Replace broken ANSI string concatenation with concat() function
[phpmyadmin/crack.git] / tbl_structure.php
blob97194310b26cef088c4c300a7db212e5ecb391cb
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 * @package phpMyAdmin
7 */
9 /**
12 require_once './libraries/common.inc.php';
13 require_once './libraries/mysql_charsets.lib.php';
15 $GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js';
16 $GLOBALS['js_include'][] = 'tbl_structure.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 = 'change';
25 } elseif (isset($_REQUEST['submit_mult_drop_x'])) {
26 $submit_mult = 'drop';
27 } elseif (isset($_REQUEST['submit_mult_primary_x'])) {
28 $submit_mult = 'primary';
29 } elseif (isset($_REQUEST['submit_mult_index_x'])) {
30 $submit_mult = 'index';
31 } elseif (isset($_REQUEST['submit_mult_unique_x'])) {
32 $submit_mult = 'unique';
33 } elseif (isset($_REQUEST['submit_mult_fulltext_x'])) {
34 $submit_mult = 'ftext';
35 } elseif (isset($_REQUEST['submit_mult_browse_x'])) {
36 $submit_mult = 'browse';
37 } elseif (isset($_REQUEST['submit_mult'])) {
38 $submit_mult = $_REQUEST['submit_mult'];
39 } elseif (isset($_REQUEST['mult_btn']) && $_REQUEST['mult_btn'] == __('Yes')) {
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 == 'browse') {
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);
112 $columns_with_unique_index = array();
113 foreach (PMA_Index::getFromTable($table, $db) as $index) {
114 if ($index->isUnique() && $index->getChoice() == 'UNIQUE') {
115 $columns = $index->getColumns();
116 foreach ($columns as $column_name => $dummy) {
117 $columns_with_unique_index[$column_name] = 1;
121 unset($index, $columns, $column_name, $dummy);
123 // 3. Get fields
124 $fields = (array) PMA_DBI_get_columns($db, $table, true);
126 // Get more complete field information
127 // For now, this is done just for MySQL 4.1.2+ new TIMESTAMP options
128 // but later, if the analyser returns more information, it
129 // could be executed for any MySQL version and replace
130 // the info given by SHOW FULL FIELDS FROM.
132 // We also need this to correctly learn if a TIMESTAMP is NOT NULL, since
133 // SHOW FULL FIELDS or INFORMATION_SCHEMA incorrectly says NULL
134 // and SHOW CREATE TABLE says NOT NULL (tested
135 // in MySQL 4.0.25 and 5.0.21, http://bugs.mysql.com/20910).
137 $show_create_table = PMA_DBI_fetch_value(
138 'SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table),
139 0, 1);
140 $analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table));
143 * prepare table infos
145 // action titles (image or string)
146 $titles = array();
147 $titles['Change'] = PMA_getIcon('b_edit.png', __('Change'), true);
148 $titles['Drop'] = PMA_getIcon('b_drop.png', __('Drop'), true);
149 $titles['NoDrop'] = PMA_getIcon('b_drop.png', __('Drop'), true);
150 $titles['Primary'] = PMA_getIcon('b_primary.png', __('Primary'), true);
151 $titles['Index'] = PMA_getIcon('b_index.png', __('Index'), true);
152 $titles['Unique'] = PMA_getIcon('b_unique.png', __('Unique'), true);
153 $titles['IdxFulltext'] = PMA_getIcon('b_ftext.png', __('Fulltext'), true);
154 $titles['NoPrimary'] = PMA_getIcon('bd_primary.png', __('Primary'), true);
155 $titles['NoIndex'] = PMA_getIcon('bd_index.png', __('Index'), true);
156 $titles['NoUnique'] = PMA_getIcon('bd_unique.png', __('Unique'), true);
157 $titles['NoIdxFulltext'] = PMA_getIcon('bd_ftext.png', __('Fulltext'), true);
158 $titles['BrowseDistinctValues'] = PMA_getIcon('b_browse.png', __('Browse distinct values'), true);
160 // hidden action titles (image and string)
161 $hidden_titles = array();
162 $hidden_titles['BrowseDistinctValues'] = PMA_getIcon('b_browse.png', __('Browse distinct values'), false, true);
163 $hidden_titles['Primary'] = PMA_getIcon('b_primary.png', __('Add primary key'), false, true);
164 $hidden_titles['NoPrimary'] = PMA_getIcon('bd_primary.png', __('Add primary key'), false, true);
165 $hidden_titles['Index'] = PMA_getIcon('b_index.png', __('Add index'), false, true);
166 $hidden_titles['NoIndex'] = PMA_getIcon('bd_index.png', __('Add index'), false, true);
167 $hidden_titles['Unique'] = PMA_getIcon('b_unique.png', __('Add unique index'), false, true);
168 $hidden_titles['NoUnique'] = PMA_getIcon('bd_unique.png', __('Add unique index'), false, true);
169 $hidden_titles['IdxFulltext'] = PMA_getIcon('b_ftext.png', __('Add FULLTEXT index'), false, true);
170 $hidden_titles['NoIdxFulltext'] = PMA_getIcon('bd_ftext.png', __('Add FULLTEXT index'), false, true);
173 * Displays the table structure ('show table' works correct since 3.23.03)
175 /* TABLE INFORMATION */
176 // table header
177 $i = 0;
179 <form method="post" action="tbl_structure.php" name="fieldsForm" id="fieldsForm">
180 <?php echo PMA_generate_common_hidden_inputs($db, $table);
181 echo '<input type="hidden" name="table_type" value=';
182 if($db_is_information_schema) {
183 echo '"information_schema" />';
184 } else if ($tbl_is_view) {
185 echo '"view" />';
186 } else {
187 echo '"table" />';
188 } ?>
190 <table id="tablestructure" class="data">
191 <thead>
192 <tr>
193 <th id="th<?php echo ++$i; ?>"></th>
194 <th id="th<?php echo ++$i; ?>">#</th>
195 <th id="th<?php echo ++$i; ?>" class="column"><?php echo __('Column'); ?></th>
196 <th id="th<?php echo ++$i; ?>" class="type"><?php echo __('Type'); ?></th>
197 <th id="th<?php echo ++$i; ?>" class="collation"><?php echo __('Collation'); ?></th>
198 <th id="th<?php echo ++$i; ?>" class="attributes"><?php echo __('Attributes'); ?></th>
199 <th id="th<?php echo ++$i; ?>" class="null"><?php echo __('Null'); ?></th>
200 <th id="th<?php echo ++$i; ?>" class="default"><?php echo __('Default'); ?></th>
201 <th id="th<?php echo ++$i; ?>" class="extra"><?php echo __('Extra'); ?></th>
202 <?php if ($db_is_information_schema || $tbl_is_view) { ?>
203 <th id="th<?php echo ++$i; ?>" class="view"><?php echo __('View'); ?></th>
204 <?php } else { ?>
205 <th colspan="7" id="th<?php echo ++$i; ?>" class="action"><?php echo __('Action'); ?></th>
206 <?php } ?>
207 </tr>
208 </thead>
209 <tbody>
211 <?php
212 unset($i);
214 // table body
216 // prepare comments
217 $comments_map = array();
218 $mime_map = array();
220 if ($GLOBALS['cfg']['ShowPropertyComments']) {
221 require_once './libraries/transformations.lib.php';
223 //$cfgRelation = PMA_getRelationsParam();
225 $comments_map = PMA_getComments($db, $table);
227 if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) {
228 $mime_map = PMA_getMIME($db, $table, true);
232 $rownum = 0;
233 $aryFields = array();
234 $checked = (!empty($checkall) ? ' checked="checked"' : '');
235 $save_row = array();
236 $odd_row = true;
237 foreach ($fields as $row) {
238 $save_row[] = $row;
239 $rownum++;
240 $aryFields[] = $row['Field'];
242 $type = $row['Type'];
243 $extracted_fieldspec = PMA_extractFieldSpec($row['Type']);
245 if ('set' == $extracted_fieldspec['type'] || 'enum' == $extracted_fieldspec['type']) {
246 $type = $extracted_fieldspec['type'] . '(' .
247 str_replace("','", "', '", $extracted_fieldspec['spec_in_brackets']) . ')';
249 // for the case ENUM('&#8211;','&ldquo;')
250 $type = htmlspecialchars($type);
251 if(strlen($type) > $GLOBALS['cfg']['LimitChars']) {
252 $type = '<abbr title="full text">' . substr($type, 0, $GLOBALS['cfg']['LimitChars']) . '</abbr>';
255 $type_nowrap = '';
257 $binary = 0;
258 $unsigned = 0;
259 $zerofill = 0;
260 } else {
261 $type_nowrap = ' nowrap="nowrap"';
262 // strip the "BINARY" attribute, except if we find "BINARY(" because
263 // this would be a BINARY or VARBINARY field type
264 if (!preg_match('@BINARY[\(]@i', $type)) {
265 $type = preg_replace('@BINARY@i', '', $type);
267 $type = preg_replace('@ZEROFILL@i', '', $type);
268 $type = preg_replace('@UNSIGNED@i', '', $type);
269 if (empty($type)) {
270 $type = ' ';
273 if (!preg_match('@BINARY[\(]@i', $row['Type'])) {
274 $binary = stristr($row['Type'], 'blob') || stristr($row['Type'], 'binary');
275 } else {
276 $binary = false;
279 $unsigned = stristr($row['Type'], 'unsigned');
280 $zerofill = stristr($row['Type'], 'zerofill');
283 unset($field_charset);
284 if ((substr($type, 0, 4) == 'char'
285 || substr($type, 0, 7) == 'varchar'
286 || substr($type, 0, 4) == 'text'
287 || substr($type, 0, 8) == 'tinytext'
288 || substr($type, 0, 10) == 'mediumtext'
289 || substr($type, 0, 8) == 'longtext'
290 || substr($type, 0, 3) == 'set'
291 || substr($type, 0, 4) == 'enum'
292 ) && !$binary) {
293 if (strpos($type, ' character set ')) {
294 $type = substr($type, 0, strpos($type, ' character set '));
296 if (!empty($row['Collation'])) {
297 $field_charset = $row['Collation'];
298 } else {
299 $field_charset = '';
301 } else {
302 $field_charset = '';
305 // Display basic mimetype [MIME]
306 if ($cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME'] && isset($mime_map[$row['Field']]['mimetype'])) {
307 $type_mime = '<br />MIME: ' . str_replace('_', '/', $mime_map[$row['Field']]['mimetype']);
308 } else {
309 $type_mime = '';
312 $attribute = ' ';
313 if ($binary) {
314 $attribute = 'BINARY';
316 if ($unsigned) {
317 $attribute = 'UNSIGNED';
319 if ($zerofill) {
320 $attribute = 'UNSIGNED ZEROFILL';
323 // MySQL 4.1.2+ TIMESTAMP options
324 // (if on_update_current_timestamp is set, then it's TRUE)
325 if (isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) {
326 $attribute = 'on update CURRENT_TIMESTAMP';
329 // here, we have a TIMESTAMP that SHOW FULL FIELDS reports as having the
330 // NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
331 // the latter.
332 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']) {
333 $row['Null'] = '';
337 if (! isset($row['Default'])) {
338 if ($row['Null'] == 'YES') {
339 $row['Default'] = '<i>NULL</i>';
341 } else {
342 $row['Default'] = htmlspecialchars($row['Default']);
345 $field_encoded = urlencode($row['Field']);
346 $field_name = htmlspecialchars($row['Field']);
347 $displayed_field_name = $field_name;
349 // underline commented fields and display a hover-title (CSS only)
351 if (isset($comments_map[$row['Field']])) {
352 $displayed_field_name = '<span class="commented_column" title="' . htmlspecialchars($comments_map[$row['Field']]) . '">' . $field_name . '</span>';
355 if ($primary && $primary->hasColumn($field_name)) {
356 $displayed_field_name = '<u>' . $field_name . '</u>';
358 echo "\n";
360 <tr class="<?php echo $odd_row ? 'odd': 'even'; $odd_row = !$odd_row; ?>">
361 <td align="center">
362 <input type="checkbox" name="selected_fld[]" value="<?php echo htmlspecialchars($row['Field']); ?>" id="checkbox_row_<?php echo $rownum; ?>" <?php echo $checked; ?> />
363 </td>
364 <td align="right">
365 <?php echo $rownum; ?>
366 </td>
367 <th nowrap="nowrap"><label for="checkbox_row_<?php echo $rownum; ?>"><?php echo $displayed_field_name; ?></label></th>
368 <td<?php echo $type_nowrap; ?>><bdo dir="ltr" xml:lang="en"><?php echo $type; echo $type_mime; ?></bdo></td>
369 <td><?php echo (empty($field_charset) ? '' : '<dfn title="' . PMA_getCollationDescr($field_charset) . '">' . $field_charset . '</dfn>'); ?></td>
370 <td nowrap="nowrap" class="column_attribute"><?php echo $attribute; ?></td>
371 <td><?php echo (($row['Null'] == 'YES') ? __('Yes') : __('No')); ?></td>
372 <td nowrap="nowrap"><?php
373 if (isset($row['Default'])) {
374 if ($extracted_fieldspec['type'] == 'bit') {
375 // here, $row['Default'] contains something like b'010'
376 echo PMA_convert_bit_default_value($row['Default']);
377 } else {
378 echo $row['Default'];
381 else {
382 echo '<i>' . _pgettext('None for default','None') . '</i>';
383 } ?></td>
384 <td nowrap="nowrap"><?php echo strtoupper($row['Extra']); ?></td>
385 <td align="center" class="browse">
386 <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('SELECT COUNT(*) AS ' . PMA_backquote(__('Rows')) . ', ' . PMA_backquote($row['Field']) . ' FROM ' . PMA_backquote($table) . ' GROUP BY ' . PMA_backquote($row['Field']) . ' ORDER BY ' . PMA_backquote($row['Field'])); ?>">
387 <?php echo $titles['BrowseDistinctValues']; ?></a>
388 </td>
389 <?php if (! $tbl_is_view && ! $db_is_information_schema) { ?>
390 <td align="center" class="edit">
391 <a href="tbl_alter.php?<?php echo $url_query; ?>&amp;field=<?php echo $field_encoded; ?>">
392 <?php echo $titles['Change']; ?></a>
393 </td>
394 <td align="center" class="drop">
395 <a <?php echo ($GLOBALS['cfg']['AjaxEnable'] ? ' class="drop_column_anchor"' : ''); ?> href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' DROP ' . PMA_backquote($row['Field'])); ?>&amp;dropped_column=<?php echo urlencode($row['Field']); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('Column %s has been dropped'), htmlspecialchars($row['Field']))); ?>" >
396 <?php echo $titles['Drop']; ?></a>
397 </td>
398 <td align="center" class="primary">
399 <?php
400 if ($type == 'text' || $type == 'blob' || 'ARCHIVE' == $tbl_type || ($primary && $primary->hasColumn($field_name))) {
401 echo $titles['NoPrimary'] . "\n";
402 $primary_enabled = false;
403 } else {
404 echo "\n";
406 <a class="add_primary_key_anchor" 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;message_to_show=<?php echo urlencode(sprintf(__('A primary key has been added on %s'), htmlspecialchars($row['Field']))); ?>" >
407 <?php echo $titles['Primary']; ?></a>
408 <?php $primary_enabled = true;
410 echo "\n";
412 </td>
413 <td align="center" class="unique">
414 <?php
415 if ($type == 'text' || $type == 'blob' || 'ARCHIVE' == $tbl_type || isset($columns_with_unique_index[$field_name])) {
416 echo $titles['NoUnique'] . "\n";
417 $unique_enabled = false;
418 } else {
419 echo "\n";
421 <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;message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
422 <?php echo $titles['Unique']; ?></a>
423 <?php $unique_enabled = true;
425 echo "\n";
427 </td>
428 <td align="center" class="index">
429 <?php
430 if ($type == 'text' || $type == 'blob' || 'ARCHIVE' == $tbl_type) {
431 echo $titles['NoIndex'] . "\n";
432 $index_enabled = false;
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;message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
437 <?php echo $titles['Index']; ?></a>
438 <?php
439 $index_enabled = true;
441 echo "\n";
443 </td>
444 <?php
445 if (! empty($tbl_type) && ($tbl_type == 'MYISAM' || $tbl_type == 'ARIA' || $tbl_type == 'MARIA')
446 // FULLTEXT is possible on TEXT, CHAR and VARCHAR
447 && (strpos(' ' . $type, 'text') || strpos(' ' . $type, 'char'))) {
448 echo "\n";
450 <td align="center" nowrap="nowrap" class="fulltext">
451 <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;message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
452 <?php echo $titles['IdxFulltext']; ?></a>
453 <?php $fulltext_enabled = true; ?>
454 </td>
455 <?php
456 } else {
457 echo "\n";
459 <td align="center" nowrap="nowrap" class="fulltext">
460 <?php echo $titles['NoIdxFulltext'] . "\n"; ?>
461 <?php $fulltext_enabled = false; ?>
462 </td>
463 <?php
464 } // end if... else...
465 echo "\n";
467 <td class="more_opts" id="more_opts<?php echo $rownum; ?>">
468 <?php echo __('More'); ?> <img src="<?php echo $pmaThemeImage . 'more.png'; ?>" alt="<?php echo __('Show more actions'); ?>" />
469 <div class="structure_actions_dropdown" id="row_<?php echo $rownum; ?>">
471 <div class="action_browse">
472 <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('SELECT COUNT(*) AS ' . PMA_backquote(__('Rows')) . ', ' . PMA_backquote($row['Field']) . ' FROM ' . PMA_backquote($table) . ' GROUP BY ' . PMA_backquote($row['Field']) . ' ORDER BY ' . PMA_backquote($row['Field'])); ?>">
473 <?php echo $hidden_titles['BrowseDistinctValues']; ?>
474 </a>
475 </div>
476 <div <?php echo ($GLOBALS['cfg']['AjaxEnable'] ? ' class="action_primary"' : ''); ?>>
477 <?php
478 if(isset($primary_enabled)) {
479 if($primary_enabled) { ?>
480 <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;message_to_show=<?php echo urlencode(sprintf(__('A primary key has been added on %s'), htmlspecialchars($row['Field']))); ?>">
481 <?php echo $hidden_titles['Primary']; ?>
482 </a>
483 <?php
484 } else {
485 echo $hidden_titles['NoPrimary'];
487 } ?>
488 </div>
489 <div class="action_unique">
490 <?php
491 if(isset($unique_enabled)) {
492 if($unique_enabled) { ?>
493 <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;message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
494 <?php echo $hidden_titles['Unique']; ?>
495 </a>
496 <?php
497 } else {
498 echo $hidden_titles['NoUnique'];
500 } ?>
501 </div>
502 <div class="action_index">
503 <?php
504 if(isset($index_enabled)) {
505 if($index_enabled) { ?>
506 <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;message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
507 <?php echo $hidden_titles['Index']; ?>
508 </a>
509 <?php
510 } else {
511 echo $hidden_titles['NoIndex'];
513 } ?>
514 </div>
515 <?php if (!PMA_DRIZZLE) { ?>
516 <div class="action_fulltext">
517 <?php
518 if(isset($fulltext_enabled)) {
519 if($fulltext_enabled) { ?>
520 <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;message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
521 <?php echo $hidden_titles['IdxFulltext']; ?>
522 </a>
523 <?php
524 } else {
525 echo $hidden_titles['NoIdxFulltext'];
527 } ?>
528 </div>
529 <?php } ?>
530 </div>
531 </td>
532 <?php
533 } // end if (! $tbl_is_view && ! $db_is_information_schema)
535 </tr>
536 <?php
537 unset($field_charset);
538 } // end while
540 echo '</tbody>' . "\n"
541 .'</table>' . "\n";
543 $checkall_url = 'tbl_structure.php?' . PMA_generate_common_url($db, $table);
546 <img class="selectallarrow" src="<?php echo $pmaThemeImage . 'arrow_' . $text_dir . '.png'; ?>"
547 width="38" height="22" alt="<?php echo __('With selected:'); ?>" />
548 <a href="<?php echo $checkall_url; ?>&amp;checkall=1"
549 onclick="if (markAllRows('fieldsForm')) return false;">
550 <?php echo __('Check All'); ?></a>
552 <a href="<?php echo $checkall_url; ?>"
553 onclick="if (unMarkAllRows('fieldsForm')) return false;">
554 <?php echo __('Uncheck All'); ?></a>
556 <i><?php echo __('With selected:'); ?></i>
558 <?php
559 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_browse', __('Browse'), 'b_browse.png', 'browse');
561 if (! $tbl_is_view && ! $db_is_information_schema) {
562 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_change', __('Change'), 'b_edit.png', 'change');
563 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_drop', __('Drop'), 'b_drop.png', 'drop');
564 if ('ARCHIVE' != $tbl_type) {
565 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_primary', __('Primary'), 'b_primary.png', 'primary');
566 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_unique', __('Unique'), 'b_unique.png', 'unique');
567 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_index', __('Index'), 'b_index.png', 'index');
570 if (! empty($tbl_type) && ($tbl_type == 'MYISAM' || $tbl_type == 'ARIA' || $tbl_type == 'MARIA')) {
571 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_fulltext', __('Fulltext'), 'b_ftext.png', 'ftext');
575 </form>
576 <hr />
578 <?php
580 * Work on the table
583 <a href="tbl_printview.php?<?php echo $url_query; ?>"><?php
584 if ($cfg['PropertiesIconic']) {
585 echo '<img class="icon" src="' . $pmaThemeImage . 'b_print.png" width="16" height="16" alt="' . __('Print view') . '"/>';
587 echo __('Print view');
588 ?></a>
590 <?php
591 if (! $tbl_is_view && ! $db_is_information_schema) {
593 // if internal relations are available, or foreign keys are supported
594 // ($tbl_type comes from libraries/tbl_info.inc.php)
595 if ($cfgRelation['relwork'] || PMA_foreignkey_supported($tbl_type)) {
597 <a href="tbl_relation.php?<?php echo $url_query; ?>"><?php
598 if ($cfg['PropertiesIconic']) {
599 echo '<img class="icon" src="' . $pmaThemeImage . 'b_relations.png" width="16" height="16" alt="' . __('Relation view') . '"/>';
601 echo __('Relation view');
602 ?></a>
603 <?php
606 <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
607 if ($cfg['PropertiesIconic']) {
608 echo '<img class="icon" src="' . $pmaThemeImage . 'b_tblanalyse.png" width="16" height="16" alt="' . __('Propose table structure') . '" />';
610 echo __('Propose table structure');
611 ?></a><?php
612 echo PMA_showMySQLDocu('Extending_MySQL', 'procedure_analyse') . "\n";
615 if(PMA_Tracker::isActive())
617 echo '<a href="tbl_tracking.php?' . $url_query . '">';
619 if ($cfg['PropertiesIconic'])
621 echo '<img class="icon" src="' . $pmaThemeImage . 'eye.png" width="16" height="16" alt="' . __('Track table') . '" /> ';
623 echo __('Track table') . '</a>';
627 <br />
628 <form method="post" action="tbl_addfield.php"
629 onsubmit="return checkFormElementInRange(this, 'num_fields', '<?php echo str_replace('\'', '\\\'', __('You have to add at least one column.')); ?>', 1)">
630 <?php
631 echo PMA_generate_common_hidden_inputs($db, $table);
632 if ($cfg['PropertiesIconic']) {
633 echo '<img class="icon" src="' . $pmaThemeImage . 'b_insrow.png" width="16" height="16" alt="' . __('Add column') . '"/>';
635 echo sprintf(__('Add %s column(s)'), '<input type="text" name="num_fields" size="2" maxlength="2" value="1" onfocus="this.select()" />');
637 // I tried displaying the drop-down inside the label but with Firefox
638 // the drop-down was blinking
639 $fieldOptions = '<select name="after_field" onclick="this.form.field_where[2].checked=true" onchange="this.form.field_where[2].checked=true">';
640 foreach ($aryFields as $fieldname) {
641 $fieldOptions .= '<option value="' . htmlspecialchars($fieldname) . '">' . htmlspecialchars($fieldname) . '</option>' . "\n";
643 unset($aryFields);
644 $fieldOptions .= '</select>';
646 $choices = array(
647 'last' => __('At End of Table'),
648 'first' => __('At Beginning of Table'),
649 'after' => sprintf(__('After %s'), '')
651 PMA_display_html_radio('field_where', $choices, 'last', false);
652 echo $fieldOptions;
653 unset($fieldOptions, $choices);
655 <input type="submit" value="<?php echo __('Go'); ?>" />
656 </form>
657 <iframe class="IE_hack" scrolling="no"></iframe>
658 <hr />
659 <?php
663 * If there are more than 20 rows, displays browse/select/insert/empty/drop
664 * links again
666 if (count($fields) > 20) {
667 require './libraries/tbl_links.inc.php';
668 } // end if (count($fields) > 20)
671 * Displays indexes
674 if (! $tbl_is_view && ! $db_is_information_schema && 'ARCHIVE' != $tbl_type) {
676 * Display indexes
678 echo PMA_Index::getView($table, $db);
680 <br />
681 <form action="./tbl_indexes.php" method="post"
682 onsubmit="return checkFormElementInRange(this, 'idx_num_fields',
683 '<?php echo str_replace('\'', '\\\'', __('Column count has to be larger than zero.')); ?>',
684 1)">
685 <fieldset>
686 <?php
687 echo PMA_generate_common_hidden_inputs($db, $table);
688 echo sprintf(__('Create an index on &nbsp;%s&nbsp;columns'),
689 '<input type="text" size="2" name="added_fields" value="1" />');
691 <input type="submit" name="create_index" value="<?php echo __('Go'); ?>"
692 onclick="return checkFormElementInRange(this.form,
693 'idx_num_fields',
694 '<?php echo str_replace('\'', '\\\'', __('Column count has to be larger than zero.')); ?>',
695 1)" />
696 </fieldset>
697 </form>
698 <br />
699 <?php
702 PMA_generate_slider_effect('tablestatistics', __('Details...'));
705 * Displays Space usage and row statistics
707 // BEGIN - Calc Table Space
708 // Get valid statistics whatever is the table type
709 if ($cfg['ShowStats']) {
710 if (empty($showtable)) {
711 $showtable = PMA_Table::sGetStatusInfo($GLOBALS['db'], $GLOBALS['table'], null, true);
714 $nonisam = false;
715 $is_innodb = (isset($showtable['Type']) && $showtable['Type'] == 'InnoDB');
716 if (isset($showtable['Type']) && !preg_match('@ISAM|HEAP@i', $showtable['Type'])) {
717 $nonisam = true;
720 // Gets some sizes
722 $mergetable = PMA_Table::isMerge($GLOBALS['db'], $GLOBALS['table']);
724 // this is to display for example 261.2 MiB instead of 268k KiB
725 $max_digits = 5;
726 $decimals = 1;
727 list($data_size, $data_unit) = PMA_formatByteDown($showtable['Data_length'], $max_digits, $decimals);
728 if ($mergetable == false) {
729 list($index_size, $index_unit) = PMA_formatByteDown($showtable['Index_length'], $max_digits, $decimals);
731 // InnoDB returns a huge value in Data_free, do not use it
732 if (! $is_innodb && isset($showtable['Data_free']) && $showtable['Data_free'] > 0) {
733 list($free_size, $free_unit) = PMA_formatByteDown($showtable['Data_free'], $max_digits, $decimals);
734 list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length'] - $showtable['Data_free'], $max_digits, $decimals);
735 } else {
736 list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length'], $max_digits, $decimals);
738 list($tot_size, $tot_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length'], $max_digits, $decimals);
739 if ($table_info_num_rows > 0) {
740 list($avg_size, $avg_unit) = PMA_formatByteDown(($showtable['Data_length'] + $showtable['Index_length']) / $showtable['Rows'], 6, 1);
743 // Displays them
744 $odd_row = false;
747 <a name="showusage"></a>
748 <?php if (! $tbl_is_view && ! $db_is_information_schema) { ?>
749 <table id="tablespaceusage" class="data">
750 <caption class="tblHeaders"><?php echo __('Space usage'); ?></caption>
751 <thead>
752 <tr>
753 <th><?php echo __('Type'); ?></th>
754 <th colspan="2"><?php echo __('Usage'); ?></th>
755 </tr>
756 </thead>
757 <tbody>
758 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
759 <th class="name"><?php echo __('Data'); ?></th>
760 <td class="value"><?php echo $data_size; ?></td>
761 <td class="unit"><?php echo $data_unit; ?></td>
762 </tr>
763 <?php
764 if (isset($index_size)) {
766 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
767 <th class="name"><?php echo __('Index'); ?></th>
768 <td class="value"><?php echo $index_size; ?></td>
769 <td class="unit"><?php echo $index_unit; ?></td>
770 </tr>
771 <?php
773 if (isset($free_size)) {
775 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?> error">
776 <th class="name"><?php echo __('Overhead'); ?></th>
777 <td class="value"><?php echo $free_size; ?></td>
778 <td class="unit"><?php echo $free_unit; ?></td>
779 </tr>
780 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
781 <th class="name"><?php echo __('Effective'); ?></th>
782 <td class="value"><?php echo $effect_size; ?></td>
783 <td class="unit"><?php echo $effect_unit; ?></td>
784 </tr>
785 <?php
787 if (isset($tot_size) && $mergetable == false) {
789 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
790 <th class="name"><?php echo __('Total'); ?></th>
791 <td class="value"><?php echo $tot_size; ?></td>
792 <td class="unit"><?php echo $tot_unit; ?></td>
793 </tr>
794 <?php
796 // Optimize link if overhead
797 if (isset($free_size) && ($tbl_type == 'MYISAM' || $tbl_type == 'ARIA' || $tbl_type == 'MARIA' || $tbl_type == 'BDB')) {
799 <tr class="tblFooters">
800 <td colspan="3" align="center">
801 <a href="sql.php?<?php echo $url_query; ?>&pos=0&amp;sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . PMA_backquote($table)); ?>"><?php
802 if ($cfg['PropertiesIconic']) {
803 echo '<img class="icon" src="' . $pmaThemeImage . 'b_tbloptimize.png" width="16" height="16" alt="' . __('Optimize table'). '" />';
805 echo __('Optimize table');
806 ?></a>
807 </td>
808 </tr>
809 <?php
812 </tbody>
813 </table>
814 <?php
816 $odd_row = false;
818 <table id="tablerowstats" class="data">
819 <caption class="tblHeaders"><?php echo __('Row Statistics'); ?></caption>
820 <thead>
821 <tr>
822 <th><?php echo __('Statements'); ?></th>
823 <th><?php echo __('Value'); ?></th>
824 </tr>
825 </thead>
826 <tbody>
827 <?php
828 if (isset($showtable['Row_format'])) {
830 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
831 <th class="name"><?php echo __('Format'); ?></th>
832 <td class="value"><?php
833 if ($showtable['Row_format'] == 'Fixed') {
834 echo __('static');
835 } elseif ($showtable['Row_format'] == 'Dynamic') {
836 echo __('dynamic');
837 } else {
838 echo $showtable['Row_format'];
840 ?></td>
841 </tr>
842 <?php
844 if (! empty($showtable['Create_options'])) {
846 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
847 <th class="name"><?php echo __('Options'); ?></th>
848 <td class="value"><?php
849 if ($showtable['Create_options'] == 'partitioned') {
850 echo __('partitioned');
851 } else {
852 echo $showtable['Create_options'];
854 ?></td>
855 </tr>
856 <?php
858 if (!empty($tbl_collation)) {
860 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
861 <th class="name"><?php echo __('Collation'); ?></th>
862 <td class="value"><?php
863 echo '<dfn title="' . PMA_getCollationDescr($tbl_collation) . '">' . $tbl_collation . '</dfn>';
864 ?></td>
865 </tr>
866 <?php
868 if (!$is_innodb && isset($showtable['Rows'])) {
870 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
871 <th class="name"><?php echo __('Rows'); ?></th>
872 <td class="value"><?php echo PMA_formatNumber($showtable['Rows'], 0); ?></td>
873 </tr>
874 <?php
876 if (!$is_innodb && isset($showtable['Avg_row_length']) && $showtable['Avg_row_length'] > 0) {
878 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
879 <th class="name"><?php echo __('Row length'); ?> &oslash;</th>
880 <td class="value"><?php echo PMA_formatNumber($showtable['Avg_row_length'], 0); ?></td>
881 </tr>
882 <?php
884 if (!$is_innodb && isset($showtable['Data_length']) && $showtable['Rows'] > 0 && $mergetable == false) {
886 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
887 <th class="name"><?php echo __(' Row size '); ?> &oslash;</th>
888 <td class="value"><?php echo $avg_size . ' ' . $avg_unit; ?></td>
889 </tr>
890 <?php
892 if (isset($showtable['Auto_increment'])) {
894 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
895 <th class="name"><?php echo __('Next'); ?> Autoindex</th>
896 <td class="value"><?php echo PMA_formatNumber($showtable['Auto_increment'], 0); ?></td>
897 </tr>
898 <?php
900 if (isset($showtable['Create_time'])) {
902 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
903 <th class="name"><?php echo __('Creation'); ?></th>
904 <td class="value"><?php echo PMA_localisedDate(strtotime($showtable['Create_time'])); ?></td>
905 </tr>
906 <?php
908 if (isset($showtable['Update_time'])) {
910 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
911 <th class="name"><?php echo __('Last update'); ?></th>
912 <td class="value"><?php echo PMA_localisedDate(strtotime($showtable['Update_time'])); ?></td>
913 </tr>
914 <?php
916 if (isset($showtable['Check_time'])) {
918 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
919 <th class="name"><?php echo __('Last check'); ?></th>
920 <td class="value"><?php echo PMA_localisedDate(strtotime($showtable['Check_time'])); ?></td>
921 </tr>
922 <?php
925 </tbody>
926 </table>
928 <!-- close slider div -->
929 </div>
931 <?php
933 // END - Calc Table Space
935 require './libraries/tbl_triggers.lib.php';
937 echo '<div class="clearfloat"></div>' . "\n";
940 * Displays the footer
942 require './libraries/footer.inc.php';