isSuperuser(); /** * Gets a core script and starts output buffering work */ require_once 'libraries/sql_query_form.lib.php'; /** * load relation params */ $cfgRelation = PMA_getRelationsParam(); /** * load bookmark support */ require_once 'libraries/bookmark.lib.php'; $querydisplay_tabs = array( 'sql', 'files', 'history', 'full', ); if (isset($_REQUEST['querydisplay_tab']) && in_array($_REQUEST['querydisplay_tab'], $querydisplay_tabs) ) { $querydisplay_tab = $_REQUEST['querydisplay_tab']; } else { $querydisplay_tab = $GLOBALS['cfg']['QueryWindowDefTab']; } /** * $_REQUEST['no_js'] is set if open new window by JavaScript failed * so this page is loaded in main frame */ $no_js = PMA_ifSetOr($_REQUEST['no_js'], false); if ($no_js) { $querydisplay_tab = 'full'; $tabs = false; } else { $tabs = array(); $tabs['sql']['icon'] = 'b_sql.png'; $tabs['sql']['text'] = __('SQL'); $tabs['sql']['fragment'] = '#'; $tabs['sql']['attr'] = 'onclick="PMA_querywindowCommit(\'sql\');return false;"'; $tabs['sql']['active'] = (bool) ($querydisplay_tab == 'sql'); $tabs['import']['icon'] = 'b_import.png'; $tabs['import']['text'] = __('Import files'); $tabs['import']['fragment'] = '#'; $tabs['import']['attr'] = 'onclick="PMA_querywindowCommit(\'files\');return false;"'; $tabs['import']['active'] = (bool) ($querydisplay_tab == 'files'); $tabs['history']['icon'] = 'b_bookmark.png'; $tabs['history']['text'] = __('SQL history'); $tabs['history']['fragment'] = '#'; $tabs['history']['attr'] = 'onclick="PMA_querywindowCommit(\'history\');return false;"'; $tabs['history']['active'] = (bool) ($querydisplay_tab == 'history'); if ($GLOBALS['cfg']['QueryWindowDefTab'] == 'full') { $tabs['all']['text'] = __('All'); $tabs['all']['fragment'] = '#'; $tabs['all']['attr'] = 'onclick="PMA_querywindowCommit(\'full\');return false;"'; $tabs['all']['active'] = (bool) ($querydisplay_tab == 'full'); } } $titles['Change'] = PMA_Util::getIcon('b_edit.png', __('Change')); $url_query = PMA_URL_getCommon($db, $table); if (! empty($sql_query)) { $show_query = 1; } if ($no_js) { // ... we redirect to appropriate query sql page // works only full if $db and $table is also stored/grabbed from $_COOKIE if (strlen($table)) { include 'tbl_sql.php'; } elseif (strlen($db)) { include 'db_sql.php'; } else { include 'server_sql.php'; } exit; } /** * Defines the query to be displayed in the query textarea */ if (! empty($show_query)) { $query_to_display = $sql_query; } else if (! empty($_REQUEST['sql_query'])) { $query_to_display = htmlspecialchars($_REQUEST['sql_query']); $show_query = 1; } else { $query_to_display = ''; } $sql_query = ''; /** * prepare JavaScript functionality */ $response = PMA_Response::getInstance(); $response->getFooter()->setMinimal(); $header = $response->getHeader(); $header->disableMenu(); $header->setBodyId('bodyquerywindow'); $scripts = $header->getScripts(); $scripts->addFile('common.js'); $scripts->addFile('querywindow.js'); if (PMA_isValid($_REQUEST['auto_commit'], 'identical', 'true')) { $scripts->addEvent('load', 'PMA_queryAutoCommit'); } // always set focus to the textarea if ($querydisplay_tab == 'sql' || $querydisplay_tab == 'full') { $scripts->addEvent('load', 'PMA_querywindowSetFocus'); } echo '
'; if ($tabs) { echo PMA_Util::getHtmlTabs($tabs, array(), 'topmenu', true); unset($tabs); } echo PMA_getHtmlForSqlQueryForm($query_to_display, $querydisplay_tab); // Hidden forms and query frame interaction stuff $_sql_history = PMA_getHistory($GLOBALS['cfg']['Server']['user']); if (! empty($_sql_history) && ($querydisplay_tab == 'history' || $querydisplay_tab == 'full') ) { $tab = $querydisplay_tab != 'full' ? 'sql' : 'full'; echo __('SQL history:') . '
' . '' . "\n"; } echo '
'; echo PMA_URL_getHiddenInputs('', ''); echo ''; echo ''; echo ''; echo ''; echo '
'; echo '
';