protect binary contents in cookies
[phpmyadmin/crack.git] / mult_submits.inc.php3
blob0cd98402477bca8a137d26352f25f0fac29a6bba
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 if ($query_type == 'drop_db' || $query_type == 'drop_tbl' || $query_type == 'drop_fld') {
162 include('./libraries/relation_cleanup.lib.php3');
165 $sql_query = '';
166 $selected_cnt = count($selected);
167 for ($i = 0; $i < $selected_cnt; $i++) {
168 switch ($query_type) {
169 case 'drop_db':
170 PMA_relationsCleanupDatabase($selected[$i]);
171 $a_query = 'DROP DATABASE '
172 . PMA_backquote(urldecode($selected[$i]));
173 $reload = 1;
174 break;
176 case 'drop_tbl':
177 PMA_relationsCleanupTable($db, $selected[$i]);
178 $sql_query .= (empty($sql_query) ? 'DROP TABLE ' : ', ')
179 . PMA_backquote(urldecode($selected[$i]))
180 . (($i == $selected_cnt-1) ? ';' : '');
181 $reload = 1;
182 break;
184 case 'check_tbl':
185 $sql_query .= (empty($sql_query) ? 'CHECK TABLE ' : ', ')
186 . PMA_backquote(urldecode($selected[$i]));
187 break;
189 case 'optimize_tbl':
190 $sql_query .= (empty($sql_query) ? 'OPTIMIZE TABLE ' : ', ')
191 . PMA_backquote(urldecode($selected[$i]));
192 break;
194 case 'analyze_tbl':
195 $sql_query .= (empty($sql_query) ? 'ANALYZE TABLE ' : ', ')
196 . PMA_backquote(urldecode($selected[$i]));
197 break;
199 case 'repair_tbl':
200 $sql_query .= (empty($sql_query) ? 'REPAIR TABLE ' : ', ')
201 . PMA_backquote(urldecode($selected[$i]));
202 break;
204 case 'empty_tbl':
205 if (PMA_MYSQL_INT_VERSION >= 40000) {
206 $a_query .= 'TRUNCATE ';
207 } else {
208 $a_query .= 'DELETE FROM ';
210 $a_query .= PMA_backquote(htmlspecialchars(urldecode($selected[$i])));
211 break;
213 case 'drop_fld':
214 PMA_relationsCleanupTable($db, $table, $selected[$i]);
215 $sql_query .= (empty($sql_query) ? 'ALTER TABLE ' . PMA_backquote($table) : ',')
216 . ' DROP ' . PMA_backquote(urldecode($selected[$i]))
217 . (($i == $selected_cnt-1) ? ';' : '');
218 break;
219 } // end switch
221 // All "DROP TABLE","DROP FIELD", "OPTIMIZE TABLE" and "REPAIR TABLE"
222 // statements will be run at once below
223 if ($query_type != 'drop_tbl'
224 && $query_type != 'drop_fld'
225 && $query_type != 'repair_tbl'
226 && $query_type != 'analyze_tbl'
227 && $query_type != 'optimize_tbl'
228 && $query_type != 'check_tbl') {
230 $sql_query .= $a_query . ';' . "\n";
232 if ($query_type != 'drop_db') {
233 PMA_mysql_select_db($db);
235 $result = @PMA_mysql_query($a_query) or PMA_mysqlDie('', $a_query, FALSE, $err_url);
236 } // end if
237 } // end for
239 if ($query_type == 'drop_tbl'
240 || $query_type == 'drop_fld') {
241 PMA_mysql_select_db($db);
242 $result = @PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', FALSE, $err_url);
243 } elseif ($query_type == 'repair_tbl'
244 || $query_type == 'analyze_tbl'
245 || $query_type == 'check_tbl'
246 || $query_type == 'optimize_tbl') {
247 include('./sql.php3');
248 exit();