fixed bug #1409972 PHP 5.1.2 compatibility

This commit is contained in:
Sebastian Mendel
2006-01-19 15:39:29 +00:00
parent bcfcf84c8b
commit 6b4f751e41
10 changed files with 201 additions and 223 deletions

View File

@@ -5,6 +5,14 @@ phpMyAdmin - Changelog
$Id$ $Id$
$Source$ $Source$
2006-01-19 Sebastian Mendel <cybot_tm@users.sourceforge.net>
* 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ř <michal@cihar.com> 2006-01-18 Michal Čihař <michal@cihar.com>
* Documentation.html: Add info about Apache CGI and http auth (patch * Documentation.html: Add info about Apache CGI and http auth (patch
#1375495). #1375495).

View File

@@ -3,8 +3,11 @@
// vim: expandtab sw=4 ts=4 sts=4: // vim: expandtab sw=4 ts=4 sts=4:
/** /**
* Get the values of the variables posted or sent to this script and display * query by example the whole database
* the headers */
/**
* requirements
*/ */
require_once('./libraries/common.lib.php'); require_once('./libraries/common.lib.php');
require_once('./libraries/relation.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 * 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'; $goto = 'db_details.php';
$zero_rows = htmlspecialchars($strSuccess); $zero_rows = htmlspecialchars($GLOBALS['strSuccess']);
$sql_query = urldecode($encoded_sql_query); $sql_query = urldecode($_REQUEST['encoded_sql_query']);
require('./sql.php'); require('./sql.php');
exit(); exit();
} else { } else {
$sub_part = '_qbe'; $sub_part = '_qbe';
require('./libraries/db_details_common.inc.php'); require('./libraries/db_details_common.inc.php');
$url_query .= '&amp;goto=db_details_qbe.php'; $url_query .= '&amp;goto=db_details_qbe.php';
$url_params['goto'] = 'db_details_qbe.php';
require('./libraries/db_details_db_info.inc.php'); require('./libraries/db_details_db_info.inc.php');
} }
if (isset($submit_sql) && !preg_match('@^SELECT@i', $encoded_sql_query)) { if ( isset($_REQUEST['submit_sql'] )
echo '<p class="warning">' . $strHaveToShow . '</p>'; && ! preg_match('@^SELECT@i', $_REQUEST['encoded_sql_query']) ) {
echo '<div class="warning">' . $GLOBALS['strHaveToShow'] . '</div>';
} }
/** /**
* Initialize some variables * Initialize some variables
*/ */
if (empty($Columns)) { $col_cnt = isset( $_REQUEST['col_cnt'] ) ? (int) $_REQUEST['col_cnt'] : 3;
$Columns = 3; // Initial number of columns $add_col = isset( $_REQUEST['add_col'] ) ? (int) $_REQUEST['add_col'] : 0;
} $add_row = isset( $_REQUEST['add_row'] ) ? (int) $_REQUEST['add_row'] : 0;
if (!isset($Add_Col)) {
$Add_Col = ''; $rows = isset( $_REQUEST['rows'] ) ? (int) $_REQUEST['rows'] : 0;
} $ins_col = isset( $_REQUEST['ins_col'] ) ? $_REQUEST['ins_col'] : array();
if (!isset($Add_Row)) { $del_col = isset( $_REQUEST['del_col'] ) ? $_REQUEST['del_col'] : array();
$Add_Row = '';
} $prev_criteria = isset( $_REQUEST['prev_criteria'] )
if (!isset($Rows)) { ? $_REQUEST['prev_criteria']
$Rows = ''; : array();
} $criteria = isset( $_REQUEST['criteria'] )
if (!isset($InsCol)) { ? $_REQUEST['criteria']
$InsCol = array(); : array_fill(0, $col_cnt, '');
}
if (!isset($DelCol)) { $ins_row = isset( $_REQUEST['ins_row'] )
$DelCol = array(); ? $_REQUEST['ins_row']
} : array_fill(0, $col_cnt, '');
if (!isset($prev_Criteria)) { $del_row = isset( $_REQUEST['del_row'] )
$prev_Criteria = ''; ? $_REQUEST['del_row']
} : array_fill(0, $col_cnt, '');
if (!isset($Criteria)) { $and_or_row = isset( $_REQUEST['and_or_row'] )
$Criteria = array(); ? $_REQUEST['and_or_row']
for ($i = 0; $i < $Columns; $i++) { : array_fill(0, $col_cnt, '');
$Criteria[$i] = ''; $and_or_col = isset( $_REQUEST['and_or_col'] )
} ? $_REQUEST['and_or_col']
} : array_fill(0, $col_cnt, '');
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] = '';
}
}
// minimum width // minimum width
$wid = 12; $form_column_width = 12;
$col = $Columns + $Add_Col; $col = max($col_cnt + $add_col, 0);
if ($col < 0) { $row = max($rows + $add_row, 0);
$col = 0;
}
$row = $Rows + $Add_Row;
if ($row < 0) {
$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 // The tables list sent by a previously submitted form
if (!empty($TableList)) { if (!empty($TableList)) {
$cnt_table_list = count($TableList); $cnt_table_list = count($TableList);
@@ -119,6 +88,19 @@ if (!empty($TableList)) {
} }
} // end if } // 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 // The tables list gets from MySQL
while ($i < $tbl_result_cnt) { while ($i < $tbl_result_cnt) {
list($tbl) = PMA_DBI_fetch_row($tbl_result); 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]); $fld[$k] = PMA_backquote($tbl) . '.' . PMA_backquote($fld[$k]);
// increase the width if necessary // increase the width if necessary
if (strlen($fld[$k]) > $wid) { if (strlen($fld[$k]) > $form_column_width) {
$wid = strlen($fld[$k]); $form_column_width = strlen($fld[$k]);
} //end if } //end if
$k++; $k++;
@@ -154,88 +136,76 @@ while ($i < $tbl_result_cnt) {
PMA_DBI_free_result($tbl_result); PMA_DBI_free_result($tbl_result);
// largest width found // largest width found
$realwidth = $wid . 'ex'; $realwidth = $form_column_width . 'ex';
/** /**
* Displays the form * Displays the Query by example form
*/ */
?>
<!-- Query by example form --> function showColumnSelectCell( $columns, $column_number, $selected = '' )
<form action="db_details_qbe.php" method="post"> {
<table border="<?php echo $cfg['Border']; ?>" cellpadding="2" cellspacing="1">
<!-- Fields row -->
<tr>
<td class="tblHeaders" align="<?php echo $cell_align_right; ?>">
<b><?php echo $strField; ?>:&nbsp;</b>
</td>
<?php
$z = 0;
for ($x = 0; $x < $col; $x++) {
if (!empty($InsCol) && isset($InsCol[$x]) && $InsCol[$x] == 'on') {
?> ?>
<td align="center" bgcolor="<?php echo $cfg['BgcolorOne']; ?>"> <td align="center">
<select style="width: <?php echo $realwidth; ?>" name="Field[<?php echo $z; ?>]" size="1"> <select name="Field[<?php echo $column_number; ?>]" size="1">
<option value=""></option> <option value=""></option>
<?php <?php
echo "\n"; foreach ( $columns as $column ) {
for ($y = 0; $y < sizeof($fld); $y++) { if ( $column === $selected ) {
if ($fld[$y] == '') {
$sel = ' selected="selected"'; $sel = ' selected="selected"';
} else { } else {
$sel = ''; $sel = '';
} }
echo ' '; echo ' ';
echo '<option value="' . htmlspecialchars($fld[$y]) . '"' . $sel . '>' . htmlspecialchars($fld[$y]) . '</option>' . "\n"; echo '<option value="' . htmlspecialchars($column) . '"' . $sel . '>'
} // end for . htmlspecialchars($column) . '</option>' . "\n";
}
?> ?>
</select> </select>
</td> </td>
<?php <?php
$z++; }
} // end if
echo "\n";
if (!empty($DelCol) && isset($DelCol[$x]) && $DelCol[$x] == 'on') { ?>
<form action="db_details_qbe.php" method="post">
<table>
<tr class="odd">
<th align="<?php echo $cell_align_right; ?>">
<?php echo $strField; ?>:
</th>
<?php
$z = 0;
for ($x = 0; $x < $col; $x++) {
if ( isset($ins_col[$x]) && $ins_col[$x] == 'on') {
showColumnSelectCell( $fld, $z );
$z++;
}
if (!empty($del_col) && isset($del_col[$x]) && $del_col[$x] == 'on') {
continue; continue;
} }
?>
<td align="center" bgcolor="<?php echo $cfg['BgcolorOne']; ?>"> $selected = '';
<select style="width: <?php echo $realwidth; ?>" name="Field[<?php echo $z; ?>]" size="1"> if ( isset( $Field[$x] ) ) {
<option value=""></option> $selected = urldecode($Field[$x]);
<?php
echo "\n";
for ($y = 0; $y < sizeof($fld); $y++) {
if (isset($Field[$x]) && $fld[$y] == urldecode($Field[$x])) {
$curField[$z] = urldecode($Field[$x]); $curField[$z] = urldecode($Field[$x]);
$sel = ' selected="selected"'; }
} else { showColumnSelectCell( $fld, $z, $selected );
$sel = '';
} // end if
echo ' ';
echo '<option value="' . htmlspecialchars($fld[$y]) . '"' . $sel . '>' . htmlspecialchars($fld[$y]) . '</option>' . "\n";
} // end for
?>
</select>
</td>
<?php
$z++; $z++;
echo "\n";
} // end for } // end for
?> ?>
</tr> </tr>
<!-- Sort row --> <!-- Sort row -->
<tr> <tr class="even">
<td class="tblHeaders" align="<?php echo $cell_align_right; ?>"> <th align="<?php echo $cell_align_right; ?>">
<b><?php echo $strSort; ?>:&nbsp;</b> <?php echo $strSort; ?>:
</td> </th>
<?php <?php
$z = 0; $z = 0;
for ($x = 0; $x < $col; $x++) { for ($x = 0; $x < $col; $x++) {
if (!empty($InsCol) && isset($InsCol[$x]) && $InsCol[$x] == 'on') { if (!empty($ins_col) && isset($ins_col[$x]) && $ins_col[$x] == 'on') {
?> ?>
<td align="center" bgcolor="<?php echo $cfg['BgcolorTwo']; ?>"> <td align="center" bgcolor="<?php echo $cfg['BgcolorTwo']; ?>">
<select style="width: <?php echo $realwidth; ?>" name="Sort[<?php echo $z; ?>]" size="1"> <select style="width: <?php echo $realwidth; ?>" name="Sort[<?php echo $z; ?>]" size="1">
@@ -249,7 +219,7 @@ for ($x = 0; $x < $col; $x++) {
} // end if } // end if
echo "\n"; echo "\n";
if (!empty($DelCol) && isset($DelCol[$x]) && $DelCol[$x] == 'on') { if (!empty($del_col) && isset($del_col[$x]) && $del_col[$x] == 'on') {
continue; continue;
} }
?> ?>
@@ -300,7 +270,7 @@ for ($x = 0; $x < $col; $x++) {
<?php <?php
$z = 0; $z = 0;
for ($x = 0; $x < $col; $x++) { for ($x = 0; $x < $col; $x++) {
if (!empty($InsCol) && isset($InsCol[$x]) && $InsCol[$x] == 'on') { if (!empty($ins_col) && isset($ins_col[$x]) && $ins_col[$x] == 'on') {
?> ?>
<td class="tblHeaders" align="center" bgcolor="<?php echo $cfg['BgcolorOne']; ?>"> <td class="tblHeaders" align="center" bgcolor="<?php echo $cfg['BgcolorOne']; ?>">
<input type="checkbox" name="Show[<?php echo $z; ?>]" /> <input type="checkbox" name="Show[<?php echo $z; ?>]" />
@@ -310,7 +280,7 @@ for ($x = 0; $x < $col; $x++) {
} // end if } // end if
echo "\n"; echo "\n";
if (!empty($DelCol) && isset($DelCol[$x]) && $DelCol[$x] == 'on') { if (!empty($del_col) && isset($del_col[$x]) && $del_col[$x] == 'on') {
continue; continue;
} }
if (isset($Show[$x])) { if (isset($Show[$x])) {
@@ -338,34 +308,34 @@ for ($x = 0; $x < $col; $x++) {
<?php <?php
$z = 0; $z = 0;
for ($x = 0; $x < $col; $x++) { for ($x = 0; $x < $col; $x++) {
if (!empty($InsCol) && isset($InsCol[$x]) && $InsCol[$x] == 'on') { if (!empty($ins_col) && isset($ins_col[$x]) && $ins_col[$x] == 'on') {
?> ?>
<td align="center" bgcolor="<?php echo $cfg['BgcolorTwo']; ?>"> <td align="center" bgcolor="<?php echo $cfg['BgcolorTwo']; ?>">
<input type="text" name="Criteria[<?php echo $z; ?>]" value="" class="textfield" style="width: <?php echo $realwidth; ?>" size="20" /> <input type="text" name="criteria[<?php echo $z; ?>]" value="" class="textfield" style="width: <?php echo $realwidth; ?>" size="20" />
</td> </td>
<?php <?php
$z++; $z++;
} // end if } // end if
echo "\n"; echo "\n";
if (!empty($DelCol) && isset($DelCol[$x]) && $DelCol[$x] == 'on') { if (!empty($del_col) && isset($del_col[$x]) && $del_col[$x] == 'on') {
continue; continue;
} }
if (isset($Criteria[$x])) { if (isset($criteria[$x])) {
$stripped_Criteria = $Criteria[$x]; $stripped_Criteria = $criteria[$x];
} }
if ((empty($prev_Criteria) || !isset($prev_Criteria[$x])) if ((empty($prev_criteria) || !isset($prev_criteria[$x]))
|| urldecode($prev_Criteria[$x]) != htmlspecialchars($stripped_Criteria)) { || urldecode($prev_criteria[$x]) != htmlspecialchars($stripped_Criteria)) {
$curCriteria[$z] = $stripped_Criteria; $curCriteria[$z] = $stripped_Criteria;
$encoded_Criteria = urlencode($stripped_Criteria); $encoded_Criteria = urlencode($stripped_Criteria);
} else { } else {
$curCriteria[$z] = urldecode($prev_Criteria[$x]); $curCriteria[$z] = urldecode($prev_criteria[$x]);
$encoded_Criteria = $prev_Criteria[$x]; $encoded_Criteria = $prev_criteria[$x];
} }
?> ?>
<td align="center" bgcolor="<?php echo $cfg['BgcolorTwo']; ?>"> <td align="center" bgcolor="<?php echo $cfg['BgcolorTwo']; ?>">
<input type="hidden" name="prev_Criteria[<?php echo $z; ?>]" value="<?php echo $encoded_Criteria; ?>" /> <input type="hidden" name="prev_criteria[<?php echo $z; ?>]" value="<?php echo $encoded_Criteria; ?>" />
<input type="text" name="Criteria[<?php echo $z; ?>]" value="<?php echo htmlspecialchars($stripped_Criteria); ?>" class="textfield" style="width: <?php echo $realwidth; ?>" size="20" /> <input type="text" name="criteria[<?php echo $z; ?>]" value="<?php echo htmlspecialchars($stripped_Criteria); ?>" class="textfield" style="width: <?php echo $realwidth; ?>" size="20" />
</td> </td>
<?php <?php
$z++; $z++;
@@ -379,7 +349,7 @@ for ($x = 0; $x < $col; $x++) {
$w = 0; $w = 0;
for ($y = 0; $y <= $row; $y++) { for ($y = 0; $y <= $row; $y++) {
$bgcolor = ($y % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; $bgcolor = ($y % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
if (isset($InsRow[$y]) && $InsRow[$y] == 'on') { if (isset($ins_row[$y]) && $ins_row[$y] == 'on') {
$chk['or'] = ' checked="checked"'; $chk['or'] = ' checked="checked"';
$chk['and'] = ''; $chk['and'] = '';
?> ?>
@@ -390,26 +360,26 @@ for ($y = 0; $y <= $row; $y++) {
<tr> <tr>
<td align="<?php echo $cell_align_right; ?>" nowrap="nowrap"> <td align="<?php echo $cell_align_right; ?>" nowrap="nowrap">
<small><?php echo $strQBEIns; ?>:</small> <small><?php echo $strQBEIns; ?>:</small>
<input type="checkbox" name="InsRow[<?php echo $w; ?>]" /> <input type="checkbox" name="ins_row[<?php echo $w; ?>]" />
</td> </td>
<td align="<?php echo $cell_align_right; ?>"> <td align="<?php echo $cell_align_right; ?>">
<b><?php echo $strAnd; ?>:</b> <b><?php echo $strAnd; ?>:</b>
</td> </td>
<td> <td>
<input type="radio" name="AndOrRow[<?php echo $w; ?>]" value="and"<?php echo $chk['and']; ?> /> <input type="radio" name="and_or_row[<?php echo $w; ?>]" value="and"<?php echo $chk['and']; ?> />
&nbsp; &nbsp;
</td> </td>
</tr> </tr>
<tr> <tr>
<td align="<?php echo $cell_align_right; ?>" nowrap="nowrap"> <td align="<?php echo $cell_align_right; ?>" nowrap="nowrap">
<small><?php echo $strQBEDel; ?>:</small> <small><?php echo $strQBEDel; ?>:</small>
<input type="checkbox" name="DelRow[<?php echo $w; ?>]" /> <input type="checkbox" name="del_row[<?php echo $w; ?>]" />
</td> </td>
<td align="<?php echo $cell_align_right; ?>"> <td align="<?php echo $cell_align_right; ?>">
<b><?php echo $strOr; ?>:</b> <b><?php echo $strOr; ?>:</b>
</td> </td>
<td> <td>
<input type="radio" name="AndOrRow[<?php echo $w; ?>]" value="or"<?php echo $chk['or']; ?> /> <input type="radio" name="and_or_row[<?php echo $w; ?>]" value="or"<?php echo $chk['or']; ?> />
&nbsp; &nbsp;
</td> </td>
</tr> </tr>
@@ -418,7 +388,7 @@ for ($y = 0; $y <= $row; $y++) {
<?php <?php
$z = 0; $z = 0;
for ($x = 0; $x < $col; $x++) { for ($x = 0; $x < $col; $x++) {
if (isset($InsCol[$x]) && $InsCol[$x] == 'on') { if (isset($ins_col[$x]) && $ins_col[$x] == 'on') {
echo "\n"; echo "\n";
$or = 'Or' . $w . '[' . $z . ']'; $or = 'Or' . $w . '[' . $z . ']';
?> ?>
@@ -428,7 +398,7 @@ for ($y = 0; $y <= $row; $y++) {
<?php <?php
$z++; $z++;
} // end if } // end if
if (isset($DelCol[$x]) && $DelCol[$x] == 'on') { if (isset($del_col[$x]) && $del_col[$x] == 'on') {
continue; continue;
} }
@@ -448,14 +418,14 @@ for ($y = 0; $y <= $row; $y++) {
<?php <?php
} // end if } // end if
if (isset($DelRow[$y]) && $DelRow[$y] == 'on') { if (isset($del_row[$y]) && $del_row[$y] == 'on') {
continue; continue;
} }
if (isset($AndOrRow[$y])) { if (isset($and_or_row[$y])) {
$curAndOrRow[$w] = $AndOrRow[$y]; $curAndOrRow[$w] = $and_or_row[$y];
} }
if (isset($AndOrRow[$y]) && $AndOrRow[$y] == 'and') { if (isset($and_or_row[$y]) && $and_or_row[$y] == 'and') {
$chk['and'] = ' checked="checked"'; $chk['and'] = ' checked="checked"';
$chk['or'] = ''; $chk['or'] = '';
} else { } else {
@@ -471,25 +441,25 @@ for ($y = 0; $y <= $row; $y++) {
<tr> <tr>
<td align="<?php echo $cell_align_right; ?>" nowrap="nowrap"> <td align="<?php echo $cell_align_right; ?>" nowrap="nowrap">
<small><?php echo $strQBEIns; ?>:</small> <small><?php echo $strQBEIns; ?>:</small>
<input type="checkbox" name="InsRow[<?php echo $w; ?>]" /> <input type="checkbox" name="ins_row[<?php echo $w; ?>]" />
</td> </td>
<td align="<?php echo $cell_align_right; ?>"> <td align="<?php echo $cell_align_right; ?>">
<b><?php echo $strAnd; ?>:</b> <b><?php echo $strAnd; ?>:</b>
</td> </td>
<td> <td>
<input type="radio" name="AndOrRow[<?php echo $w; ?>]" value="and"<?php echo $chk['and']; ?> /> <input type="radio" name="and_or_row[<?php echo $w; ?>]" value="and"<?php echo $chk['and']; ?> />
</td> </td>
</tr> </tr>
<tr> <tr>
<td align="<?php echo $cell_align_right; ?>" nowrap="nowrap"> <td align="<?php echo $cell_align_right; ?>" nowrap="nowrap">
<small><?php echo $strQBEDel; ?>:</small> <small><?php echo $strQBEDel; ?>:</small>
<input type="checkbox" name="DelRow[<?php echo $w; ?>]" /> <input type="checkbox" name="del_row[<?php echo $w; ?>]" />
</td> </td>
<td align="<?php echo $cell_align_right; ?>"> <td align="<?php echo $cell_align_right; ?>">
<b><?php echo $strOr; ?>:</b> <b><?php echo $strOr; ?>:</b>
</td> </td>
<td> <td>
<input type="radio" name="AndOrRow[<?php echo $w; ?>]" value="or"<?php echo $chk['or']; ?> /> <input type="radio" name="and_or_row[<?php echo $w; ?>]" value="or"<?php echo $chk['or']; ?> />
</td> </td>
</tr> </tr>
</table> </table>
@@ -497,7 +467,7 @@ for ($y = 0; $y <= $row; $y++) {
<?php <?php
$z = 0; $z = 0;
for ($x = 0; $x < $col; $x++) { for ($x = 0; $x < $col; $x++) {
if (!empty($InsCol) && isset($InsCol[$x]) && $InsCol[$x] == 'on') { if (!empty($ins_col) && isset($ins_col[$x]) && $ins_col[$x] == 'on') {
echo "\n"; echo "\n";
$or = 'Or' . $w . '[' . $z . ']'; $or = 'Or' . $w . '[' . $z . ']';
?> ?>
@@ -507,7 +477,7 @@ for ($y = 0; $y <= $row; $y++) {
<?php <?php
$z++; $z++;
} // end if } // end if
if (!empty($DelCol) && isset($DelCol[$x]) && $DelCol[$x] == 'on') { if (!empty($del_col) && isset($del_col[$x]) && $del_col[$x] == 'on') {
continue; continue;
} }
@@ -548,9 +518,9 @@ for ($y = 0; $y <= $row; $y++) {
<?php <?php
$z = 0; $z = 0;
for ($x = 0; $x < $col; $x++) { for ($x = 0; $x < $col; $x++) {
if (!empty($InsCol) && isset($InsCol[$x]) && $InsCol[$x] == 'on') { if (!empty($ins_col) && isset($ins_col[$x]) && $ins_col[$x] == 'on') {
$curAndOrCol[$z] = $AndOrCol[$y]; $curAndOrCol[$z] = $and_or_col[$y];
if ($AndOrCol[$z] == 'or') { if ($and_or_col[$z] == 'or') {
$chk['or'] = ' checked="checked"'; $chk['or'] = ' checked="checked"';
$chk['and'] = ''; $chk['and'] = '';
} else { } else {
@@ -560,28 +530,28 @@ for ($x = 0; $x < $col; $x++) {
?> ?>
<td align="center" bgcolor="<?php echo $cfg['BgcolorTwo']; ?>"> <td align="center" bgcolor="<?php echo $cfg['BgcolorTwo']; ?>">
<b><?php echo $strOr; ?>:</b> <b><?php echo $strOr; ?>:</b>
<input type="radio" name="AndOrCol[<?php echo $z; ?>]" value="or"<?php echo $chk['or']; ?> /> <input type="radio" name="and_or_col[<?php echo $z; ?>]" value="or"<?php echo $chk['or']; ?> />
&nbsp;&nbsp;<b><?php echo $strAnd; ?>:</b> &nbsp;&nbsp;<b><?php echo $strAnd; ?>:</b>
<input type="radio" name="AndOrCol[<?php echo $z; ?>]" value="and"<?php echo $chk['and']; ?> /> <input type="radio" name="and_or_col[<?php echo $z; ?>]" value="and"<?php echo $chk['and']; ?> />
<br /> <br />
<?php echo $strQBEIns . "\n"; ?> <?php echo $strQBEIns . "\n"; ?>
<input type="checkbox" name="InsCol[<?php echo $z; ?>]" /> <input type="checkbox" name="ins_col[<?php echo $z; ?>]" />
&nbsp;&nbsp;<?php echo $strQBEDel . "\n"; ?> &nbsp;&nbsp;<?php echo $strQBEDel . "\n"; ?>
<input type="checkbox" name="DelCol[<?php echo $z; ?>]" /> <input type="checkbox" name="del_col[<?php echo $z; ?>]" />
</td> </td>
<?php <?php
$z++; $z++;
} // end if } // end if
echo "\n"; echo "\n";
if (!empty($DelCol) && isset($DelCol[$x]) && $DelCol[$x] == 'on') { if (!empty($del_col) && isset($del_col[$x]) && $del_col[$x] == 'on') {
continue; continue;
} }
if (isset($AndOrCol[$y])) { if (isset($and_or_col[$y])) {
$curAndOrCol[$z] = $AndOrCol[$y]; $curAndOrCol[$z] = $and_or_col[$y];
} }
if (isset($AndOrCol[$z]) && $AndOrCol[$z] == 'or') { if (isset($and_or_col[$z]) && $and_or_col[$z] == 'or') {
$chk['or'] = ' checked="checked"'; $chk['or'] = ' checked="checked"';
$chk['and'] = ''; $chk['and'] = '';
} else { } else {
@@ -591,14 +561,14 @@ for ($x = 0; $x < $col; $x++) {
?> ?>
<td align="center" bgcolor="<?php echo $cfg['BgcolorTwo']; ?>"> <td align="center" bgcolor="<?php echo $cfg['BgcolorTwo']; ?>">
<b><?php echo $strOr; ?>:</b> <b><?php echo $strOr; ?>:</b>
<input type="radio" name="AndOrCol[<?php echo $z; ?>]" value="or"<?php echo $chk['or']; ?> /> <input type="radio" name="and_or_col[<?php echo $z; ?>]" value="or"<?php echo $chk['or']; ?> />
&nbsp;&nbsp;<b><?php echo $strAnd; ?>:</b> &nbsp;&nbsp;<b><?php echo $strAnd; ?>:</b>
<input type="radio" name="AndOrCol[<?php echo $z; ?>]" value="and"<?php echo $chk['and']; ?> /> <input type="radio" name="and_or_col[<?php echo $z; ?>]" value="and"<?php echo $chk['and']; ?> />
<br /> <br />
<?php echo $strQBEIns . "\n"; ?> <?php echo $strQBEIns . "\n"; ?>
<input type="checkbox" name="InsCol[<?php echo $z; ?>]" /> <input type="checkbox" name="ins_col[<?php echo $z; ?>]" />
&nbsp;&nbsp;<?php echo $strQBEDel . "\n"; ?> &nbsp;&nbsp;<?php echo $strQBEDel . "\n"; ?>
<input type="checkbox" name="DelCol[<?php echo $z; ?>]" /> <input type="checkbox" name="del_col[<?php echo $z; ?>]" />
</td> </td>
<?php <?php
$z++; $z++;
@@ -613,13 +583,13 @@ for ($x = 0; $x < $col; $x++) {
<table border="0" cellpadding="2" cellspacing="1"> <table border="0" cellpadding="2" cellspacing="1">
<tr> <tr>
<td nowrap="nowrap"><input type="hidden" value="<?php echo htmlspecialchars($db); ?>" name="db" /> <td nowrap="nowrap"><input type="hidden" value="<?php echo htmlspecialchars($db); ?>" name="db" />
<input type="hidden" value="<?php echo $z; ?>" name="Columns" /> <input type="hidden" value="<?php echo $z; ?>" name="col_cnt" />
<?php <?php
$w--; $w--;
?> ?>
<input type="hidden" value="<?php echo $w; ?>" name="Rows" /> <input type="hidden" value="<?php echo $w; ?>" name="rows" />
<?php echo $strAddDeleteRow; ?>: <?php echo $strAddDeleteRow; ?>:
<select size="1" name="Add_Row" style="vertical-align: middle"> <select size="1" name="add_row" style="vertical-align: middle">
<option value="-3">-3</option> <option value="-3">-3</option>
<option value="-2">-2</option> <option value="-2">-2</option>
<option value="-1">-1</option> <option value="-1">-1</option>
@@ -631,7 +601,7 @@ for ($x = 0; $x < $col; $x++) {
</td> </td>
<td width="10">&nbsp;</td> <td width="10">&nbsp;</td>
<td nowrap="nowrap"><?php echo $strAddDeleteColumn; ?>: <td nowrap="nowrap"><?php echo $strAddDeleteColumn; ?>:
<select size="1" name="Add_Col" style="vertical-align: middle"> <select size="1" name="add_col" style="vertical-align: middle">
<option value="-3">-3</option> <option value="-3">-3</option>
<option value="-2">-2</option> <option value="-2">-2</option>
<option value="-1">-1</option> <option value="-1">-1</option>
@@ -658,7 +628,7 @@ for ($x = 0; $x < $col; $x++) {
<?php <?php
$strTableListOptions = ''; $strTableListOptions = '';
$numTableListOptions = 0; $numTableListOptions = 0;
foreach($tbl_names AS $key => $val) { foreach ($tbl_names AS $key => $val) {
$strTableListOptions .= ' '; $strTableListOptions .= ' ';
$strTableListOptions .= '<option value="' . htmlspecialchars($key) . '"' . $val . '>' . htmlspecialchars($key) . '</option>' . "\n"; $strTableListOptions .= '<option value="' . htmlspecialchars($key) . '"' . $val . '>' . htmlspecialchars($key) . '</option>' . "\n";
$numTableListOptions++; $numTableListOptions++;
@@ -729,7 +699,7 @@ if (isset($Field) && count($Field) > 0) {
// Check 'where' clauses // Check 'where' clauses
if ($cfgRelation['relwork'] && count($tab_all) > 0) { if ($cfgRelation['relwork'] && count($tab_all) > 0) {
// Now we need all tables that we have in the where clause // 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++) { for ($x = 0; $x < $crit_cnt; $x++) {
$curr_tab = explode('.', urldecode($Field[$x])); $curr_tab = explode('.', urldecode($Field[$x]));
if (!empty($curr_tab[0]) && !empty($curr_tab[1])) { 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]); $col_raw = urldecode($curr_tab[1]);
$col1 = str_replace('`', '', $col_raw); $col1 = str_replace('`', '', $col_raw);
$col1 = $tab . '.' . $col1; $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 // we can check which of our columns has a where clause
if (!empty($Criteria[$x])) { if (!empty($criteria[$x])) {
if (substr($Criteria[$x], 0, 1) == '=' || stristr($Criteria[$x], 'is')) { if (substr($criteria[$x], 0, 1) == '=' || stristr($criteria[$x], 'is')) {
$col_where[$col] = $col1; $col_where[$col] = $col1;
$tab_wher[$tab] = $tab; $tab_wher[$tab] = $tab;
} }
@@ -791,10 +761,10 @@ if (isset($Field) && count($Field) > 0) {
if (isset($col_unique) && count($col_unique) > 0) { if (isset($col_unique) && count($col_unique) > 0) {
$col_cand = $col_unique; $col_cand = $col_unique;
$needsort = 1; $needsort = 1;
} else if (isset($col_index) && count($col_index) > 0) { } elseif (isset($col_index) && count($col_index) > 0) {
$col_cand = $col_index; $col_cand = $col_index;
$needsort = 1; $needsort = 1;
} else if (isset($col_where) && count($col_where) > 0) { } elseif (isset($col_where) && count($col_where) > 0) {
$col_cand = $tab_wher; $col_cand = $tab_wher;
$needsort = 0; $needsort = 0;
} else { } else {

View File

@@ -103,7 +103,7 @@ function PMA_setDisplayMode(&$the_disp_mode, &$the_total)
// 2.2 Statement is a "SHOW..." // 2.2 Statement is a "SHOW..."
elseif ($GLOBALS['is_show']) { elseif ($GLOBALS['is_show']) {
// 2.2.1 TODO : defines edit/delete links depending on show statement // 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) { if (isset($which[1]) && strpos(' ' . strtoupper($which[1]), 'PROCESSLIST') > 0) {
$do_display['edit_lnk'] = 'nn'; // no edit link $do_display['edit_lnk'] = 'nn'; // no edit link
$do_display['del_lnk'] = 'kp'; // "kill process" type 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'])); $sort_expression = trim(str_replace(' ', ' ', $analyzed_sql[0]['order_by_clause']));
// Get rid of ASC|DESC (TODO: analyzer) // 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; $sort_expression_nodir = isset($matches[1]) ? trim($matches[1]) : $sort_expression;
// sorting by indexes, only if it makes sense (only one table ref) // 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` // FROM `PMA_relation` AS `1` , `PMA_relation` AS `2`
if (($is_join 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]['expr'])
&& isset($analyzed_sql[0]['select_expr'][$i]['column']) && isset($analyzed_sql[0]['select_expr'][$i]['column'])
&& $analyzed_sql[0]['select_expr'][$i]['expr'] != && $analyzed_sql[0]['select_expr'][$i]['expr'] !=
@@ -792,7 +792,7 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
$order_img = ' <img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 's_asc.png" width="11" height="9" alt="'. $GLOBALS['strAscending'] . '" title="'. $GLOBALS['strAscending'] . '" id="soimg' . $i . '" />'; $order_img = ' <img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 's_asc.png" width="11" height="9" alt="'. $GLOBALS['strAscending'] . '" title="'. $GLOBALS['strAscending'] . '" id="soimg' . $i . '" />';
} }
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]; $sorted_sql_query = $regs3[1] . $sort_order . $regs3[2];
} else { } else {
$sorted_sql_query = $unsorted_sql_query . $sort_order; $sorted_sql_query = $unsorted_sql_query . $sort_order;

View File

@@ -244,7 +244,7 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
$type = $row['Type']; $type = $row['Type'];
// reformat mysql query output - staybyte - 9. June 2001 // reformat mysql query output - staybyte - 9. June 2001
// loic1: set or enum types: slashes single quotes inside options // 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); $tmp[2] = substr(ereg_replace('([^,])\'\'', '\\1\\\'', ',' . $tmp[2]), 1);
$type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')'; $type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
$type_nowrap = ''; $type_nowrap = '';
@@ -261,9 +261,9 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
$type = '&nbsp;'; $type = '&nbsp;';
} }
$binary = eregi('BINARY', $row['Type'], $test = array()); $binary = eregi('BINARY', $row['Type']);
$unsigned = eregi('UNSIGNED', $row['Type'], $test = array()); $unsigned = eregi('UNSIGNED', $row['Type']);
$zerofill = eregi('ZEROFILL', $row['Type'], $test = array()); $zerofill = eregi('ZEROFILL', $row['Type']);
} }
$strAttribute = '&nbsp;'; $strAttribute = '&nbsp;';
if ($binary) { if ($binary) {

View File

@@ -332,7 +332,7 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
$type = $row['Type']; $type = $row['Type'];
// reformat mysql query output - staybyte - 9. June 2001 // reformat mysql query output - staybyte - 9. June 2001
// loic1: set or enum types: slashes single quotes inside options // 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); $tmp[2] = substr(ereg_replace('([^,])\'\'', '\\1\\\'', ',' . $tmp[2]), 1);
$type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')'; $type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
$type_nowrap = ''; $type_nowrap = '';
@@ -349,9 +349,9 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
$type = '&nbsp;'; $type = '&nbsp;';
} }
$binary = eregi('BINARY', $row['Type'], $test = array()); $binary = eregi('BINARY', $row['Type']);
$unsigned = eregi('UNSIGNED', $row['Type'], $test = array()); $unsigned = eregi('UNSIGNED', $row['Type']);
$zerofill = eregi('ZEROFILL', $row['Type'], $test = array()); $zerofill = eregi('ZEROFILL', $row['Type']);
} }
$strAttribute = '&nbsp;'; $strAttribute = '&nbsp;';
if ($binary) { if ($binary) {

View File

@@ -136,7 +136,7 @@ function PMA_importRunQuery($sql = '', $full = '')
} }
// If a 'USE <db>' SQL-clause was found and the query succeeded, set our current $db to the new one // If a 'USE <db>' 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]); $db = trim($match[1]);
$reload = TRUE; $reload = TRUE;
} }

View File

@@ -123,7 +123,7 @@ function PMA_getIp()
// True IP without proxy // True IP without proxy
return $direct_ip; return $direct_ip;
} else { } 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)) { if ($is_ip && (count($regs) > 0)) {
// True IP behind a proxy // True IP behind a proxy
return $regs[0]; return $regs[0];
@@ -161,7 +161,7 @@ function PMA_ipMaskTest($testRange, $ipToTest)
{ {
$result = TRUE; $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 // performs a mask match
$ipl = ip2long($ipToTest); $ipl = ip2long($ipToTest);
$rangel = ip2long($regs[1] . '.' . $regs[2] . '.' . $regs[3] . '.' . $regs[4]); $rangel = ip2long($regs[1] . '.' . $regs[2] . '.' . $regs[3] . '.' . $regs[4]);

View File

@@ -50,7 +50,7 @@ function PMA_getAvailableMIMEtypes() {
@ksort($filestack); @ksort($filestack);
foreach ($filestack AS $key => $file) { 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. // File contains transformation functions.
$base = explode('__', str_replace('.inc.php', '', $file)); $base = explode('__', str_replace('.inc.php', '', $file));
$mimetype = str_replace('_', '/', $base[0]); $mimetype = str_replace('_', '/', $base[0]);
@@ -59,7 +59,7 @@ function PMA_getAvailableMIMEtypes() {
$stack['transformation'][] = $mimetype . ': ' . $base[1]; $stack['transformation'][] = $mimetype . ': ' . $base[1];
$stack['transformation_file'][] = $file; $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. // File is a plain mimetype, no functions.
$base = str_replace('.inc.php', '', $file); $base = str_replace('.inc.php', '', $file);

View File

@@ -67,7 +67,7 @@ function PMA_transformation_text_plain__external($buffer, $options = array(), $m
0 => array("pipe", "r"), 0 => array("pipe", "r"),
1 => array("pipe", "w") 1 => array("pipe", "w")
); );
$process = proc_open($program . ' ' . $poptions, $descriptorspec, $pipes = array()); $process = proc_open($program . ' ' . $poptions, $descriptorspec, $pipes);
if (is_resource($process)) { if (is_resource($process)) {
fwrite($pipes[0], $buffer); fwrite($pipes[0], $buffer);
fclose($pipes[0]); fclose($pipes[0]);

View File

@@ -1293,7 +1293,7 @@ function PMA_RT_DOC($alltables)
$type = $row['Type']; $type = $row['Type'];
// reformat mysql query output - staybyte - 9. June 2001 // reformat mysql query output - staybyte - 9. June 2001
// loic1: set or enum types: slashes single quotes inside options // 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); $tmp[2] = substr(preg_replace("@([^,])''@", "\\1\\'", ',' . $tmp[2]), 1);
$type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')'; $type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
$type_nowrap = ''; $type_nowrap = '';