strCantLoad
[phpmyadmin/crack.git] / mult_submits.inc.php3
blob494a2718890925d720a095cb217ecfb24e83b6e6
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 (get_magic_quotes_gpc()) {
13 $submit_mult = stripslashes($submit_mult);
15 if (!empty($selected_db)) {
16 $selected = $selected_db;
17 $what = 'drop_db';
18 } else if (!empty($selected_tbl)) {
19 if ($submit_mult == $strPrintView) {
20 include('./tbl_printview.php3');
21 exit();
22 } else {
23 $selected = $selected_tbl;
24 switch ($submit_mult) {
25 case $strDrop:
26 $what = 'drop_tbl';
27 break;
28 case $strEmpty:
29 $what = 'empty_tbl';
30 break;
31 case $strOptimizeTable:
32 unset($submit_mult);
33 $query_type = 'optimize_tbl';
34 $mult_btn = (get_magic_quotes_gpc() ? addslashes($strYes) : $strYes);
35 break;
36 case $strRepairTable:
37 unset($submit_mult);
38 $query_type = 'repair_tbl';
39 $mult_btn = (get_magic_quotes_gpc() ? addslashes($strYes) : $strYes);
40 break;
41 } // end switch
43 } else {
44 $selected = $selected_fld;
45 if ($submit_mult == $strDrop) {
46 $what = 'drop_fld';
47 } else {
48 include('./tbl_alter.php3');
49 exit();
52 } // end if
55 /**
56 * Displays the confirmation form if required
58 if (!empty($submit_mult) && !empty($what)) {
59 // Builds the query
60 $full_query = '';
61 $selected_cnt = count($selected);
62 for ($i = 0; $i < $selected_cnt; $i++) {
63 switch ($what) {
64 case 'drop_db':
65 $full_query .= 'DROP DATABASE '
66 . PMA_backquote(htmlspecialchars(urldecode($selected[$i])))
67 . ';<br />';
68 break;
70 case 'drop_tbl':
71 $full_query .= (empty($full_query) ? 'DROP TABLE ' : ', ')
72 . PMA_backquote(htmlspecialchars(urldecode($selected[$i])))
73 . (($i == $selected_cnt - 1) ? ';<br />' : '');
74 break;
76 case 'empty_tbl':
77 if (PMA_MYSQL_INT_VERSION >= 40000) {
78 $full_query .= 'TRUNCATE ';
79 } else {
80 $full_query .= 'DELETE FROM ';
82 $full_query .= PMA_backquote(htmlspecialchars(urldecode($selected[$i])))
83 . ';<br />';
84 break;
86 case 'drop_fld':
87 if ($full_query == '') {
88 $full_query .= 'ALTER TABLE '
89 . PMA_backquote(htmlspecialchars($table))
90 . '<br />&nbsp;&nbsp;DROP '
91 . PMA_backquote(htmlspecialchars(urldecode($selected[$i])))
92 . ',';
93 } else {
94 $full_query .= '<br />&nbsp;&nbsp;DROP '
95 . PMA_backquote(htmlspecialchars(urldecode($selected[$i])))
96 . ',';
98 if ($i == $selected_cnt-1) {
99 $full_query = ereg_replace(',$', ';<br />', $full_query);
101 break;
102 } // end switch
105 // Displays the form
106 echo $strDoYouReally . '&nbsp;:<br />' . "\n";
107 echo '<tt>' . $full_query . '</tt>&nbsp;?<br/>' . "\n";
109 <form action="<?php echo $action; ?>" method="post">
110 <?php
111 echo "\n";
112 if (strpos(' ' . $action, 'db_details') == 1) {
113 echo PMA_generate_common_hidden_inputs($db);
114 } else if (strpos(' ' . $action, 'tbl_properties') == 1) {
115 echo PMA_generate_common_hidden_inputs($db,$table);
117 for ($i = 0; $i < $selected_cnt; $i++) {
118 echo ' <input type="hidden" name="selected[]" value="' . htmlspecialchars($selected[$i]) . '" />' . "\n";
121 <input type="hidden" name="query_type" value="<?php echo $what; ?>" />
122 <input type="submit" name="mult_btn" value="<?php echo $strYes; ?>" />
123 <input type="submit" name="mult_btn" value="<?php echo $strNo; ?>" />
124 </form>
125 <?php
126 echo"\n";
128 include('./footer.inc.php3');
129 exit();
130 } // end if
134 * Executes the query
136 else if ((get_magic_quotes_gpc() && stripslashes($mult_btn) == $strYes)
137 || $mult_btn == $strYes) {
139 $sql_query = '';
140 $selected_cnt = count($selected);
141 for ($i = 0; $i < $selected_cnt; $i++) {
142 switch ($query_type) {
143 case 'drop_db':
144 $a_query = 'DROP DATABASE '
145 . PMA_backquote(urldecode($selected[$i]));
146 $reload = 1;
147 break;
149 case 'drop_tbl':
150 $sql_query .= (empty($sql_query) ? 'DROP TABLE ' : ', ')
151 . PMA_backquote(urldecode($selected[$i]))
152 . (($i == $selected_cnt-1) ? ';' : '');
153 $reload = 1;
154 break;
156 case 'optimize_tbl':
157 $sql_query .= (empty($sql_query) ? 'OPTIMIZE TABLE ' : ', ')
158 . PMA_backquote(urldecode($selected[$i]))
159 . (($i == $selected_cnt-1) ? ';' : '');
160 break;
162 case 'repair_tbl':
163 $sql_query .= (empty($sql_query) ? 'REPAIR TABLE ' : ', ')
164 . PMA_backquote(urldecode($selected[$i]))
165 . (($i == $selected_cnt-1) ? ';' : '');
166 break;
168 case 'empty_tbl':
169 $a_query = 'DELETE FROM '
170 . PMA_backquote(urldecode($selected[$i]));
171 break;
173 case 'drop_fld':
174 $sql_query .= (empty($sql_query) ? 'ALTER TABLE ' . PMA_backquote($table) : ',')
175 . ' DROP ' . PMA_backquote(urldecode($selected[$i]))
176 . (($i == $selected_cnt-1) ? ';' : '');
177 break;
178 } // end switch
180 // All "DROP TABLE","DROP FIELD", "OPTIMIZE TABLE" and "REPAIR TABLE"
181 // statements will be run at once below
182 if ($query_type != 'drop_tbl'
183 && $query_type != 'drop_fld'
184 && $query_type != 'repair_tbl'
185 && $query_type != 'optimize_tbl') {
186 $sql_query .= $a_query . ';' . "\n";
188 if ($query_type != 'drop_db') {
189 PMA_mysql_select_db($db);
191 $result = @PMA_mysql_query($a_query) or PMA_mysqlDie('', $a_query, FALSE, $err_url);
192 } // end if
193 } // end for
195 if ($query_type == 'drop_tbl'
196 || $query_type == 'drop_fld'
197 || $query_type == 'repair_tbl'
198 || $query_type == 'optimize_tbl') {
199 PMA_mysql_select_db($db);
200 $result = @PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', FALSE, $err_url);
203 PMA_showMessage($strSuccess);