bug #2315549 [import] fclose() error with "Create PHP code"
[phpmyadmin/crack.git] / tbl_structure.php
blobe786cf130702ce88f845ab082e4113d144514fe1
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Displays table structure infos like fields/columns, indexes, size, rows
5 * and allows manipulation of indexes and columns/fields
6 * @version $Id$
7 */
9 /**
12 require_once './libraries/common.inc.php';
13 require_once './libraries/mysql_charsets.lib.php';
14 require_once './libraries/relation.lib.php';
16 $GLOBALS['js_include'][] = 'mootools.js';
18 /**
19 * handle multiple field commands if required
21 * submit_mult_*_x comes from IE if <input type="img" ...> is used
23 if (isset($_REQUEST['submit_mult_change_x'])) {
24 $submit_mult = $strChange;
25 } elseif (isset($_REQUEST['submit_mult_drop_x'])) {
26 $submit_mult = $strDrop;
27 } elseif (isset($_REQUEST['submit_mult_primary_x'])) {
28 $submit_mult = $strPrimary;
29 } elseif (isset($_REQUEST['submit_mult_index_x'])) {
30 $submit_mult = $strIndex;
31 } elseif (isset($_REQUEST['submit_mult_unique_x'])) {
32 $submit_mult = $strUnique;
33 } elseif (isset($_REQUEST['submit_mult_fulltext_x'])) {
34 $submit_mult = $strIdxFulltext;
35 } elseif (isset($_REQUEST['submit_mult_browse_x'])) {
36 $submit_mult = $strBrowse;
37 } elseif (isset($_REQUEST['submit_mult'])) {
38 $submit_mult = $_REQUEST['submit_mult'];
39 } elseif (isset($_REQUEST['mult_btn']) && $_REQUEST['mult_btn'] == $strYes) {
40 $submit_mult = 'row_delete';
41 if (isset($_REQUEST['selected'])) {
42 $_REQUEST['selected_fld'] = $_REQUEST['selected'];
46 if (! empty($submit_mult) && isset($_REQUEST['selected_fld'])) {
47 $err_url = 'tbl_structure.php?' . PMA_generate_common_url($db, $table);
48 if ($submit_mult == $strBrowse) {
49 // browsing the table displaying only selected fields/columns
50 $GLOBALS['active_page'] = 'sql.php';
51 $sql_query = '';
52 foreach ($_REQUEST['selected_fld'] as $idx => $sval) {
53 if ($sql_query == '') {
54 $sql_query .= 'SELECT ' . PMA_backquote($sval);
55 } else {
56 $sql_query .= ', ' . PMA_backquote($sval);
60 // what is this htmlspecialchars() for??
61 //$sql_query .= ' FROM ' . PMA_backquote(htmlspecialchars($table));
62 $sql_query .= ' FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table);
63 require './sql.php';
64 exit;
65 } else {
66 // handle multiple field commands
67 // handle confirmation of deleting multiple fields/columns
68 $action = 'tbl_structure.php';
69 require './libraries/mult_submits.inc.php';
70 //require_once './libraries/header.inc.php';
71 //require_once './libraries/tbl_links.inc.php';
73 if (empty($message)) {
74 $message = PMA_Message::success();
79 /**
80 * Gets the relation settings
82 $cfgRelation = PMA_getRelationsParam();
84 /**
85 * Runs common work
87 require_once './libraries/tbl_common.php';
88 $url_query .= '&amp;goto=tbl_structure.php&amp;back=tbl_structure.php';
89 $url_params['goto'] = 'tbl_structure.php';
90 $url_params['back'] = 'tbl_structure.php';
92 /**
93 * Prepares the table structure display
97 /**
98 * Gets tables informations
100 require_once './libraries/tbl_info.inc.php';
103 * Displays top menu links
105 require_once './libraries/tbl_links.inc.php';
106 require_once './libraries/Index.class.php';
108 // 2. Gets table keys and retains them
109 // @todo should be: $server->db($db)->table($table)->primary()
110 $primary = PMA_Index::getPrimary($table, $db);
113 // 3. Get fields
114 $fields_rs = PMA_DBI_query('SHOW FULL FIELDS FROM ' . PMA_backquote($table) . ';', null, PMA_DBI_QUERY_STORE);
115 $fields_cnt = PMA_DBI_num_rows($fields_rs);
118 // Get more complete field information
119 // For now, this is done just for MySQL 4.1.2+ new TIMESTAMP options
120 // but later, if the analyser returns more information, it
121 // could be executed for any MySQL version and replace
122 // the info given by SHOW FULL FIELDS FROM.
124 // We also need this to correctly learn if a TIMESTAMP is NOT NULL, since
125 // SHOW FULL FIELDS or INFORMATION_SCHEMA incorrectly says NULL
126 // and SHOW CREATE TABLE says NOT NULL (tested
127 // in MySQL 4.0.25 and 5.0.21, http://bugs.mysql.com/20910).
129 $show_create_table = PMA_DBI_fetch_value(
130 'SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table),
131 0, 1);
132 $analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table));
135 * prepare table infos
137 // action titles (image or string)
138 $titles = array();
139 $titles['Change'] = PMA_getIcon('b_edit.png', $strChange, true);
140 $titles['Drop'] = PMA_getIcon('b_drop.png', $strDrop, true);
141 $titles['NoDrop'] = PMA_getIcon('b_drop.png', $strDrop, true);
142 $titles['Primary'] = PMA_getIcon('b_primary.png', $strPrimary, true);
143 $titles['Index'] = PMA_getIcon('b_index.png', $strIndex, true);
144 $titles['Unique'] = PMA_getIcon('b_unique.png', $strUnique, true);
145 $titles['IdxFulltext'] = PMA_getIcon('b_ftext.png', $strIdxFulltext, true);
146 $titles['NoPrimary'] = PMA_getIcon('bd_primary.png', $strPrimary, true);
147 $titles['NoIndex'] = PMA_getIcon('bd_index.png', $strIndex, true);
148 $titles['NoUnique'] = PMA_getIcon('bd_unique.png', $strUnique, true);
149 $titles['NoIdxFulltext'] = PMA_getIcon('bd_ftext.png', $strIdxFulltext, true);
150 $titles['BrowseDistinctValues'] = PMA_getIcon('b_browse.png', $strBrowseDistinctValues, true);
153 * Displays the table structure ('show table' works correct since 3.23.03)
155 /* TABLE INFORMATION */
156 // table header
157 $i = 0;
159 <form method="post" action="tbl_structure.php" name="fieldsForm" id="fieldsForm">
160 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
161 <table id="tablestructure" class="data">
162 <thead>
163 <tr>
164 <th id="th<?php echo ++$i; ?>"></th>
165 <th id="th<?php echo ++$i; ?>"><?php echo $strField; ?></th>
166 <th id="th<?php echo ++$i; ?>"><?php echo $strType; ?></th>
167 <th id="th<?php echo ++$i; ?>"><?php echo $strCollation; ?></th>
168 <th id="th<?php echo ++$i; ?>"><?php echo $strAttr; ?></th>
169 <th id="th<?php echo ++$i; ?>"><?php echo $strNull; ?></th>
170 <th id="th<?php echo ++$i; ?>"><?php echo $strDefault; ?></th>
171 <th id="th<?php echo ++$i; ?>"><?php echo $strExtra; ?></th>
172 <?php if ($db_is_information_schema || $tbl_is_view) { ?>
173 <th id="th<?php echo ++$i; ?>"><?php echo $strView; ?></th>
174 <?php } else { ?>
175 <th colspan="7" id="th<?php echo ++$i; ?>"><?php echo $strAction; ?></th>
176 <?php } ?>
177 </tr>
178 </thead>
179 <tbody>
180 <?php
181 unset($i);
184 // table body
186 // prepare comments
187 $comments_map = array();
188 $mime_map = array();
190 if ($GLOBALS['cfg']['ShowPropertyComments']) {
191 require_once './libraries/relation.lib.php';
192 require_once './libraries/transformations.lib.php';
194 //$cfgRelation = PMA_getRelationsParam();
196 $comments_map = PMA_getComments($db, $table);
198 if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) {
199 $mime_map = PMA_getMIME($db, $table, true);
203 $rownum = 0;
204 $aryFields = array();
205 $checked = (!empty($checkall) ? ' checked="checked"' : '');
206 $save_row = array();
207 $odd_row = true;
208 while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
209 $save_row[] = $row;
210 $rownum++;
211 $aryFields[] = $row['Field'];
213 $type = $row['Type'];
214 $extracted_fieldspec = PMA_extractFieldSpec($row['Type']);
216 if ('set' == $extracted_fieldspec['type'] || 'enum' == $extracted_fieldspec['type']) {
217 $type = $extracted_fieldspec['type'] . '(' . $extracted_fieldspec['spec_in_brackets'] . ')';
219 // for the case ENUM('&#8211;','&ldquo;')
220 $type = htmlspecialchars($type);
222 $type_nowrap = '';
224 $binary = 0;
225 $unsigned = 0;
226 $zerofill = 0;
227 } else {
228 $type_nowrap = ' nowrap="nowrap"';
229 // strip the "BINARY" attribute, except if we find "BINARY(" because
230 // this would be a BINARY or VARBINARY field type
231 if (!preg_match('@BINARY[\(]@i', $type)) {
232 $type = preg_replace('@BINARY@i', '', $type);
234 $type = preg_replace('@ZEROFILL@i', '', $type);
235 $type = preg_replace('@UNSIGNED@i', '', $type);
236 if (empty($type)) {
237 $type = ' ';
240 if (!preg_match('@BINARY[\(]@i', $row['Type'])) {
241 $binary = stristr($row['Type'], 'blob') || stristr($row['Type'], 'binary');
242 } else {
243 $binary = false;
246 $unsigned = stristr($row['Type'], 'unsigned');
247 $zerofill = stristr($row['Type'], 'zerofill');
250 unset($field_charset);
251 if ((substr($type, 0, 4) == 'char'
252 || substr($type, 0, 7) == 'varchar'
253 || substr($type, 0, 4) == 'text'
254 || substr($type, 0, 8) == 'tinytext'
255 || substr($type, 0, 10) == 'mediumtext'
256 || substr($type, 0, 8) == 'longtext'
257 || substr($type, 0, 3) == 'set'
258 || substr($type, 0, 4) == 'enum'
259 ) && !$binary) {
260 if (strpos($type, ' character set ')) {
261 $type = substr($type, 0, strpos($type, ' character set '));
263 if (!empty($row['Collation'])) {
264 $field_charset = $row['Collation'];
265 } else {
266 $field_charset = '';
268 } else {
269 $field_charset = '';
272 // garvin: Display basic mimetype [MIME]
273 if ($cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME'] && isset($mime_map[$row['Field']]['mimetype'])) {
274 $type_mime = '<br />MIME: ' . str_replace('_', '/', $mime_map[$row['Field']]['mimetype']);
275 } else {
276 $type_mime = '';
279 $attribute = ' ';
280 if ($binary) {
281 $attribute = 'BINARY';
283 if ($unsigned) {
284 $attribute = 'UNSIGNED';
286 if ($zerofill) {
287 $attribute = 'UNSIGNED ZEROFILL';
290 // MySQL 4.1.2+ TIMESTAMP options
291 // (if on_update_current_timestamp is set, then it's TRUE)
292 if (isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) {
293 $attribute = 'on update CURRENT_TIMESTAMP';
296 // here, we have a TIMESTAMP that SHOW FULL FIELDS reports as having the
297 // NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
298 // the latter.
299 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']) {
300 $row['Null'] = '';
304 if (!isset($row['Default'])) {
305 if ($row['Null'] == 'YES') {
306 $row['Default'] = '<i>NULL</i>';
308 } else {
309 $row['Default'] = htmlspecialchars($row['Default']);
312 $field_encoded = urlencode($row['Field']);
313 $field_name = htmlspecialchars($row['Field']);
315 // garvin: underline commented fields and display a hover-title (CSS only)
317 $comment_style = '';
318 if (isset($comments_map[$row['Field']])) {
319 $field_name = '<span style="border-bottom: 1px dashed black;" title="' . htmlspecialchars($comments_map[$row['Field']]) . '">' . $field_name . '</span>';
322 if ($primary && $primary->hasColumn($field_name)) {
323 $field_name = '<u>' . $field_name . '</u>';
325 echo "\n";
327 <tr class="<?php echo $odd_row ? 'odd': 'even'; $odd_row = !$odd_row; ?>">
328 <td align="center">
329 <input type="checkbox" name="selected_fld[]" value="<?php echo htmlspecialchars($row['Field']); ?>" id="checkbox_row_<?php echo $rownum; ?>" <?php echo $checked; ?> />
330 </td>
331 <th nowrap="nowrap"><label for="checkbox_row_<?php echo $rownum; ?>"><?php echo $field_name; ?></label></th>
332 <td<?php echo $type_nowrap; ?>><bdo dir="ltr" xml:lang="en"><?php echo $type; echo $type_mime; ?></bdo></td>
333 <td><?php echo (empty($field_charset) ? '' : '<dfn title="' . PMA_getCollationDescr($field_charset) . '">' . $field_charset . '</dfn>'); ?></td>
334 <td nowrap="nowrap" style="font-size: 70%"><?php echo $attribute; ?></td>
335 <td><?php echo (($row['Null'] == 'YES') ? $strYes : $strNo); ?></td>
336 <td nowrap="nowrap"><?php
337 if (isset($row['Default'])) {
338 if ($extracted_fieldspec['type'] == 'bit') {
339 echo PMA_printable_bit_value($row['Default'], $extracted_fieldspec['spec_in_brackets']);
340 } else {
341 echo $row['Default'];
344 else {
345 echo '<i>' . $strNone . '</i>';
346 } ?></td>
347 <td nowrap="nowrap"><?php echo $row['Extra']; ?></td>
348 <td align="center">
349 <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('SELECT COUNT(*) AS ' . PMA_backquote($strRows) . ', ' . PMA_backquote($row['Field']) . ' FROM ' . PMA_backquote($table) . ' GROUP BY ' . PMA_backquote($row['Field']) . ' ORDER BY ' . PMA_backquote($row['Field'])); ?>">
350 <?php echo $titles['BrowseDistinctValues']; ?></a>
351 </td>
352 <?php if (! $tbl_is_view && ! $db_is_information_schema) { ?>
353 <td align="center">
354 <a href="tbl_alter.php?<?php echo $url_query; ?>&amp;field=<?php echo $field_encoded; ?>">
355 <?php echo $titles['Change']; ?></a>
356 </td>
357 <td align="center">
358 <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']))); ?>"
359 onclick="return confirmLink(this, 'ALTER TABLE <?php echo PMA_jsFormat($table); ?> DROP <?php echo PMA_jsFormat($row['Field']); ?>')">
360 <?php echo $titles['Drop']; ?></a>
361 </td>
362 <td align="center">
363 <?php
364 if ($type == 'text' || $type == 'blob' || 'ARCHIVE' == $tbl_type) {
365 echo $titles['NoPrimary'] . "\n";
366 } else {
367 echo "\n";
369 <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ($primary ? ' DROP PRIMARY KEY,' : '') . ' ADD PRIMARY KEY(' . PMA_backquote($row['Field']) . ')'); ?>&amp;zero_rows=<?php echo urlencode(sprintf($strAPrimaryKey, htmlspecialchars($row['Field']))); ?>"
370 onclick="return confirmLink(this, 'ALTER TABLE <?php echo PMA_jsFormat($table) . ($primary ? ' DROP PRIMARY KEY,' : ''); ?> ADD PRIMARY KEY(<?php echo PMA_jsFormat($row['Field']); ?>)')">
371 <?php echo $titles['Primary']; ?></a>
372 <?php
374 echo "\n";
376 </td>
377 <td align="center">
378 <?php
379 if ($type == 'text' || $type == 'blob' || 'ARCHIVE' == $tbl_type) {
380 echo $titles['NoUnique'] . "\n";
381 } else {
382 echo "\n";
384 <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']))); ?>">
385 <?php echo $titles['Unique']; ?></a>
386 <?php
388 echo "\n";
390 </td>
391 <td align="center">
392 <?php
393 if ($type == 'text' || $type == 'blob' || 'ARCHIVE' == $tbl_type) {
394 echo $titles['NoIndex'] . "\n";
395 } else {
396 echo "\n";
398 <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']))); ?>">
399 <?php echo $titles['Index']; ?></a>
400 <?php
402 echo "\n";
404 </td>
405 <?php
406 if (! empty($tbl_type) && ($tbl_type == 'MYISAM' || $tbl_type == 'MARIA')
407 // FULLTEXT is possible on TEXT, CHAR and VARCHAR
408 && (strpos(' ' . $type, 'text') || strpos(' ' . $type, 'char'))) {
409 echo "\n";
411 <td align="center" nowrap="nowrap">
412 <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']))); ?>">
413 <?php echo $titles['IdxFulltext']; ?></a>
414 </td>
415 <?php
416 } else {
417 echo "\n";
419 <td align="center" nowrap="nowrap">
420 <?php echo $titles['NoIdxFulltext'] . "\n"; ?>
421 </td>
422 <?php
423 } // end if... else...
424 echo "\n";
425 } // end if (! $tbl_is_view && ! $db_is_information_schema)
427 </tr>
428 <?php
429 unset($field_charset);
430 } // end while
432 echo '</tbody>' . "\n"
433 .'</table>' . "\n";
435 $checkall_url = 'tbl_structure.php?' . PMA_generate_common_url($db, $table);
438 <img class="selectallarrow" src="<?php echo $pmaThemeImage . 'arrow_' . $text_dir . '.png'; ?>"
439 width="38" height="22" alt="<?php echo $strWithChecked; ?>" />
440 <a href="<?php echo $checkall_url; ?>&amp;checkall=1"
441 onclick="if (markAllRows('fieldsForm')) return false;">
442 <?php echo $strCheckAll; ?></a>
444 <a href="<?php echo $checkall_url; ?>"
445 onclick="if (unMarkAllRows('fieldsForm')) return false;">
446 <?php echo $strUncheckAll; ?></a>
448 <i><?php echo $strWithChecked; ?></i>
450 <?php
451 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_browse', $strBrowse, 'b_browse.png');
453 if (! $tbl_is_view && ! $db_is_information_schema) {
454 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_change', $strChange, 'b_edit.png');
455 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_drop', $strDrop, 'b_drop.png');
456 if ('ARCHIVE' != $tbl_type) {
457 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_primary', $strPrimary, 'b_primary.png');
458 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_unique', $strUnique, 'b_unique.png');
459 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_index', $strIndex, 'b_index.png');
461 if (! empty($tbl_type) && ($tbl_type == 'MYISAM' || $tbl_type == 'MARIA')) {
462 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_fulltext', $strIdxFulltext, 'b_ftext.png');
466 </form>
467 <hr />
469 <?php
471 * Work on the table
474 <a href="tbl_printview.php?<?php echo $url_query; ?>"><?php
475 if ($cfg['PropertiesIconic']) {
476 echo '<img class="icon" src="' . $pmaThemeImage . 'b_print.png" width="16" height="16" alt="' . $strPrintView . '"/>';
478 echo $strPrintView;
479 ?></a>
481 <?php
482 if (! $tbl_is_view && ! $db_is_information_schema) {
484 // if internal relations are available, or foreign keys are supported
485 // ($tbl_type comes from libraries/tbl_info.inc.php)
486 if ($cfgRelation['relwork'] || PMA_foreignkey_supported($tbl_type)) {
488 <a href="tbl_relation.php?<?php echo $url_query; ?>"><?php
489 if ($cfg['PropertiesIconic']) {
490 echo '<img class="icon" src="' . $pmaThemeImage . 'b_relations.png" width="16" height="16" alt="' . $strRelationView . '"/>';
492 echo $strRelationView;
493 ?></a>
494 <?php
497 <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
498 if ($cfg['PropertiesIconic']) {
499 echo '<img class="icon" src="' . $pmaThemeImage . 'b_tblanalyse.png" width="16" height="16" alt="' . $strStructPropose . '" />';
501 echo $strStructPropose;
502 ?></a><?php
503 echo PMA_showMySQLDocu('Extending_MySQL', 'procedure_analyse') . "\n";
504 ?><br />
505 <form method="post" action="tbl_addfield.php"
506 onsubmit="return checkFormElementInRange(this, 'num_fields', '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidFieldAddCount']); ?>', 1)">
507 <?php
508 echo PMA_generate_common_hidden_inputs($db, $table);
509 if ($cfg['PropertiesIconic']) {
510 echo '<img class="icon" src="' . $pmaThemeImage . 'b_insrow.png" width="16" height="16" alt="' . $strAddNewField . '"/>';
512 echo sprintf($strAddFields, '<input type="text" name="num_fields" size="2" maxlength="2" value="1" style="vertical-align: middle" onfocus="this.select()" />');
514 // here we want to display a field selector inside the label for
515 // the After choice, and $strAfter contains a parameter to display
516 // this selector at the best place for each language; thus we
517 // set the fifth parameter of PMA_generate_html_radio() to false
518 // in order to avoid the usual escaping with htmlspecialchars() inside
519 // the label
520 $fieldOptions = '<select name="after_field" style="vertical-align: middle" onclick="this.form.field_where[2].checked=true" onchange="this.form.field_where[2].checked=true">';
521 foreach ($aryFields as $fieldname) {
522 $fieldOptions .= '<option value="' . htmlspecialchars($fieldname) . '">' . htmlspecialchars($fieldname) . '</option>' . "\n";
524 unset($aryFields);
525 $fieldOptions .= '</select>';
527 $choices = array(
528 'last' => $strAtEndOfTable,
529 'first' => $strAtBeginningOfTable,
530 'after' => sprintf($strAfter, $fieldOptions)
532 PMA_generate_html_radio('field_where', $choices, 'last', false, false);
533 unset($fieldOptions, $choices);
535 <input type="submit" value="<?php echo $strGo; ?>" style="vertical-align: middle" />
536 </form>
537 <hr />
538 <?php
542 * If there are more than 20 rows, displays browse/select/insert/empty/drop
543 * links again
545 if ($fields_cnt > 20) {
546 require './libraries/tbl_links.inc.php';
547 } // end if ($fields_cnt > 20)
550 * Displays indexes
552 PMA_generate_slider_effect('tablestatistics_indexes', $strDetails);
554 if (! $tbl_is_view && ! $db_is_information_schema && 'ARCHIVE' != $tbl_type) {
556 * Display indexes
558 echo PMA_Index::getView($table, $db);
560 <br />
561 <form action="./tbl_indexes.php" method="post"
562 onsubmit="return checkFormElementInRange(this, 'idx_num_fields',
563 '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidColumnCount']); ?>',
564 1)">
565 <fieldset>
566 <?php
567 echo PMA_generate_common_hidden_inputs($db, $table);
568 echo sprintf($strCreateIndex,
569 '<input type="text" size="2" name="added_fields" value="1" />');
571 <input type="submit" name="create_index" value="<?php echo $strGo; ?>"
572 onclick="return checkFormElementInRange(this.form,
573 'idx_num_fields',
574 '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidColumnCount']); ?>',
575 1)" />
576 </fieldset>
577 </form>
578 <br />
579 <?php
581 echo '<div id="tablestatistics">' . "\n";
584 * Displays Space usage and row statistics
586 // BEGIN - Calc Table Space - staybyte - 9 June 2001
587 // loic1, 22 feb. 2002: updated with patch from
588 // Joshua Nye <josh at boxcarmedia.com> to get valid
589 // statistics whatever is the table type
590 if ($cfg['ShowStats']) {
591 $nonisam = false;
592 $is_innodb = (isset($showtable['Type']) && $showtable['Type'] == 'InnoDB');
593 if (isset($showtable['Type']) && !preg_match('@ISAM|HEAP@i', $showtable['Type'])) {
594 $nonisam = true;
597 // Gets some sizes
598 $mergetable = false;
599 if (isset($showtable['Type']) && $showtable['Type'] == 'MRG_MyISAM') {
600 $mergetable = true;
602 // this is to display for example 261.2 MiB instead of 268k KiB
603 $max_digits = 5;
604 $decimals = 1;
605 list($data_size, $data_unit) = PMA_formatByteDown($showtable['Data_length'], $max_digits, $decimals);
606 if ($mergetable == false) {
607 list($index_size, $index_unit) = PMA_formatByteDown($showtable['Index_length'], $max_digits, $decimals);
609 if (isset($showtable['Data_free']) && $showtable['Data_free'] > 0) {
610 list($free_size, $free_unit) = PMA_formatByteDown($showtable['Data_free'], $max_digits, $decimals);
611 list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length'] - $showtable['Data_free'], $max_digits, $decimals);
612 } else {
613 list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length'], $max_digits, $decimals);
615 list($tot_size, $tot_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length'], $max_digits, $decimals);
616 if ($table_info_num_rows > 0) {
617 list($avg_size, $avg_unit) = PMA_formatByteDown(($showtable['Data_length'] + $showtable['Index_length']) / $showtable['Rows'], 6, 1);
620 // Displays them
621 $odd_row = false;
624 <a name="showusage"></a>
625 <?php if (! $tbl_is_view && ! $db_is_information_schema) { ?>
626 <table id="tablespaceusage" class="data">
627 <caption class="tblHeaders"><?php echo $strSpaceUsage; ?></caption>
628 <thead>
629 <tr>
630 <th><?php echo $strType; ?></th>
631 <th colspan="2"><?php echo $strUsage; ?></th>
632 </tr>
633 </thead>
634 <tbody>
635 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
636 <th class="name"><?php echo $strData; ?></th>
637 <td class="value"><?php echo $data_size; ?></td>
638 <td class="unit"><?php echo $data_unit; ?></td>
639 </tr>
640 <?php
641 if (isset($index_size)) {
643 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
644 <th class="name"><?php echo $strIndex; ?></th>
645 <td class="value"><?php echo $index_size; ?></td>
646 <td class="unit"><?php echo $index_unit; ?></td>
647 </tr>
648 <?php
650 if (isset($free_size)) {
652 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?> warning">
653 <th class="name"><?php echo $strOverhead; ?></th>
654 <td class="value"><?php echo $free_size; ?></td>
655 <td class="unit"><?php echo $free_unit; ?></td>
656 </tr>
657 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
658 <th class="name"><?php echo $strEffective; ?></th>
659 <td class="value"><?php echo $effect_size; ?></td>
660 <td class="unit"><?php echo $effect_unit; ?></td>
661 </tr>
662 <?php
664 if (isset($tot_size) && $mergetable == false) {
666 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
667 <th class="name"><?php echo $strTotalUC; ?></th>
668 <td class="value"><?php echo $tot_size; ?></td>
669 <td class="unit"><?php echo $tot_unit; ?></td>
670 </tr>
671 <?php
673 // Optimize link if overhead
674 if (isset($free_size) && ($tbl_type == 'MYISAM' || $tbl_type == 'MARIA' || $tbl_type == 'BDB')) {
676 <tr class="tblFooters">
677 <td colspan="3" align="center">
678 <a href="sql.php?<?php echo $url_query; ?>&pos=0&amp;sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . PMA_backquote($table)); ?>"><?php
679 if ($cfg['PropertiesIconic']) {
680 echo '<img class="icon" src="' . $pmaThemeImage . 'b_tbloptimize.png" width="16" height="16" alt="' . $strOptimizeTable. '" />';
682 echo $strOptimizeTable;
683 ?></a>
684 </td>
685 </tr>
686 <?php
689 </tbody>
690 </table>
691 <?php
693 $odd_row = false;
695 <table id="tablerowstats" class="data">
696 <caption class="tblHeaders"><?php echo $strRowsStatistic; ?></caption>
697 <thead>
698 <tr>
699 <th><?php echo $strStatement; ?></th>
700 <th><?php echo $strValue; ?></th>
701 </tr>
702 </thead>
703 <tbody>
704 <?php
705 if (isset($showtable['Row_format'])) {
707 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
708 <th class="name"><?php echo $strFormat; ?></th>
709 <td class="value"><?php
710 if ($showtable['Row_format'] == 'Fixed') {
711 echo $strFixed;
712 } elseif ($showtable['Row_format'] == 'Dynamic') {
713 echo $strDynamic;
714 } else {
715 echo $showtable['Row_format'];
717 ?></td>
718 </tr>
719 <?php
721 if (! empty($showtable['Create_options'])) {
723 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
724 <th class="name"><?php echo $strOptions; ?></th>
725 <td class="value"><?php
726 if ($showtable['Create_options'] == 'partitioned') {
727 echo $strPartitioned;
728 } else {
729 echo $showtable['Create_options'];
731 ?></td>
732 </tr>
733 <?php
735 if (!empty($tbl_collation)) {
737 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
738 <th class="name"><?php echo $strCollation; ?></th>
739 <td class="value"><?php
740 echo '<dfn title="' . PMA_getCollationDescr($tbl_collation) . '">' . $tbl_collation . '</dfn>';
741 ?></td>
742 </tr>
743 <?php
745 if (!$is_innodb && isset($showtable['Rows'])) {
747 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
748 <th class="name"><?php echo $strRows; ?></th>
749 <td class="value"><?php echo PMA_formatNumber($showtable['Rows'], 0); ?></td>
750 </tr>
751 <?php
753 if (!$is_innodb && isset($showtable['Avg_row_length']) && $showtable['Avg_row_length'] > 0) {
755 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
756 <th class="name"><?php echo $strRowLength; ?> &oslash;</th>
757 <td class="value"><?php echo PMA_formatNumber($showtable['Avg_row_length'], 0); ?></td>
758 </tr>
759 <?php
761 if (!$is_innodb && isset($showtable['Data_length']) && $showtable['Rows'] > 0 && $mergetable == false) {
763 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
764 <th class="name"><?php echo $strRowSize; ?> &oslash;</th>
765 <td class="value"><?php echo $avg_size . ' ' . $avg_unit; ?></td>
766 </tr>
767 <?php
769 if (isset($showtable['Auto_increment'])) {
771 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
772 <th class="name"><?php echo $strNext; ?> Autoindex</th>
773 <td class="value"><?php echo PMA_formatNumber($showtable['Auto_increment'], 0); ?></td>
774 </tr>
775 <?php
777 if (isset($showtable['Create_time'])) {
779 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
780 <th class="name"><?php echo $strStatCreateTime; ?></th>
781 <td class="value"><?php echo PMA_localisedDate(strtotime($showtable['Create_time'])); ?></td>
782 </tr>
783 <?php
785 if (isset($showtable['Update_time'])) {
787 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
788 <th class="name"><?php echo $strStatUpdateTime; ?></th>
789 <td class="value"><?php echo PMA_localisedDate(strtotime($showtable['Update_time'])); ?></td>
790 </tr>
791 <?php
793 if (isset($showtable['Check_time'])) {
795 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
796 <th class="name"><?php echo $strStatCheckTime; ?></th>
797 <td class="value"><?php echo PMA_localisedDate(strtotime($showtable['Check_time'])); ?></td>
798 </tr>
799 <?php
802 </tbody>
803 </table>
804 <?php
806 // END - Calc Table Space
808 require './libraries/tbl_triggers.lib.php';
810 echo '<div class="clearfloat"></div>' . "\n";
811 echo '</div>' . "\n";
812 echo '</div>' . "\n";
815 * Displays the footer
817 require_once './libraries/footer.inc.php';