<?php /* vim: set expandtab sw=4 ts=4 sts=4: */ /** * Server SQL executor * * @package PhpMyAdmin */ /** * */ require_once 'libraries/common.inc.php'; require_once 'libraries/config/page_settings.class.php'; PMA_PageSettings::showGroup('Sql_queries'); /** * Does the common work */ $response = PMA_Response::getInstance(); $header = $response->getHeader(); $scripts = $header->getScripts(); $scripts->addFile('makegrid.js'); $scripts->addFile('jquery/jquery.uitablefilter.js'); $scripts->addFile('sql.js'); require_once 'libraries/server_common.inc.php'; require_once 'libraries/sql_query_form.lib.php'; /** * Query box, bookmark, insert data from textfile */ $response->addHTML(PMA_getHtmlForSqlQueryForm());
/* vim: set expandtab sw=4 ts=4 sts=4: */ /** * Database SQL executor * * @package PhpMyAdmin */ /** * */ require_once 'libraries/common.inc.php'; /** * Runs common work */ $response = PMA_Response::getInstance(); $header = $response->getHeader(); $scripts = $header->getScripts(); $scripts->addFile('functions.js'); $scripts->addFile('makegrid.js'); $scripts->addFile('jquery/jquery.uitablefilter.js'); $scripts->addFile('sql.js'); require 'libraries/db_common.inc.php'; require_once 'libraries/sql_query_form.lib.php'; // After a syntax error, we return to this script // with the typed query in the textarea. $goto = 'db_sql.php'; $back = 'db_sql.php'; /** * Query box, bookmark, insert data from textfile */ $response->addHTML(PMA_getHtmlForSqlQueryForm(true, false, isset($_REQUEST['delimiter']) ? htmlspecialchars($_REQUEST['delimiter']) : ';'));
/** * Test for PMA_getHtmlForSqlQueryForm * * @return void */ public function testPMAGetHtmlForSqlQueryForm() { //Call the test function $GLOBALS['is_upload'] = true; $query = "select * from PMA"; $html = PMA_getHtmlForSqlQueryForm($query); //validate 1: query $this->assertContains(htmlspecialchars($query), $html); //validate 2: $enctype $enctype = ' enctype="multipart/form-data"'; $this->assertContains($enctype, $html); //validate 3: sqlqueryform $this->assertContains('id="sqlqueryform" name="sqlform">', $html); //validate 4: $db, $table $table = $GLOBALS['table']; $db = $GLOBALS['db']; $this->assertContains(PMA_URL_getHiddenInputs($db, $table), $html); //validate 5: $goto $goto = empty($GLOBALS['goto']) ? 'tbl_sql.php' : $GLOBALS['goto']; $this->assertContains(htmlspecialchars($goto), $html); //validate 6: PMA_Kanji_encodingForm $this->assertContains(PMA_Kanji_encodingForm(), $html); }
/** * Function to export as sql dump * * @param array $entries entries * * @return string HTML SQL query form */ function PMA_exportAsSQLDump($entries) { $html = ''; $new_query = "# " . __('You can execute the dump by creating and using a temporary database. ' . 'Please ensure that you have the privileges to do so.') . "\n" . "# " . __('Comment out these two lines if you do not need them.') . "\n" . "\n" . "CREATE database IF NOT EXISTS pma_temp_db; \n" . "USE pma_temp_db; \n" . "\n"; foreach ($entries as $entry) { $new_query .= $entry['statement']; } $msg = PMA_Message::success(__('SQL statements exported. Please copy the dump or execute it.')); $html .= $msg->getDisplay(); $db_temp = $GLOBALS['db']; $table_temp = $GLOBALS['table']; $GLOBALS['db'] = $GLOBALS['table'] = ''; include_once './libraries/sql_query_form.lib.php'; $html .= PMA_getHtmlForSqlQueryForm($new_query, 'sql'); $GLOBALS['db'] = $db_temp; $GLOBALS['table'] = $table_temp; return $html; }
$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 '<div id="querywindowcontainer">'; 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:') . '<br />' . '<ul>'; foreach ($_sql_history as $query) { echo '<li>' . "\n"; // edit link $url_params = array('querydisplay_tab' => $tab, 'sql_query' => $query['sqlquery'], 'db' => $query['db'], 'table' => $query['table']); echo '<a href="querywindow.php' . PMA_URL_getCommon($url_params) . '">' . $titles['Change'] . '</a>'; // execute link $url_params['auto_commit'] = 'true'; echo '<a href="import.php' . PMA_URL_getCommon($url_params) . '"' . ' target="frame_content">'; if (!empty($query['db'])) { echo '[';