3 // vim: expandtab sw=4 ts=4 sts=4:
6 * WARNING: This script has to be included at the very end of your code because
7 * it will stop the script execution!
10 require_once('./libraries/relation.lib.php'); // for PMA_setHistory()
16 // If query window is wanted and open, update with latest selected db/table.
17 if ($cfg['QueryFrame'] && $cfg['QueryFrameJS']) {
20 <script type
="text/javascript">
23 if (!isset($no_history) && !empty($db) && (!isset($error_message) ||
$error_message == '')) {
24 $tables = PMA_DBI_try_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE
);
25 $num_tables = ($tables) ? @PMA_DBI_num_rows
($tables) : 0;
26 $common_url_query = PMA_generate_common_url($db);
28 $num_tables_disp = ' (' . $num_tables . ')';
30 $num_tables_disp = ' (-)';
33 var forceQueryFrameReload
= false;
35 // $is_drop_database comes from sql.php when we saw a DROP DATABASE
36 // $force_queryframe_reload comes from db_operations.php
37 if ((isset($is_drop_database) && $is_drop_database) ||
(isset($force_queryframe_reload) && $force_queryframe_reload == TRUE)) {
39 forceQueryFrameReload
= true;
43 var dbBoxSetupDone
= false;
44 function dbBoxSetup() {
45 if (dbBoxSetupDone
!= true) {
46 if (parent
.frames
.queryframe
&& parent
.frames
.queryframe
.document
.left
&& parent
.frames
.queryframe
.document
.left
.lightm_db
) {
47 parent
.frames
.queryframe
.document
.left
.lightm_db
.value
= '<?php echo addslashes($db); ?>';
48 dbBoxSetupDone
= true;
50 setTimeout("dbBoxSetup();",500);
54 if (parent
.frames
.queryframe
&& parent
.frames
.queryframe
.document
&& parent
.frames
.queryframe
.document
.queryframeform
) {
55 parent
.frames
.queryframe
.document
.queryframeform
.db
.value
= "<?php echo (isset($db) ? addslashes($db) : ''); ?>";
56 parent
.frames
.queryframe
.document
.queryframeform
.table
.value
= "<?php echo (isset($table) ? addslashes($table) : ''); ?>";
58 if (parent
.frames
.queryframe
&& parent
.frames
.queryframe
.document
&& parent
.frames
.queryframe
.document
.left
&& parent
.frames
.queryframe
.document
.left
.lightm_db
) {
59 selidx
= parent
.frames
.queryframe
.document
.left
.lightm_db
.selectedIndex
;
60 if (parent
.frames
.queryframe
.document
.left
.lightm_db
.options
[selidx
].value
== "<?php echo addslashes($db); ?>" && forceQueryFrameReload
== false) {
61 parent
.frames
.queryframe
.document
.left
.lightm_db
.options
[selidx
].text
= "<?php echo addslashes($db) . $num_tables_disp; ?>";
63 parent
.frames
.queryframe
.location
.reload();
64 setTimeout("dbBoxSetup();",2000);
71 function reload_querywindow () {
72 if (parent
.frames
.queryframe
&& parent
.frames
.queryframe
.querywindow
&& !parent
.frames
.queryframe
.querywindow
.closed
&& parent
.frames
.queryframe
.querywindow
.location
) {
74 if (!isset($no_history) && (!isset($error_message) ||
$error_message == '')) {
75 if (isset($LockFromUpdate) && $LockFromUpdate == '1' && isset($sql_query)) {
76 // When the button 'LockFromUpdate' was selected in the querywindow, it does not submit it's contents to
77 // itself. So we create a SQL-history entry here.
78 if ($cfg['QueryHistoryDB'] && $cfgRelation['historywork']) {
79 PMA_setHistory((isset($db) ?
$db : ''), (isset($table) ?
$table : ''), $cfg['Server']['user'], $sql_query);
83 if (!parent
.frames
.queryframe
.querywindow
.document
.sqlform
.LockFromUpdate ||
!parent
.frames
.queryframe
.querywindow
.document
.sqlform
.LockFromUpdate
.checked
) {
84 parent
.frames
.queryframe
.querywindow
.document
.querywindow
.db
.value
= "<?php echo (isset($db) ? addslashes($db) : '') ?>";
85 parent
.frames
.queryframe
.querywindow
.document
.querywindow
.query_history_latest_db
.value
= "<?php echo (isset($db) ? addslashes($db) : '') ?>";
86 parent
.frames
.queryframe
.querywindow
.document
.querywindow
.table
.value
= "<?php echo (isset($table) ? addslashes($table) : '') ?>";
87 parent
.frames
.queryframe
.querywindow
.document
.querywindow
.query_history_latest_table
.value
= "<?php echo (isset($table) ? addslashes($table) : '') ?>";
89 <?php
echo (isset($sql_query) ?
'parent.frames.queryframe.querywindow.document.querywindow.query_history_latest.value = "' . urlencode($sql_query) . '";' : '// no sql query update') . "\n"; ?
>
91 parent
.frames
.queryframe
.querywindow
.document
.querywindow
.submit();
96 // no submit, query was invalid
103 function focus_querywindow(sql_query
) {
104 if (parent
.frames
.queryframe
&& parent
.frames
.queryframe
.querywindow
&& !parent
.frames
.queryframe
.querywindow
.closed
&& parent
.frames
.queryframe
.querywindow
.location
) {
105 if (parent
.frames
.queryframe
.querywindow
.document
.querywindow
.querydisplay_tab
!= 'sql') {
106 parent
.frames
.queryframe
.querywindow
.document
.querywindow
.querydisplay_tab
.value
= "sql";
107 parent
.frames
.queryframe
.querywindow
.document
.querywindow
.query_history_latest
.value
= sql_query
;
108 parent
.frames
.queryframe
.querywindow
.document
.querywindow
.submit();
109 parent
.frames
.queryframe
.querywindow
.focus();
111 parent
.frames
.queryframe
.querywindow
.focus();
115 } else if (parent
.frames
.queryframe
) {
116 new_win_url
= 'querywindow.php?sql_query=' + sql_query +
'&<?php echo PMA_generate_common_url(isset($db) ? addslashes($db) : '', isset($table) ? addslashes($table) : '', '&'); ?>';
117 parent
.frames
.queryframe
.querywindow
=window
.open(new_win_url
, '','toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=yes,resizable=yes,width=<?php echo $cfg['QueryWindowWidth
']; ?>,height=<?php echo $cfg['QueryWindowHeight
']; ?>');
119 if (!parent
.frames
.queryframe
.querywindow
.opener
) {
120 parent
.frames
.queryframe
.querywindow
.opener
= parent
.frames
.queryframe
;
123 // reload_querywindow();
128 reload_querywindow();
130 if (isset($focus_querywindow) && $focus_querywindow == "true") {
132 if (parent
.frames
.queryframe
&& parent
.frames
.queryframe
.querywindow
&& !parent
.frames
.queryframe
.querywindow
.closed
&& parent
.frames
.queryframe
.querywindow
.location
) {
146 * Close database connections
148 if (isset($GLOBALS['dbh']) && $GLOBALS['dbh']) {
149 @PMA_DBI_close
($GLOBALS['dbh']);
151 if (isset($GLOBALS['userlink']) && $GLOBALS['userlink']) {
152 @PMA_DBI_close
($GLOBALS['userlink']);
156 <?php
include('./config.footer.inc.php'); ?
>
157 <script type
="text/javascript" language
="javascript" src
="libraries/tooltip.js"></script
>
164 * Generates profiling data if requested
166 if (isset($GLOBALS['cfg']['DBG']['enable'])
167 && $GLOBALS['cfg']['DBG']['enable']
168 && isset($GLOBALS['cfg']['DBG']['profile']['enable'])
169 && $GLOBALS['cfg']['DBG']['profile']['enable']) {
170 //run the basic setup code first
171 require_once('./libraries/dbg/setup.php');
172 //if the setup ran fine, then do the profiling
173 if (isset($GLOBALS['DBG']) && $GLOBALS['DBG']) {
174 require_once('./libraries/dbg/profiling.php');
175 dbg_dump_profiling_results();
180 * Sends bufferized data
182 if (isset($GLOBALS['cfg']['OBGzip']) && $GLOBALS['cfg']['OBGzip']
183 && isset($GLOBALS['ob_mode']) && $GLOBALS['ob_mode']) {
184 PMA_outBufferPost($GLOBALS['ob_mode']);
188 * Stops the script execution