From 6b4f751e4107e69850199a6471b9a34254caad6c Mon Sep 17 00:00:00 2001 From: Sebastian Mendel Date: Thu, 19 Jan 2006 15:39:29 +0000 Subject: [PATCH] fixed bug #1409972 PHP 5.1.2 compatibility --- ChangeLog | 8 + db_details_qbe.php | 378 ++++++++---------- libraries/display_tbl.lib.php | 8 +- libraries/export/htmlword.php | 8 +- libraries/export/latex.php | 8 +- libraries/import.lib.php | 2 +- libraries/ip_allow_deny.lib.php | 4 +- libraries/transformations.lib.php | 4 +- .../text_plain__external.inc.php | 2 +- pdf_schema.php | 2 +- 10 files changed, 201 insertions(+), 223 deletions(-) diff --git a/ChangeLog b/ChangeLog index 651caf253..dd0cb5c42 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,14 @@ phpMyAdmin - Changelog $Id$ $Source$ +2006-01-19 Sebastian Mendel + * pdf_schema.php, db_details_qbe.php, libraries\display_tbl.lib.php, + libraries\export\htmlword.php, libraries\export\latex.php, + libraries\import.lib.php, libraries\ip_allow_deny.lib.php, + libraries\transformations.lib.php, + libraries\transformations\text_plain__external.inc.php: + fixed bug #1409972 PHP 5.1.2 compatibility + 2006-01-18 Michal Čihař * Documentation.html: Add info about Apache CGI and http auth (patch #1375495). diff --git a/db_details_qbe.php b/db_details_qbe.php index ff4ed541d..a2baf4389 100644 --- a/db_details_qbe.php +++ b/db_details_qbe.php @@ -3,8 +3,11 @@ // vim: expandtab sw=4 ts=4 sts=4: /** - * Get the values of the variables posted or sent to this script and display - * the headers + * query by example the whole database + */ + +/** + * requirements */ require_once('./libraries/common.lib.php'); require_once('./libraries/relation.lib.php'); @@ -19,98 +22,64 @@ $cfgRelation = PMA_getRelationsParam(); /** * A query has been submitted -> execute it, else display the headers */ -if (isset($submit_sql) && preg_match('@^SELECT@i', $encoded_sql_query)) { +if ( isset( $_REQUEST['submit_sql'] ) + && preg_match('@^SELECT@i', $_REQUEST['encoded_sql_query']) ) { $goto = 'db_details.php'; - $zero_rows = htmlspecialchars($strSuccess); - $sql_query = urldecode($encoded_sql_query); + $zero_rows = htmlspecialchars($GLOBALS['strSuccess']); + $sql_query = urldecode($_REQUEST['encoded_sql_query']); require('./sql.php'); exit(); } else { $sub_part = '_qbe'; require('./libraries/db_details_common.inc.php'); $url_query .= '&goto=db_details_qbe.php'; + $url_params['goto'] = 'db_details_qbe.php'; require('./libraries/db_details_db_info.inc.php'); } -if (isset($submit_sql) && !preg_match('@^SELECT@i', $encoded_sql_query)) { - echo '

' . $strHaveToShow . '

