update
[phpmyadmin/crack.git] / tbl_properties_operations.php3
blob876e484b6b2d9f917e57e331724811a0c6e77508
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 <option value=""></option>
117 <?php
118 // The function used below is defined in "common.lib.php3"
119 PMA_availableDatabases('main.php3?' . PMA_generate_common_url());
120 for ($i = 0; $i < $num_dbs; $i++) {
121 echo ' ';
122 echo '<option value="' . str_replace('"', '&quot;', $dblist[$i]) . '">' . htmlspecialchars($dblist[$i]) . '</option>';
123 echo "\n";
124 } // end for
126 </select>
127 &nbsp;<b>.</b>&nbsp;
128 <input type="text" size="20" name="new_name" value="<?php echo htmlspecialchars($table); ?>" class="textfield" onfocus="this.select()" />
129 </td>
130 </tr>
131 <tr>
132 <td align="<?php echo $cell_align_right; ?>" valign="top">
133 <input type="submit" name="submit_move" value="<?php echo $strGo; ?>" />
134 </td>
135 </tr>
136 </table>
137 </form>
138 </td>
139 <td width="25">&nbsp;</td>
140 <td valign="top">
141 <form method="post" action="tbl_move_copy.php3"
142 onsubmit="return emptyFormElements(this, 'new_name')">
143 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
144 <input type="hidden" name="reload" value="1" />
145 <table border="0" cellspacing="0" cellpadding="0">
146 <tr>
147 <td colspan="2" nowrap="nowrap">
148 <?php echo $strCopyTable . "\n"; ?>
149 </td>
150 </tr>
151 <tr>
152 <td colspan="2">
153 <select name="target_db">
154 <?php
155 for ($i = 0; $i < $num_dbs; $i++) {
156 echo ' ';
157 echo '<option value="' . str_replace('"', '&quot;', $dblist[$i]) . '"';
158 if ($dblist[$i] == $db) {
159 echo ' selected="selected"';
161 echo '>' . htmlspecialchars($dblist[$i]) . '</option>';
162 echo "\n";
163 } // end for
165 </select>
166 &nbsp;<b>.</b>&nbsp;
167 <input type="text" size="20" name="new_name" class="textfield" onfocus="this.select()" />
168 </td>
169 </tr>
170 <tr>
171 <td nowrap="nowrap">
172 <input type="radio" name="what" value="structure" id="radio_copy_structure" checked="checked" />
173 <label for="radio_copy_structure"><?php echo $strStrucOnly; ?></label>&nbsp;&nbsp;<br />
174 <input type="radio" name="what" value="data" id="radio_copy_data" />
175 <label for="radio_copy_data"><?php echo $strStrucData; ?></label>&nbsp;&nbsp;<br />
176 <input type="radio" name="what" value="dataonly" id="radio_copy_dataonly" />
177 <label for="radio_copy_dataonly"><?php echo $strDataOnly; ?></label>&nbsp;&nbsp;<br />
178 <input type="checkbox" name="drop_if_exists" value="true" id="checkbox_drop" />
179 <label for="checkbox_drop"><?php echo $strStrucDrop; ?></label>&nbsp;&nbsp;
180 </td>
181 <td align="<?php echo $cell_align_right; ?>" valign="top">
182 <input type="submit" name="submit_copy" value="<?php echo $strGo; ?>" />
183 </td>
184 </tr>
185 </table>
186 </form>
187 </td>
188 </tr>
189 </table>
190 </div>
191 </li>
193 <?php
194 if (PMA_MYSQL_INT_VERSION >= 32322) {
195 if ($tbl_type == 'MYISAM' or $tbl_type == 'BDB') {
197 <!-- Table maintenance -->
198 <li style="vertical-align: top">
199 <div style="margin-bottom: 10px">
200 <table border="0" cellspacing="0" cellpadding="0" style="vertical-align: top">
201 <tr>
202 <td><?php echo $strTableMaintenance; ?>&nbsp;:&nbsp;</td>
203 <?php
204 echo "\n";
205 if ($tbl_type == 'MYISAM') {
207 <td>
208 <a href="sql.php3?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('CHECK TABLE ' . PMA_backquote($table)); ?>">
209 <?php echo $strCheckTable; ?></a>&nbsp;
210 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'CHECK_TABLE') . "\n"; ?>
211 </td>
212 <td>&nbsp;-&nbsp;</td>
213 <?php
215 echo "\n";
216 if ($tbl_type == 'MYISAM' || $tbl_type == 'BDB') {
218 <td>
219 <a href="sql.php3?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ANALYZE TABLE ' . PMA_backquote($table)); ?>">
220 <?php echo $strAnalyzeTable; ?></a>&nbsp;
221 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'ANALYZE_TABLE') . "\n";?>
222 </td>
223 <?php
225 echo "\n";
227 </tr>
228 <tr>
229 <td>&nbsp;</td>
230 <?php
231 echo "\n";
232 if ($tbl_type == 'MYISAM') {
234 <td>
235 <a href="sql.php3?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('REPAIR TABLE ' . PMA_backquote($table)); ?>">
236 <?php echo $strRepairTable; ?></a>&nbsp;
237 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'REPAIR_TABLE') . "\n"; ?>
238 </td>
239 <td>&nbsp;-&nbsp;</td>
240 <?php
242 echo "\n";
243 if ($tbl_type == 'MYISAM' || $tbl_type == 'BDB') {
245 <td>
246 <a href="sql.php3?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . PMA_backquote($table)); ?>">
247 <?php echo $strOptimizeTable; ?></a>&nbsp;
248 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'OPTIMIZE_TABLE') . "\n"; ?>
249 </td>
250 <?php
252 echo "\n";
254 </tr>
255 </table><br />
256 </div>
257 </li>
258 <?php
259 } // end MYISAM or BDB case
260 echo "\n";
261 } // end MySQL >= 3.23.22
263 // loic1: "OPTIMIZE" statement is available for MyISAM and BDB tables only and
264 // MyISAM/BDB tables exists since MySQL 3.23.06/3.23.34
265 else if (PMA_MYSQL_INT_VERSION >= 32306
266 && ($tbl_type == 'MYISAM' or $tbl_type == 'BDB')) {
268 <!-- Table maintenance -->
269 <li style="vertical-align: top">
270 <div style="margin-bottom: 10px">
271 <?php echo $strTableMaintenance; ?>&nbsp;:&nbsp;
272 <a href="sql.php3?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . PMA_backquote($table)); ?>">
273 <?php echo $strOptimizeTable; ?></a>&nbsp;
274 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'OPTIMIZE_TABLE') . "\n"; ?>
275 </div>
276 </li>
277 <?php
278 echo "\n";
279 } // end 3.23.06 < MySQL < 3.23.22
281 // Referential integrity check
282 if ($cfgRelation['relwork']) {
284 // we need this PMA_mysql_select_db if the user has access to more than one db
285 // and $db is not the last of the list, because PMA_availableDatabases()
286 // has made a PMA_mysql_select_db() on the last one
287 PMA_mysql_select_db($db);
288 $foreign = PMA_getForeigners($db, $table);
290 if ($foreign) {
292 <!-- Referential integrity check -->
293 <li style="vertical-align: top">
294 <div style="margin-bottom: 10px">
295 <?php echo $strReferentialIntegrity; ?><br />
296 <?php
297 echo "\n";
298 while (list($master, $arr) = each($foreign)){
299 $join_query = 'SELECT ' . PMA_backquote($table) . '.* FROM '
300 . PMA_backquote($table) . ' LEFT JOIN '
301 . PMA_backquote($arr['foreign_table']);
302 if ($arr['foreign_table'] == $table) {
303 $foreign_table = $table . '1';
304 $join_query .= ' AS ' . PMA_backquote($foreign_table);
305 } else {
306 $foreign_table = $arr['foreign_table'];
308 $join_query .= ' ON '
309 . PMA_backquote($table) . '.' . PMA_backquote($master)
310 . ' = ' . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
311 . ' WHERE '
312 . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
313 . ' IS NULL AND '
314 . PMA_backquote($table) . '.' . PMA_backquote($master)
315 . ' IS NOT NULL';
316 echo ' '
317 . '<a href="sql.php3?' . $url_query
318 . '&amp;sql_query='
319 . urlencode($join_query)
320 . '">' . $master . '&nbsp;->&nbsp;' . $arr['foreign_table'] . '.' . $arr['foreign_field']
321 . '</a><br />' . "\n";
322 unset($foreign_table);
323 unset($join_query);
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_showMySQLDocu('MySQL_Database_Administration', 'FLUSH') . "\n"; ?>
340 <br /><br />
341 </li>
343 </ul>
345 <?php
347 * Displays the footer
349 echo "\n";
350 require('./footer.inc.php3');