Documentation TYPO3 par Ameos |
00001 <?php 00002 /* $Id: mult_submits.inc.php,v 2.3.4.1 2004/01/14 14:22:45 lem9 Exp $ */ 00003 // vim: expandtab sw=4 ts=4 sts=4: 00004 00005 00009 if (!empty($submit_mult) 00010 && ($submit_mult != $strWithChecked) 00011 && ( !empty($selected_db) 00012 || !empty($selected_tbl) 00013 || !empty($selected_fld) 00014 || !empty($rows_to_delete) 00015 )) { 00016 00017 if (!empty($selected_db)) { 00018 $selected = $selected_db; 00019 $what = 'drop_db'; 00020 } else if (!empty($selected_tbl)) { 00021 if ($submit_mult == $strPrintView) { 00022 require('./tbl_printview.php'); 00023 } else { 00024 $selected = $selected_tbl; 00025 switch ($submit_mult) { 00026 case 'drop_db': 00027 $what = 'drop_db'; 00028 break; 00029 case $strDrop: 00030 $what = 'drop_tbl'; 00031 break; 00032 case $strEmpty: 00033 $what = 'empty_tbl'; 00034 break; 00035 case $strCheckTable: 00036 unset($submit_mult); 00037 $query_type = 'check_tbl'; 00038 $mult_btn = $strYes; 00039 break; 00040 case $strOptimizeTable: 00041 unset($submit_mult); 00042 $query_type = 'optimize_tbl'; 00043 $mult_btn = $strYes; 00044 break; 00045 case $strRepairTable: 00046 unset($submit_mult); 00047 $query_type = 'repair_tbl'; 00048 $mult_btn = $strYes; 00049 break; 00050 case $strAnalyzeTable: 00051 unset($submit_mult); 00052 $query_type = 'analyze_tbl'; 00053 $mult_btn = $strYes; 00054 break; 00055 } // end switch 00056 } 00057 } else if (!empty($selected_fld)) { 00058 $selected = $selected_fld; 00059 if ($submit_mult == $strDrop) { 00060 $what = 'drop_fld'; 00061 } else { 00062 require('./tbl_alter.php'); 00063 } 00064 } else { 00065 $what = 'row_delete'; 00066 $selected = $rows_to_delete; 00067 } 00068 } // end if 00069 00070 00074 if (!empty($submit_mult) && !empty($what)) { 00075 $js_to_run = 'functions.js'; 00076 unset($message); 00077 if (!empty($table)) { 00078 require('./tbl_properties_common.php'); 00079 $url_query .= '&goto=tbl_properties.php&back=tbl_properties.php'; 00080 require('./tbl_properties_table_info.php'); 00081 } 00082 elseif (!empty($db)) { 00083 require('./db_details_common.php'); 00084 require('./db_details_db_info.php'); 00085 } 00086 // Builds the query 00087 $full_query = ''; 00088 $selected_cnt = count($selected); 00089 $i = 0; 00090 foreach($selected AS $idx => $sval) { 00091 $i++; 00092 switch ($what) { 00093 case 'row_delete': 00094 $full_query .= htmlspecialchars(urldecode($sval)) 00095 . ';<br />'; 00096 break; 00097 case 'drop_db': 00098 $full_query .= 'DROP DATABASE ' 00099 . PMA_backquote(htmlspecialchars(urldecode($sval))) 00100 . ';<br />'; 00101 break; 00102 00103 case 'drop_tbl': 00104 $full_query .= (empty($full_query) ? 'DROP TABLE ' : ', ') 00105 . PMA_backquote(htmlspecialchars(urldecode($sval))) 00106 . (($i == $selected_cnt - 1) ? ';<br />' : ''); 00107 break; 00108 00109 case 'empty_tbl': 00110 if (PMA_MYSQL_INT_VERSION >= 40000) { 00111 $full_query .= 'TRUNCATE '; 00112 } else { 00113 $full_query .= 'DELETE FROM '; 00114 } 00115 $full_query .= PMA_backquote(htmlspecialchars(urldecode($sval))) 00116 . ';<br />'; 00117 break; 00118 00119 case 'drop_fld': 00120 if ($full_query == '') { 00121 $full_query .= 'ALTER TABLE ' 00122 . PMA_backquote(htmlspecialchars($table)) 00123 . '<br /> DROP ' 00124 . PMA_backquote(htmlspecialchars(urldecode($sval))) 00125 . ','; 00126 } else { 00127 $full_query .= '<br /> DROP ' 00128 . PMA_backquote(htmlspecialchars(urldecode($sval))) 00129 . ','; 00130 } 00131 if ($i == $selected_cnt-1) { 00132 $full_query = preg_replace('@,$@', ';<br />', $full_query); 00133 } 00134 break; 00135 } // end switch 00136 } 00137 00138 // Displays the form 00139 echo $strDoYouReally . ' :<br />' . "\n"; 00140 echo '<tt>' . $full_query . '</tt> ?<br/>' . "\n"; 00141 ?> 00142 <form action="<?php echo $action; ?>" method="post"> 00143 <?php 00144 echo "\n"; 00145 if (strpos(' ' . $action, 'db_details') == 1) { 00146 echo PMA_generate_common_hidden_inputs($db); 00147 } else if (strpos(' ' . $action, 'tbl_properties') == 1 00148 || $what == 'row_delete') { 00149 echo PMA_generate_common_hidden_inputs($db,$table); 00150 } else { 00151 echo PMA_generate_common_hidden_inputs(); 00152 } 00153 foreach($selected AS $idx => $sval) { 00154 echo ' <input type="hidden" name="selected[]" value="' . htmlspecialchars($sval) . '" />' . "\n"; 00155 } 00156 ?> 00157 <input type="hidden" name="query_type" value="<?php echo $what; ?>" /> 00158 <?php 00159 if ($what == 'row_delete') { 00160 echo '<input type="hidden" name="original_sql_query" value="' . $original_sql_query . '" />' . "\n"; 00161 echo '<input type="hidden" name="original_pos" value="' . $original_pos . '" />' . "\n"; 00162 echo '<input type="hidden" name="original_url_query" value="' . $original_url_query . '" />' . "\n"; 00163 } 00164 ?> 00165 <input type="submit" name="mult_btn" value="<?php echo $strYes; ?>" /> 00166 <input type="submit" name="mult_btn" value="<?php echo $strNo; ?>" /> 00167 </form> 00168 <?php 00169 echo"\n"; 00170 00171 require_once('./footer.inc.php'); 00172 } // end if 00173 00174 00178 else if ($mult_btn == $strYes) { 00179 00180 if ($query_type == 'drop_db' || $query_type == 'drop_tbl' || $query_type == 'drop_fld') { 00181 require_once('./libraries/relation_cleanup.lib.php'); 00182 } 00183 00184 $sql_query = ''; 00185 $selected_cnt = count($selected); 00186 for ($i = 0; $i < $selected_cnt; $i++) { 00187 switch ($query_type) { 00188 case 'row_delete': 00189 $a_query = urldecode($selected[$i]); 00190 break; 00191 00192 case 'drop_db': 00193 PMA_relationsCleanupDatabase($selected[$i]); 00194 $a_query = 'DROP DATABASE ' 00195 . PMA_backquote(urldecode($selected[$i])); 00196 $reload = 1; 00197 break; 00198 00199 case 'drop_tbl': 00200 PMA_relationsCleanupTable($db, $selected[$i]); 00201 $sql_query .= (empty($sql_query) ? 'DROP TABLE ' : ', ') 00202 . PMA_backquote(urldecode($selected[$i])) 00203 . (($i == $selected_cnt-1) ? ';' : ''); 00204 $reload = 1; 00205 break; 00206 00207 case 'check_tbl': 00208 $sql_query .= (empty($sql_query) ? 'CHECK TABLE ' : ', ') 00209 . PMA_backquote(urldecode($selected[$i])); 00210 break; 00211 00212 case 'optimize_tbl': 00213 $sql_query .= (empty($sql_query) ? 'OPTIMIZE TABLE ' : ', ') 00214 . PMA_backquote(urldecode($selected[$i])); 00215 break; 00216 00217 case 'analyze_tbl': 00218 $sql_query .= (empty($sql_query) ? 'ANALYZE TABLE ' : ', ') 00219 . PMA_backquote(urldecode($selected[$i])); 00220 break; 00221 00222 case 'repair_tbl': 00223 $sql_query .= (empty($sql_query) ? 'REPAIR TABLE ' : ', ') 00224 . PMA_backquote(urldecode($selected[$i])); 00225 break; 00226 00227 case 'empty_tbl': 00228 if (PMA_MYSQL_INT_VERSION >= 40000) { 00229 $a_query = 'TRUNCATE '; 00230 } else { 00231 $a_query = 'DELETE FROM '; 00232 } 00233 $a_query .= PMA_backquote(htmlspecialchars(urldecode($selected[$i]))); 00234 break; 00235 00236 case 'drop_fld': 00237 PMA_relationsCleanupColumn($db, $table, $selected[$i]); 00238 $sql_query .= (empty($sql_query) ? 'ALTER TABLE ' . PMA_backquote($table) : ',') 00239 . ' DROP ' . PMA_backquote(urldecode($selected[$i])) 00240 . (($i == $selected_cnt-1) ? ';' : ''); 00241 break; 00242 } // end switch 00243 00244 // All "DROP TABLE","DROP FIELD", "OPTIMIZE TABLE" and "REPAIR TABLE" 00245 // statements will be run at once below 00246 if ($query_type != 'drop_tbl' 00247 && $query_type != 'drop_fld' 00248 && $query_type != 'repair_tbl' 00249 && $query_type != 'analyze_tbl' 00250 && $query_type != 'optimize_tbl' 00251 && $query_type != 'check_tbl') { 00252 00253 $sql_query .= $a_query . ';' . "\n"; 00254 00255 if ($query_type != 'drop_db') { 00256 PMA_mysql_select_db($db); 00257 } 00258 $result = @PMA_mysql_query($a_query) or PMA_mysqlDie('', $a_query, FALSE, $err_url); 00259 } // end if 00260 } // end for 00261 00262 if ($query_type == 'drop_tbl' 00263 || $query_type == 'drop_fld') { 00264 PMA_mysql_select_db($db); 00265 $result = @PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', FALSE, $err_url); 00266 } elseif ($query_type == 'repair_tbl' 00267 || $query_type == 'analyze_tbl' 00268 || $query_type == 'check_tbl' 00269 || $query_type == 'optimize_tbl') { 00270 require('./sql.php'); 00271 } 00272 00273 } 00274 00275 ?>