argh, commited not final version...
[phpmyadmin/crack.git] / tbl_properties_structure.php
blob0144816d7272241a9b3c194ce816c1db0014309b
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
5 require_once './libraries/common.lib.php';
6 require_once './libraries/mysql_charsets.lib.php';
7 require_once './libraries/relation.lib.php';
9 /**
10 * Gets the relation settings
12 $cfgRelation = PMA_getRelationsParam();
15 /**
16 * Drop multiple fields if required
19 // workaround for IE problem:
20 if (isset($submit_mult_change_x)) {
21 $submit_mult = $strChange;
22 } elseif (isset($submit_mult_drop_x)) {
23 $submit_mult = $strDrop;
24 } elseif (isset($submit_mult_primary_x)) {
25 $submit_mult = $strPrimary;
26 } elseif (isset($submit_mult_index_x)) {
27 $submit_mult = $strIndex;
28 } elseif (isset($submit_mult_unique_x)) {
29 $submit_mult = $strUnique;
30 } elseif (isset($submit_mult_fulltext_x)) {
31 $submit_mult = $strIdxFulltext;
34 if ((!empty($submit_mult) && isset($selected_fld))
35 || isset($mult_btn)) {
36 $action = 'tbl_properties_structure.php';
37 $err_url = 'tbl_properties_structure.php?' . PMA_generate_common_url($db, $table);
38 require './libraries/mult_submits.inc.php';
41 /**
42 * Runs common work
44 require_once './libraries/tbl_properties_common.php';
45 $url_query .= '&amp;goto=tbl_properties_structure.php&amp;back=tbl_properties_structure.php';
47 /**
48 * Prepares the table structure display
51 /**
52 * Gets tables informations
54 require_once './libraries/tbl_properties_table_info.inc.php';
56 /**
57 * Show result of multi submit operation
59 if ((!empty($submit_mult) && isset($selected_fld))
60 || isset($mult_btn)) {
61 $message = $strSuccess;
64 /**
65 * Displays top menu links
67 require_once './libraries/tbl_properties_links.inc.php';
69 // 2. Gets table keys and retains them
70 $result = PMA_DBI_query('SHOW INDEX FROM ' . PMA_backquote($table) . ';');
71 $primary = '';
72 $ret_keys = array();
73 $pk_array = array(); // will be use to emphasis prim. keys in the table view
74 while ($row = PMA_DBI_fetch_assoc($result)) {
75 $ret_keys[] = $row;
76 // Backups the list of primary keys
77 if ($row['Key_name'] == 'PRIMARY') {
78 $primary .= $row['Column_name'] . ', ';
79 $pk_array[$row['Column_name']] = 1;
81 } // end while
82 PMA_DBI_free_result($result);
84 // 3. Get fields
85 $fields_rs = PMA_DBI_query('SHOW FULL FIELDS FROM ' . PMA_backquote($table) . ';', null, PMA_DBI_QUERY_STORE);
86 $fields_cnt = PMA_DBI_num_rows($fields_rs);
88 // Get more complete field information
89 // For now, this is done just for MySQL 4.1.2+ new TIMESTAMP options
90 // but later, if the analyser returns more information, it
91 // could be executed for any MySQL version and replace
92 // the info given by SHOW FULL FIELDS FROM.
94 // We also need this to correctly learn if a TIMESTAMP is NOT NULL, since
95 // SHOW FULL FIELDS or INFORMATION_SCHEMA incorrectly says NULL
96 // and SHOW CREATE TABLE says NOT NULL (tested
97 // in MySQL 4.0.25 and 5.0.21, http://bugs.mysql.com/20910).
99 $show_create_table = PMA_DBI_fetch_value(
100 'SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table),
101 0, 1);
102 $analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table));
105 * prepare table infos
107 // action titles (image or string)
108 $titles = array();
109 if ($cfg['PropertiesIconic'] == true) {
110 if ($cfg['PropertiesIconic'] === 'both') {
111 $iconic_spacer = '<div class="nowrap">';
112 } else {
113 $iconic_spacer = '';
116 // images replaced 2004-05-08 by mkkeck
117 $titles['Change'] = $iconic_spacer
118 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
119 . 'b_edit.png" alt="' . $strChange . '" title="' . $strChange . '" />';
120 $titles['Drop'] = $iconic_spacer
121 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
122 . 'b_drop.png" alt="' . $strDrop . '" title="' . $strDrop . '" />';
123 $titles['NoDrop'] = $iconic_spacer
124 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
125 . 'b_drop.png" alt="' . $strDrop . '" title="' . $strDrop . '" />';
126 $titles['Primary'] = $iconic_spacer
127 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
128 . 'b_primary.png" alt="' . $strPrimary . '" title="' . $strPrimary . '" />';
129 $titles['Index'] = $iconic_spacer
130 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
131 . 'b_index.png" alt="' . $strIndex . '" title="' . $strIndex . '" />';
132 $titles['Unique'] = $iconic_spacer
133 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
134 . 'b_unique.png" alt="' . $strUnique . '" title="' . $strUnique . '" />';
135 $titles['IdxFulltext'] = $iconic_spacer
136 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
137 . 'b_ftext.png" alt="' . $strIdxFulltext . '" title="' . $strIdxFulltext . '" />';
138 $titles['NoPrimary'] = $iconic_spacer
139 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
140 . 'bd_primary.png" alt="' . $strPrimary . '" title="' . $strPrimary . '" />';
141 $titles['NoIndex'] = $iconic_spacer
142 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
143 . 'bd_index.png" alt="' . $strIndex . '" title="' . $strIndex . '" />';
144 $titles['NoUnique'] = $iconic_spacer
145 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
146 . 'bd_unique.png" alt="' . $strUnique . '" title="' . $strUnique . '" />';
147 $titles['NoIdxFulltext'] = $iconic_spacer
148 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
149 . 'bd_ftext.png" alt="' . $strIdxFulltext . '" title="' . $strIdxFulltext . '" />';
150 $titles['BrowseDistinctValues'] = $iconic_spacer
151 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
152 . 'b_browse.png" alt="' . $strBrowseDistinctValues . '" title="' . $strBrowseDistinctValues . '" />';
154 if ($cfg['PropertiesIconic'] === 'both') {
155 $titles['Change'] .= $strChange . '</div>';
156 $titles['Drop'] .= $strDrop . '</div>';
157 $titles['NoDrop'] .= $strDrop . '</div>';
158 $titles['Primary'] .= $strPrimary . '</div>';
159 $titles['Index'] .= $strIndex . '</div>';
160 $titles['Unique'] .= $strUnique . '</div>';
161 $titles['IdxFulltext' ] .= $strIdxFulltext . '</div>';
162 $titles['NoPrimary'] .= $strPrimary . '</div>';
163 $titles['NoIndex'] .= $strIndex . '</div>';
164 $titles['NoUnique'] .= $strUnique . '</div>';
165 $titles['NoIdxFulltext'] .= $strIdxFulltext . '</div>';
166 $titles['BrowseDistinctValues'] .= $strBrowseDistinctValues . '</div>';
168 } else {
169 $titles['Change'] = $strChange;
170 $titles['Drop'] = $strDrop;
171 $titles['NoDrop'] = $strDrop;
172 $titles['Primary'] = $strPrimary;
173 $titles['Index'] = $strIndex;
174 $titles['Unique'] = $strUnique;
175 $titles['IdxFulltext'] = $strIdxFulltext;
176 $titles['NoPrimary'] = $strPrimary;
177 $titles['NoIndex'] = $strIndex;
178 $titles['NoUnique'] = $strUnique;
179 $titles['NoIdxFulltext'] = $strIdxFulltext;
180 $titles['BrowseDistinctValues'] = $strBrowseDistinctValues;
184 * Displays the table structure ('show table' works correct since 3.23.03)
186 /* TABLE INFORMATION */
187 // table header
188 $i = 0;
190 <form method="post" action="tbl_properties_structure.php" name="fieldsForm" id="fieldsForm">
191 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
192 <table id="tablestructure" class="data">
193 <thead>
194 <tr>
195 <th id="th<?php echo ++$i; ?>"></th>
196 <th id="th<?php echo ++$i; ?>"><?php echo $strField; ?></th>
197 <th id="th<?php echo ++$i; ?>"><?php echo $strType; ?></th>
198 <?php echo PMA_MYSQL_INT_VERSION >= 40100 ? ' <th id="th' . ++$i . '">' . $strCollation . '</th>' . "\n" : ''; ?>
199 <th id="th<?php echo ++$i; ?>"><?php echo $strAttr; ?></th>
200 <th id="th<?php echo ++$i; ?>"><?php echo $strNull; ?></th>
201 <th id="th<?php echo ++$i; ?>"><?php echo $strDefault; ?></th>
202 <th id="th<?php echo ++$i; ?>"><?php echo $strExtra; ?></th>
203 <?php if ($db_is_information_schema || $tbl_is_view) { ?>
204 <th id="th<?php echo ++$i; ?>"><?php echo $strView; ?></th>
205 <?php } else { ?>
206 <th colspan="7" id="th<?php echo ++$i; ?>"><?php echo $strAction; ?></th>
207 <?php } ?>
208 </tr>
209 </thead>
210 <tbody>
211 <?php
212 unset($i);
215 // table body
217 // prepare comments
218 $comments_map = array();
219 $mime_map = array();
221 if ($GLOBALS['cfg']['ShowPropertyComments']) {
222 require_once './libraries/relation.lib.php';
223 require_once './libraries/transformations.lib.php';
225 $cfgRelation = PMA_getRelationsParam();
227 if ($cfgRelation['commwork'] || PMA_MYSQL_INT_VERSION >= 40100) {
228 $comments_map = PMA_getComments($db, $table);
230 if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) {
231 $mime_map = PMA_getMIME($db, $table, true);
236 $rownum = 0;
237 $aryFields = array();
238 $checked = (!empty($checkall) ? ' checked="checked"' : '');
239 $save_row = array();
240 $odd_row = true;
241 while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
242 $save_row[] = $row;
243 $rownum++;
244 $aryFields[] = $row['Field'];
246 $type = $row['Type'];
247 // reformat mysql query output - staybyte - 9. June 2001
248 // loic1: set or enum types: slashes single quotes inside options
249 if (preg_match('@^(set|enum)\((.+)\)$@i', $type, $tmp)) {
250 $tmp[2] = substr(preg_replace('@([^,])\'\'@', '\\1\\\'', ',' . $tmp[2]), 1);
251 $type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
253 // for the case ENUM('&#8211;','&ldquo;')
254 $type = htmlspecialchars($type);
256 $type_nowrap = '';
258 $binary = 0;
259 $unsigned = 0;
260 $zerofill = 0;
261 } else {
262 $type_nowrap = ' nowrap="nowrap"';
263 // strip the "BINARY" attribute, except if we find "BINARY(" because
264 // this would be a BINARY or VARBINARY field type
265 if (!preg_match('@BINARY[\(]@i', $type)) {
266 $type = preg_replace('@BINARY@i', '', $type);
268 $type = preg_replace('@ZEROFILL@i', '', $type);
269 $type = preg_replace('@UNSIGNED@i', '', $type);
270 if (empty($type)) {
271 $type = ' ';
274 if (!preg_match('@BINARY[\(]@i', $row['Type'])) {
275 $binary = stristr($row['Type'], 'blob') || stristr($row['Type'], 'binary');
276 } else {
277 $binary = false;
280 $unsigned = stristr($row['Type'], 'unsigned');
281 $zerofill = stristr($row['Type'], 'zerofill');
284 // rabus: Divide charset from the rest of the type definition (MySQL >= 4.1)
285 unset($field_charset);
286 if (PMA_MYSQL_INT_VERSION >= 40100) {
287 if ((substr($type, 0, 4) == 'char'
288 || substr($type, 0, 7) == 'varchar'
289 || substr($type, 0, 4) == 'text'
290 || substr($type, 0, 8) == 'tinytext'
291 || substr($type, 0, 10) == 'mediumtext'
292 || substr($type, 0, 8) == 'longtext'
293 || substr($type, 0, 3) == 'set'
294 || substr($type, 0, 4) == 'enum'
295 ) && !$binary) {
296 if (strpos($type, ' character set ')) {
297 $type = substr($type, 0, strpos($type, ' character set '));
299 if (!empty($row['Collation'])) {
300 $field_charset = $row['Collation'];
301 } else {
302 $field_charset = '';
304 } else {
305 $field_charset = '';
309 // garvin: Display basic mimetype [MIME]
310 if ($cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME'] && isset($mime_map[$row['Field']]['mimetype'])) {
311 $type_mime = '<br />MIME: ' . str_replace('_', '/', $mime_map[$row['Field']]['mimetype']);
312 } else {
313 $type_mime = '';
316 $attribute = ' ';
317 if ($binary) {
318 $attribute = 'BINARY';
320 if ($unsigned) {
321 $attribute = 'UNSIGNED';
323 if ($zerofill) {
324 $attribute = 'UNSIGNED ZEROFILL';
327 // MySQL 4.1.2+ TIMESTAMP options
328 // (if on_update_current_timestamp is set, then it's TRUE)
329 if (isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) {
330 $attribute = 'ON UPDATE CURRENT_TIMESTAMP';
333 // here, we have a TIMESTAMP that SHOW FULL FIELDS reports as having the
334 // NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
335 // the latter.
336 if (!empty($analyzed_sql[0]['create_table_fields'][$row['Field']]['type']) && $analyzed_sql[0]['create_table_fields'][$row['Field']]['type'] == 'TIMESTAMP' && $analyzed_sql[0]['create_table_fields'][$row['Field']]['timestamp_not_null']) {
337 $row['Null'] = '';
341 if (!isset($row['Default'])) {
342 if ($row['Null'] == 'YES') {
343 $row['Default'] = '<i>NULL</i>';
345 } else {
346 $row['Default'] = htmlspecialchars($row['Default']);
349 $field_encoded = urlencode($row['Field']);
350 $field_name = htmlspecialchars($row['Field']);
352 // garvin: underline commented fields and display a hover-title (CSS only)
354 $comment_style = '';
355 if (isset($comments_map[$row['Field']])) {
356 $field_name = '<span style="border-bottom: 1px dashed black;" title="' . htmlspecialchars($comments_map[$row['Field']]) . '">' . $field_name . '</span>';
359 if (isset($pk_array[$row['Field']])) {
360 $field_name = '<u>' . $field_name . '</u>';
362 echo "\n";
364 <tr class="<?php echo $odd_row ? 'odd': 'even'; $odd_row = !$odd_row; ?>">
365 <td align="center">
366 <input type="checkbox" name="selected_fld[]" value="<?php echo $field_encoded; ?>" id="checkbox_row_<?php echo $rownum; ?>" <?php echo $checked; ?> />
367 </td>
368 <th nowrap="nowrap"><label for="checkbox_row_<?php echo $rownum; ?>"><?php echo $field_name; ?></label></th>
369 <td<?php echo $type_nowrap; ?>><bdo dir="ltr" xml:lang="en"><?php echo $type; echo $type_mime; ?></bdo></td>
370 <?php echo PMA_MYSQL_INT_VERSION >= 40100 ? ' <td>' . (empty($field_charset) ? '' : '<dfn title="' . PMA_getCollationDescr($field_charset) . '">' . $field_charset . '</dfn>') . '</td>' . "\n" : '' ?>
371 <td nowrap="nowrap" style="font-size: 70%"><?php echo $attribute; ?></td>
372 <td><?php echo (($row['Null'] == 'YES') ? $strYes : $strNo); ?></td>
373 <td nowrap="nowrap"><?php if (isset($row['Default'])) { echo $row['Default']; } ?></td>
374 <td nowrap="nowrap"><?php echo $row['Extra']; ?></td>
375 <td align="center">
376 <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('SELECT COUNT(*) AS `' . $strRows . '`, `' . $row['Field'] . '` FROM `' . $table . '` GROUP BY `' . $row['Field'] . '` ORDER BY `' . $row['Field'] . '`'); ?>">
377 <?php echo $titles['BrowseDistinctValues']; ?></a>
378 </td>
379 <?php if (! $tbl_is_view && ! $db_is_information_schema) { ?>
380 <td align="center">
381 <a href="tbl_alter.php?<?php echo $url_query; ?>&amp;field=<?php echo $field_encoded; ?>">
382 <?php echo $titles['Change']; ?></a>
383 </td>
384 <td align="center">
385 <?php
386 // loic1: Drop field only if there is more than one field in the table
387 if ($fields_cnt > 1) {
388 echo "\n";
390 <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' DROP ' . PMA_backquote($row['Field'])); ?>&amp;cpurge=1&amp;purgekey=<?php echo urlencode($row['Field']); ?>&amp;zero_rows=<?php echo urlencode(sprintf($strFieldHasBeenDropped, htmlspecialchars($row['Field']))); ?>"
391 onclick="return confirmLink(this, 'ALTER TABLE <?php echo PMA_jsFormat($table); ?> DROP <?php echo PMA_jsFormat($row['Field']); ?>')">
392 <?php echo $titles['Drop']; ?></a>
393 <?php
394 } else {
395 echo "\n" . ' ' . $titles['NoDrop'];
397 echo "\n";
399 </td>
400 <td align="center">
401 <?php
402 if ($type == 'text' || $type == 'blob') {
403 echo $titles['NoPrimary'] . "\n";
404 } else {
405 echo "\n";
407 <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . (empty($primary) ? '' : ' DROP PRIMARY KEY,') . ' ADD PRIMARY KEY(' . PMA_backquote($row['Field']) . ')'); ?>&amp;zero_rows=<?php echo urlencode(sprintf($strAPrimaryKey, htmlspecialchars($row['Field']))); ?>"
408 onclick="return confirmLink(this, 'ALTER TABLE <?php echo PMA_jsFormat($table) . (empty($primary) ? '' : ' DROP PRIMARY KEY,'); ?> ADD PRIMARY KEY(<?php echo PMA_jsFormat($row['Field']); ?>)')">
409 <?php echo $titles['Primary']; ?></a>
410 <?php
412 echo "\n";
414 </td>
415 <td align="center">
416 <?php
417 if ($type == 'text' || $type == 'blob') {
418 echo $titles['NoUnique'] . "\n";
419 } else {
420 echo "\n";
422 <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD UNIQUE(' . PMA_backquote($row['Field']) . ')'); ?>&amp;zero_rows=<?php echo urlencode(sprintf($strAnIndex, htmlspecialchars($row['Field']))); ?>">
423 <?php echo $titles['Unique']; ?></a>
424 <?php
426 echo "\n";
428 </td>
429 <td align="center">
430 <?php
431 if ($type == 'text' || $type == 'blob') {
432 echo $titles['NoIndex'] . "\n";
433 } else {
434 echo "\n";
436 <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD INDEX(' . PMA_backquote($row['Field']) . ')'); ?>&amp;zero_rows=<?php echo urlencode(sprintf($strAnIndex, htmlspecialchars($row['Field']))); ?>">
437 <?php echo $titles['Index']; ?></a>
438 <?php
440 echo "\n";
442 </td>
443 <?php
444 if ((!empty($tbl_type) && $tbl_type == 'MYISAM')
445 && (strpos(' ' . $type, 'text') || strpos(' ' . $type, 'varchar'))) {
446 echo "\n";
448 <td align="center" nowrap="nowrap">
449 <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD FULLTEXT(' . PMA_backquote($row['Field']) . ')'); ?>&amp;zero_rows=<?php echo urlencode(sprintf($strAnIndex, htmlspecialchars($row['Field']))); ?>">
450 <?php echo $titles['IdxFulltext']; ?></a>
451 </td>
452 <?php
453 } else {
454 echo "\n";
456 <td align="center" nowrap="nowrap">
457 <?php echo $titles['NoIdxFulltext'] . "\n"; ?>
458 </td>
459 <?php
460 } // end if... else...
461 echo "\n";
462 } // end if (! $tbl_is_view && ! $db_is_information_schema)
464 </tr>
465 <?php
466 unset($field_charset);
467 } // end while
469 echo '</tbody>' . "\n"
470 .'</table>' . "\n";
472 $checkall_url = 'tbl_properties_structure.php?' . PMA_generate_common_url($db, $table);
475 <img class="selectallarrow" src="<?php echo $pmaThemeImage . 'arrow_' . $text_dir . '.png'; ?>"
476 width="38" height="22" alt="<?php echo $strWithChecked; ?>" />
477 <a href="<?php echo $checkall_url; ?>&amp;checkall=1"
478 onclick="if (markAllRows('fieldsForm')) return false;">
479 <?php echo $strCheckAll; ?></a>
481 <a href="<?php echo $checkall_url; ?>"
482 onclick="if (unMarkAllRows('fieldsForm')) return false;">
483 <?php echo $strUncheckAll; ?></a>
485 <i><?php echo $strWithChecked; ?></i>
487 <?php
488 if ($cfg['PropertiesIconic']) {
489 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_browse', $strBrowse, 'b_browse.png');
490 } else {
491 echo '<input type="submit" name="submit_mult" value="' . $strChange . '" title="' . $strChange . '" />' . "\n";
493 if (! $tbl_is_view && ! $db_is_information_schema) {
494 if ($cfg['PropertiesIconic']) {
495 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_change', $strChange, 'b_edit.png');
496 // Drop button if there is at least two fields
497 if ($fields_cnt > 1) {
498 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_drop', $strDrop, 'b_drop.png');
500 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_primary', $strPrimary, 'b_primary.png');
501 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_unique', $strUnique, 'b_unique.png');
502 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_index', $strIndex, 'b_index.png');
503 if ((!empty($tbl_type) && $tbl_type == 'MYISAM')) {
504 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_fulltext', $strIdxFulltext, 'b_ftext.png');
506 } else {
507 // Drop button if there is at least two fields
508 if ($fields_cnt > 1) {
509 echo '<i>' . $strOr . '</i>' . "\n"
510 . '<input type="submit" name="submit_mult" value="' . $strDrop . '" title="' . $strDrop . '" />' . "\n";
512 echo '<i>' . $strOr . '</i>' . "\n"
513 . '<input type="submit" name="submit_mult" value="' . $strPrimary . '" title="' . $strPrimary . '" />' . "\n";
514 echo '<i>' . $strOr . '</i>' . "\n"
515 . '<input type="submit" name="submit_mult" value="' . $strIndex . '" title="' . $strIndex . '" />' . "\n";
516 echo '<i>' . $strOr . '</i>' . "\n"
517 . '<input type="submit" name="submit_mult" value="' . $strUnique . '" title="' . $strUnique . '" />' . "\n";
518 if ((!empty($tbl_type) && $tbl_type == 'MYISAM')) {
519 echo '<i>' . $strOr . '</i>' . "\n"
520 . '<input type="submit" name="submit_mult" value="' . $strIdxFulltext . '" title="' . $strIdxFulltext . '" />' . "\n";
525 </form>
526 <hr />
528 <?php
530 * Work on the table
533 <a href="tbl_printview.php?<?php echo $url_query; ?>"><?php
534 if ($cfg['PropertiesIconic']) {
535 echo '<img class="icon" src="' . $pmaThemeImage . 'b_print.png" width="16" height="16" alt="' . $strPrintView . '"/>';
537 echo $strPrintView;
538 ?></a>
540 <?php
541 if (! $tbl_is_view && ! $db_is_information_schema) {
543 // if internal relations are available, or the table type is INNODB
544 // ($tbl_type comes from libraries/tbl_properties_table_info.inc.php)
545 if ($cfgRelation['relwork'] || $tbl_type=="INNODB") {
547 <a href="tbl_relation.php?<?php echo $url_query; ?>"><?php
548 if ($cfg['PropertiesIconic']) {
549 echo '<img class="icon" src="' . $pmaThemeImage . 'b_relations.png" width="16" height="16" alt="' . $strRelationView . '"/>';
551 echo $strRelationView;
552 ?></a>
553 <?php
556 <a href="sql.php?<?php echo $url_query; ?>&amp;session_max_rows=all&amp;sql_query=<?php echo urlencode('SELECT * FROM ' . PMA_backquote($table) . ' PROCEDURE ANALYSE()'); ?>"><?php
557 if ($cfg['PropertiesIconic']) {
558 echo '<img class="icon" src="' . $pmaThemeImage . 'b_tblanalyse.png" width="16" height="16" alt="' . $strStructPropose . '" />';
560 echo $strStructPropose;
561 ?></a><?php
562 echo PMA_showMySQLDocu('Extending_MySQL', 'procedure_analyse') . "\n";
563 ?><br />
564 <form method="post" action="tbl_addfield.php"
565 onsubmit="return checkFormElementInRange(this, 'num_fields', '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidFieldAddCount']); ?>', 1)">
566 <?php
567 echo PMA_generate_common_hidden_inputs($db, $table);
568 if ($cfg['PropertiesIconic']) {
569 echo '<img class="icon" src="' . $pmaThemeImage . 'b_insrow.png" width="16" height="16" alt="' . $strAddNewField . '"/>';
571 echo sprintf($strAddFields, '<input type="text" name="num_fields" size="2" maxlength="2" value="1" style="vertical-align: middle" onfocus="this.select()" />');
573 <input type="radio" name="field_where" id="radio_field_where_last" value="last" checked="checked" /><label for="radio_field_where_last"><?php echo $strAtEndOfTable; ?></label>
574 <input type="radio" name="field_where" id="radio_field_where_first" value="first" /><label for="radio_field_where_first"><?php echo $strAtBeginningOfTable; ?></label>
575 <input type="radio" name="field_where" id="radio_field_where_after" value="after" /><?php
576 $fieldOptions = '</label><select name="after_field" style="vertical-align: middle" onclick="this.form.field_where[2].checked=true" onchange="this.form.field_where[2].checked=true">';
577 foreach ($aryFields as $fieldname) {
578 $fieldOptions .= '<option value="' . htmlspecialchars($fieldname) . '">' . htmlspecialchars($fieldname) . '</option>' . "\n";
580 unset($aryFields);
581 $fieldOptions .= '</select><label for="radio_field_where_after">';
582 echo str_replace('<label for="radio_field_where_after"></label>', '', '<label for="radio_field_where_after">' . sprintf($strAfter, $fieldOptions) . '</label>') . "\n";
584 <input type="submit" value="<?php echo $strGo; ?>" style="vertical-align: middle" />
585 </form>
586 <hr />
587 <?php
591 * If there are more than 20 rows, displays browse/select/insert/empty/drop
592 * links again
594 if ($fields_cnt > 20) {
595 require './libraries/tbl_properties_links.inc.php';
596 } // end if ($fields_cnt > 20)
597 echo "\n\n";
600 * Displays indexes
602 echo '<div id="tablestatistics">' . "\n";
603 if (! $tbl_is_view && ! $db_is_information_schema) {
604 define('PMA_IDX_INCLUDED', 1);
605 require './tbl_indexes.php';
609 * Displays Space usage and row statistics
611 // BEGIN - Calc Table Space - staybyte - 9 June 2001
612 // loic1, 22 feb. 2002: updated with patch from
613 // Joshua Nye <josh at boxcarmedia.com> to get valid
614 // statistics whatever is the table type
615 if ($cfg['ShowStats']) {
616 $nonisam = false;
617 $is_innodb = (isset($showtable['Type']) && $showtable['Type'] == 'InnoDB');
618 if (isset($showtable['Type']) && !preg_match('@ISAM|HEAP@i', $showtable['Type'])) {
619 $nonisam = true;
622 // Gets some sizes
623 $mergetable = false;
624 if (isset($showtable['Type']) && $showtable['Type'] == 'MRG_MyISAM') {
625 $mergetable = true;
627 list($data_size, $data_unit) = PMA_formatByteDown($showtable['Data_length']);
628 if ($mergetable == false) {
629 list($index_size, $index_unit) = PMA_formatByteDown($showtable['Index_length']);
631 if (isset($showtable['Data_free']) && $showtable['Data_free'] > 0) {
632 list($free_size, $free_unit) = PMA_formatByteDown($showtable['Data_free']);
633 list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length'] - $showtable['Data_free']);
634 } else {
635 list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length']);
637 list($tot_size, $tot_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length']);
638 if ($table_info_num_rows > 0) {
639 list($avg_size, $avg_unit) = PMA_formatByteDown(($showtable['Data_length'] + $showtable['Index_length']) / $showtable['Rows'], 6, 1);
642 // Displays them
643 $odd_row = false;
646 <a name="showusage"></a>
647 <?php if (! $tbl_is_view && ! $db_is_information_schema) { ?>
648 <table id="tablespaceusage" class="data">
649 <caption class="tblHeaders"><?php echo $strSpaceUsage; ?></caption>
650 <thead>
651 <tr>
652 <th><?php echo $strType; ?></th>
653 <th colspan="2"><?php echo $strUsage; ?></th>
654 </tr>
655 </thead>
656 <tbody>
657 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
658 <th class="name"><?php echo $strData; ?></th>
659 <td class="value"><?php echo $data_size; ?></td>
660 <td class="unit"><?php echo $data_unit; ?></td>
661 </tr>
662 <?php
663 if (isset($index_size)) {
665 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
666 <th class="name"><?php echo $strIndex; ?></th>
667 <td class="value"><?php echo $index_size; ?></td>
668 <td class="unit"><?php echo $index_unit; ?></td>
669 </tr>
670 <?php
672 if (isset($free_size)) {
674 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?> warning">
675 <th class="name"><?php echo $strOverhead; ?></th>
676 <td class="value"><?php echo $free_size; ?></td>
677 <td class="unit"><?php echo $free_unit; ?></td>
678 </tr>
679 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
680 <th class="name"><?php echo $strEffective; ?></th>
681 <td class="value"><?php echo $effect_size; ?></td>
682 <td class="unit"><?php echo $effect_unit; ?></td>
683 </tr>
684 <?php
686 if (isset($tot_size) && $mergetable == false) {
688 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
689 <th class="name"><?php echo $strTotalUC; ?></th>
690 <td class="value"><?php echo $tot_size; ?></td>
691 <td class="unit"><?php echo $tot_unit; ?></td>
692 </tr>
693 <?php
695 // Optimize link if overhead
696 if (isset($free_size) && ($tbl_type == 'MYISAM' || $tbl_type == 'BDB')) {
698 <tr class="tblFooters">
699 <td colspan="3" align="center">
700 <a href="sql.php?<?php echo $url_query; ?>&pos=0&amp;sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . PMA_backquote($table)); ?>"><?php
701 if ($cfg['PropertiesIconic']) {
702 echo '<img class="icon" src="' . $pmaThemeImage . 'b_tbloptimize.png" width="16" height="16" alt="' . $strOptimizeTable. '" />';
704 echo $strOptimizeTable;
705 ?></a>
706 </td>
707 </tr>
708 <?php
711 </tbody>
712 </table>
713 <?php
715 $odd_row = false;
717 <table id="tablerowstats" class="data">
718 <caption class="tblHeaders"><?php echo $strRowsStatistic; ?></caption>
719 <thead>
720 <tr>
721 <th><?php echo $strStatement; ?></th>
722 <th><?php echo $strValue; ?></th>
723 </tr>
724 </thead>
725 <tbody>
726 <?php
727 if (isset($showtable['Row_format'])) {
729 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
730 <th class="name"><?php echo $strFormat; ?></th>
731 <td class="value"><?php
732 if ($showtable['Row_format'] == 'Fixed') {
733 echo $strFixed;
734 } elseif ($showtable['Row_format'] == 'Dynamic') {
735 echo $strDynamic;
736 } else {
737 echo $showtable['Row_format'];
739 ?></td>
740 </tr>
741 <?php
743 if (PMA_MYSQL_INT_VERSION >= 40100 && !empty($tbl_collation)) {
745 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
746 <th class="name"><?php echo $strCollation; ?></th>
747 <td class="value"><?php
748 echo '<dfn title="' . PMA_getCollationDescr($tbl_collation) . '">' . $tbl_collation . '</dfn>';
749 ?></td>
750 </tr>
751 <?php
753 if (!$is_innodb && isset($showtable['Rows'])) {
755 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
756 <th class="name"><?php echo $strRows; ?></th>
757 <td class="value"><?php echo PMA_formatNumber($showtable['Rows'], 0); ?></td>
758 </tr>
759 <?php
761 if (!$is_innodb && isset($showtable['Avg_row_length']) && $showtable['Avg_row_length'] > 0) {
763 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
764 <th class="name"><?php echo $strRowLength; ?> &oslash;</th>
765 <td class="value"><?php echo PMA_formatNumber($showtable['Avg_row_length'], 0); ?></td>
766 </tr>
767 <?php
769 if (!$is_innodb && isset($showtable['Data_length']) && $showtable['Rows'] > 0 && $mergetable == false) {
771 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
772 <th class="name"><?php echo $strRowSize; ?> &oslash;</th>
773 <td class="value"><?php echo $avg_size . ' ' . $avg_unit; ?></td>
774 </tr>
775 <?php
777 if (isset($showtable['Auto_increment'])) {
779 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
780 <th class="name"><?php echo $strNext; ?> Autoindex</th>
781 <td class="value"><?php echo PMA_formatNumber($showtable['Auto_increment'], 0); ?></td>
782 </tr>
783 <?php
785 if (isset($showtable['Create_time'])) {
787 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
788 <th class="name"><?php echo $strStatCreateTime; ?></th>
789 <td class="value"><?php echo PMA_localisedDate(strtotime($showtable['Create_time'])); ?></td>
790 </tr>
791 <?php
793 if (isset($showtable['Update_time'])) {
795 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
796 <th class="name"><?php echo $strStatUpdateTime; ?></th>
797 <td class="value"><?php echo PMA_localisedDate(strtotime($showtable['Update_time'])); ?></td>
798 </tr>
799 <?php
801 if (isset($showtable['Check_time'])) {
803 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
804 <th class="name"><?php echo $strStatCheckTime; ?></th>
805 <td class="value"><?php echo PMA_localisedDate(strtotime($showtable['Check_time'])); ?></td>
806 </tr>
807 <?php
810 </tbody>
811 </table>
812 <?php
814 // END - Calc Table Space
815 echo '<div class="clearfloat"></div>' . "\n";
816 echo '</div>' . "\n";
819 * Displays the footer
821 require_once './libraries/footer.inc.php';