diff --git a/db_details.php3 b/db_details.php3
index c4b9000c0..4c75e7337 100755
--- a/db_details.php3
+++ b/db_details.php3
@@ -31,7 +31,7 @@ window.parent.frames['nav'].location.replace('./left.php3?lang=';
+ break;
+
+ case 'drop_tbl':
+ $full_query .= 'DROP TABLE '
+ . backquote(htmlspecialchars(urldecode($selected[$i])))
+ . ';
';
+ break;
+
+ case 'empty_tbl':
+ $full_query .= 'DELETE FROM '
+ . backquote(htmlspecialchars(urldecode($selected[$i])))
+ . ';
';
+ break;
+
+ case 'drop_fld':
+ $full_query .= 'ALTER TABLE '
+ . backquote(htmlspecialchars($table))
+ . ' DROP '
+ . backquote(htmlspecialchars(urldecode($selected[$i])))
+ . ';
';
+ break;
+ } // end switch
+ }
+
+ // Displays the form
+ echo $strDoYouReally . ' :
' . "\n";
+ echo '' . $full_query . ' ?
' . "\n";
+ ?>
+
+
diff --git a/tbl_alter.php3 b/tbl_alter.php3
index c673b29c8..e0c85f29b 100755
--- a/tbl_alter.php3
+++ b/tbl_alter.php3
@@ -6,65 +6,72 @@
* Gets some core libraries
*/
require('./grab_globals.inc.php3');
-if (isset($submit)) {
- $js_to_run = 'functions.js';
+if (!isset($submit_mult)) {
+ if (isset($submit)) {
+ $js_to_run = 'functions.js';
+ }
+ include('./header.inc.php3');
}
-require('./header.inc.php3');
/**
* Modifications have been submitted -> updates the table
*/
if (isset($submit)) {
- if (get_magic_quotes_gpc()) {
- $field_name[0] = stripslashes($field_name[0]);
- $field_default[0] = stripslashes($field_default[0]);
- $field_length[0] = stripslashes($field_length[0]);
- }
-
- if (MYSQL_INT_VERSION < 32306) {
- check_reserved_words($field_name[0]);
- }
-
- // Some fields have been urlencoded or double quotes have been translated
- // to """ in tbl_properties.php3
- $field_orig[0] = urldecode($field_orig[0]);
- if (str_replace('"', '"', $field_orig[0]) == $field_name[0]) {
- $field_name[0] = $field_orig[0];
- }
- $field_default_orig[0] = urldecode($field_default_orig[0]);
- if (str_replace('"', '"', $field_default_orig[0]) == $field_default[0]) {
- $field_default[0] = $field_default_orig[0];
- }
- $field_length_orig[0] = urldecode($field_length_orig[0]);
- if (str_replace('"', '"', $field_length_orig[0]) == $field_length[0]) {
- $field_length[0] = $field_length_orig[0];
- }
- if (!isset($query)) {
- $query = '';
- }
- $query .= ' ' . backquote($field_orig[0]) . ' ' . backquote($field_name[0]) . ' ' . $field_type[0];
- // Some field types shouldn't have lengths
- if ($field_length[0] != ''
- && !eregi('^(DATE|DATETIME|TIME|TINYBLOB|TINYTEXT|BLOB|TEXT|MEDIUMBLOB|MEDIUMTEXT|LONGBLOB|LONGTEXT)$', $field_type[0])) {
- $query .= '(' . $field_length[0] . ')';
- }
- if ($field_attribute[0] != '') {
- $query .= ' ' . $field_attribute[0];
- }
- if ($field_default[0] != '') {
- if (strtoupper($field_default[0]) == 'NULL') {
- $query .= ' DEFAULT NULL';
- } else {
- $query .= ' DEFAULT \'' . sql_addslashes($field_default[0]) . '\'';
+ $field_cnt = count($field_orig);
+ for ($i = 0; $i < $field_cnt; $i++) {
+ if (get_magic_quotes_gpc()) {
+ $field_name[$i] = stripslashes($field_name[$i]);
+ $field_default[$i] = stripslashes($field_default[$i]);
+ $field_length[$i] = stripslashes($field_length[$i]);
}
- }
- if ($field_null[0] != '') {
- $query .= ' ' . $field_null[0];
- }
- if ($field_extra[0] != '') {
- $query .= ' ' . $field_extra[0];
- }
+
+ if (MYSQL_INT_VERSION < 32306) {
+ check_reserved_words($field_name[$i]);
+ }
+
+ // Some fields have been urlencoded or double quotes have been translated
+ // to """ in tbl_properties.php3
+ $field_orig[$i] = urldecode($field_orig[$i]);
+ if (str_replace('"', '"', $field_orig[$i]) == $field_name[$i]) {
+ $field_name[$i] = $field_orig[$i];
+ }
+ $field_default_orig[$i] = urldecode($field_default_orig[$i]);
+ if (str_replace('"', '"', $field_default_orig[$i]) == $field_default[$i]) {
+ $field_default[$i] = $field_default_orig[$i];
+ }
+ $field_length_orig[$i] = urldecode($field_length_orig[$i]);
+ if (str_replace('"', '"', $field_length_orig[$i]) == $field_length[$i]) {
+ $field_length[$i] = $field_length_orig[$i];
+ }
+ if (!isset($query)) {
+ $query = '';
+ } else {
+ $query .= ', CHANGE ';
+ }
+ $query .= backquote($field_orig[$i]) . ' ' . backquote($field_name[$i]) . ' ' . $field_type[$i];
+ // Some field types shouldn't have lengths
+ if ($field_length[$i] != ''
+ && !eregi('^(DATE|DATETIME|TIME|TINYBLOB|TINYTEXT|BLOB|TEXT|MEDIUMBLOB|MEDIUMTEXT|LONGBLOB|LONGTEXT)$', $field_type[$i])) {
+ $query .= '(' . $field_length[$i] . ')';
+ }
+ if ($field_attribute[$i] != '') {
+ $query .= ' ' . $field_attribute[$i];
+ }
+ if ($field_default[$i] != '') {
+ if (strtoupper($field_default[$i]) == 'NULL') {
+ $query .= ' DEFAULT NULL';
+ } else {
+ $query .= ' DEFAULT \'' . sql_addslashes($field_default[$i]) . '\'';
+ }
+ }
+ if ($field_null[$i] != '') {
+ $query .= ' ' . $field_null[$i];
+ }
+ if ($field_extra[$i] != '') {
+ $query .= ' ' . $field_extra[$i];
+ }
+ } // end for
// Optimization fix - 2 May 2001 - Robbat2
$sql_query = 'ALTER TABLE ' . backquote($db) . '.' . backquote($table) . ' CHANGE ' . $query;
@@ -79,14 +86,27 @@ if (isset($submit)) {
* No modifications yet required -> displays the table fields
*/
else {
- if (get_magic_quotes_gpc()) {
- $field = sql_addslashes(stripslashes($field), TRUE);
+ if (!isset($selected)) {
+ $selected[] = $field;
+ $selected_cnt = 1;
} else {
- $field = sql_addslashes($field, TRUE);
+ $selected_cnt = count($selected);
}
- $local_query = 'SHOW FIELDS FROM ' . backquote($db) . '.' . backquote($table) . " LIKE '$field'";
- $result = mysql_query($local_query) or mysql_die('', $local_query);
- $num_fields = mysql_num_rows($result);
+
+ // TODO: optimize in case of multiple fields to modify
+ for ($i = 0; $i < $selected_cnt; $i++) {
+ if (get_magic_quotes_gpc()) {
+ $field = sql_addslashes(stripslashes($selected[$i]), TRUE);
+ } else {
+ $field = sql_addslashes($selected[$i], TRUE);
+ }
+ $local_query = 'SHOW FIELDS FROM ' . backquote($db) . '.' . backquote($table) . " LIKE '$field'";
+ $result = mysql_query($local_query) or mysql_die('', $local_query);
+ $fields_meta[] = mysql_fetch_array($result);
+ mysql_free_result($result);
+ }
+
+ $num_fields = count($fields_meta);
$action = 'tbl_alter.php3';
include('./tbl_properties.inc.php3');
}
diff --git a/tbl_properties.inc.php3 b/tbl_properties.inc.php3
index 3c7225cfe..a0f5a825b 100755
--- a/tbl_properties.inc.php3
+++ b/tbl_properties.inc.php3
@@ -51,8 +51,8 @@ if (!$is_backup) {
diff --git a/tbl_properties.php3 b/tbl_properties.php3
index 50c321cdc..aac3e210f 100755
--- a/tbl_properties.php3
+++ b/tbl_properties.php3
@@ -20,7 +20,7 @@ if (!isset($message)) {
*/
if (!empty($submit_mult) || isset($btnDrop)) {
$action = 'tbl_properties.php3';
- include('./mult_drops.inc.php3');
+ include('./mult_submits.inc.php3');
}