more typos
[phpmyadmin/crack.git] / mult_submits.inc.php3
blob861f40a4c9814a035fc772941b413e8bf71e54f2
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 'drop_db':
23 $what = 'drop_db';
24 break;
25 case $strDrop:
26 $what = 'drop_tbl';
27 break;
28 case $strEmpty:
29 $what = 'empty_tbl';
30 break;
31 case $strCheckTable:
32 unset($submit_mult);
33 $query_type = 'check_tbl';
34 $mult_btn = $strYes;
35 break;
36 case $strOptimizeTable:
37 unset($submit_mult);
38 $query_type = 'optimize_tbl';
39 $mult_btn = $strYes;
40 break;
41 case $strRepairTable:
42 unset($submit_mult);
43 $query_type = 'repair_tbl';
44 $mult_btn = $strYes;
45 break;
46 case $strAnalyzeTable:
47 unset($submit_mult);
48 $query_type = 'analyze_tbl';
49 $mult_btn = $strYes;
50 break;
51 } // end switch
53 } else {
54 $selected = $selected_fld;
55 if ($submit_mult == $strDrop) {
56 $what = 'drop_fld';
57 } else {
58 include('./tbl_alter.php3');
59 exit();
62 } // end if
65 /**
66 * Displays the confirmation form if required
68 if (!empty($submit_mult) && !empty($what)) {
69 $js_to_run = 'functions.js';
70 unset($message);
71 if (!empty($table)) {
72 include('./tbl_properties_common.php3');
73 $url_query .= '&amp;goto=tbl_properties.php3&amp;back=tbl_properties.php3';
74 include('./tbl_properties_table_info.php3');
76 elseif (!empty($db)) {
77 include('./db_details_common.php3');
78 include('./db_details_db_info.php3');
80 // Builds the query
81 $full_query = '';
82 $selected_cnt = count($selected);
83 for ($i = 0; $i < $selected_cnt; $i++) {
84 switch ($what) {
85 case 'drop_db':
86 $full_query .= 'DROP DATABASE '
87 . PMA_backquote(htmlspecialchars(urldecode($selected[$i])))
88 . ';<br />';
89 break;
91 case 'drop_tbl':
92 $full_query .= (empty($full_query) ? 'DROP TABLE ' : ', ')
93 . PMA_backquote(htmlspecialchars(urldecode($selected[$i])))
94 . (($i == $selected_cnt - 1) ? ';<br />' : '');
95 break;
97 case 'empty_tbl':
98 if (PMA_MYSQL_INT_VERSION >= 40000) {
99 $full_query .= 'TRUNCATE ';
100 } else {
101 $full_query .= 'DELETE FROM ';
103 $full_query .= PMA_backquote(htmlspecialchars(urldecode($selected[$i])))
104 . ';<br />';
105 break;
107 case 'drop_fld':
108 if ($full_query == '') {
109 $full_query .= 'ALTER TABLE '
110 . PMA_backquote(htmlspecialchars($table))
111 . '<br />&nbsp;&nbsp;DROP '
112 . PMA_backquote(htmlspecialchars(urldecode($selected[$i])))
113 . ',';
114 } else {
115 $full_query .= '<br />&nbsp;&nbsp;DROP '
116 . PMA_backquote(htmlspecialchars(urldecode($selected[$i])))
117 . ',';
119 if ($i == $selected_cnt-1) {
120 $full_query = ereg_replace(',$', ';<br />', $full_query);
122 break;
123 } // end switch
126 // Displays the form
127 echo $strDoYouReally . '&nbsp;:<br />' . "\n";
128 echo '<tt>' . $full_query . '</tt>&nbsp;?<br/>' . "\n";
130 <form action="<?php echo $action; ?>" method="post">
131 <?php
132 echo "\n";
133 if (strpos(' ' . $action, 'db_details') == 1) {
134 echo PMA_generate_common_hidden_inputs($db);
135 } else if (strpos(' ' . $action, 'tbl_properties') == 1) {
136 echo PMA_generate_common_hidden_inputs($db,$table);
137 } else {
138 echo PMA_generate_common_hidden_inputs();
140 for ($i = 0; $i < $selected_cnt; $i++) {
141 echo ' <input type="hidden" name="selected[]" value="' . htmlspecialchars($selected[$i]) . '" />' . "\n";
144 <input type="hidden" name="query_type" value="<?php echo $what; ?>" />
145 <input type="submit" name="mult_btn" value="<?php echo $strYes; ?>" />
146 <input type="submit" name="mult_btn" value="<?php echo $strNo; ?>" />
147 </form>
148 <?php
149 echo"\n";
151 include('./footer.inc.php3');
152 exit();
153 } // end if
157 * Executes the query
159 else if ($mult_btn == $strYes) {
161 $sql_query = '';
162 $selected_cnt = count($selected);
163 for ($i = 0; $i < $selected_cnt; $i++) {
164 switch ($query_type) {
165 case 'drop_db':
166 $a_query = 'DROP DATABASE '
167 . PMA_backquote(urldecode($selected[$i]));
168 $reload = 1;
169 break;
171 case 'drop_tbl':
172 $sql_query .= (empty($sql_query) ? 'DROP TABLE ' : ', ')
173 . PMA_backquote(urldecode($selected[$i]))
174 . (($i == $selected_cnt-1) ? ';' : '');
175 $reload = 1;
176 break;
178 case 'check_tbl':
179 $sql_query .= (empty($sql_query) ? 'CHECK TABLE ' : ', ')
180 . PMA_backquote(urldecode($selected[$i]));
181 break;
183 case 'optimize_tbl':
184 $sql_query .= (empty($sql_query) ? 'OPTIMIZE TABLE ' : ', ')
185 . PMA_backquote(urldecode($selected[$i]));
186 break;
188 case 'analyze_tbl':
189 $sql_query .= (empty($sql_query) ? 'ANALYZE TABLE ' : ', ')
190 . PMA_backquote(urldecode($selected[$i]));
191 break;
193 case 'repair_tbl':
194 $sql_query .= (empty($sql_query) ? 'REPAIR TABLE ' : ', ')
195 . PMA_backquote(urldecode($selected[$i]));
196 break;
198 case 'empty_tbl':
199 $a_query = 'DELETE FROM '
200 . PMA_backquote(urldecode($selected[$i]));
201 break;
203 case 'drop_fld':
204 $sql_query .= (empty($sql_query) ? 'ALTER TABLE ' . PMA_backquote($table) : ',')
205 . ' DROP ' . PMA_backquote(urldecode($selected[$i]))
206 . (($i == $selected_cnt-1) ? ';' : '');
207 break;
208 } // end switch
210 // All "DROP TABLE","DROP FIELD", "OPTIMIZE TABLE" and "REPAIR TABLE"
211 // statements will be run at once below
212 if ($query_type != 'drop_tbl'
213 && $query_type != 'drop_fld'
214 && $query_type != 'repair_tbl'
215 && $query_type != 'analyze_tbl'
216 && $query_type != 'optimize_tbl'
217 && $query_type != 'check_tbl') {
219 $sql_query .= $a_query . ';' . "\n";
221 if ($query_type != 'drop_db') {
222 PMA_mysql_select_db($db);
224 $result = @PMA_mysql_query($a_query) or PMA_mysqlDie('', $a_query, FALSE, $err_url);
225 } // end if
226 } // end for
228 if ($query_type == 'drop_tbl'
229 || $query_type == 'drop_fld') {
230 PMA_mysql_select_db($db);
231 $result = @PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', FALSE, $err_url);
232 } elseif ($query_type == 'repair_tbl'
233 || $query_type == 'analyze_tbl'
234 || $query_type == 'check_tbl'
235 || $query_type == 'optimize_tbl') {
236 include('./sql.php3');
237 exit();