Rename db_* files to drop useless _details part.
[phpmyadmin/crack.git] / libraries / db_info.inc.php
blob10fb3fc2a618e26f700f509cded087130708491f
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
6 // Check parameters
8 require_once('./libraries/common.lib.php');
10 PMA_checkParameters(array('db'));
12 $is_show_stats = $cfg['ShowStats'];
14 if ( PMA_MYSQL_INT_VERSION >= 50002 && $db == 'information_schema' ) {
15 $is_show_stats = false;
16 $db_is_information_schema = true;
17 } else {
18 $db_is_information_schema = false;
21 function fillTooltip( &$tooltip_truename, &$tooltip_aliasname, &$tmp ) {
22 $tooltip_truename[$tmp['Name']] = ($GLOBALS['cfg']['ShowTooltipAliasTB'] && $GLOBALS['cfg']['ShowTooltipAliasTB'] != 'nested' ? (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : $tmp['Name']) : $tmp['Name']);
23 $tooltip_aliasname[$tmp['Name']] = ($GLOBALS['cfg']['ShowTooltipAliasTB'] && $GLOBALS['cfg']['ShowTooltipAliasTB'] != 'nested' ? $tmp['Name'] : (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : $tmp['Name']));
24 if (isset($tmp['Create_time']) && !empty($tmp['Create_time'])) {
25 $tooltip_aliasname[$tmp['Name']] .= ', ' . $GLOBALS['strStatCreateTime'] . ': ' . PMA_localisedDate(strtotime($tmp['Create_time']));
28 if (isset($tmp['Update_time']) && !empty($tmp['Update_time'])) {
29 $tooltip_aliasname[$tmp['Name']] .= ', ' . $GLOBALS['strStatUpdateTime'] . ': ' . PMA_localisedDate(strtotime($tmp['Update_time']));
32 if (isset($tmp['Check_time']) && !empty($tmp['Check_time'])) {
33 $tooltip_aliasname[$tmp['Name']] .= ', ' . $GLOBALS['strStatCheckTime'] . ': ' . PMA_localisedDate(strtotime($tmp['Check_time']));
36 return true;
39 /**
40 * Gets the list of the table in the current db and informations about these
41 * tables if possible
43 // staybyte: speedup view on locked tables - 11 June 2001
44 $tables = array();
46 // When used in Nested table group mode, only show tables matching the given groupname
47 if (!empty($tbl_group) && !$cfg['ShowTooltipAliasTB']) {
48 $tbl_group_sql = ' LIKE "' . PMA_escape_mysql_wildcards( $tbl_group ) . '%"';
49 } else {
50 $tbl_group_sql = '';
53 if ( $cfg['ShowTooltip'] ) {
54 $tooltip_truename = array();
55 $tooltip_aliasname = array();
58 // Special speedup for newer MySQL Versions (in 4.0 format changed)
59 if ( true === $cfg['SkipLockedTables'] ) {
60 $db_info_result = PMA_DBI_query('SHOW OPEN TABLES FROM ' . PMA_backquote($db) . ';');
62 // Blending out tables in use
63 if ($db_info_result != FALSE && PMA_DBI_num_rows($db_info_result) > 0) {
64 while ($tmp = PMA_DBI_fetch_row($db_info_result)) {
65 // if in use memorize tablename
66 if (preg_match('@in_use=[1-9]+@i', $tmp[1])) {
67 $sot_cache[$tmp[0]] = TRUE;
70 PMA_DBI_free_result($db_info_result);
72 if (isset($sot_cache)) {
73 $db_info_result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . $tbl_group_sql . ';', null, PMA_DBI_QUERY_STORE);
74 if ($db_info_result != FALSE && PMA_DBI_num_rows($db_info_result) > 0) {
75 while ($tmp = PMA_DBI_fetch_row($db_info_result)) {
76 if (!isset($sot_cache[$tmp[0]])) {
77 $sts_result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\';');
78 $sts_tmp = PMA_DBI_fetch_assoc($sts_result);
79 PMA_DBI_free_result($sts_result);
80 unset($sts_result);
82 if (!isset($sts_tmp['Type']) && isset($sts_tmp['Engine'])) {
83 $sts_tmp['Type'] =& $sts_tmp['Engine'];
86 if (!empty($tbl_group) && $cfg['ShowTooltipAliasTB'] && !preg_match('@' . preg_quote($tbl_group, '@') . '@i', $sts_tmp['Comment'])) {
87 continue;
90 if ($cfg['ShowTooltip']) {
91 fillTooltip($tooltip_truename, $tooltip_aliasname, $sts_tmp);
94 $tables[$sts_tmp['Name']] = $sts_tmp;
95 } else { // table in use
96 $tables[$tmp[0]] = array('Name' => $tmp[0]);
99 PMA_DBI_free_result($db_info_result);
101 if ( $GLOBALS['cfg']['NaturalOrder'] ) {
102 uksort( $tables, 'strnatcasecmp' );
105 $sot_ready = TRUE;
108 } else {
109 PMA_DBI_free_result($db_info_result);
110 unset($db_info_result);
114 if ( ! isset( $sot_ready ) ) {
115 if ( ! empty( $tbl_group ) && ! $cfg['ShowTooltipAliasTB'] ) {
116 // only tables for selected group
117 $tables = PMA_DBI_get_tables_full( $db, $tbl_group, true );
118 } elseif ( ! empty( $tbl_group ) && $cfg['ShowTooltipAliasTB'] ) {
119 // only tables for selected group,
120 // but grouping is done on comment ...
121 $tables = PMA_DBI_get_tables_full( $db, $tbl_group, 'comment' );
122 } else {
123 // all tables in db
124 $tables = PMA_DBI_get_tables_full( $db );
127 if ( $cfg['ShowTooltip'] ) {
128 foreach ( $tables as $each_table ) {
129 fillTooltip( $tooltip_truename, $tooltip_aliasname, $each_table );
134 $num_tables = count( $tables );
137 * Displays top menu links
139 require('./libraries/db_links.inc.php');