update
[phpmyadmin/crack.git] / left.php3
blobdbab42d9fe23e56a6987610171c0591e499c3c52
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']; ?>">
169 <!-- Link to the welcome page -->
170 <div id="el1Parent" class="parent" style="margin-bottom: 5px">
171 <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>
172 </div>
175 <!-- Databases and tables list -->
176 <?php
177 // Don't display expansible/collapsible database info if:
178 // 1. $server == 0 (no server selected)
179 // This is the case when there are multiple servers and
180 // '$cfg['ServerDefault'] = 0' is set. In that case, we want the welcome
181 // screen to appear with no database info displayed.
182 // 2. there is only one database available (ie either only one database exists
183 // or $cfg['Servers']['only_db'] is defined and is not an array)
184 // In this case, the database should not be collapsible/expandable
185 if ($num_dbs > 1) {
187 // Light mode -> beginning of the select combo for databases
188 if ($cfg['LeftFrameLight']) {
189 echo ' <form method="post" action="index.php3" name="left" target="_parent">' . "\n";
190 echo ' <input type="hidden" name="lang" value="' . $lang . '" />' . "\n";
191 echo ' <input type="hidden" name="convcharset" value="' . $convcharset . '" />' . "\n";
192 echo ' <input type="hidden" name="server" value="' . $server . '" />' . "\n";
193 echo ' <select name="lightm_db" onchange="this.form.submit()">' . "\n";
194 echo ' <option value="">(' . $strDatabases . ') ...</option>' . "\n";
195 $table_list = '';
196 $table_list_header = '';
197 $db_name = '';
200 $selected_db = 0;
202 // Gets the tables list per database
203 for ($i = 0; $i < $num_dbs; $i++) {
204 $db = $dblist[$i];
205 $j = $i + 2;
206 if (!empty($db_start) && $db == $db_start) {
207 $selected_db = $j;
209 $tables = @PMA_mysql_list_tables($db);
210 $num_tables = ($tables) ? @mysql_numrows($tables) : 0;
211 $common_url_query = 'lang=' . $lang
212 . '&amp;convcharset=' . $convcharset
213 . '&amp;server=' . $server
214 . '&amp;db=' . urlencode($db);
215 if ($num_tables) {
216 $num_tables_disp = $num_tables;
217 } else {
218 $num_tables_disp = '-';
221 // Get additional infomation about tables for tooltip
222 if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION >= 32303
223 && $num_tables
224 && (!$cfg['LeftFrameLight'] || $selected_db == $j)) {
225 $tooltip = array();
226 $result = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
227 while ($tmp = PMA_mysql_fetch_array($result)) {
228 $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '')
229 . '(' . (isset($tmp['Rows']) ? $tmp['Rows'] : '0') . ' ' . $strRows . ')';
230 } // end while
231 } // end if
233 // No light mode -> displays the expandible/collapsible db list
234 if ($cfg['LeftFrameLight'] == FALSE) {
236 // Displays the database name
237 $on_mouse = (($cfg['LeftPointerColor'] == '') ? '' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el' . $j . '\', \'' . $cfg['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el' . $j . '\', \'' . $cfg['LeftBgColor'] . '\')}"');
239 echo "\n";
240 echo ' <div id="el' . $j . 'Parent" class="parent"' . $on_mouse . '>';
242 if (!empty($num_tables)) {
243 echo "\n";
245 <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}">
246 <img name="imEx" id="el<?php echo $j; ?>Img" src="images/plus.gif" border="0" width="9" height="9" alt="+" /></a>
247 <?php
248 } else {
249 echo "\n";
251 <nobr><img name="imEx" src="images/minus.gif" border="0" width="9" height="9" alt="-" />
252 <?php
254 echo "\n";
256 <a class="item" href="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>" onclick="if (capable) {expandBase('el<?php echo $j; ?>', false)}">
257 <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>
258 </div>
260 <div id="el<?php echo $j;?>Child" class="child" style="margin-bottom: 5px"<?php echo $on_mouse; ?>>
262 <?php
263 // Displays the list of tables from the current database
264 for ($t = 0; $t < $num_tables; $t++) {
265 $table = PMA_mysql_tablename($tables, $t);
266 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
267 ? str_replace('"', '&quot;', $tooltip[$table])
268 : '';
269 echo "\n";
271 <nobr><img src="images/spacer.gif" border="0" width="9" height="9" alt="" />
272 <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']; ?>">
273 <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>
274 <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); ?>">
275 <?php echo $table; ?></a></nobr><br />
276 <?php
277 } // end for $t (tables list)
278 echo "\n";
280 </div>
281 <?php
282 echo "\n";
286 // Light mode -> displays the select combo with databases names and the
287 // list of tables contained in the current database
288 else {
289 echo "\n";
291 // Builds the databases' names list
292 if (!empty($db_start) && $db == $db_start) {
293 // Gets the list of tables from the current database
294 for ($t = 0; $t < $num_tables; $t++) {
295 $table = PMA_mysql_tablename($tables, $t);
296 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
297 ? str_replace('"', '&quot;', $tooltip[$table])
298 : '';
299 $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";
300 $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";
301 if (PMA_USR_BROWSER_AGENT == 'IE') {
302 $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";
303 } else {
304 $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";
306 } // end for $t (tables list)
308 if (!$table_list) {
309 $table_list = ' <br /><br />' . "\n"
310 . ' <div>' . $strNoTablesFound . '</div>' . "\n";
312 $selected = ' selected="selected"';
314 $table_list_header .= ' <a class="item" target="phpmain" href="' . $cfg['DefaultTabDatabase'] . '?' . $common_url_query . '">' . "\n";
315 $table_list_header .= ' <span class="heada"><b>' . $db . '</b><bdo dir="' . $text_dir . '">&nbsp;&nbsp;</bdo></span></a><br />' . "\n\n";
316 } else {
317 $selected = '';
318 } // end if... else...
320 if (!empty($num_tables)) {
321 echo ' <option value="' . urlencode($db) . '"' . $selected . '>' . $db . ' (' . $num_tables . ')</option>' . "\n";
322 } else {
323 echo ' <option value="' . urlencode($db) . '"' . $selected . '>' . $db . ' (-)</option>' . "\n";
324 } // end if... else...
326 } // end if (light mode)
328 } // end for $i (db list)
330 // Light mode -> end of the select combo for databases and table list for
331 // the current database
332 if ($cfg['LeftFrameLight']) {
333 echo ' </select>' . "\n";
334 echo ' <noscript><input type="submit" name="Go" value="' . $strGo . '" /></noscript>' . "\n";
335 echo ' </form>' . "\n";
337 if (!$table_list) {
338 $table_list = ' <div>' . $strSelectADb . '</div>' . "\n";
341 // Displays the current database name and the list of tables it
342 // contains
343 echo "\n" . ' <hr noshade="noshade" />' . "\n\n";
344 echo $table_list_header;
345 echo $table_list;
346 echo "\n" . ' <hr noshade="noshade" />' . "\n";
350 // No light mode -> initialize some js variables for the
351 // expandible/collapsible stuff
352 else {
355 <!-- Arrange collapsible/expandable db list at startup -->
356 <script type="text/javascript" language="javascript1.2">
357 <!--
358 if (isNS4) {
359 firstEl = 'el1Parent';
360 firstInd = nsGetIndex(firstEl);
361 nsShowAll();
362 nsArrangeList();
364 var expandedDb = '<?php echo (empty($selected_db)) ? '' : 'el' . $selected_db . 'Child'; ?>';
365 //-->
366 </script>
367 <?php
369 } // end if... else... (light mode)
371 } // end if ($server > 1)
374 // Case where only one database has to be displayed
375 else if ($num_dbs == 1) {
376 $db = $dblist[0];
377 $tables = @PMA_mysql_list_tables($db);
378 $num_tables = ($tables) ? @mysql_numrows($tables) : 0;
379 $common_url_query = 'lang=' . $lang
380 . '&amp;server=' . $server
381 . '&amp;db=' . urlencode($db);
382 if ($num_tables) {
383 $num_tables_disp = $num_tables;
384 } else {
385 $num_tables_disp = '-';
388 // Get additional infomation about tables for tooltip
389 if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION >= 32303
390 && $num_tables) {
391 $tooltip = array();
392 $result = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
393 while ($tmp = PMA_mysql_fetch_array($result)) {
394 $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '')
395 . '(' . (isset($tmp['Rows']) ? $tmp['Rows'] : '0') . ' ' . $strRows . ')';
396 } // end while
397 } // end if
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; ?><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 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
412 ? str_replace('"', '&quot;', $tooltip[$table])
413 : '';
414 echo "\n";
416 <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']; ?>">
417 <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>
418 <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); ?>">
419 <?php echo $table; ?></a></nobr><br />
420 <?php
421 } // end for $j (tables list)
422 echo "\n";
424 </div>
425 <?php
426 } // end if ($num_dbs == 1)
429 // Case where no database has to be displayed
430 else {
431 echo "\n";
432 echo '<p>' . $strNoDatabases . '</p>';
433 } // end if ($num_dbs == 0)
434 echo "\n";
437 </body>
438 </html>
440 <?php
442 * Close MySql connections
444 if (isset($dbh) && $dbh) {
445 @mysql_close($dbh);
447 if (isset($userlink) && $userlink) {
448 @mysql_close($userlink);
453 * Sends bufferized data
455 if (isset($cfg['OBGzip']) && $cfg['OBGzip']
456 && isset($ob_mode) && $ob_mode) {
457 PMA_outBufferPost($ob_mode);