update
[phpmyadmin/crack.git] / mult_submits.inc.php3
blob22bf25349d6106c741d984d4ca66399ccfe15de2
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 <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
111 <input type="hidden" name="convcharset" value="<?php echo $convcharset; ?>" />
112 <input type="hidden" name="server" value="<?php echo $server; ?>" />
113 <?php
114 echo "\n";
115 if (strpos(' ' . $action, 'db_details') == 1) {
116 echo ' <input type="hidden" name="db" value="' . htmlspecialchars($db) . '" />' . "\n";
117 } else if (strpos(' ' . $action, 'tbl_properties') == 1) {
118 echo ' <input type="hidden" name="db" value="' . htmlspecialchars($db) . '" />' . "\n";
119 echo ' <input type="hidden" name="table" value="' . htmlspecialchars($table) . '" />' . "\n";
121 for ($i = 0; $i < $selected_cnt; $i++) {
122 echo ' <input type="hidden" name="selected[]" value="' . htmlspecialchars($selected[$i]) . '" />' . "\n";
125 <input type="hidden" name="query_type" value="<?php echo $what; ?>" />
126 <input type="submit" name="mult_btn" value="<?php echo $strYes; ?>" />
127 <input type="submit" name="mult_btn" value="<?php echo $strNo; ?>" />
128 </form>
129 <?php
130 echo"\n";
132 include('./footer.inc.php3');
133 exit();
134 } // end if
138 * Executes the query
140 else if ((get_magic_quotes_gpc() && stripslashes($mult_btn) == $strYes)
141 || $mult_btn == $strYes) {
143 $sql_query = '';
144 $selected_cnt = count($selected);
145 for ($i = 0; $i < $selected_cnt; $i++) {
146 switch ($query_type) {
147 case 'drop_db':
148 $a_query = 'DROP DATABASE '
149 . PMA_backquote(urldecode($selected[$i]));
150 $reload = 1;
151 break;
153 case 'drop_tbl':
154 $sql_query .= (empty($sql_query) ? 'DROP TABLE ' : ', ')
155 . PMA_backquote(urldecode($selected[$i]))
156 . (($i == $selected_cnt-1) ? ';' : '');
157 $reload = 1;
158 break;
160 case 'optimize_tbl':
161 $sql_query .= (empty($sql_query) ? 'OPTIMIZE TABLE ' : ', ')
162 . PMA_backquote(urldecode($selected[$i]))
163 . (($i == $selected_cnt-1) ? ';' : '');
164 break;
166 case 'repair_tbl':
167 $sql_query .= (empty($sql_query) ? 'REPAIR TABLE ' : ', ')
168 . PMA_backquote(urldecode($selected[$i]))
169 . (($i == $selected_cnt-1) ? ';' : '');
170 break;
172 case 'empty_tbl':
173 $a_query = 'DELETE FROM '
174 . PMA_backquote(urldecode($selected[$i]));
175 break;
177 case 'drop_fld':
178 $sql_query .= (empty($sql_query) ? 'ALTER TABLE ' . PMA_backquote($table) : ',')
179 . ' DROP ' . PMA_backquote(urldecode($selected[$i]))
180 . (($i == $selected_cnt-1) ? ';' : '');
181 break;
182 } // end switch
184 // All "DROP TABLE","DROP FIELD", "OPTIMIZE TABLE" and "REPAIR TABLE"
185 // statements will be run at once below
186 if ($query_type != 'drop_tbl'
187 && $query_type != 'drop_fld'
188 && $query_type != 'repair_tbl'
189 && $query_type != 'optimize_tbl') {
190 $sql_query .= $a_query . ';' . "\n";
192 if ($query_type != 'drop_db') {
193 PMA_mysql_select_db($db);
195 $result = @PMA_mysql_query($a_query) or PMA_mysqlDie('', $a_query, FALSE, $err_url);
196 } // end if
197 } // end for
199 if ($query_type == 'drop_tbl'
200 || $query_type == 'drop_fld'
201 || $query_type == 'repair_tbl'
202 || $query_type == 'optimize_tbl') {
203 PMA_mysql_select_db($db);
204 $result = @PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', FALSE, $err_url);
207 PMA_showMessage($strSuccess);