fixed inactivity timeout failure
[openemr.git] / interface / main / myadmin / left.php
blob3ac93ada58aa93d01cea5a277421748e82ad47e2
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
6 /**
7 * Gets the variables sent to this script, retains the db name that may have
8 * been defined as startup option and include a core library
9 */
10 require_once('./libraries/grab_globals.lib.php');
11 if (isset($lightm_db) && !empty($lightm_db)) {
12 // no longer urlencoded because of html entities in the db name
13 // $db = urldecode($lightm_db);
14 $db = $lightm_db;
17 if (!empty($db)) {
18 $db_start = $db;
22 /**
23 * Gets a core script and starts output buffering work
25 require_once('./libraries/common.lib.php');
26 require_once('./libraries/ob.lib.php');
27 if ($cfg['OBGzip']) {
28 $ob_mode = PMA_outBufferModeGet();
29 if ($ob_mode) {
30 PMA_outBufferPre($ob_mode);
34 // This check had been put here to avoid revealing the full path
35 // of the phpMyAdmin directory in case this script is called
36 // directly. But some users report a "Missing hash" message and
37 // I cannot reproduce it, so let's define $hash to a dummy value
38 // and hope some other clue will surface, to sort this bug.
39 //PMA_checkParameters(array('hash'));
40 if (!isset($hash)) {
41 $hash='';
44 require_once('./libraries/bookmark.lib.php');
45 require_once('./libraries/relation.lib.php');
46 $cfgRelation = PMA_getRelationsParam();
48 function PMA_reduceNest($_table) {
50 if ($GLOBALS['cfg']['LeftFrameTableLevel'] > 0) {
51 $max = $GLOBALS['cfg']['LeftFrameTableLevel'];
52 $temp_table = $_table;
53 $new_table = array();
54 $last_index = 0;
55 for ($ti = 0; $ti < $max; $ti++) {
56 if (isset($temp_table[$ti])) {
57 $new_table[$ti] = $temp_table[$ti];
58 unset($temp_table[$ti]);
59 $last_index = $ti;
63 $_table = $new_table;
66 return $_table;
69 function PMA_indent($spaces) {
70 $string = '';
71 for ($i = 0; $i <= $spaces; $i++) {
72 $string .= ' ';
75 return $string;
78 function PMA_nestedSetHeaderParent($baseid, $key, $keyhistory, $indent, $indent_level, $val, $childout = true) {
79 $name = $key;
80 $id = preg_replace('@[^a-z0-9]*@i', '', $baseid . $keyhistory . $key) . $indent;
82 $on_mouse = (($GLOBALS['cfg']['LeftPointerColor'] == '') ? '' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el' . $id . '\', \'' . $GLOBALS['cfg']['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el' . $id . '\', \'' . $GLOBALS['cfg']['LeftBgColor'] . '\')}"');
84 $countarray = $val;
85 if (count($countarray) == 2 && isset($countarray['pma_name']) && isset($countarray['pma_list_item'])) {
86 $counter = count($countarray['pma_name']);
87 } else {
88 unset($countarray['pma_name']);
89 if (count($countarray) > 1) {
90 unset($countarray['pma_list_item']);
92 $counter = count($countarray);
95 echo "\n";
96 echo PMA_indent($indent * 5) . '<div id="el' . $id . 'Parent" class="parent"' . $on_mouse . '>' . "\n";
97 echo PMA_indent($indent * 6) . '<nobr><img src="images/spacer.gif" border="0" width="' . (($indent - 1) * $indent_level) . '" height="9" alt="" /><a class="item" href="' . $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . $GLOBALS['common_url_query'] . '" onclick="if (capable) {expandBase(\'el' . $id . '\', true); return false} else {return true}">';
98 echo '<img name="imEx" id="el' . $id . 'Img" src="images/plus.png" border="0" width="9" height="9" alt="+" /></a>' . "\n";
99 echo PMA_indent($indent * 6) . '<a class="item" href="' . $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . $GLOBALS['common_url_query'] . '" title="' . htmlspecialchars($name) . '" onclick="if (capable) {expandBase(\'el' . $id . '\', false)}"><span class="heada">' . htmlspecialchars($name) . '<bdo dir="' . $GLOBALS['text_dir'] . '">&nbsp;&nbsp;</bdo></span><span class="headaCnt">(' . $counter . ')</span></a></nobr>' . "\n";
100 echo PMA_indent($indent * 5) . '</div><id class="PMA_nestedSetHeaderParent">' . "\n";
101 echo "\n";
103 if ($childout) {
104 echo PMA_indent($indent * 5) . '<div id="el' . $id . 'Child" class="child" ' . $on_mouse . '>' . "\n";
108 function PMA_nestedSetHeader($baseid, $tablestack, $keyhistory, $indent, $indent_level, $headerOut, $firstGroup = false, $firstGroupClose = true) {
109 if ($firstGroup) {
110 PMA_nestedSetHeaderParent($baseid, $firstGroup, $keyhistory, $indent, $indent_level, $tablestack);
111 $indent++;
114 foreach($tablestack AS $key => $val) {
115 if ($key != 'pma_name' && $key != 'pma_list_item') {
116 if ($headerOut) {
117 PMA_nestedSetHeaderParent($baseid, $key, $keyhistory, $indent, $indent_level, $val);
120 if (isset($val['pma_name']) && isset($val['pma_list_item']) && count($val) == 2) {
121 PMA_nestedSet($baseid, $val, $key, $keyhistory . $key, false, ($indent + 1));
122 } else {
123 PMA_nestedSet($baseid, $val, $key, $keyhistory . $key, true, ($indent + 1));
126 if ($headerOut) {
127 echo PMA_indent($indent * 5) . '</div><id class="PMA_nestedSetHeader">' . "\n";
132 if ($firstGroup && $firstGroupClose) {
133 echo PMA_indent($indent * 4) . '</div><id class="PMA_nestedSetHeader2">' . "\n";
134 } elseif ($firstGroup) {
135 echo PMA_indent($indent * 4) . '<id spacer="div omitted" class="PMA_nestedSetHeader2">' . "\n";
139 function PMA_nestedSet($baseid, $tablestack, $key = '__protected__', $keyhistory = '', $headerOut = false, $indent = 1) {
141 if ($keyhistory == '' && $key != '__protected__') {
142 $keyhistory = $key;
145 $indent_level = 9;
147 if (isset($tablestack)
148 && isset($tablestack['pma_name'])
149 && isset($tablestack['pma_list_item'])) {
151 if (count($tablestack) > 1 && !empty($key) && isset($tablestack['pma_name']) && isset($tablestack['pma_list_item']) && $indent == 1) {
152 PMA_nestedSetHeader($baseid, $tablestack, $keyhistory, ($indent+1), $indent_level, $headerOut, $key, false);
153 $divClose = true;
154 $extra_indent = 1;
155 } else {
156 PMA_nestedSetHeader($baseid, $tablestack, $keyhistory, $indent, $indent_level, $headerOut);
157 $divClose = false;
158 $extra_indent = 0;
161 $on_mouse = (($GLOBALS['cfg']['LeftPointerColor'] == '') ? '' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el' . $keyhistory . $key . '\', \'' . $GLOBALS['cfg']['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el' . $keyhistory . $key . '\', \'' . $GLOBALS['cfg']['LeftBgColor'] . '\')}"');
163 $loops = 0;
164 foreach($tablestack['pma_name'] AS $tkey => $tval) {
166 echo PMA_indent($indent * 5) . '<nobr><img src="images/spacer.gif" border="0" width="' . (($indent+$extra_indent) * $indent_level) . '" height="9" alt="" />';
167 $items = explode("\n", $tablestack['pma_list_item'][$tkey]);
168 foreach($items AS $ikey => $ival) {
169 echo "\n";
170 echo PMA_indent(($indent * 5)) . $ival;
172 echo "\n";
174 $loops++;
177 if ($divClose) {
178 echo PMA_indent($indent * 5) . '</div><id space="putting omitted div" class="PMA_nestedSet2">';
181 } elseif (is_array($tablestack)) {
182 PMA_nestedSetHeader($baseid, $tablestack, $keyhistory, (($key == '__protected__' && $indent == 1 )? ($indent-1) : ($indent + 1)), $indent_level, $headerOut, (($key == '__protected__' && $indent == 1) || ($indent > 1) ? false : $key));
185 return true;
188 * Get the list and number of available databases.
189 * Skipped if no server selected: in this case no database should be displayed
190 * before the user choose among available ones at the welcome screen.
192 if ($server > 0) {
193 PMA_availableDatabases(); // this function is defined in "common.lib.php"
194 } else {
195 $num_dbs = 0;
199 // garvin: For re-usability, moved http-headers
200 // to a seperate file. It can now be included by header.inc.php,
201 // queryframe.php, querywindow.php.
203 require_once('./libraries/header_http.inc.php');
206 * Displays the frame
208 // Gets the font sizes to use
209 PMA_setFontSizes();
211 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
212 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
213 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $available_languages[$lang][2]; ?>" lang="<?php echo $available_languages[$lang][2]; ?>" dir="<?php echo $text_dir; ?>">
215 <head>
216 <title>phpMyAdmin</title>
217 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset; ?>" />
218 <base<?php if (!empty($cfg['PmaAbsoluteUri'])) echo ' href="' . $cfg['PmaAbsoluteUri'] . '"'; ?> target="phpmain<?php echo $hash; ?>" />
220 <script type="text/javascript" language="javascript">
221 <!--
222 <?php
223 if (isset($lightm_db) && !empty($lightm_db)) {
225 window.parent.frames['phpmain<?php echo $hash; ?>'].location.replace('./<?php echo $cfg['DefaultTabDatabase'] . '?' . PMA_generate_common_url($db, '', '&');?>');
226 <?php
227 } elseif (isset($lightm_db)) {
229 window.parent.frames['phpmain<?php echo $hash; ?>'].location.replace('./main.php?<?php echo PMA_generate_common_url('', '', '&');?>');
230 <?php
233 //-->
234 </script>
236 <?php
237 // Expandable/collapsible databases list is only used if there is more than one
238 // database to display
239 if (($num_dbs > 1 || !empty($cfg['LeftFrameTableSeparator'])) && !$cfg['LeftFrameLight']) {
240 echo "\n";
242 <!-- Collapsible tables list scripts -->
243 <script type="text/javascript" language="javascript">
244 <!--
245 var isDOM = (typeof(document.getElementsByTagName) != 'undefined'
246 && typeof(document.createElement) != 'undefined')
247 ? 1 : 0;
248 var isIE4 = (typeof(document.all) != 'undefined'
249 && parseInt(navigator.appVersion) >= 4)
250 ? 1 : 0;
251 var isNS4 = (typeof(document.layers) != 'undefined')
252 ? 1 : 0;
253 var capable = (isDOM || isIE4 || isNS4)
254 ? 1 : 0;
255 // Uggly fix for Opera and Konqueror 2.2 that are half DOM compliant
256 if (capable) {
257 if (typeof(window.opera) != 'undefined') {
258 var browserName = ' ' + navigator.userAgent.toLowerCase();
259 if ((browserName.indexOf('konqueror 7') == 0)) {
260 capable = 0;
263 else if (typeof(navigator.userAgent) != 'undefined') {
264 var browserName = ' ' + navigator.userAgent.toLowerCase();
265 if ((browserName.indexOf('konqueror') > 0) && (browserName.indexOf('konqueror/3') == 0)) {
266 capable = 0;
268 } // end if... else if...
269 } // end if
271 var isServer = <?php echo ($server > 0) ? 'true' : 'false'; ?>;
273 document.writeln('<link rel="stylesheet" type="text/css" href="./css/phpmyadmin.css.php?lang=<?php echo $lang; ?>&amp;js_frame=left&amp;js_capable=' + capable + '&amp;js_isDOM=' + isDOM + '&amp;js_isIE4=' + isIE4 + '" />');
274 //-->
275 </script>
276 <noscript>
277 <link rel="stylesheet" type="text/css" href="./css/phpmyadmin.css.php?lang=<?php echo $lang; ?>&amp;js_frame=left&amp;js_capable=0&amp;js_isDOM=0&amp;js_isIE4=0" />
278 </noscript>
280 <script src="libraries/left.js" type="text/javascript" language="javascript1.2"></script>
281 <?php
282 } // end if ($num_dbs > 1)
284 else if ($num_dbs == 1) {
285 echo "\n";
287 <link rel="stylesheet" type="text/css" href="./css/phpmyadmin.css.php?js_frame=left&amp;js_capable=0&amp;js_isDOM=0&amp;js_isIE4=0" />
288 <?php
289 } // end if ($num_dbs == 1)
291 else {
292 echo "\n";
294 <link rel="stylesheet" type="text/css" href="./css/phpmyadmin.css.php?js_frame=left&amp;num_dbs=0" />
295 <?php
296 } // end if ($num_dbs < 1)
298 echo "\n";
300 </head>
302 <body bgcolor="<?php echo $cfg['LeftBgColor']; ?>">
304 <?php
305 if ($cfg['LeftDisplayLogo']) {
307 <!-- phpMyAdmin logo -->
308 <a href="http://www.phpmyadmin.net" target="_blank"><img src="./images/pma_logo.png" width="88" height="31" border="0" alt="phpMyAdmin" /></a>
309 <?php
311 echo "\n";
312 if ($cfg['LeftDisplayServers']) {
314 <form method="post" action="index.php" target="_parent">
315 <select name="server" onchange="this.form.submit();">
316 <?php
317 echo "\n";
318 foreach($cfg['Servers'] AS $key => $val) {
319 if (!empty($val['host'])) {
320 echo ' <option value="' . $key . '"';
321 if (!empty($server) && ($server == $key)) {
322 echo ' selected="selected"';
324 echo '>';
325 if (!empty($val['verbose'])) {
326 echo $val['verbose'];
327 } else {
328 echo $val['host'];
329 if (!empty($val['port'])) {
330 echo ':' . $val['port'];
332 // loic1: skip this because it's not a so good idea to display
333 // sockets used to everybody
334 // if (!empty($val['socket']) && PMA_PHP_INT_VERSION >= 30010) {
335 // echo ':' . $val['socket'];
336 // }
338 // loic1: if 'only_db' is an array and there is more than one
339 // value, displaying such informations may not be a so good
340 // idea
341 if (!empty($val['only_db'])) {
342 echo ' - ' . (is_array($val['only_db']) ? implode(', ', $val['only_db']) : $val['only_db']);
344 if (!empty($val['user']) && ($val['auth_type'] == 'config')) {
345 echo ' (' . $val['user'] . ')';
347 echo '&nbsp;</option>' . "\n";
348 } // end if (!empty($val['host']))
349 } // end while
351 </select>
352 <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
353 <input type="hidden" name="convcharset" value="<?php echo $convcharset; ?>" />
354 <noscript><input type="submit" value="<?php echo $strGo; ?>" /></noscript>
355 </form>
356 <?php
358 echo "\n";
360 <!-- Link to the welcome page -->
361 <div id="el1Parent" class="parent" style="margin-bottom: 5px">
362 <nobr><a class="item" href="main.php?<?php echo PMA_generate_common_url(); ?>"><span class="heada"><b><?php echo $strHome; ?></b></span></a></nobr>
363 </div>
366 <!-- Databases and tables list -->
367 <?php
368 // Don't display expansible/collapsible database info if:
369 // 1. $server == 0 (no server selected)
370 // This is the case when there are multiple servers and
371 // '$cfg['ServerDefault'] = 0' is set. In that case, we want the welcome
372 // screen to appear with no database info displayed.
373 // 2. there is only one database available (ie either only one database exists
374 // or $cfg['Servers']['only_db'] is defined and is not an array)
375 // In this case, the database should not be collapsible/expandable
376 if ($num_dbs > 1) {
378 // Light mode -> beginning of the select combo for databases
379 // Note: When javascript is active, the frameset will be changed from
380 // within left.php. With no JS (<noscript>) the whole frameset will
381 // be rebuilt with the new target frame.
382 if ($cfg['LeftFrameLight']) {
384 <script type="text/javascript" language="javascript">
385 document.writeln('<form method="post" action="left.php" name="left" target="nav">');
386 </script>
387 <noscript>
388 <form method="post" action="index.php" name="left" target="_parent">
389 </noscript>
390 <?php
391 echo PMA_generate_common_hidden_inputs();
392 echo ' <input type="hidden" name="hash" value="' . $hash . '" />' . "\n";
393 echo ' <select name="lightm_db" onchange="this.form.submit()">' . "\n";
394 echo ' <option value="">(' . $strDatabases . ') ...</option>' . "\n";
395 $table_list = '';
396 $table_list_header = '';
397 $db_name = '';
400 $selected_db = 0;
402 // Gets the tables list per database
403 for ($i = 0; $i < $num_dbs; $i++) {
404 $db = $dblist[$i];
405 $j = $i + 2;
406 if (!empty($db_start) && $db == $db_start) {
407 $selected_db = $j;
409 $tables = @PMA_mysql_list_tables($db);
410 $num_tables = ($tables) ? @mysql_numrows($tables) : 0;
411 $common_url_query = PMA_generate_common_url($db);
412 if ($num_tables) {
413 $num_tables_disp = $num_tables;
414 } else {
415 $num_tables_disp = '-';
418 // Get additional information about tables for tooltip
419 if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION >= 32303
420 && $num_tables
421 && (!$cfg['LeftFrameLight'] || $selected_db == $j)) {
422 $tooltip = array();
423 $tooltip_name = array();
424 $result = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
425 while ($tmp = PMA_mysql_fetch_array($result)) {
426 $tooltip_name[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '');
427 $tmp['Comment'] = ($cfg['ShowTooltipAliasTB'] ? $tmp['Name'] : $tmp['Comment']);
429 $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '')
430 . '(' . (isset($tmp['Rows']) ? $tmp['Rows'] : '0') . ' ' . $strRows . ')';
431 } // end while
432 } // end if
434 // garvin: Get comments from PMA comments table
435 $db_tooltip = '';
436 if ($cfg['ShowTooltip'] && $cfgRelation['commwork']) {
437 $tmp_db_tooltip = PMA_getComments($db);
438 if (is_array($tmp_db_tooltip)) {
439 $db_tooltip = implode(' ', $tmp_db_tooltip);
443 // No light mode -> displays the expandible/collapsible db list
444 if ($cfg['LeftFrameLight'] == FALSE) {
446 // Displays the database name
447 $on_mouse = (($cfg['LeftPointerColor'] == '') ? '' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el' . $j . '\', \'' . $cfg['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el' . $j . '\', \'' . $cfg['LeftBgColor'] . '\')}"');
449 echo "\n";
450 echo ' <div id="el' . $j . 'Parent" class="parent"' . $on_mouse . '>';
452 if (!empty($num_tables)) {
453 echo "\n";
455 <nobr><a class="item" href="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>" onclick="if (capable) {expandBase('el<?php echo $j; ?>', true); return false} else {return true}">
456 <img name="imEx" id="el<?php echo $j; ?>Img" src="images/plus.png" border="0" width="9" height="9" alt="+" /></a>
457 <?php
458 } else {
459 echo "\n";
461 <nobr><img name="imEx" src="images/minus.png" border="0" width="9" height="9" alt="-" />
462 <?php
464 echo "\n";
466 <a class="item" href="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>" title="<?php echo ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? htmlspecialchars($db) : htmlspecialchars($db_tooltip)); ?>" onclick="if (capable) {expandBase('el<?php echo $j; ?>', false)}">
467 <span class="heada"><?php echo ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? '<i>' . htmlspecialchars($db_tooltip) . '</i>' : htmlspecialchars($db)); ?><bdo dir="<?php echo($text_dir); ?>">&nbsp;&nbsp;</bdo></span><span class="headaCnt">(<?php echo $num_tables_disp; ?>)</span></a></nobr>
468 </div>
470 <div id="el<?php echo $j;?>Child" class="child" style="margin-bottom: 5px"<?php echo $on_mouse; ?>>
471 <?php
472 // Displays the list of tables from the current database
473 $tablestack = array();
474 for ($t = 0; $t < $num_tables; $t++) {
475 $table = PMA_mysql_tablename($tables, $t);
476 $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
477 ? htmlspecialchars($tooltip_name[$table])
478 : '';
479 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
480 ? htmlspecialchars($tooltip[$table])
481 : '';
483 $book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
485 $list_item = '<a target="phpmain' . $hash . '" href="sql.php?' . $common_url_query . '&amp;table=' . urlencode($table) . '&amp;sql_query=' . (isset($book_sql_query) && $book_sql_query != FALSE ? urlencode($book_sql_query) : urlencode('SELECT * FROM ' . PMA_backquote($table))) . '&amp;pos=0&amp;goto=' . $cfg['DefaultTabTable'] . '" title="' . $strBrowse . ': ' . $url_title . '">';
486 $list_item .= '<img src="images/button_smallbrowse.png" width="10" height="10" border="0" alt="' . $strBrowse . ': ' . $url_title . '" /></a>';
487 $list_item .= '<bdo dir="' . $text_dir . '">&nbsp;</bdo>' . "\n";
488 $list_item .= '<a class="tblItem" id="tbl_' . md5($table) . '" title="' . $url_title . '" target="phpmain' . $hash . '" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&amp;table=' . urlencode($table) . '">';
489 $list_item .= ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)) . '</a></nobr><br />' . "\n";
491 // garvin: Check whether to display nested sets
492 if (!empty($cfg['LeftFrameTableSeparator'])) {
493 $_table = explode($cfg['LeftFrameTableSeparator'], str_replace('\'', '\\\'',$table));
494 if (is_array($_table)) {
495 foreach($_table AS $key => $val) {
496 if ($val == '') {
497 $_table[$key] = '__protected__';
501 unset($_table[count($_table)-1]);
502 $_table = PMA_reduceNest($_table);
504 $eval_string = '$tablestack[\'' . implode('\'][\'', $_table) . '\'][\'pma_name\'][] = \'' . str_replace('\'', '\\\'', $table) . '\';';
505 $eval_string .= '$tablestack[\'' . implode('\'][\'', $_table) . '\'][\'pma_list_item\'][] = \'' . str_replace('\'', '\\\'', $list_item) . '\';';
506 eval($eval_string);
507 } else {
508 $tablestack['']['pma_name'][] = $table;
509 $tablestack['']['pma_list_item'][] = $list_item;
511 } else {
512 $tablestack['']['pma_name'][] = $table;
513 $tablestack['']['pma_list_item'][] = $list_item;
515 } // end for $t (tables list)
517 PMA_nestedSet($j, $tablestack);
519 </div>
520 <?php
521 echo "\n";
525 // Light mode -> displays the select combo with databases names and the
526 // list of tables contained in the current database
527 else {
528 echo "\n";
530 // Builds the databases' names list
531 if (!empty($db_start) && $db == $db_start) {
532 // Gets the list of tables from the current database
533 for ($t = 0; $t < $num_tables; $t++) {
534 $table = PMA_mysql_tablename($tables, $t);
535 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
536 ? htmlentities($tooltip[$table])
537 : '';
538 $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
539 ? htmlentities($tooltip_name[$table])
540 : '';
542 $book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
544 $table_list .= ' <nobr><a target="phpmain' . $hash . '" href="sql.php?' . $common_url_query . '&amp;table=' . urlencode($table) . '&amp;sql_query=' . (isset($book_sql_query) && $book_sql_query != FALSE ? urlencode($book_sql_query) : urlencode('SELECT * FROM ' . PMA_backquote($table))) . '&amp;pos=0&amp;goto=' . $cfg['DefaultTabTable'] . '">' . "\n";
545 $table_list .= ' <img src="images/button_smallbrowse.png" width="10" height="10" border="0" alt="' . $strBrowse . ': ' . $url_title . '" title="' . $strBrowse . ': ' . $url_title . '" /></a><bdo dir="' . $text_dir . '">&nbsp;</bdo>' . "\n";
546 if (PMA_USR_BROWSER_AGENT == 'IE') {
547 $table_list .= ' <span class="tblItem"><a class="tblItem" id="tbl_' . md5($table) . '" title="' . $url_title . '" target="phpmain' . $hash . '" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&amp;table=' . urlencode($table) . '">' . ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)) . '</a></span></nobr><br />' . "\n";
548 } else {
549 $table_list .= ' <a class="tblItem" id="tbl_' . md5($table) . '" title="' . $url_title . '" target="phpmain' . $hash . '" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&amp;table=' . urlencode($table) . '">' . ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)) . '</a></nobr><br />' . "\n";
551 } // end for $t (tables list)
553 if (!$table_list) {
554 $table_list = ' <br /><br />' . "\n"
555 . ' <div>' . $strNoTablesFound . '</div>' . "\n";
557 $selected = ' selected="selected"';
559 $table_list_header .= ' <a class="item" target="phpmain' . $hash . '" href="' . $cfg['DefaultTabDatabase'] . '?' . $common_url_query . '">' . "\n";
560 $table_list_header .= ' <span class="heada"><b>' . ($db_tooltip != '' && $cfg['ShowTooltipAliasTB'] ? htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . '</b><bdo dir="' . $text_dir . '">&nbsp;&nbsp;</bdo></span></a><br />' . "\n\n";
561 } else {
562 $selected = '';
563 } // end if... else...
565 if (!empty($num_tables)) {
566 echo ' <option value="' . htmlspecialchars($db) . '"' . $selected . '>' . ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . ' (' . $num_tables . ')</option>' . "\n";
567 } else {
568 echo ' <option value="' . htmlspecialchars($db) . '"' . $selected . '>' . ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . ' (-)</option>' . "\n";
569 } // end if... else...
571 } // end if (light mode)
573 } // end for $i (db list)
575 // Light mode -> end of the select combo for databases and table list for
576 // the current database
577 if ($cfg['LeftFrameLight']) {
578 echo ' </select>' . "\n";
579 echo ' <noscript><input type="submit" name="Go" value="' . $strGo . '" /></noscript>' . "\n";
580 echo ' </form>' . "\n";
582 if (!$table_list) {
583 $table_list = ' <div>' . $strSelectADb . '</div>' . "\n";
586 // Displays the current database name and the list of tables it
587 // contains
588 echo "\n" . ' <hr noshade="noshade" />' . "\n\n";
589 echo $table_list_header;
590 echo $table_list;
591 echo "\n" . ' <hr noshade="noshade" />' . "\n";
594 // No light mode -> initialize some js variables for the
595 // expandible/collapsible stuff
596 else {
599 <!-- Arrange collapsible/expandable db list at startup -->
600 <script type="text/javascript" language="javascript1.2">
601 <!--
602 if (isNS4) {
603 firstEl = 'el1Parent';
604 firstInd = nsGetIndex(firstEl);
605 nsShowAll();
606 nsArrangeList();
608 var expandedDb = '<?php echo (empty($selected_db)) ? '' : 'el' . $selected_db . 'Child'; ?>';
609 //-->
610 </script>
611 <?php
613 } // end if... else... (light mode)
615 } // end if ($server > 1)
618 // Case where only one database has to be displayed
619 else if ($num_dbs == 1) {
620 $db = $dblist[0];
621 $tables = @PMA_mysql_list_tables($db);
622 $num_tables = ($tables) ? @mysql_numrows($tables) : 0;
623 $common_url_query = PMA_generate_common_url($db);
624 if ($num_tables) {
625 $num_tables_disp = $num_tables;
626 } else {
627 $num_tables_disp = '-';
630 // Get additional infomation about tables for tooltip
631 if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION >= 32303
632 && $num_tables) {
633 $tooltip = array();
634 $tooltip_name = array();
635 $result = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
636 while ($tmp = PMA_mysql_fetch_array($result)) {
637 $tooltip_name[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '');
638 $tmp['Comment'] = ($cfg['ShowTooltipAliasTB'] ? $tmp['Name'] : $tmp['Comment']);
640 $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '')
641 . '(' . (isset($tmp['Rows']) ? $tmp['Rows'] : '0') . ' ' . $strRows . ')';
642 } // end while
643 } // end if
645 // garvin: Get comments from PMA comments table
646 $db_tooltip = '';
647 if ($cfg['ShowTooltip'] && $cfgRelation['commwork']) {
648 $tmp_db_tooltip = PMA_getComments($db);
649 if (is_array($tmp_db_tooltip)) {
650 $db_tooltip = implode(' ', $tmp_db_tooltip);
655 // Displays the database name
656 if (!$cfg['LeftFrameLight']) {
657 $on_mouse = (($cfg['LeftPointerColor'] == '') ? '' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el2\', \'' . $cfg['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el2\', \'' . $cfg['LeftBgColor'] . '\')}"');
659 echo "\n";
660 echo ' <div id="el2Parent" class="parent"' . $on_mouse . '>';
662 if (!empty($num_tables)) {
663 echo "\n";
665 <nobr><a class="item" href="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>" onclick="if (capable) {expandBase('el2', true); return false} else {return true}">
666 <img name="imEx" id="el2Img" src="images/plus.png" border="0" width="9" height="9" alt="+" /></a>
667 <?php
668 } else {
669 echo "\n";
671 <nobr><img name="imEx" src="images/minus.png" border="0" width="9" height="9" alt="-" />
672 <?php
674 echo "\n";
676 <a class="item" href="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>" title="<?php echo ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? htmlspecialchars($db) : htmlspecialchars($db_tooltip)); ?>" onclick="if (capable) {expandBase('el2', false)}">
677 <span class="heada"><?php echo ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? '<i>' . htmlspecialchars($db_tooltip) . '</i>' : htmlspecialchars($db)); ?><bdo dir="<?php echo($text_dir); ?>">&nbsp;&nbsp;</bdo></span><span class="headaCnt">(<?php echo $num_tables_disp; ?>)</span></a></nobr>
678 </div>
680 <div id="el2Child" class="child" style="margin-bottom: 5px"<?php echo $on_mouse; ?>>
681 <?php
682 } else {
683 echo "\n";
685 <div id="el2Parent" class="parent">
686 <nobr><a class="item" href="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>">
687 <span class="heada"><?php echo ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? htmlspecialchars($db_tooltip) : htmlspecialchars($db)); ?><bdo dir="<?php echo($text_dir); ?>">&nbsp;&nbsp;</bdo></span><span class="headaCnt">(<?php echo $num_tables_disp; ?>)</span></a></nobr>
688 </div>
689 <div id="el2Child" class="child" style="margin-bottom: 5px">
690 <?php
693 // Displays the list of tables from the current database
694 $tablestack = array();
695 for ($j = 0; $j < $num_tables; $j++) {
696 $table = PMA_mysql_tablename($tables, $j);
697 $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
698 ? htmlentities($tooltip_name[$table])
699 : '';
700 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
701 ? htmlentities($tooltip[$table])
702 : '';
703 $book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
705 if ($cfg['LeftFrameLight']) {
706 echo "\n";
708 <nobr><a target="phpmain<?php echo $hash; ?>" href="sql.php?<?php echo $common_url_query; ?>&amp;table=<?php echo urlencode($table); ?>&amp;sql_query=<?php echo (isset($book_sql_query) && $book_sql_query != FALSE ? urlencode($book_sql_query) : urlencode('SELECT * FROM ' . PMA_backquote($table))); ?>&amp;pos=0&amp;goto=<?php echo $cfg['DefaultTabTable']; ?>" title="<?php echo $strBrowse . ': ' . $url_title; ?>">
709 <img src="images/button_smallbrowse.png" width="10" height="10" border="0" alt="<?php echo $strBrowse . ': ' . $url_title; ?>" /></a><bdo dir="<?php echo $text_dir; ?>">&nbsp;</bdo>
710 <a class="tblItem" id="tbl_<?php echo md5($table); ?>" title="<?php echo $url_title; ?>" target="phpmain<?php echo $hash; ?>" href="<?php echo $cfg['DefaultTabTable']; ?>?<?php echo $common_url_query; ?>&amp;table=<?php echo urlencode($table); ?>">
711 <?php echo ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)); ?></a></nobr><br />
712 <?php
713 } else {
714 $list_item = '<a target="phpmain' . $hash . '" href="sql.php?' . $common_url_query . '&amp;table=' . urlencode($table) . '&amp;sql_query=' . (isset($book_sql_query) && $book_sql_query != FALSE ? urlencode($book_sql_query) : urlencode('SELECT * FROM ' . PMA_backquote($table))) . '&amp;pos=0&amp;goto=' . $cfg['DefaultTabTable'] . '" title="' . $strBrowse . ': ' . $url_title . '">';
715 $list_item .= '<img src="images/button_smallbrowse.png" width="10" height="10" border="0" alt="' . $strBrowse . ': ' . $url_title . '" /></a>';
716 $list_item .= '<bdo dir="' . $text_dir . '">&nbsp;</bdo>' . "\n";
717 $list_item .= '<a class="tblItem" id="tbl_' . md5($table) . '" title="' . $url_title . '" target="phpmain' . $hash . '" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&amp;table=' . urlencode($table) . '">';
718 $list_item .= ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)) . '</a></nobr><br />';
720 // garvin: Check whether to display nested sets
721 if (!empty($cfg['LeftFrameTableSeparator'])) {
722 $_table = explode($cfg['LeftFrameTableSeparator'], str_replace('\'', '\\\'',$table));
723 if (is_array($_table)) {
724 foreach($_table AS $key => $val) {
725 if ($val == '') {
726 $_table[$key] = '__protected__';
730 unset($_table[count($_table)-1]);
731 $_table = PMA_reduceNest($_table);
733 $eval_string = '$tablestack[\'' . implode('\'][\'', $_table) . '\'][\'pma_name\'][] = \'' . str_replace('\'', '\\\'', $table) . '\';';
734 $eval_string .= '$tablestack[\'' . implode('\'][\'', $_table) . '\'][\'pma_list_item\'][] = \'' . str_replace('\'', '\\\'', $list_item) . '\';';
735 eval($eval_string);
736 } else {
737 $tablestack['']['pma_name'][] = $table;
738 $tablestack['']['pma_list_item'][] = $list_item;
740 } else {
741 $tablestack['']['pma_name'][] = $table;
742 $tablestack['']['pma_list_item'][] = $list_item;
745 } // end for $j (tables list)
747 if (!$cfg['LeftFrameLight']) {
748 PMA_nestedSet('1', $tablestack);
750 </div>
751 <!-- Arrange collapsible/expandable db list at startup -->
752 <script type="text/javascript" language="javascript1.2">
753 <!--
754 if (isNS4) {
755 firstEl = 'el1Parent';
756 firstInd = nsGetIndex(firstEl);
757 nsShowAll();
758 nsArrangeList();
760 var expandedDb = '<?php echo (empty($selected_db)) ? '' : 'el' . $selected_db . 'Child'; ?>';
761 //-->
762 </script>
763 <?php
764 } else {
765 echo ' </div>';
768 echo "\n";
769 } // end if ($num_dbs == 1)
772 // Case where no database has to be displayed
773 else {
774 echo "\n";
775 echo '<p>' . $strNoDatabases . '</p>';
776 } // end if ($num_dbs == 0)
777 echo "\n";
780 </body>
781 </html>
783 <?php
785 * Close MySql connections
787 if (isset($dbh) && $dbh) {
788 @mysql_close($dbh);
790 if (isset($userlink) && $userlink) {
791 @mysql_close($userlink);
796 * Sends bufferized data
798 if (isset($cfg['OBGzip']) && $cfg['OBGzip']
799 && isset($ob_mode) && $ob_mode) {
800 PMA_outBufferPost($ob_mode);