/** * Prints details about the current Git commit revision * * @return void */ function PMA_printGitRevision() { if (!$GLOBALS['PMA_Config']->get('PMA_VERSION_GIT')) { $response = PMA_Response::getInstance(); $response->isSuccess(false); return; } // load revision data from repo $GLOBALS['PMA_Config']->checkGitRevision(); // if using a remote commit fast-forwarded, link to GitHub $commit_hash = substr($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITHASH'), 0, 7); $commit_hash = '<strong title="' . htmlspecialchars($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_MESSAGE')) . '">' . $commit_hash . '</strong>'; if ($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_ISREMOTECOMMIT')) { $commit_hash = '<a href="' . PMA_linkURL('https://github.com/phpmyadmin/phpmyadmin/commit/' . $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITHASH')) . '" target="_blank">' . $commit_hash . '</a>'; } $branch = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_BRANCH'); if ($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_ISREMOTEBRANCH')) { $branch = '<a href="' . PMA_linkURL('https://github.com/phpmyadmin/phpmyadmin/tree/' . $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_BRANCH')) . '" target="_blank">' . $branch . '</a>'; } if ($branch !== false) { $branch = sprintf(__('%1$s from %2$s branch'), $commit_hash, $branch); } else { $branch = $commit_hash . ' (' . __('no branch') . ')'; } $committer = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITTER'); $author = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_AUTHOR'); PMA_printListItem(__('Git revision:') . ' ' . $branch . ',<br /> ' . sprintf(__('committed on %1$s by %2$s'), PMA_Util::localisedDate(strtotime($committer['date'])), '<a href="' . PMA_linkURL('mailto:' . $committer['email']) . '">' . htmlspecialchars($committer['name']) . '</a>') . ($author != $committer ? ', <br />' . sprintf(__('authored on %1$s by %2$s'), PMA_Util::localisedDate(strtotime($author['date'])), '<a href="' . PMA_linkURL('mailto:' . $author['email']) . '">' . htmlspecialchars($author['name']) . '</a>') : ''), 'li_pma_version_git', null, null, null); }
/** * This function is called from one of the other functions in this file * and it completes the handling of the export functionality. * * @param string $item_name The name of the item that we are exporting * @param string $export_data The SQL query to create the requested item * * @return void */ function PMA_RTE_handleExport($item_name, $export_data) { global $db; $item_name = htmlspecialchars(PMA_Util::backquote($_GET['item_name'])); if ($export_data !== false) { $export_data = '<textarea cols="40" rows="15" style="width: 100%;">' . htmlspecialchars(trim($export_data)) . '</textarea>'; $title = sprintf(PMA_RTE_getWord('export'), $item_name); if ($GLOBALS['is_ajax_request'] == true) { $response = PMA_Response::getInstance(); $response->addJSON('message', $export_data); $response->addJSON('title', $title); exit; } else { echo "<fieldset>\n" . "<legend>{$title}</legend>\n" . $export_data . "</fieldset>\n"; } } else { $_db = htmlspecialchars(PMA_Util::backquote($db)); $message = __('Error in processing request:') . ' ' . sprintf(PMA_RTE_getWord('not_found'), $item_name, $_db); $response = PMA_message::error($message); if ($GLOBALS['is_ajax_request'] == true) { $response = PMA_Response::getInstance(); $response->isSuccess(false); $response->addJSON('message', $message); exit; } else { $response->display(); } } }
/** * Renders the navigation tree, or part of it * * @return string The navigation tree */ public function getDisplay() { /* Init */ $retval = ''; if (!PMA_Response::getInstance()->isAjax()) { $header = new PMA_NavigationHeader(); $retval = $header->getDisplay(); } $tree = new PMA_NavigationTree(); if (!PMA_Response::getInstance()->isAjax() || !empty($_REQUEST['full']) || !empty($_REQUEST['reload'])) { $treeRender = $tree->renderState(); } else { $treeRender = $tree->renderPath(); } if (!$treeRender) { $retval .= PMA_Message::error(__('An error has occurred while loading the navigation tree'))->getDisplay(); } else { $retval .= $treeRender; } if (!PMA_Response::getInstance()->isAjax()) { // closes the tags that were opened by the navigation header $retval .= '</div>'; $retval .= '</div>'; $retval .= $this->_getDropHandler(); $retval .= '</div>'; } return $retval; }
/** * Send TRI or EVN editor via ajax or by echoing. * * @param string $type TRI or EVN * @param string $mode Editor mode 'add' or 'edit' * @param array $item Data necessary to create the editor * @param string $title Title of the editor * @param string $db Database * @param string $operation Operation 'change' or '' * * @return void */ function PMA_RTE_sendEditor($type, $mode, $item, $title, $db, $operation = null) { if ($item !== false) { // Show form if ($type == 'TRI') { $editor = PMA_TRI_getEditorForm($mode, $item); } else { // EVN $editor = PMA_EVN_getEditorForm($mode, $operation, $item); } if ($GLOBALS['is_ajax_request']) { $response = PMA_Response::getInstance(); $response->addJSON('message', $editor); $response->addJSON('title', $title); } else { echo "\n\n<h2>{$title}</h2>\n\n{$editor}"; unset($_POST); } exit; } else { $message = __('Error in processing request:') . ' '; $message .= sprintf(PMA_RTE_getWord('not_found'), htmlspecialchars(PMA_Util::backquote($_REQUEST['item_name'])), htmlspecialchars(PMA_Util::backquote($db))); $message = PMA_message::error($message); if ($GLOBALS['is_ajax_request']) { $response = PMA_Response::getInstance(); $response->isSuccess(false); $response->addJSON('message', $message); exit; } else { $message->display(); } } }
/** * Function to handle the creation or edit of an index * * @param string $db current db * @param string $table current table * @param PMA_Index $index current index * * @return void */ function PMA_handleCreateOrEditIndex($db, $table, $index) { $error = false; $sql_query = PMA_getSqlQueryForIndexCreateOrEdit($db, $table, $index, $error); // If there is a request for SQL previewing. if (isset($_REQUEST['preview_sql'])) { PMA_previewSQL($sql_query); } if (!$error) { $GLOBALS['dbi']->query($sql_query); $message = PMA_Message::success(__('Table %1$s has been altered successfully.')); $message->addParam($table); if ($GLOBALS['is_ajax_request'] == true) { $response = PMA_Response::getInstance(); $response->addJSON('message', $message); $response->addJSON('index_table', PMA_Index::getView($table, $db)); $response->addJSON('sql_query', PMA_Util::getMessage(null, $sql_query)); } else { include 'tbl_structure.php'; } exit; } else { $response = PMA_Response::getInstance(); $response->isSuccess(false); $response->addJSON('message', $error); exit; } }
public function __construct() { $response = PMA_Response::getInstance(); $scripts = $response->getHeader()->getScripts(); $scripts->addFile('codemirror/mode/javascript/javascript.js'); $scripts->addFile('transformations/json.js'); }
/** * User is not allowed to login to MySQL -> authentication failed * * @global string the MySQL error message PHP returns * @global string the connection type (persistent or not) * @global string the MySQL server port to use * @global string the MySQL socket port to use * @global array the current server settings * @global string the font face to use in case of failure * @global string the default font size to use in case of failure * @global string the big font size to use in case of failure * @global boolean tell the "PMA_mysqlDie()" function headers have been * sent * * @return boolean always true (no return indeed) */ public function authFails() { $conn_error = PMA_DBI_getError(); if (!$conn_error) { $conn_error = __('Cannot connect: invalid settings.'); } /* HTML header */ $response = PMA_Response::getInstance(); $response->getFooter()->setMinimal(); $header = $response->getHeader(); $header->setTitle(__('Access denied')); $header->disableMenu(); echo '<br /><br /> <center> <h1>'; echo sprintf(__('Welcome to %s'), ' phpMyAdmin '); echo '</h1> </center> <br /> <table cellpadding="0" cellspacing="3" style="margin: 0 auto" width="80%"> <tr> <td>'; if (isset($GLOBALS['allowDeny_forbidden']) && $GLOBALS['allowDeny_forbidden']) { trigger_error(__('Access denied'), E_USER_NOTICE); } else { // Check whether user has configured something if ($GLOBALS['PMA_Config']->source_mtime == 0) { echo '<p>' . sprintf(__('You probably did not create a configuration file.' . ' You might want to use the %1$ssetup script%2$s to' . ' create one.'), '<a href="setup/">', '</a>') . '</p>' . "\n"; } elseif (!isset($GLOBALS['errno']) || isset($GLOBALS['errno']) && $GLOBALS['errno'] != 2002 && $GLOBALS['errno'] != 2003) { // if we display the "Server not responding" error, do not confuse // users by telling them they have a settings problem // (note: it's true that they could have a badly typed host name, // but anyway the current message tells that the server // rejected the connection, which is not really what happened) // 2002 is the error given by mysqli // 2003 is the error given by mysql trigger_error(__('phpMyAdmin tried to connect to the MySQL server, and the' . ' server rejected the connection. You should check the' . ' host, username and password in your configuration and' . ' make sure that they correspond to the information given' . ' by the administrator of the MySQL server.'), E_USER_WARNING); } PMA_Util::mysqlDie($conn_error, '', true, '', false); } $GLOBALS['error_handler']->dispUserErrors(); echo '</td> </tr>'; if (count($GLOBALS['cfg']['Servers']) > 1) { // offer a chance to login to other servers if the current one failed include_once './libraries/select_server.lib.php'; echo '<tr>' . "\n"; echo ' <td>' . "\n"; PMA_selectServer(true, true); echo ' </td>' . "\n"; echo '</tr>' . "\n"; } echo '</table>' . "\n"; exit; return true; }
/** * No-arg constructor */ public function __construct() { if (!empty($GLOBALS['cfg']['CodemirrorEnable'])) { $response = PMA_Response::getInstance(); $scripts = $response->getHeader()->getScripts(); $scripts->addFile('codemirror/lib/codemirror.js'); $scripts->addFile('codemirror/mode/xml/xml.js'); $scripts->addFile('codemirror/addon/runmode/runmode.js'); $scripts->addFile('transformations/xml.js'); } }
/** * Displays authentication form * * @return boolean */ public function authForm() { /* Perform logout to custom URL */ if (!empty($_REQUEST['old_usr']) && !empty($GLOBALS['cfg']['Server']['LogoutURL'])) { PMA_sendHeaderLocation($GLOBALS['cfg']['Server']['LogoutURL']); if (!defined('TESTSUITE')) { exit; } else { return false; } } if (empty($GLOBALS['cfg']['Server']['auth_http_realm'])) { if (empty($GLOBALS['cfg']['Server']['verbose'])) { $server_message = $GLOBALS['cfg']['Server']['host']; } else { $server_message = $GLOBALS['cfg']['Server']['verbose']; } $realm_message = 'phpMyAdmin ' . $server_message; } else { $realm_message = $GLOBALS['cfg']['Server']['auth_http_realm']; } // remove non US-ASCII to respect RFC2616 $realm_message = preg_replace('/[^\\x20-\\x7e]/i', '', $realm_message); header('WWW-Authenticate: Basic realm="' . $realm_message . '"'); header('HTTP/1.0 401 Unauthorized'); if (php_sapi_name() !== 'cgi-fcgi') { header('status: 401 Unauthorized'); } /* HTML header */ $response = PMA_Response::getInstance(); $response->getFooter()->setMinimal(); $header = $response->getHeader(); $header->setTitle(__('Access denied!')); $header->disableMenuAndConsole(); $header->setBodyId('loginform'); $response->addHTML('<h1>'); $response->addHTML(sprintf(__('Welcome to %s'), ' phpMyAdmin')); $response->addHTML('</h1>'); $response->addHTML('<h3>'); $response->addHTML(PMA_Message::error(__('Wrong username/password. Access denied.'))); $response->addHTML('</h3>'); if (file_exists(CUSTOM_FOOTER_FILE)) { include CUSTOM_FOOTER_FILE; } if (!defined('TESTSUITE')) { exit; } else { return false; } }
/** * Test for AuthenticationHttp::auth * * @return void */ public function testAuth() { if (!defined('PMA_TEST_HEADERS')) { $this->markTestSkipped('Cannot redefine constant/function - missing runkit extension'); } $_REQUEST['old_usr'] = '******'; $GLOBALS['cfg']['Server']['LogoutURL'] = 'http://phpmyadmin.net/logout'; $this->assertFalse($this->object->auth()); $this->assertContains('Location: http://phpmyadmin.net/logout', $GLOBALS['header'][0]); // case 2 $restoreInstance = PMA_Response::getInstance(); // mock footer $mockFooter = $this->getMockBuilder('PMA_Footer')->disableOriginalConstructor()->setMethods(array('setMinimal'))->getMock(); $mockFooter->expects($this->once())->method('setMinimal')->with(); // mock header $mockHeader = $this->getMockBuilder('PMA_Header')->disableOriginalConstructor()->setMethods(array('setBodyId', 'setTitle', 'disableMenuAndConsole', 'addHTML'))->getMock(); $mockHeader->expects($this->once())->method('setBodyId')->with('loginform'); $mockHeader->expects($this->once())->method('setTitle')->with('Access denied!'); $mockHeader->expects($this->once())->method('disableMenuAndConsole')->with(); // set mocked headers and footers $mockResponse = $this->getMockBuilder('PMA_Response')->disableOriginalConstructor()->setMethods(array('getHeader', 'getFooter', 'addHTML'))->getMock(); $mockResponse->expects($this->once())->method('getFooter')->with()->will($this->returnValue($mockFooter)); $mockResponse->expects($this->once())->method('getHeader')->with()->will($this->returnValue($mockHeader)); $mockResponse->expects($this->exactly(6))->method('addHTML')->with(); $attrInstance = new ReflectionProperty('PMA_Response', '_instance'); $attrInstance->setAccessible(true); $attrInstance->setValue($mockResponse); $GLOBALS['header'] = array(); $_REQUEST['old_usr'] = ''; $GLOBALS['cfg']['Server']['verbose'] = 'verboseMessagê'; $this->assertFalse($this->object->auth()); $this->assertEquals(array('WWW-Authenticate: Basic realm="phpMyAdmin verboseMessag"', 'HTTP/1.0 401 Unauthorized', 'status: 401 Unauthorized'), $GLOBALS['header']); $attrInstance->setValue($restoreInstance); // case 3 $GLOBALS['header'] = array(); $GLOBALS['cfg']['Server']['verbose'] = ''; $GLOBALS['cfg']['Server']['host'] = 'hòst'; $this->assertFalse($this->object->auth()); $this->assertEquals(array('WWW-Authenticate: Basic realm="phpMyAdmin hst"', 'HTTP/1.0 401 Unauthorized', 'status: 401 Unauthorized'), $GLOBALS['header']); // case 4 $GLOBALS['header'] = array(); $GLOBALS['cfg']['Server']['host'] = ''; $GLOBALS['cfg']['Server']['auth_http_realm'] = 'rêäealmmessage'; $this->assertFalse($this->object->auth()); $this->assertEquals(array('WWW-Authenticate: Basic realm="realmmessage"', 'HTTP/1.0 401 Unauthorized', 'status: 401 Unauthorized'), $GLOBALS['header']); }
/** * Send the message as an ajax request * * @param array $change_password_message Message to display * @param string $sql_query SQL query executed * * @return void */ function PMA_getChangePassMessage($change_password_message, $sql_query = '') { if ($GLOBALS['is_ajax_request'] == true) { /** * If in an Ajax request, we don't need to show the rest of the page */ $response = PMA_Response::getInstance(); if ($change_password_message['error']) { $response->addJSON('message', $change_password_message['msg']); $response->isSuccess(false); } else { $sql_query = PMA_Util::getMessage($change_password_message['msg'], $sql_query, 'success'); $response->addJSON('message', $sql_query); } exit; } }
/** * Renders the navigation tree, or part of it * * @return string The navigation tree */ public function getDisplay() { /* Init */ $retval = ''; if (!PMA_Response::getInstance()->isAjax()) { $header = new PMA_NavigationHeader(); $retval = $header->getDisplay(); } $tree = new PMA_NavigationTree(); if (!PMA_Response::getInstance()->isAjax() || !empty($_REQUEST['full']) || !empty($_REQUEST['reload'])) { if ($GLOBALS['cfg']['ShowDatabasesNavigationAsTree']) { // provide database tree in navigation $navRender = $tree->renderState(); } else { // provide legacy pre-4.0 navigation $navRender = $tree->renderDbSelect(); } } else { $navRender = $tree->renderPath(); } if (!$navRender) { $retval .= PMA_Message::error(__('An error has occurred while loading the navigation display'))->getDisplay(); } else { $retval .= $navRender; } if (!PMA_Response::getInstance()->isAjax()) { // closes the tags that were opened by the navigation header $retval .= '</div>'; // pma_navigation_tree $retval .= '<div id="pma_navi_settings_container">'; if (!defined('PMA_DISABLE_NAVI_SETTINGS')) { $retval .= PMA_PageSettings::getNaviSettings(); } $retval .= '</div>'; //pma_navi_settings_container $retval .= '</div>'; // pma_navigation_content $retval .= $this->_getDropHandler(); $retval .= '</div>'; // pma_navigation } return $retval; }
/** * Get Ajax return when $_REQUEST['type'] === 'setval' * * @param Array $variable_doc_links documentation links * * @return null */ function PMA_getAjaxReturnForSetVal($variable_doc_links) { $response = PMA_Response::getInstance(); $value = $_REQUEST['varValue']; $matches = array(); if (isset($variable_doc_links[$_REQUEST['varName']][3]) && $variable_doc_links[$_REQUEST['varName']][3] == 'byte' && preg_match('/^\\s*(\\d+(\\.\\d+)?)\\s*(mb|kb|mib|kib|gb|gib)\\s*$/i', $value, $matches)) { $exp = array('kb' => 1, 'kib' => 1, 'mb' => 2, 'mib' => 2, 'gb' => 3, 'gib' => 3); $value = floatval($matches[1]) * PMA_Util::pow(1024, $exp[mb_strtolower($matches[3])]); } else { $value = PMA_Util::sqlAddSlashes($value); } if (!is_numeric($value)) { $value = "'" . $value . "'"; } if (!preg_match("/[^a-zA-Z0-9_]+/", $_REQUEST['varName']) && $GLOBALS['dbi']->query('SET GLOBAL ' . $_REQUEST['varName'] . ' = ' . $value)) { // Some values are rounded down etc. $varValue = $GLOBALS['dbi']->fetchSingleRow('SHOW GLOBAL VARIABLES WHERE Variable_name="' . PMA_Util::sqlAddSlashes($_REQUEST['varName']) . '";', 'NUM'); $response->addJSON('variable', PMA_formatVariable($_REQUEST['varName'], $varValue[1], $variable_doc_links)); } else { $response->isSuccess(false); $response->addJSON('error', __('Setting variable failed')); } }
/** * Get List of information: Changes / copies a user * * @return array */ function PMA_getDataForChangeOrCopyUser() { $queries = null; $password = null; if (isset($_REQUEST['change_copy'])) { $user_host_condition = ' WHERE `User` = ' . "'" . PMA_Util::sqlAddSlashes($_REQUEST['old_username']) . "'" . ' AND `Host` = ' . "'" . PMA_Util::sqlAddSlashes($_REQUEST['old_hostname']) . "';"; $row = $GLOBALS['dbi']->fetchSingleRow('SELECT * FROM `mysql`.`user` ' . $user_host_condition); if (!$row) { $response = PMA_Response::getInstance(); $response->addHTML(PMA_Message::notice(__('No user found.'))->getDisplay()); unset($_REQUEST['change_copy']); } else { extract($row, EXTR_OVERWRITE); // Recent MySQL versions have the field "Password" in mysql.user, // so the previous extract creates $Password but this script // uses $password if (!isset($password) && isset($Password)) { $password = $Password; } if (PMA_Util::getServerType() == 'MySQL' && PMA_MYSQL_INT_VERSION >= 50606 && PMA_MYSQL_INT_VERSION < 50706 && isset($password) && empty($password) && isset($plugin) && $plugin == 'sha256_password') { $password = $authentication_string; } // Always use 'authentication_string' column // for MySQL 5.7.6+ since it does not have // the 'password' column at all if (PMA_Util::getServerType() == 'MySQL' && PMA_MYSQL_INT_VERSION >= 50706 && isset($authentication_string)) { $password = $authentication_string; } $queries = array(); } } return array($queries, $password); }
/** * Function to export as entries * * @param array $entries entries * * @return void */ function PMA_exportAsFileDownload($entries) { @ini_set('url_rewriter.tags', ''); $dump = "# " . sprintf(__('Tracking report for table `%s`'), htmlspecialchars($_REQUEST['table'])) . "\n" . "# " . date('Y-m-d H:i:s') . "\n"; foreach ($entries as $entry) { $dump .= $entry['statement']; } $filename = 'log_' . htmlspecialchars($_REQUEST['table']) . '.sql'; PMA_Response::getInstance()->disable(); PMA_downloadHeader($filename, 'text/x-sql', mb_strlen($dump)); echo $dump; exit; }
/** * Function to report all the collected php errors. * Must be called at the end of each script * by the $GLOBALS['error_handler'] only. * * @return void */ public function reportErrors() { // if there're no actual errors, if (!$this->hasErrors() || $this->countErrors() == $this->countUserErrors()) { // then simply return. return; } // Delete all the prev_errors in session & store new prev_errors in session $this->savePreviousErrors(); $response = PMA_Response::getInstance(); $jsCode = ''; if ($GLOBALS['cfg']['SendErrorReports'] == 'always') { if ($response->isAjax()) { // set flag for automatic report submission. $response->addJSON('_sendErrorAlways', '1'); } else { // send the error reports asynchronously & without asking user $jsCode .= '$("#pma_report_errors_form").submit();' . 'PMA_ajaxShowMessage( PMA_messages["phpErrorsBeingSubmitted"], false );'; // js code to appropriate focusing, $jsCode .= '$("html, body").animate({ scrollTop:$(document).height() }, "slow");'; } } elseif ($GLOBALS['cfg']['SendErrorReports'] == 'ask') { //ask user whether to submit errors or not. if (!$response->isAjax()) { // js code to show appropriate msgs, event binding & focusing. $jsCode = 'PMA_ajaxShowMessage(PMA_messages["phpErrorsFound"]);' . '$("#pma_ignore_errors_popup").bind("click", function() { PMA_ignorePhpErrors() });' . '$("#pma_ignore_all_errors_popup").bind("click", function() { PMA_ignorePhpErrors(false) });' . '$("#pma_ignore_errors_bottom").bind("click", function() { PMA_ignorePhpErrors() });' . '$("#pma_ignore_all_errors_bottom").bind("click", function() { PMA_ignorePhpErrors(false) });' . '$("html, body").animate({ scrollTop:$(document).height() }, "slow");'; } } // The errors are already sent from the response. // Just focus on errors division upon load event. $response->getFooter()->getScripts()->addCode($jsCode); }
// some types, for example longtext, are reported as // "longtext character set latin7" when their charset and / or collation // differs from the ones of the corresponding database. $tmp = mb_strpos($type, 'character set'); if ($tmp) { $type = mb_substr($type, 0, $tmp - 1); } // rtrim the type, for cases like "float unsigned" $type = rtrim($type); if (isset($submit_length) && $submit_length != false) { $length = $submit_length; } // Variable tell if current column is bound in a foreign key constraint or not. if (isset($columnMeta['Field']) && isset($_form_params['table'])) { $columnMeta['column_status'] = PMA_checkChildForeignReferences($_form_params['db'], $_form_params['table'], $columnMeta['Field'], $foreigners, $child_references); } // old column attributes if ($is_backup) { $_form_params = PMA_getFormParamsForOldColumn($columnMeta, $length, $_form_params, $columnNumber, $type, $extracted_columnspec); } $content_cells[$columnNumber] = PMA_getHtmlForColumnAttributes($columnNumber, isset($columnMeta) ? $columnMeta : array(), mb_strtoupper($type), $length_values_input_size, $length, isset($default_current_timestamp) ? $default_current_timestamp : null, isset($extracted_columnspec) ? $extracted_columnspec : null, isset($submit_attribute) ? $submit_attribute : null, isset($analyzed_sql) ? $analyzed_sql : null, isset($submit_default_current_timestamp) ? $submit_default_current_timestamp : null, $comments_map, isset($fields_meta) ? $fields_meta : null, $is_backup, isset($move_columns) ? $move_columns : array(), $cfgRelation, isset($available_mime) ? $available_mime : array(), isset($mime_map) ? $mime_map : array()); } // end for $html = PMA_getHtmlForTableCreateOrAddField($action, $_form_params, $content_cells, $header_cells); unset($_form_params); $response = PMA_Response::getInstance(); $header = $response->getHeader(); $scripts = $header->getScripts(); $scripts->addFile('jquery/jquery.uitablefilter.js'); $scripts->addFile('indexes.js'); $response->addHTML($html);
/** * Handles requests for executing a routine * * @return Does not return */ function PMA_RTN_handleExecute() { global $_GET, $_POST, $_REQUEST, $GLOBALS, $db; /** * Handle all user requests other than the default of listing routines */ if (!empty($_REQUEST['execute_routine']) && !empty($_REQUEST['item_name'])) { // Build the queries $routine = PMA_RTN_getDataFromName($_REQUEST['item_name'], $_REQUEST['item_type'], false); if ($routine !== false) { $queries = array(); $end_query = array(); $args = array(); $all_functions = $GLOBALS['PMA_Types']->getAllFunctions(); for ($i = 0; $i < $routine['item_num_params']; $i++) { if (isset($_REQUEST['params'][$routine['item_param_name'][$i]])) { $value = $_REQUEST['params'][$routine['item_param_name'][$i]]; if (is_array($value)) { // is SET type $value = implode(',', $value); } $value = PMA_Util::sqlAddSlashes($value); if (!empty($_REQUEST['funcs'][$routine['item_param_name'][$i]]) && in_array($_REQUEST['funcs'][$routine['item_param_name'][$i]], $all_functions)) { $queries[] = "SET @p{$i}={$_REQUEST['funcs'][$routine['item_param_name'][$i]]}('{$value}');\n"; } else { $queries[] = "SET @p{$i}='{$value}';\n"; } $args[] = "@p{$i}"; } else { $args[] = "@p{$i}"; } if ($routine['item_type'] == 'PROCEDURE') { if ($routine['item_param_dir'][$i] == 'OUT' || $routine['item_param_dir'][$i] == 'INOUT') { $end_query[] = "@p{$i} AS " . PMA_Util::backquote($routine['item_param_name'][$i]); } } } if ($routine['item_type'] == 'PROCEDURE') { $queries[] = "CALL " . PMA_Util::backquote($routine['item_name']) . "(" . implode(', ', $args) . ");\n"; if (count($end_query)) { $queries[] = "SELECT " . implode(', ', $end_query) . ";\n"; } } else { $queries[] = "SELECT " . PMA_Util::backquote($routine['item_name']) . "(" . implode(', ', $args) . ") " . "AS " . PMA_Util::backquote($routine['item_name']) . ";\n"; } // Get all the queries as one SQL statement $multiple_query = implode("", $queries); $outcome = true; $affected = 0; // Execute query if (!PMA_DBI_try_multi_query($multiple_query)) { $outcome = false; } // Generate output if ($outcome) { // Pass the SQL queries through the "pretty printer" $output = '<code class="sql" style="margin-bottom: 1em;">'; $output .= PMA_SQP_formatHtml(PMA_SQP_parse(implode($queries))); $output .= '</code>'; // Display results $output .= "<fieldset><legend>"; $output .= sprintf(__('Execution results of routine %s'), PMA_Util::backquote(htmlspecialchars($routine['item_name']))); $output .= "</legend>"; $num_of_rusults_set_to_display = 0; do { $result = PMA_DBI_store_result(); $num_rows = PMA_DBI_num_rows($result); if ($result !== false && $num_rows > 0) { $output .= "<table><tr>"; foreach (PMA_DBI_get_fields_meta($result) as $key => $field) { $output .= "<th>"; $output .= htmlspecialchars($field->name); $output .= "</th>"; } $output .= "</tr>"; $color_class = 'odd'; while ($row = PMA_DBI_fetch_assoc($result)) { $output .= "<tr>"; foreach ($row as $key => $value) { if ($value === null) { $value = '<i>NULL</i>'; } else { $value = htmlspecialchars($value); } $output .= "<td class='" . $color_class . "'>" . $value . "</td>"; } $output .= "</tr>"; $color_class = $color_class == 'odd' ? 'even' : 'odd'; } $output .= "</table>"; $num_of_rusults_set_to_display++; $affected = $num_rows; } if (!PMA_DBI_more_results()) { break; } $output .= "<br/>"; PMA_DBI_free_result($result); } while (PMA_DBI_next_result()); $output .= "</fieldset>"; $message = __('Your SQL query has been executed successfully'); if ($routine['item_type'] == 'PROCEDURE') { $message .= '<br />'; // TODO : message need to be modified according to the // output from the routine $message .= sprintf(_ngettext('%d row affected by the last statement inside the procedure', '%d rows affected by the last statement inside the procedure', $affected), $affected); } $message = PMA_message::success($message); if ($num_of_rusults_set_to_display == 0) { $notice = __('MySQL returned an empty result set (i.e. zero rows).'); $output .= PMA_message::notice($notice)->getDisplay(); } } else { $output = ''; $message = PMA_message::error(sprintf(__('The following query has failed: "%s"'), htmlspecialchars($query)) . '<br /><br />' . __('MySQL said: ') . PMA_DBI_getError(null)); } // Print/send output if ($GLOBALS['is_ajax_request']) { $response = PMA_Response::getInstance(); $response->isSuccess($message->isSuccess()); $response->addJSON('message', $message->getDisplay() . $output); $response->addJSON('dialog', false); exit; } else { echo $message->getDisplay() . $output; if ($message->isError()) { // At least one query has failed, so shouldn't // execute any more queries, so we quit. exit; } unset($_POST); // Now deliberately fall through to displaying the routines list } } else { $message = __('Error in processing request') . ' : '; $message .= sprintf(PMA_RTE_getWord('not_found'), htmlspecialchars(PMA_Util::backquote($_REQUEST['item_name'])), htmlspecialchars(PMA_Util::backquote($db))); $message = PMA_message::error($message); if ($GLOBALS['is_ajax_request']) { $response = PMA_Response::getInstance(); $response->isSuccess(false); $response->addJSON('message', $message); exit; } else { echo $message->getDisplay(); unset($_POST); } } } else { if (!empty($_GET['execute_dialog']) && !empty($_GET['item_name'])) { /** * Display the execute form for a routine. */ $routine = PMA_RTN_getDataFromName($_GET['item_name'], $_GET['item_type'], true); if ($routine !== false) { $form = PMA_RTN_getExecuteForm($routine); if ($GLOBALS['is_ajax_request'] == true) { $title = __("Execute routine") . " " . PMA_Util::backquote(htmlentities($_GET['item_name'], ENT_QUOTES)); $response = PMA_Response::getInstance(); $response->addJSON('message', $form); $response->addJSON('title', $title); $response->addJSON('dialog', true); } else { echo "\n\n<h2>" . __("Execute routine") . "</h2>\n\n"; echo $form; } exit; } else { if ($GLOBALS['is_ajax_request'] == true) { $message = __('Error in processing request') . ' : '; $message .= sprintf(PMA_RTE_getWord('not_found'), htmlspecialchars(PMA_Util::backquote($_REQUEST['item_name'])), htmlspecialchars(PMA_Util::backquote($db))); $message = PMA_message::error($message); $response = PMA_Response::getInstance(); $response->isSuccess(false); $response->addJSON('message', $message); exit; } } } } }
/** * Renders the footer * * @return string */ public function getDisplay() { $retval = ''; $this->_setHistory(); if ($this->_isEnabled) { if (!$this->_isAjax) { $retval .= "</div>"; } if (!$this->_isAjax && !$this->_isMinimal) { if (PMA_getenv('SCRIPT_NAME') && empty($_POST) && empty($GLOBALS['checked_special']) && !$this->_isAjax) { $url = $this->getSelfUrl('unencoded'); $header = PMA_Response::getInstance()->getHeader(); $scripts = $header->getScripts()->getFiles(); $menuHash = $header->getMenu()->getHash(); // prime the client-side cache $this->_scripts->addCode(sprintf('AJAX.cache.primer = {' . ' url: "%s",' . ' scripts: %s,' . ' menuHash: "%s"' . '};', PMA_escapeJsString($url), json_encode($scripts), PMA_escapeJsString($menuHash))); $url = $this->getSelfUrl(); $retval .= $this->_getSelfLink($url); } $retval .= $this->_getDebugMessage(); $retval .= $this->getErrorMessages(); $retval .= $this->_scripts->getDisplay(); if ($GLOBALS['cfg']['DBG']['demo']) { $retval .= '<div id="pma_demo">'; $retval .= $this->_getDemoMessage(); $retval .= '</div>'; } // Include possible custom footers if (file_exists(CUSTOM_FOOTER_FILE)) { $retval .= '<div id="pma_footer">'; ob_start(); include CUSTOM_FOOTER_FILE; $retval .= ob_get_contents(); ob_end_clean(); $retval .= '</div>'; } } if (!$this->_isAjax) { $retval .= "</body></html>"; } } return $retval; }
/** * Function to display results when the executed query returns non empty results * * @param array $result executed query results * @param array $analyzed_sql_results analysed sql results * @param string $db current database * @param string $table current table * @param string $disp_mode display mode * @param string $message message to show * @param array $sql_data sql data * @param object $displayResultsObject Instance of DisplayResults.class * @param string $goto goto page url * @param string $pmaThemeImage uri of the theme image * @param string $sql_limit_to_append sql limit to append * @param int $unlim_num_rows unlimited number of rows * @param int $num_rows number of rows * @param string $full_sql_query full sql query * @param string $disp_query display query * @param string $disp_message display message * @param array $profiling_results profiling results * @param string $query_type query type * @param array|null $selectedTables array of table names selected from * the database structure page, for an * action like check table, optimize * table, analyze table or repair table * @param string $sql_query sql query * @param string $complete_query complete sql query * * @return void */ function PMA_sendQueryResponseForResultsReturned($result, $analyzed_sql_results, $db, $table, $disp_mode, $message, $sql_data, $displayResultsObject, $goto, $pmaThemeImage, $sql_limit_to_append, $unlim_num_rows, $num_rows, $full_sql_query, $disp_query, $disp_message, $profiling_results, $query_type, $selectedTables, $sql_query, $complete_query) { // If we are retrieving the full value of a truncated field or the original // value of a transformed field, show it here if (isset($_REQUEST['grid_edit']) && $_REQUEST['grid_edit'] == true) { PMA_sendResponseForGridEdit($result); // script has exited at this point } // Gets the list of fields properties if (isset($result) && $result) { $fields_meta = $GLOBALS['dbi']->getFieldsMeta($result); } // Should be initialized these parameters before parsing $showtable = isset($showtable) ? $showtable : null; $url_query = isset($url_query) ? $url_query : null; $response = PMA_Response::getInstance(); $header = $response->getHeader(); $scripts = $header->getScripts(); // hide edit and delete links: // - for information_schema // - if the result set does not contain all the columns of a unique key // (unless this is an updatable view) $sele_exp_cls = $analyzed_sql_results['analyzed_sql'][0]['select_expr_clause']; $updatableView = trim($sele_exp_cls) == '*' && PMA_Table::isUpdatableView($db, $table); $has_unique = PMA_resultSetContainsUniqueKey($db, $table, $fields_meta); $just_one_table = PMA_resultSetHasJustOneTable($fields_meta); $editable = ($has_unique || $updatableView) && $just_one_table; // Displays the results in a table if (empty($disp_mode)) { // see the "PMA_setDisplayMode()" function in // libraries/DisplayResults.class.php $disp_mode = 'urdr111101'; } if (!empty($table) && ($GLOBALS['dbi']->isSystemSchema($db) || !$editable)) { $disp_mode = 'nnnn110111'; } if (isset($_REQUEST['printview']) && $_REQUEST['printview'] == '1') { $disp_mode = 'nnnn000000'; } if (isset($_REQUEST['table_maintenance'])) { $scripts->addFile('makegrid.js'); $scripts->addFile('sql.js'); $table_maintenance_html = ''; if (isset($message)) { $message = PMA_Message::success($message); $table_maintenance_html = PMA_Util::getMessage($message, $GLOBALS['sql_query'], 'success'); } $table_maintenance_html .= PMA_getHtmlForSqlQueryResultsTable(isset($sql_data) ? $sql_data : null, $displayResultsObject, $db, $goto, $pmaThemeImage, $url_query, $disp_mode, $sql_limit_to_append, false, $unlim_num_rows, $num_rows, $showtable, $result, $analyzed_sql_results); if (empty($sql_data) || ($sql_data['valid_queries'] = 1)) { $response->addHTML($table_maintenance_html); exit; } } if (!isset($_REQUEST['printview']) || $_REQUEST['printview'] != '1') { $scripts->addFile('makegrid.js'); $scripts->addFile('sql.js'); unset($GLOBALS['message']); //we don't need to buffer the output in getMessage here. //set a global variable and check against it in the function $GLOBALS['buffer_message'] = false; } $print_view_header_html = PMA_getHtmlForPrintViewHeader($db, $full_sql_query, $num_rows); $previous_update_query_html = PMA_getHtmlForPreviousUpdateQuery(isset($disp_query) ? $disp_query : null, $GLOBALS['cfg']['ShowSQL'], isset($sql_data) ? $sql_data : null, isset($disp_message) ? $disp_message : null); $profiling_chart_html = PMA_getHtmlForProfilingChart($disp_mode, $db, isset($profiling_results) ? $profiling_results : null); $missing_unique_column_msg = PMA_getMessageIfMissingColumnIndex($table, $db, $editable); $bookmark_created_msg = PMA_getBookmarkCreatedMessage(); $table_html = PMA_getHtmlForSqlQueryResultsTable(isset($sql_data) ? $sql_data : null, $displayResultsObject, $db, $goto, $pmaThemeImage, $url_query, $disp_mode, $sql_limit_to_append, $editable, $unlim_num_rows, $num_rows, $showtable, $result, $analyzed_sql_results); $indexes_problems_html = PMA_getHtmlForIndexesProblems(isset($query_type) ? $query_type : null, isset($selectedTables) ? $selectedTables : null, $db); $cfgBookmark = PMA_Bookmark_getParams(); if ($cfgBookmark) { $bookmark_support_html = PMA_getHtmlForBookmark($disp_mode, $cfgBookmark, $sql_query, $db, $table, isset($complete_query) ? $complete_query : $sql_query, $cfgBookmark['user']); } else { $bookmark_support_html = ''; } $print_button_html = PMA_getHtmlForPrintButton(); $html_output = isset($table_maintenance_html) ? $table_maintenance_html : ''; $html_output .= isset($print_view_header_html) ? $print_view_header_html : ''; $html_output .= PMA_getHtmlForSqlQueryResults($previous_update_query_html, $profiling_chart_html, $missing_unique_column_msg, $bookmark_created_msg, $table_html, $indexes_problems_html, $bookmark_support_html, $print_button_html); $response->addHTML($html_output); exit; }
/** * Move or copy a table * * @param string $db current database name * @param string $table current table name * * @return void */ function PMA_moveOrCopyTable($db, $table) { /** * Selects the database to work with */ $GLOBALS['dbi']->selectDb($db); /** * $_REQUEST['target_db'] could be empty in case we came from an input field * (when there are many databases, no drop-down) */ if (empty($_REQUEST['target_db'])) { $_REQUEST['target_db'] = $db; } /** * A target table name has been sent to this script -> do the work */ if (PMA_isValid($_REQUEST['new_name'])) { if ($db == $_REQUEST['target_db'] && $table == $_REQUEST['new_name']) { if (isset($_REQUEST['submit_move'])) { $message = PMA_Message::error(__('Can\'t move table to same one!')); } else { $message = PMA_Message::error(__('Can\'t copy table to same one!')); } } else { PMA_Table::moveCopy($db, $table, $_REQUEST['target_db'], $_REQUEST['new_name'], $_REQUEST['what'], isset($_REQUEST['submit_move']), 'one_table'); if (isset($_REQUEST['adjust_privileges']) && !empty($_REQUEST['adjust_privileges'])) { if (isset($_REQUEST['submit_move'])) { PMA_AdjustPrivileges_renameOrMoveTable($db, $table, $_REQUEST['target_db'], $_REQUEST['new_name']); } else { PMA_AdjustPrivileges_copyTable($db, $table, $_REQUEST['target_db'], $_REQUEST['new_name']); } if (isset($_REQUEST['submit_move'])) { $message = PMA_Message::success(__('Table %s has been moved to %s. Privileges have been ' . 'adjusted.')); } else { $message = PMA_Message::success(__('Table %s has been copied to %s. Privileges have been ' . 'adjusted.')); } } else { if (isset($_REQUEST['submit_move'])) { $message = PMA_Message::success(__('Table %s has been moved to %s.')); } else { $message = PMA_Message::success(__('Table %s has been copied to %s.')); } } $old = PMA_Util::backquote($db) . '.' . PMA_Util::backquote($table); $message->addParam($old); $new = PMA_Util::backquote($_REQUEST['target_db']) . '.' . PMA_Util::backquote($_REQUEST['new_name']); $message->addParam($new); /* Check: Work on new table or on old table? */ if (isset($_REQUEST['submit_move']) || PMA_isValid($_REQUEST['switch_to_new'])) { } } } else { /** * No new name for the table! */ $message = PMA_Message::error(__('The table name is empty!')); } if ($GLOBALS['is_ajax_request'] == true) { $response = PMA_Response::getInstance(); $response->addJSON('message', $message); if ($message->isSuccess()) { $response->addJSON('db', $GLOBALS['db']); } else { $response->isSuccess(false); } exit; } }
/** * Get the HTML for user form and check the privileges for a particular database. * * @param string $link_edit standard link for edit * @param string $conditional_class if ajaxable 'Ajax' otherwise '' * * @return string $html_output */ function PMA_getHtmlForSpecificDbPrivileges($link_edit, $conditional_class) { // check the privileges for a particular database. $html_output = '<form id="usersForm" action="server_privileges.php">' . '<fieldset>' . "\n"; $html_output .= '<legend>' . "\n" . PMA_Util::getIcon('b_usrcheck.png') . ' ' . sprintf(__('Users having access to "%s"'), '<a href="' . $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . PMA_generate_common_url($_REQUEST['checkprivs']) . '">' . htmlspecialchars($_REQUEST['checkprivs']) . '</a>') . "\n" . '</legend>' . "\n"; $html_output .= '<table id="dbspecificuserrights" class="data">' . "\n" . '<thead>' . "\n" . '<tr><th>' . __('User') . '</th>' . "\n" . '<th>' . __('Host') . '</th>' . "\n" . '<th>' . __('Type') . '</th>' . "\n" . '<th>' . __('Privileges') . '</th>' . "\n" . '<th>' . __('Grant') . '</th>' . "\n" . '<th>' . __('Action') . '</th>' . "\n" . '</tr>' . "\n" . '</thead>' . "\n"; $odd_row = true; // now, we build the table... list($list_of_privileges, $list_of_compared_privileges) = PMA_getListOfPrivilegesAndComparedPrivileges(); $sql_query = '(SELECT ' . $list_of_privileges . ', `Db`' . ' FROM `mysql`.`db`' . ' WHERE \'' . PMA_Util::sqlAddSlashes($_REQUEST['checkprivs']) . "'" . ' LIKE `Db`' . ' AND NOT (' . $list_of_compared_privileges . ')) ' . 'UNION ' . '(SELECT ' . $list_of_privileges . ', \'*\' AS `Db`' . ' FROM `mysql`.`user` ' . ' WHERE NOT (' . $list_of_compared_privileges . ')) ' . ' ORDER BY `User` ASC,' . ' `Host` ASC,' . ' `Db` ASC;'; $res = PMA_DBI_query($sql_query); $row = PMA_DBI_fetch_assoc($res); if ($row) { $found = true; } $html_output .= PMA_getHtmlTableBodyForSpecificDbPrivs($found, $row, $odd_row, $link_edit, $res); $html_output .= '</table>' . '</fieldset>' . '</form>' . "\n"; if ($GLOBALS['is_ajax_request'] == true && empty($_REQUEST['ajax_page_request'])) { $message = PMA_Message::success(__('User has been added.')); $response = PMA_Response::getInstance(); $response->addJSON('message', $message); $response->addJSON('user_form', $html_output); exit; } else { // Offer to create a new user for the current database $html_output .= '<fieldset id="fieldset_add_user">' . "\n" . '<legend>' . _pgettext('Create new user', 'New') . '</legend>' . "\n"; $html_output .= '<a href="server_privileges.php?' . $GLOBALS['url_query'] . '&adduser=1&' . 'dbname=' . htmlspecialchars($_REQUEST['checkprivs']) . '" rel="' . 'checkprivs=' . htmlspecialchars($_REQUEST['checkprivs']) . '&' . $GLOBALS['url_query'] . '" class="' . $conditional_class . '" name="db_specific">' . "\n" . PMA_Util::getIcon('b_usradd.png') . ' ' . __('Add user') . '</a>' . "\n"; $html_output .= '</fieldset>' . "\n"; } return $html_output; }
/** * Prepares a Delete link * * @param string $del_url delete url * @param string $del_str text for the delete link * @param string $js_conf text for the JS confirmation * @param string $class css classes for the td element * * @return string the generated HTML * * @access private * * @see _getTableBody(), _getCheckboxAndLinks() */ private function _getDeleteLink($del_url, $del_str, $js_conf, $class) { $ret = ''; if (!empty($del_url)) { $ret .= '<td class="'; if (!empty($class)) { $ret .= $class . ' '; } $ajax = PMA_Response::getInstance()->isAjax() ? ' ajax' : ''; $ret .= 'center" ' . ' >' . PMA_Util::linkOrButton($del_url, $del_str, array('class' => 'delete_row requireConfirm' . $ajax), false) . '<div class="hide">' . $js_conf . '</div>' . '</td>'; } return $ret; }
/** * Check wether insert row mode and if so include tbl_changen script and set * global variables. * * @return void */ function PMA_isInsertRow() { if (isset($_REQUEST['insert_rows']) && is_numeric($_REQUEST['insert_rows']) && $_REQUEST['insert_rows'] != $GLOBALS['cfg']['InsertRows']) { $GLOBALS['cfg']['InsertRows'] = $_REQUEST['insert_rows']; $response = PMA_Response::getInstance(); $header = $response->getHeader(); $scripts = $header->getScripts(); $scripts->addFile('tbl_change.js'); if (!defined('TESTSUITE')) { include 'tbl_change.php'; exit; } } }
/** * Function to send html for table dropdown list * * @return void */ function PMA_sendHtmlForTableDropdownList() { $response = PMA_Response::getInstance(); $tables = array(); $foreign = isset($_REQUEST['foreign']) && $_REQUEST['foreign'] === 'true'; if ($foreign) { $tbl_storage_engine = strtoupper(PMA_Table::sGetStatusInfo($_REQUEST['db'], $_REQUEST['table'], 'Engine')); } // In Drizzle, 'SHOW TABLE STATUS' will show status only for the tables // which are currently in the table cache. Hence we have to use 'SHOW TABLES' // and manully retrieve table engine values. if ($foreign && !PMA_DRIZZLE) { $query = 'SHOW TABLE STATUS FROM ' . PMA_Util::backquote($_REQUEST['foreignDb']); $tables_rs = $GLOBALS['dbi']->query($query, null, PMA_DatabaseInterface::QUERY_STORE); while ($row = $GLOBALS['dbi']->fetchArray($tables_rs)) { if (isset($row['Engine']) && strtoupper($row['Engine']) == $tbl_storage_engine) { $tables[] = htmlspecialchars($row['Name']); } } } else { $query = 'SHOW TABLES FROM ' . PMA_Util::backquote($_REQUEST['foreignDb']); $tables_rs = $GLOBALS['dbi']->query($query, null, PMA_DatabaseInterface::QUERY_STORE); while ($row = $GLOBALS['dbi']->fetchArray($tables_rs)) { if ($foreign && PMA_DRIZZLE) { $engine = strtoupper(PMA_Table::sGetStatusInfo($_REQUEST['foreignDb'], $row[0], 'Engine')); if (isset($engine) && $engine == $tbl_storage_engine) { $tables[] = htmlspecialchars($row[0]); } } else { $tables[] = htmlspecialchars($row[0]); } } } $response->addJSON('tables', $tables); }
/** * Stores user credentials after successful login. * * @return void|bool */ public function storeUserCredentials() { global $cfg; $this->createIV(); // Name and password cookies need to be refreshed each time // Duration = one month for username $this->storeUsernameCookie($cfg['Server']['user']); // Duration = as configured $this->storePasswordCookie($cfg['Server']['password']); // Set server cookies if required (once per session) and, in this case, // force reload to ensure the client accepts cookies if (!$GLOBALS['from_cookie']) { if ($GLOBALS['cfg']['AllowArbitraryServer']) { if (!empty($GLOBALS['pma_auth_server'])) { // Duration = one month for servername $GLOBALS['PMA_Config']->setCookie('pmaServer-' . $GLOBALS['server'], $cfg['Server']['host']); } else { // Delete servername cookie $GLOBALS['PMA_Config']->removeCookie('pmaServer-' . $GLOBALS['server']); } } // URL where to go: $redirect_url = $cfg['PmaAbsoluteUri'] . 'index.php'; // any parameters to pass? $url_params = array(); if (mb_strlen($GLOBALS['db'])) { $url_params['db'] = $GLOBALS['db']; } if (mb_strlen($GLOBALS['table'])) { $url_params['table'] = $GLOBALS['table']; } // any target to pass? if (!empty($GLOBALS['target']) && $GLOBALS['target'] != 'index.php') { $url_params['target'] = $GLOBALS['target']; } /** * Clear user cache. */ PMA_Util::clearUserCache(); PMA_Response::getInstance()->disable(); PMA_sendHeaderLocation($redirect_url . PMA_URL_getCommon($url_params, 'text'), true); if (!defined('TESTSUITE')) { exit; } else { return false; } } // end if return true; }
/** * Get List of information: Changes / copies a user * * @return array */ function PMA_getDataForChangeOrCopyUser() { $queries = null; $password = null; if (isset($_REQUEST['change_copy'])) { $user_host_condition = ' WHERE `User` = ' . "'" . PMA_Util::sqlAddSlashes($_REQUEST['old_username']) . "'" . ' AND `Host` = ' . "'" . PMA_Util::sqlAddSlashes($_REQUEST['old_hostname']) . "';"; $row = $GLOBALS['dbi']->fetchSingleRow('SELECT * FROM `mysql`.`user` ' . $user_host_condition); if (!$row) { $response = PMA_Response::getInstance(); $response->addHTML(PMA_Message::notice(__('No user found.'))->getDisplay()); unset($_REQUEST['change_copy']); } else { extract($row, EXTR_OVERWRITE); // Recent MySQL versions have the field "Password" in mysql.user, // so the previous extract creates $Password but this script // uses $password if (!isset($password) && isset($Password)) { $password = $Password; } $queries = array(); } } return array($queries, $password); }
/** * Sends an HTML response to the browser * * @static * @return void */ public static function response() { $response = PMA_Response::getInstance(); chdir($response->getCWD()); $buffer = PMA_OutputBuffering::getInstance(); if (empty($response->_HTML)) { $response->_HTML = $buffer->getContents(); } if ($response->isAjax()) { $response->_ajaxResponse(); } else { $response->_htmlResponse(); } $buffer->flush(); exit; }
/** * Adds JS code snippets to be displayed by the PMA_Response class. * Adds a newline to each snippet. * * @param string $str Js code to be added (e.g. "token=1234;") * * @return void */ function PMA_addJSCode($str) { $response = PMA_Response::getInstance(); $header = $response->getHeader(); $scripts = $header->getScripts(); $scripts->addCode($str); }
/** * Output EPS Document for download * * @param string $fileName name of the eps document * * @return void * * @access public */ function showOutput($fileName) { // if(ob_get_clean()){ //ob_end_clean(); //} $output = $this->stringCommands; PMA_Response::getInstance()->disable(); PMA_downloadHeader($fileName, 'image/x-eps', mb_strlen($output)); print $output; }