/** * Test for getMessageForDeletedRows() method * * @param int $rows Number of rows * @param string $output Expected string * * @return void * * @dataProvider providerDeletedRows */ public function testDeletedRows($rows, $output) { $this->object = new PMA\libraries\Message(); $msg = $this->object->getMessageForDeletedRows($rows); echo $this->object->addMessage($msg); $this->expectOutputString($output); $this->object->display(); }
$scripts->addFile('tbl_operations.js'); /** * Runs common work */ require './libraries/tbl_common.inc.php'; $url_query .= '&goto=view_operations.php&back=view_operations.php'; $url_params['goto'] = $url_params['back'] = 'view_operations.php'; /** * Gets tables information */ require './libraries/tbl_info.inc.php'; $reread_info = false; /** * Updates if required */ $_message = new PMA\libraries\Message(); $_type = 'success'; if (isset($_REQUEST['submitoptions'])) { if (isset($_REQUEST['new_name'])) { if ($pma_table->rename($_REQUEST['new_name'])) { $_message->addText($pma_table->getLastMessage()); $result = true; $GLOBALS['table'] = $pma_table->getName(); $reread_info = true; $reload = true; } else { $_message->addText($pma_table->getLastError()); $result = false; } } $warning_messages = PMA_getWarningMessagesArray();
unset($_REQUEST['do_save_data']); include_once 'libraries/create_addfield.lib.php'; list($result, $sql_query) = PMA_tryColumnCreationQuery($db, $table, $err_url); if ($result === true) { // If comments were sent, enable relation stuff include_once 'libraries/transformations.lib.php'; // Update comment table for mime types [MIME] if (isset($_REQUEST['field_mimetype']) && is_array($_REQUEST['field_mimetype']) && $cfg['BrowseMIME']) { foreach ($_REQUEST['field_mimetype'] as $fieldindex => $mimetype) { if (isset($_REQUEST['field_name'][$fieldindex]) && mb_strlen($_REQUEST['field_name'][$fieldindex])) { PMA_setMIME($db, $table, $_REQUEST['field_name'][$fieldindex], $mimetype, $_REQUEST['field_transformation'][$fieldindex], $_REQUEST['field_transformation_options'][$fieldindex], $_REQUEST['field_input_transformation'][$fieldindex], $_REQUEST['field_input_transformation_options'][$fieldindex]); } } } // Go back to the structure sub-page $message = PMA\libraries\Message::success(__('Table %1$s has been altered successfully.')); $message->addParam($table); $response->addJSON('message', PMA\libraries\Util::getMessage($message, $sql_query, 'success')); exit; } else { $error_message_html = PMA\libraries\Util::mysqlDie('', '', false, $err_url, false); $response->addHTML($error_message_html); $response->setRequestStatus(false); exit; } } // end do alter table /** * Displays the form used to define the new field */ if ($abort == false) {
$message = PMA\libraries\Message::rawError($GLOBALS['dbi']->getError()); // avoid displaying the not-created db name in header or navi panel $GLOBALS['db'] = ''; $GLOBALS['table'] = ''; /** * If in an Ajax request, just display the message with {@link PMA\libraries\Response} */ if ($GLOBALS['is_ajax_request'] == true) { $response = PMA\libraries\Response::getInstance(); $response->setRequestStatus(false); $response->addJSON('message', $message); } else { include_once 'index.php'; } } else { $message = PMA\libraries\Message::success(__('Database %1$s has been created.')); $message->addParam($_POST['new_db']); $GLOBALS['db'] = $_POST['new_db']; /** * If in an Ajax request, build the output and send it */ if ($GLOBALS['is_ajax_request'] == true) { //Construct the html for the new database, so that it can be appended to // the list of databases on server_databases.php /** * Build the array to be passed to {@link PMA_URL_getCommon} * to generate the links * * @global array $GLOBALS['db_url_params'] * @name $db_url_params */
$currentSearchId = $savedSearch->getId(); } /** * A query has been submitted -> (maybe) execute it */ $message_to_display = false; if (isset($_REQUEST['submit_sql']) && !empty($sql_query)) { if (!preg_match('@^SELECT@i', $sql_query)) { $message_to_display = true; } else { $goto = 'db_sql.php'; PMA_executeQueryAndSendQueryResponse(null, false, $_REQUEST['db'], null, false, null, null, null, null, null, $goto, $pmaThemeImage, null, null, null, $sql_query, null, null); } } $sub_part = '_qbe'; require 'libraries/db_common.inc.php'; $url_query .= '&goto=db_qbe.php'; $url_params['goto'] = 'db_qbe.php'; list($tables, $num_tables, $total_num_tables, $sub_part, $is_show_stats, $db_is_system_schema, $tooltip_truename, $tooltip_aliasname, $pos) = PMA\libraries\Util::getDbInfo($db, isset($sub_part) ? $sub_part : ''); if ($message_to_display) { PMA\libraries\Message::error(__('You have to choose at least one column to display!'))->display(); } unset($message_to_display); // create new qbe search instance $db_qbe = new PMA\libraries\DbQbe($GLOBALS['db'], $savedSearchList, $savedSearch); $url = 'db_designer.php' . URL::getCommon(array_merge($url_params, array('query' => 1))); $response->addHTML(PMA\libraries\Message::notice(sprintf(__('Switch to %svisual builder%s'), '<a href="' . $url . '">', '</a>'))); /** * Displays the Query by example form */ $response->addHTML($db_qbe->getSelectionForm());
/* Message to show to the user */ if ($success) { if (isset($_REQUEST['automatic']) && $_REQUEST['automatic'] === "true" || $GLOBALS['cfg']['SendErrorReports'] == 'always') { $msg = __('An error has been detected and an error report has been ' . 'automatically submitted based on your settings.'); } else { $msg = __('Thank you for submitting this report.'); } } else { $msg = __('An error has been detected and an error report has been ' . 'generated but failed to be sent.') . ' ' . __('If you experience any ' . 'problems please submit a bug report manually.'); } $msg .= ' ' . __('You may want to refresh the page.'); /* Create message object */ if ($success) { $msg = PMA\libraries\Message::notice($msg); } else { $msg = PMA\libraries\Message::error($msg); } /* Add message to response */ if ($response->isAjax()) { if ($_REQUEST['exception_type'] == 'js') { $response->addJSON('message', $msg); } else { $response->addJSON('_errSubmitMsg', $msg); } } elseif ($_REQUEST['exception_type'] == 'php') { $jsCode = 'PMA_ajaxShowMessage("<div class=\\"error\\">' . $msg . '</div>", false);'; $response->getFooter()->getScripts()->addCode($jsCode); } if ($_REQUEST['exception_type'] == 'php') { // clear previous errors & save new ones. $GLOBALS['error_handler']->savePreviousErrors();
/** * Generate the message * * @return array error value and message */ function PMA_setChangePasswordMsg() { $error = false; $message = PMA\libraries\Message::success(__('The profile has been updated.')); if ($_REQUEST['nopass'] != '1') { if (empty($_REQUEST['pma_pw']) || empty($_REQUEST['pma_pw2'])) { $message = PMA\libraries\Message::error(__('The password is empty!')); $error = true; } elseif ($_REQUEST['pma_pw'] != $_REQUEST['pma_pw2']) { $message = PMA\libraries\Message::error(__('The passwords aren\'t the same!')); $error = true; } elseif (strlen($_REQUEST['pma_pw']) > 256) { $message = PMA_Message::error(__('Password is too long!')); $error = true; } } return array('error' => $error, 'msg' => $message); }
// Don't even try to drop information_schema. // You won't be able to. Believe me. You won't. // Don't allow to easily drop mysql database, RFE #1327514. if (($is_superuser || $GLOBALS['cfg']['AllowUserDropDatabase']) && !$db_is_system_schema && $GLOBALS['db'] != 'mysql') { $response->addHTML(PMA_getHtmlForDropDatabaseLink($GLOBALS['db'])); } /** * Copy database */ $response->addHTML(PMA_getHtmlForCopyDatabase($GLOBALS['db'])); /** * Change database charset */ $response->addHTML(PMA_getHtmlForChangeDatabaseCharset($GLOBALS['db'], $table)); if (!$cfgRelation['allworks'] && $cfg['PmaNoRelation_DisableWarning'] == false) { $message = PMA\libraries\Message::notice(__('The phpMyAdmin configuration storage has been deactivated. ' . '%sFind out why%s.')); $message->addParam('<a href="' . './chk_rel.php' . $url_query . '">', false); $message->addParam('</a>', false); /* Show error if user has configured something, notice elsewhere */ if (!empty($cfg['Servers'][$server]['pmadb'])) { $message->isError(true); } } // end if } // end if (!$is_information_schema) $response->addHTML('</div>'); // not sure about displaying the PDF dialog in case db is information_schema if ($cfgRelation['pdfwork'] && $num_tables > 0) { // We only show this if we find something in the new pdf_pages table $test_query = '
* Send headers depending on whether the user chose to download a dump file * or not */ if ($asfile) { // Download // (avoid rewriting data containing HTML with anchors and forms; // this was reported to happen under Plesk) @ini_set('url_rewriter.tags', ''); $filename = PMA_sanitizeFilename($filename); PMA_downloadHeader($filename, $mime_type); } else { // HTML if ($export_type == 'database') { $num_tables = count($tables); if ($num_tables == 0) { $message = PMA\libraries\Message::error(__('No tables found in database.')); $active_page = 'db_export.php'; include 'db_export.php'; exit; } } list($html, $back_button) = PMA_getHtmlForDisplayedExportHeader($export_type, $db, $table); echo $html; unset($html); } // end download } // Fake loop just to allow skip of remain of this code by break, I'd really // need exceptions here :-) do { // Re - initialize
/** * Handles editor requests for adding or editing an item * * @return void */ function PMA_TRI_handleEditor() { global $_REQUEST, $_POST, $errors, $db, $table; if (!empty($_REQUEST['editor_process_add']) || !empty($_REQUEST['editor_process_edit'])) { $sql_query = ''; $item_query = PMA_TRI_getQueryFromRequest(); if (!count($errors)) { // set by PMA_RTN_getQueryFromRequest() // Execute the created query if (!empty($_REQUEST['editor_process_edit'])) { // Backup the old trigger, in case something goes wrong $trigger = PMA_TRI_getDataFromName($_REQUEST['item_original_name']); $create_item = $trigger['create']; $drop_item = $trigger['drop'] . ';'; $result = $GLOBALS['dbi']->tryQuery($drop_item); if (!$result) { $errors[] = sprintf(__('The following query has failed: "%s"'), htmlspecialchars($drop_item)) . '<br />' . __('MySQL said: ') . $GLOBALS['dbi']->getError(null); } else { $result = $GLOBALS['dbi']->tryQuery($item_query); if (!$result) { $errors[] = sprintf(__('The following query has failed: "%s"'), htmlspecialchars($item_query)) . '<br />' . __('MySQL said: ') . $GLOBALS['dbi']->getError(null); // We dropped the old item, but were unable to create the // new one. Try to restore the backup query. $result = $GLOBALS['dbi']->tryQuery($create_item); $errors = checkResult($result, __('Sorry, we failed to restore the dropped trigger.'), $create_item, $errors); } else { $message = PMA\libraries\Message::success(__('Trigger %1$s has been modified.')); $message->addParam(PMA\libraries\Util::backquote($_REQUEST['item_name'])); $sql_query = $drop_item . $item_query; } } } else { // 'Add a new item' mode $result = $GLOBALS['dbi']->tryQuery($item_query); if (!$result) { $errors[] = sprintf(__('The following query has failed: "%s"'), htmlspecialchars($item_query)) . '<br /><br />' . __('MySQL said: ') . $GLOBALS['dbi']->getError(null); } else { $message = PMA\libraries\Message::success(__('Trigger %1$s has been created.')); $message->addParam(PMA\libraries\Util::backquote($_REQUEST['item_name'])); $sql_query = $item_query; } } } if (count($errors)) { $message = PMA\libraries\Message::error('<b>' . __('One or more errors have occurred while processing your request:') . '</b>'); $message->addHtml('<ul>'); foreach ($errors as $string) { $message->addHtml('<li>' . $string . '</li>'); } $message->addHtml('</ul>'); } $output = PMA\libraries\Util::getMessage($message, $sql_query); if ($GLOBALS['is_ajax_request']) { $response = PMA\libraries\Response::getInstance(); if ($message->isSuccess()) { $items = $GLOBALS['dbi']->getTriggers($db, $table, ''); $trigger = false; foreach ($items as $value) { if ($value['name'] == $_REQUEST['item_name']) { $trigger = $value; } } $insert = false; if (empty($table) || $trigger !== false && $table == $trigger['table']) { $insert = true; $response->addJSON('new_row', PMA_TRI_getRowForList($trigger)); $response->addJSON('name', htmlspecialchars(mb_strtoupper($_REQUEST['item_name']))); } $response->addJSON('insert', $insert); $response->addJSON('message', $output); } else { $response->addJSON('message', $message); $response->setRequestStatus(false); } exit; } } /** * Display a form used to add/edit a trigger, if necessary */ if (count($errors) || empty($_REQUEST['editor_process_add']) && empty($_REQUEST['editor_process_edit']) && (!empty($_REQUEST['add_item']) || !empty($_REQUEST['edit_item']))) { // Get the data for the form (if any) if (!empty($_REQUEST['add_item'])) { $title = PMA_RTE_getWord('add'); $item = PMA_TRI_getDataFromRequest(); $mode = 'add'; } else { if (!empty($_REQUEST['edit_item'])) { $title = __("Edit trigger"); if (!empty($_REQUEST['item_name']) && empty($_REQUEST['editor_process_edit'])) { $item = PMA_TRI_getDataFromName($_REQUEST['item_name']); if ($item !== false) { $item['item_original_name'] = $item['item_name']; } } else { $item = PMA_TRI_getDataFromRequest(); } $mode = 'edit'; } } PMA_RTE_sendEditor('TRI', $mode, $item, $title, $db); } }
require_once 'libraries/replication.inc.php'; require_once 'libraries/replication_gui.lib.php'; /** * Does the common work */ $response = PMA\libraries\Response::getInstance(); $header = $response->getHeader(); $scripts = $header->getScripts(); $scripts->addFile('server_privileges.js'); $scripts->addFile('replication.js'); /** * Checks if the user is allowed to do what he tries to... */ if (!$is_superuser) { $html = PMA_getHtmlForSubPageHeader('replication'); $html .= PMA\libraries\Message::error(__('No Privileges'))->getDisplay(); $response->addHTML($html); exit; } // change $GLOBALS['url_params'] with $_REQUEST['url_params'] // only if it is an array if (isset($_REQUEST['url_params']) && is_array($_REQUEST['url_params'])) { $GLOBALS['url_params'] = $_REQUEST['url_params']; } /** * Handling control requests */ PMA_handleControlRequest(); /** * start output */
} unset($multi_edit_columns, $is_insertignore); // If there is a request for SQL previewing. if (isset($_REQUEST['preview_sql'])) { PMA_previewSQL($query); } /** * Executes the sql query and get the result, then move back to the calling * page */ list($url_params, $total_affected_rows, $last_messages, $warning_messages, $error_messages, $return_to_sql_query) = PMA_executeSqlQuery($url_params, $query); if ($is_insert && (count($value_sets) > 0 || $row_skipped)) { $message = PMA\libraries\Message::getMessageForInsertedRows($total_affected_rows); $unsaved_values = array_values($unsaved_values); } else { $message = PMA\libraries\Message::getMessageForAffectedRows($total_affected_rows); } if ($row_skipped) { $goto_include = 'tbl_change.php'; $message->addMessagesString($insert_errors, '<br />'); $message->isError(true); } $message->addMessages($last_messages, '<br />'); if (!empty($warning_messages)) { $message->addMessagesString($warning_messages, '<br />'); $message->isError(true); } if (!empty($error_messages)) { $message->addMessagesString($error_messages); $message->isError(true); }
$header = $response->getHeader(); $scripts = $header->getScripts(); $scripts->addFile('export.js'); // $sub_part is used in PMA\libraries\Util::getDbInfo() to see if we are coming from // db_export.php, in which case we don't obey $cfg['MaxTableList'] $sub_part = '_export'; require_once 'libraries/db_common.inc.php'; $url_query .= '&goto=db_export.php'; list($tables, $num_tables, $total_num_tables, $sub_part, $is_show_stats, $db_is_system_schema, $tooltip_truename, $tooltip_aliasname, $pos) = PMA\libraries\Util::getDbInfo($db, isset($sub_part) ? $sub_part : ''); /** * Displays the form */ $export_page_title = __('View dump (schema) of database'); // exit if no tables in db found if ($num_tables < 1) { PMA\libraries\Message::error(__('No tables found in database.'))->display(); exit; } // end if $multi_values = '<div class="export_table_list_container">'; if (isset($_GET['structure_or_data_forced'])) { $force_val = htmlspecialchars($_GET['structure_or_data_forced']); } else { $force_val = 0; } $multi_values .= '<input type="hidden" name="structure_or_data_forced" value="' . $force_val . '">'; $multi_values .= '<table class="export_table_select">' . '<thead><tr><th></th>' . '<th>' . __('Tables') . '</th>' . '<th class="export_structure">' . __('Structure') . '</th>' . '<th class="export_data">' . __('Data') . '</th>' . '</tr><tr>' . '<td></td>' . '<td class="export_table_name all">' . __('Select all') . '</td>' . '<td class="export_structure all">' . '<input type="checkbox" id="table_structure_all" /></td>' . '<td class="export_data all"><input type="checkbox" id="table_data_all" />' . '</td>' . '</tr></thead>' . '<tbody>'; $multi_values .= "\n"; // when called by libraries/mult_submits.inc.php if (!empty($_POST['selected_tbl']) && empty($table_select)) { $table_select = $_POST['selected_tbl'];
/* vim: set expandtab sw=4 ts=4 sts=4: */ /** * The navigation panel - displays server, db and table selection tree * * @package PhpMyAdmin-Navigation */ // Include common functionalities use PMA\libraries\config\PageSettings; use PMA\libraries\navigation\Navigation; require_once './libraries/common.inc.php'; // Also initialises the collapsible tree class $response = PMA\libraries\Response::getInstance(); $navigation = new Navigation(); if (!$response->isAjax()) { $response->addHTML(PMA\libraries\Message::error(__('Fatal error: The navigation can only be accessed via AJAX'))); exit; } if (isset($_REQUEST['getNaviSettings']) && $_REQUEST['getNaviSettings']) { $response->addJSON('message', PageSettings::getNaviSettings()); exit; } $cfgRelation = PMA_getRelationsParam(); if ($cfgRelation['navwork']) { if (isset($_REQUEST['hideNavItem'])) { if (!empty($_REQUEST['itemName']) && !empty($_REQUEST['itemType']) && !empty($_REQUEST['dbName'])) { $navigation->hideNavigationItem($_REQUEST['itemName'], $_REQUEST['itemType'], $_REQUEST['dbName'], !empty($_REQUEST['tableName']) ? $_REQUEST['tableName'] : null); } exit; } if (isset($_REQUEST['unhideNavItem'])) {
&& $_REQUEST['toggle_activation'] == 'deactivate_now' ) { $html .= PMA_changeTracking('deactivate'); } // Activate tracking if (isset($_REQUEST['toggle_activation']) && $_REQUEST['toggle_activation'] == 'activate_now' ) { $html .= PMA_changeTracking('activate'); } // Export as SQL execution if (isset($_REQUEST['report_export']) && $_REQUEST['export_type'] == 'execution') { $sql_result = PMA_exportAsSQLExecution($entries); $msg = PMA\libraries\Message::success(__('SQL statements executed.')); $html .= $msg->getDisplay(); } // Export as SQL dump if (isset($_REQUEST['report_export']) && $_REQUEST['export_type'] == 'sqldump') { $html .= PMA_exportAsSQLDump($entries); } /* * Schema snapshot */ if (isset($_REQUEST['snapshot'])) { $html .= PMA_getHtmlForSchemaSnapshot($url_query); } // end of snapshot report
/** * Handles editor requests for adding or editing an item * * @return void */ function PMA_EVN_handleEditor() { global $_REQUEST, $_POST, $errors, $db; if (!empty($_REQUEST['editor_process_add']) || !empty($_REQUEST['editor_process_edit'])) { $sql_query = ''; $item_query = PMA_EVN_getQueryFromRequest(); if (!count($errors)) { // set by PMA_RTN_getQueryFromRequest() // Execute the created query if (!empty($_REQUEST['editor_process_edit'])) { // Backup the old trigger, in case something goes wrong $create_item = $GLOBALS['dbi']->getDefinition($db, 'EVENT', $_REQUEST['item_original_name']); $drop_item = "DROP EVENT " . PMA\libraries\Util::backquote($_REQUEST['item_original_name']) . ";\n"; $result = $GLOBALS['dbi']->tryQuery($drop_item); if (!$result) { $errors[] = sprintf(__('The following query has failed: "%s"'), htmlspecialchars($drop_item)) . '<br />' . __('MySQL said: ') . $GLOBALS['dbi']->getError(null); } else { $result = $GLOBALS['dbi']->tryQuery($item_query); if (!$result) { $errors[] = sprintf(__('The following query has failed: "%s"'), htmlspecialchars($item_query)) . '<br />' . __('MySQL said: ') . $GLOBALS['dbi']->getError(null); // We dropped the old item, but were unable to create // the new one. Try to restore the backup query $result = $GLOBALS['dbi']->tryQuery($create_item); $errors = checkResult($result, __('Sorry, we failed to restore the dropped event.'), $create_item, $errors); } else { $message = PMA\libraries\Message::success(__('Event %1$s has been modified.')); $message->addParam(PMA\libraries\Util::backquote($_REQUEST['item_name'])); $sql_query = $drop_item . $item_query; } } } else { // 'Add a new item' mode $result = $GLOBALS['dbi']->tryQuery($item_query); if (!$result) { $errors[] = sprintf(__('The following query has failed: "%s"'), htmlspecialchars($item_query)) . '<br /><br />' . __('MySQL said: ') . $GLOBALS['dbi']->getError(null); } else { $message = PMA\libraries\Message::success(__('Event %1$s has been created.')); $message->addParam(PMA\libraries\Util::backquote($_REQUEST['item_name'])); $sql_query = $item_query; } } } if (count($errors)) { $message = PMA\libraries\Message::error('<b>' . __('One or more errors have occurred while processing your request:') . '</b>'); $message->addString('<ul>'); foreach ($errors as $string) { $message->addString('<li>' . $string . '</li>'); } $message->addString('</ul>'); } $output = PMA\libraries\Util::getMessage($message, $sql_query); if ($GLOBALS['is_ajax_request']) { $response = PMA\libraries\Response::getInstance(); if ($message->isSuccess()) { $events = $GLOBALS['dbi']->getEvents($db, $_REQUEST['item_name']); $event = $events[0]; $response->addJSON('name', htmlspecialchars(mb_strtoupper($_REQUEST['item_name']))); $response->addJSON('new_row', PMA_EVN_getRowForList($event)); $response->addJSON('insert', !empty($event)); $response->addJSON('message', $output); } else { $response->setRequestStatus(false); $response->addJSON('message', $message); } exit; } } /** * Display a form used to add/edit a trigger, if necessary */ if (count($errors) || empty($_REQUEST['editor_process_add']) && empty($_REQUEST['editor_process_edit']) && (!empty($_REQUEST['add_item']) || !empty($_REQUEST['edit_item']) || !empty($_REQUEST['item_changetype']))) { // FIXME: this must be simpler than that $operation = ''; if (!empty($_REQUEST['item_changetype'])) { $operation = 'change'; } // Get the data for the form (if any) if (!empty($_REQUEST['add_item'])) { $title = PMA_RTE_getWord('add'); $item = PMA_EVN_getDataFromRequest(); $mode = 'add'; } else { if (!empty($_REQUEST['edit_item'])) { $title = __("Edit event"); if (!empty($_REQUEST['item_name']) && empty($_REQUEST['editor_process_edit']) && empty($_REQUEST['item_changetype'])) { $item = PMA_EVN_getDataFromName($_REQUEST['item_name']); if ($item !== false) { $item['item_original_name'] = $item['item_name']; } } else { $item = PMA_EVN_getDataFromRequest(); } $mode = 'edit'; } } PMA_RTE_sendEditor('EVN', $mode, $item, $title, $db, $operation); } }
$columnAdd = PMA_getHTMLforAddCentralColumn($total_rows, $pos, $db); $response->addHTML($columnAdd); exit; } $table_navigation_html = PMA_getHTMLforTableNavigation($total_rows, $pos, $db); $response->addHTML($table_navigation_html); $columnAdd = PMA_getHTMLforAddCentralColumn($total_rows, $pos, $db); $response->addHTML($columnAdd); $deleteRowForm = '<form method="post" id="del_form" action="db_central_columns.php">' . PMA_URL_getHiddenInputs($db) . '<input id="del_col_name" type="hidden" name="col_name" value="">' . '<input type="hidden" name="pos" value="' . $pos . '">' . '<input type="hidden" name="delete_save" value="delete"></form>'; $response->addHTML($deleteRowForm); $table_struct = '<div id="tableslistcontainer">' . '<form name="tableslistcontainer">' . '<table id="table_columns" class="tablesorter" ' . 'style="min-width:100%" class="data">'; $response->addHTML($table_struct); $tableheader = PMA_getCentralColumnsTableHeader('column_heading', __('Click to sort.'), 2); $response->addHTML($tableheader); $result = PMA_getColumnsList($db, $pos, $max_rows); $odd_row = true; $row_num = 0; foreach ($result as $row) { $tableHtmlRow = PMA_getHTMLforCentralColumnsTableRow($row, $odd_row, $row_num, $db); $response->addHTML($tableHtmlRow); $odd_row = !$odd_row; $row_num++; } $response->addHTML('</table>'); $tablefooter = PMA_getCentralColumnsTableFooter($pmaThemeImage, $text_dir); $response->addHTML($tablefooter); $response->addHTML('</form></div>'); $message = PMA\libraries\Message::success(sprintf(__('Showing rows %1$s - %2$s.'), $pos + 1, $pos + count($result))); if (isset($tmp_msg) && $tmp_msg !== true) { $message = $tmp_msg; }
// AJAX requests can't be cached! PMA_noCacheHeader(); // $_GET["message"] is used for asking for an import message if (isset($_GET["message"]) && $_GET["message"]) { header('Content-type: text/html'); // wait 0.3 sec before we check for $_SESSION variable, // which is set inside import.php usleep(300000); $maximumTime = ini_get('max_execution_time'); $timestamp = time(); // wait until message is available while ($_SESSION['Import_message']['message'] == null) { // close session before sleeping session_write_close(); // sleep usleep(250000); // 0.25 sec // reopen session session_start(); if (time() - $timestamp > $maximumTime) { $_SESSION['Import_message']['message'] = PMA\libraries\Message::error(__('Could not load the progress of the import.'))->getDisplay(); break; } } echo $_SESSION['Import_message']['message']; echo '<fieldset class="tblFooters">', "\n"; echo ' [ <a href="', $_SESSION['Import_message']['go_back_url'] . '">', __('Back'), '</a> ]', "\n"; echo '</fieldset>', "\n"; } else { PMA_importAjaxStatus($_GET["id"]); }
* Deletes users * (Changes / copies a user, part IV) */ if (isset($_REQUEST['delete']) || isset($_REQUEST['change_copy']) && $_REQUEST['mode'] < 4) { include_once 'libraries/relation_cleanup.lib.php'; $queries = PMA_getDataForDeleteUsers($queries); if (empty($_REQUEST['change_copy'])) { list($sql_query, $message) = PMA_deleteUser($queries); } } /** * Changes / copies a user, part V */ if (isset($_REQUEST['change_copy'])) { $queries = PMA_getDataForQueries($queries, $queries_for_display); $message = PMA\libraries\Message::success(); $sql_query = join("\n", $queries); } /** * Reloads the privilege tables into memory */ $message_ret = PMA_updateMessageForReload(); if (isset($message_ret)) { $message = $message_ret; unset($message_ret); } /** * If we are in an Ajax request for Create User/Edit User/Revoke User/ * Flush Privileges, show $message and exit. */ if ($GLOBALS['is_ajax_request'] && empty($_REQUEST['ajax_page_request']) && !isset($_REQUEST['export']) && (!isset($_REQUEST['submit_mult']) || $_REQUEST['submit_mult'] != 'export') && (!isset($_REQUEST['initial']) || $_REQUEST['initial'] === null || $_REQUEST['initial'] === '' || isset($_REQUEST['delete']) && $_REQUEST['delete'] === 'Go') && !isset($_REQUEST['showall']) && !isset($_REQUEST['edit_user_group_dialog']) && !isset($_REQUEST['db_specific'])) {
// Checking if the WHERE clause has to be replaced. if (!empty($where_clause) && is_array($where_clause)) { $replaces[] = array('WHERE', 'WHERE (' . implode(') OR (', $where_clause) . ')'); } // Preparing to remove the LIMIT clause. $replaces[] = array('LIMIT', ''); // Replacing the clauses. $sql_query = SqlParser\Utils\Query::replaceClauses($parser->statements[0], $parser->list, $replaces); // Removing the aliases by finding the alias followed by a dot. $tokens = SqlParser\Lexer::getTokens($sql_query); foreach ($aliases as $alias => $table) { $tokens = SqlParser\Utils\Tokens::replaceTokens($tokens, array(array('value_str' => $alias), array('type' => SqlParser\Token::TYPE_OPERATOR, 'value_str' => '.')), array(new SqlParser\Token($table), new SqlParser\Token('.', SqlParser\Token::TYPE_OPERATOR))); } $sql_query = SqlParser\TokensList::build($tokens); } echo PMA\libraries\Util::getMessage(PMA\libraries\Message::success()); } require_once 'libraries/display_export.lib.php'; if (!isset($sql_query)) { $sql_query = ''; } if (!isset($num_tables)) { $num_tables = 0; } if (!isset($unlim_num_rows)) { $unlim_num_rows = 0; } if (!isset($multi_values)) { $multi_values = ''; } $response = Response::getInstance();
$pma_transformation_data = $systemDb->getExistingTransformationData($GLOBALS['db']); if ($pma_transformation_data !== false) { // SQL for store new transformation details of VIEW $new_transformations_sql = $systemDb->getNewTransformationDataSql($pma_transformation_data, $column_map, $_REQUEST['view']['name'], $GLOBALS['db']); // Store new transformations if ($new_transformations_sql != '') { $GLOBALS['dbi']->tryQuery($new_transformations_sql); } } unset($pma_transformation_data); if (!isset($_REQUEST['ajax_dialog'])) { $message = PMA\libraries\Message::success(); include 'tbl_structure.php'; } else { $response = PMA\libraries\Response::getInstance(); $response->addJSON('message', PMA\libraries\Util::getMessage(PMA\libraries\Message::success(), $sql_query)); $response->setRequestStatus(true); } exit; } // prefill values if not already filled from former submission $view = array('operation' => 'create', 'or_replace' => '', 'algorithm' => '', 'definer' => '', 'sql_security' => '', 'name' => '', 'column_names' => '', 'as' => $sql_query, 'with' => ''); if (PMA_isValid($_REQUEST['view'], 'array')) { $view = array_merge($view, $_REQUEST['view']); } $url_params['db'] = $GLOBALS['db']; $url_params['reload'] = 1; /** * Displays the page */ $htmlString = '<!-- CREATE VIEW options -->' . '<div id="div_view_options">' . '<form method="post" action="view_create.php">' . PMA_URL_getHiddenInputs($url_params) . '<fieldset>' . '<legend>' . (isset($_REQUEST['ajax_dialog']) ? __('Details') : ($view['operation'] == 'create' ? __('Create view') : __('Edit view'))) . '</legend>' . '<table class="rte_table">';
$_message .= $pma_table->getLastError(); $result = false; } } } if (isset($result)) { // set to success by default, because result set could be empty // (for example, a table rename) $_type = 'success'; if (empty($_message)) { $_message = $result ? __('Your SQL query has been executed successfully.') : __('Error'); // $result should exist, regardless of $_message $_type = $result ? 'success' : 'error'; } if (!empty($warning_messages)) { $_message = new PMA\libraries\Message(); $_message->addMessages($warning_messages); $_message->isError(true); unset($warning_messages); } echo PMA\libraries\Util::getMessage($_message, $sql_query, $_type); unset($_message, $_type); } $url_params['goto'] = 'view_operations.php'; $url_params['back'] = 'view_operations.php'; /** * Displays the page */ ?> <!-- Table operations --> <div class="operations_half_width">
} elseif (isset($_REQUEST['submit_create_version'])) { PMA_createTrackingForMultipleTables($_REQUEST['selected']); PMA\libraries\Message::success(sprintf(__('Version %1$s was created for selected tables,' . ' tracking is active for them.'), htmlspecialchars($_REQUEST['version'])))->display(); } elseif (isset($_REQUEST['submit_mult'])) { if (!empty($_REQUEST['selected_tbl'])) { if ($_REQUEST['submit_mult'] == 'delete_tracking') { foreach ($_REQUEST['selected_tbl'] as $table) { Tracker::deleteTracking($GLOBALS['db'], $table); } PMA\libraries\Message::success(__('Tracking data deleted successfully.'))->display(); } elseif ($_REQUEST['submit_mult'] == 'track') { echo PMA_getHtmlForDataDefinitionAndManipulationStatements('db_tracking.php' . $url_query, 0, $GLOBALS['db'], $_REQUEST['selected_tbl']); exit; } } else { PMA\libraries\Message::notice(__('No tables selected.'))->display(); } } // Get tracked data about the database $data = Tracker::getTrackedData($_REQUEST['db'], '', '1'); // No tables present and no log exist if ($num_tables == 0 && count($data['ddlog']) == 0) { echo '<p>', __('No tables found in database.'), '</p>', "\n"; if (empty($db_is_system_schema)) { echo PMA_getHtmlForCreateTable($db); } exit; } // --------------------------------------------------------------------------- $cfgRelation = PMA_getRelationsParam(); // Prepare statement to get HEAD version
} $response = PMA\libraries\Response::getInstance(); $response->addJSON('ajax_reload', $ajax_reload); $response->addHTML($html_output); exit; } else { if ($result) { // Save a Bookmark with more than one queries (if Bookmark label given). if (!empty($_POST['bkm_label']) && !empty($import_text)) { $cfgBookmark = PMA_Bookmark_getParams(); PMA_storeTheQueryAsBookmark($db, $cfgBookmark['user'], $_REQUEST['sql_query'], $_POST['bkm_label'], isset($_POST['bkm_replace']) ? $_POST['bkm_replace'] : null); } $response = PMA\libraries\Response::getInstance(); $response->setRequestStatus(true); $response->addJSON('message', PMA\libraries\Message::success($msg)); $response->addJSON('sql_query', PMA\libraries\Util::getMessage($msg, $sql_query, 'success')); } else { if ($result == false) { $response = PMA\libraries\Response::getInstance(); $response->setRequestStatus(false); $response->addJSON('message', PMA\libraries\Message::error($msg)); } else { $active_page = $goto; include '' . $goto; } } } // If there is request for ROLLBACK in the end. if (isset($_REQUEST['rollback_query'])) { $GLOBALS['dbi']->query('ROLLBACK'); }
$_message = $result ? PMA\libraries\Message::success() : PMA\libraries\Message::error(); } if (isset($GLOBALS['ajax_request']) && $GLOBALS['ajax_request'] == true) { $response = PMA\libraries\Response::getInstance(); $response->setRequestStatus($_message->isSuccess()); $response->addJSON('message', $_message); if (!empty($sql_query)) { $response->addJSON('sql_query', PMA\libraries\Util::getMessage(null, $sql_query)); } exit; } } else { $_message = $result ? PMA\libraries\Message::success($_message) : PMA\libraries\Message::error($_message); } if (!empty($warning_messages)) { $_message = new PMA\libraries\Message(); $_message->addMessages($warning_messages); $_message->isError(true); if (isset($GLOBALS['ajax_request']) && $GLOBALS['ajax_request'] == true) { $response = PMA\libraries\Response::getInstance(); $response->setRequestStatus(false); $response->addJSON('message', $_message); if (!empty($sql_query)) { $response->addJSON('sql_query', PMA\libraries\Util::getMessage(null, $sql_query)); } exit; } unset($warning_messages); } if (empty($sql_query)) { $response->addHTML($_message->getDisplay());
require_once 'libraries/common.inc.php'; require_once 'libraries/server_users.lib.php'; require_once 'libraries/server_user_groups.lib.php'; PMA_getRelationsParam(); if (!$GLOBALS['cfgRelation']['menuswork']) { exit; } $response = PMA\libraries\Response::getInstance(); $header = $response->getHeader(); $scripts = $header->getScripts(); $scripts->addFile('server_user_groups.js'); /** * Only allowed to superuser */ if (!$GLOBALS['is_superuser']) { $response->addHTML(PMA\libraries\Message::error(__('No Privileges'))->getDisplay()); exit; } $response->addHTML('<div>'); $response->addHTML(PMA_getHtmlForSubMenusOnUsersPage('server_user_groups.php')); /** * Delete user group */ if (!empty($_REQUEST['deleteUserGroup'])) { PMA_deleteUserGroup($_REQUEST['userGroup']); } /** * Add a new user group */ if (!empty($_REQUEST['addUserGroupSubmit'])) { PMA_editUserGroup($_REQUEST['userGroup'], true);
PMA_getRelationsParam(); if (! $GLOBALS['cfgRelation']['menuswork']) { exit; } $response = Response::getInstance(); $header = $response->getHeader(); $scripts = $header->getScripts(); $scripts->addFile('server_user_groups.js'); /** * Only allowed to superuser */ if (! $GLOBALS['is_superuser']) { $response->addHTML( PMA\libraries\Message::error(__('No Privileges')) ->getDisplay() ); exit; } $response->addHTML('<div>'); $response->addHTML(PMA_getHtmlForSubMenusOnUsersPage('server_user_groups.php')); /** * Delete user group */ if (! empty($_REQUEST['deleteUserGroup'])) { PMA_deleteUserGroup($_REQUEST['userGroup']); }
/** * Tests for displayFormAction() * * @return void * @test */ public function testDisplayFormAction() { $table = $this->getMockBuilder('PMA\\libraries\\Table')->disableOriginalConstructor()->getMock(); $table->expects($this->any())->method('getStatusInfo')->will($this->returnValue("")); $table->expects($this->any())->method('isView')->will($this->returnValue(false)); $table->expects($this->any())->method('getNameAndTypeOfTheColumns')->will($this->returnValue(array("field_name" => "field_type"))); $GLOBALS['dbi']->expects($this->any())->method('getTable')->will($this->returnValue($table)); $container = Container::getDefaultContainer(); $container->set('db', 'db'); $container->set('table', 'table'); $container->set('dbi', $GLOBALS['dbi']); $response = new \PMA\Test\Stubs\Response(); $container->set('PMA\\libraries\\Response', $response); $container->alias('response', 'PMA\\libraries\\Response'); $index = new PMA\libraries\Index(); $ctrl = new TableIndexesController($index); $_REQUEST['create_index'] = true; $_REQUEST['added_fields'] = 3; $ctrl->displayFormAction(); $html = $response->getHTMLResult(); //PMA_URL_getHiddenInputs $this->assertContains(PMA_URL_getHiddenInputs(array('db' => 'db', 'table' => 'table', 'create_index' => 1)), $html); $doc_html = PMA\libraries\Util::showHint(PMA\libraries\Message::notice(__('"PRIMARY" <b>must</b> be the name of' . ' and <b>only of</b> a primary key!'))); $this->assertContains($doc_html, $html); $this->assertContains(PMA\libraries\Util::showMySQLDocu('ALTER_TABLE'), $html); // generateIndexSelector $this->assertContains(PMA\libraries\Template::trim($index->generateIndexChoiceSelector(false)), $html); $this->assertContains(sprintf(__('Add %s column(s) to index'), 1), $html); //$field_name & $field_type $this->assertContains("field_name", $html); $this->assertContains("field_type", $html); }
} /** * Check for existence of config directory which should not exist in * production environment. */ if (file_exists('config')) { trigger_error(__('Directory [code]config[/code], which is used by the setup script, ' . 'still exists in your phpMyAdmin directory. It is strongly ' . 'recommended to remove it once phpMyAdmin has been configured. ' . 'Otherwise the security of your server may be compromised by ' . 'unauthorized people downloading your configuration.'), E_USER_WARNING); } if ($server > 0) { $cfgRelation = PMA_getRelationsParam(); if (!$cfgRelation['allworks'] && $cfg['PmaNoRelation_DisableWarning'] == false) { $msg_text = __('The phpMyAdmin configuration storage is not completely ' . 'configured, some extended features have been deactivated. ' . '%sFind out why%s. '); if ($cfg['ZeroConf'] == true) { $msg_text .= '<br> ' . __('Or alternately go to \'Operations\' tab of any database ' . 'to set it up there.'); } $msg = PMA\libraries\Message::notice($msg_text); $msg->addParam('<a href="' . $cfg['PmaAbsoluteUri'] . 'chk_rel.php' . $common_url_query . '">', false); $msg->addParam('</a>', false); /* Show error if user has configured something, notice elsewhere */ if (!empty($cfg['Servers'][$server]['pmadb'])) { $msg->isError(true); } $msg->display(); } // end if } /** * Warning about different MySQL library and server version * (a difference on the third digit does not count). * If someday there is a constant that we can check about mysqlnd, * we can use it instead of strpos().
/** * Kills a selected process * on ajax request */ if ($response->isAjax() && !empty($_REQUEST['kill'])) { $kill = intval($_REQUEST['kill']); $query = $GLOBALS['dbi']->getKillQuery($kill); if ($GLOBALS['dbi']->tryQuery($query)) { $message = PMA\libraries\Message::success( __('Thread %s was successfully killed.') ); $response->setRequestStatus(true); } else { $message = PMA\libraries\Message::error( __( 'phpMyAdmin was unable to kill thread %s.' . ' It probably has already been closed.' ) ); $response->setRequestStatus(false); } $message->addParam($kill); $response->addJSON('message', $message); } elseif ($response->isAjax() && !empty($_REQUEST['refresh'])) { // Only sends the process list table $response->addHTML(PMA_getHtmlForServerProcessList()); } else { // Load the full page $header = $response->getHeader(); $scripts = $header->getScripts(); $scripts->addFile('server_status_processes.js'); $response->addHTML('<div>');