Protect against php code input from user (bug #1530370).
[phpmyadmin/crack.git] / tbl_properties_structure.php
blob589c71584cc40793a420695b11726ce92c7150fd
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';
8 /**
9 * Drop multiple fields if required
12 // workaround for IE problem:
13 if (isset($submit_mult_change_x)) {
14 $submit_mult = $strChange;
15 } elseif (isset($submit_mult_drop_x)) {
16 $submit_mult = $strDrop;
17 } elseif (isset($submit_mult_primary_x)) {
18 $submit_mult = $strPrimary;
19 } elseif (isset($submit_mult_index_x)) {
20 $submit_mult = $strIndex;
21 } elseif (isset($submit_mult_unique_x)) {
22 $submit_mult = $strUnique;
23 } elseif (isset($submit_mult_fulltext_x)) {
24 $submit_mult = $strIdxFulltext;
27 if ((!empty($submit_mult) && isset($selected_fld))
28 || isset($mult_btn)) {
29 $action = 'tbl_properties_structure.php';
30 $err_url = 'tbl_properties_structure.php?' . PMA_generate_common_url($db, $table);
31 require './libraries/mult_submits.inc.php';
34 /**
35 * Runs common work
37 require_once './libraries/tbl_properties_common.php';
38 $url_query .= '&amp;goto=tbl_properties_structure.php&amp;back=tbl_properties_structure.php';
40 /**
41 * Prepares the table structure display
44 /**
45 * Gets tables informations
47 require_once './libraries/tbl_properties_table_info.inc.php';
49 /**
50 * Show result of multi submit operation
52 if ((!empty($submit_mult) && isset($selected_fld))
53 || isset($mult_btn)) {
54 $message = $strSuccess;
57 /**
58 * Displays top menu links
60 require_once './libraries/tbl_properties_links.inc.php';
62 // 2. Gets table keys and retains them
63 $result = PMA_DBI_query('SHOW INDEX FROM ' . PMA_backquote($table) . ';');
64 $primary = '';
65 $ret_keys = array();
66 $pk_array = array(); // will be use to emphasis prim. keys in the table view
67 while ($row = PMA_DBI_fetch_assoc($result)) {
68 $ret_keys[] = $row;
69 // Backups the list of primary keys
70 if ($row['Key_name'] == 'PRIMARY') {
71 $primary .= $row['Column_name'] . ', ';
72 $pk_array[$row['Column_name']] = 1;
74 } // end while
75 PMA_DBI_free_result($result);
77 // 3. Get fields
78 $fields_rs = PMA_DBI_query('SHOW FULL FIELDS FROM ' . PMA_backquote($table) . ';', null, PMA_DBI_QUERY_STORE);
79 $fields_cnt = PMA_DBI_num_rows($fields_rs);
81 // Get more complete field information
82 // For now, this is done just for MySQL 4.1.2+ new TIMESTAMP options
83 // but later, if the analyser returns more information, it
84 // could be executed for any MySQL version and replace
85 // the info given by SHOW FULL FIELDS FROM.
87 // We also need this to correctly learn if a TIMESTAMP is NOT NULL, since
88 // SHOW FULL FIELDS or INFORMATION_SCHEMA incorrectly says NULL
89 // and SHOW CREATE TABLE says NOT NULL (tested
90 // in MySQL 4.0.25 and 5.0.21, http://bugs.mysql.com/20910).
92 $show_create_table = PMA_DBI_fetch_value(
93 'SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table),
94 0, 1);
95 $analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table));
97 /**
98 * prepare table infos
100 // action titles (image or string)
101 $titles = array();
102 if ($cfg['PropertiesIconic'] == true) {
103 if ($cfg['PropertiesIconic'] === 'both') {
104 $iconic_spacer = '<div class="nowrap">';
105 } else {
106 $iconic_spacer = '';
109 // images replaced 2004-05-08 by mkkeck
110 $titles['Change'] = $iconic_spacer
111 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
112 . 'b_edit.png" alt="' . $strChange . '" title="' . $strChange . '" />';
113 $titles['Drop'] = $iconic_spacer
114 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
115 . 'b_drop.png" alt="' . $strDrop . '" title="' . $strDrop . '" />';
116 $titles['NoDrop'] = $iconic_spacer
117 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
118 . 'b_drop.png" alt="' . $strDrop . '" title="' . $strDrop . '" />';
119 $titles['Primary'] = $iconic_spacer
120 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
121 . 'b_primary.png" alt="' . $strPrimary . '" title="' . $strPrimary . '" />';
122 $titles['Index'] = $iconic_spacer
123 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
124 . 'b_index.png" alt="' . $strIndex . '" title="' . $strIndex . '" />';
125 $titles['Unique'] = $iconic_spacer
126 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
127 . 'b_unique.png" alt="' . $strUnique . '" title="' . $strUnique . '" />';
128 $titles['IdxFulltext'] = $iconic_spacer
129 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
130 . 'b_ftext.png" alt="' . $strIdxFulltext . '" title="' . $strIdxFulltext . '" />';
131 $titles['NoPrimary'] = $iconic_spacer
132 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
133 . 'bd_primary.png" alt="' . $strPrimary . '" title="' . $strPrimary . '" />';
134 $titles['NoIndex'] = $iconic_spacer
135 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
136 . 'bd_index.png" alt="' . $strIndex . '" title="' . $strIndex . '" />';
137 $titles['NoUnique'] = $iconic_spacer
138 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
139 . 'bd_unique.png" alt="' . $strUnique . '" title="' . $strUnique . '" />';
140 $titles['NoIdxFulltext'] = $iconic_spacer
141 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
142 . 'bd_ftext.png" alt="' . $strIdxFulltext . '" title="' . $strIdxFulltext . '" />';
143 $titles['BrowseDistinctValues'] = $iconic_spacer
144 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
145 . 'b_browse.png" alt="' . $strBrowseDistinctValues . '" title="' . $strBrowseDistinctValues . '" />';
147 if ($cfg['PropertiesIconic'] === 'both') {
148 $titles['Change'] .= $strChange . '</div>';
149 $titles['Drop'] .= $strDrop . '</div>';
150 $titles['NoDrop'] .= $strDrop . '</div>';
151 $titles['Primary'] .= $strPrimary . '</div>';
152 $titles['Index'] .= $strIndex . '</div>';
153 $titles['Unique'] .= $strUnique . '</div>';
154 $titles['IdxFulltext' ] .= $strIdxFulltext . '</div>';
155 $titles['NoPrimary'] .= $strPrimary . '</div>';
156 $titles['NoIndex'] .= $strIndex . '</div>';
157 $titles['NoUnique'] .= $strUnique . '</div>';
158 $titles['NoIdxFulltext'] .= $strIdxFulltext . '</div>';
159 $titles['BrowseDistinctValues'] .= $strBrowseDistinctValues . '</div>';
161 } else {
162 $titles['Change'] = $strChange;
163 $titles['Drop'] = $strDrop;
164 $titles['NoDrop'] = $strDrop;
165 $titles['Primary'] = $strPrimary;
166 $titles['Index'] = $strIndex;
167 $titles['Unique'] = $strUnique;
168 $titles['IdxFulltext'] = $strIdxFulltext;
169 $titles['NoPrimary'] = $strPrimary;
170 $titles['NoIndex'] = $strIndex;
171 $titles['NoUnique'] = $strUnique;
172 $titles['NoIdxFulltext'] = $strIdxFulltext;
173 $titles['BrowseDistinctValues'] = $strBrowseDistinctValues;
177 * Displays the table structure ('show table' works correct since 3.23.03)
179 /* TABLE INFORMATION */
180 // table header
181 $i = 0;
183 <form method="post" action="tbl_properties_structure.php" name="fieldsForm" id="fieldsForm">
184 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
185 <table id="tablestructure" class="data">
186 <thead>
187 <tr>
188 <th id="th<?php echo ++$i; ?>"></th>
189 <th id="th<?php echo ++$i; ?>"><?php echo $strField; ?></th>
190 <th id="th<?php echo ++$i; ?>"><?php echo $strType; ?></th>
191 <?php echo PMA_MYSQL_INT_VERSION >= 40100 ? ' <th id="th' . ++$i . '">' . $strCollation . '</th>' . "\n" : ''; ?>
192 <th id="th<?php echo ++$i; ?>"><?php echo $strAttr; ?></th>
193 <th id="th<?php echo ++$i; ?>"><?php echo $strNull; ?></th>
194 <th id="th<?php echo ++$i; ?>"><?php echo $strDefault; ?></th>
195 <th id="th<?php echo ++$i; ?>"><?php echo $strExtra; ?></th>
196 <?php if ($db_is_information_schema || $tbl_is_view) { ?>
197 <th id="th<?php echo ++$i; ?>"><?php echo $strView; ?></th>
198 <?php } else { ?>
199 <th colspan="7" id="th<?php echo ++$i; ?>"><?php echo $strAction; ?></th>
200 <?php } ?>
201 </tr>
202 </thead>
203 <tbody>
204 <?php
205 unset($i);
208 // table body
210 // prepare comments
211 $comments_map = array();
212 $mime_map = array();
214 if ($GLOBALS['cfg']['ShowPropertyComments']) {
215 require_once './libraries/relation.lib.php';
216 require_once './libraries/transformations.lib.php';
218 $cfgRelation = PMA_getRelationsParam();
220 if ($cfgRelation['commwork'] || PMA_MYSQL_INT_VERSION >= 40100) {
221 $comments_map = PMA_getComments($db, $table);
223 if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) {
224 $mime_map = PMA_getMIME($db, $table, true);
229 $rownum = 0;
230 $aryFields = array();
231 $checked = (!empty($checkall) ? ' checked="checked"' : '');
232 $save_row = array();
233 $odd_row = true;
234 while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
235 $save_row[] = $row;
236 $rownum++;
237 $aryFields[] = $row['Field'];
239 $type = $row['Type'];
240 // reformat mysql query output - staybyte - 9. June 2001
241 // loic1: set or enum types: slashes single quotes inside options
242 if (preg_match('@^(set|enum)\((.+)\)$@i', $type, $tmp)) {
243 $tmp[2] = substr(preg_replace('@([^,])\'\'@', '\\1\\\'', ',' . $tmp[2]), 1);
244 $type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
246 // for the case ENUM('&#8211;','&ldquo;')
247 $type = htmlspecialchars($type);
249 $type_nowrap = '';
251 $binary = 0;
252 $unsigned = 0;
253 $zerofill = 0;
254 } else {
255 $type_nowrap = ' nowrap="nowrap"';
256 // strip the "BINARY" attribute, except if we find "BINARY(" because
257 // this would be a BINARY or VARBINARY field type
258 if (!preg_match('@BINARY[\(]@i', $type)) {
259 $type = preg_replace('@BINARY@i', '', $type);
261 $type = preg_replace('@ZEROFILL@i', '', $type);
262 $type = preg_replace('@UNSIGNED@i', '', $type);
263 if (empty($type)) {
264 $type = ' ';
267 if (!preg_match('@BINARY[\(]@i', $row['Type'])) {
268 $binary = stristr($row['Type'], 'blob') || stristr($row['Type'], 'binary');
269 } else {
270 $binary = false;
273 $unsigned = stristr($row['Type'], 'unsigned');
274 $zerofill = stristr($row['Type'], 'zerofill');
277 // rabus: Divide charset from the rest of the type definition (MySQL >= 4.1)
278 unset($field_charset);
279 if (PMA_MYSQL_INT_VERSION >= 40100) {
280 if ((substr($type, 0, 4) == 'char'
281 || substr($type, 0, 7) == 'varchar'
282 || substr($type, 0, 4) == 'text'
283 || substr($type, 0, 8) == 'tinytext'
284 || substr($type, 0, 10) == 'mediumtext'
285 || substr($type, 0, 8) == 'longtext'
286 || substr($type, 0, 3) == 'set'
287 || substr($type, 0, 4) == 'enum'
288 ) && !$binary) {
289 if (strpos($type, ' character set ')) {
290 $type = substr($type, 0, strpos($type, ' character set '));
292 if (!empty($row['Collation'])) {
293 $field_charset = $row['Collation'];
294 } else {
295 $field_charset = '';
297 } else {
298 $field_charset = '';
302 // garvin: Display basic mimetype [MIME]
303 if ($cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME'] && isset($mime_map[$row['Field']]['mimetype'])) {
304 $type_mime = '<br />MIME: ' . str_replace('_', '/', $mime_map[$row['Field']]['mimetype']);
305 } else {
306 $type_mime = '';
309 $attribute = ' ';
310 if ($binary) {
311 $attribute = 'BINARY';
313 if ($unsigned) {
314 $attribute = 'UNSIGNED';
316 if ($zerofill) {
317 $attribute = 'UNSIGNED ZEROFILL';
320 // MySQL 4.1.2+ TIMESTAMP options
321 // (if on_update_current_timestamp is set, then it's TRUE)
322 if (isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) {
323 $attribute = 'ON UPDATE CURRENT_TIMESTAMP';
326 // here, we have a TIMESTAMP that SHOW FULL FIELDS reports as having the
327 // NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
328 // the latter.
329 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']) {
330 $row['Null'] = '';
334 if (!isset($row['Default'])) {
335 if ($row['Null'] == 'YES') {
336 $row['Default'] = '<i>NULL</i>';
338 } else {
339 $row['Default'] = htmlspecialchars($row['Default']);
342 $field_encoded = urlencode($row['Field']);
343 $field_name = htmlspecialchars($row['Field']);
345 // garvin: underline commented fields and display a hover-title (CSS only)
347 $comment_style = '';
348 if (isset($comments_map[$row['Field']])) {
349 $field_name = '<span style="border-bottom: 1px dashed black;" title="' . htmlspecialchars($comments_map[$row['Field']]) . '">' . $field_name . '</span>';
352 if (isset($pk_array[$row['Field']])) {
353 $field_name = '<u>' . $field_name . '</u>';
355 echo "\n";
357 <tr class="<?php echo $odd_row ? 'odd': 'even'; $odd_row = !$odd_row; ?>">
358 <td align="center">
359 <input type="checkbox" name="selected_fld[]" value="<?php echo $field_encoded; ?>" id="checkbox_row_<?php echo $rownum; ?>" <?php echo $checked; ?> />
360 </td>
361 <th nowrap="nowrap"><label for="checkbox_row_<?php echo $rownum; ?>"><?php echo $field_name; ?></label></th>
362 <td<?php echo $type_nowrap; ?>><bdo dir="ltr" xml:lang="en"><?php echo $type; echo $type_mime; ?></bdo></td>
363 <?php echo PMA_MYSQL_INT_VERSION >= 40100 ? ' <td>' . (empty($field_charset) ? '' : '<dfn title="' . PMA_getCollationDescr($field_charset) . '">' . $field_charset . '</dfn>') . '</td>' . "\n" : '' ?>
364 <td nowrap="nowrap" style="font-size: 70%"><?php echo $attribute; ?></td>
365 <td><?php echo (($row['Null'] == 'YES') ? $strYes : $strNo); ?></td>
366 <td nowrap="nowrap"><?php if (isset($row['Default'])) { echo $row['Default']; } ?></td>
367 <td nowrap="nowrap"><?php echo $row['Extra']; ?></td>
368 <td align="center">
369 <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'] . '`'); ?>">
370 <?php echo $titles['BrowseDistinctValues']; ?></a>
371 </td>
372 <?php if (! $tbl_is_view && ! $db_is_information_schema) { ?>
373 <td align="center">
374 <a href="tbl_alter.php?<?php echo $url_query; ?>&amp;field=<?php echo $field_encoded; ?>">
375 <?php echo $titles['Change']; ?></a>
376 </td>
377 <td align="center">
378 <?php
379 // loic1: Drop field only if there is more than one field in the table
380 if ($fields_cnt > 1) {
381 echo "\n";
383 <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']))); ?>"
384 onclick="return confirmLink(this, 'ALTER TABLE <?php echo PMA_jsFormat($table); ?> DROP <?php echo PMA_jsFormat($row['Field']); ?>')">
385 <?php echo $titles['Drop']; ?></a>
386 <?php
387 } else {
388 echo "\n" . ' ' . $titles['NoDrop'];
390 echo "\n";
392 </td>
393 <td align="center">
394 <?php
395 if ($type == 'text' || $type == 'blob') {
396 echo $titles['NoPrimary'] . "\n";
397 } else {
398 echo "\n";
400 <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']))); ?>"
401 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']); ?>)')">
402 <?php echo $titles['Primary']; ?></a>
403 <?php
405 echo "\n";
407 </td>
408 <td align="center">
409 <?php
410 if ($type == 'text' || $type == 'blob') {
411 echo $titles['NoUnique'] . "\n";
412 } else {
413 echo "\n";
415 <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']))); ?>">
416 <?php echo $titles['Unique']; ?></a>
417 <?php
419 echo "\n";
421 </td>
422 <td align="center">
423 <?php
424 if ($type == 'text' || $type == 'blob') {
425 echo $titles['NoIndex'] . "\n";
426 } else {
427 echo "\n";
429 <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']))); ?>">
430 <?php echo $titles['Index']; ?></a>
431 <?php
433 echo "\n";
435 </td>
436 <?php
437 if ((!empty($tbl_type) && $tbl_type == 'MYISAM')
438 && (strpos(' ' . $type, 'text') || strpos(' ' . $type, 'varchar'))) {
439 echo "\n";
441 <td align="center" nowrap="nowrap">
442 <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']))); ?>">
443 <?php echo $titles['IdxFulltext']; ?></a>
444 </td>
445 <?php
446 } else {
447 echo "\n";
449 <td align="center" nowrap="nowrap">
450 <?php echo $titles['NoIdxFulltext'] . "\n"; ?>
451 </td>
452 <?php
453 } // end if... else...
454 echo "\n";
455 } // end if (! $tbl_is_view && ! $db_is_information_schema)
457 </tr>
458 <?php
459 unset($field_charset);
460 } // end while
462 echo '</tbody>' . "\n"
463 .'</table>' . "\n";
465 $checkall_url = 'tbl_properties_structure.php?' . PMA_generate_common_url($db, $table);
468 <img class="selectallarrow" src="<?php echo $pmaThemeImage . 'arrow_' . $text_dir . '.png'; ?>"
469 width="38" height="22" alt="<?php echo $strWithChecked; ?>" />
470 <a href="<?php echo $checkall_url; ?>&amp;checkall=1"
471 onclick="if (markAllRows('fieldsForm')) return false;">
472 <?php echo $strCheckAll; ?></a>
474 <a href="<?php echo $checkall_url; ?>"
475 onclick="if (unMarkAllRows('fieldsForm')) return false;">
476 <?php echo $strUncheckAll; ?></a>
478 <i><?php echo $strWithChecked; ?></i>
480 <?php
481 if ($cfg['PropertiesIconic']) {
482 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_browse', $strBrowse, 'b_browse.png');
483 } else {
484 echo '<input type="submit" name="submit_mult" value="' . $strChange . '" title="' . $strChange . '" />' . "\n";
486 if (! $tbl_is_view && ! $db_is_information_schema) {
487 if ($cfg['PropertiesIconic']) {
488 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_change', $strChange, 'b_edit.png');
489 // Drop button if there is at least two fields
490 if ($fields_cnt > 1) {
491 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_drop', $strDrop, 'b_drop.png');
493 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_primary', $strPrimary, 'b_primary.png');
494 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_unique', $strUnique, 'b_unique.png');
495 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_index', $strIndex, 'b_index.png');
496 if ((!empty($tbl_type) && $tbl_type == 'MYISAM')) {
497 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_fulltext', $strIdxFulltext, 'b_ftext.png');
499 } else {
500 // Drop button if there is at least two fields
501 if ($fields_cnt > 1) {
502 echo '<i>' . $strOr . '</i>' . "\n"
503 . '<input type="submit" name="submit_mult" value="' . $strDrop . '" title="' . $strDrop . '" />' . "\n";
505 echo '<i>' . $strOr . '</i>' . "\n"
506 . '<input type="submit" name="submit_mult" value="' . $strPrimary . '" title="' . $strPrimary . '" />' . "\n";
507 echo '<i>' . $strOr . '</i>' . "\n"
508 . '<input type="submit" name="submit_mult" value="' . $strIndex . '" title="' . $strIndex . '" />' . "\n";
509 echo '<i>' . $strOr . '</i>' . "\n"
510 . '<input type="submit" name="submit_mult" value="' . $strUnique . '" title="' . $strUnique . '" />' . "\n";
511 if ((!empty($tbl_type) && $tbl_type == 'MYISAM')) {
512 echo '<i>' . $strOr . '</i>' . "\n"
513 . '<input type="submit" name="submit_mult" value="' . $strIdxFulltext . '" title="' . $strIdxFulltext . '" />' . "\n";
518 </form>
519 <hr />
521 <?php
523 * Work on the table
526 <a href="tbl_printview.php?<?php echo $url_query; ?>"><?php
527 if ($cfg['PropertiesIconic']) {
528 echo '<img class="icon" src="' . $pmaThemeImage . 'b_print.png" width="16" height="16" alt="' . $strPrintView . '"/>';
530 echo $strPrintView;
531 ?></a>
533 <?php
534 if (! $tbl_is_view && ! $db_is_information_schema) {
535 // if internal relations are available, or the table type is INNODB
536 // ($tbl_type comes from libraries/tbl_properties_table_info.inc.php)
538 if ($cfg['Server']['relation'] || $tbl_type=="INNODB") {
540 <a href="tbl_relation.php?<?php echo $url_query; ?>"><?php
541 if ($cfg['PropertiesIconic']) {
542 echo '<img class="icon" src="' . $pmaThemeImage . 'b_relations.png" width="16" height="16" alt="' . $strRelationView . '"/>';
544 echo $strRelationView;
545 ?></a>
546 <?php
549 <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
550 if ($cfg['PropertiesIconic']) {
551 echo '<img class="icon" src="' . $pmaThemeImage . 'b_tblanalyse.png" width="16" height="16" alt="' . $strStructPropose . '" />';
553 echo $strStructPropose;
554 ?></a><?php
555 echo PMA_showMySQLDocu('Extending_MySQL', 'procedure_analyse') . "\n";
556 ?><br />
557 <form method="post" action="tbl_addfield.php"
558 onsubmit="return checkFormElementInRange(this, 'num_fields', '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidFieldAddCount']); ?>', 1)">
559 <?php
560 echo PMA_generate_common_hidden_inputs($db, $table);
561 if ($cfg['PropertiesIconic']) {
562 echo '<img class="icon" src="' . $pmaThemeImage . 'b_insrow.png" width="16" height="16" alt="' . $strAddNewField . '"/>';
564 echo sprintf($strAddFields, '<input type="text" name="num_fields" size="2" maxlength="2" value="1" style="vertical-align: middle" onfocus="this.select()" />');
566 <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>
567 <input type="radio" name="field_where" id="radio_field_where_first" value="first" /><label for="radio_field_where_first"><?php echo $strAtBeginningOfTable; ?></label>
568 <input type="radio" name="field_where" id="radio_field_where_after" value="after" /><?php
569 $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">';
570 foreach ($aryFields as $fieldname) {
571 $fieldOptions .= '<option value="' . htmlspecialchars($fieldname) . '">' . htmlspecialchars($fieldname) . '</option>' . "\n";
573 unset($aryFields);
574 $fieldOptions .= '</select><label for="radio_field_where_after">';
575 echo str_replace('<label for="radio_field_where_after"></label>', '', '<label for="radio_field_where_after">' . sprintf($strAfter, $fieldOptions) . '</label>') . "\n";
577 <input type="submit" value="<?php echo $strGo; ?>" style="vertical-align: middle" />
578 </form>
579 <hr />
580 <?php
584 * If there are more than 20 rows, displays browse/select/insert/empty/drop
585 * links again
587 if ($fields_cnt > 20) {
588 require './libraries/tbl_properties_links.inc.php';
589 } // end if ($fields_cnt > 20)
590 echo "\n\n";
593 * Displays indexes
595 echo '<div id="tablestatistics">' . "\n";
596 if (! $tbl_is_view && ! $db_is_information_schema) {
597 define('PMA_IDX_INCLUDED', 1);
598 require './tbl_indexes.php';
602 * Displays Space usage and row statistics
604 // BEGIN - Calc Table Space - staybyte - 9 June 2001
605 // loic1, 22 feb. 2002: updated with patch from
606 // Joshua Nye <josh at boxcarmedia.com> to get valid
607 // statistics whatever is the table type
608 if ($cfg['ShowStats']) {
609 $nonisam = false;
610 $is_innodb = (isset($showtable['Type']) && $showtable['Type'] == 'InnoDB');
611 if (isset($showtable['Type']) && !preg_match('@ISAM|HEAP@i', $showtable['Type'])) {
612 $nonisam = true;
615 // Gets some sizes
616 $mergetable = false;
617 if (isset($showtable['Type']) && $showtable['Type'] == 'MRG_MyISAM') {
618 $mergetable = true;
620 list($data_size, $data_unit) = PMA_formatByteDown($showtable['Data_length']);
621 if ($mergetable == false) {
622 list($index_size, $index_unit) = PMA_formatByteDown($showtable['Index_length']);
624 if (isset($showtable['Data_free']) && $showtable['Data_free'] > 0) {
625 list($free_size, $free_unit) = PMA_formatByteDown($showtable['Data_free']);
626 list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length'] - $showtable['Data_free']);
627 } else {
628 list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length']);
630 list($tot_size, $tot_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length']);
631 if ($table_info_num_rows > 0) {
632 list($avg_size, $avg_unit) = PMA_formatByteDown(($showtable['Data_length'] + $showtable['Index_length']) / $showtable['Rows'], 6, 1);
635 // Displays them
636 $odd_row = false;
639 <a name="showusage"></a>
640 <?php if (! $tbl_is_view && ! $db_is_information_schema) { ?>
641 <table id="tablespaceusage" class="data">
642 <caption class="tblHeaders"><?php echo $strSpaceUsage; ?></caption>
643 <thead>
644 <tr>
645 <th><?php echo $strType; ?></th>
646 <th colspan="2"><?php echo $strUsage; ?></th>
647 </tr>
648 </thead>
649 <tbody>
650 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
651 <th class="name"><?php echo $strData; ?></th>
652 <td class="value"><?php echo $data_size; ?></td>
653 <td class="unit"><?php echo $data_unit; ?></td>
654 </tr>
655 <?php
656 if (isset($index_size)) {
658 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
659 <th class="name"><?php echo $strIndex; ?></th>
660 <td class="value"><?php echo $index_size; ?></td>
661 <td class="unit"><?php echo $index_unit; ?></td>
662 </tr>
663 <?php
665 if (isset($free_size)) {
667 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?> warning">
668 <th class="name"><?php echo $strOverhead; ?></th>
669 <td class="value"><?php echo $free_size; ?></td>
670 <td class="unit"><?php echo $free_unit; ?></td>
671 </tr>
672 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
673 <th class="name"><?php echo $strEffective; ?></th>
674 <td class="value"><?php echo $effect_size; ?></td>
675 <td class="unit"><?php echo $effect_unit; ?></td>
676 </tr>
677 <?php
679 if (isset($tot_size) && $mergetable == false) {
681 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
682 <th class="name"><?php echo $strTotalUC; ?></th>
683 <td class="value"><?php echo $tot_size; ?></td>
684 <td class="unit"><?php echo $tot_unit; ?></td>
685 </tr>
686 <?php
688 // Optimize link if overhead
689 if (isset($free_size) && ($tbl_type == 'MYISAM' || $tbl_type == 'BDB')) {
691 <tr class="tblFooters">
692 <td colspan="3" align="center">
693 <a href="sql.php?<?php echo $url_query; ?>&pos=0&amp;sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . PMA_backquote($table)); ?>"><?php
694 if ($cfg['PropertiesIconic']) {
695 echo '<img class="icon" src="' . $pmaThemeImage . 'b_tbloptimize.png" width="16" height="16" alt="' . $strOptimizeTable. '" />';
697 echo $strOptimizeTable;
698 ?></a>
699 </td>
700 </tr>
701 <?php
704 </tbody>
705 </table>
706 <?php
708 $odd_row = false;
710 <table id="tablerowstats" class="data">
711 <caption class="tblHeaders"><?php echo $strRowsStatistic; ?></caption>
712 <thead>
713 <tr>
714 <th><?php echo $strStatement; ?></th>
715 <th><?php echo $strValue; ?></th>
716 </tr>
717 </thead>
718 <tbody>
719 <?php
720 if (isset($showtable['Row_format'])) {
722 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
723 <th class="name"><?php echo $strFormat; ?></th>
724 <td class="value"><?php
725 if ($showtable['Row_format'] == 'Fixed') {
726 echo $strFixed;
727 } elseif ($showtable['Row_format'] == 'Dynamic') {
728 echo $strDynamic;
729 } else {
730 echo $showtable['Row_format'];
732 ?></td>
733 </tr>
734 <?php
736 if (PMA_MYSQL_INT_VERSION >= 40100 && !empty($tbl_collation)) {
738 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
739 <th class="name"><?php echo $strCollation; ?></th>
740 <td class="value"><?php
741 echo '<dfn title="' . PMA_getCollationDescr($tbl_collation) . '">' . $tbl_collation . '</dfn>';
742 ?></td>
743 </tr>
744 <?php
746 if (!$is_innodb && isset($showtable['Rows'])) {
748 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
749 <th class="name"><?php echo $strRows; ?></th>
750 <td class="value"><?php echo PMA_formatNumber($showtable['Rows'], 0); ?></td>
751 </tr>
752 <?php
754 if (!$is_innodb && isset($showtable['Avg_row_length']) && $showtable['Avg_row_length'] > 0) {
756 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
757 <th class="name"><?php echo $strRowLength; ?> &oslash;</th>
758 <td class="value"><?php echo PMA_formatNumber($showtable['Avg_row_length'], 0); ?></td>
759 </tr>
760 <?php
762 if (!$is_innodb && isset($showtable['Data_length']) && $showtable['Rows'] > 0 && $mergetable == false) {
764 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
765 <th class="name"><?php echo $strRowSize; ?> &oslash;</th>
766 <td class="value"><?php echo $avg_size . ' ' . $avg_unit; ?></td>
767 </tr>
768 <?php
770 if (isset($showtable['Auto_increment'])) {
772 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
773 <th class="name"><?php echo $strNext; ?> Autoindex</th>
774 <td class="value"><?php echo PMA_formatNumber($showtable['Auto_increment'], 0); ?></td>
775 </tr>
776 <?php
778 if (isset($showtable['Create_time'])) {
780 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
781 <th class="name"><?php echo $strStatCreateTime; ?></th>
782 <td class="value"><?php echo PMA_localisedDate(strtotime($showtable['Create_time'])); ?></td>
783 </tr>
784 <?php
786 if (isset($showtable['Update_time'])) {
788 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
789 <th class="name"><?php echo $strStatUpdateTime; ?></th>
790 <td class="value"><?php echo PMA_localisedDate(strtotime($showtable['Update_time'])); ?></td>
791 </tr>
792 <?php
794 if (isset($showtable['Check_time'])) {
796 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
797 <th class="name"><?php echo $strStatCheckTime; ?></th>
798 <td class="value"><?php echo PMA_localisedDate(strtotime($showtable['Check_time'])); ?></td>
799 </tr>
800 <?php
803 </tbody>
804 </table>
805 <?php
807 // END - Calc Table Space
808 echo '<div class="clearfloat"></div>' . "\n";
809 echo '</div>' . "\n";
812 * Displays the footer
814 require_once './libraries/footer.inc.php';