uninitialized var
[phpmyadmin/crack.git] / left.php3
blob86402105f1bb1c67caa0a6c58c70257e5cb97ee2
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<?php echo $hash; ?>" />
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<?php echo $hash; ?>" 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); ?>"
258 target="phpmain<?php echo $hash; ?>" href="<?php echo $cfg['DefaultTabTable']; ?>?<?php echo $common_url_query; ?>&amp;table=<?php echo urlencode($table); ?>">
259 <?php echo ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)); ?></a></nobr><br />
260 <?php
261 } // end for $t (tables list)
262 echo "\n";
264 </div>
265 <?php
266 echo "\n";
270 // Light mode -> displays the select combo with databases names and the
271 // list of tables contained in the current database
272 else {
273 echo "\n";
275 // Builds the databases' names list
276 if (!empty($db_start) && $db == $db_start) {
277 // Gets the list of tables from the current database
278 for ($t = 0; $t < $num_tables; $t++) {
279 $table = PMA_mysql_tablename($tables, $t);
280 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
281 ? str_replace('"', '&quot;', $tooltip[$table])
282 : '';
283 $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
284 ? str_replace('"', '&quot;', $tooltip_name[$table])
285 : '';
287 $book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
289 $table_list .= ' <nobr><a target="phpmain' . $hash . '" 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";
290 $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";
291 if (PMA_USR_BROWSER_AGENT == 'IE') {
292 $table_list .= ' <span class="tblItem"><a class="tblItem" id="tbl_' . md5($table) . '" title="' . htmlspecialchars($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";
293 } else {
294 $table_list .= ' <a class="tblItem" id="tbl_' . md5($table) . '" title="' . htmlspecialchars($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";
296 } // end for $t (tables list)
298 if (!$table_list) {
299 $table_list = ' <br /><br />' . "\n"
300 . ' <div>' . $strNoTablesFound . '</div>' . "\n";
302 $selected = ' selected="selected"';
304 $table_list_header .= ' <a class="item" target="phpmain' . $hash . '" href="' . $cfg['DefaultTabDatabase'] . '?' . $common_url_query . '">' . "\n";
305 $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";
306 } else {
307 $selected = '';
308 } // end if... else...
310 if (!empty($num_tables)) {
311 echo ' <option value="' . htmlspecialchars($db) . '"' . $selected . '>' . ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . ' (' . $num_tables . ')</option>' . "\n";
312 } else {
313 echo ' <option value="' . htmlspecialchars($db) . '"' . $selected . '>' . ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . ' (-)</option>' . "\n";
314 } // end if... else...
316 } // end if (light mode)
318 } // end for $i (db list)
320 // Light mode -> end of the select combo for databases and table list for
321 // the current database
322 if ($cfg['LeftFrameLight']) {
323 echo ' </select>' . "\n";
324 echo ' <noscript><input type="submit" name="Go" value="' . $strGo . '" /></noscript>' . "\n";
325 echo ' </form>' . "\n";
327 if (!$table_list) {
328 $table_list = ' <div>' . $strSelectADb . '</div>' . "\n";
331 // Displays the current database name and the list of tables it
332 // contains
333 echo "\n" . ' <hr noshade="noshade" />' . "\n\n";
334 echo $table_list_header;
335 echo $table_list;
336 echo "\n" . ' <hr noshade="noshade" />' . "\n";
339 // No light mode -> initialize some js variables for the
340 // expandible/collapsible stuff
341 else {
344 <!-- Arrange collapsible/expandable db list at startup -->
345 <script type="text/javascript" language="javascript1.2">
346 <!--
347 if (isNS4) {
348 firstEl = 'el1Parent';
349 firstInd = nsGetIndex(firstEl);
350 nsShowAll();
351 nsArrangeList();
353 var expandedDb = '<?php echo (empty($selected_db)) ? '' : 'el' . $selected_db . 'Child'; ?>';
354 //-->
355 </script>
356 <?php
358 } // end if... else... (light mode)
360 } // end if ($server > 1)
363 // Case where only one database has to be displayed
364 else if ($num_dbs == 1) {
365 $db = $dblist[0];
366 $tables = @PMA_mysql_list_tables($db);
367 $num_tables = ($tables) ? @mysql_numrows($tables) : 0;
368 $common_url_query = PMA_generate_common_url($db);
369 if ($num_tables) {
370 $num_tables_disp = $num_tables;
371 } else {
372 $num_tables_disp = '-';
375 // Get additional infomation about tables for tooltip
376 if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION >= 32303
377 && $num_tables) {
378 $tooltip = array();
379 $tooltip_name = array();
380 $result = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
381 while ($tmp = PMA_mysql_fetch_array($result)) {
382 $tooltip_name[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '');
383 $tmp['Comment'] = ($cfg['ShowTooltipAliasTB'] ? $tmp['Name'] : $tmp['Comment']);
385 $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '')
386 . '(' . (isset($tmp['Rows']) ? $tmp['Rows'] : '0') . ' ' . $strRows . ')';
387 } // end while
388 } // end if
390 // garvin: Get comments from PMA comments table
391 $db_tooltip = '';
392 if ($cfg['ShowTooltip'] && $cfgRelation['commwork']) {
393 $tmp_db_tooltip = PMA_getComments($db);
394 if (is_array($tmp_db_tooltip)) {
395 $db_tooltip = implode(' ', $tmp_db_tooltip);
399 // Displays the database name
400 echo "\n";
402 <div id="el2Parent" class="parent">
403 <nobr><a class="item" href="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>">
404 <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>
405 </div>
406 <div id="el2Child" class="child" style="margin-bottom: 5px">
407 <?php
408 // Displays the list of tables from the current database
409 for ($j = 0; $j < $num_tables; $j++) {
410 $table = PMA_mysql_tablename($tables, $j);
411 $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
412 ? str_replace('"', '&quot;', $tooltip_name[$table])
413 : '';
414 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
415 ? str_replace('"', '&quot;', $tooltip[$table])
416 : '';
417 $book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
419 echo "\n";
421 <nobr><a target="phpmain<?php echo $hash; ?>" 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); ?>">
422 <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>
423 <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); ?>">
424 <?php echo ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)); ?></a></nobr><br />
425 <?php
426 } // end for $j (tables list)
427 echo "\n";
429 </div>
430 <?php
431 } // end if ($num_dbs == 1)
434 // Case where no database has to be displayed
435 else {
436 echo "\n";
437 echo '<p>' . $strNoDatabases . '</p>';
438 } // end if ($num_dbs == 0)
439 echo "\n";
442 <form name="hashform" action="left.php3">
443 <input type="hidden" name="hash" value="<?php echo $hash; ?>">
444 </form>
445 </body>
446 </html>
448 <?php
450 * Close MySql connections
452 if (isset($dbh) && $dbh) {
453 @mysql_close($dbh);
455 if (isset($userlink) && $userlink) {
456 @mysql_close($userlink);
461 * Sends bufferized data
463 if (isset($cfg['OBGzip']) && $cfg['OBGzip']
464 && isset($ob_mode) && $ob_mode) {
465 PMA_outBufferPost($ob_mode);