no priv messages for db creation
[phpmyadmin/crack.git] / left.php3
blob9670aa63c8c82bb9696da803f1e2bbf40f642838
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);
29 /**
30 * Get the list and number of available databases.
31 * Skipped if no server selected: in this case no database should be displayed
32 * before the user choose among available ones at the welcome screen.
34 if ($server > 0) {
35 PMA_availableDatabases(); // this function is defined in "common.lib.php3"
36 } else {
37 $num_dbs = 0;
41 /**
42 * Send http headers
44 // Don't use cache (required for Opera)
45 $now = gmdate('D, d M Y H:i:s') . ' GMT';
46 header('Expires: ' . $now);
47 header('Last-Modified: ' . $now);
48 header('Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
49 header('Pragma: no-cache'); // HTTP/1.0
50 // Define the charset to be used
51 header('Content-Type: text/html; charset=' . $charset);
54 /**
55 * Displays the frame
57 // Gets the font sizes to use
58 PMA_setFontSizes();
60 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
61 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
62 <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; ?>">
64 <head>
65 <title>phpMyAdmin</title>
66 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset; ?>" />
67 <base<?php if (!empty($cfg['PmaAbsoluteUri'])) echo ' href="' . $cfg['PmaAbsoluteUri'] . '"'; ?> target="phpmain" />
68 <?php
69 // Expandable/collapsible databases list is only used if there is more than one
70 // database to display
71 if ($num_dbs > 1 && !$cfg['LeftFrameLight']) {
72 echo "\n";
74 <!-- Collapsible tables list scripts -->
75 <script type="text/javascript" language="javascript">
76 <!--
77 var isDOM = (typeof(document.getElementsByTagName) != 'undefined'
78 && typeof(document.createElement) != 'undefined')
79 ? 1 : 0;
80 var isIE4 = (typeof(document.all) != 'undefined'
81 && parseInt(navigator.appVersion) >= 4)
82 ? 1 : 0;
83 var isNS4 = (typeof(document.layers) != 'undefined')
84 ? 1 : 0;
85 var capable = (isDOM || isIE4 || isNS4)
86 ? 1 : 0;
87 // Uggly fix for Opera and Konqueror 2.2 that are half DOM compliant
88 if (capable) {
89 if (typeof(window.opera) != 'undefined') {
90 capable = 0;
92 else if (typeof(navigator.userAgent) != 'undefined') {
93 var browserName = ' ' + navigator.userAgent.toLowerCase();
94 if (browserName.indexOf('konqueror') > 0) {
95 capable = 0;
97 } // end if... else if...
98 } // end if
99 var fontFamily = '<?php echo $left_font_family; ?>';
100 var fontSize = '<?php echo $font_size; ?>';
101 var fontBig = '<?php echo $font_bigger; ?>';
102 var fontSmall = '<?php echo $font_smaller; ?>';
103 var isServer = <?php echo ($server > 0) ? 'true' : 'false'; ?>;
104 //-->
105 </script>
106 <script src="libraries/left.js" type="text/javascript" language="javascript1.2"></script>
107 <noscript>
108 <style type="text/css">
109 <!--
110 div {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>; color: #000000}
111 .heada {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>; color: #000000}
112 .headaCnt {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_smaller; ?>; color: #000000}
113 .parent {font-family: <?php echo $left_font_family; ?>; color: #000000; text-decoration: none}
114 .child {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_smaller; ?>; color: #333399; text-decoration: none}
115 .item, .item:active, .item:hover, .tblItem, .tblItem:active {color: #333399; text-decoration: none}
116 .tblItem:hover {color: #FF0000; text-decoration: underline}
117 //-->
118 </style>
119 </noscript>
121 <style type="text/css">
122 <!--
123 body {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>}
124 //-->
125 </style>
126 <?php
127 } // end if ($num_dbs > 1)
129 else if ($num_dbs == 1) {
130 echo "\n";
132 <style type="text/css">
133 <!--
134 body {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>}
135 div {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>; color: #000000}
136 .heada {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>; color: #000000}
137 .headaCnt {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_smaller; ?>; color: #000000}
138 .parent {font-family: <?php echo $left_font_family; ?>; color: #000000; text-decoration: none}
139 .child {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_smaller; ?>; color: #333399; text-decoration: none}
140 .item, .item:active, .item:hover, .tblItem, .tblItem:active {font-size: <?php echo $font_smaller; ?>; color: #333399; text-decoration: none}
141 .tblItem:hover {color: #FF0000; text-decoration: underline}
142 //-->
143 </style>
144 <?php
145 } // end if ($num_dbs == 1)
147 else {
148 echo "\n";
150 <style type="text/css">
151 <!--
152 body {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>}
153 div {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>; color: #000000}
154 input {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>}
155 select {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>; background-color: #ffffff; color: #000000}
156 .heada {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>; color: #000000}
157 .parent {font-family: <?php echo $left_font_family; ?>; color: #000000; text-decoration: none}
158 .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}
159 .tblItem:hover {color: #FF0000; text-decoration: underline}
160 //-->
161 </style>
162 <?php
163 } // end if ($num_dbs < 1)
165 echo "\n";
167 </head>
169 <body bgcolor="<?php echo $cfg['LeftBgColor']; ?>">
171 <?php
172 if ($cfg['LeftDisplayLogo']) {
174 <!-- phpMyAdmin logo -->
175 <a href="http://www.phpmyadmin.net" target="_blank"><img src="./images/pma_logo.png" width="88" height="31" border="0" alt="phpMyAdmin" /></a>
176 <?php
178 echo "\n";
180 <!-- Link to the welcome page -->
181 <div id="el1Parent" class="parent" style="margin-bottom: 5px">
182 <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>
183 </div>
186 <!-- Databases and tables list -->
187 <?php
188 // Don't display expansible/collapsible database info if:
189 // 1. $server == 0 (no server selected)
190 // This is the case when there are multiple servers and
191 // '$cfg['ServerDefault'] = 0' is set. In that case, we want the welcome
192 // screen to appear with no database info displayed.
193 // 2. there is only one database available (ie either only one database exists
194 // or $cfg['Servers']['only_db'] is defined and is not an array)
195 // In this case, the database should not be collapsible/expandable
196 if ($num_dbs > 1) {
198 // Light mode -> beginning of the select combo for databases
199 if ($cfg['LeftFrameLight']) {
200 echo ' <form method="post" action="index.php3" name="left" target="_parent">' . "\n";
201 echo ' <input type="hidden" name="lang" value="' . $lang . '" />' . "\n";
202 echo ' <input type="hidden" name="convcharset" value="' . $convcharset . '" />' . "\n";
203 echo ' <input type="hidden" name="server" value="' . $server . '" />' . "\n";
204 echo ' <select name="lightm_db" onchange="this.form.submit()">' . "\n";
205 echo ' <option value="">(' . $strDatabases . ') ...</option>' . "\n";
206 $table_list = '';
207 $table_list_header = '';
208 $db_name = '';
211 $selected_db = 0;
213 // Gets the tables list per database
214 for ($i = 0; $i < $num_dbs; $i++) {
215 $db = $dblist[$i];
216 $j = $i + 2;
217 if (!empty($db_start) && $db == $db_start) {
218 $selected_db = $j;
220 $tables = @PMA_mysql_list_tables($db);
221 $num_tables = ($tables) ? @mysql_numrows($tables) : 0;
222 $common_url_query = 'lang=' . $lang
223 . '&amp;convcharset=' . $convcharset
224 . '&amp;server=' . $server
225 . '&amp;db=' . urlencode($db);
226 if ($num_tables) {
227 $num_tables_disp = $num_tables;
228 } else {
229 $num_tables_disp = '-';
232 // Get additional infomation about tables for tooltip
233 if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION >= 32303
234 && $num_tables
235 && (!$cfg['LeftFrameLight'] || $selected_db == $j)) {
236 $tooltip = array();
237 $result = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
238 while ($tmp = PMA_mysql_fetch_array($result)) {
239 $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '')
240 . '(' . (isset($tmp['Rows']) ? $tmp['Rows'] : '0') . ' ' . $strRows . ')';
241 } // end while
242 } // end if
244 // No light mode -> displays the expandible/collapsible db list
245 if ($cfg['LeftFrameLight'] == FALSE) {
247 // Displays the database name
248 $on_mouse = (($cfg['LeftPointerColor'] == '') ? '' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el' . $j . '\', \'' . $cfg['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el' . $j . '\', \'' . $cfg['LeftBgColor'] . '\')}"');
250 echo "\n";
251 echo ' <div id="el' . $j . 'Parent" class="parent"' . $on_mouse . '>';
253 if (!empty($num_tables)) {
254 echo "\n";
256 <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}">
257 <img name="imEx" id="el<?php echo $j; ?>Img" src="images/plus.gif" border="0" width="9" height="9" alt="+" /></a>
258 <?php
259 } else {
260 echo "\n";
262 <nobr><img name="imEx" src="images/minus.gif" border="0" width="9" height="9" alt="-" />
263 <?php
265 echo "\n";
267 <a class="item" href="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>" onclick="if (capable) {expandBase('el<?php echo $j; ?>', false)}">
268 <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>
269 </div>
271 <div id="el<?php echo $j;?>Child" class="child" style="margin-bottom: 5px"<?php echo $on_mouse; ?>>
273 <?php
274 // Displays the list of tables from the current database
275 for ($t = 0; $t < $num_tables; $t++) {
276 $table = PMA_mysql_tablename($tables, $t);
277 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
278 ? str_replace('"', '&quot;', $tooltip[$table])
279 : '';
280 echo "\n";
282 <nobr><img src="images/spacer.gif" border="0" width="9" height="9" alt="" />
283 <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']; ?>">
284 <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>
285 <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); ?>">
286 <?php echo $table; ?></a></nobr><br />
287 <?php
288 } // end for $t (tables list)
289 echo "\n";
291 </div>
292 <?php
293 echo "\n";
297 // Light mode -> displays the select combo with databases names and the
298 // list of tables contained in the current database
299 else {
300 echo "\n";
302 // Builds the databases' names list
303 if (!empty($db_start) && $db == $db_start) {
304 // Gets the list of tables from the current database
305 for ($t = 0; $t < $num_tables; $t++) {
306 $table = PMA_mysql_tablename($tables, $t);
307 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
308 ? str_replace('"', '&quot;', $tooltip[$table])
309 : '';
310 $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";
311 $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";
312 if (PMA_USR_BROWSER_AGENT == 'IE') {
313 $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";
314 } else {
315 $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";
317 } // end for $t (tables list)
319 if (!$table_list) {
320 $table_list = ' <br /><br />' . "\n"
321 . ' <div>' . $strNoTablesFound . '</div>' . "\n";
323 $selected = ' selected="selected"';
325 $table_list_header .= ' <a class="item" target="phpmain" href="' . $cfg['DefaultTabDatabase'] . '?' . $common_url_query . '">' . "\n";
326 $table_list_header .= ' <span class="heada"><b>' . $db . '</b><bdo dir="' . $text_dir . '">&nbsp;&nbsp;</bdo></span></a><br />' . "\n\n";
327 } else {
328 $selected = '';
329 } // end if... else...
331 if (!empty($num_tables)) {
332 echo ' <option value="' . urlencode($db) . '"' . $selected . '>' . $db . ' (' . $num_tables . ')</option>' . "\n";
333 } else {
334 echo ' <option value="' . urlencode($db) . '"' . $selected . '>' . $db . ' (-)</option>' . "\n";
335 } // end if... else...
337 } // end if (light mode)
339 } // end for $i (db list)
341 // Light mode -> end of the select combo for databases and table list for
342 // the current database
343 if ($cfg['LeftFrameLight']) {
344 echo ' </select>' . "\n";
345 echo ' <noscript><input type="submit" name="Go" value="' . $strGo . '" /></noscript>' . "\n";
346 echo ' </form>' . "\n";
348 if (!$table_list) {
349 $table_list = ' <div>' . $strSelectADb . '</div>' . "\n";
352 // Displays the current database name and the list of tables it
353 // contains
354 echo "\n" . ' <hr noshade="noshade" />' . "\n\n";
355 echo $table_list_header;
356 echo $table_list;
357 echo "\n" . ' <hr noshade="noshade" />' . "\n";
360 // No light mode -> initialize some js variables for the
361 // expandible/collapsible stuff
362 else {
365 <!-- Arrange collapsible/expandable db list at startup -->
366 <script type="text/javascript" language="javascript1.2">
367 <!--
368 if (isNS4) {
369 firstEl = 'el1Parent';
370 firstInd = nsGetIndex(firstEl);
371 nsShowAll();
372 nsArrangeList();
374 var expandedDb = '<?php echo (empty($selected_db)) ? '' : 'el' . $selected_db . 'Child'; ?>';
375 //-->
376 </script>
377 <?php
379 } // end if... else... (light mode)
381 } // end if ($server > 1)
384 // Case where only one database has to be displayed
385 else if ($num_dbs == 1) {
386 $db = $dblist[0];
387 $tables = @PMA_mysql_list_tables($db);
388 $num_tables = ($tables) ? @mysql_numrows($tables) : 0;
389 $common_url_query = 'lang=' . $lang
390 . '&amp;server=' . $server
391 . '&amp;db=' . urlencode($db);
392 if ($num_tables) {
393 $num_tables_disp = $num_tables;
394 } else {
395 $num_tables_disp = '-';
398 // Get additional infomation about tables for tooltip
399 if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION >= 32303
400 && $num_tables) {
401 $tooltip = array();
402 $result = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
403 while ($tmp = PMA_mysql_fetch_array($result)) {
404 $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '')
405 . '(' . (isset($tmp['Rows']) ? $tmp['Rows'] : '0') . ' ' . $strRows . ')';
406 } // end while
407 } // end if
409 // Displays the database name
410 echo "\n";
412 <div id="el2Parent" class="parent">
413 <nobr><a class="item" href="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>">
414 <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>
415 </div>
416 <div id="el2Child" class="child" style="margin-bottom: 5px">
417 <?php
418 // Displays the list of tables from the current database
419 for ($j = 0; $j < $num_tables; $j++) {
420 $table = PMA_mysql_tablename($tables, $j);
421 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
422 ? str_replace('"', '&quot;', $tooltip[$table])
423 : '';
424 echo "\n";
426 <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']; ?>">
427 <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>
428 <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); ?>">
429 <?php echo $table; ?></a></nobr><br />
430 <?php
431 } // end for $j (tables list)
432 echo "\n";
434 </div>
435 <?php
436 } // end if ($num_dbs == 1)
439 // Case where no database has to be displayed
440 else {
441 echo "\n";
442 echo '<p>' . $strNoDatabases . '</p>';
443 } // end if ($num_dbs == 0)
444 echo "\n";
447 </body>
448 </html>
450 <?php
452 * Close MySql connections
454 if (isset($dbh) && $dbh) {
455 @mysql_close($dbh);
457 if (isset($userlink) && $userlink) {
458 @mysql_close($userlink);
463 * Sends bufferized data
465 if (isset($cfg['OBGzip']) && $cfg['OBGzip']
466 && isset($ob_mode) && $ob_mode) {
467 PMA_outBufferPost($ob_mode);