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 echo PMA_printTab($strAll, '#', '', 'onClick="javascript:query_tab_commit(\'full\');return false;"', '', (isset($querydisplay_tab) && $querydisplay_tab == 'full' ?
TRUE : FALSE));
157 if (!$cfg['LightTabs']) {
158 echo '</tr></table>';
167 // Hidden forms and query frame interaction stuff
168 if ($cfg['QueryFrame'] && $cfg['QueryFrameJS']) {
170 $input_query_history = array();
171 $sql_history = array();
174 if (isset($query_history_latest) && isset($query_history_latest_db) && $query_history_latest != '' && $query_history_latest_db != '') {
175 if ($cfg['QueryHistoryDB'] && $cfgRelation['historywork']) {
176 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);
179 $input_query_history[] = '<input type="hidden" name="query_history[]" value="' . $query_history_latest . '" />';
180 $input_query_history[] = '<input type="hidden" name="query_history_db[]" value="' . htmlspecialchars($query_history_latest_db) . '" />';
181 $input_query_history[] = '<input type="hidden" name="query_history_table[]" value="' . (isset($query_history_latest_table) ?
htmlspecialchars($query_history_latest_table) : '') . '" />';
183 $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";
185 $sql_query = urldecode($query_history_latest);
186 $db = $query_history_latest_db;
187 $table = $query_history_latest_table;
189 $dup_sql[$query_history_latest] = true;
192 if ($cfg['QueryHistoryDB'] && $cfgRelation['historywork']) {
194 $temp_history = PMA_getHistory($cfg['Server']['user']);
195 if (is_array($temp_history) && count($temp_history) > 0) {
196 @reset
($temp_history);
197 while(@list
($history_nr, $history_array) = @each
($temp_history)) {
198 if (!isset($dup_sql[$history_array['sqlquery']])) {
199 $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";
200 $dup_sql[$history_array['sqlquery']] = true;
207 if (isset($query_history) && is_array($query_history)) {
208 $current_index = count($query_history);
209 @reset
($query_history);
210 while(list($query_no, $query_sql) = each($query_history)) {
211 if (!isset($dup_sql[$query_sql])) {
213 $input_query_history[] = '<input type="hidden" name="query_history[]" value="' . $query_sql . '" />';
214 $input_query_history[] = '<input type="hidden" name="query_history_db[]" value="' . htmlspecialchars($query_history_db[$query_no]) . '" />';
215 $input_query_history[] = '<input type="hidden" name="query_history_table[]" value="' . (isset($query_history_table[$query_no]) ?
htmlspecialchars($query_history_table[$query_no]) : '') . '" />';
217 $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";
218 $dup_sql[$query_sql] = true;
219 } // end if check if this item exists
220 } // end while print history
221 } // end if history exists
223 } // end if DB-based history
226 $url_query = PMA_generate_common_url(isset($db) ?
$db : '', isset($table) ?
$table : '');
231 require './libraries/bookmark.lib.php3';
232 $is_inside_querywindow = TRUE;
233 require './tbl_query_box.php3';
235 // Hidden forms and query frame interaction stuff
236 if ($cfg['QueryFrame'] && $cfg['QueryFrameJS']) {
237 if (isset($auto_commit) && $auto_commit == 'true') {
239 <script type
="text/javascript" language
="javascript">
245 if (isset($sql_history) && isset($querydisplay_tab) && ($querydisplay_tab == 'history' ||
$querydisplay_tab == 'full') && is_array($sql_history) && count($sql_history) > 0) {
248 <div style
="margin-bottom: 10px"><?php
echo $strQuerySQLHistory . ':<br><ul>' . implode('', $sql_history) . '</ul>'; ?
></div
>
253 <form action
="querywindow.php3" method
="post" name
="querywindow">
255 echo PMA_generate_common_hidden_inputs('', '');
256 if (count($input_query_history) > 0) {
257 echo implode("\n", $input_query_history);
260 <input type
="hidden" name
="db" value
="<?php echo (isset($db) && $db != '' ? $db : ''); ?>" />
261 <input type
="hidden" name
="table" value
="<?php echo (isset($table) && $table != '' ? $table : ''); ?>" />
263 <input type
="hidden" name
="query_history_latest" value
="" />
264 <input type
="hidden" name
="query_history_latest_db" value
="" />
265 <input type
="hidden" name
="query_history_latest_table" value
="" />
267 <input type
="hidden" name
="previous_db" value
="<?php echo htmlspecialchars($db); ?>" />
269 <input type
="hidden" name
="auto_commit" value
="false" />
270 <input type
="hidden" name
="querydisplay_tab" value
="<?php echo $querydisplay_tab; ?>" />
276 if ($cfg['QueryFrame'] && $cfg['QueryFrameJS'] && $cfg['QueryFrameDebug']) {
280 <a href
='#' onClick
='return debug();'><?php
echo $strQueryFrameDebug; ?
></a
>
292 * Close MySql connections
294 if (isset($dbh) && $dbh) {
297 if (isset($userlink) && $userlink) {
298 @mysql_close
($userlink);
303 * Sends bufferized data
305 if (isset($cfg['OBGzip']) && $cfg['OBGzip']
306 && isset($ob_mode) && $ob_mode) {
307 PMA_outBufferPost($ob_mode);