bug 653764
[phpmyadmin/crack.git] / tbl_properties_operations.php3
blobc41b7b06912f024d1cc4924b7176deceb48340e2
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((get_magic_quotes_gpc()) ? addslashes($strSuccess) : $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 <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 htmlspecialchars($db); ?>" />
65 <input type="hidden" name="table" value="<?php echo htmlspecialchars($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 htmlspecialchars($db); ?>" />
95 <input type="hidden" name="table" value="<?php echo htmlspecialchars($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 htmlspecialchars($db); ?>" />
116 <input type="hidden" name="table" value="<?php echo htmlspecialchars($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 htmlspecialchars($db); ?>" />
159 <input type="hidden" name="table" value="<?php echo htmlspecialchars($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_showMySQLDocu('MySQL_Database_Administration', 'CHECK_TABLE') . "\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_showMySQLDocu('MySQL_Database_Administration', 'ANALYZE_TABLE') . "\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_showMySQLDocu('MySQL_Database_Administration', 'REPAIR_TABLE') . "\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_showMySQLDocu('MySQL_Database_Administration', 'OPTIMIZE_TABLE') . "\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_showMySQLDocu('MySQL_Database_Administration', 'OPTIMIZE_TABLE') . "\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 $join_query = 'SELECT ' . PMA_backquote($table) . '.* FROM '
312 . PMA_backquote($table) . ' LEFT JOIN '
313 . PMA_backquote($arr['foreign_table']);
314 if ($arr['foreign_table'] == $table) {
315 $foreign_table = $table . '1';
316 $join_query .= ' AS ' . PMA_backquote($foreign_table);
317 } else {
318 $foreign_table = $arr['foreign_table'];
320 $join_query .= ' ON '
321 . PMA_backquote($table) . '.' . PMA_backquote($master)
322 . ' = ' . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
323 . ' WHERE '
324 . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
325 . ' IS NULL AND '
326 . PMA_backquote($table) . '.' . PMA_backquote($master)
327 . ' IS NOT NULL';
328 echo ' '
329 . '<a href="sql.php3?' . $url_query
330 . '&amp;sql_query='
331 . urlencode($join_query)
332 . '">' . $master . '&nbsp;->&nbsp;' . $arr['foreign_table'] . '.' . $arr['foreign_field']
333 . '</a><br />' . "\n";
334 unset($foreign_table);
335 unset($join_query);
336 } // end while
338 </div>
339 </li><br />
340 <?php
341 } // end if ($result)
342 echo "\n";
344 } // end if (!empty($cfg['Server']['relation']))
347 <!-- Flushes the table -->
348 <li>
349 <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'; ?>">
350 <?php echo $strFlushTable; ?></a>&nbsp;
351 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'FLUSH') . "\n"; ?>
352 <br /><br />
353 </li>
355 </ul>
357 <?php
359 * Displays the footer
361 echo "\n";
362 require('./footer.inc.php3');