'; +if ( isset($_REQUEST['submit_sql'] ) + && ! preg_match('@^SELECT@i', $_REQUEST['encoded_sql_query']) ) { + echo '
' . $GLOBALS['strHaveToShow'] . '
'; } /** * Initialize some variables */ -if (empty($Columns)) { - $Columns = 3; // Initial number of columns -} -if (!isset($Add_Col)) { - $Add_Col = ''; -} -if (!isset($Add_Row)) { - $Add_Row = ''; -} -if (!isset($Rows)) { - $Rows = ''; -} -if (!isset($InsCol)) { - $InsCol = array(); -} -if (!isset($DelCol)) { - $DelCol = array(); -} -if (!isset($prev_Criteria)) { - $prev_Criteria = ''; -} -if (!isset($Criteria)) { - $Criteria = array(); - for ($i = 0; $i < $Columns; $i++) { - $Criteria[$i] = ''; - } -} -if (!isset($InsRow)) { - $InsRow = array(); - for ($i = 0; $i < $Columns; $i++) { - $InsRow[$i] = ''; - } -} -if (!isset($DelRow)) { - $DelRow = array(); - for ($i = 0; $i < $Columns; $i++) { - $DelRow[$i] = ''; - } -} -if (!isset($AndOrRow)) { - $AndOrRow = array(); - for ($i = 0; $i < $Columns; $i++) { - $AndOrRow[$i] = ''; - } -} -if (!isset($AndOrCol)) { - $AndOrCol = array(); - for ($i = 0; $i < $Columns; $i++) { - $AndOrCol[$i] = ''; - } -} +$col_cnt = isset( $_REQUEST['col_cnt'] ) ? (int) $_REQUEST['col_cnt'] : 3; +$add_col = isset( $_REQUEST['add_col'] ) ? (int) $_REQUEST['add_col'] : 0; +$add_row = isset( $_REQUEST['add_row'] ) ? (int) $_REQUEST['add_row'] : 0; + +$rows = isset( $_REQUEST['rows'] ) ? (int) $_REQUEST['rows'] : 0; +$ins_col = isset( $_REQUEST['ins_col'] ) ? $_REQUEST['ins_col'] : array(); +$del_col = isset( $_REQUEST['del_col'] ) ? $_REQUEST['del_col'] : array(); + +$prev_criteria = isset( $_REQUEST['prev_criteria'] ) + ? $_REQUEST['prev_criteria'] + : array(); +$criteria = isset( $_REQUEST['criteria'] ) + ? $_REQUEST['criteria'] + : array_fill(0, $col_cnt, ''); + +$ins_row = isset( $_REQUEST['ins_row'] ) + ? $_REQUEST['ins_row'] + : array_fill(0, $col_cnt, ''); +$del_row = isset( $_REQUEST['del_row'] ) + ? $_REQUEST['del_row'] + : array_fill(0, $col_cnt, ''); +$and_or_row = isset( $_REQUEST['and_or_row'] ) + ? $_REQUEST['and_or_row'] + : array_fill(0, $col_cnt, ''); +$and_or_col = isset( $_REQUEST['and_or_col'] ) + ? $_REQUEST['and_or_col'] + : array_fill(0, $col_cnt, ''); + // minimum width -$wid = 12; -$col = $Columns + $Add_Col; -if ($col < 0) { - $col = 0; -} -$row = $Rows + $Add_Row; -if ($row < 0) { - $row = 0; -} +$form_column_width = 12; +$col = max($col_cnt + $add_col, 0); +$row = max($rows + $add_row, 0); -/** - * Prepares the form - */ -$tbl_result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE); -$tbl_result_cnt = PMA_DBI_num_rows($tbl_result); -$i = 0; -$k = 0; - // The tables list sent by a previously submitted form if (!empty($TableList)) { $cnt_table_list = count($TableList); @@ -119,6 +88,19 @@ if (!empty($TableList)) { } } // end if + +$columns = PMA_DBI_get_columns_full( $GLOBALS['db'] ); +$tables = PMA_DBI_get_columns_full( $GLOBALS['db'] ); + + +/** + * Prepares the form + */ +$tbl_result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', null, PMA_DBI_QUERY_STORE); +$tbl_result_cnt = PMA_DBI_num_rows($tbl_result); +$i = 0; +$k = 0; + // The tables list gets from MySQL while ($i < $tbl_result_cnt) { list($tbl) = PMA_DBI_fetch_row($tbl_result); @@ -140,8 +122,8 @@ while ($i < $tbl_result_cnt) { $fld[$k] = PMA_backquote($tbl) . '.' . PMA_backquote($fld[$k]); // increase the width if necessary - if (strlen($fld[$k]) > $wid) { - $wid = strlen($fld[$k]); + if (strlen($fld[$k]) > $form_column_width) { + $form_column_width = strlen($fld[$k]); } //end if $k++; @@ -154,88 +136,76 @@ while ($i < $tbl_result_cnt) { PMA_DBI_free_result($tbl_result); // largest width found -$realwidth = $wid . 'ex'; +$realwidth = $form_column_width . 'ex'; /** - * Displays the form + * Displays the Query by example form */ -?> - -
- - - - - - - - + ' . htmlspecialchars($fld[$y]) . '' . "\n"; - } // end for - ?> - - - - +} - - - +?> + + +
- - - - + - +
- -
+ + + + + + + + @@ -390,26 +360,26 @@ for ($y = 0; $y <= $row; $y++) { @@ -418,7 +388,7 @@ for ($y = 0; $y <= $row; $y++) { @@ -428,7 +398,7 @@ for ($y = 0; $y <= $row; $y++) {
+ : +
+ : + @@ -310,7 +280,7 @@ for ($x = 0; $x < $col; $x++) { } // end if echo "\n"; - if (!empty($DelCol) && isset($DelCol[$x]) && $DelCol[$x] == 'on') { + if (!empty($del_col) && isset($del_col[$x]) && $del_col[$x] == 'on') { continue; } if (isset($Show[$x])) { @@ -338,34 +308,34 @@ for ($x = 0; $x < $col; $x++) { - + - - + +
: - + : - /> + />  
: - + : - /> + />  
: - + : - /> + />
: - + : - /> + />
@@ -497,7 +467,7 @@ for ($y = 0; $y <= $row; $y++) { @@ -507,7 +477,7 @@ for ($y = 0; $y <= $row; $y++) { : - /> + />   : - /> + />
- +    - + : - /> + />   : - /> + />
- +    - + - + - + : - @@ -631,7 +601,7 @@ for ($x = 0; $x < $col; $x++) {   : - @@ -658,7 +628,7 @@ for ($x = 0; $x < $col; $x++) { $val) { +foreach ($tbl_names AS $key => $val) { $strTableListOptions .= ' '; $strTableListOptions .= '' . "\n"; $numTableListOptions++; @@ -729,7 +699,7 @@ if (isset($Field) && count($Field) > 0) { // Check 'where' clauses if ($cfgRelation['relwork'] && count($tab_all) > 0) { // Now we need all tables that we have in the where clause - $crit_cnt = count($Criteria); + $crit_cnt = count($criteria); for ($x = 0; $x < $crit_cnt; $x++) { $curr_tab = explode('.', urldecode($Field[$x])); if (!empty($curr_tab[0]) && !empty($curr_tab[1])) { @@ -739,10 +709,10 @@ if (isset($Field) && count($Field) > 0) { $col_raw = urldecode($curr_tab[1]); $col1 = str_replace('`', '', $col_raw); $col1 = $tab . '.' . $col1; - // Now we know that our array has the same numbers as $Criteria + // Now we know that our array has the same numbers as $criteria // we can check which of our columns has a where clause - if (!empty($Criteria[$x])) { - if (substr($Criteria[$x], 0, 1) == '=' || stristr($Criteria[$x], 'is')) { + if (!empty($criteria[$x])) { + if (substr($criteria[$x], 0, 1) == '=' || stristr($criteria[$x], 'is')) { $col_where[$col] = $col1; $tab_wher[$tab] = $tab; } @@ -791,10 +761,10 @@ if (isset($Field) && count($Field) > 0) { if (isset($col_unique) && count($col_unique) > 0) { $col_cand = $col_unique; $needsort = 1; - } else if (isset($col_index) && count($col_index) > 0) { + } elseif (isset($col_index) && count($col_index) > 0) { $col_cand = $col_index; $needsort = 1; - } else if (isset($col_where) && count($col_where) > 0) { + } elseif (isset($col_where) && count($col_where) > 0) { $col_cand = $tab_wher; $needsort = 0; } else { diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php index 11c3de615..e5fdd276c 100644 --- a/libraries/display_tbl.lib.php +++ b/libraries/display_tbl.lib.php @@ -103,7 +103,7 @@ function PMA_setDisplayMode(&$the_disp_mode, &$the_total) // 2.2 Statement is a "SHOW..." elseif ($GLOBALS['is_show']) { // 2.2.1 TODO : defines edit/delete links depending on show statement - $tmp = preg_match('@^SHOW[[:space:]]+(VARIABLES|(FULL[[:space:]]+)?PROCESSLIST|STATUS|TABLE|GRANTS|CREATE|LOGS|DATABASES|FIELDS)@i', $GLOBALS['sql_query'], $which = array() ); + $tmp = preg_match('@^SHOW[[:space:]]+(VARIABLES|(FULL[[:space:]]+)?PROCESSLIST|STATUS|TABLE|GRANTS|CREATE|LOGS|DATABASES|FIELDS)@i', $GLOBALS['sql_query'], $which); if (isset($which[1]) && strpos(' ' . strtoupper($which[1]), 'PROCESSLIST') > 0) { $do_display['edit_lnk'] = 'nn'; // no edit link $do_display['del_lnk'] = 'kp'; // "kill process" type edit link @@ -478,7 +478,7 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $ $sort_expression = trim(str_replace(' ', ' ', $analyzed_sql[0]['order_by_clause'])); // Get rid of ASC|DESC (TODO: analyzer) - preg_match('@(.*)([[:space:]]*(ASC|DESC))@si', $sort_expression, $matches = array()); + preg_match('@(.*)([[:space:]]*(ASC|DESC))@si', $sort_expression, $matches); $sort_expression_nodir = isset($matches[1]) ? trim($matches[1]) : $sort_expression; // sorting by indexes, only if it makes sense (only one table ref) @@ -740,7 +740,7 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $ // FROM `PMA_relation` AS `1` , `PMA_relation` AS `2` if (($is_join - && !preg_match('~([^[:space:],]|`[^`]`)[[:space:]]+(as[[:space:]]+)?' . strtr($fields_meta[$i]->name, array('[' => '\\[', '~' => '\\~', '\\' => '\\\\')) . '~i', $select_expr, $parts = array())) + && !preg_match('~([^[:space:],]|`[^`]`)[[:space:]]+(as[[:space:]]+)?' . strtr($fields_meta[$i]->name, array('[' => '\\[', '~' => '\\~', '\\' => '\\\\')) . '~i', $select_expr, $parts)) || ( isset($analyzed_sql[0]['select_expr'][$i]['expr']) && isset($analyzed_sql[0]['select_expr'][$i]['column']) && $analyzed_sql[0]['select_expr'][$i]['expr'] != @@ -792,7 +792,7 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $ $order_img = ' '. $GLOBALS['strAscending'] . ''; } - if (preg_match('@(.*)([[:space:]](LIMIT (.*)|PROCEDURE (.*)|FOR UPDATE|LOCK IN SHARE MODE))@i', $unsorted_sql_query, $regs3 = array())) { + if (preg_match('@(.*)([[:space:]](LIMIT (.*)|PROCEDURE (.*)|FOR UPDATE|LOCK IN SHARE MODE))@i', $unsorted_sql_query, $regs3)) { $sorted_sql_query = $regs3[1] . $sort_order . $regs3[2]; } else { $sorted_sql_query = $unsorted_sql_query . $sort_order; diff --git a/libraries/export/htmlword.php b/libraries/export/htmlword.php index 7a4794c63..c9219916f 100644 --- a/libraries/export/htmlword.php +++ b/libraries/export/htmlword.php @@ -244,7 +244,7 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals $type = $row['Type']; // reformat mysql query output - staybyte - 9. June 2001 // loic1: set or enum types: slashes single quotes inside options - if (eregi('^(set|enum)\((.+)\)$', $type, $tmp = array())) { + if (eregi('^(set|enum)\((.+)\)$', $type, $tmp)) { $tmp[2] = substr(ereg_replace('([^,])\'\'', '\\1\\\'', ',' . $tmp[2]), 1); $type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')'; $type_nowrap = ''; @@ -261,9 +261,9 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals $type = ' '; } - $binary = eregi('BINARY', $row['Type'], $test = array()); - $unsigned = eregi('UNSIGNED', $row['Type'], $test = array()); - $zerofill = eregi('ZEROFILL', $row['Type'], $test = array()); + $binary = eregi('BINARY', $row['Type']); + $unsigned = eregi('UNSIGNED', $row['Type']); + $zerofill = eregi('ZEROFILL', $row['Type']); } $strAttribute = ' '; if ($binary) { diff --git a/libraries/export/latex.php b/libraries/export/latex.php index 4b74142ae..1a0bf2d65 100644 --- a/libraries/export/latex.php +++ b/libraries/export/latex.php @@ -332,7 +332,7 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals $type = $row['Type']; // reformat mysql query output - staybyte - 9. June 2001 // loic1: set or enum types: slashes single quotes inside options - if (eregi('^(set|enum)\((.+)\)$', $type, $tmp = array())) { + if (eregi('^(set|enum)\((.+)\)$', $type, $tmp)) { $tmp[2] = substr(ereg_replace('([^,])\'\'', '\\1\\\'', ',' . $tmp[2]), 1); $type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')'; $type_nowrap = ''; @@ -349,9 +349,9 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals $type = ' '; } - $binary = eregi('BINARY', $row['Type'], $test = array()); - $unsigned = eregi('UNSIGNED', $row['Type'], $test = array()); - $zerofill = eregi('ZEROFILL', $row['Type'], $test = array()); + $binary = eregi('BINARY', $row['Type']); + $unsigned = eregi('UNSIGNED', $row['Type']); + $zerofill = eregi('ZEROFILL', $row['Type']); } $strAttribute = ' '; if ($binary) { diff --git a/libraries/import.lib.php b/libraries/import.lib.php index 61bcad686..0562575d5 100644 --- a/libraries/import.lib.php +++ b/libraries/import.lib.php @@ -136,7 +136,7 @@ function PMA_importRunQuery($sql = '', $full = '') } // If a 'USE ' SQL-clause was found and the query succeeded, set our current $db to the new one - if ($result != FALSE && preg_match('@^[\s]*USE[[:space:]]*([\S]+)@i', $import_run_buffer['sql'], $match = array() )) { + if ($result != FALSE && preg_match('@^[\s]*USE[[:space:]]*([\S]+)@i', $import_run_buffer['sql'], $match)) { $db = trim($match[1]); $reload = TRUE; } diff --git a/libraries/ip_allow_deny.lib.php b/libraries/ip_allow_deny.lib.php index d4caadb2c..f603dff3a 100644 --- a/libraries/ip_allow_deny.lib.php +++ b/libraries/ip_allow_deny.lib.php @@ -123,7 +123,7 @@ function PMA_getIp() // True IP without proxy return $direct_ip; } else { - $is_ip = preg_match('|^([0-9]{1,3}\.){3,3}[0-9]{1,3}|', $proxy_ip, $regs = array()); + $is_ip = preg_match('|^([0-9]{1,3}\.){3,3}[0-9]{1,3}|', $proxy_ip, $regs); if ($is_ip && (count($regs) > 0)) { // True IP behind a proxy return $regs[0]; @@ -161,7 +161,7 @@ function PMA_ipMaskTest($testRange, $ipToTest) { $result = TRUE; - if (preg_match('|([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)/([0-9]+)|', $testRange, $regs = array())) { + if (preg_match('|([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)/([0-9]+)|', $testRange, $regs)) { // performs a mask match $ipl = ip2long($ipToTest); $rangel = ip2long($regs[1] . '.' . $regs[2] . '.' . $regs[3] . '.' . $regs[4]); diff --git a/libraries/transformations.lib.php b/libraries/transformations.lib.php index a342e85f9..6b3f3af53 100644 --- a/libraries/transformations.lib.php +++ b/libraries/transformations.lib.php @@ -50,7 +50,7 @@ function PMA_getAvailableMIMEtypes() { @ksort($filestack); foreach ($filestack AS $key => $file) { - if (preg_match('|^.*__.*\.inc\.php$|', trim($file), $match = array())) { + if (preg_match('|^.*__.*\.inc\.php$|', trim($file))) { // File contains transformation functions. $base = explode('__', str_replace('.inc.php', '', $file)); $mimetype = str_replace('_', '/', $base[0]); @@ -59,7 +59,7 @@ function PMA_getAvailableMIMEtypes() { $stack['transformation'][] = $mimetype . ': ' . $base[1]; $stack['transformation_file'][] = $file; - } elseif (preg_match('|^.*\.inc\.php$|', trim($file), $match)) { + } elseif (preg_match('|^.*\.inc\.php$|', trim($file))) { // File is a plain mimetype, no functions. $base = str_replace('.inc.php', '', $file); diff --git a/libraries/transformations/text_plain__external.inc.php b/libraries/transformations/text_plain__external.inc.php index 983047ad9..b0520245e 100644 --- a/libraries/transformations/text_plain__external.inc.php +++ b/libraries/transformations/text_plain__external.inc.php @@ -67,7 +67,7 @@ function PMA_transformation_text_plain__external($buffer, $options = array(), $m 0 => array("pipe", "r"), 1 => array("pipe", "w") ); - $process = proc_open($program . ' ' . $poptions, $descriptorspec, $pipes = array()); + $process = proc_open($program . ' ' . $poptions, $descriptorspec, $pipes); if (is_resource($process)) { fwrite($pipes[0], $buffer); fclose($pipes[0]); diff --git a/pdf_schema.php b/pdf_schema.php index 811faf2c9..2db981a8f 100644 --- a/pdf_schema.php +++ b/pdf_schema.php @@ -1293,7 +1293,7 @@ function PMA_RT_DOC($alltables) $type = $row['Type']; // reformat mysql query output - staybyte - 9. June 2001 // loic1: set or enum types: slashes single quotes inside options - if (preg_match('@^(set|enum)\((.+)\)$@i', $type, $tmp = array())) { + if (preg_match('@^(set|enum)\((.+)\)$@i', $type, $tmp)) { $tmp[2] = substr(preg_replace("@([^,])''@", "\\1\\'", ',' . $tmp[2]), 1); $type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')'; $type_nowrap = '';