From 0d4ccd012d3c8046eceb2a5019cdba7754bdbaae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 18 Jul 2011 10:06:31 +0200 Subject: [PATCH 1/6] Use old_offset instead of strlen It is really not needed to use real data as we have the offset stored anyway. --- libraries/zip.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/zip.lib.php b/libraries/zip.lib.php index 443b173783..672b00a23f 100644 --- a/libraries/zip.lib.php +++ b/libraries/zip.lib.php @@ -205,7 +205,7 @@ class zipfile pack('v', sizeof($this -> ctrl_dir)) . // total # of entries "on this disk" pack('v', sizeof($this -> ctrl_dir)) . // total # of entries overall pack('V', strlen($ctrldir)) . // size of central dir - pack('V', strlen($data)) . // offset to start of central dir + pack('V', $this -> old_offset) . // offset to start of central dir "\x00\x00"; // .zip file comment length if ( $this -> doWrite ) { // Send central directory & end ctrl dir to STDOUT From d867d7787da206402c382ad334b8b2a7aa085f4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 18 Jul 2011 10:09:03 +0200 Subject: [PATCH 2/6] Remove commented out code --- libraries/zip.lib.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/libraries/zip.lib.php b/libraries/zip.lib.php index 672b00a23f..e5b18290d1 100644 --- a/libraries/zip.lib.php +++ b/libraries/zip.lib.php @@ -147,14 +147,6 @@ class zipfile // "file data" segment $fr .= $zdata; - // "data descriptor" segment (optional but necessary if archive is not - // served as file) - // this seems not to be needed at all and causes - // problems in some cases (bug #1037737) - //$fr .= pack('V', $crc); // crc32 - //$fr .= pack('V', $c_len); // compressed filesize - //$fr .= pack('V', $unc_len); // uncompressed filesize - // echo this entry on the fly, ... if ( $this -> doWrite) { echo $fr; From 6c45a67d884552b73b54435a5fb957f5f401bd23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 18 Jul 2011 10:10:17 +0200 Subject: [PATCH 3/6] Update references, remove non existing ones --- libraries/zip.lib.php | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/libraries/zip.lib.php b/libraries/zip.lib.php index e5b18290d1..23f28ceee2 100644 --- a/libraries/zip.lib.php +++ b/libraries/zip.lib.php @@ -9,18 +9,7 @@ * Zip file creation class. * Makes zip files. * - * Based on : - * - * http://www.zend.com/codex.php?id=535&single=1 - * By Eric Mueller - * - * http://www.zend.com/codex.php?id=470&single=1 - * by Denis125 - * - * a patch from Peter Listiak for last modified - * date and time of the compressed file - * - * Official ZIP file format: http://www.pkware.com/appnote.txt + * @see Official ZIP file format: http://www.pkware.com/support/zip-app-note * * @access public * @package phpMyAdmin From ba9e74bb855deb71598d68081e92879820aaf0be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 18 Jul 2011 10:17:46 +0200 Subject: [PATCH 4/6] Function file_get_contents is available since PHP 4.3.0, no need to check for it --- libraries/Config.class.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/libraries/Config.class.php b/libraries/Config.class.php index 9c7ab4804d..1a678f07f9 100644 --- a/libraries/Config.class.php +++ b/libraries/Config.class.php @@ -353,13 +353,7 @@ class PMA_Config * Parses the configuration file */ $old_error_reporting = error_reporting(0); - if (function_exists('file_get_contents')) { - $eval_result = - eval('?' . '>' . trim(file_get_contents($this->getSource()))); - } else { - $eval_result = - eval('?' . '>' . trim(implode("\n", file($this->getSource())))); - } + $eval_result = eval('?' . '>' . trim(file_get_contents($this->getSource()))); error_reporting($old_error_reporting); if ($eval_result === false) { From f48846cbc048641c59805a2cbe11b17f76fc2119 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 18 Jul 2011 10:18:31 +0200 Subject: [PATCH 5/6] Document why eval is used --- libraries/Config.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/Config.class.php b/libraries/Config.class.php index 1a678f07f9..942ee9e2d4 100644 --- a/libraries/Config.class.php +++ b/libraries/Config.class.php @@ -350,7 +350,8 @@ class PMA_Config $cfg = array(); /** - * Parses the configuration file + * Parses the configuration file, the eval is used here to avoid + * problems with trailing whitespace, what is often a problem. */ $old_error_reporting = error_reporting(0); $eval_result = eval('?' . '>' . trim(file_get_contents($this->getSource()))); From 1b5691656ef67e5f07c5e218f2dacc6d36ae0a77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 18 Jul 2011 10:27:50 +0200 Subject: [PATCH 6/6] Use PMA_DBI_get_columns instead of own query --- libraries/export/htmlword.php | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/libraries/export/htmlword.php b/libraries/export/htmlword.php index e662cfb52d..ddc18ac4d5 100644 --- a/libraries/export/htmlword.php +++ b/libraries/export/htmlword.php @@ -213,9 +213,6 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals * Gets fields properties */ PMA_DBI_select_db($db); - $local_query = 'SHOW FIELDS FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table); - $result = PMA_DBI_query($local_query); - $fields_cnt = PMA_DBI_num_rows($result); // Check if we can use Relations if ($do_relation && ! empty($cfgRelation['relation'])) { @@ -272,10 +269,11 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals return false; } - while ($row = PMA_DBI_fetch_assoc($result)) { + $columns = PMA_DBI_get_columns($db, $table); + foreach ($columns as $column) { $schema_insert = ''; - $type = $row['Type']; + $type = $column['Type']; // reformat mysql query output // set or enum types: slashes single quotes inside options if (preg_match('/^(set|enum)\((.+)\)$/i', $type, $tmp)) { @@ -295,9 +293,9 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals $type = ' '; } - $binary = preg_match('/BINARY/i', $row['Type']); - $unsigned = preg_match('/UNSIGNED/i', $row['Type']); - $zerofill = preg_match('/ZEROFILL/i', $row['Type']); + $binary = preg_match('/BINARY/i', $column['Type']); + $unsigned = preg_match('/UNSIGNED/i', $column['Type']); + $zerofill = preg_match('/ZEROFILL/i', $column['Type']); } $attribute = ' '; if ($binary) { @@ -309,28 +307,28 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals if ($zerofill) { $attribute = 'UNSIGNED ZEROFILL'; } - if (! isset($row['Default'])) { - if ($row['Null'] != 'NO') { - $row['Default'] = 'NULL'; + if (! isset($column['Default'])) { + if ($column['Null'] != 'NO') { + $column['Default'] = 'NULL'; } } $fmt_pre = ''; $fmt_post = ''; - if (in_array($row['Field'], $unique_keys)) { + if (in_array($column['Field'], $unique_keys)) { $fmt_pre = '' . $fmt_pre; $fmt_post = $fmt_post . ''; } - if ($row['Key'] == 'PRI') { + if ($column['Key'] == 'PRI') { $fmt_pre = '' . $fmt_pre; $fmt_post = $fmt_post . ''; } - $schema_insert .= '' . $fmt_pre . htmlspecialchars($row['Field']) . $fmt_post . ''; + $schema_insert .= '' . $fmt_pre . htmlspecialchars($column['Field']) . $fmt_post . ''; $schema_insert .= '' . htmlspecialchars($type) . ''; - $schema_insert .= '' . htmlspecialchars(($row['Null'] == '' || $row['Null'] == 'NO') ? __('No') : __('Yes')) . ''; - $schema_insert .= '' . htmlspecialchars(isset($row['Default']) ? $row['Default'] : '') . ''; + $schema_insert .= '' . htmlspecialchars(($column['Null'] == '' || $column['Null'] == 'NO') ? __('No') : __('Yes')) . ''; + $schema_insert .= '' . htmlspecialchars(isset($column['Default']) ? $column['Default'] : '') . ''; - $field_name = $row['Field']; + $field_name = $column['Field']; if ($do_relation && $have_rel) { $schema_insert .= '' . (isset($res_rel[$field_name]) ? htmlspecialchars($res_rel[$field_name]['foreign_table'] . ' (' . $res_rel[$field_name]['foreign_field'] . ')') : '') . '';