from Loic
[phpmyadmin/crack.git] / tbl_properties_operations.php3
blobc4829f728e5e4c2185271ead4409f3d8b153717b
1 <?php
2 /* $Id$ */
5 /**
6 * Runs common work
7 */
8 require('./tbl_properties_common.php3');
9 $err_url = 'tbl_properties_operations.php3' . $err_url;
10 $url_query .= '&amp;back=tbl_properties_operations.php3';
13 /**
14 * Gets relation settings
16 require('./libraries/relation.lib.php3');
17 $cfgRelation = PMA_getRelationsParam();
20 /**
21 * Reordering the table has been requested by the user
23 if (isset($submitorderby) && !empty($order_field)) {
24 $sql_query = 'ALTER TABLE ' . PMA_backquote($table)
25 . ' ORDER BY ' . PMA_backquote(urldecode($order_field));
26 $result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', $sql_query, '', $err_url);
27 PMA_showMessage((get_magic_quotes_gpc()) ? addslashes($strSuccess) : $strSuccess);
28 } // end if
31 /**
32 * Gets tables informations and displays top links
34 $sub_part = '_operations';
35 require('./tbl_properties_table_info.php3');
38 /**
39 * Get columns names
41 $local_query = 'SHOW COLUMNS FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table);
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 <input type="hidden" name="server" value="<?php echo $server; ?>" />
62 <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
63 <input type="hidden" name="convcharset" value="<?php echo $convcharset; ?>" />
64 <input type="hidden" name="db" value="<?php echo $db; ?>" />
65 <input type="hidden" name="table" value="<?php echo $table; ?>" />
66 <?php echo $strAlterOrderBy; ?>&nbsp;:
67 <select name="order_field" style="vertical-align: middle">
68 <?php
69 echo "\n";
70 reset($columns);
71 while (list($junk, $fieldname) = each($columns)) {
72 echo ' <option value="' . urlencode($fieldname) . '">' . htmlspecialchars($fieldname) . '</option>' . "\n";
74 unset($columns);
76 </select>
77 <input type="submit" name="submitorderby" value="<?php echo $strGo; ?>" style="vertical-align: middle" />
78 &nbsp;<?php echo $strSingly . "\n"; ?>
79 </form>
80 </li>
81 <?php
83 echo "\n";
86 <!-- Change table name -->
87 <li>
88 <div style="margin-bottom: 10px">
89 <form method="post" action="tbl_rename.php3"
90 onsubmit="return emptyFormElements(this, 'new_name')">
91 <input type="hidden" name="server" value="<?php echo $server; ?>" />
92 <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
93 <input type="hidden" name="convcharset" value="<?php echo $convcharset; ?>" />
94 <input type="hidden" name="db" value="<?php echo $db; ?>" />
95 <input type="hidden" name="table" value="<?php echo $table; ?>" />
96 <input type="hidden" name="reload" value="1" />
97 <?php echo $strRenameTable; ?>&nbsp;:
98 <input type="text" size="20" name="new_name" value="<?php echo htmlspecialchars($table); ?>" class="textfield" onfocus="this.select()" />&nbsp;
99 <input type="submit" value="<?php echo $strGo; ?>" />
100 </form>
101 </div>
102 </li>
104 <!-- Move and copy table -->
105 <li style="vertical-align: top">
106 <div style="margin-bottom: 10px">
107 <table border="0" cellspacing="0" cellpadding="0" style="vertical-align: top">
108 <tr>
109 <td valign="top">
110 <form method="post" action="tbl_move_copy.php3"
111 onsubmit="return emptyFormElements(this, 'new_name')">
112 <input type="hidden" name="server" value="<?php echo $server; ?>" />
113 <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
114 <input type="hidden" name="convcharset" value="<?php echo $convcharset; ?>" />
115 <input type="hidden" name="db" value="<?php echo $db; ?>" />
116 <input type="hidden" name="table" value="<?php echo $table; ?>" />
117 <input type="hidden" name="reload" value="1" />
118 <input type="hidden" name="what" value="data" />
119 <table border="0" cellspacing="0" cellpadding="0">
120 <tr>
121 <td nowrap="nowrap">
122 <?php echo $strMoveTable . "\n"; ?>
123 </td>
124 </tr>
125 <tr>
126 <td>
127 <select name="target_db">
128 <option value=""></option>
129 <?php
130 // The function used below is defined in "common.lib.php3"
131 PMA_availableDatabases('main.php3?lang=' . $lang . '&amp;server=' . $server);
132 for ($i = 0; $i < $num_dbs; $i++) {
133 echo ' ';
134 echo '<option value="' . str_replace('"', '&quot;', $dblist[$i]) . '">' . htmlspecialchars($dblist[$i]) . '</option>';
135 echo "\n";
136 } // end for
138 </select>
139 &nbsp;<b>.</b>&nbsp;
140 <input type="text" size="20" name="new_name" value="<?php echo $table; ?>" class="textfield" onfocus="this.select()" />
141 </td>
142 </tr>
143 <tr>
144 <td align="<?php echo $cell_align_right; ?>" valign="top">
145 <input type="submit" name="submit_move" value="<?php echo $strGo; ?>" />
146 </td>
147 </tr>
148 </table>
149 </form>
150 </td>
151 <td width="25">&nbsp;</td>
152 <td valign="top">
153 <form method="post" action="tbl_move_copy.php3"
154 onsubmit="return emptyFormElements(this, 'new_name')">
155 <input type="hidden" name="server" value="<?php echo $server; ?>" />
156 <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
157 <input type="hidden" name="convcharset" value="<?php echo $convcharset; ?>" />
158 <input type="hidden" name="db" value="<?php echo $db; ?>" />
159 <input type="hidden" name="table" value="<?php echo $table; ?>" />
160 <input type="hidden" name="reload" value="1" />
161 <table border="0" cellspacing="0" cellpadding="0">
162 <tr>
163 <td colspan="2" nowrap="nowrap">
164 <?php echo $strCopyTable . "\n"; ?>
165 </td>
166 </tr>
167 <tr>
168 <td colspan="2">
169 <select name="target_db">
170 <?php
171 for ($i = 0; $i < $num_dbs; $i++) {
172 echo ' ';
173 echo '<option value="' . str_replace('"', '&quot;', $dblist[$i]) . '"';
174 if ($dblist[$i] == $db) {
175 echo ' selected="selected"';
177 echo '>' . htmlspecialchars($dblist[$i]) . '</option>';
178 echo "\n";
179 } // end for
181 </select>
182 &nbsp;<b>.</b>&nbsp;
183 <input type="text" size="20" name="new_name" class="textfield" onfocus="this.select()" />
184 </td>
185 </tr>
186 <tr>
187 <td nowrap="nowrap">
188 <input type="radio" name="what" value="structure" id="radio_copy_structure" checked="checked" />
189 <label for="radio_copy_structure"><?php echo $strStrucOnly; ?></label>&nbsp;&nbsp;<br />
190 <input type="radio" name="what" value="data" id="radio_copy_data" />
191 <label for="radio_copy_data"><?php echo $strStrucData; ?></label>&nbsp;&nbsp;
192 </td>
193 <td align="<?php echo $cell_align_right; ?>" valign="top">
194 <input type="submit" name="submit_copy" value="<?php echo $strGo; ?>" />
195 </td>
196 </tr>
197 </table>
198 </form>
199 </td>
200 </tr>
201 </table>
202 </div>
203 </li>
205 <?php
206 if (PMA_MYSQL_INT_VERSION >= 32322) {
207 if ($tbl_type == 'MYISAM' or $tbl_type == 'BDB') {
209 <!-- Table maintenance -->
210 <li style="vertical-align: top">
211 <div style="margin-bottom: 10px">
212 <table border="0" cellspacing="0" cellpadding="0" style="vertical-align: top">
213 <tr>
214 <td><?php echo $strTableMaintenance; ?>&nbsp;:&nbsp;</td>
215 <?php
216 echo "\n";
217 if ($tbl_type == 'MYISAM') {
219 <td>
220 <a href="sql.php3?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('CHECK TABLE ' . PMA_backquote($table)); ?>">
221 <?php echo $strCheckTable; ?></a>&nbsp;
222 <?php echo PMA_showDocuShort('C/H/CHECK_TABLE.html') . "\n"; ?>
223 </td>
224 <td>&nbsp;-&nbsp;</td>
225 <?php
227 echo "\n";
228 if ($tbl_type == 'MYISAM' || $tbl_type == 'BDB') {
230 <td>
231 <a href="sql.php3?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ANALYZE TABLE ' . PMA_backquote($table)); ?>">
232 <?php echo $strAnalyzeTable; ?></a>&nbsp;
233 <?php echo PMA_showDocuShort('A/N/ANALYZE_TABLE.html') . "\n";?>
234 </td>
235 <?php
237 echo "\n";
239 </tr>
240 <tr>
241 <td>&nbsp;</td>
242 <?php
243 echo "\n";
244 if ($tbl_type == 'MYISAM') {
246 <td>
247 <a href="sql.php3?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('REPAIR TABLE ' . PMA_backquote($table)); ?>">
248 <?php echo $strRepairTable; ?></a>&nbsp;
249 <?php echo PMA_showDocuShort('R/E/REPAIR_TABLE.html') . "\n"; ?>
250 </td>
251 <td>&nbsp;-&nbsp;</td>
252 <?php
254 echo "\n";
255 if ($tbl_type == 'MYISAM' || $tbl_type == 'BDB') {
257 <td>
258 <a href="sql.php3?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . PMA_backquote($table)); ?>">
259 <?php echo $strOptimizeTable; ?></a>&nbsp;
260 <?php echo PMA_showDocuShort('O/P/OPTIMIZE_TABLE.html') . "\n"; ?>
261 </td>
262 <?php
264 echo "\n";
266 </tr>
267 </table><br />
268 </div>
269 </li>
270 <?php
271 } // end MYISAM or BDB case
272 echo "\n";
273 } // end MySQL >= 3.23.22
275 // loic1: "OPTIMIZE" statement is available for MyISAM and BDB tables only and
276 // MyISAM/BDB tables exists since MySQL 3.23.06/3.23.34
277 else if (PMA_MYSQL_INT_VERSION >= 32306
278 && ($tbl_type == 'MYISAM' or $tbl_type == 'BDB')) {
280 <!-- Table maintenance -->
281 <li style="vertical-align: top">
282 <div style="margin-bottom: 10px">
283 <?php echo $strTableMaintenance; ?>&nbsp;:&nbsp;
284 <a href="sql.php3?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . PMA_backquote($table)); ?>">
285 <?php echo $strOptimizeTable; ?></a>&nbsp;
286 <?php echo PMA_showDocuShort('O/P/OPTIMIZE_TABLE.html') . "\n"; ?>
287 </div>
288 </li>
289 <?php
290 echo "\n";
291 } // end 3.23.06 < MySQL < 3.23.22
293 // Referential integrity check
294 if ($cfgRelation['relwork']) {
296 // we need this PMA_mysql_select_db if the user has access to more than one db
297 // and $db is not the last of the list, because PMA_availableDatabases()
298 // has made a PMA_mysql_select_db() on the last one
299 PMA_mysql_select_db($db);
300 $foreign = PMA_getForeigners($db, $table);
302 if ($foreign) {
304 <!-- Referential integrity check -->
305 <li style="vertical-align: top">
306 <div style="margin-bottom: 10px">
307 <?php echo $strReferentialIntegrity; ?><br />
308 <?php
309 echo "\n";
310 while (list($master, $arr) = each($foreign)){
311 echo ' '
312 . '<a href="sql.php3?' . $url_query
313 . '&amp;sql_query='
314 . urlencode('SELECT ' . PMA_backquote($table) . '.* FROM '
315 . PMA_backquote($table) . ' LEFT JOIN '
316 . PMA_backquote($arr['foreign_table']) . ' ON '
317 . PMA_backquote($table) . '.' . PMA_backquote($master)
318 . ' = ' . PMA_backquote($arr['foreign_table']) . '.' . PMA_backquote($arr['foreign_field'])
319 . ' WHERE '
320 . PMA_backquote($arr['foreign_table']) . '.' . PMA_backquote($arr['foreign_field'])
321 . ' IS NULL')
322 . '">' . $master . '&nbsp;->&nbsp;' . $arr['foreign_table'] . '.' . $arr['foreign_field']
323 . '</a><br />' . "\n";
324 } // end while
326 </div>
327 </li><br />
328 <?php
329 } // end if ($result)
330 echo "\n";
332 } // end if (!empty($cfg['Server']['relation']))
335 <!-- Flushes the table -->
336 <li>
337 <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'; ?>">
338 <?php echo $strFlushTable; ?></a>&nbsp;
339 <?php echo PMA_showDocuShort('F/L/FLUSH.html') . "\n"; ?>
340 <br /><br />
341 </li>
343 </ul>
345 <?php
347 * Displays the footer
349 echo "\n";
350 require('./footer.inc.php3');