bug #1116026, export under IE 6 (XP SP2)
[phpmyadmin/crack.git] / queryframe.php
blob085a8e93d6024049b04b630551f8906192d24778
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
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_once('./libraries/grab_globals.lib.php');
10 if (!empty($db)) {
11 $db_start = $db;
15 /**
16 * Gets a core script and starts output buffering work
18 require_once('./libraries/common.lib.php');
19 require_once('./libraries/bookmark.lib.php');
20 require_once('./libraries/ob.lib.php');
21 if ($cfg['OBGzip']) {
22 $ob_mode = PMA_outBufferModeGet();
23 if ($ob_mode) {
24 PMA_outBufferPre($ob_mode);
28 // garvin: For re-usability, moved http-headers
29 // to a seperate file. It can now be included by header.inc.php,
30 // queryframe.php, querywindow.php.
32 require_once('./libraries/header_http.inc.php');
34 /**
35 * Displays the frame
37 // Gets the font sizes to use
38 PMA_setFontSizes();
40 /**
41 * Relations
43 require_once('./libraries/relation.lib.php');
44 $cfgRelation = PMA_getRelationsParam();
45 echo "<?xml version=\"1.0\" encoding=\"" . $GLOBALS['charset'] . "\"?".">"; // remove vertical scroll bar bug in ie
47 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
48 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
49 <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; ?>">
51 <head>
52 <title>phpMyAdmin</title>
53 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset; ?>" />
54 <base<?php if (!empty($cfg['PmaAbsoluteUri'])) echo ' href="' . $cfg['PmaAbsoluteUri'] . '"'; ?> />
55 <link rel="stylesheet" type="text/css" href="./css/phpmyadmin.css.php?<?php echo PMA_generate_common_url(); ?>&amp;js_frame=left&amp;num_dbs=0" />
56 <?php
57 if ($cfg['QueryFrame'] && $cfg['QueryFrameJS']) {
59 <script type="text/javascript" language="javascript">
60 <!--
61 var querywindow = '';
63 function open_querywindow(url) {
65 if (!querywindow.closed && querywindow.location) {
66 querywindow.focus();
67 } else {
68 querywindow=window.open(url + '&db=' + document.queryframeform.db.value + '&table=' + document.queryframeform.table.value, '','toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=yes,resizable=yes,width=<?php echo $cfg['QueryWindowWidth']; ?>,height=<?php echo $cfg['QueryWindowHeight']; ?>');
71 if (!querywindow.opener) {
72 querywindow.opener = blank;
75 if (window.focus) {
76 querywindow.focus();
79 return false;
82 /**
83 * function resizeRowsLeft()
84 * added 2004-07-20 by Michael Keck <mail@michaelkeck.de>
85 * - this function checks the complete frameset of
86 * index.php (parent.frames)
87 * - gets the offsetHeight of qfcontainer
88 * - sets a new frameset.rows - definition for the
89 * frameset 'leftFrameset' in 'index.php' dynamic.
90 * this script was tested on
91 * IE 6, Opera 7.53, Netsacpe 7.1 and Firefox 0.9
92 * and should work on all other DOM-Browsers and old IE-Browsers.
93 * It will never work on Netscape smaller Version 6 and IE smaller Version 4.
94 * Please give me feedback if any browser doesn't work with this script
95 * mailto:mail@michaelkeck.de?subject=resizeFrames - Browser: [the browser]
96 **/
98 function resizeRowsLeft() {
99 if (document.getElementById('qfcontainer')) { // dom browsers
100 // get the height of the div-element 'qfcontainer'
101 // we must add 10 (px) for framespacing
102 newHeight = document.getElementById('qfcontainer').offsetHeight+10;
103 // check if the frameset exists
104 // please see index.php and check the frameset-definitions
105 if (parent.document.getElementById('mainFrameset') && parent.document.getElementById('leftFrameset')) {
106 parent.document.getElementById('leftFrameset').rows=newHeight+',*';
108 } else {
109 if (document.all) { // older ie-browsers
110 // get the height of the div-element 'qfcontainer'
111 // we must add 10 (px) for framespacing
112 newHeight=document.all('qfcontainer').offsetHeight+10;
113 // check if the frameset exists
114 // please see index.php and check the frameset-definitions
115 if (parent.leftFrameset) {
116 parent.leftFrameset.rows=newHeight+',*';
122 //-->
123 </script>
124 <?php
125 // setup the onload handler for resizing frames
126 $js_frame_onload=' onload="resizeRowsLeft();"';
128 if ($cfg['QueryFrame']) {
130 <script type="text/javascript" language="javascript">
131 <!--
132 // added 2004-09-16 by Michael Keck (mkkeck)
133 // bug: #1027321
134 // drop-down databases list keep focus on database change
135 // modified 2004-11-06: bug #1046434 (Light mode does not work)
136 var focus_removed = false;
137 function remove_focus_select() {
138 focus_removed = false;
139 set_focus_to_nav();
141 function set_focus_to_nav() {
142 if (typeof(parent.frames.nav)!='undefined' && focus_removed!=true) {
143 parent.frames.nav.focus();
144 focus_removed=true;
145 } else {
146 focus_removed=false;
147 setTimeout("set_focus_to_nav();",500);
150 //-->
151 </script>
152 <?php
155 </head>
157 <body id="body_queryFrame" bgcolor="<?php echo $cfg['LeftBgColor']; ?>"<?php echo ((isset($js_frame_onload) && $js_frame_onload!='') ? $js_frame_onload : ''); ?>>
158 <div id="qfcontainer">
159 <?php
160 if ($cfg['LeftDisplayLogo']) {
162 <!-- phpMyAdmin logo -->
163 <?php
164 if (@file_exists($pmaThemeImage . 'logo_left.png')) {
167 <div align="center">
168 <a href="http://www.phpmyadmin.net" target="_blank"><img src="<?php echo '' . $pmaThemeImage . 'logo_left.png'; ?>" alt="phpMyAdmin" vspace="3" border="0" /></a>
169 </div>
170 <?php
171 } else {
172 echo ' '
173 . '<div align="center"><a href="http://www.phpmyadmin.net" target="_blank">'
174 . '<img src="' . $GLOBALS['pmaThemeImage'] . 'pma_logo2.png' .'" alt="phpMyAdmin" border="0" />'
175 . '</a></div>' . "\n";
177 echo '<hr id="hr_first" />';
178 } // end of display logo
180 if ($cfg['MainPageIconic']) {
181 $str_spacer_links='';
182 } else{
183 $str_spacer_links=' - ';
186 <!-- Link to the welcome page -->
187 <div align="center">
188 <?php
189 echo '<a class="item" href="main.php?' . PMA_generate_common_url() . '" target="phpmain' . $hash . '">'
190 . ($cfg['MainPageIconic']
191 ? '<img src="' . $pmaThemeImage . 'b_home.png" width="16" height="16" border="0" hspace="2" alt="' . $strHome . '" title="' . $strHome . '"'
192 .' onmouseover="this.style.backgroundColor=\'#ffffff\';" onmouseout="this.style.backgroundColor=\'\';" align="middle" />'
193 : '<b>' . $strHome . '</b>')
194 . '</a>';
195 // if we have chosen server
196 if ($server != 0) {
197 // Logout for advanced authentication
198 if ($cfg['Server']['auth_type'] != 'config') {
199 echo $str_spacer_links;
200 echo '<a class="item" href="index.php?' . PMA_generate_common_url() . '&amp;old_usr=' . urlencode($PHP_AUTH_USER) . '" target="_parent">'
201 . ($cfg['MainPageIconic']
202 ? '<img src="' . $pmaThemeImage . 's_loggoff.png" width="16" height="16" border="0" hspace="2" alt="' . $strLogout . '" title="' . $strLogout . '"'
203 .' onmouseover="this.style.backgroundColor=\'#ffffff\';" onmouseout="this.style.backgroundColor=\'\';" align="middle" />'
204 : '<b>' . $strLogout . '</b>')
205 . '</a>';
206 } // end if
208 $anchor = 'querywindow.php?' . PMA_generate_common_url('', '');
209 if ($cfg['QueryFrameJS']) {
210 $href = $anchor;
211 $target = '';
212 $onclick = 'onclick="javascript:open_querywindow(this.href); return false;"';
213 } else {
214 $href = $anchor;
215 $target = 'target="phpmain' . $hash . '"';
216 $onclick = '';
218 if ($cfg['MainPageIconic']) {
219 $query_frame_link_text = '<img src="' . $pmaThemeImage . 'b_selboard.png" border="0" hspace="1" width="16" height="16" alt="' . $strQueryFrame . '" title="' . $strQueryFrame . '"'
220 .' onmouseover="this.style.backgroundColor=\'#ffffff\';" onmouseout="this.style.backgroundColor=\'\';" align="middle" />';
221 } else {
222 echo ($str_spacer_links != '' ? '<br />' : '');
223 $query_frame_link_text = '<b>' . $strQueryFrame . '</b>';
226 <script type="text/javascript">
227 <!--
228 document.writeln('<a href="<?php echo $href; ?>" <?php echo $target . ' ' . $onclick; ?> class="item"><?php echo addslashes($query_frame_link_text); ?><\/a>');
229 //-->
230 </script>
231 <noscript>
232 <a href="<?php echo $href; ?>&amp;no_js=true" <?php echo $target . ' ' . $onclick; ?> target="phpmain<?php echo $hash; ?>" class="item"><?php echo $query_frame_link_text; ?></a>
233 </noscript>
234 <?php
237 if ($cfg['MainPageIconic']) {
238 echo '<img src="' .$GLOBALS['pmaThemeImage'] . 'spacer.png' .'" width="2" height="1" border="0" alt="" />'
239 . '<a href="Documentation.html" target="documentation" class="item">'
240 . '<img src="' . $pmaThemeImage . 'b_docs.png" border="0" hspace="1" width="16" height="16" alt="' . $strPmaDocumentation . '" title="' . $strPmaDocumentation . '"'
241 . ' onmouseover="this.style.backgroundColor=\'#ffffff\';" onmouseout="this.style.backgroundColor=\'\';" align="middle" />'
242 . '</a>';
243 echo ''
244 . '<a href="' . $cfg['MySQLManualBase'] . '" target="documentation" class="item">'
245 . '<img src="' . $pmaThemeImage . 'b_sqlhelp.png" border="0" hspace="1" width="16" height="16" alt="MySQL - ' . $strDocu . '" title="MySQL - ' . $strDocu . '"'
246 .' onmouseover="this.style.backgroundColor=\'#ffffff\';" onmouseout="this.style.backgroundColor=\'\';" align="middle" />'
247 . '</a>';
251 </div>
252 <hr id="hr_second" />
254 <?php
255 if ($cfg['LeftDisplayServers']){
256 $show_server_left = TRUE;
257 include('./libraries/select_server.lib.php');
258 } // end if LeftDisplayServers
260 <!-- Databases list -->
261 <?php
263 * Get the list and number of available databases.
264 * Skipped if no server selected: in this case no database should be displayed
265 * before the user choose among available ones at the welcome screen.
267 if ($server > 0) {
268 PMA_availableDatabases(); // this function is defined in "common.lib.php"
269 } else {
270 $num_dbs = 0;
273 // Don't display expansible/collapsible database info if:
274 // 1. $server == 0 (no server selected)
275 // This is the case when there are multiple servers and
276 // '$cfg['ServerDefault'] = 0' is set. In that case, we want the welcome
277 // screen to appear with no database info displayed.
278 // 2. there is only one database available (ie either only one database exists
279 // or $cfg['Servers']['only_db'] is defined and is not an array)
280 // In this case, the database should not be collapsible/expandable
281 if ($num_dbs > 1) {
282 // Light mode -> beginning of the select combo for databases
283 // Note: When javascript is active, the frameset will be changed from
284 // within left.php. With no JS (<noscript>) the whole frameset will
285 // be rebuilt with the new target frame.
286 if ($cfg['LeftFrameLight']) {
288 <table border="0" cellpadding="1" cellspacing="0">
289 <tr>
290 <td align="left" class="heada"><?php echo $strDatabase; ?>:</td>
291 </tr>
292 <tr>
293 <td nowrap="nowrap">
294 <form method="post" action="index.php" name="left" target="_parent" style="margin: 0px; padding: 0px;">
295 <script type="text/javascript" language="javascript">
296 <!--
297 document.left.action="left.php";
298 document.left.target="nav";
299 //-->
300 </script>
301 <?php
302 echo PMA_generate_common_hidden_inputs();
303 echo ' <input type="hidden" name="hash" value="' . $hash . '" />' . "\n";
305 <select name="lightm_db" onchange="remove_focus_select();this.form.submit();">
306 <?php
307 echo ' <option value="">(' . $strDatabases . ') ...</option>' . "\n";
308 $table_list = '';
309 $table_list_header = '';
310 $db_name = '';
311 $selected_db = 0;
313 // natural order for db list; but do not sort if user asked
314 // for a specific order with the 'only_db' mechanism
316 // TODO: merge this logic with the one in left.php
318 if (!is_array($cfg['Server']['only_db']) && $cfg['NaturalOrder'] && $num_dbs > 0) {
319 $dblist_temp = $dblist;
320 natsort($dblist_temp);
321 $i = 0;
322 foreach ($dblist_temp as $each) {
323 $dblist[$i] = $each;
324 $i++;
328 // Gets the tables list per database
329 for ($i = 0; $i < $num_dbs; $i++) {
330 $db = $dblist[$i];
331 $j = $i + 2;
332 if (!empty($db_start) && $db == $db_start) {
333 $selected_db = $j;
335 $tables = PMA_DBI_try_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE);
336 $num_tables = ($tables) ? @PMA_DBI_num_rows($tables) : 0;
337 $common_url_query = PMA_generate_common_url($db);
338 if ($num_tables) {
339 $num_tables_disp = $num_tables;
340 } else {
341 $num_tables_disp = '-';
343 // Get additional information about tables for tooltip
344 if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION >= 32303
345 && $num_tables
346 && (!$cfg['LeftFrameLight'] || $selected_db == $j)) {
347 $tooltip = array();
348 $tooltip_name = array();
349 $result = PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
350 while ($tmp = PMA_DBI_fetch_assoc($result)) {
351 $tooltip_name[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '');
352 $tmp['Comment'] = ($cfg['ShowTooltipAliasTB'] && $cfg['ShowTooltipAliasTB'] !== 'nested' ? $tmp['Name'] : $tmp['Comment']);
353 $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '')
354 . '(' . (isset($tmp['Rows']) ? $tmp['Rows'] : '0') . ' ' . $strRows . ')';
355 } // end while
356 } // end if
358 // garvin: Get comments from PMA comments table
359 $db_tooltip = '';
360 if ($cfg['ShowTooltip'] && $cfgRelation['commwork']) {
361 $tmp_db_tooltip = PMA_getComments($db);
362 if (is_array($tmp_db_tooltip)) {
363 $db_tooltip = implode(' ', $tmp_db_tooltip);
367 // Builds the databases' names list
368 if (!empty($db_start) && $db == $db_start) {
369 $table_title = array();
370 $table_array = array();
371 // Gets the list of tables from the current database
372 while (list($table) = PMA_DBI_fetch_row($tables)) {
373 $table_array[$table] = '';
374 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
375 ? htmlspecialchars($tooltip[$table])
376 : '';
377 $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
378 ? htmlspecialchars($tooltip_name[$table])
379 : '';
380 $book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
381 } // end while (tables list)
382 $selected = ' selected="selected"';
383 } else {
384 $selected = '';
385 } // end if... else...
387 if (!empty($num_tables)) {
388 echo ' '
389 . '<option value="' . htmlspecialchars($db) . '"' . $selected . '>'
390 . ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . ' (' . $num_tables . ')</option>' . "\n";
391 } else {
392 echo ' '
393 . '<option value="' . htmlspecialchars($db) . '"' . $selected . '>'
394 . ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . ' (-)</option>' . "\n";
395 } // end if... else...
397 } // end for $i (db list)
399 </select>
400 <noscript>
401 <input type="submit" name="Go" value="<?php echo $strGo; ?>" />
402 </noscript>
403 </form>
404 </td>
405 </tr>
406 </table>
407 <hr id="hr_third" />
408 <?php
409 } // end if LeftFrameLight
410 } // end if num_db > 1
412 <form name="queryframeform" action="queryframe.php" method="get" style="margin:0px; padding:0px; display:none;">
413 <input type="hidden" name="db" value="" />
414 <input type="hidden" name="table" value="" />
415 <input type="hidden" name="framename" value="queryframe" />
416 </form>
417 <form name="hashform" action="queryframe.php" style="margin:0px; padding:0px; display:none;">
418 <input type="hidden" name="hash" value="<?php echo $hash; ?>" />
419 </form>
420 </div>
421 </body>
422 </html>
424 <?php
426 * Close MySql connections
428 if (isset($dbh) && $dbh) {
429 @PMA_DBI_close($dbh);
431 if (isset($userlink) && $userlink) {
432 @PMA_DBI_close($userlink);
437 * Sends bufferized data
439 if (isset($cfg['OBGzip']) && $cfg['OBGzip']
440 && isset($ob_mode) && $ob_mode) {
441 PMA_outBufferPost($ob_mode);