update
[phpmyadmin/crack.git] / mult_submits.inc.php3
blob49b571be7f422886c27aa27d85c36f79d0d2f7d9
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
6 /**
7 * Prepares the work and runs some other scripts if required
8 */
9 if (!empty($submit_mult)
10 && (!empty($selected_db) || !empty($selected_tbl) || !empty($selected_fld))) {
12 if (!empty($selected_db)) {
13 $selected = $selected_db;
14 $what = 'drop_db';
15 } else if (!empty($selected_tbl)) {
16 if ($submit_mult == $strPrintView) {
17 include('./tbl_printview.php3');
18 exit();
19 } else {
20 $selected = $selected_tbl;
21 switch ($submit_mult) {
22 case $strDrop:
23 $what = 'drop_tbl';
24 break;
25 case $strEmpty:
26 $what = 'empty_tbl';
27 break;
28 case $strCheckTable:
29 unset($submit_mult);
30 $query_type = 'check_tbl';
31 $mult_btn = $strYes;
32 break;
33 case $strOptimizeTable:
34 unset($submit_mult);
35 $query_type = 'optimize_tbl';
36 $mult_btn = $strYes;
37 break;
38 case $strRepairTable:
39 unset($submit_mult);
40 $query_type = 'repair_tbl';
41 $mult_btn = $strYes;
42 break;
43 case $strAnalyzeTable:
44 unset($submit_mult);
45 $query_type = 'analyze_tbl';
46 $mult_btn = $strYes;
47 break;
48 } // end switch
50 } else {
51 $selected = $selected_fld;
52 if ($submit_mult == $strDrop) {
53 $what = 'drop_fld';
54 } else {
55 include('./tbl_alter.php3');
56 exit();
59 } // end if
62 /**
63 * Displays the confirmation form if required
65 if (!empty($submit_mult) && !empty($what)) {
66 $js_to_run = 'functions.js';
67 unset($message);
68 if (!empty($table)) {
69 include('./tbl_properties_common.php3');
70 $url_query .= '&amp;goto=tbl_properties.php3&amp;back=tbl_properties.php3';
71 include('./tbl_properties_table_info.php3');
73 else {
74 include('./db_details_common.php3');
75 include('./db_details_db_info.php3');
77 // Builds the query
78 $full_query = '';
79 $selected_cnt = count($selected);
80 for ($i = 0; $i < $selected_cnt; $i++) {
81 switch ($what) {
82 case 'drop_db':
83 $full_query .= 'DROP DATABASE '
84 . PMA_backquote(htmlspecialchars(urldecode($selected[$i])))
85 . ';<br />';
86 break;
88 case 'drop_tbl':
89 $full_query .= (empty($full_query) ? 'DROP TABLE ' : ', ')
90 . PMA_backquote(htmlspecialchars(urldecode($selected[$i])))
91 . (($i == $selected_cnt - 1) ? ';<br />' : '');
92 break;
94 case 'empty_tbl':
95 if (PMA_MYSQL_INT_VERSION >= 40000) {
96 $full_query .= 'TRUNCATE ';
97 } else {
98 $full_query .= 'DELETE FROM ';
100 $full_query .= PMA_backquote(htmlspecialchars(urldecode($selected[$i])))
101 . ';<br />';
102 break;
104 case 'drop_fld':
105 if ($full_query == '') {
106 $full_query .= 'ALTER TABLE '
107 . PMA_backquote(htmlspecialchars($table))
108 . '<br />&nbsp;&nbsp;DROP '
109 . PMA_backquote(htmlspecialchars(urldecode($selected[$i])))
110 . ',';
111 } else {
112 $full_query .= '<br />&nbsp;&nbsp;DROP '
113 . PMA_backquote(htmlspecialchars(urldecode($selected[$i])))
114 . ',';
116 if ($i == $selected_cnt-1) {
117 $full_query = ereg_replace(',$', ';<br />', $full_query);
119 break;
120 } // end switch
123 // Displays the form
124 echo $strDoYouReally . '&nbsp;:<br />' . "\n";
125 echo '<tt>' . $full_query . '</tt>&nbsp;?<br/>' . "\n";
127 <form action="<?php echo $action; ?>" method="post">
128 <?php
129 echo "\n";
130 if (strpos(' ' . $action, 'db_details') == 1) {
131 echo PMA_generate_common_hidden_inputs($db);
132 } else if (strpos(' ' . $action, 'tbl_properties') == 1) {
133 echo PMA_generate_common_hidden_inputs($db,$table);
135 for ($i = 0; $i < $selected_cnt; $i++) {
136 echo ' <input type="hidden" name="selected[]" value="' . htmlspecialchars($selected[$i]) . '" />' . "\n";
139 <input type="hidden" name="query_type" value="<?php echo $what; ?>" />
140 <input type="submit" name="mult_btn" value="<?php echo $strYes; ?>" />
141 <input type="submit" name="mult_btn" value="<?php echo $strNo; ?>" />
142 </form>
143 <?php
144 echo"\n";
146 include('./footer.inc.php3');
147 exit();
148 } // end if
152 * Executes the query
154 else if ($mult_btn == $strYes) {
156 $sql_query = '';
157 $selected_cnt = count($selected);
158 for ($i = 0; $i < $selected_cnt; $i++) {
159 switch ($query_type) {
160 case 'drop_db':
161 $a_query = 'DROP DATABASE '
162 . PMA_backquote(urldecode($selected[$i]));
163 $reload = 1;
164 break;
166 case 'drop_tbl':
167 $sql_query .= (empty($sql_query) ? 'DROP TABLE ' : ', ')
168 . PMA_backquote(urldecode($selected[$i]))
169 . (($i == $selected_cnt-1) ? ';' : '');
170 $reload = 1;
171 break;
173 case 'check_tbl':
174 $sql_query .= (empty($sql_query) ? 'CHECK TABLE ' : ', ')
175 . PMA_backquote(urldecode($selected[$i]));
176 break;
178 case 'optimize_tbl':
179 $sql_query .= (empty($sql_query) ? 'OPTIMIZE TABLE ' : ', ')
180 . PMA_backquote(urldecode($selected[$i]));
181 break;
183 case 'analyze_tbl':
184 $sql_query .= (empty($sql_query) ? 'ANALYZE TABLE ' : ', ')
185 . PMA_backquote(urldecode($selected[$i]));
186 break;
188 case 'repair_tbl':
189 $sql_query .= (empty($sql_query) ? 'REPAIR TABLE ' : ', ')
190 . PMA_backquote(urldecode($selected[$i]));
191 break;
193 case 'empty_tbl':
194 $a_query = 'DELETE FROM '
195 . PMA_backquote(urldecode($selected[$i]));
196 break;
198 case 'drop_fld':
199 $sql_query .= (empty($sql_query) ? 'ALTER TABLE ' . PMA_backquote($table) : ',')
200 . ' DROP ' . PMA_backquote(urldecode($selected[$i]))
201 . (($i == $selected_cnt-1) ? ';' : '');
202 break;
203 } // end switch
205 // All "DROP TABLE","DROP FIELD", "OPTIMIZE TABLE" and "REPAIR TABLE"
206 // statements will be run at once below
207 if ($query_type != 'drop_tbl'
208 && $query_type != 'drop_fld'
209 && $query_type != 'repair_tbl'
210 && $query_type != 'analyze_tbl'
211 && $query_type != 'optimize_tbl'
212 && $query_type != 'check_tbl') {
213 $sql_query .= $a_query . ';' . "\n";
215 if ($query_type != 'drop_db') {
216 PMA_mysql_select_db($db);
218 $result = @PMA_mysql_query($a_query) or PMA_mysqlDie('', $a_query, FALSE, $err_url);
219 } // end if
220 } // end for
222 if ($query_type == 'drop_tbl'
223 || $query_type == 'drop_fld') {
224 PMA_mysql_select_db($db);
225 $result = @PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', FALSE, $err_url);
226 } elseif ($query_type == 'repair_tbl'
227 || $query_type == 'analyze_tbl'
228 || $query_type == 'check_tbl'
229 || $query_type == 'optimize_tbl') {
230 include('./sql.php3');
231 exit();