status is not a reserved word
[phpmyadmin/crack.git] / left.php3
blob8f7ecf75bc08a9a2372d1d927b96470fd560c914
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('./libraries/grab_globals.lib.php3');
11 if (!empty($db)) {
12 $db_start = $db;
16 /**
17 * Gets a core script and starts output buffering work
19 require('./libraries/common.lib.php3');
20 require('./libraries/ob.lib.php3');
21 if ($cfg['OBGzip']) {
22 $ob_mode = PMA_outBufferModeGet();
23 if ($ob_mode) {
24 PMA_outBufferPre($ob_mode);
28 include('./libraries/bookmark.lib.php3');
29 require('./libraries/relation.lib.php3');
30 $cfgRelation = PMA_getRelationsParam();
32 /**
33 * Get the list and number of available databases.
34 * Skipped if no server selected: in this case no database should be displayed
35 * before the user choose among available ones at the welcome screen.
37 if ($server > 0) {
38 PMA_availableDatabases(); // this function is defined in "common.lib.php3"
39 } else {
40 $num_dbs = 0;
44 // garvin: For re-usability, moved http-headers
45 // to a seperate file. It can now be included by header.inc.php3,
46 // queryframe.php3, querywindow.php3.
48 include('./libraries/header_http.inc.php3');
50 /**
51 * Displays the frame
53 // Gets the font sizes to use
54 PMA_setFontSizes();
56 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
57 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
58 <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; ?>">
60 <head>
61 <title>phpMyAdmin</title>
62 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset; ?>" />
63 <base<?php if (!empty($cfg['PmaAbsoluteUri'])) echo ' href="' . $cfg['PmaAbsoluteUri'] . '"'; ?> target="phpmain" />
64 <?php
65 // Expandable/collapsible databases list is only used if there is more than one
66 // database to display
67 if ($num_dbs > 1 && !$cfg['LeftFrameLight']) {
68 echo "\n";
70 <!-- Collapsible tables list scripts -->
71 <script type="text/javascript" language="javascript">
72 <!--
73 var isDOM = (typeof(document.getElementsByTagName) != 'undefined'
74 && typeof(document.createElement) != 'undefined')
75 ? 1 : 0;
76 var isIE4 = (typeof(document.all) != 'undefined'
77 && parseInt(navigator.appVersion) >= 4)
78 ? 1 : 0;
79 var isNS4 = (typeof(document.layers) != 'undefined')
80 ? 1 : 0;
81 var capable = (isDOM || isIE4 || isNS4)
82 ? 1 : 0;
83 // Uggly fix for Opera and Konqueror 2.2 that are half DOM compliant
84 if (capable) {
85 if (typeof(window.opera) != 'undefined') {
86 capable = 0;
88 else if (typeof(navigator.userAgent) != 'undefined') {
89 var browserName = ' ' + navigator.userAgent.toLowerCase();
90 if (browserName.indexOf('konqueror') > 0) {
91 capable = 0;
93 } // end if... else if...
94 } // end if
96 var isServer = <?php echo ($server > 0) ? 'true' : 'false'; ?>;
98 document.writeln('<link rel="stylesheet" type="text/css" href="./css/phpmyadmin.css.php3?lang=<?php echo $lang; ?>&amp;js_frame=left&amp;js_capable=' + capable + '&amp;js_isDOM=' + isDOM + '&amp;js_isIE4=' + isIE4 + '" />');
99 //-->
100 </script>
101 <noscript>
102 <link rel="stylesheet" type="text/css" href="./css/phpmyadmin.css.php3?lang=<?php echo $lang; ?>&amp;js_frame=left&amp;js_capable=0&amp;js_isDOM=0&amp;js_isIE4=0" />
103 </noscript>
105 <script src="libraries/left.js" type="text/javascript" language="javascript1.2"></script>
106 <?php
107 } // end if ($num_dbs > 1)
109 else if ($num_dbs == 1) {
110 echo "\n";
112 <link rel="stylesheet" type="text/css" href="./css/phpmyadmin.css.php3?js_frame=left&amp;js_capable=0&amp;js_isDOM=0&amp;js_isIE4=0" />
113 <?php
114 } // end if ($num_dbs == 1)
116 else {
117 echo "\n";
119 <link rel="stylesheet" type="text/css" href="./css/phpmyadmin.css.php3?js_frame=left&amp;num_dbs=0" />
120 <?php
121 } // end if ($num_dbs < 1)
123 echo "\n";
125 </head>
127 <body bgcolor="<?php echo $cfg['LeftBgColor']; ?>">
129 <?php
130 if ($cfg['LeftDisplayLogo']) {
132 <!-- phpMyAdmin logo -->
133 <a href="http://www.phpmyadmin.net" target="_blank"><img src="./images/pma_logo.png" width="88" height="31" border="0" alt="phpMyAdmin" /></a>
134 <?php
136 echo "\n";
138 <!-- Link to the welcome page -->
139 <div id="el1Parent" class="parent" style="margin-bottom: 5px">
140 <nobr><a class="item" href="main.php3?<?php echo PMA_generate_common_url(); ?>"><span class="heada"><b><?php echo $strHome; ?></b></span></a></nobr>
141 </div>
144 <!-- Databases and tables list -->
145 <?php
146 // Don't display expansible/collapsible database info if:
147 // 1. $server == 0 (no server selected)
148 // This is the case when there are multiple servers and
149 // '$cfg['ServerDefault'] = 0' is set. In that case, we want the welcome
150 // screen to appear with no database info displayed.
151 // 2. there is only one database available (ie either only one database exists
152 // or $cfg['Servers']['only_db'] is defined and is not an array)
153 // In this case, the database should not be collapsible/expandable
154 if ($num_dbs > 1) {
156 // Light mode -> beginning of the select combo for databases
157 if ($cfg['LeftFrameLight']) {
158 echo ' <form method="post" action="index.php3" name="left" target="_parent">' . "\n";
159 echo PMA_generate_common_hidden_inputs();
160 echo ' <select name="lightm_db" onchange="this.form.submit()">' . "\n";
161 echo ' <option value="">(' . $strDatabases . ') ...</option>' . "\n";
162 $table_list = '';
163 $table_list_header = '';
164 $db_name = '';
167 $selected_db = 0;
169 // Gets the tables list per database
170 for ($i = 0; $i < $num_dbs; $i++) {
171 $db = $dblist[$i];
172 $j = $i + 2;
173 if (!empty($db_start) && $db == $db_start) {
174 $selected_db = $j;
176 $tables = @PMA_mysql_list_tables($db);
177 $num_tables = ($tables) ? @mysql_numrows($tables) : 0;
178 $common_url_query = PMA_generate_common_url($db);
179 if ($num_tables) {
180 $num_tables_disp = $num_tables;
181 } else {
182 $num_tables_disp = '-';
185 // Get additional information about tables for tooltip
186 if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION >= 32303
187 && $num_tables
188 && (!$cfg['LeftFrameLight'] || $selected_db == $j)) {
189 $tooltip = array();
190 $tooltip_name = array();
191 $result = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
192 while ($tmp = PMA_mysql_fetch_array($result)) {
193 $tooltip_name[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '');
194 $tmp['Comment'] = ($cfg['ShowTooltipAliasTB'] ? $tmp['Name'] : $tmp['Comment']);
196 $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '')
197 . '(' . (isset($tmp['Rows']) ? $tmp['Rows'] : '0') . ' ' . $strRows . ')';
198 } // end while
199 } // end if
201 // garvin: Get comments from PMA comments table
202 $db_tooltip = '';
203 if ($cfg['ShowTooltip'] && $cfgRelation['commwork']) {
204 $tmp_db_tooltip = PMA_getComments($db);
205 if (is_array($tmp_db_tooltip)) {
206 $db_tooltip = implode(' ', $tmp_db_tooltip);
210 // No light mode -> displays the expandible/collapsible db list
211 if ($cfg['LeftFrameLight'] == FALSE) {
213 // Displays the database name
214 $on_mouse = (($cfg['LeftPointerColor'] == '') ? '' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el' . $j . '\', \'' . $cfg['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el' . $j . '\', \'' . $cfg['LeftBgColor'] . '\')}"');
216 echo "\n";
217 echo ' <div id="el' . $j . 'Parent" class="parent"' . $on_mouse . '>';
219 if (!empty($num_tables)) {
220 echo "\n";
222 <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}">
223 <img name="imEx" id="el<?php echo $j; ?>Img" src="images/plus.png" border="0" width="9" height="9" alt="+" /></a>
224 <?php
225 } else {
226 echo "\n";
228 <nobr><img name="imEx" src="images/minus.png" border="0" width="9" height="9" alt="-" />
229 <?php
231 echo "\n";
233 <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)}">
234 <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>
235 </div>
237 <div id="el<?php echo $j;?>Child" class="child" style="margin-bottom: 5px"<?php echo $on_mouse; ?>>
239 <?php
240 // Displays the list of tables from the current database
241 for ($t = 0; $t < $num_tables; $t++) {
242 $table = PMA_mysql_tablename($tables, $t);
243 $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
244 ? htmlspecialchars($tooltip_name[$table])
245 : '';
246 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
247 ? htmlspecialchars($tooltip[$table])
248 : '';
250 echo "\n";
252 $book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
254 <nobr><img src="images/spacer.gif" border="0" width="9" height="9" alt="" />
255 <a target="phpmain" href="sql.php3?<?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 . ': ' . htmlspecialchars($url_title); ?>">
256 <img src="images/browse.png" width="8" height="8" border="0" alt="<?php echo $strBrowse . ': ' . $url_title; ?>" /></a><bdo dir="<?php echo $text_dir; ?>">&nbsp;</bdo>
257 <a class="tblItem" id="tbl_<?php echo md5($table); ?>" title="<?php echo htmlspecialchars($url_title); ?>" target="phpmain" href="<?php echo $cfg['DefaultTabTable']; ?>?<?php echo $common_url_query; ?>&amp;table=<?php echo urlencode($table); ?>">
258 <?php echo ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)); ?></a></nobr><br />
259 <?php
260 } // end for $t (tables list)
261 echo "\n";
263 </div>
264 <?php
265 echo "\n";
269 // Light mode -> displays the select combo with databases names and the
270 // list of tables contained in the current database
271 else {
272 echo "\n";
274 // Builds the databases' names list
275 if (!empty($db_start) && $db == $db_start) {
276 // Gets the list of tables from the current database
277 for ($t = 0; $t < $num_tables; $t++) {
278 $table = PMA_mysql_tablename($tables, $t);
279 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
280 ? str_replace('"', '&quot;', $tooltip[$table])
281 : '';
282 $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
283 ? str_replace('"', '&quot;', $tooltip_name[$table])
284 : '';
286 $book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
288 $table_list .= ' <nobr><a target="phpmain" href="sql.php3?' . $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";
289 $table_list .= ' <img src="images/browse.png" width="8" height="8" border="0" alt="' . $strBrowse . ': ' . $url_title . '" title="' . $strBrowse . ': ' . htmlspecialchars($url_title) . '" /></a><bdo dir="' . $text_dir . '">&nbsp;</bdo>' . "\n";
290 if (PMA_USR_BROWSER_AGENT == 'IE') {
291 $table_list .= ' <span class="tblItem"><a class="tblItem" id="tbl_' . md5($table) . '" title="' . htmlspecialchars($url_title) . '" target="phpmain" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&amp;table=' . urlencode($table) . '">' . ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)) . '</a></span></nobr><br />' . "\n";
292 } else {
293 $table_list .= ' <a class="tblItem" id="tbl_' . md5($table) . '" title="' . htmlspecialchars($url_title) . '" target="phpmain" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&amp;table=' . urlencode($table) . '">' . ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)) . '</a></nobr><br />' . "\n";
295 } // end for $t (tables list)
297 if (!$table_list) {
298 $table_list = ' <br /><br />' . "\n"
299 . ' <div>' . $strNoTablesFound . '</div>' . "\n";
301 $selected = ' selected="selected"';
303 $table_list_header .= ' <a class="item" target="phpmain" href="' . $cfg['DefaultTabDatabase'] . '?' . $common_url_query . '">' . "\n";
304 $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";
305 } else {
306 $selected = '';
307 } // end if... else...
309 if (!empty($num_tables)) {
310 echo ' <option value="' . htmlspecialchars($db) . '"' . $selected . '>' . ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . ' (' . $num_tables . ')</option>' . "\n";
311 } else {
312 echo ' <option value="' . htmlspecialchars($db) . '"' . $selected . '>' . ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . ' (-)</option>' . "\n";
313 } // end if... else...
315 } // end if (light mode)
317 } // end for $i (db list)
319 // Light mode -> end of the select combo for databases and table list for
320 // the current database
321 if ($cfg['LeftFrameLight']) {
322 echo ' </select>' . "\n";
323 echo ' <noscript><input type="submit" name="Go" value="' . $strGo . '" /></noscript>' . "\n";
324 echo ' </form>' . "\n";
326 if (!$table_list) {
327 $table_list = ' <div>' . $strSelectADb . '</div>' . "\n";
330 // Displays the current database name and the list of tables it
331 // contains
332 echo "\n" . ' <hr noshade="noshade" />' . "\n\n";
333 echo $table_list_header;
334 echo $table_list;
335 echo "\n" . ' <hr noshade="noshade" />' . "\n";
338 // No light mode -> initialize some js variables for the
339 // expandible/collapsible stuff
340 else {
343 <!-- Arrange collapsible/expandable db list at startup -->
344 <script type="text/javascript" language="javascript1.2">
345 <!--
346 if (isNS4) {
347 firstEl = 'el1Parent';
348 firstInd = nsGetIndex(firstEl);
349 nsShowAll();
350 nsArrangeList();
352 var expandedDb = '<?php echo (empty($selected_db)) ? '' : 'el' . $selected_db . 'Child'; ?>';
353 //-->
354 </script>
355 <?php
357 } // end if... else... (light mode)
359 } // end if ($server > 1)
362 // Case where only one database has to be displayed
363 else if ($num_dbs == 1) {
364 $db = $dblist[0];
365 $tables = @PMA_mysql_list_tables($db);
366 $num_tables = ($tables) ? @mysql_numrows($tables) : 0;
367 $common_url_query = PMA_generate_common_url($db);
368 if ($num_tables) {
369 $num_tables_disp = $num_tables;
370 } else {
371 $num_tables_disp = '-';
374 // Get additional infomation about tables for tooltip
375 if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION >= 32303
376 && $num_tables) {
377 $tooltip = array();
378 $tooltip_name = array();
379 $result = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
380 while ($tmp = PMA_mysql_fetch_array($result)) {
381 $tooltip_name[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '');
382 $tmp['Comment'] = ($cfg['ShowTooltipAliasTB'] ? $tmp['Name'] : $tmp['Comment']);
384 $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '')
385 . '(' . (isset($tmp['Rows']) ? $tmp['Rows'] : '0') . ' ' . $strRows . ')';
386 } // end while
387 } // end if
389 // garvin: Get comments from PMA comments table
390 $db_tooltip = '';
391 if ($cfg['ShowTooltip'] && $cfgRelation['commwork']) {
392 $tmp_db_tooltip = PMA_getComments($db);
393 if (is_array($tmp_db_tooltip)) {
394 $db_tooltip = implode(' ', $tmp_db_tooltip);
398 // Displays the database name
399 echo "\n";
401 <div id="el2Parent" class="parent">
402 <nobr><a class="item" href="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>">
403 <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>
404 </div>
405 <div id="el2Child" class="child" style="margin-bottom: 5px">
406 <?php
407 // Displays the list of tables from the current database
408 for ($j = 0; $j < $num_tables; $j++) {
409 $table = PMA_mysql_tablename($tables, $j);
410 $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
411 ? str_replace('"', '&quot;', $tooltip_name[$table])
412 : '';
413 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
414 ? str_replace('"', '&quot;', $tooltip[$table])
415 : '';
416 $book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
418 echo "\n";
420 <nobr><a target="phpmain" href="sql.php3?<?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 . ': ' . htmlspecialchars($table); ?>">
421 <img src="images/browse.png" width="8" height="8" border="0" alt="<?php echo $strBrowse . ': ' . htmlspecialchars($table); ?>" /></a><bdo dir="<?php echo $text_dir; ?>">&nbsp;</bdo>
422 <a class="tblItem" id="tbl_<?php echo md5($table); ?>" title="<?php echo $url_title; ?>" target="phpmain" href="<?php echo $cfg['DefaultTabTable']; ?>?<?php echo $common_url_query; ?>&amp;table=<?php echo urlencode($table); ?>">
423 <?php echo ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)); ?></a></nobr><br />
424 <?php
425 } // end for $j (tables list)
426 echo "\n";
428 </div>
429 <?php
430 } // end if ($num_dbs == 1)
433 // Case where no database has to be displayed
434 else {
435 echo "\n";
436 echo '<p>' . $strNoDatabases . '</p>';
437 } // end if ($num_dbs == 0)
438 echo "\n";
441 </body>
442 </html>
444 <?php
446 * Close MySql connections
448 if (isset($dbh) && $dbh) {
449 @mysql_close($dbh);
451 if (isset($userlink) && $userlink) {
452 @mysql_close($userlink);
457 * Sends bufferized data
459 if (isset($cfg['OBGzip']) && $cfg['OBGzip']
460 && isset($ob_mode) && $ob_mode) {
461 PMA_outBufferPost($ob_mode);