update
[phpmyadmin/crack.git] / tbl_properties_operations.php3
blobed156805c76042baca33a8c9cd48513237d959b5
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
6 /**
7 * Runs common work
8 */
9 require('./tbl_properties_common.php3');
10 //$err_url = 'tbl_properties_operations.php3' . $err_url;
11 $url_query .= '&amp;goto=tbl_properties_operations.php3&amp;back=tbl_properties_operations.php3';
14 /**
15 * Gets relation settings
17 require('./libraries/relation.lib.php3');
18 $cfgRelation = PMA_getRelationsParam();
21 /**
22 * Reordering the table has been requested by the user
24 if (isset($submitorderby) && !empty($order_field)) {
25 $sql_query = 'ALTER TABLE ' . PMA_backquote($table)
26 . ' ORDER BY ' . PMA_backquote(urldecode($order_field));
27 $result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', $sql_query, '', $err_url);
28 PMA_showMessage($strSuccess);
29 } // end if
32 /**
33 * Gets tables informations and displays top links
35 require('./tbl_properties_table_info.php3');
38 /**
39 * Get columns names
41 $local_query = 'SHOW COLUMNS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($db);
42 $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $error_url);
43 for ($i = 0; $row = PMA_mysql_fetch_array($result); $i++) {
44 $columns[$i] = $row['Field'];
46 mysql_free_result($result);
49 /**
50 * Displays the page
53 <ul>
55 <?php
56 if (PMA_MYSQL_INT_VERSION >= 32334) {
58 <!-- Order the table -->
59 <li>
60 <form method="post" action="tbl_properties_operations.php3">
61 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
62 <?php echo $strAlterOrderBy; ?>&nbsp;:
63 <select name="order_field" style="vertical-align: middle">
64 <?php
65 echo "\n";
66 reset($columns);
67 while (list($junk, $fieldname) = each($columns)) {
68 echo ' <option value="' . htmlspecialchars($fieldname) . '">' . htmlspecialchars($fieldname) . '</option>' . "\n";
70 unset($columns);
72 </select>
73 <input type="submit" name="submitorderby" value="<?php echo $strGo; ?>" style="vertical-align: middle" />
74 &nbsp;<?php echo $strSingly . "\n"; ?>
75 </form>
76 </li>
77 <?php
79 echo "\n";
82 <!-- Change table name -->
83 <li>
84 <div style="margin-bottom: 10px">
85 <form method="post" action="tbl_rename.php3"
86 onsubmit="return emptyFormElements(this, 'new_name')">
87 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
88 <input type="hidden" name="reload" value="1" />
89 <?php echo $strRenameTable; ?>&nbsp;:
90 <input type="text" size="20" name="new_name" value="<?php echo htmlspecialchars($table); ?>" class="textfield" onfocus="this.select()" />&nbsp;
91 <input type="submit" value="<?php echo $strGo; ?>" />
92 </form>
93 </div>
94 </li>
96 <!-- Move and copy table -->
97 <li style="vertical-align: top">
98 <div style="margin-bottom: 10px">
99 <table border="0" cellspacing="0" cellpadding="0" style="vertical-align: top">
100 <tr>
101 <td valign="top">
102 <form method="post" action="tbl_move_copy.php3"
103 onsubmit="return emptyFormElements(this, 'new_name')">
104 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
105 <input type="hidden" name="reload" value="1" />
106 <input type="hidden" name="what" value="data" />
107 <table border="0" cellspacing="0" cellpadding="0">
108 <tr>
109 <td nowrap="nowrap">
110 <?php echo $strMoveTable . "\n"; ?>
111 </td>
112 </tr>
113 <tr>
114 <td>
115 <select name="target_db">
116 <?php
117 // The function used below is defined in "common.lib.php3"
118 PMA_availableDatabases('main.php3?' . PMA_generate_common_url());
119 for ($i = 0; $i < $num_dbs; $i++) {
120 echo ' ';
121 echo '<option value="' . htmlspecialchars($dblist[$i]) . '">' . htmlspecialchars($dblist[$i]) . '</option>';
122 echo "\n";
123 } // end for
125 </select>
126 &nbsp;<b>.</b>&nbsp;
127 <input type="text" size="20" name="new_name" value="<?php echo htmlspecialchars($table); ?>" class="textfield" onfocus="this.select()" />
128 </td>
129 </tr>
130 <tr>
131 <td align="<?php echo $cell_align_right; ?>" valign="top">
132 <input type="submit" name="submit_move" value="<?php echo $strGo; ?>" />
133 </td>
134 </tr>
135 </table>
136 </form>
137 </td>
138 <td width="25">&nbsp;</td>
139 <td valign="top">
140 <form method="post" action="tbl_move_copy.php3"
141 onsubmit="return emptyFormElements(this, 'new_name')">
142 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
143 <input type="hidden" name="reload" value="1" />
144 <table border="0" cellspacing="0" cellpadding="0">
145 <tr>
146 <td colspan="2" nowrap="nowrap">
147 <?php echo $strCopyTable . "\n"; ?>
148 </td>
149 </tr>
150 <tr>
151 <td colspan="2">
152 <select name="target_db">
153 <?php
154 for ($i = 0; $i < $num_dbs; $i++) {
155 echo ' ';
156 echo '<option value="' . htmlspecialchars($dblist[$i]) . '"';
157 if ($dblist[$i] == $db) {
158 echo ' selected="selected"';
160 echo '>' . htmlspecialchars($dblist[$i]) . '</option>';
161 echo "\n";
162 } // end for
164 </select>
165 &nbsp;<b>.</b>&nbsp;
166 <input type="text" size="20" name="new_name" class="textfield" onfocus="this.select()" />
167 </td>
168 </tr>
169 <tr>
170 <td nowrap="nowrap">
171 <input type="radio" name="what" value="structure" id="radio_copy_structure" checked="checked" />
172 <label for="radio_copy_structure"><?php echo $strStrucOnly; ?></label>&nbsp;&nbsp;<br />
173 <input type="radio" name="what" value="data" id="radio_copy_data" />
174 <label for="radio_copy_data"><?php echo $strStrucData; ?></label>&nbsp;&nbsp;<br />
175 <input type="radio" name="what" value="dataonly" id="radio_copy_dataonly" />
176 <label for="radio_copy_dataonly"><?php echo $strDataOnly; ?></label>&nbsp;&nbsp;<br />
177 <input type="checkbox" name="drop_if_exists" value="true" id="checkbox_drop" />
178 <label for="checkbox_drop"><?php echo $strStrucDrop; ?></label>&nbsp;&nbsp;<br />
179 <?php
180 if (isset($_COOKIE) && isset($_COOKIE['pma_switch_to_new']) && $_COOKIE['pma_switch_to_new'] == 'true') {
181 $pma_switch_to_new = 'true';
182 } elseif (isset($HTTP_COOKIE_VARS) && isset($HTTP_COOKIE_VARS['pma_switch_to_new']) && $HTTP_COOKIE_VARS['pma_switch_to_new'] == 'true') {
183 $pma_switch_to_new = 'true';
186 <input type="checkbox" name="switch_to_new" value="true" id="checkbox_switch" <?php echo ((isset($pma_switch_to_new) && $pma_switch_to_new == 'true') ? 'checked="checked"' : ''); ?>/>
187 <label for="checkbox_switch"><?php echo $strSwitchToTable; ?></label>&nbsp;&nbsp;
188 </td>
189 <td align="<?php echo $cell_align_right; ?>" valign="top">
190 <input type="submit" name="submit_copy" value="<?php echo $strGo; ?>" />
191 </td>
192 </tr>
193 </table>
194 </form>
195 </td>
196 </tr>
197 </table>
198 </div>
199 </li>
201 <?php
202 if (PMA_MYSQL_INT_VERSION >= 32322) {
203 if ($tbl_type == 'MYISAM' or $tbl_type == 'BDB') {
205 <!-- Table maintenance -->
206 <li style="vertical-align: top">
207 <div style="margin-bottom: 10px">
208 <table border="0" cellspacing="0" cellpadding="0" style="vertical-align: top">
209 <tr>
210 <td><?php echo $strTableMaintenance; ?>&nbsp;:&nbsp;</td>
211 <?php
212 echo "\n";
213 if ($tbl_type == 'MYISAM') {
215 <td>
216 <a href="sql.php3?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('CHECK TABLE ' . PMA_backquote($table)); ?>">
217 <?php echo $strCheckTable; ?></a>&nbsp;
218 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'CHECK_TABLE') . "\n"; ?>
219 </td>
220 <td>&nbsp;-&nbsp;</td>
221 <?php
223 echo "\n";
224 if ($tbl_type == 'MYISAM' || $tbl_type == 'BDB') {
226 <td>
227 <a href="sql.php3?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ANALYZE TABLE ' . PMA_backquote($table)); ?>">
228 <?php echo $strAnalyzeTable; ?></a>&nbsp;
229 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'ANALYZE_TABLE') . "\n";?>
230 </td>
231 <?php
233 echo "\n";
235 </tr>
236 <tr>
237 <td>&nbsp;</td>
238 <?php
239 echo "\n";
240 if ($tbl_type == 'MYISAM') {
242 <td>
243 <a href="sql.php3?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('REPAIR TABLE ' . PMA_backquote($table)); ?>">
244 <?php echo $strRepairTable; ?></a>&nbsp;
245 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'REPAIR_TABLE') . "\n"; ?>
246 </td>
247 <td>&nbsp;-&nbsp;</td>
248 <?php
250 echo "\n";
251 if ($tbl_type == 'MYISAM' || $tbl_type == 'BDB') {
253 <td>
254 <a href="sql.php3?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . PMA_backquote($table)); ?>">
255 <?php echo $strOptimizeTable; ?></a>&nbsp;
256 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'OPTIMIZE_TABLE') . "\n"; ?>
257 </td>
258 <?php
260 echo "\n";
262 </tr>
263 </table><br />
264 </div>
265 </li>
266 <?php
267 } // end MYISAM or BDB case
268 echo "\n";
269 } // end MySQL >= 3.23.22
271 // loic1: "OPTIMIZE" statement is available for MyISAM and BDB tables only and
272 // MyISAM/BDB tables exists since MySQL 3.23.06/3.23.34
273 else if (PMA_MYSQL_INT_VERSION >= 32306
274 && ($tbl_type == 'MYISAM' or $tbl_type == 'BDB')) {
276 <!-- Table maintenance -->
277 <li style="vertical-align: top">
278 <div style="margin-bottom: 10px">
279 <?php echo $strTableMaintenance; ?>&nbsp;:&nbsp;
280 <a href="sql.php3?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . PMA_backquote($table)); ?>">
281 <?php echo $strOptimizeTable; ?></a>&nbsp;
282 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'OPTIMIZE_TABLE') . "\n"; ?>
283 </div>
284 </li>
285 <?php
286 echo "\n";
287 } // end 3.23.06 < MySQL < 3.23.22
289 // Referential integrity check
290 if ($cfgRelation['relwork']) {
292 // we need this PMA_mysql_select_db if the user has access to more than one db
293 // and $db is not the last of the list, because PMA_availableDatabases()
294 // has made a PMA_mysql_select_db() on the last one
295 PMA_mysql_select_db($db);
296 $foreign = PMA_getForeigners($db, $table);
298 if ($foreign) {
300 <!-- Referential integrity check -->
301 <li style="vertical-align: top">
302 <div style="margin-bottom: 10px">
303 <?php echo $strReferentialIntegrity; ?><br />
304 <?php
305 echo "\n";
306 while (list($master, $arr) = each($foreign)){
307 $join_query = 'SELECT ' . PMA_backquote($table) . '.* FROM '
308 . PMA_backquote($table) . ' LEFT JOIN '
309 . PMA_backquote($arr['foreign_table']);
310 if ($arr['foreign_table'] == $table) {
311 $foreign_table = $table . '1';
312 $join_query .= ' AS ' . PMA_backquote($foreign_table);
313 } else {
314 $foreign_table = $arr['foreign_table'];
316 $join_query .= ' ON '
317 . PMA_backquote($table) . '.' . PMA_backquote($master)
318 . ' = ' . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
319 . ' WHERE '
320 . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
321 . ' IS NULL AND '
322 . PMA_backquote($table) . '.' . PMA_backquote($master)
323 . ' IS NOT NULL';
324 echo ' '
325 . '<a href="sql.php3?' . $url_query
326 . '&amp;sql_query='
327 . urlencode($join_query)
328 . '">' . $master . '&nbsp;->&nbsp;' . $arr['foreign_table'] . '.' . $arr['foreign_field']
329 . '</a><br />' . "\n";
330 unset($foreign_table);
331 unset($join_query);
332 } // end while
334 </div>
335 </li><br />
336 <?php
337 } // end if ($result)
338 echo "\n";
340 } // end if (!empty($cfg['Server']['relation']))
343 <!-- Flushes the table -->
344 <li>
345 <a href="sql.php3?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('FLUSH TABLE ' . PMA_backquote($table)); ?>&amp;zero_rows=<?php echo urlencode(sprintf($strTableHasBeenFlushed, htmlspecialchars($table))); if ($cfg['ShowTooltip']) echo '&amp;reload=1'; ?>">
346 <?php echo $strFlushTable; ?></a>&nbsp;
347 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'FLUSH') . "\n"; ?>
348 <br /><br />
349 </li>
351 </ul>
353 <?php
355 * Displays the footer
357 echo "\n";
358 require('./footer.inc.php3');