remove uva prefix

This commit is contained in:
Marc Delisle
2006-12-10 12:32:41 +00:00
parent c165dbe297
commit d01f9977fb
7 changed files with 48 additions and 43 deletions

View File

@@ -5,6 +5,11 @@ phpMyAdmin - ChangeLog
$Id$ $Id$
$HeadURL$ $HeadURL$
2006-12-10 Marc Delisle <lem9@users.sourceforge.net>
* many scripts: we were using "uva" in variables and function names,
this was code suggested by University of Virginia; I improved the code
by removing this uva prefix
2006-12-07 Marc Delisle <lem9@users.sourceforge.net> 2006-12-07 Marc Delisle <lem9@users.sourceforge.net>
* libraries/ip_allow_deny.lib.php: checks that the header contains * libraries/ip_allow_deny.lib.php: checks that the header contains
only one IP address, thanks to Christian Schmidt only one IP address, thanks to Christian Schmidt

View File

@@ -456,9 +456,9 @@ require_once './libraries/PMA_List.class.php';
WHERE `Select_priv` = 'Y' WHERE `Select_priv` = 'Y'
AND `User` AND `User`
IN ('" . PMA_sqlAddslashes($GLOBALS['cfg']['Server']['user']) . "', '')"; IN ('" . PMA_sqlAddslashes($GLOBALS['cfg']['Server']['user']) . "', '')";
$uva_mydbs = PMA_DBI_fetch_result($local_query, null, null, $tmp_mydbs = PMA_DBI_fetch_result($local_query, null, null,
$GLOBALS['controllink']); $GLOBALS['controllink']);
if ($uva_mydbs) { if ($tmp_mydbs) {
// Will use as associative array of the following 2 code // Will use as associative array of the following 2 code
// lines: // lines:
// the 1st is the only line intact from before // the 1st is the only line intact from before
@@ -469,38 +469,38 @@ require_once './libraries/PMA_List.class.php';
// populating $dblist[], as previous code did. But it is // populating $dblist[], as previous code did. But it is
// now populated with actual database names instead of // now populated with actual database names instead of
// with regular expressions. // with regular expressions.
var_dump($uva_mydbs); var_dump($tmp_mydbs);
$uva_alldbs = PMA_DBI_query('SHOW DATABASES;', $GLOBALS['controllink']); $tmp_alldbs = PMA_DBI_query('SHOW DATABASES;', $GLOBALS['controllink']);
// loic1: all databases cases - part 2 // loic1: all databases cases - part 2
if (isset($uva_mydbs['%'])) { if (isset($tmp_mydbs['%'])) {
while ($uva_row = PMA_DBI_fetch_row($uva_alldbs)) { while ($tmp_row = PMA_DBI_fetch_row($tmp_alldbs)) {
$dblist[] = $uva_row[0]; $dblist[] = $tmp_row[0];
} // end while } // end while
} else { } else {
while ($uva_row = PMA_DBI_fetch_row($uva_alldbs)) { while ($tmp_row = PMA_DBI_fetch_row($tmp_alldbs)) {
$uva_db = $uva_row[0]; $tmp_db = $tmp_row[0];
if (isset($uva_mydbs[$uva_db]) && $uva_mydbs[$uva_db] == 1) { if (isset($tmp_mydbs[$tmp_db]) && $tmp_mydbs[$tmp_db] == 1) {
$dblist[] = $uva_db; $dblist[] = $tmp_db;
$uva_mydbs[$uva_db] = 0; $tmp_mydbs[$tmp_db] = 0;
} elseif (!isset($dblist[$uva_db])) { } elseif (!isset($dblist[$tmp_db])) {
foreach ($uva_mydbs as $uva_matchpattern => $uva_value) { foreach ($tmp_mydbs as $tmp_matchpattern => $tmp_value) {
// loic1: fixed bad regexp // loic1: fixed bad regexp
// TODO: db names may contain characters // TODO: db names may contain characters
// that are regexp instructions // that are regexp instructions
$re = '(^|(\\\\\\\\)+|[^\])'; $re = '(^|(\\\\\\\\)+|[^\])';
$uva_regex = ereg_replace($re . '%', '\\1.*', ereg_replace($re . '_', '\\1.{1}', $uva_matchpattern)); $tmp_regex = ereg_replace($re . '%', '\\1.*', ereg_replace($re . '_', '\\1.{1}', $tmp_matchpattern));
// Fixed db name matching // Fixed db name matching
// 2000-08-28 -- Benjamin Gandon // 2000-08-28 -- Benjamin Gandon
if (ereg('^' . $uva_regex . '$', $uva_db)) { if (ereg('^' . $tmp_regex . '$', $tmp_db)) {
$dblist[] = $uva_db; $dblist[] = $tmp_db;
break; break;
} }
} // end while } // end while
} // end if ... elseif ... } // end if ... elseif ...
} // end while } // end while
} // end else } // end else
PMA_DBI_free_result($uva_alldbs); PMA_DBI_free_result($tmp_alldbs);
unset($uva_mydbs); unset($tmp_mydbs);
} // end if } // end if
// 2. get allowed dbs from the "mysql.tables_priv" table // 2. get allowed dbs from the "mysql.tables_priv" table

View File

@@ -2106,11 +2106,11 @@ window.parent.updateTableTitle('<?php echo $uni_tbl; ?>', '<?php echo PMA_jsForm
* @author Michal Cihar (michal@cihar.com) * @author Michal Cihar (michal@cihar.com)
* @return string calculated condition * @return string calculated condition
*/ */
function PMA_getUvaCondition($handle, $fields_cnt, $fields_meta, $row) function PMA_getUniqueCondition($handle, $fields_cnt, $fields_meta, $row)
{ {
$primary_key = ''; $primary_key = '';
$unique_key = ''; $unique_key = '';
$uva_nonprimary_condition = ''; $nonprimary_condition = '';
for ($i = 0; $i < $fields_cnt; ++$i) { for ($i = 0; $i < $fields_cnt; ++$i) {
$field_flags = PMA_DBI_field_flags($handle, $i); $field_flags = PMA_DBI_field_flags($handle, $i);
@@ -2185,25 +2185,25 @@ window.parent.updateTableTitle('<?php echo $uni_tbl; ?>', '<?php echo PMA_jsForm
} elseif ($meta->unique_key > 0) { } elseif ($meta->unique_key > 0) {
$unique_key .= $condition; $unique_key .= $condition;
} }
$uva_nonprimary_condition .= $condition; $nonprimary_condition .= $condition;
} // end for } // end for
// Correction uva 19991216: prefer primary or unique keys // Correction University of Virginia 19991216:
// for condition, but use conjunction of all values if no // prefer primary or unique keys for condition,
// primary key // but use conjunction of all values if no primary key
if ($primary_key) { if ($primary_key) {
$uva_condition = $primary_key; $preferred_condition = $primary_key;
} elseif ($unique_key) { } elseif ($unique_key) {
$uva_condition = $unique_key; $preferred_condition = $unique_key;
} else { } else {
$uva_condition = $uva_nonprimary_condition; $preferred_condition = $nonprimary_condition;
} }
return preg_replace('|\s?AND$|', '', $uva_condition); return preg_replace('|\s?AND$|', '', $preferred_condition);
} // end function } // end function
/** /**
* Function to generate unique condition for specified row. * Generate a button or image tag
* *
* @param string name of button element * @param string name of button element
* @param string class of button element * @param string class of button element

View File

@@ -1011,7 +1011,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
$vertical_display['data'] = array(); $vertical_display['data'] = array();
$vertical_display['row_delete'] = array(); $vertical_display['row_delete'] = array();
// Correction uva 19991216 in the while below // Correction University of Virginia 19991216 in the while below
// Previous code assumed that all tables have keys, specifically that // Previous code assumed that all tables have keys, specifically that
// the phpMyAdmin GUI should support row delete/edit only for such // the phpMyAdmin GUI should support row delete/edit only for such
// tables. // tables.
@@ -1068,7 +1068,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
// 1. Prepares the row (gets primary keys to use) // 1. Prepares the row (gets primary keys to use)
// 1.1 Results from a "SELECT" statement -> builds the // 1.1 Results from a "SELECT" statement -> builds the
// "primary" key to use in links // "primary" key to use in links
$uva_condition = urlencode(PMA_getUvaCondition($dt_result, $fields_cnt, $fields_meta, $row)); $unique_condition = urlencode(PMA_getUniqueCondition($dt_result, $fields_cnt, $fields_meta, $row));
// 1.2 Defines the urls for the modify/delete link(s) // 1.2 Defines the urls for the modify/delete link(s)
$url_query = PMA_generate_common_url($db, $table) $url_query = PMA_generate_common_url($db, $table)
@@ -1093,7 +1093,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
$edit_url = 'tbl_change.php' $edit_url = 'tbl_change.php'
. '?' . $url_query . '?' . $url_query
. '&amp;primary_key=' . $uva_condition . '&amp;primary_key=' . $unique_condition
. '&amp;sql_query=' . urlencode($url_sql_query) . '&amp;sql_query=' . urlencode($url_sql_query)
. '&amp;goto=' . urlencode($lnk_goto); . '&amp;goto=' . urlencode($lnk_goto);
if ($GLOBALS['cfg']['PropertiesIconic'] === false) { if ($GLOBALS['cfg']['PropertiesIconic'] === false) {
@@ -1136,14 +1136,14 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
. '&sql_query=' . urlencode($url_sql_query) . '&sql_query=' . urlencode($url_sql_query)
. '&zero_rows=' . urlencode(htmlspecialchars($GLOBALS['strDeleted'])) . '&zero_rows=' . urlencode(htmlspecialchars($GLOBALS['strDeleted']))
. '&goto=' . (empty($goto) ? 'tbl_sql.php' : $goto); . '&goto=' . (empty($goto) ? 'tbl_sql.php' : $goto);
$del_query = urlencode('DELETE FROM ' . PMA_backquote($table) . ' WHERE') . $uva_condition . '+LIMIT+1'; $del_query = urlencode('DELETE FROM ' . PMA_backquote($table) . ' WHERE') . $unique_condition . '+LIMIT+1';
$del_url = 'sql.php' $del_url = 'sql.php'
. '?' . $url_query . '?' . $url_query
. '&amp;sql_query=' . $del_query . '&amp;sql_query=' . $del_query
. '&amp;zero_rows=' . urlencode(htmlspecialchars($GLOBALS['strDeleted'])) . '&amp;zero_rows=' . urlencode(htmlspecialchars($GLOBALS['strDeleted']))
. '&amp;goto=' . urlencode($lnk_goto); . '&amp;goto=' . urlencode($lnk_goto);
$js_conf = 'DELETE FROM ' . PMA_jsFormat($table) $js_conf = 'DELETE FROM ' . PMA_jsFormat($table)
. ' WHERE ' . trim(PMA_jsFormat(urldecode($uva_condition), false)) . ' WHERE ' . trim(PMA_jsFormat(urldecode($unique_condition), false))
. ' LIMIT 1'; . ' LIMIT 1';
if ($GLOBALS['cfg']['PropertiesIconic'] === false) { if ($GLOBALS['cfg']['PropertiesIconic'] === false) {
$del_str = $GLOBALS['strDelete']; $del_str = $GLOBALS['strDelete'];
@@ -1236,7 +1236,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
$transform_options['wrapper_link'] = '?' $transform_options['wrapper_link'] = '?'
. (isset($url_query) ? $url_query : '') . (isset($url_query) ? $url_query : '')
. '&amp;primary_key=' . (isset($uva_condition) ? $uva_condition : '') . '&amp;primary_key=' . (isset($unique_condition) ? $unique_condition : '')
. '&amp;sql_query=' . (isset($sql_query) ? urlencode($url_sql_query) : '') . '&amp;sql_query=' . (isset($sql_query) ? urlencode($url_sql_query) : '')
. '&amp;goto=' . (isset($sql_goto) ? urlencode($lnk_goto) : '') . '&amp;goto=' . (isset($sql_goto) ? urlencode($lnk_goto) : '')
. '&amp;transform_key=' . urlencode($meta->name); . '&amp;transform_key=' . urlencode($meta->name);
@@ -1485,7 +1485,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
if (!empty($del_url) && $is_display['del_lnk'] != 'kp') { if (!empty($del_url) && $is_display['del_lnk'] != 'kp') {
$vertical_display['row_delete'][$row_no] .= ' <td align="center" class="' . $class . '" ' . $column_style_vertical . '>' . "\n" $vertical_display['row_delete'][$row_no] .= ' <td align="center" class="' . $class . '" ' . $column_style_vertical . '>' . "\n"
. ' <input type="checkbox" id="id_rows_to_delete' . $row_no . '[%_PMA_CHECKBOX_DIR_%]" name="rows_to_delete[' . $uva_condition . ']"' . ' <input type="checkbox" id="id_rows_to_delete' . $row_no . '[%_PMA_CHECKBOX_DIR_%]" name="rows_to_delete[' . $unique_condition . ']"'
. ' onclick="' . $column_marker_vertical . 'copyCheckboxesRange(\'rowsDeleteForm\', \'id_rows_to_delete' . $row_no . '\',\'[%_PMA_CHECKBOX_DIR_%]\');"' . ' onclick="' . $column_marker_vertical . 'copyCheckboxesRange(\'rowsDeleteForm\', \'id_rows_to_delete' . $row_no . '\',\'[%_PMA_CHECKBOX_DIR_%]\');"'
. ' value="' . $del_query . '" ' . (isset($GLOBALS['checkall']) ? 'checked="checked"' : '') . ' />' . "\n" . ' value="' . $del_query . '" ' . (isset($GLOBALS['checkall']) ? 'checked="checked"' : '') . ' />' . "\n"
. ' </td>' . "\n"; . ' </td>' . "\n";

View File

@@ -12,7 +12,7 @@ if ( $doWriteModifyAt == 'left' ){
if (!empty($del_url) && $is_display['del_lnk'] != 'kp') { if (!empty($del_url) && $is_display['del_lnk'] != 'kp') {
echo ' <td align="center">' . "\n" echo ' <td align="center">' . "\n"
. ' <input type="checkbox" id="id_rows_to_delete' . $row_no . '" name="rows_to_delete[' . $uva_condition . ']"' . ' <input type="checkbox" id="id_rows_to_delete' . $row_no . '" name="rows_to_delete[' . $unique_condition . ']"'
. ' onclick="copyCheckboxesRange(\'rowsDeleteForm\', \'id_rows_to_delete' . $row_no . '\',\'l\');"' . ' onclick="copyCheckboxesRange(\'rowsDeleteForm\', \'id_rows_to_delete' . $row_no . '\',\'l\');"'
. ' value="' . $del_query . '" ' . (isset($GLOBALS['checkall']) ? 'checked="checked"' : '') . ' />' . "\n" . ' value="' . $del_query . '" ' . (isset($GLOBALS['checkall']) ? 'checked="checked"' : '') . ' />' . "\n"
. ' </td>' . "\n"; . ' </td>' . "\n";
@@ -42,7 +42,7 @@ if ( $doWriteModifyAt == 'left' ){
} }
if (!empty($del_url) && $is_display['del_lnk'] != 'kp') { if (!empty($del_url) && $is_display['del_lnk'] != 'kp') {
echo ' <td align="center">' . "\n" echo ' <td align="center">' . "\n"
. ' <input type="checkbox" id="id_rows_to_delete' . $row_no . 'r" name="rows_to_delete[' . $uva_condition . ']"' . ' <input type="checkbox" id="id_rows_to_delete' . $row_no . 'r" name="rows_to_delete[' . $unique_condition . ']"'
. ' onclick="copyCheckboxesRange(\'rowsDeleteForm\', \'id_rows_to_delete' . $row_no . '\',\'r\');"' . ' onclick="copyCheckboxesRange(\'rowsDeleteForm\', \'id_rows_to_delete' . $row_no . '\',\'r\');"'
. ' value="' . $del_query . '" ' . (isset($GLOBALS['checkall']) ? 'checked="checked"' : '') . ' />' . "\n" . ' value="' . $del_query . '" ' . (isset($GLOBALS['checkall']) ? 'checked="checked"' : '') . ' />' . "\n"
. ' </td>' . "\n"; . ' </td>' . "\n";

View File

@@ -796,7 +796,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
$insert_line .= $field_set[$i] . ' = ' . $values[$i]; $insert_line .= $field_set[$i] . ' = ' . $values[$i];
} }
$insert_line .= ' WHERE ' . PMA_getUvaCondition($result, $fields_cnt, $fields_meta, $row); $insert_line .= ' WHERE ' . PMA_getUniqueCondition($result, $fields_cnt, $fields_meta, $row);
} else { } else {

View File

@@ -70,7 +70,7 @@ if (isset($after_insert) && $after_insert == 'new_insert') {
$res = PMA_DBI_query($local_query); $res = PMA_DBI_query($local_query);
$row = PMA_DBI_fetch_row($res); $row = PMA_DBI_fetch_row($res);
$meta = PMA_DBI_get_fields_meta($res); $meta = PMA_DBI_get_fields_meta($res);
$goto .= '&primary_key[]=' . urlencode(PMA_getUvaCondition($res, count($row), $meta, $row)); $goto .= '&primary_key[]=' . urlencode(PMA_getUniqueCondition($res, count($row), $meta, $row));
} }
} }
} elseif ($goto == 'sql.php') { } elseif ($goto == 'sql.php') {