2.2.4
[phpmyadmin/arisferyanto.git] / mult_submits.inc.php3
blob790aa48635b5e4003360c1de75587ef6ebf3e8b0
1 <?php
2 /* $Id$ */
5 /**
6 * Confirmation form if required or include of other scripts
7 */
8 if (!empty($submit_mult)
9 && (!empty($selected_db) || !empty($selected_tbl) || !empty($selected_fld))) {
11 if (get_magic_quotes_gpc()) {
12 $submit_mult = stripslashes($submit_mult);
14 if (!empty($selected_db)) {
15 $selected = $selected_db;
16 $what = 'drop_db';
17 } else if (!empty($selected_tbl)) {
18 if ($submit_mult == $strPrintView) {
19 include('./tbl_printview.php3');
20 exit();
21 } else {
22 $selected = $selected_tbl;
23 switch ($submit_mult) {
24 case $strDrop:
25 $what = 'drop_tbl';
26 break;
27 case $strEmpty:
28 $what = 'empty_tbl';
29 break;
30 case $strOptimizeTable:
31 $what = 'optimize_tbl';
32 break;
33 } // end switch
35 } else {
36 $selected = $selected_fld;
37 if ($submit_mult == $strDrop) {
38 $what = 'drop_fld';
39 } else {
40 include('./tbl_alter.php3');
41 exit();
45 // Builds the query
46 $full_query = '';
47 $selected_cnt = count($selected);
48 for ($i = 0; $i < $selected_cnt; $i++) {
49 switch ($what) {
50 case 'drop_db':
51 $full_query .= 'DROP DATABASE '
52 . PMA_backquote(htmlspecialchars(urldecode($selected[$i])))
53 . ';<br />';
54 break;
56 case 'drop_tbl':
57 $full_query .= (empty($full_query) ? 'DROP TABLE ' : ', ')
58 . PMA_backquote(htmlspecialchars(urldecode($selected[$i])))
59 . (($i == $selected_cnt - 1) ? ';<br />' : '');
60 break;
62 case 'optimize_tbl':
63 $full_query .= (empty($full_query) ? 'OPTIMIZE TABLE ' : ', ')
64 . PMA_backquote(htmlspecialchars(urldecode($selected[$i])))
65 . (($i == $selected_cnt - 1) ? ';<br />' : '');
66 break;
68 case 'empty_tbl':
69 $full_query .= 'DELETE FROM '
70 . PMA_backquote(htmlspecialchars(urldecode($selected[$i])))
71 . ';<br />';
72 break;
74 case 'drop_fld':
75 if ($full_query == '') {
76 $full_query .= 'ALTER TABLE '
77 . PMA_backquote(htmlspecialchars($table))
78 . '<br />&nbsp;&nbsp;DROP '
79 . PMA_backquote(htmlspecialchars(urldecode($selected[$i])))
80 . ',';
81 } else {
82 $full_query .= '<br />&nbsp;&nbsp;DROP '
83 . PMA_backquote(htmlspecialchars(urldecode($selected[$i])))
84 . ',';
86 if ($i == $selected_cnt-1) {
87 $full_query = ereg_replace(',$', ';<br />', $full_query);
89 break;
90 } // end switch
93 // Displays the form
94 echo $strDoYouReally . '&nbsp;:<br />' . "\n";
95 echo '<tt>' . $full_query . '</tt>&nbsp;?<br/>' . "\n";
97 <form action="<?php echo $action; ?>" method="post">
98 <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
99 <input type="hidden" name="server" value="<?php echo $server; ?>" />
100 <?php
101 echo "\n";
102 if ($action == 'db_details.php3') {
103 echo ' <input type="hidden" name="db" value="' . $db . '" />' . "\n";
104 } else if ($action == 'tbl_properties.php3') {
105 echo ' <input type="hidden" name="db" value="' . $db . '" />' . "\n";
106 echo ' <input type="hidden" name="table" value="' . $table . '" />' . "\n";
108 for ($i = 0; $i < $selected_cnt; $i++) {
109 echo ' <input type="hidden" name="selected[]" value="' . $selected[$i] . '" />' . "\n";
112 <input type="hidden" name="query_type" value="<?php echo $what; ?>" />
113 <input type="submit" name="mult_btn" value="<?php echo $strYes; ?>" />
114 <input type="submit" name="mult_btn" value="<?php echo $strNo; ?>" />
115 </form>
116 <?php
117 echo"\n";
119 include('./footer.inc.php3');
120 exit();
124 * Executes the query
126 else if ((get_magic_quotes_gpc() && stripslashes($mult_btn) == $strYes)
127 || $mult_btn == $strYes) {
129 $sql_query = '';
130 $selected_cnt = count($selected);
131 for ($i = 0; $i < $selected_cnt; $i++) {
132 switch ($query_type) {
133 case 'drop_db':
134 $a_query = 'DROP DATABASE '
135 . PMA_backquote(urldecode($selected[$i]));
136 $reload = 1;
137 break;
139 case 'drop_tbl':
140 $sql_query .= (empty($sql_query) ? 'DROP TABLE ' : ', ')
141 . PMA_backquote(urldecode($selected[$i]))
142 . (($i == $selected_cnt-1) ? ';' : '');
143 $reload = 1;
144 break;
146 case 'optimize_tbl':
147 $sql_query .= (empty($sql_query) ? 'OPTIMIZE TABLE ' : ', ')
148 . PMA_backquote(urldecode($selected[$i]))
149 . (($i == $selected_cnt-1) ? ';' : '');
150 break;
152 case 'empty_tbl':
153 $a_query = 'DELETE FROM '
154 . PMA_backquote(urldecode($selected[$i]));
155 break;
157 case 'drop_fld':
158 $sql_query .= (empty($sql_query) ? 'ALTER TABLE ' . PMA_backquote($table) : ',')
159 . ' DROP ' . PMA_backquote(urldecode($selected[$i]))
160 . (($i == $selected_cnt-1) ? ';' : '');
161 break;
162 } // end switch
164 // All "DROP TABLE","DROP FIELD" and "OPTIMIZE TABLE" statements will
165 // be run at once below
166 if ($query_type != 'drop_tbl'
167 && $query_type != 'drop_fld'
168 && $query_type != 'optimize_tbl') {
169 $sql_query .= $a_query . ';' . "\n";
171 if ($query_type != 'drop_db') {
172 mysql_select_db($db);
174 $result = @mysql_query($a_query) or PMA_mysqlDie('', $a_query, FALSE, $err_url);
175 } // end if
176 } // end for
178 if ($query_type == 'drop_tbl'
179 || $query_type == 'drop_fld'
180 || $query_type == 'optimize_tbl') {
181 mysql_select_db($db);
182 $result = @mysql_query($sql_query) or PMA_mysqlDie('', '', FALSE, $err_url);
185 PMA_showMessage($strSuccess);