3 // vim: expandtab sw=4 ts=4 sts=4:
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
10 require('./libraries/grab_globals.lib.php3');
17 * Gets a core script and starts output buffering work
19 require('./libraries/common.lib.php3');
20 require('./libraries/ob.lib.php3');
22 $ob_mode = PMA_outBufferModeGet();
24 PMA_outBufferPre($ob_mode);
28 require('./libraries/relation.lib.php3');
29 $cfgRelation = PMA_getRelationsParam();
32 * Get the list and number of available databases.
33 * Skipped if no server selected: in this case no database should be displayed
34 * before the user choose among available ones at the welcome screen.
37 PMA_availableDatabases(); // this function is defined in "common.lib.php3"
46 // Don't use cache (required for Opera)
47 $now = gmdate('D, d M Y H:i:s') . ' GMT';
48 header('Expires: ' . $now);
49 header('Last-Modified: ' . $now);
50 header('Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
51 header('Pragma: no-cache'); // HTTP/1.0
52 // Define the charset to be used
53 header('Content-Type: text/html; charset=' . $charset);
58 // Gets the font sizes to use
61 <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
62 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
63 <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; ?>">
66 <title
>phpMyAdmin
</title
>
67 <meta http
-equiv
="Content-Type" content
="text/html; charset=<?php echo $charset; ?>" />
68 <base
<?php
if (!empty($cfg['PmaAbsoluteUri'])) echo ' href="' . $cfg['PmaAbsoluteUri'] . '"'; ?
> />
69 <style type
="text/css">
71 body
{font
-family
: <?php
echo $left_font_family; ?
>; font
-size
: <?php
echo $font_size; ?
>}
72 div
{font
-family
: <?php
echo $left_font_family; ?
>; font
-size
: <?php
echo $font_size; ?
>; color
: #000000}
73 .heada
{font
-family
: <?php
echo $left_font_family; ?
>; font
-size
: <?php
echo $font_size; ?
>; color
: #000000}
74 .headaCnt
{font
-family
: <?php
echo $left_font_family; ?
>; font
-size
: <?php
echo $font_smaller; ?
>; color
: #000000}
75 .parent
{font
-family
: <?php
echo $left_font_family; ?
>; color
: #000000; text-decoration: none}
76 .child
{font
-family
: <?php
echo $left_font_family; ?
>; font
-size
: <?php
echo $font_smaller; ?
>; color
: #333399; text-decoration: none}
77 .item
, .item
:active
, .item
:hover
, .tblItem
, .tblItem
:active
{font
-size
: <?php
echo $font_smaller; ?
>; color
: #333399; text-decoration: none}
78 .tblItem
:hover
{color
: #FF0000; text-decoration: underline}
80 border
-top
: 1px solid
#999;
81 border
-right
: 1px solid
#666;
82 border
-left
: 1px solid
#999;
85 -moz
-border
-radius
: 2px
;
91 border
-bottom
: 1px solid
#666;
97 <script type
="text/javascript" language
="javascript">
99 if ($cfg['QueryFrame'] && $cfg['QueryFrameJS'] && $cfg['QueryFrameDebug']) {
100 $js_db = (isset($db) ?
$db : 'FALSE');
101 $js_table = (isset($table) ?
$table : 'FALSE');
102 $js_server = (isset($server) ?
$server : 'FALSE');
104 $js_true_db = '\' + document.querywindow.db.value + \'';
105 $js_true_table = '\' + document.querywindow.table.value + \'';
106 $js_true_server = '\' + document.querywindow.server.value + \'';
108 $js_parent = '\' + opener.location.href + \'';
109 $js_frame = '\' + opener.parent.location.href + \'';
112 alert('<?php echo sprintf($strQueryFrameDebugBox, $js_db, $js_table, $js_server, $js_true_db, $js_true_table, $js_true_server, $js_parent, $js_frame); ?>');
118 function query_auto_commit() {
119 document
.sqlform
.submit();
122 function query_tab_commit(tab
) {
123 document
.querywindow
.querydisplay_tab
.value
= tab
;
124 document
.querywindow
.submit();
128 // js form validation stuff
129 var errorMsg0
= '<?php echo str_replace('\'
', '\\\'
', $GLOBALS['strFormEmpty
']); ?>';
130 var errorMsg1
= '<?php echo str_replace('\'
', '\\\'
', $GLOBALS['strNotNumber
']); ?>';
131 var errorMsg2
= '<?php echo str_replace('\'
', '\\\'
', $GLOBALS['strNotValidNumber
']); ?>';
132 var noDropDbMsg
= '<?php echo((!$GLOBALS['cfg
']['AllowUserDropDatabase
']) ? str_replace('\'
', '\\\'
', $GLOBALS['strNoDropDatabases
']) : ''); ?>';
133 var confirmMsg
= '<?php echo(($GLOBALS['cfg
']['Confirm
']) ? str_replace('\'
', '\\\'
', $GLOBALS['strDoYouReally
']) : ''); ?>';
136 <script src
="libraries/functions.js" type
="text/javascript" language
="javascript"></script
>
139 <body bgcolor
="<?php echo ($cfg['QueryFrameJS'] ? $cfg['LeftBgColor'] : $cfg['RightBgColor']); ?>">
142 $querydisplay_tab = (isset($querydisplay_tab) ?
$querydisplay_tab : $cfg['QueryWindowDefTab']);
144 if ($cfg['LightTabs']) {
147 echo '<table border="0" cellspacing="0" cellpadding="3" width="100%" class="tabs">
149 <td width="8"> </td>';
152 echo PMA_printTab($strSQL, '#', '', 'onClick="javascript:query_tab_commit(\'sql\');return false;"', '', (isset($querydisplay_tab) && $querydisplay_tab == 'sql' ?
TRUE : FALSE));
153 echo PMA_printTab($strImportFiles, '#', '', 'onClick="javascript:query_tab_commit(\'files\');return false;"', '', (isset($querydisplay_tab) && $querydisplay_tab == 'files' ?
TRUE : FALSE));
154 echo PMA_printTab($strQuerySQLHistory, '#', '', 'onClick="javascript:query_tab_commit(\'history\');return false;"', '', (isset($querydisplay_tab) && $querydisplay_tab == 'history' ?
TRUE : FALSE));
155 if ($cfg['QueryWindowDefTab'] == 'full') {
156 echo PMA_printTab($strAll, '#', '', 'onClick="javascript:query_tab_commit(\'full\');return false;"', '', (isset($querydisplay_tab) && $querydisplay_tab == 'full' ?
TRUE : FALSE));
159 if (!$cfg['LightTabs']) {
160 echo '</tr></table>';
169 // Hidden forms and query frame interaction stuff
170 if ($cfg['QueryFrame'] && $cfg['QueryFrameJS']) {
172 $input_query_history = array();
173 $sql_history = array();
176 if (isset($query_history_latest) && isset($query_history_latest_db) && $query_history_latest != '' && $query_history_latest_db != '') {
177 if ($cfg['QueryHistoryDB'] && $cfgRelation['historywork']) {
178 PMA_setHistory((isset($query_history_latest_db) ?
$query_history_latest_db : ''), (isset($query_history_latest_table) ?
$query_history_latest_table : ''), $cfg['Server']['user'], $query_history_latest);
181 $input_query_history[] = '<input type="hidden" name="query_history[]" value="' . $query_history_latest . '" />';
182 $input_query_history[] = '<input type="hidden" name="query_history_db[]" value="' . htmlspecialchars($query_history_latest_db) . '" />';
183 $input_query_history[] = '<input type="hidden" name="query_history_table[]" value="' . (isset($query_history_latest_table) ?
htmlspecialchars($query_history_latest_table) : '') . '" />';
185 $sql_history[] = '<li><a href="#" onClick="document.querywindow.querydisplay_tab.value = \'' . (isset($querydisplay_tab) && $querydisplay_tab != 'full' ?
'sql' : 'full') . '\'; document.querywindow.query_history_latest.value = \'' . htmlspecialchars($query_history_latest) . '\'; document.querywindow.auto_commit.value = \'true\'; document.querywindow.db.value = \'' . htmlspecialchars($query_history_latest_db) . '\'; document.querywindow.query_history_latest_db.value = \'' . htmlspecialchars($query_history_latest_db) . '\'; document.querywindow.table.value = \'' . (isset($query_history_latest_table) ?
htmlspecialchars($query_history_latest_table) : '') . '\'; document.querywindow.query_history_latest_table.value = \'' . (isset($query_history_latest_table) ?
htmlspecialchars($query_history_latest_table) : '') . '\'; document.querywindow.submit(); return false;">[' . htmlspecialchars($query_history_latest_db) . '] ' . urldecode($query_history_latest) . '</a></li>' . "\n";
187 $sql_query = urldecode($query_history_latest);
188 $db = $query_history_latest_db;
189 $table = $query_history_latest_table;
191 $dup_sql[$query_history_latest] = true;
194 if ($cfg['QueryHistoryDB'] && $cfgRelation['historywork']) {
196 $temp_history = PMA_getHistory($cfg['Server']['user']);
197 if (is_array($temp_history) && count($temp_history) > 0) {
198 @reset
($temp_history);
199 while(@list
($history_nr, $history_array) = @each
($temp_history)) {
200 if (!isset($dup_sql[$history_array['sqlquery']])) {
201 $sql_history[] = '<li><a href="#" onClick="document.querywindow.querydisplay_tab.value = \'' . (isset($querydisplay_tab) && $querydisplay_tab != 'full' ?
'sql' : 'full') . '\'; document.querywindow.query_history_latest.value = \'' . htmlspecialchars($history_array['sqlquery']) . '\'; document.querywindow.auto_commit.value = \'true\'; document.querywindow.db.value = \'' . htmlspecialchars($history_array['db']) . '\'; document.querywindow.query_history_latest_db.value = \'' . htmlspecialchars($history_array['db']) . '\'; document.querywindow.table.value = \'' . (isset($history_array['table']) ?
htmlspecialchars($history_array['table']) : '') . '\'; document.querywindow.query_history_latest_table.value = \'' . (isset($history_array['table']) ?
htmlspecialchars($history_array['table']) : '') . '\'; document.querywindow.submit(); return false;">[' . htmlspecialchars($history_array['db']) . '] ' . urldecode($history_array['sqlquery']) . '</a></li>' . "\n";
202 $dup_sql[$history_array['sqlquery']] = true;
209 if (isset($query_history) && is_array($query_history)) {
210 $current_index = count($query_history);
211 @reset
($query_history);
212 while(list($query_no, $query_sql) = each($query_history)) {
213 if (!isset($dup_sql[$query_sql])) {
215 $input_query_history[] = '<input type="hidden" name="query_history[]" value="' . $query_sql . '" />';
216 $input_query_history[] = '<input type="hidden" name="query_history_db[]" value="' . htmlspecialchars($query_history_db[$query_no]) . '" />';
217 $input_query_history[] = '<input type="hidden" name="query_history_table[]" value="' . (isset($query_history_table[$query_no]) ?
htmlspecialchars($query_history_table[$query_no]) : '') . '" />';
219 $sql_history[] = '<li><a href="#" onClick="document.querywindow.querydisplay_tab.value = \'' . (isset($querydisplay_tab) && $querydisplay_tab != 'full' ?
'sql' : 'full') . '\'; document.querywindow.query_history_latest.value = \'' . htmlspecialchars($query_sql) . '\'; document.querywindow.auto_commit.value = \'true\'; document.querywindow.db.value = \'' . htmlspecialchars($query_history_db[$query_no]) . '\'; document.querywindow.query_history_latest_db.value = \'' . htmlspecialchars($query_history_db[$query_no]) . '\'; document.querywindow.table.value = \'' . (isset($query_history_table[$query_no]) ?
htmlspecialchars($query_history_table[$query_no]) : '') . '\'; document.querywindow.query_history_latest_table.value = \'' . (isset($query_history_table[$query_no]) ?
htmlspecialchars($query_history_table[$query_no]) : '') . '\'; document.querywindow.submit(); return false;">[' . htmlspecialchars($query_history_db[$query_no]) . '] ' . urldecode($query_sql) . '</a></li>' . "\n";
220 $dup_sql[$query_sql] = true;
221 } // end if check if this item exists
222 } // end while print history
223 } // end if history exists
225 } // end if DB-based history
228 $url_query = PMA_generate_common_url(isset($db) ?
$db : '', isset($table) ?
$table : '');
233 require './libraries/bookmark.lib.php3';
234 $is_inside_querywindow = TRUE;
235 require './tbl_query_box.php3';
237 // Hidden forms and query frame interaction stuff
238 if ($cfg['QueryFrame'] && $cfg['QueryFrameJS']) {
239 if (isset($auto_commit) && $auto_commit == 'true') {
241 <script type
="text/javascript" language
="javascript">
247 if (isset($sql_history) && isset($querydisplay_tab) && ($querydisplay_tab == 'history' ||
$querydisplay_tab == 'full') && is_array($sql_history) && count($sql_history) > 0) {
250 <div style
="margin-bottom: 10px"><?php
echo $strQuerySQLHistory . ':<br><ul>' . implode('', $sql_history) . '</ul>'; ?
></div
>
255 <form action
="querywindow.php3" method
="post" name
="querywindow">
257 echo PMA_generate_common_hidden_inputs('', '');
258 if (count($input_query_history) > 0) {
259 echo implode("\n", $input_query_history);
262 <input type
="hidden" name
="db" value
="<?php echo (isset($db) && $db != '' ? $db : ''); ?>" />
263 <input type
="hidden" name
="table" value
="<?php echo (isset($table) && $table != '' ? $table : ''); ?>" />
265 <input type
="hidden" name
="query_history_latest" value
="" />
266 <input type
="hidden" name
="query_history_latest_db" value
="" />
267 <input type
="hidden" name
="query_history_latest_table" value
="" />
269 <input type
="hidden" name
="previous_db" value
="<?php echo htmlspecialchars($db); ?>" />
271 <input type
="hidden" name
="auto_commit" value
="false" />
272 <input type
="hidden" name
="querydisplay_tab" value
="<?php echo $querydisplay_tab; ?>" />
278 if ($cfg['QueryFrame'] && $cfg['QueryFrameJS'] && $cfg['QueryFrameDebug']) {
282 <a href
='#' onClick
='return debug();'><?php
echo $strQueryFrameDebug; ?
></a
>
294 * Close MySql connections
296 if (isset($dbh) && $dbh) {
299 if (isset($userlink) && $userlink) {
300 @mysql_close
($userlink);
305 * Sends bufferized data
307 if (isset($cfg['OBGzip']) && $cfg['OBGzip']
308 && isset($ob_mode) && $ob_mode) {
309 PMA_outBufferPost($ob_mode);