refresh
[phpmyadmin/crack.git] / tbl_alter.php3
blob5f387053321d6aaa75f03a9f5ec90d05cf915a5a
1 <?php
2 /* $Id$ */
5 /**
6 * Gets some core libraries
7 */
8 require('./grab_globals.inc.php3');
9 require('./header.inc.php3');
12 /**
13 * Modifications have been submitted -> updates the table
15 if (isset($submit)) {
16 // Some fields have been urlencoded or double quotes have been translated
17 // to "&quot;" in tbl_properties.php3
18 $field_orig[0] = urldecode($field_orig[0]);
19 if (str_replace('"', '&quot;', $field_orig[0]) == $field_name[0]) {
20 $field_name[0] = $field_orig[0];
22 $field_default_orig[0] = urldecode($field_default_orig[0]);
23 if (str_replace('"', '&quot;', $field_default_orig[0]) == $field_default[0]) {
24 $field_default[0] = $field_default_orig[0];
27 if (!isset($query)) {
28 $query = '';
30 $query .= ' ' . backquote($field_orig[0]) . ' ' . backquote($field_name[0]) . ' ' . $field_type[0] . ' ';
31 if ($field_length[0] != '') {
32 $query .= '(' . $field_length[0] . ') ';
34 if ($field_attribute[0] != '') {
35 $query .= $field_attribute[0] . ' ';
37 if ($field_default[0] != '') {
38 $query .= 'DEFAULT \'' . sql_addslashes($field_default[0]) . '\' ';
40 $query .= $field_null[0] . ' ' . $field_extra[0];
41 if (get_magic_quotes_gpc()) {
42 $query = stripslashes($query);
45 // Optimization fix - 2 May 2001 - Robbat2
46 $sql_query = 'ALTER TABLE ' . backquote($db) . '.' . backquote($table) . ' CHANGE ' . $query;
47 $result = mysql_query($sql_query) or mysql_die();
48 $message = $strTable . ' ' . htmlspecialchars($table) . ' ' . $strHasBeenAltered;
49 include('./tbl_properties.php3');
50 exit();
54 /**
55 * No modifications yet required -> displays the table fields
57 else {
58 if (get_magic_quotes_gpc()) {
59 $field = sql_addslashes(stripslashes($field), TRUE);
60 } else {
61 $field = sql_addslashes($field, TRUE);
63 $result = mysql_query('SHOW FIELDS FROM ' . backquote($db) . '.' . backquote($table) . " LIKE '$field'") or mysql_die();
64 $num_fields = mysql_num_rows($result);
65 $action = 'tbl_alter.php3';
66 include('./tbl_properties.inc.php3');
70 /**
71 * Displays the footer
73 require('./footer.inc.php3');