updates
[phpmyadmin/crack.git] / left.php3
blob124b3048a8209b123215e9adcb8765ae54f7d478
1 <?php
2 /* $Id$ */
5 /**
6 * Gets the variables sent to this script, retains the db name that may have
7 * been defined as startup option and include a core library
8 */
9 require('./libraries/grab_globals.lib.php3');
10 if (!empty($db)) {
11 $db_start = $db;
15 /**
16 * Gets a core script and starts output buffering work
18 require('./libraries/common.lib.php3');
19 require('./libraries/ob.lib.php3');
20 if ($cfg['OBGzip']) {
21 $ob_mode = PMA_outBufferModeGet();
22 if ($ob_mode) {
23 PMA_outBufferPre($ob_mode);
28 /**
29 * Get the list and number of available databases.
30 * Skipped if no server selected: in this case no database should be displayed
31 * before the user choose among available ones at the welcome screen.
33 if ($server > 0) {
34 PMA_availableDatabases(); // this function is defined in "common.lib.php3"
35 } else {
36 $num_dbs = 0;
40 /**
41 * Send http headers
43 // Don't use cache (required for Opera)
44 $now = gmdate('D, d M Y H:i:s') . ' GMT';
45 header('Expires: ' . $now);
46 header('Last-Modified: ' . $now);
47 header('Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
48 header('Pragma: no-cache'); // HTTP/1.0
49 // Define the charset to be used
50 header('Content-Type: text/html; charset=' . $charset);
53 /**
54 * Displays the frame
56 // Gets the font sizes to use
57 PMA_setFontSizes();
59 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
60 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
61 <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; ?>">
63 <head>
64 <title>phpMyAdmin</title>
65 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset; ?>" />
66 <base<?php if (!empty($cfg['PmaAbsoluteUri'])) echo ' href="' . $cfg['PmaAbsoluteUri'] . '"'; ?> target="phpmain" />
67 <?php
68 // Expandable/collapsible databases list is only used if there is more than one
69 // database to display
70 if ($num_dbs > 1 && !$cfg['LeftFrameLight']) {
71 echo "\n";
73 <!-- Collapsible tables list scripts -->
74 <script type="text/javascript" language="javascript">
75 <!--
76 var isDOM = (typeof(document.getElementsByTagName) != 'undefined'
77 && typeof(document.createElement) != 'undefined')
78 ? 1 : 0;
79 var isIE4 = (typeof(document.all) != 'undefined'
80 && parseInt(navigator.appVersion) >= 4)
81 ? 1 : 0;
82 var isNS4 = (typeof(document.layers) != 'undefined')
83 ? 1 : 0;
84 var capable = (isDOM || isIE4 || isNS4)
85 ? 1 : 0;
86 // Uggly fix for Opera and Konqueror 2.2 that are half DOM compliant
87 if (capable) {
88 if (typeof(window.opera) != 'undefined') {
89 capable = 0;
91 else if (typeof(navigator.userAgent) != 'undefined') {
92 var browserName = ' ' + navigator.userAgent.toLowerCase();
93 if (browserName.indexOf('konqueror') > 0) {
94 capable = 0;
96 } // end if... else if...
97 } // end if
98 var fontFamily = '<?php echo $left_font_family; ?>';
99 var fontSize = '<?php echo $font_size; ?>';
100 var fontBig = '<?php echo $font_bigger; ?>';
101 var fontSmall = '<?php echo $font_smaller; ?>';
102 var isServer = <?php echo ($server > 0) ? 'true' : 'false'; ?>;
103 //-->
104 </script>
105 <script src="libraries/left.js" type="text/javascript" language="javascript1.2"></script>
106 <noscript>
107 <style type="text/css">
108 <!--
109 div {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>; color: #000000}
110 .heada {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>; color: #000000}
111 .headaCnt {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_smaller; ?>; color: #000000}
112 .parent {font-family: <?php echo $left_font_family; ?>; color: #000000; text-decoration: none}
113 .child {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_smaller; ?>; color: #333399; text-decoration: none}
114 .item, .item:active, .item:hover, .tblItem, .tblItem:active {color: #333399; text-decoration: none}
115 .tblItem:hover {color: #FF0000; text-decoration: underline}
116 //-->
117 </style>
118 </noscript>
120 <style type="text/css">
121 <!--
122 body {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>}
123 //-->
124 </style>
125 <?php
126 } // end if ($num_dbs > 1)
128 else if ($num_dbs == 1) {
129 echo "\n";
131 <style type="text/css">
132 <!--
133 body {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>}
134 div {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>; color: #000000}
135 .heada {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>; color: #000000}
136 .headaCnt {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_smaller; ?>; color: #000000}
137 .parent {font-family: <?php echo $left_font_family; ?>; color: #000000; text-decoration: none}
138 .child {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_smaller; ?>; color: #333399; text-decoration: none}
139 .item, .item:active, .item:hover, .tblItem, .tblItem:active {font-size: <?php echo $font_smaller; ?>; color: #333399; text-decoration: none}
140 .tblItem:hover {color: #FF0000; text-decoration: underline}
141 //-->
142 </style>
143 <?php
144 } // end if ($num_dbs == 1)
146 else {
147 echo "\n";
149 <style type="text/css">
150 <!--
151 body {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>}
152 div {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>; color: #000000}
153 input {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>}
154 select {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>; background-color: #ffffff; color: #000000}
155 .heada {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>; color: #000000}
156 .parent {font-family: <?php echo $left_font_family; ?>; color: #000000; text-decoration: none}
157 .item, .item:active, .item:hover, .tblItem, .tblItem:active {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_smaller; ?>; color: #333399; text-decoration: none}
158 .tblItem:hover {color: #FF0000; text-decoration: underline}
159 //-->
160 </style>
161 <?php
162 } // end if ($num_dbs < 1)
164 echo "\n";
166 </head>
168 <body bgcolor="<?php echo $cfg['LeftBgColor']; ?>">
170 <?php
171 if ($cfg['LeftDisplayLogo']) {
173 <!-- phpMyAdmin logo -->
174 <a href="http://www.phpmyadmin.net" target="_blank"><img src="./images/pma_logo.png" width="88" height="31" border="0" alt="phpMyAdmin" /></a>
175 <?php
177 echo "\n";
179 <!-- Link to the welcome page -->
180 <div id="el1Parent" class="parent" style="margin-bottom: 5px">
181 <nobr><a class="item" href="main.php3?lang=<?php echo $lang; ?>&amp;convcharset=<?php echo $convcharset; ?>&amp;server=<?php echo $server; ?>"><span class="heada"><b><?php echo $strHome; ?></b></span></a></nobr>
182 </div>
185 <!-- Databases and tables list -->
186 <?php
187 // Don't display expansible/collapsible database info if:
188 // 1. $server == 0 (no server selected)
189 // This is the case when there are multiple servers and
190 // '$cfg['ServerDefault'] = 0' is set. In that case, we want the welcome
191 // screen to appear with no database info displayed.
192 // 2. there is only one database available (ie either only one database exists
193 // or $cfg['Servers']['only_db'] is defined and is not an array)
194 // In this case, the database should not be collapsible/expandable
195 if ($num_dbs > 1) {
197 // Light mode -> beginning of the select combo for databases
198 if ($cfg['LeftFrameLight']) {
199 echo ' <form method="post" action="index.php3" name="left" target="_parent">' . "\n";
200 echo ' <input type="hidden" name="lang" value="' . $lang . '" />' . "\n";
201 echo ' <input type="hidden" name="convcharset" value="' . $convcharset . '" />' . "\n";
202 echo ' <input type="hidden" name="server" value="' . $server . '" />' . "\n";
203 echo ' <select name="lightm_db" onchange="this.form.submit()">' . "\n";
204 echo ' <option value="">(' . $strDatabases . ') ...</option>' . "\n";
205 $table_list = '';
206 $table_list_header = '';
207 $db_name = '';
210 $selected_db = 0;
212 // Gets the tables list per database
213 for ($i = 0; $i < $num_dbs; $i++) {
214 $db = $dblist[$i];
215 $j = $i + 2;
216 if (!empty($db_start) && $db == $db_start) {
217 $selected_db = $j;
219 $tables = @PMA_mysql_list_tables($db);
220 $num_tables = ($tables) ? @mysql_numrows($tables) : 0;
221 $common_url_query = 'lang=' . $lang
222 . '&amp;convcharset=' . $convcharset
223 . '&amp;server=' . $server
224 . '&amp;db=' . urlencode($db);
225 if ($num_tables) {
226 $num_tables_disp = $num_tables;
227 } else {
228 $num_tables_disp = '-';
231 // Get additional infomation about tables for tooltip
232 if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION >= 32303
233 && $num_tables
234 && (!$cfg['LeftFrameLight'] || $selected_db == $j)) {
235 $tooltip = array();
236 $result = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
237 while ($tmp = PMA_mysql_fetch_array($result)) {
238 $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '')
239 . '(' . (isset($tmp['Rows']) ? $tmp['Rows'] : '0') . ' ' . $strRows . ')';
240 } // end while
241 } // end if
243 // No light mode -> displays the expandible/collapsible db list
244 if ($cfg['LeftFrameLight'] == FALSE) {
246 // Displays the database name
247 $on_mouse = (($cfg['LeftPointerColor'] == '') ? '' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el' . $j . '\', \'' . $cfg['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el' . $j . '\', \'' . $cfg['LeftBgColor'] . '\')}"');
249 echo "\n";
250 echo ' <div id="el' . $j . 'Parent" class="parent"' . $on_mouse . '>';
252 if (!empty($num_tables)) {
253 echo "\n";
255 <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}">
256 <img name="imEx" id="el<?php echo $j; ?>Img" src="images/plus.gif" border="0" width="9" height="9" alt="+" /></a>
257 <?php
258 } else {
259 echo "\n";
261 <nobr><img name="imEx" src="images/minus.gif" border="0" width="9" height="9" alt="-" />
262 <?php
264 echo "\n";
266 <a class="item" href="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>" onclick="if (capable) {expandBase('el<?php echo $j; ?>', false)}">
267 <span class="heada"><?php echo $db; ?><bdo dir="<?php echo($text_dir); ?>">&nbsp;&nbsp;</bdo></span><span class="headaCnt">(<?php echo $num_tables_disp; ?>)</span></a></nobr>
268 </div>
270 <div id="el<?php echo $j;?>Child" class="child" style="margin-bottom: 5px"<?php echo $on_mouse; ?>>
272 <?php
273 // Displays the list of tables from the current database
274 for ($t = 0; $t < $num_tables; $t++) {
275 $table = PMA_mysql_tablename($tables, $t);
276 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
277 ? str_replace('"', '&quot;', $tooltip[$table])
278 : '';
279 echo "\n";
281 <nobr><img src="images/spacer.gif" border="0" width="9" height="9" alt="" />
282 <a target="phpmain" href="sql.php3?<?php echo $common_url_query; ?>&amp;table=<?php echo urlencode($table); ?>&amp;sql_query=<?php echo urlencode('SELECT * FROM ' . PMA_backquote($table)); ?>&amp;pos=0&amp;goto=<?php echo $cfg['DefaultTabTable']; ?>">
283 <img src="images/browse.gif" width="8" height="8" border="0" alt="<?php echo "$strBrowse: $table"; ?>" title="<?php echo "$strBrowse: $table"; ?>" /></a><bdo dir="<?php echo $text_dir; ?>">&nbsp;</bdo>
284 <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); ?>">
285 <?php echo $table; ?></a></nobr><br />
286 <?php
287 } // end for $t (tables list)
288 echo "\n";
290 </div>
291 <?php
292 echo "\n";
296 // Light mode -> displays the select combo with databases names and the
297 // list of tables contained in the current database
298 else {
299 echo "\n";
301 // Builds the databases' names list
302 if (!empty($db_start) && $db == $db_start) {
303 // Gets the list of tables from the current database
304 for ($t = 0; $t < $num_tables; $t++) {
305 $table = PMA_mysql_tablename($tables, $t);
306 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
307 ? str_replace('"', '&quot;', $tooltip[$table])
308 : '';
309 $table_list .= ' <nobr><a target="phpmain" href="sql.php3?' . $common_url_query . '&amp;table=' . urlencode($table) . '&amp;sql_query=' . urlencode('SELECT * FROM ' . PMA_backquote($table)) . '&amp;pos=0&amp;goto=' . $cfg['DefaultTabTable'] . '">' . "\n";
310 $table_list .= ' <img src="images/browse.gif" width="8" height="8" border="0" alt="' . $strBrowse . ': ' . $table . '" title="' . $strBrowse . ': ' . $table . '" /></a><bdo dir="' . $text_dir . '">&nbsp;</bdo>' . "\n";
311 if (PMA_USR_BROWSER_AGENT == 'IE') {
312 $table_list .= ' <span class="tblItem"><a class="tblItem" id="tbl_' . md5($table) . '" title="' . $url_title . '" target="phpmain" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&amp;table=' . urlencode($table) . '">' . $table . '</a></span></nobr><br />' . "\n";
313 } else {
314 $table_list .= ' <a class="tblItem" id="tbl_' . md5($table) . '" title="' . $url_title . '" target="phpmain" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&amp;table=' . urlencode($table) . '">' . $table . '</a></nobr><br />' . "\n";
316 } // end for $t (tables list)
318 if (!$table_list) {
319 $table_list = ' <br /><br />' . "\n"
320 . ' <div>' . $strNoTablesFound . '</div>' . "\n";
322 $selected = ' selected="selected"';
324 $table_list_header .= ' <a class="item" target="phpmain" href="' . $cfg['DefaultTabDatabase'] . '?' . $common_url_query . '">' . "\n";
325 $table_list_header .= ' <span class="heada"><b>' . $db . '</b><bdo dir="' . $text_dir . '">&nbsp;&nbsp;</bdo></span></a><br />' . "\n\n";
326 } else {
327 $selected = '';
328 } // end if... else...
330 if (!empty($num_tables)) {
331 echo ' <option value="' . urlencode($db) . '"' . $selected . '>' . $db . ' (' . $num_tables . ')</option>' . "\n";
332 } else {
333 echo ' <option value="' . urlencode($db) . '"' . $selected . '>' . $db . ' (-)</option>' . "\n";
334 } // end if... else...
336 } // end if (light mode)
338 } // end for $i (db list)
340 // Light mode -> end of the select combo for databases and table list for
341 // the current database
342 if ($cfg['LeftFrameLight']) {
343 echo ' </select>' . "\n";
344 echo ' <noscript><input type="submit" name="Go" value="' . $strGo . '" /></noscript>' . "\n";
345 echo ' </form>' . "\n";
347 if (!$table_list) {
348 $table_list = ' <div>' . $strSelectADb . '</div>' . "\n";
351 // Displays the current database name and the list of tables it
352 // contains
353 echo "\n" . ' <hr noshade="noshade" />' . "\n\n";
354 echo $table_list_header;
355 echo $table_list;
356 echo "\n" . ' <hr noshade="noshade" />' . "\n";
359 // No light mode -> initialize some js variables for the
360 // expandible/collapsible stuff
361 else {
364 <!-- Arrange collapsible/expandable db list at startup -->
365 <script type="text/javascript" language="javascript1.2">
366 <!--
367 if (isNS4) {
368 firstEl = 'el1Parent';
369 firstInd = nsGetIndex(firstEl);
370 nsShowAll();
371 nsArrangeList();
373 var expandedDb = '<?php echo (empty($selected_db)) ? '' : 'el' . $selected_db . 'Child'; ?>';
374 //-->
375 </script>
376 <?php
378 } // end if... else... (light mode)
380 } // end if ($server > 1)
383 // Case where only one database has to be displayed
384 else if ($num_dbs == 1) {
385 $db = $dblist[0];
386 $tables = @PMA_mysql_list_tables($db);
387 $num_tables = ($tables) ? @mysql_numrows($tables) : 0;
388 $common_url_query = 'lang=' . $lang
389 . '&amp;server=' . $server
390 . '&amp;db=' . urlencode($db);
391 if ($num_tables) {
392 $num_tables_disp = $num_tables;
393 } else {
394 $num_tables_disp = '-';
397 // Get additional infomation about tables for tooltip
398 if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION >= 32303
399 && $num_tables) {
400 $tooltip = array();
401 $result = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
402 while ($tmp = PMA_mysql_fetch_array($result)) {
403 $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '')
404 . '(' . (isset($tmp['Rows']) ? $tmp['Rows'] : '0') . ' ' . $strRows . ')';
405 } // end while
406 } // end if
408 // Displays the database name
409 echo "\n";
411 <div id="el2Parent" class="parent">
412 <nobr><a class="item" href="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>">
413 <span class="heada"><?php echo $db; ?><bdo dir="<?php echo($text_dir); ?>">&nbsp;&nbsp;</bdo></span><span class="headaCnt">(<?php echo $num_tables_disp; ?>)</span></a></nobr>
414 </div>
415 <div id="el2Child" class="child" style="margin-bottom: 5px">
416 <?php
417 // Displays the list of tables from the current database
418 for ($j = 0; $j < $num_tables; $j++) {
419 $table = PMA_mysql_tablename($tables, $j);
420 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
421 ? str_replace('"', '&quot;', $tooltip[$table])
422 : '';
423 echo "\n";
425 <nobr><a target="phpmain" href="sql.php3?<?php echo $common_url_query; ?>&amp;table=<?php echo urlencode($table); ?>&amp;sql_query=<?php echo urlencode('SELECT * FROM ' . PMA_backquote($table)); ?>&amp;pos=0&amp;goto=<?php echo $cfg['DefaultTabTable']; ?>">
426 <img src="images/browse.gif" width="8" height="8" border="0" alt="<?php echo "$strBrowse: $table"; ?>" title="<?php echo "$strBrowse: $table"; ?>" /></a><bdo dir="<?php echo $text_dir; ?>">&nbsp;</bdo>
427 <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); ?>">
428 <?php echo $table; ?></a></nobr><br />
429 <?php
430 } // end for $j (tables list)
431 echo "\n";
433 </div>
434 <?php
435 } // end if ($num_dbs == 1)
438 // Case where no database has to be displayed
439 else {
440 echo "\n";
441 echo '<p>' . $strNoDatabases . '</p>';
442 } // end if ($num_dbs == 0)
443 echo "\n";
446 </body>
447 </html>
449 <?php
451 * Close MySql connections
453 if (isset($dbh) && $dbh) {
454 @mysql_close($dbh);
456 if (isset($userlink) && $userlink) {
457 @mysql_close($userlink);
462 * Sends bufferized data
464 if (isset($cfg['OBGzip']) && $cfg['OBGzip']
465 && isset($ob_mode) && $ob_mode) {
466 PMA_outBufferPost($ob_mode);