Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xChangeLog7
-rw-r--r--browse_foreigners.php16
-rw-r--r--libraries/display_tbl.lib.php15
-rw-r--r--libraries/display_tbl_links.lib.php2
-rw-r--r--mult_submits.inc.php20
-rw-r--r--tbl_change.php1056
-rw-r--r--tbl_replace.php249
-rw-r--r--tbl_replace_fields.php44
-rw-r--r--tbl_row_delete.php104
9 files changed, 827 insertions, 686 deletions
diff --git a/ChangeLog b/ChangeLog
index e75d2eee5e..0a484a2fc7 100755
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,13 @@ phpMyAdmin - Changelog
$Id$
$Source$
+2003-12-04 Garvin Hicking <grinch@supergarv.de>
+ * browse_foreigner.php, mult_submits.inc.php, tbl_change.php,
+ tbl_replace.php, tbl_replace_fields.php, tbl_row_delete,
+ libraries/display_tbl.lib.php, libraries/display_tbl_links.lib.php:
+ Multi row edit via checkboxes in browse mode is now available.
+ This means, you can edit multiple records at once now.
+
2003-12-02 Marc Delisle <lem9@users.sourceforge.net>
* libraries/display_tbl.lib.php: the constant used to check
if the transformation function is included no longer exists
diff --git a/browse_foreigners.php b/browse_foreigners.php
index 677266c372..33252fa98c 100644
--- a/browse_foreigners.php
+++ b/browse_foreigners.php
@@ -43,8 +43,8 @@ PMA_setFontSizes();
<script type="text/javascript" language="javascript">
self.focus();
function formupdate(field, key) {
- if (opener && opener.document && opener.document.insertForm && opener.document.insertForm.elements['field_' + field + '[]']) {
- opener.document.insertForm.elements['field_' + field + '[]'].value = key;
+ if (opener && opener.document && opener.document.insertForm && opener.document.insertForm.elements['field_' + field + '<?php echo (isset($pk) ? '[multi_edit][' . $pk . ']' : ''); ?>[]']) {
+ opener.document.insertForm.elements['field_' + field + '<?php echo (isset($pk) ? '[multi_edit][' . $pk . ']' : ''); ?>[]'].value = key;
self.close();
} else {
alert('<?php echo PMA_jsFormat($strWindowNotFound); ?>');
@@ -78,6 +78,16 @@ require('./libraries/get_foreign.lib.php');
<form action="browse_foreigners.php" method="post">
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
<input type="hidden" name="field" value="<?php echo urlencode($field); ?>" />
+<?php
+if (isset($pk)) {
+ $pk_uri = '&amp;pk=' . $pk;
+?>
+<input type="hidden" name="pk" value="<?php echo $pk; ?>" />
+<?php
+} else {
+ $pk_uri = '';
+}
+?>
<table width="100%">
<?php
@@ -93,7 +103,7 @@ $nbTotalPage = @ceil($the_total / $session_max_rows);
if ($the_total > $per_page) {
$gotopage = '<br />' . $GLOBALS['strPageNumber']
- . '<select name="goToPage" onChange="goToUrl(this, \'browse_foreigners.php?field=' . urlencode($field) . '&amp;' . PMA_generate_common_url($db, $table) . '&amp;\');">';
+ . '<select name="goToPage" onChange="goToUrl(this, \'browse_foreigners.php?field=' . urlencode($field) . '&amp;' . PMA_generate_common_url($db, $table) . $pk_uri . '\');">';
if ($nbTotalPage < 200) {
$firstPage = 1;
$lastPage = $nbTotalPage;
diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php
index 20f8825c13..4eba180e74 100644
--- a/libraries/display_tbl.lib.php
+++ b/libraries/display_tbl.lib.php
@@ -1488,7 +1488,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql)
if (!empty($del_url)) {
$vertical_display['row_delete'][$row_no] .= ' <td align="center" valign="' . ($bookmark_go != '' ? 'top' : 'middle') . '" bgcolor="' . $bgcolor . '">' . "\n"
- . ' <input type="checkbox" name="rows_to_delete[]" value="' . $del_query . '" />' . "\n"
+ . ' <input type="checkbox" name="rows_to_delete[' . $uva_condition . ']" value="' . $del_query . '" />' . "\n"
. ' </td>' . "\n";
} else {
unset($vertical_display['row_delete'][$row_no]);
@@ -1862,15 +1862,22 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
/* Opera has trouble with <input type="image"> */
/* IE has trouble with <button> */
if (PMA_USR_BROWSER_AGENT != 'IE') {
- echo ' <button class="mult_submit" type="submit" name="submit_mult" value="row_delete" title="' . $delete_text . '">' . "\n"
+ echo ' <button class="mult_submit" type="submit" name="submit_mult" value="row_edit" title="' . $GLOBALS['strEdit'] . '">' . "\n"
+ . '<img src="./images/button_edit.png" title="' . $GLOBALS['strEdit'] . '" alt="' . $GLOBALS['strEdit'] . '" width="11" height="13" />' . (($propicon == 'both') ? '&nbsp;' . $GLOBALS['strEdit'] : '') . "\n"
+ . '</button>';
+
+ echo '&nbsp;<button class="mult_submit" type="submit" name="submit_mult" value="row_delete" title="' . $delete_text . '">' . "\n"
. '<img src="./images/button_drop.png" title="' . $delete_text . '" alt="' . $delete_text . '" width="11" height="13" />' . (($propicon == 'both') ? '&nbsp;' . $delete_text : '') . "\n"
. '</button>';
+
} else {
- echo ' <input type="image" name="submit_mult" value="row_delete" title="' . $delete_text . '" src="./images/button_drop.png" />' . (($propicon == 'both') ? '&nbsp;' . $delete_text : '');
+ echo ' <input type="image" name="submit_mult_edit" value="row_edit" title="' . $GLOBALS['strEdit'] . '" src="./images/button_edit.png" />' . (($propicon == 'both') ? '&nbsp;' . $GLOBALS['strEdit'] : '');
+ echo '&nbsp;<input type="image" name="submit_mult" value="row_delete" title="' . $delete_text . '" src="./images/button_drop.png" />' . (($propicon == 'both') ? '&nbsp;' . $delete_text : '');
}
echo "\n";
} else {
- echo ' <input type="submit" name="submit_mult" value="row_delete" title="' . $delete_text . '" />' . "\n";
+ echo ' <input type="submit" name="submit_mult" value="row_edit" title="' . $GLOBALS['strEdit'] . '" />' . "\n";
+ echo '&nbsp;<input type="submit" name="submit_mult" value="row_delete" title="' . $delete_text . '" />' . "\n";
}
echo '<input type="hidden" name="sql_query" value="' . $sql_query . '" />' . "\n";
echo '<input type="hidden" name="pos" value="' . $pos . '" />' . "\n";
diff --git a/libraries/display_tbl_links.lib.php b/libraries/display_tbl_links.lib.php
index df384f18c1..86a45504cf 100644
--- a/libraries/display_tbl_links.lib.php
+++ b/libraries/display_tbl_links.lib.php
@@ -4,7 +4,7 @@
if (!empty($del_url)) {
echo ' <td align="center" valign="' . ($bookmark_go != '' ? 'top' : 'middle') . '" bgcolor="' . $bgcolor . '">' . "\n"
- . ' <input type="checkbox" name="rows_to_delete[]" value="' . $del_query . '" />' . "\n"
+ . ' <input type="checkbox" name="rows_to_delete[' . $uva_condition . ']" value="' . $del_query . '" />' . "\n"
. ' </td>' . "\n";
}
if (!empty($edit_url)) {
diff --git a/mult_submits.inc.php b/mult_submits.inc.php
index dfe34158cd..992f3ef70f 100644
--- a/mult_submits.inc.php
+++ b/mult_submits.inc.php
@@ -86,21 +86,23 @@ if (!empty($submit_mult) && !empty($what)) {
// Builds the query
$full_query = '';
$selected_cnt = count($selected);
- for ($i = 0; $i < $selected_cnt; $i++) {
+ $i = 0;
+ foreach($selected AS $idx => $sval) {
+ $i++;
switch ($what) {
case 'row_delete':
- $full_query .= htmlspecialchars(urldecode($selected[$i]))
+ $full_query .= htmlspecialchars(urldecode($sval))
. ';<br />';
break;
case 'drop_db':
$full_query .= 'DROP DATABASE '
- . PMA_backquote(htmlspecialchars(urldecode($selected[$i])))
+ . PMA_backquote(htmlspecialchars(urldecode($sval)))
. ';<br />';
break;
case 'drop_tbl':
$full_query .= (empty($full_query) ? 'DROP TABLE ' : ', ')
- . PMA_backquote(htmlspecialchars(urldecode($selected[$i])))
+ . PMA_backquote(htmlspecialchars(urldecode($sval)))
. (($i == $selected_cnt - 1) ? ';<br />' : '');
break;
@@ -110,7 +112,7 @@ if (!empty($submit_mult) && !empty($what)) {
} else {
$full_query .= 'DELETE FROM ';
}
- $full_query .= PMA_backquote(htmlspecialchars(urldecode($selected[$i])))
+ $full_query .= PMA_backquote(htmlspecialchars(urldecode($sval)))
. ';<br />';
break;
@@ -119,11 +121,11 @@ if (!empty($submit_mult) && !empty($what)) {
$full_query .= 'ALTER TABLE '
. PMA_backquote(htmlspecialchars($table))
. '<br />&nbsp;&nbsp;DROP '
- . PMA_backquote(htmlspecialchars(urldecode($selected[$i])))
+ . PMA_backquote(htmlspecialchars(urldecode($sval)))
. ',';
} else {
$full_query .= '<br />&nbsp;&nbsp;DROP '
- . PMA_backquote(htmlspecialchars(urldecode($selected[$i])))
+ . PMA_backquote(htmlspecialchars(urldecode($sval)))
. ',';
}
if ($i == $selected_cnt-1) {
@@ -148,8 +150,8 @@ if (!empty($submit_mult) && !empty($what)) {
} else {
echo PMA_generate_common_hidden_inputs();
}
- for ($i = 0; $i < $selected_cnt; $i++) {
- echo ' <input type="hidden" name="selected[]" value="' . htmlspecialchars($selected[$i]) . '" />' . "\n";
+ foreach($selected AS $idx => $sval) {
+ echo ' <input type="hidden" name="selected[]" value="' . htmlspecialchars($sval) . '" />' . "\n";
}
?>
<input type="hidden" name="query_type" value="<?php echo $what; ?>" />
diff --git a/tbl_change.php b/tbl_change.php
index de4543dc7a..8f29832e00 100644
--- a/tbl_change.php
+++ b/tbl_change.php
@@ -81,35 +81,44 @@ echo '<br />';
PMA_mysql_select_db($db);
$table_def = PMA_mysql_query('SHOW FIELDS FROM ' . PMA_backquote($table));
if (isset($primary_key)) {
- $local_query = 'SELECT * FROM ' . PMA_backquote($table) . ' WHERE ' . $primary_key;
- $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
- $row = PMA_mysql_fetch_array($result);
-
- // No row returned
- if (!$row) {
- unset($row);
- unset($primary_key);
- $goto_cpy = $goto;
- $goto = 'tbl_properties.php?'
- . PMA_generate_common_url($db, $table)
- . '&amp;$show_query=1'
- . '&amp;sql_query=' . urlencode($local_query);
- if (isset($sql_query)) {
- $sql_query_cpy = $sql_query;
- unset($sql_query);
- }
- $sql_query = $local_query;
- PMA_showMessage($strEmptyResultSet);
- $goto = $goto_cpy;
- unset($goto_cpy);
- if (isset($sql_query_cpy)) {
- $sql_query = $sql_query_cpy;
- unset($sql_query_cpy);
- }
- } // end if (no record returned)
-}
-else
-{
+ if (is_array($primary_key)) {
+ $primary_key_array = $primary_key;
+ } else {
+ $primary_key_array = array(0 => $primary_key);
+ }
+
+ $row = array();
+ $result = array();
+ foreach($primary_key_array AS $rowcount => $primary_key) {
+ $local_query = 'SELECT * FROM ' . PMA_backquote($table) . ' WHERE ' . $primary_key;
+ $result[$rowcount] = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
+ $row[$rowcount] = PMA_mysql_fetch_array($result[$rowcount]);
+ $primary_keys[$rowcount] = $primary_key;
+
+ // No row returned
+ if (!$row[$rowcount]) {
+ unset($row[$rowcount]);
+ unset($primary_key_array[$rowcount]);
+ $goto_cpy = $goto;
+ $goto = 'tbl_properties.php?'
+ . PMA_generate_common_url($db, $table)
+ . '&amp;$show_query=1'
+ . '&amp;sql_query=' . urlencode($local_query);
+ if (isset($sql_query)) {
+ $sql_query_cpy = $sql_query;
+ unset($sql_query);
+ }
+ $sql_query = $local_query;
+ PMA_showMessage($strEmptyResultSet);
+ $goto = $goto_cpy;
+ unset($goto_cpy);
+ if (isset($sql_query_cpy)) {
+ $sql_query = $sql_query_cpy;
+ unset($sql_query_cpy);
+ }
+ } // end if (no record returned)
+ }
+} else {
$local_query = 'SELECT * FROM ' . PMA_backquote($table) . ' LIMIT 1';
$result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
unset($row);
@@ -154,28 +163,15 @@ document.onkeydown = onKeyDownArrowsHandler;
<input type="hidden" name="err_url" value="<?php echo urlencode($err_url); ?>" />
<input type="hidden" name="sql_query" value="<?php echo isset($sql_query) ? urlencode($sql_query) : ''; ?>" />
<?php
-if (isset($primary_key)) {
- ?>
- <input type="hidden" name="primary_key" value="<?php echo urlencode($primary_key); ?>" />
- <?php
-}
-echo "\n";
-?>
-
- <table border="<?php echo $cfg['Border']; ?>">
- <tr>
- <th><?php echo $strField; ?></th>
- <th><?php echo $strType; ?></th>
+if (isset($primary_key_array)) {
+ foreach($primary_key_array AS $primary_key) {
+ ?>
+ <input type="hidden" name="primary_key[]" value="<?php echo urlencode($primary_key); ?>" />
<?php
-if ($cfg['ShowFunctionFields']) {
- echo ' <th>' . $strFunction . '</th>' . "\n";
+ }
}
-?>
- <th><?php echo $strNull; ?></th>
- <th><?php echo $strValue; ?></th>
- </tr>
+echo "\n";
-<?php
if ($cfg['PropertiesIconic'] == true) {
// We need to copy the value or else the == 'both' check will always return true
$propicon = (string)$cfg['PropertiesIconic'];
@@ -202,525 +198,565 @@ $fields_cnt = mysql_num_rows($table_def);
// Set a flag here because the 'if' would not be valid in the loop
// if we set a value in some field
$insert_mode = (!isset($row) ? TRUE : FALSE);
+$loop_array = (isset($row) ? $row : array(0 => array(0 => 0)));
-for ($i = 0; $i < $fields_cnt; $i++) {
- // Display the submit button after every 15 lines --swix
- // (wanted to use an <a href="#bottom"> and <a name> instead,
- // but it didn't worked because of the <base href>)
-
- if ((($i % 15) == 0) && ($i != 0)) {
- ?>
- <tr>
- <th colspan="5" align="right">
- <input type="submit" value="<?php echo $strGo; ?>" />&nbsp;
- </th>
- </tr>
- <?php
- } // end if
- echo "\n";
-
- $row_table_def = PMA_mysql_fetch_array($table_def);
- $row_table_def['True_Type'] = preg_replace('@\(.*@s', '', $row_table_def['Type']);
+while ($trow = PMA_mysql_fetch_array($table_def)) {
+ $trow_table_def[] = $trow;
+}
- $field = $row_table_def['Field'];
+$o_rows = 0;
+foreach($loop_array AS $vrowcount => $vrow) {
+ $vresult = (isset($result) && is_array($result) && isset($result[$vrowcount]) ? $result[$vrowcount] : $result);
+?>
+ <table border="<?php echo $cfg['Border']; ?>">
+ <tr>
+ <th><?php echo $strField; ?></th>
+ <th><?php echo $strType; ?></th>
+<?php
+ if ($cfg['ShowFunctionFields']) {
+ echo ' <th>' . $strFunction . '</th>' . "\n";
+ }
+?>
+ <th><?php echo $strNull; ?></th>
+ <th><?php echo $strValue; ?></th>
+ </tr>
+<?php
- // garvin: possible workaround. If current field is numerical, do not try to
- // access the result-array with its 'associative' key but with its numerical
- // represantation.
- if (is_numeric($field)) {
- $rowfield = $i;
+ if ($insert_mode) {
+ $vkey = '';
+ $browse_foreigners_uri = '';
} else {
- $rowfield = $field;
+ $vkey = '[multi_edit][' . urlencode($primary_keys[$vrowcount]) . ']';
+ $browse_foreigners_uri = '&amp;pk=' . urlencode($primary_keys[$vrowcount]);
}
- // d a t e t i m e
- //
- // loic1: current date should not be set as default if the field is NULL
- // for the current row
- // lem9: but do not put here the current datetime if there is a default
- // value (the real default value will be set in the
- // Default value logic below)
- if ($row_table_def['Type'] == 'datetime'
- && (!isset($row_table_def['Default']))) {
- // INSERT case
- if ($insert_mode) {
- $row[$rowfield] = date('Y-m-d H:i:s', time());
+ // garvin: For looping on multiple rows, we need to reset any variable used inside the loop to indicate sth.
+ unset($timestamp_seen);
+ unset($first_timestamp);
+
+ // Sets a multiplier used for input-field counts (as zero cannot be used, advance the counter plus one)
+ $m_rows = $o_rows + 1;
+
+ for ($i = 0; $i < $fields_cnt; $i++) {
+ // Display the submit button after every 15 lines --swix
+ // (wanted to use an <a href="#bottom"> and <a name> instead,
+ // but it didn't worked because of the <base href>)
+
+ if ((($i % 15) == 0) && ($i != 0)) {
+ ?>
+ <tr>
+ <th colspan="5" align="right">
+ <input type="submit" value="<?php echo $strGo; ?>" />&nbsp;
+ </th>
+ </tr>
+ <?php
+ } // end if
+ echo "\n";
+
+ $row_table_def = $trow_table_def[$i];
+ $row_table_def['True_Type'] = preg_replace('@\(.*@s', '', $row_table_def['Type']);
+
+ $field = $row_table_def['Field'];
+
+ // garvin: possible workaround. If current field is numerical, do not try to
+ // access the result-array with its 'associative' key but with its numerical
+ // represantation.
+ if (is_numeric($field)) {
+ $rowfield = $i;
+ } else {
+ $rowfield = $field;
}
- // UPDATE case with an empty and not NULL value under PHP4
- else if (empty($row[$rowfield]) && is_null($row[$rowfield])) {
- $row[$rowfield] = date('Y-m-d H:i:s', time());
- } // end if... else if...
- }
- $len = (preg_match('@float|double@', $row_table_def['Type']))
- ? 100
- : @mysql_field_len($result, $i);
- $first_timestamp = 0;
-
- $bgcolor = ($i % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
- ?>
- <tr>
- <td <?php echo ($cfg['LongtextDoubleTextarea'] && strstr($row_table_def['True_Type'], 'longtext') ? 'rowspan="2"' : ''); ?> align="center" bgcolor="<?php echo $bgcolor; ?>"><?php echo htmlspecialchars($field); ?></td>
- <?php
- echo "\n";
-
- // The type column
- $is_binary = stristr($row_table_def['Type'], ' binary');
- $is_blob = stristr($row_table_def['Type'], 'blob');
- $is_char = stristr($row_table_def['Type'], 'char');
- switch ($row_table_def['True_Type']) {
- case 'set':
- $type = 'set';
- $type_nowrap = '';
- break;
- case 'enum':
- $type = 'enum';
- $type_nowrap = '';
- break;
- case 'timestamp':
- if (!$timestamp_seen) { // can only occur once per table
- $timestamp_seen = 1;
- $first_timestamp = 1;
+
+ // d a t e t i m e
+ //
+ // loic1: current date should not be set as default if the field is NULL
+ // for the current row
+ // lem9: but do not put here the current datetime if there is a default
+ // value (the real default value will be set in the
+ // Default value logic below)
+ if ($row_table_def['Type'] == 'datetime'
+ && (!isset($row_table_def['Default']))) {
+ // INSERT case
+ if ($insert_mode) {
+ $vrow[$rowfield] = date('Y-m-d H:i:s', time());
}
- $type = $row_table_def['Type'];
- $type_nowrap = ' nowrap="nowrap"';
- break;
-
- default:
- $type = $row_table_def['Type'];
- $type_nowrap = ' nowrap="nowrap"';
- break;
- }
- ?>
- <td align="center" bgcolor="<?php echo $bgcolor; ?>"<?php echo $type_nowrap; ?>>
- <?php echo $type; ?>
- </td>
- <?php
- echo "\n";
-
- // Prepares the field value
- $real_null_value = FALSE;
- if (isset($row)) {
- if (!isset($row[$rowfield])
- || (function_exists('is_null') && is_null($row[$rowfield]))) {
- $real_null_value = TRUE;
- $row[$rowfield] = '';
- $special_chars = '';
- $data = $row[$rowfield];
- } else {
- // loic1: special binary "characters"
- if ($is_binary || $is_blob) {
- $row[$rowfield] = str_replace("\x00", '\0', $row[$rowfield]);
- $row[$rowfield] = str_replace("\x08", '\b', $row[$rowfield]);
- $row[$rowfield] = str_replace("\x0a", '\n', $row[$rowfield]);
- $row[$rowfield] = str_replace("\x0d", '\r', $row[$rowfield]);
- $row[$rowfield] = str_replace("\x1a", '\Z', $row[$rowfield]);
- } // end if
- $special_chars = htmlspecialchars($row[$rowfield]);
- $data = $row[$rowfield];
- } // end if... else...
- // loic1: if a timestamp field value is not included in an update
- // statement MySQL auto-update it to the current timestamp
- $backup_field = ($row_table_def['True_Type'] == 'timestamp')
- ? ''
- : '<input type="hidden" name="fields_prev[' . urlencode($field) . ']" value="' . urlencode($row[$rowfield]) . '" />';
- } else {
- // loic1: display default values
- if (!isset($row_table_def['Default'])) {
- $row_table_def['Default'] = '';
- $real_null_value = TRUE;
- $data = '';
- //$data = 'NULL';
- } else {
- $data = $row_table_def['Default'];
+ // UPDATE case with an empty and not NULL value under PHP4
+ else if (empty($vrow[$rowfield]) && is_null($vrow[$rowfield])) {
+ $vrow[$rowfield] = date('Y-m-d H:i:s', time());
+ } // end if... else if...
}
- $special_chars = htmlspecialchars($row_table_def['Default']);
- $backup_field = '';
- }
-
- // The function column
- // -------------------
- // Change by Bernard M. Piller <bernard@bmpsystems.com>
- // We don't want binary data to be destroyed
- // Note: from the MySQL manual: "BINARY doesn't affect how the column is
- // stored or retrieved" so it does not mean that the contents is
- // binary
- if ($cfg['ShowFunctionFields']) {
- if (($cfg['ProtectBinary'] && $is_blob)
- || ($cfg['ProtectBinary'] == 'all' && $is_binary)) {
- echo ' <td align="center" bgcolor="'. $bgcolor . '">' . $strBinary . '</td>' . "\n";
- } else if (strstr($row_table_def['True_Type'], 'enum') || strstr($row_table_def['True_Type'], 'set')) {
- echo ' <td align="center" bgcolor="'. $bgcolor . '">--</td>' . "\n";
+ $len = (preg_match('@float|double@', $row_table_def['Type']))
+ ? 100
+ : @mysql_field_len($vresult, $i);
+ $first_timestamp = 0;
+
+ $bgcolor = ($i % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
+ ?>
+ <tr>
+ <td <?php echo ($cfg['LongtextDoubleTextarea'] && strstr($row_table_def['True_Type'], 'longtext') ? 'rowspan="2"' : ''); ?> align="center" bgcolor="<?php echo $bgcolor; ?>"><?php echo htmlspecialchars($field); ?></td>
+ <?php
+ echo "\n";
+
+ // The type column
+ $is_binary = stristr($row_table_def['Type'], ' binary');
+ $is_blob = stristr($row_table_def['Type'], 'blob');
+ $is_char = stristr($row_table_def['Type'], 'char');
+ switch ($row_table_def['True_Type']) {
+ case 'set':
+ $type = 'set';
+ $type_nowrap = '';
+ break;
+ case 'enum':
+ $type = 'enum';
+ $type_nowrap = '';
+ break;
+ case 'timestamp':
+ if (!$timestamp_seen) { // can only occur once per table
+ $timestamp_seen = 1;
+ $first_timestamp = 1;
+ }
+ $type = $row_table_def['Type'];
+ $type_nowrap = ' nowrap="nowrap"';
+ break;
+
+ default:
+ $type = $row_table_def['Type'];
+ $type_nowrap = ' nowrap="nowrap"';
+ break;
+ }
+ ?>
+ <td align="center" bgcolor="<?php echo $bgcolor; ?>"<?php echo $type_nowrap; ?>>
+ <?php echo $type; ?>
+ </td>
+ <?php
+ echo "\n";
+
+ // Prepares the field value
+ $real_null_value = FALSE;
+ if (isset($vrow)) {
+ if (!isset($vrow[$rowfield])
+ || (function_exists('is_null') && is_null($vrow[$rowfield]))) {
+ $real_null_value = TRUE;
+ $vrow[$rowfield] = '';
+ $special_chars = '';
+ $data = $vrow[$rowfield];
+ } else {
+ // loic1: special binary "characters"
+ if ($is_binary || $is_blob) {
+ $vrow[$rowfield] = str_replace("\x00", '\0', $vrow[$rowfield]);
+ $vrow[$rowfield] = str_replace("\x08", '\b', $vrow[$rowfield]);
+ $vrow[$rowfield] = str_replace("\x0a", '\n', $vrow[$rowfield]);
+ $vrow[$rowfield] = str_replace("\x0d", '\r', $vrow[$rowfield]);
+ $vrow[$rowfield] = str_replace("\x1a", '\Z', $vrow[$rowfield]);
+ } // end if
+ $special_chars = htmlspecialchars($vrow[$rowfield]);
+ $data = $vrow[$rowfield];
+ } // end if... else...
+ // loic1: if a timestamp field value is not included in an update
+ // statement MySQL auto-update it to the current timestamp
+ $backup_field = ($row_table_def['True_Type'] == 'timestamp')
+ ? ''
+ : '<input type="hidden" name="fields_prev' . $vkey . '[' . urlencode($field) . ']" value="' . urlencode($vrow[$rowfield]) . '" />';
} else {
- ?>
- <td bgcolor="<?php echo $bgcolor; ?>">
- <select name="funcs[<?php echo urlencode($field); ?>]" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo ($fields_cnt + $i + 1); ?>" id="field_<?php echo $i; ?>_1">
- <option></option>
- <?php
- echo "\n";
- $selected = '';
-
- // garvin: Find the current type in the RestrictColumnTypes. Will result in 'FUNC_CHAR'
- // or something similar. Then directly look up the entry in the RestrictFunctions array,
- // which will then reveal the available dropdown options
- if (isset($cfg['RestrictFunctions']) && isset($cfg['RestrictColumnTypes']) && isset($cfg['RestrictColumnTypes'][strtoupper($row_table_def['True_Type'])]) && isset($cfg['RestrictFunctions'][$cfg['RestrictColumnTypes'][strtoupper($row_table_def['True_Type'])]])) {
- $current_func_type = $cfg['RestrictColumnTypes'][strtoupper($row_table_def['True_Type'])];
- $dropdown = $cfg['RestrictFunctions'][$current_func_type];
- $default_function = $cfg['DefaultFunctions'][$current_func_type];
+ // loic1: display default values
+ if (!isset($row_table_def['Default'])) {
+ $row_table_def['Default'] = '';
+ $real_null_value = TRUE;
+ $data = '';
+ //$data = 'NULL';
} else {
- $dropdown = array();
- }
-
- $dropdown_built = array();
- $op_spacing_needed = FALSE;
-
- // garvin: loop on the dropdown array and print all available options for that field.
- $cnt_dropdown = count($dropdown);
- for ($j = 0; $j < $cnt_dropdown; $j++) {
- // Is current function defined as default?
- $selected = ($first_timestamp && $dropdown[$j] == $cfg['DefaultFunctions']['first_timestamp'])
- || (!$first_timestamp && $dropdown[$j] == $default_function)
- ? ' selected="selected"'
- : '';
- echo ' ';
- echo '<option' . $selected . '>' . $dropdown[$j] . '</option>' . "\n";
- $dropdown_built[$dropdown[$j]] = 'TRUE';
- $op_spacing_needed = TRUE;
+ $data = $row_table_def['Default'];
}
-
- // garvin: For compatibility's sake, do not let out all other functions. Instead
- // print a seperator (blank) and then show ALL functions which weren't shown
- // yet.
- $cnt_functions = count($cfg['Functions']);
- for ($j = 0; $j < $cnt_functions; $j++) {
- if (!isset($dropdown_built[$cfg['Functions'][$j]]) || $dropdown_built[$cfg['Functions'][$j]] != 'TRUE') {
+ $special_chars = htmlspecialchars($row_table_def['Default']);
+ $backup_field = '';
+ }
+
+ // The function column
+ // -------------------
+ // Change by Bernard M. Piller <bernard@bmpsystems.com>
+ // We don't want binary data to be destroyed
+ // Note: from the MySQL manual: "BINARY doesn't affect how the column is
+ // stored or retrieved" so it does not mean that the contents is
+ // binary
+ if ($cfg['ShowFunctionFields']) {
+ if (($cfg['ProtectBinary'] && $is_blob)
+ || ($cfg['ProtectBinary'] == 'all' && $is_binary)) {
+ echo ' <td align="center" bgcolor="'. $bgcolor . '">' . $strBinary . '</td>' . "\n";
+ } else if (strstr($row_table_def['True_Type'], 'enum') || strstr($row_table_def['True_Type'], 'set')) {
+ echo ' <td align="center" bgcolor="'. $bgcolor . '">--</td>' . "\n";
+ } else {
+ ?>
+ <td bgcolor="<?php echo $bgcolor; ?>">
+ <select name="funcs<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo ($fields_cnt + ($i * $m_rows) + 1); ?>" id="field_<?php echo $i * $m_rows; ?>_1">
+ <option></option>
+ <?php
+ echo "\n";
+ $selected = '';
+
+ // garvin: Find the current type in the RestrictColumnTypes. Will result in 'FUNC_CHAR'
+ // or something similar. Then directly look up the entry in the RestrictFunctions array,
+ // which will then reveal the available dropdown options
+ if (isset($cfg['RestrictFunctions']) && isset($cfg['RestrictColumnTypes']) && isset($cfg['RestrictColumnTypes'][strtoupper($row_table_def['True_Type'])]) && isset($cfg['RestrictFunctions'][$cfg['RestrictColumnTypes'][strtoupper($row_table_def['True_Type'])]])) {
+ $current_func_type = $cfg['RestrictColumnTypes'][strtoupper($row_table_def['True_Type'])];
+ $dropdown = $cfg['RestrictFunctions'][$current_func_type];
+ $default_function = $cfg['DefaultFunctions'][$current_func_type];
+ } else {
+ $dropdown = array();
+ }
+
+ $dropdown_built = array();
+ $op_spacing_needed = FALSE;
+
+ // garvin: loop on the dropdown array and print all available options for that field.
+ $cnt_dropdown = count($dropdown);
+ for ($j = 0; $j < $cnt_dropdown; $j++) {
// Is current function defined as default?
- $selected = ($first_timestamp && $cfg['Functions'][$j] == $cfg['DefaultFunctions']['first_timestamp'])
- || (!$first_timestamp && $cfg['Functions'][$j] == $default_function)
+ $selected = ($first_timestamp && $dropdown[$j] == $cfg['DefaultFunctions']['first_timestamp'])
+ || (!$first_timestamp && $dropdown[$j] == $default_function)
? ' selected="selected"'
: '';
- if ($op_spacing_needed == TRUE) {
+ echo ' ';
+ echo '<option' . $selected . '>' . $dropdown[$j] . '</option>' . "\n";
+ $dropdown_built[$dropdown[$j]] = 'TRUE';
+ $op_spacing_needed = TRUE;
+ }
+
+ // garvin: For compatibility's sake, do not let out all other functions. Instead
+ // print a seperator (blank) and then show ALL functions which weren't shown
+ // yet.
+ $cnt_functions = count($cfg['Functions']);
+ for ($j = 0; $j < $cnt_functions; $j++) {
+ if (!isset($dropdown_built[$cfg['Functions'][$j]]) || $dropdown_built[$cfg['Functions'][$j]] != 'TRUE') {
+ // Is current function defined as default?
+ $selected = ($first_timestamp && $cfg['Functions'][$j] == $cfg['DefaultFunctions']['first_timestamp'])
+ || (!$first_timestamp && $cfg['Functions'][$j] == $default_function)
+ ? ' selected="selected"'
+ : '';
+ if ($op_spacing_needed == TRUE) {
+ echo ' ';
+ echo '<option value="">--------</option>' . "\n";
+ $op_spacing_needed = FALSE;
+ }
+
echo ' ';
- echo '<option value="">--------</option>' . "\n";
- $op_spacing_needed = FALSE;
+ echo '<option' . $selected . '>' . $cfg['Functions'][$j] . '</option>' . "\n";
}
-
- echo ' ';
- echo '<option' . $selected . '>' . $cfg['Functions'][$j] . '</option>' . "\n";
+ } // end for
+ unset($selected);
+ ?>
+ </select>
+ </td>
+ <?php
+ }
+ } // end if ($cfg['ShowFunctionFields'])
+ echo "\n";
+
+ // The null column
+ // ---------------
+ echo ' <td bgcolor="' . $bgcolor . '">' . "\n";
+ if (!(($cfg['ProtectBinary'] && $is_blob) || ($cfg['ProtectBinary'] == 'all' && $is_binary))
+ && $row_table_def['Null'] == 'YES') {
+ echo ' <input type="checkbox" tabindex="' . ((2 * $fields_cnt) + ($i * $m_rows) + 1) . '"'
+ . ' name="fields_null[' . urlencode($field) . ']"';
+ //if ($data == 'NULL' && !$first_timestamp) {
+ if ($real_null_value && !$first_timestamp) {
+ echo ' checked="checked"';
+ }
+ echo ' id="field_' . ($i * $m_rows) . '_2"';
+ $onclick = ' onclick="if (this.checked) {nullify(';
+ if (strstr($row_table_def['True_Type'], 'enum')) {
+ if (strlen($row_table_def['Type']) > 20) {
+ $onclick .= '1, ';
+ } else {
+ $onclick .= '2, ';
}
- } // end for
- unset($selected);
- ?>
- </select>
- </td>
- <?php
- }
- } // end if ($cfg['ShowFunctionFields'])
- echo "\n";
-
- // The null column
- // ---------------
- echo ' <td bgcolor="' . $bgcolor . '">' . "\n";
- if (!(($cfg['ProtectBinary'] && $is_blob) || ($cfg['ProtectBinary'] == 'all' && $is_binary))
- && $row_table_def['Null'] == 'YES') {
- echo ' <input type="checkbox" tabindex="' . ((2 * $fields_cnt) + $i + 1) . '"'
- . ' name="fields_null[' . urlencode($field) . ']"';
- //if ($data == 'NULL' && !$first_timestamp) {
- if ($real_null_value && !$first_timestamp) {
- echo ' checked="checked"';
- }
- echo ' id="field_' . $i . '_2"';
- $onclick = ' onclick="if (this.checked) {nullify(';
- if (strstr($row_table_def['True_Type'], 'enum')) {
- if (strlen($row_table_def['Type']) > 20) {
- $onclick .= '1, ';
+ } else if (strstr($row_table_def['True_Type'], 'set')) {
+ $onclick .= '3, ';
+ } else if ($foreigners && isset($foreigners[$field])) {
+ $onclick .= '4, ';
} else {
- $onclick .= '2, ';
+ $onclick .= '5, ';
}
- } else if (strstr($row_table_def['True_Type'], 'set')) {
- $onclick .= '3, ';
- } else if ($foreigners && isset($foreigners[$field])) {
- $onclick .= '4, ';
+ $onclick .= '\'' . urlencode($field) . '\', \'' . md5($field) . '\'); this.checked = true}; return true" />' . "\n";
+ echo $onclick;
} else {
- $onclick .= '5, ';
+ echo ' &nbsp;' . "\n";
}
- $onclick .= '\'' . urlencode($field) . '\', \'' . md5($field) . '\'); this.checked = true}; return true" />' . "\n";
- echo $onclick;
- } else {
- echo ' &nbsp;' . "\n";
- }
- echo ' </td>' . "\n";
-
- // The value column (depends on type)
- // ----------------
-
- require('./libraries/get_foreign.lib.php');
-
- if (isset($foreign_link) && $foreign_link == true) {
- ?>
- <td bgcolor="<?php echo $bgcolor; ?>">
- <?php echo $backup_field . "\n"; ?>
- <input type="hidden" name="fields_type[<?php echo urlencode($field); ?>]" value="foreign" />
- <input type="hidden" name="fields[<?php echo urlencode($field); ?>]" value="" id="field_<?php echo $i; ?>_1" />
- <input type="text" name="field_<?php echo md5($field); ?>[]" class="textfield" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo ($i + 1); ?>" id="field_<?php echo $i; ?>_3" value="<?php echo htmlspecialchars($data); ?>" />
- <script type="text/javascript" language="javascript">
- document.writeln('<a target="_blank" onclick="window.open(this.href, \'foreigners\', \'width=640,height=240,scrollbars=yes\'); return false" href="browse_foreigners.php?<?php echo PMA_generate_common_url($db, $table); ?>&amp;field=<?php echo urlencode($field); ?>"><?php echo str_replace("'", "\'", $titles['Browse']); ?></a>');
- </script>
- </td>
- <?php
- } else if (isset($disp) && $disp) {
- ?>
- <td bgcolor="<?php echo $bgcolor; ?>">
- <?php echo $backup_field . "\n"; ?>
- <input type="hidden" name="fields_type[<?php echo urlencode($field); ?>]" value="foreign" />
- <input type="hidden" name="fields[<?php echo urlencode($field); ?>]" value="" id="field_<?php echo $i; ?>_1" />
- <select name="field_<?php echo md5($field); ?>[]" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo ($i + 1); ?>" id="field_<?php echo $i; ?>_3">
- <?php echo PMA_foreignDropdown($disp, $foreign_field, $foreign_display, $data, 100); ?>
- </select>
- </td>
- <?php
- unset($disp);
- }
- else if ($cfg['LongtextDoubleTextarea'] && strstr($type, 'longtext')) {
- ?>
- <td bgcolor="<?php echo $bgcolor; ?>">&nbsp;</td>
- </tr>
- <tr>
- <td colspan="4" align="right" bgcolor="<?php echo $bgcolor; ?>">
- <?php echo $backup_field . "\n"; ?>
- <textarea name="fields[<?php echo urlencode($field); ?>]" rows="<?php echo ($cfg['TextareaRows']*2); ?>" cols="<?php echo ($cfg['TextareaCols']*2); ?>" wrap="virtual" dir="<?php echo $text_dir; ?>" id="field_<?php echo $i; ?>_3"
- <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo ($i + 1); ?>"><?php echo $special_chars; ?></textarea>
- </td>
- <?php
- }
- else if (strstr($type, 'text')) {
- ?>
- <td bgcolor="<?php echo $bgcolor; ?>">
- <?php echo $backup_field . "\n"; ?>
- <textarea name="fields[<?php echo urlencode($field); ?>]" rows="<?php echo $cfg['TextareaRows']; ?>" cols="<?php echo $cfg['TextareaCols']; ?>" wrap="virtual" dir="<?php echo $text_dir; ?>" id="field_<?php echo $i; ?>_3"
- <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo ($i + 1); ?>"><?php echo $special_chars; ?></textarea>
- </td>
- <?php
- echo "\n";
- if (strlen($special_chars) > 32000) {
- echo ' <td bgcolor="' . $bgcolor . '">' . $strTextAreaLength . '</td>' . "\n";
- }
- }
- else if ($type == 'enum') {
- $enum = PMA_getEnumSetOptions($row_table_def['Type']);
- $enum_cnt = count($enum);
- ?>
- <td bgcolor="<?php echo $bgcolor; ?>">
- <input type="hidden" name="fields_type[<?php echo urlencode($field); ?>]" value="enum" />
- <input type="hidden" name="fields[<?php echo urlencode($field); ?>]" value="" />
- <?php
- echo "\n" . ' ' . $backup_field;
-
- // show dropdown or radio depend on length
- if (strlen($row_table_def['Type']) > 20) {
- echo "\n";
+ echo ' </td>' . "\n";
+
+ // The value column (depends on type)
+ // ----------------
+
+ require('./libraries/get_foreign.lib.php');
+
+ if (isset($foreign_link) && $foreign_link == true) {
?>
- <select name="field_<?php echo md5($field); ?>[]" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo ($i + 1); ?>" id="field_<?php echo $i; ?>_3">
- <option value=""></option>
+ <td bgcolor="<?php echo $bgcolor; ?>">
+ <?php echo $backup_field . "\n"; ?>
+ <input type="hidden" name="fields_type<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="foreign" />
+ <input type="hidden" name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="" id="field_<?php echo ($i * $m_rows); ?>_1" />
+ <input type="text" name="field_<?php echo md5($field); ?><?php echo $vkey; ?>[]" class="textfield" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo (($i * $m_rows) + 1); ?>" id="field_<?php echo ($i * $mrows); ?>_3" value="<?php echo htmlspecialchars($data); ?>" />
+ <script type="text/javascript" language="javascript">
+ document.writeln('<a target="_blank" onclick="window.open(this.href, \'foreigners\', \'width=640,height=240,scrollbars=yes\'); return false" href="browse_foreigners.php?<?php echo PMA_generate_common_url($db, $table); ?>&amp;field=<?php echo urlencode($field) . $browse_foreigners_uri; ?>"><?php echo str_replace("'", "\'", $titles['Browse']); ?></a>');
+ </script>
+ </td>
<?php
- echo "\n";
-
- for ($j = 0; $j < $enum_cnt; $j++) {
- // Removes automatic MySQL escape format
- $enum_atom = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $enum[$j]));
- echo ' ';
- echo '<option value="' . htmlspecialchars($enum_atom) . '"';
- if ($data == $enum_atom
- || ($data == '' && (!isset($primary_key) || $row_table_def['Null'] != 'YES')
- && isset($row_table_def['Default']) && $enum_atom == $row_table_def['Default'])) {
- echo ' selected="selected"';
- }
- echo '>' . htmlspecialchars($enum_atom) . '</option>' . "\n";
- } // end for
-
+ } else if (isset($disp) && $disp) {
?>
+ <td bgcolor="<?php echo $bgcolor; ?>">
+ <?php echo $backup_field . "\n"; ?>
+ <input type="hidden" name="fields_type<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="foreign" />
+ <input type="hidden" name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="" id="field_<?php echo $i; ?>_1" />
+ <select name="field_<?php echo md5($field); ?><?php echo $vkey; ?>[]" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo (($i * $m_rows) + 1); ?>" id="field_<?php echo ($i * $m_rows); ?>_3">
+ <?php echo PMA_foreignDropdown($disp, $foreign_field, $foreign_display, $data, 100); ?>
</select>
+ </td>
<?php
- } // end if
- else {
- echo "\n";
- for ($j = 0; $j < $enum_cnt; $j++) {
- // Removes automatic MySQL escape format
- $enum_atom = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $enum[$j]));
- echo ' ';
- echo '<input type="radio" name="field_' . md5($field) . '[]" value="' . urlencode($enum_atom) . '" id="field_' . $i . '_3_' . $j . '" onclick="if (typeof(document.forms[\'insertForm\'].elements[\'fields_null[' . urlencode($field) . ']\']) != \'undefined\') {document.forms[\'insertForm\'].elements[\'fields_null[' . urlencode($field) .']\'].checked = false}"';
- if ($data == $enum_atom
- || ($data == '' && (!isset($primary_key) || $row_table_def['Null'] != 'YES')
- && isset($row_table_def['Default']) && $enum_atom == $row_table_def['Default'])) {
- echo ' checked="checked"';
- }
- echo 'tabindex="' . ($i + 1) . '" />' . "\n";
- echo ' <label for="field_' . $i . '_3_' . $j . '">' . htmlspecialchars($enum_atom) . '</label>' . "\n";
- } // end for
-
- } // end else
- echo "\n";
- ?>
- </td>
- <?php
- echo "\n";
- }
- else if ($type == 'set') {
- $set = PMA_getEnumSetOptions($row_table_def['Type']);
-
- if (isset($vset)) {
- unset($vset);
+ unset($disp);
}
- for ($vals = explode(',', $data); list($t, $k) = each($vals);) {
- $vset[$k] = 1;
+ else if ($cfg['LongtextDoubleTextarea'] && strstr($type, 'longtext')) {
+ ?>
+ <td bgcolor="<?php echo $bgcolor; ?>">&nbsp;</td>
+ </tr>
+ <tr>
+ <td colspan="4" align="right" bgcolor="<?php echo $bgcolor; ?>">
+ <?php echo $backup_field . "\n"; ?>
+ <textarea name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" rows="<?php echo ($cfg['TextareaRows']*2); ?>" cols="<?php echo ($cfg['TextareaCols']*2); ?>" wrap="virtual" dir="<?php echo $text_dir; ?>" id="field_<?php echo ($i * $m_rows); ?>_3"
+ <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo (($i * $m_rows) + 1); ?>"><?php echo $special_chars; ?></textarea>
+ </td>
+ <?php
}
- $countset = count($set);
- $size = min(4, $countset);
- ?>
- <td bgcolor="<?php echo $bgcolor; ?>">
- <?php echo $backup_field . "\n"; ?>
- <input type="hidden" name="fields_type[<?php echo urlencode($field); ?>]" value="set" />
- <input type="hidden" name="fields[<?php echo urlencode($field); ?>]" value="" />
- <select name="field_<?php echo md5($field); ?>[]" size="<?php echo $size; ?>" multiple="multiple" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo ($i + 1); ?>" id="field_<?php echo $i; ?>_3">
- <?php
- echo "\n";
- for ($j = 0; $j < $countset; $j++) {
- echo ' ';
- echo '<option value="'. htmlspecialchars($set[$j]) . '"';
- if (isset($vset[$set[$j]]) && $vset[$set[$j]]) {
- echo ' selected="selected"';
- }
- echo '>' . htmlspecialchars($set[$j]) . '</option>' . "\n";
- } // end for
- ?>
- </select>
- </td>
- <?php
- }
- // Change by Bernard M. Piller <bernard@bmpsystems.com>
- // We don't want binary data destroyed
- else if ($is_binary || $is_blob) {
- if (($cfg['ProtectBinary'] && $is_blob)
- || ($cfg['ProtectBinary'] == 'all' && $is_binary)) {
+ else if (strstr($type, 'text')) {
+ ?>
+ <td bgcolor="<?php echo $bgcolor; ?>">
+ <?php echo $backup_field . "\n"; ?>
+ <textarea name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" rows="<?php echo $cfg['TextareaRows']; ?>" cols="<?php echo $cfg['TextareaCols']; ?>" wrap="virtual" dir="<?php echo $text_dir; ?>" id="field_<?php echo ($i * $m_rows); ?>_3"
+ <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo (($i * $m_rows) + 1); ?>"><?php echo $special_chars; ?></textarea>
+ </td>
+ <?php
echo "\n";
+ if (strlen($special_chars) > 32000) {
+ echo ' <td bgcolor="' . $bgcolor . '">' . $strTextAreaLength . '</td>' . "\n";
+ }
+ }
+ else if ($type == 'enum') {
+ $enum = PMA_getEnumSetOptions($row_table_def['Type']);
+ $enum_cnt = count($enum);
?>
- <td align="center" bgcolor="<?php echo $bgcolor; ?>">
+ <td bgcolor="<?php echo $bgcolor; ?>">
+ <input type="hidden" name="fields_type<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="enum" />
+ <input type="hidden" name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="" />
<?php
- echo $strBinaryDoNotEdit;
- if (isset($data)) {
- $data_size = PMA_formatByteDown(strlen(stripslashes($data)), 3, 1);
- echo ' ('. $data_size [0] . ' ' . $data_size[1] . ')';
- unset($data_size);
- }
+ echo "\n" . ' ' . $backup_field;
+
+ // show dropdown or radio depend on length
+ if (strlen($row_table_def['Type']) > 20) {
+ echo "\n";
+ ?>
+ <select name="field_<?php echo md5($field); ?><?php echo $vkey; ?>[]" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo (($i * $m_rows) + 1); ?>" id="field_<?php echo ($i * $m_rows); ?>_3">
+ <option value=""></option>
+ <?php
+ echo "\n";
+
+ for ($j = 0; $j < $enum_cnt; $j++) {
+ // Removes automatic MySQL escape format
+ $enum_atom = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $enum[$j]));
+ echo ' ';
+ echo '<option value="' . htmlspecialchars($enum_atom) . '"';
+ if ($data == $enum_atom
+ || ($data == '' && (!isset($primary_key) || $row_table_def['Null'] != 'YES')
+ && isset($row_table_def['Default']) && $enum_atom == $row_table_def['Default'])) {
+ echo ' selected="selected"';
+ }
+ echo '>' . htmlspecialchars($enum_atom) . '</option>' . "\n";
+ } // end for
+
+ ?>
+ </select>
+ <?php
+ } // end if
+ else {
echo "\n";
+ for ($j = 0; $j < $enum_cnt; $j++) {
+ // Removes automatic MySQL escape format
+ $enum_atom = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $enum[$j]));
+ echo ' ';
+ echo '<input type="radio" name="field_' . md5($field) . $vkey . '[]" value="' . urlencode($enum_atom) . '" id="field_' . ($i*$m_rows) . '_3_' . $j . '" onclick="if (typeof(document.forms[\'insertForm\'].elements[\'fields_null' . str_replace('"', '\"', $vkey) . '[' . urlencode($field) . ']\']) != \'undefined\') {document.forms[\'insertForm\'].elements[\'fields_null' . str_replace('"', '\"', $vkey) . '[' . urlencode($field) .']\'].checked = false}"';
+ if ($data == $enum_atom
+ || ($data == '' && (!isset($primary_key) || $row_table_def['Null'] != 'YES')
+ && isset($row_table_def['Default']) && $enum_atom == $row_table_def['Default'])) {
+ echo ' checked="checked"';
+ }
+ echo 'tabindex="' . (($i * $m_rows) + 1) . '" />' . "\n";
+ echo ' <label for="field_' . ($i * $m_rows) . '_3_' . $j . '">' . htmlspecialchars($enum_atom) . '</label>' . "\n";
+ } // end for
+
+ } // end else
+ echo "\n";
?>
- <input type="hidden" name="fields_type[<?php echo urlencode($field); ?>]" value="protected" />
- <input type="hidden" name="fields[<?php echo urlencode($field); ?>]" value="" />
+ </td>
<?php
- } else if ($is_blob) {
echo "\n";
+ }
+ else if ($type == 'set') {
+ $set = PMA_getEnumSetOptions($row_table_def['Type']);
+
+ if (isset($vset)) {
+ unset($vset);
+ }
+ for ($vals = explode(',', $data); list($t, $k) = each($vals);) {
+ $vset[$k] = 1;
+ }
+ $countset = count($set);
+ $size = min(4, $countset);
?>
- <td bgcolor="<?php echo $bgcolor; ?>">
- <?php echo $backup_field . "\n"; ?>
- <textarea name="fields[<?php echo urlencode($field); ?>]" rows="<?php echo $cfg['TextareaRows']; ?>" cols="<?php echo $cfg['TextareaCols']; ?>" wrap="virtual" dir="<?php echo $text_dir; ?>" id="field_<?php echo $i; ?>_3"
- <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo ($i + 1); ?>" ><?php echo $special_chars; ?></textarea>
+ <td bgcolor="<?php echo $bgcolor; ?>">
+ <?php echo $backup_field . "\n"; ?>
+ <input type="hidden" name="fields_type<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="set" />
+ <input type="hidden" name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="" />
+ <select name="field_<?php echo md5($field); ?><?php echo $vkey; ?>[]" size="<?php echo $size; ?>" multiple="multiple" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo (($i * $m_rows) + 1); ?>" id="field_<?php echo ($i * $m_rows); ?>_3">
<?php
-
- } else {
- if ($len < 4) {
- $fieldsize = $maxlength = 4;
- } else {
- $fieldsize = (($len > 40) ? 40 : $len);
- $maxlength = $len;
- }
echo "\n";
+ for ($j = 0; $j < $countset; $j++) {
+ echo ' ';
+ echo '<option value="'. htmlspecialchars($set[$j]) . '"';
+ if (isset($vset[$set[$j]]) && $vset[$set[$j]]) {
+ echo ' selected="selected"';
+ }
+ echo '>' . htmlspecialchars($set[$j]) . '</option>' . "\n";
+ } // end for
?>
- <td bgcolor="<?php echo $bgcolor; ?>">
- <?php echo $backup_field . "\n"; ?>
- <input type="text" name="fields[<?php echo urlencode($field); ?>]" value="<?php echo $special_chars; ?>" size="<?php echo $fieldsize; ?>" maxlength="<?php echo $maxlength; ?>" class="textfield" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo ($i + 1); ?>" id="field_<?php echo $i; ?>_3" />
+ </select>
+ </td>
<?php
- } // end if...elseif...else
-
- // Upload choice (only for BLOBs because the binary
- // attribute does not imply binary contents)
- // (displayed whatever value the ProtectBinary has)
-
- if ($is_upload && $is_blob) {
- echo '<input type="file" name="fields_upload_' . urlencode($field) . '" class="textfield" id="field_' . $i . '_3" />';
}
-
- if (!empty($cfg['UploadDir'])) {
- if (substr($cfg['UploadDir'], -1) != '/') {
- $cfg['UploadDir'] .= '/';
- }
- if ($handle = @opendir($cfg['UploadDir'])) {
- $is_first = 0;
- while ($file = @readdir($handle)) {
- if (is_file($cfg['UploadDir'] . $file) && !PMA_checkFileExtensions($file, '.sql')) {
- if ($is_first == 0) {
- echo "<br />\n";
- echo ' <i>' . $strOr . '</i>' . ' ' . $strWebServerUploadDirectory . '&nbsp;:<br />' . "\n";
- echo ' <select size="1" name="fields_uploadlocal_' . urlencode($field) . '">' . "\n";
- echo ' <option value="" selected="selected"></option>' . "\n";
- } // end if (is_first)
- echo ' <option value="' . htmlspecialchars($file) . '">' . htmlspecialchars($file) . '</option>' . "\n";
- $is_first++;
- } // end if (is_file)
- } // end while
- if ($is_first > 0) {
- echo ' </select>' . "\n";
- } // end if (isfirst > 0)
- @closedir($handle);
+ // Change by Bernard M. Piller <bernard@bmpsystems.com>
+ // We don't want binary data destroyed
+ else if ($is_binary || $is_blob) {
+ if (($cfg['ProtectBinary'] && $is_blob)
+ || ($cfg['ProtectBinary'] == 'all' && $is_binary)) {
+ echo "\n";
+ ?>
+ <td align="center" bgcolor="<?php echo $bgcolor; ?>">
+ <?php
+ echo $strBinaryDoNotEdit;
+ if (isset($data)) {
+ $data_size = PMA_formatByteDown(strlen(stripslashes($data)), 3, 1);
+ echo ' ('. $data_size [0] . ' ' . $data_size[1] . ')';
+ unset($data_size);
+ }
+ echo "\n";
+ ?>
+ <input type="hidden" name="fields_type<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="protected" />
+ <input type="hidden" name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="" />
+ <?php
+ } else if ($is_blob) {
+ echo "\n";
+ ?>
+ <td bgcolor="<?php echo $bgcolor; ?>">
+ <?php echo $backup_field . "\n"; ?>
+ <textarea name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" rows="<?php echo $cfg['TextareaRows']; ?>" cols="<?php echo $cfg['TextareaCols']; ?>" wrap="virtual" dir="<?php echo $text_dir; ?>" id="field_<?php echo ($i*$m_rows); ?>_3"
+ <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo (($i * $m_rows) + 1); ?>" ><?php echo $special_chars; ?></textarea>
+ <?php
+
} else {
- echo ' <font color="red">' . $strError . '</font><br />' . "\n";
- echo ' ' . $strWebServerUploadDirectoryError . "\n";
+ if ($len < 4) {
+ $fieldsize = $maxlength = 4;
+ } else {
+ $fieldsize = (($len > 40) ? 40 : $len);
+ $maxlength = $len;
+ }
+ echo "\n";
+ ?>
+ <td bgcolor="<?php echo $bgcolor; ?>">
+ <?php echo $backup_field . "\n"; ?>
+ <input type="text" name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="<?php echo $special_chars; ?>" size="<?php echo $fieldsize; ?>" maxlength="<?php echo $maxlength; ?>" class="textfield" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo (($i * $m_rows) + 1); ?>" id="field_<?php echo ($i * $m_rows); ?>_3" />
+ <?php
+ } // end if...elseif...else
+
+ // Upload choice (only for BLOBs because the binary
+ // attribute does not imply binary contents)
+ // (displayed whatever value the ProtectBinary has)
+
+ if ($is_upload && $is_blob) {
+ echo '<input type="file" name="fields_upload_' . urlencode($field) . $vkey . '" class="textfield" id="field_' . ($i * $m_rows) . '_3" />';
}
- } // end if (web-server upload directory)
-
- echo '</td>';
-
- } // end else if ( binary or blob)
- else {
- // For char or varchar, respect the maximum length (M); for other
- // types (int or float), the length is not a limit on the values that
- // can be entered, so let's be generous (20) (we could also use the
- // real limits for each numeric type)
- if ($is_char) {
- $fieldsize = (($len > 40) ? 40 : $len);
- $maxlength = $len;
- }
+
+ if (!empty($cfg['UploadDir'])) {
+ if (substr($cfg['UploadDir'], -1) != '/') {
+ $cfg['UploadDir'] .= '/';
+ }
+ if ($handle = @opendir($cfg['UploadDir'])) {
+ $is_first = 0;
+ while ($file = @readdir($handle)) {
+ if (is_file($cfg['UploadDir'] . $file) && !PMA_checkFileExtensions($file, '.sql')) {
+ if ($is_first == 0) {
+ echo "<br />\n";
+ echo ' <i>' . $strOr . '</i>' . ' ' . $strWebServerUploadDirectory . '&nbsp;:<br />' . "\n";
+ echo ' <select size="1" name="fields_uploadlocal_' . urlencode($field) . $vkey . '">' . "\n";
+ echo ' <option value="" selected="selected"></option>' . "\n";
+ } // end if (is_first)
+ echo ' <option value="' . htmlspecialchars($file) . '">' . htmlspecialchars($file) . '</option>' . "\n";
+ $is_first++;
+ } // end if (is_file)
+ } // end while
+ if ($is_first > 0) {
+ echo ' </select>' . "\n";
+ } // end if (isfirst > 0)
+ @closedir($handle);
+ } else {
+ echo ' <font color="red">' . $strError . '</font><br />' . "\n";
+ echo ' ' . $strWebServerUploadDirectoryError . "\n";
+ }
+ } // end if (web-server upload directory)
+
+ echo '</td>';
+
+ } // end else if ( binary or blob)
else {
- $fieldsize = $maxlength = 20;
- } // end if... else...
- echo "\n";
- ?>
- <td bgcolor="<?php echo $bgcolor; ?>">
- <?php echo $backup_field . "\n"; ?>
- <?php
- if ($is_char && isset($cfg['CharEditing']) && ($cfg['CharEditing'] == 'textarea')) {
+ // For char or varchar, respect the maximum length (M); for other
+ // types (int or float), the length is not a limit on the values that
+ // can be entered, so let's be generous (20) (we could also use the
+ // real limits for each numeric type)
+ if ($is_char) {
+ $fieldsize = (($len > 40) ? 40 : $len);
+ $maxlength = $len;
+ }
+ else {
+ $fieldsize = $maxlength = 20;
+ } // end if... else...
echo "\n";
?>
- <textarea name="fields[<?php echo urlencode($field); ?>]" rows="<?php echo $cfg['CharTextareaRows']; ?>" cols="<?php echo $cfg['CharTextareaCols']; ?>" wrap="virtual" dir="<?php echo $text_dir; ?>" id="field_<?php echo $i; ?>_3"
- <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo ($i + 1); ?>" ><?php echo $special_chars; ?></textarea>
+ <td bgcolor="<?php echo $bgcolor; ?>">
+ <?php echo $backup_field . "\n"; ?>
<?php
- } else {
+ if ($is_char && isset($cfg['CharEditing']) && ($cfg['CharEditing'] == 'textarea')) {
+ echo "\n";
+ ?>
+ <textarea name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" rows="<?php echo $cfg['CharTextareaRows']; ?>" cols="<?php echo $cfg['CharTextareaCols']; ?>" wrap="virtual" dir="<?php echo $text_dir; ?>" id="field_<?php echo ($i * $m_rows); ?>_3"
+ <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo (($i * $m_rows) + 1); ?>" ><?php echo $special_chars; ?></textarea>
+ <?php
+ } else {
+ echo "\n";
+ ?>
+ <input type="text" name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="<?php echo $special_chars; ?>" size="<?php echo $fieldsize; ?>" maxlength="<?php echo $maxlength; ?>" class="textfield" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo (($i * $m_rows) + 1); ?>" id="field_<?php echo ($i * $m_rows); ?>_3" />
+ <?php
+ }
echo "\n";
?>
- <input type="text" name="fields[<?php echo urlencode($field); ?>]" value="<?php echo $special_chars; ?>" size="<?php echo $fieldsize; ?>" maxlength="<?php echo $maxlength; ?>" class="textfield" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo ($i + 1); ?>" id="field_<?php echo $i; ?>_3" />
+ </td>
<?php
}
echo "\n";
?>
- </td>
+ </tr>
<?php
- }
echo "\n";
- ?>
- </tr>
- <?php
-echo "\n";
-} // end for
+ } // end for
+ $o_rows++;
+ echo ' </table><br />';
+} // end foreach on multi-edit
?>
- </table>
<br />
<table cellpadding="5">
diff --git a/tbl_replace.php b/tbl_replace.php
index 1e5286b8d7..b9781aa8c3 100644
--- a/tbl_replace.php
+++ b/tbl_replace.php
@@ -58,7 +58,7 @@ if (isset($err_url)) {
$err_url = urldecode($err_url);
} else {
$err_url = str_replace('&', '&amp;', $goto)
- . (empty($primary_key) ? '' : '&amp;primary_key=' . $primary_key);
+ . (empty($primary_key) ? '' : '&amp;primary_key=' . (is_array($primary_key) ? $primary_key[0] : $primary_key));
}
// Resets tables defined in the configuration file
@@ -73,46 +73,60 @@ $seen_binary = FALSE;
* Prepares the update of a row
*/
if (isset($primary_key) && ($submit_type != $strInsertAsNewRow)) {
- // Restore the "primary key" to a convenient format
- $primary_key = urldecode($primary_key);
-
- // Defines the SET part of the sql query
- $valuelist = '';
-
- foreach($fields AS $key => $val) {
- $encoded_key = $key;
- $key = urldecode($key);
-
- require('./tbl_replace_fields.php');
-
- // No change for this column and no MySQL function is used -> next column
- if (empty($funcs[$encoded_key])
- && isset($fields_prev) && isset($fields_prev[$encoded_key])
- && ("'" . PMA_sqlAddslashes(urldecode($fields_prev[$encoded_key])) . "'" == $val)) {
- continue;
- }
- else if (!empty($val)) {
- if (empty($funcs[$encoded_key])) {
- $valuelist .= PMA_backquote($key) . ' = ' . $val . ', ';
- } else if ($val == '\'\''
- && (preg_match('@^(NOW|CURDATE|CURTIME|UNIX_TIMESTAMP|RAND|USER|LAST_INSERT_ID)$@', $funcs[$encoded_key]))) {
- $valuelist .= PMA_backquote($key) . ' = ' . $funcs[$encoded_key] . '(), ';
- } else {
- $valuelist .= PMA_backquote($key) . ' = ' . $funcs[$encoded_key] . "($val), ";
+ $loop_array = (is_array($primary_key) ? $primary_key : array(0 => $primary_key));
+ PMA_mysql_select_db($db);
+ $query = array();
+ $message = '';
+
+ foreach($loop_array AS $primary_key_index => $enc_primary_key) {
+ // Restore the "primary key" to a convenient format
+ $primary_key = urldecode($enc_primary_key);
+
+ // Defines the SET part of the sql query
+ $valuelist = '';
+
+ // Map multi-edit keys to single-level arrays, dependent on how we got the fields
+ $me_fields = (isset($fields['multi_edit']) ? $fields['multi_edit'][$enc_primary_key] : $fields);
+ $me_fields_prev = (isset($fields_prev['multi_edit']) ? $fields_prev['multi_edit'][$enc_primary_key] : $fields_prev);
+ $me_funcs = (isset($funcs['multi_edit']) ? $funcs['multi_edit'][$enc_primary_key] : $funcs);
+ $me_fields_type = (isset($fields_type['multi_edit']) ? $fields_type['multi_edit'][$enc_primary_key] : $fields_type);
+ $me_fields_null = (isset($fields_null['multi_edit']) ? $fields_null['multi_edit'][$enc_primary_key] : $fields_null);
+
+ foreach($me_fields AS $key => $val) {
+ $encoded_key = $key;
+ $key = urldecode($key);
+
+ require('./tbl_replace_fields.php');
+
+ // No change for this column and no MySQL function is used -> next column
+ if (empty($me_funcs[$encoded_key])
+ && isset($me_fields_prev) && isset($me_fields_prev[$encoded_key])
+ && ("'" . PMA_sqlAddslashes(urldecode($me_fields_prev[$encoded_key])) . "'" == $val)) {
+ continue;
+ }
+ else if (!empty($val)) {
+ if (empty($me_funcs[$encoded_key])) {
+ $valuelist .= PMA_backquote($key) . ' = ' . $val . ', ';
+ } else if ($val == '\'\''
+ && (preg_match('@^(NOW|CURDATE|CURTIME|UNIX_TIMESTAMP|RAND|USER|LAST_INSERT_ID)$@', $me_funcs[$encoded_key]))) {
+ $valuelist .= PMA_backquote($key) . ' = ' . $me_funcs[$encoded_key] . '(), ';
+ } else {
+ $valuelist .= PMA_backquote($key) . ' = ' . $me_funcs[$encoded_key] . "($val), ";
+ }
}
+ } // end while
+
+ // Builds the sql update query
+ $valuelist = preg_replace('@, $@', '', $valuelist);
+ if (!empty($valuelist)) {
+ $query[] = 'UPDATE ' . PMA_backquote($table) . ' SET ' . $valuelist . ' WHERE' . $primary_key
+ . ' LIMIT 1';
+ $message = $strAffectedRows . '&nbsp;<br />';
}
- } // end while
-
- // Builds the sql update query
- $valuelist = preg_replace('@, $@', '', $valuelist);
- if (!empty($valuelist)) {
- PMA_mysql_select_db($db);
- $query = 'UPDATE ' . PMA_backquote($table) . ' SET ' . $valuelist . ' WHERE' . $primary_key
- . ' LIMIT 1';
- $message = $strAffectedRows . '&nbsp;';
}
- // No change -> move back to the calling script
- else {
+
+ if (empty($valuelist)) {
+ // No change -> move back to the calling script
$message = $strNoModification;
if ($is_gotofile) {
$js_to_run = 'functions.js';
@@ -130,41 +144,52 @@ if (isset($primary_key) && ($submit_type != $strInsertAsNewRow)) {
* Prepares the insert of a row
*/
else {
+ $loop_array = (isset($primary_key) && is_array($primary_key) ? $primary_key : array(0 => (isset($primary_key) ? $primary_key : null)));
+ $query = array();
+ $message = '';
PMA_mysql_select_db($db);
-
- $fieldlist = '';
- $valuelist = '';
-
- // garvin: Get, if sent, any protected fields to insert them here:
- if (isset($fields_type) && is_array($fields_type) && isset($primary_key)) {
- $prot_local_query = 'SELECT * FROM ' . PMA_backquote($table) . ' WHERE ' . urldecode($primary_key);
- $prot_result = PMA_mysql_query($prot_local_query) or PMA_mysqlDie('', $prot_local_query, '', $err_url);
- $prot_row = PMA_mysql_fetch_array($prot_result);
- }
-
- foreach($fields AS $key => $val) {
- $encoded_key = $key;
- $key = urldecode($key);
- $fieldlist .= PMA_backquote($key) . ', ';
-
- require('./tbl_replace_fields.php');
-
- if (empty($funcs[$encoded_key])) {
- $valuelist .= $val . ', ';
- } else if (($val == '\'\''
- && preg_match('@^(UNIX_TIMESTAMP|RAND|LAST_INSERT_ID)$@', $funcs[$encoded_key]))
- || preg_match('@^(NOW|CURDATE|CURTIME|USER)$@', $funcs[$encoded_key])) {
- $valuelist .= $funcs[$encoded_key] . '(), ';
- } else {
- $valuelist .= $funcs[$encoded_key] . '(' . $val . '), ';
+
+ foreach($loop_array AS $primary_key_index => $enc_primary_key) {
+ $fieldlist = '';
+ $valuelist = '';
+
+ $me_fields = (isset($fields['multi_edit']) ? $fields['multi_edit'][$enc_primary_key] : $fields);
+ $me_fields_prev = (isset($fields_prev['multi_edit']) ? $fields_prev['multi_edit'][$enc_primary_key] : $fields_prev);
+ $me_funcs = (isset($funcs['multi_edit']) ? $funcs['multi_edit'][$enc_primary_key] : $funcs);
+ $me_fields_type = (isset($fields_type['multi_edit']) ? $fields_type['multi_edit'][$enc_primary_key] : $fields_type);
+ $me_fields_null = (isset($fields_null['multi_edit']) ? $fields_null['multi_edit'][$enc_primary_key] : $fields_null);
+
+ // garvin: Get, if sent, any protected fields to insert them here:
+ if (isset($me_fields_type) && is_array($me_fields_type) && isset($enc_primary_key)) {
+ $prot_local_query = 'SELECT * FROM ' . PMA_backquote($table) . ' WHERE ' . urldecode($enc_primary_key);
+ $prot_result = PMA_mysql_query($prot_local_query) or PMA_mysqlDie('', $prot_local_query, '', $err_url);
+ $prot_row = PMA_mysql_fetch_array($prot_result);
}
- } // end while
-
- // Builds the sql insert query
- $fieldlist = preg_replace('@, $@', '', $fieldlist);
- $valuelist = preg_replace('@, $@', '', $valuelist);
- $query = 'INSERT INTO ' . PMA_backquote($table) . ' (' . $fieldlist . ') VALUES (' . $valuelist . ')';
- $message = $strInsertedRows . '&nbsp;';
+
+ foreach($me_fields AS $key => $val) {
+ $encoded_key = $key;
+ $key = urldecode($key);
+ $fieldlist .= PMA_backquote($key) . ', ';
+
+ require('./tbl_replace_fields.php');
+
+ if (empty($me_funcs[$encoded_key])) {
+ $valuelist .= $val . ', ';
+ } else if (($val == '\'\''
+ && preg_match('@^(UNIX_TIMESTAMP|RAND|LAST_INSERT_ID)$@', $me_funcs[$encoded_key]))
+ || preg_match('@^(NOW|CURDATE|CURTIME|USER)$@', $me_funcs[$encoded_key])) {
+ $valuelist .= $me_funcs[$encoded_key] . '(), ';
+ } else {
+ $valuelist .= $me_funcs[$encoded_key] . '(' . $val . '), ';
+ }
+ } // end while
+
+ // Builds the sql insert query
+ $fieldlist = preg_replace('@, $@', '', $fieldlist);
+ $valuelist = preg_replace('@, $@', '', $valuelist);
+ $query[] = 'INSERT INTO ' . PMA_backquote($table) . ' (' . $fieldlist . ') VALUES (' . $valuelist . ')';
+ $message = $strInsertedRows . '&nbsp;';
+ }
} // end row insertion
@@ -172,41 +197,55 @@ else {
* Executes the sql query and get the result, then move back to the calling
* page
*/
-$sql_query = $query . ';';
-$result = PMA_mysql_query($query);
-if (!$result) {
- $error = PMA_mysql_error();
- require_once('./header.inc.php');
- PMA_mysqlDie($error, '', '', $err_url);
-} else {
- if (@mysql_affected_rows()) {
- $message .= @mysql_affected_rows();
- } else {
- $message = $strModifications;
- }
- $insert_id = mysql_insert_id();
- if ($insert_id != 0) {
- $message .= '<br />'.$strInsertedRowId . '&nbsp;' . $insert_id;
- }
- if ($is_gotofile) {
- if ($goto == 'db_details.php' && !empty($table)) {
- unset($table);
+$sql_query = implode(';', $query) . ';';
+$total_affected_rows = 0;
+
+foreach($query AS $query_index => $single_query) {
+ $result = PMA_mysql_query($single_query);
+ if (!$result) {
+ if ($cfg['IgnoreMultiSubmitErrors']) {
+ $message .= PMA_mysql_error();
+ } else {
+ $error = PMA_mysql_error();
+ require_once('./header.inc.php');
+ PMA_mysqlDie($error, '', '', $err_url);
}
- $js_to_run = 'functions.js';
- $active_page = $goto;
- require_once('./header.inc.php');
- require('./' . preg_replace('@\.\.*@', '.', $goto));
} else {
- // I don't understand this one:
- //$add_query = (strpos(' ' . $goto, 'tbl_change') ? '&disp_query=' . urlencode($sql_query) : '');
-
- // if we have seen binary,
- // we do not append the query to the Location so it won't be displayed
- // on the resulting page
- // Nijel: we also need to limit size of url...
- $add_query = (!$seen_binary && strlen($sql_query) < 1024 ? '&disp_query=' . urlencode($sql_query) : '');
- header('Location: ' . $cfg['PmaAbsoluteUri'] . $goto . '&disp_message=' . urlencode($message) . $add_query);
+ if (@mysql_affected_rows()) {
+ $total_affected_rows += @mysql_affected_rows;
+ }
+
+ $insert_id = mysql_insert_id();
+ if ($insert_id != 0) {
+ $message .= '<br />'.$strInsertedRowId . '&nbsp;' . $insert_id;
+ }
+ } // end if
+}
+
+if ($total_affected_rows != 0) {
+ $message .= '<br />' . $total_affected_rows;
+} else {
+ $message .= $strModifications;
+}
+
+if ($is_gotofile) {
+ if ($goto == 'db_details.php' && !empty($table)) {
+ unset($table);
}
- exit();
-} // end if
+ $js_to_run = 'functions.js';
+ $active_page = $goto;
+ require_once('./header.inc.php');
+ require('./' . preg_replace('@\.\.*@', '.', $goto));
+} else {
+ // I don't understand this one:
+ //$add_query = (strpos(' ' . $goto, 'tbl_change') ? '&disp_query=' . urlencode($sql_query) : '');
+
+ // if we have seen binary,
+ // we do not append the query to the Location so it won't be displayed
+ // on the resulting page
+ // Nijel: we also need to limit size of url...
+ $add_query = (!$seen_binary && strlen($sql_query) < 1024 ? '&disp_query=' . urlencode($sql_query) : '');
+ header('Location: ' . $cfg['PmaAbsoluteUri'] . $goto . '&disp_message=' . urlencode($message) . $add_query);
+}
+exit();
?>
diff --git a/tbl_replace_fields.php b/tbl_replace_fields.php
index b496bfc128..9dde6b349c 100644
--- a/tbl_replace_fields.php
+++ b/tbl_replace_fields.php
@@ -26,13 +26,18 @@ PMA_checkParameters(array('db','encoded_key'));
// binary file is uploaded, thus bypassing further manipulation of $val.
$check_stop = false;
-if (isset(${'fields_upload_' . $encoded_key}) && ${'fields_upload_' . $encoded_key} != 'none'){
+
+// Check if a multi-edit row was found
+${'me_fields_upload_' . $encoded_key} = (isset($enc_primary_key) && isset(${'fields_upload_' . $encoded_key}['multi_edit']) ? ${'fields_upload_' . $encoded_key}['multi_edit'][$enc_primary_key] : ${'fields_upload_' . $encoded_key});
+${'me_fields_uploadlocal_' . $encoded_key} = (isset($enc_primary_key) && isset(${'fields_uploadlocal_' . $encoded_key}['multi_edit']) ? ${'fields_uploadlocal_' . $encoded_key}['multi_edit'][$enc_primary_key] : ${'fields_uploadlocal_' . $encoded_key});
+
+if (isset(${'me_fields_upload_' . $encoded_key}) && ${'me_fields_upload_' . $encoded_key} != 'none'){
// garvin: This fields content is a blob-file upload.
- if (!empty(${'fields_upload_' . $encoded_key})) {
+ if (!empty(${'me_fields_upload_' . $encoded_key})) {
// garvin: The blob-field is not empty. Check what we have there.
- $data_file = ${'fields_upload_' . $encoded_key};
+ $data_file = ${'me_fields_upload_' . $encoded_key};
if (is_uploaded_file($data_file)) {
// garvin: A valid uploaded file is found. Look into the file...
@@ -56,11 +61,11 @@ if (isset(${'fields_upload_' . $encoded_key}) && ${'fields_upload_' . $encoded_k
// void
}
- } elseif (!empty(${'fields_uploadlocal_' . $encoded_key})) {
+ } elseif (!empty(${'me_fields_uploadlocal_' . $encoded_key})) {
if (substr($cfg['UploadDir'], -1) != '/') {
$cfg['UploadDir'] .= '/';
}
- $file_to_upload = $cfg['UploadDir'] . preg_replace('@\.\.*@', '.', ${'fields_uploadlocal_' . $encoded_key});
+ $file_to_upload = $cfg['UploadDir'] . preg_replace('@\.\.*@', '.', ${'me_fields_uploadlocal_' . $encoded_key});
// A local file will be uploaded.
$open_basedir = @ini_get('open_basedir');
@@ -110,8 +115,18 @@ if (!$check_stop) {
// f i e l d v a l u e i n t h e f o r m
- if (isset($fields_type[$encoded_key])) $type = $fields_type[$encoded_key];
+ if (isset($me_fields_type[$encoded_key])) $type = $me_fields_type[$encoded_key];
else $type = '';
+
+ $f = 'field_' . md5($key);
+ $t_fval = $$f;
+
+ if (isset($t_fval['multi_edit'][$enc_primary_key])) {
+ $fval = &$t_fval['multi_edit'][$enc_primary_key];
+ } else {
+ $fval = &$t_fval;
+ }
+
switch (strtolower($val)) {
// let users type NULL or null to input this string and not a NULL value
//case 'null':
@@ -120,9 +135,8 @@ if (!$check_stop) {
switch ($type) {
case 'enum':
// if we have an enum, then construct the value
- $f = 'field_' . md5($key);
- if (!empty($$f)) {
- $val = implode(',', $$f);
+ if (!empty($fval)) {
+ $val = implode(',', $fval);
if ($val == 'null') {
// void
} else {
@@ -136,9 +150,8 @@ if (!$check_stop) {
break;
case 'set':
// if we have a set, then construct the value
- $f = 'field_' . md5($key);
- if (!empty($$f)) {
- $val = implode(',', $$f);
+ if (!empty($fval)) {
+ $val = implode(',', $fval);
// the data here is not urlencoded!
//$val = "'" . PMA_sqlAddslashes(urldecode($val)) . "'";
$val = "'" . PMA_sqlAddslashes($val) . "'";
@@ -148,9 +161,8 @@ if (!$check_stop) {
break;
case 'foreign':
// if we have a foreign key, then construct the value
- $f = 'field_' . md5($key);
- if (!empty($$f)) {
- $val = implode(',', $$f);
+ if (!empty($fval)) {
+ $val = implode(',', $fval);
if ($val == 'null') {
// void
} else {
@@ -196,7 +208,7 @@ if (!$check_stop) {
// Was the Null checkbox checked for this field?
// (if there is a value, we ignore the Null checkbox: this could
// be possible if Javascript is disabled in the browser)
- if (isset($fields_null) && isset($fields_null[$encoded_key])
+ if (isset($me_fields_null) && isset($me_fields_null[$encoded_key])
&& $val=="''") {
$val = 'NULL';
}
diff --git a/tbl_row_delete.php b/tbl_row_delete.php
index 5c9db87ca4..2073b3d6b5 100644
--- a/tbl_row_delete.php
+++ b/tbl_row_delete.php
@@ -13,47 +13,75 @@ require_once('./header.inc.php');
// workaround for IE problem:
if (isset($submit_mult_x)) {
$submit_mult = 'row_delete';
+} elseif (isset($submit_mult_edit_x)) {
+ $submit_mult = 'row_edit';
}
-if ((!empty($submit_mult) && isset($rows_to_delete) && is_array($rows_to_delete))
- || isset($mult_btn)) {
- $action = 'tbl_row_delete.php';
- $err_url = 'tbl_row_delete.php?' . PMA_generate_common_url($db, $table);
- if (!isset($mult_btn)) {
- $original_sql_query = $sql_query;
- $original_url_query = $url_query;
- $original_pos = $pos;
- }
- require('./mult_submits.inc.php');
-}
-$url_query = PMA_generate_common_url($db, $table)
- . '&amp;goto=tbl_properties.php';
-
-
-/**
- * Show result of multi submit operation
- */
-if ((!empty($submit_mult) && isset($rows_to_delete))
- || isset($mult_btn)) {
- PMA_showMessage($strSuccess);
-}
-
-if (isset($original_sql_query)) {
- $sql_query = $original_sql_query;
-}
-
-if (isset($original_url_query)) {
- $url_query = $original_url_query;
+// garvin: If the 'Ask for confirmation' button was pressed, this can only come from 'delete' mode,
+// so we set it straight away.
+if (isset($mult_btn)) {
+ $submit_mult = 'row_delete';
}
-if (isset($original_pos)) {
- $pos = $original_pos;
+if (!empty($submit_mult)) {
+ switch($submit_mult) {
+ case 'row_edit':
+ if (isset($rows_to_delete) && is_array($rows_to_delete)) {
+ $primary_key = array();
+ // garvin: As we got the fields to be edited from the 'rows_to_delete' checkbox, we use the index of it as the
+ // indicating primary key. Then we built the array which is used for the tbl_change.php script.
+ foreach($rows_to_delete AS $i_primary_key => $del_query) {
+ $primary_key[] = urldecode($i_primary_key);
+ }
+
+ include './tbl_change.php';
+ }
+ break;
+
+ case 'row_delete':
+ default:
+ if ((isset($rows_to_delete) && is_array($rows_to_delete))
+ || isset($mult_btn)) {
+ $action = 'tbl_row_delete.php';
+ $err_url = 'tbl_row_delete.php?' . PMA_generate_common_url($db, $table);
+ if (!isset($mult_btn)) {
+ $original_sql_query = $sql_query;
+ $original_url_query = $url_query;
+ $original_pos = $pos;
+ }
+ require('./mult_submits.inc.php');
+ }
+ $url_query = PMA_generate_common_url($db, $table)
+ . '&amp;goto=tbl_properties.php';
+
+
+ /**
+ * Show result of multi submit operation
+ */
+ if ((!empty($submit_mult) && isset($rows_to_delete))
+ || isset($mult_btn)) {
+ PMA_showMessage($strSuccess);
+ }
+
+ if (isset($original_sql_query)) {
+ $sql_query = $original_sql_query;
+ }
+
+ if (isset($original_url_query)) {
+ $url_query = $original_url_query;
+ }
+
+ if (isset($original_pos)) {
+ $pos = $original_pos;
+ }
+
+ require('./sql.php');
+
+ /**
+ * Displays the footer
+ */
+ require_once('./footer.inc.php');
+ break;
+ }
}
-
-require('./sql.php');
-
-/**
- * Displays the footer
- */
-require_once('./footer.inc.php');
?>