/** * 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; } }
/** * Test for getMessage * * @return void */ function testShowMessageNotAjax() { global $cfg; $GLOBALS['is_ajax_request'] = true; $GLOBALS['table'] = 'tbl'; $GLOBALS['db'] = 'db'; $GLOBALS['sql_query'] = "SELECT * FROM tblPatient "; $this->expectOutputString("<div id=\"result_query\" align=\"\">\n <div class=\"notice\">msg</div><code class=\"sql\"><span class=\"syntax\"><span class=\"inner_sql\"><a href=\"./url.php?url=http%3A%2F%2Fdev.mysql.com%2Fdoc%2Frefman%2F5.0%2Fen%2Fselect.html&server=server&lang=en&token=647a62ad301bf9025e3b13bc7caa02cb\" target=\"mysql_doc\"><span class=\"syntax_alpha syntax_alpha_reservedWord\">SELECT</span></a> <span class=\"syntax_punct\">*</span> <br /><span class=\"syntax_alpha syntax_alpha_reservedWord\">FROM</span> <span class=\"syntax_alpha syntax_alpha_identifier\">tblPatient</span></span></span></code><div class=\"tools\"><form action=\"sql.php\" method=\"post\"><input type=\"hidden\" name=\"db\" value=\"db\" /><input type=\"hidden\" name=\"table\" value=\"tbl\" /><input type=\"hidden\" name=\"server\" value=\"server\" /><input type=\"hidden\" name=\"lang\" value=\"en\" /><input type=\"hidden\" name=\"token\" value=\"647a62ad301bf9025e3b13bc7caa02cb\" /><input type=\"hidden\" name=\"sql_query\" value=\"SELECT * FROM tblPatient \" /></form><script type=\"text/javascript\">\n //<![CDATA[\n \$('.tools form').last().after('[<a href=\"#\" title=\"Inline edit of this query\" class=\"inline_edit_sql\">Inline</a>]');\n //]]>\n </script> [\n <a href=\"tbl_sql.php?db=db&table=tbl&sql_query=SELECT+%2A+FROM+tblPatient+&show_query=1&server=server&lang=en&token=647a62ad301bf9025e3b13bc7caa02cb#querybox\" >Edit</a>\n ] [\n <a href=\"import.php?db=db&table=tbl&sql_query=EXPLAIN+SELECT+%2A+FROM+tblPatient+&server=server&lang=en&token=647a62ad301bf9025e3b13bc7caa02cb\" >Explain SQL</a>\n ] [\n <a href=\"import.php?db=db&table=tbl&sql_query=SELECT+%2A+FROM+tblPatient+&show_query=1&show_as_php=1&server=server&lang=en&token=647a62ad301bf9025e3b13bc7caa02cb\" >Create PHP Code</a>\n ] [\n <a href=\"import.php?db=db&table=tbl&sql_query=SELECT+%2A+FROM+tblPatient+&show_query=1&server=server&lang=en&token=647a62ad301bf9025e3b13bc7caa02cb\" >Refresh</a>\n ]</div></div>"); echo PMA_Util::getMessage("msg"); //$this->assertEquals("", PMA_Util::getMessage("msg")); $this->assertTrue(true); }
/** * Returns the menu and the breadcrumbs as a string * * @return string */ public function getDisplay() { $retval = $this->_getBreadcrumbs(); $retval .= $this->_getMenu(); if (!empty($GLOBALS['message'])) { if (isset($GLOBALS['buffer_message'])) { $buffer_message = $GLOBALS['buffer_message']; } $retval .= PMA_Util::getMessage($GLOBALS['message']); unset($GLOBALS['message']); if (isset($buffer_message)) { $GLOBALS['buffer_message'] = $buffer_message; } } return $retval; }
/** * This function return the extra data array for the ajax behavior * * @param string $password password * @param string $sql_query sql query * @param string $hostname hostname * @param string $username username * * @return array $extra_data */ function PMA_getExtraDataForAjaxBehavior($password, $sql_query, $hostname, $username) { if (isset($GLOBALS['dbname'])) { //if (preg_match('/\\\\(?:_|%)/i', $dbname)) { if (preg_match('/(?<!\\\\)(?:_|%)/i', $GLOBALS['dbname'])) { $dbname_is_wildcard = true; } else { $dbname_is_wildcard = false; } } $user_group_count = 0; if ($GLOBALS['cfgRelation']['menuswork']) { $user_group_count = PMA_getUserGroupCount(); } $extra_data = array(); if (mb_strlen($sql_query)) { $extra_data['sql_query'] = PMA_Util::getMessage(null, $sql_query); } if (isset($_REQUEST['change_copy'])) { /** * generate html on the fly for the new user that was just created. */ $new_user_string = '<tr>' . "\n" . '<td> <input type="checkbox" name="selected_usr[]" ' . 'id="checkbox_sel_users_"' . 'value="' . htmlspecialchars($username) . '&#27;' . htmlspecialchars($hostname) . '" />' . '</td>' . "\n" . '<td><label for="checkbox_sel_users_">' . (empty($_REQUEST['username']) ? '<span style="color: #FF0000">' . __('Any') . '</span>' : htmlspecialchars($username)) . '</label></td>' . "\n" . '<td>' . htmlspecialchars($hostname) . '</td>' . "\n"; $new_user_string .= '<td>'; if (!empty($password) || isset($_POST['pma_pw'])) { $new_user_string .= __('Yes'); } else { $new_user_string .= '<span style="color: #FF0000">' . __('No') . '</span>'; } $new_user_string .= '</td>' . "\n"; $new_user_string .= '<td>' . '<code>' . join(', ', PMA_extractPrivInfo(null, true)) . '</code>' . '</td>'; //Fill in privileges here // if $cfg['Servers'][$i]['users'] and $cfg['Servers'][$i]['usergroups'] are // enabled $cfgRelation = PMA_getRelationsParam(); if (isset($cfgRelation['users']) && isset($cfgRelation['usergroups'])) { $new_user_string .= '<td class="usrGroup"></td>'; } $new_user_string .= '<td>'; if (isset($_POST['Grant_priv']) && $_POST['Grant_priv'] == 'Y') { $new_user_string .= __('Yes'); } else { $new_user_string .= __('No'); } $new_user_string .= '</td>'; if ($GLOBALS['is_grantuser']) { $new_user_string .= '<td>' . PMA_getUserLink('edit', $username, $hostname) . '</td>' . "\n"; } if (isset($cfgRelation['menuswork']) && $user_group_count > 0) { $new_user_string .= '<td>' . PMA_getUserGroupEditLink($username) . '</td>' . "\n"; } $new_user_string .= '<td>' . PMA_getUserLink('export', $username, $hostname, '', '', isset($_GET['initial']) ? $_GET['initial'] : '') . '</td>' . "\n"; $new_user_string .= '</tr>'; $extra_data['new_user_string'] = $new_user_string; /** * Generate the string for this alphabet's initial, to update the user * pagination */ $new_user_initial = mb_strtoupper(mb_substr($username, 0, 1)); $newUserInitialString = '<a href="server_privileges.php' . PMA_URL_getCommon(array('initial' => $new_user_initial)) . '">' . $new_user_initial . '</a>'; $extra_data['new_user_initial'] = $new_user_initial; $extra_data['new_user_initial_string'] = $newUserInitialString; } if (isset($_POST['update_privs'])) { $extra_data['db_specific_privs'] = false; $extra_data['db_wildcard_privs'] = false; if (isset($dbname_is_wildcard)) { $extra_data['db_specific_privs'] = !$dbname_is_wildcard; $extra_data['db_wildcard_privs'] = $dbname_is_wildcard; } $new_privileges = join(', ', PMA_extractPrivInfo(null, true)); $extra_data['new_privileges'] = $new_privileges; } if (isset($_REQUEST['validate_username'])) { $sql_query = "SELECT * FROM `mysql`.`user` WHERE `User` = '" . $_REQUEST['username'] . "';"; $res = $GLOBALS['dbi']->query($sql_query); $row = $GLOBALS['dbi']->fetchRow($res); if (empty($row)) { $extra_data['user_exists'] = false; } else { $extra_data['user_exists'] = true; } } return $extra_data; }
/** * Handles editor requests for adding or editing an item * * @return Does not return */ function PMA_RTN_handleEditor() { global $_GET, $_POST, $_REQUEST, $GLOBALS, $db, $errors; if (!empty($_REQUEST['editor_process_add']) || !empty($_REQUEST['editor_process_edit'])) { /** * Handle a request to create/edit a routine */ $sql_query = ''; $routine_query = PMA_RTN_getQueryFromRequest(); if (!count($errors)) { // set by PMA_RTN_getQueryFromRequest() // Execute the created query if (!empty($_REQUEST['editor_process_edit'])) { if (!in_array($_REQUEST['item_original_type'], array('PROCEDURE', 'FUNCTION'))) { $errors[] = sprintf(__('Invalid routine type: "%s"'), htmlspecialchars($_REQUEST['item_original_type'])); } else { // Backup the old routine, in case something goes wrong $create_routine = PMA_DBI_get_definition($db, $_REQUEST['item_original_type'], $_REQUEST['item_original_name']); $drop_routine = "DROP {$_REQUEST['item_original_type']} " . PMA_Util::backquote($_REQUEST['item_original_name']) . ";\n"; $result = PMA_DBI_try_query($drop_routine); if (!$result) { $errors[] = sprintf(__('The following query has failed: "%s"'), htmlspecialchars($drop_routine)) . '<br />' . __('MySQL said: ') . PMA_DBI_getError(null); } else { $result = PMA_DBI_try_query($routine_query); if (!$result) { $errors[] = sprintf(__('The following query has failed: "%s"'), htmlspecialchars($routine_query)) . '<br />' . __('MySQL said: ') . PMA_DBI_getError(null); // We dropped the old routine, but were unable to create the new one // Try to restore the backup query $result = PMA_DBI_try_query($create_routine); if (!$result) { // OMG, this is really bad! We dropped the query, // failed to create a new one // and now even the backup query does not execute! // This should not happen, but we better handle // this just in case. $errors[] = __('Sorry, we failed to restore the dropped routine.') . '<br />' . __('The backed up query was:') . "\"" . htmlspecialchars($create_routine) . "\"" . '<br />' . __('MySQL said: ') . PMA_DBI_getError(null); } } else { $message = PMA_Message::success(__('Routine %1$s has been modified.')); $message->addParam(PMA_Util::backquote($_REQUEST['item_name'])); $sql_query = $drop_routine . $routine_query; } } } } else { // 'Add a new routine' mode $result = PMA_DBI_try_query($routine_query); if (!$result) { $errors[] = sprintf(__('The following query has failed: "%s"'), htmlspecialchars($routine_query)) . '<br /><br />' . __('MySQL said: ') . PMA_DBI_getError(null); } else { $message = PMA_Message::success(__('Routine %1$s has been created.')); $message->addParam(PMA_Util::backquote($_REQUEST['item_name'])); $sql_query = $routine_query; } } } if (count($errors)) { $message = PMA_Message::error(__('<b>One or more errors have occured while processing your request:</b>')); $message->addString('<ul>'); foreach ($errors as $string) { $message->addString('<li>' . $string . '</li>'); } $message->addString('</ul>'); } $output = PMA_Util::getMessage($message, $sql_query); if ($GLOBALS['is_ajax_request']) { $response = PMA_Response::getInstance(); if ($message->isSuccess()) { $columns = "`SPECIFIC_NAME`, `ROUTINE_NAME`, `ROUTINE_TYPE`, `DTD_IDENTIFIER`, `ROUTINE_DEFINITION`"; $where = "ROUTINE_SCHEMA='" . PMA_Util::sqlAddSlashes($db) . "' " . "AND ROUTINE_NAME='" . PMA_Util::sqlAddSlashes($_REQUEST['item_name']) . "'" . "AND ROUTINE_TYPE='" . PMA_Util::sqlAddSlashes($_REQUEST['item_type']) . "'"; $routine = PMA_DBI_fetch_single_row("SELECT {$columns} FROM `INFORMATION_SCHEMA`.`ROUTINES` WHERE {$where};"); $response->addJSON('name', htmlspecialchars(strtoupper($_REQUEST['item_name']))); $response->addJSON('new_row', PMA_RTN_getRowForList($routine)); $response->addJSON('insert', !empty($routine)); $response->addJSON('message', $output); } else { $response->isSuccess(false); $response->addJSON('message', $output); } exit; } } /** * Display a form used to add/edit a routine, 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['routine_addparameter']) || !empty($_REQUEST['routine_removeparameter']) || !empty($_REQUEST['routine_changetype']))) { // Handle requests to add/remove parameters and changing routine type // This is necessary when JS is disabled $operation = ''; if (!empty($_REQUEST['routine_addparameter'])) { $operation = 'add'; } else { if (!empty($_REQUEST['routine_removeparameter'])) { $operation = 'remove'; } else { if (!empty($_REQUEST['routine_changetype'])) { $operation = 'change'; } } } // Get the data for the form (if any) if (!empty($_REQUEST['add_item'])) { $title = PMA_RTE_getWord('add'); $routine = PMA_RTN_getDataFromRequest(); $mode = 'add'; } else { if (!empty($_REQUEST['edit_item'])) { $title = __("Edit routine"); if (!$operation && !empty($_REQUEST['item_name']) && empty($_REQUEST['editor_process_edit'])) { $routine = PMA_RTN_getDataFromName($_REQUEST['item_name'], $_REQUEST['item_type']); if ($routine !== false) { $routine['item_original_name'] = $routine['item_name']; $routine['item_original_type'] = $routine['item_type']; } } else { $routine = PMA_RTN_getDataFromRequest(); } $mode = 'edit'; } } if ($routine !== false) { // Show form $editor = PMA_RTN_getEditorForm($mode, $operation, $routine); if ($GLOBALS['is_ajax_request']) { $response = PMA_Response::getInstance(); $response->addJSON('message', $editor); $response->addJSON('title', $title); $response->addJSON('param_template', PMA_RTN_getParameterRow()); $response->addJSON('type', $routine['item_type']); } else { echo "\n\n<h2>{$title}</h2>\n\n{$editor}"; } 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->isSuccess(false); $response->addJSON('message', $message); exit; } else { $message->display(); } } } }
/** * Prepare a table of results returned by a SQL query. * * @param integer &$dt_result the link id associated to the query * which results have to be displayed * @param array &$displayParts the parts to display * @param array $analyzed_sql the analyzed query * @param boolean $is_limited_display With limited operations or not * * @return string $table_html Generated HTML content for resulted table * * @access public * * @see sql.php file */ public function getTable(&$dt_result, &$displayParts, $analyzed_sql, $is_limited_display = false) { $table_html = ''; // Following variable are needed for use in isset/empty or // use with array indexes/safe use in foreach $fields_meta = $this->__get('fields_meta'); $showtable = $this->__get('showtable'); $printview = $this->__get('printview'); // why was this called here? (already called from sql.php) //$this->setConfigParamsForDisplayTable(); /** * @todo move this to a central place * @todo for other future table types */ $is_innodb = isset($showtable['Type']) && $showtable['Type'] == self::TABLE_TYPE_INNO_DB; if ($is_innodb && !isset($analyzed_sql[0]['queryflags']['union']) && !isset($analyzed_sql[0]['table_ref'][1]['table_name']) && (empty($analyzed_sql[0]['where_clause']) || $analyzed_sql[0]['where_clause'] == '1 ')) { // "j u s t b r o w s i n g" $pre_count = '~'; $after_count = PMA_Util::showHint(PMA_sanitize(__('May be approximate. See [doc@faq3-11]FAQ 3.11[/doc].'))); } else { $pre_count = ''; $after_count = ''; } // 1. ----- Prepares the work ----- // 1.1 Gets the information about which functionalities should be // displayed $total = ''; $displayParts = $this->_setDisplayParts($displayParts, $total); // 1.2 Defines offsets for the next and previous pages if ($displayParts['nav_bar'] == '1') { list($pos_next, $pos_prev) = $this->_getOffsets(); } // end if if (!isset($analyzed_sql[0]['order_by_clause'])) { $analyzed_sql[0]['order_by_clause'] = ""; } // 1.3 Find the sort expression // we need $sort_expression and $sort_expression_nodirection // even if there are many table references list($sort_expression, $sort_expression_nodirection, $sort_direction) = $this->_getSortParams($analyzed_sql[0]['order_by_clause']); $number_of_columns = count($sort_expression_nodirection); // 1.4 Prepares display of first and last value of the sorted column $sorted_column_message = ''; for ($i = 0; $i < $number_of_columns; $i++) { $sorted_column_message .= $this->_getSortedColumnMessage($dt_result, $sort_expression_nodirection[$i]); } // 2. ----- Prepare to display the top of the page ----- // 2.1 Prepares a messages with position information if ($displayParts['nav_bar'] == '1' && isset($pos_next)) { $message = $this->_setMessageInformation($sorted_column_message, $analyzed_sql[0]['limit_clause'], $total, $pos_next, $pre_count, $after_count); $table_html .= PMA_Util::getMessage($message, $this->__get('sql_query'), 'success'); } elseif (!isset($printview) || $printview != '1') { $table_html .= PMA_Util::getMessage(__('Your SQL query has been executed successfully.'), $this->__get('sql_query'), 'success'); } // 2.3 Prepare the navigation bars if (!mb_strlen($this->__get('table'))) { if (isset($analyzed_sql[0]['query_type']) && $analyzed_sql[0]['query_type'] == self::QUERY_TYPE_SELECT) { // table does not always contain a real table name, // for example in MySQL 5.0.x, the query SHOW STATUS // returns STATUS as a table name $this->__set('table', $fields_meta[0]->table); } else { $this->__set('table', ''); } } if ($displayParts['nav_bar'] == '1' && empty($analyzed_sql[0]['limit_clause'])) { $table_html .= $this->_getPlacedTableNavigations($pos_next, $pos_prev, self::PLACE_TOP_DIRECTION_DROPDOWN, $is_innodb); } elseif (!isset($printview) || $printview != '1') { $table_html .= "\n" . '<br /><br />' . "\n"; } // 2b ----- Get field references from Database ----- // (see the 'relation' configuration variable) // initialize map $map = array(); // find tables $target = array(); if (isset($analyzed_sql[0]['table_ref']) && is_array($analyzed_sql[0]['table_ref'])) { foreach ($analyzed_sql[0]['table_ref'] as $table_ref_position => $table_ref) { $target[] = $analyzed_sql[0]['table_ref'][$table_ref_position]['table_true_name']; } } if (mb_strlen($this->__get('table'))) { // This method set the values for $map array $this->_setParamForLinkForeignKeyRelatedTables($map); // Coming from 'Distinct values' action of structure page // We manipulate relations mechanism to show a link to related rows. if ($this->__get('is_browse_distinct')) { $map[$fields_meta[1]->name] = array($this->__get('table'), $fields_meta[1]->name, '', $this->__get('db')); } } // end if // end 2b // 3. ----- Prepare the results table ----- $table_html .= $this->_getTableHeaders($displayParts, $analyzed_sql, $sort_expression, $sort_expression_nodirection, $sort_direction, $is_limited_display) . '<tbody>' . "\n"; $table_html .= $this->_getTableBody($dt_result, $displayParts, $map, $analyzed_sql, $is_limited_display); $this->__set('vertical_display', null); $table_html .= '</tbody>' . "\n" . '</table>'; // 4. ----- Prepares the link for multi-fields edit and delete if ($displayParts['del_lnk'] == self::DELETE_ROW && $displayParts['del_lnk'] != self::KILL_PROCESS) { $table_html .= $this->_getMultiRowOperationLinks($dt_result, $analyzed_sql, $displayParts['del_lnk']); } // 5. ----- Get the navigation bar at the bottom if required ----- if ($displayParts['nav_bar'] == '1' && empty($analyzed_sql[0]['limit_clause'])) { $table_html .= $this->_getPlacedTableNavigations($pos_next, $pos_prev, self::PLACE_BOTTOM_DIRECTION_DROPDOWN, $is_innodb); } elseif (!isset($printview) || $printview != '1') { $table_html .= "\n" . '<br /><br />' . "\n"; } // 6. ----- Prepare "Query results operations" if ((!isset($printview) || $printview != '1') && !$is_limited_display) { $table_html .= $this->_getResultsOperations($displayParts, $analyzed_sql); } return $table_html; }
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_Message(); $_message->addMessages($warning_messages); $_message->isError(true); unset($warning_messages); } echo PMA_Util::getMessage($_message, $sql_query, $_type, $is_view = true); 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"> <form method="post" action="view_operations.php"> <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?> <input type="hidden" name="reload" value="1" />
/** * 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; }
/** * Function to get html for schema snapshot * * @param string $url_query url query * * @return string */ function PMA_getHtmlForSchemaSnapshot($url_query) { $html = '<h3>' . __('Structure snapshot') . ' [<a href="tbl_tracking.php' . $url_query . '">' . __('Close') . '</a>]</h3>'; $data = PMA_Tracker::getTrackedData($_REQUEST['db'], $_REQUEST['table'], $_REQUEST['version']); // Get first DROP TABLE/VIEW and CREATE TABLE/VIEW statements $drop_create_statements = $data['ddlog'][0]['statement']; if (mb_strstr($data['ddlog'][0]['statement'], 'DROP TABLE') || mb_strstr($data['ddlog'][0]['statement'], 'DROP VIEW')) { $drop_create_statements .= $data['ddlog'][1]['statement']; } // Print SQL code $html .= PMA_Util::getMessage(sprintf(__('Version %s snapshot (SQL code)'), htmlspecialchars($_REQUEST['version'])), $drop_create_statements); // Unserialize snapshot $temp = unserialize($data['schema_snapshot']); $columns = $temp['COLUMNS']; $indexes = $temp['INDEXES']; $html .= PMA_getHtmlForColumns($columns); if (count($indexes) > 0) { $html .= PMA_getHtmlForIndexes($indexes); } // endif $html .= '<br /><hr /><br />'; return $html; }
/** * Update the table's structure based on $_REQUEST * * @param string $db database name * @param string $table table name * * @return boolean $regenerate true if error occurred * */ function PMA_updateColumns($db, $table) { $err_url = 'tbl_structure.php?' . PMA_URL_getCommon($db, $table); $regenerate = false; $field_cnt = count($_REQUEST['field_name']); $key_fields = array(); $changes = array(); for ($i = 0; $i < $field_cnt; $i++) { if (PMA_columnNeedsAlterTable($i)) { $changes[] = 'CHANGE ' . PMA_Table::generateAlter(isset($_REQUEST['field_orig'][$i]) ? $_REQUEST['field_orig'][$i] : '', $_REQUEST['field_name'][$i], $_REQUEST['field_type'][$i], $_REQUEST['field_length'][$i], $_REQUEST['field_attribute'][$i], isset($_REQUEST['field_collation'][$i]) ? $_REQUEST['field_collation'][$i] : '', isset($_REQUEST['field_null'][$i]) ? $_REQUEST['field_null'][$i] : 'NOT NULL', $_REQUEST['field_default_type'][$i], $_REQUEST['field_default_value'][$i], isset($_REQUEST['field_extra'][$i]) ? $_REQUEST['field_extra'][$i] : false, isset($_REQUEST['field_comments'][$i]) ? $_REQUEST['field_comments'][$i] : '', $key_fields, $i, isset($_REQUEST['field_move_to'][$i]) ? $_REQUEST['field_move_to'][$i] : ''); } } // end for $response = PMA_Response::getInstance(); if (count($changes) > 0) { // Builds the primary keys statements and updates the table $key_query = ''; /** * this is a little bit more complex * * @todo if someone selects A_I when altering a column we need to check: * - no other column with A_I * - the column has an index, if not create one * */ // To allow replication, we first select the db to use // and then run queries on this db. if (!$GLOBALS['dbi']->selectDb($db)) { PMA_Util::mysqlDie($GLOBALS['dbi']->getError(), 'USE ' . PMA_Util::backquote($db) . ';', '', $err_url); } $sql_query = 'ALTER TABLE ' . PMA_Util::backquote($table) . ' '; $sql_query .= implode(', ', $changes) . $key_query; $sql_query .= ';'; $result = $GLOBALS['dbi']->tryQuery($sql_query); if ($result !== false) { $message = PMA_Message::success(__('Table %1$s has been altered successfully.')); $message->addParam($table); $response->addHTML(PMA_Util::getMessage($message, $sql_query, 'success')); } else { // An error happened while inserting/updating a table definition $response->isSuccess(false); $response->addJSON('message', PMA_Message::rawError(__('Query error') . ':<br />' . $GLOBALS['dbi']->getError())); $regenerate = true; } } include_once 'libraries/transformations.lib.php'; // update field names in relation if (isset($_REQUEST['field_orig']) && is_array($_REQUEST['field_orig'])) { foreach ($_REQUEST['field_orig'] as $fieldindex => $fieldcontent) { if ($_REQUEST['field_name'][$fieldindex] != $fieldcontent) { PMA_REL_renameField($db, $table, $fieldcontent, $_REQUEST['field_name'][$fieldindex]); } } } // update mime types if (isset($_REQUEST['field_mimetype']) && is_array($_REQUEST['field_mimetype']) && $GLOBALS['cfg']['BrowseMIME']) { foreach ($_REQUEST['field_mimetype'] as $fieldindex => $mimetype) { if (isset($_REQUEST['field_name'][$fieldindex]) && strlen($_REQUEST['field_name'][$fieldindex])) { PMA_setMIME($db, $table, $_REQUEST['field_name'][$fieldindex], $mimetype, $_REQUEST['field_transformation'][$fieldindex], $_REQUEST['field_transformation_options'][$fieldindex]); } } } return $regenerate; }
"> <td><?php echo htmlspecialchars($tablename); ?> </td> <td><?php echo $my_link; ?> </td> </tr> <?php if ($style == 'even') { $style = 'odd'; } else { $style = 'even'; } } } ?> </tbody> </table> <?php } // If available print out database log if (count($data['ddlog']) > 0) { $log = ''; foreach ($data['ddlog'] as $entry) { $log .= '# ' . $entry['date'] . ' ' . $entry['username'] . "\n" . $entry['statement'] . "\n"; } echo PMA_Util::getMessage(__('Database Log'), $log); }
$cfgRelation = PMA_getRelationsParam(); /** * Check if comments were updated * (must be done before displaying the menu tabs) */ if (isset($_REQUEST['comment'])) { PMA_setDbComment($GLOBALS['db'], $_REQUEST['comment']); } require 'libraries/db_common.inc.php'; $url_query .= '&goto=db_operations.php'; // Gets the database structure $sub_part = '_structure'; require 'libraries/db_info.inc.php'; echo "\n"; if (isset($message)) { echo PMA_Util::getMessage($message, $sql_query); unset($message); } $_REQUEST['db_collation'] = PMA_getDbCollation($GLOBALS['db']); $is_information_schema = $GLOBALS['dbi']->isSystemSchema($GLOBALS['db']); $response->addHTML('<div id="boxContainer" data-box-width="300">'); if (!$is_information_schema) { if ($cfgRelation['commwork']) { /** * database comment */ $response->addHTML(PMA_getHtmlForDatabaseComment($GLOBALS['db'])); } $response->addHTML('<div class="operations_half_width">'); ob_start(); include 'libraries/display_create_table.lib.php';
/** * Update the table's structure based on $_REQUEST * * @param string $db database name * @param string $table table name * * @return boolean $regenerate true if error occurred * */ function PMA_updateColumns($db, $table) { $err_url = 'tbl_structure.php' . PMA_URL_getCommon(array('db' => $db, 'table' => $table)); $regenerate = false; $field_cnt = count($_REQUEST['field_name']); $changes = array(); $pmatable = new PMA_Table($table, $db); $adjust_privileges = array(); for ($i = 0; $i < $field_cnt; $i++) { if (PMA_columnNeedsAlterTable($i)) { $changes[] = 'CHANGE ' . PMA_Table::generateAlter(isset($_REQUEST['field_orig'][$i]) ? $_REQUEST['field_orig'][$i] : '', $_REQUEST['field_name'][$i], $_REQUEST['field_type'][$i], $_REQUEST['field_length'][$i], $_REQUEST['field_attribute'][$i], isset($_REQUEST['field_collation'][$i]) ? $_REQUEST['field_collation'][$i] : '', isset($_REQUEST['field_null'][$i]) ? $_REQUEST['field_null'][$i] : 'NOT NULL', $_REQUEST['field_default_type'][$i], $_REQUEST['field_default_value'][$i], isset($_REQUEST['field_extra'][$i]) ? $_REQUEST['field_extra'][$i] : false, isset($_REQUEST['field_comments'][$i]) ? $_REQUEST['field_comments'][$i] : '', isset($_REQUEST['field_virtuality'][$i]) ? $_REQUEST['field_virtuality'][$i] : '', isset($_REQUEST['field_expression'][$i]) ? $_REQUEST['field_expression'][$i] : '', isset($_REQUEST['field_move_to'][$i]) ? $_REQUEST['field_move_to'][$i] : ''); // find the remembered sort expression $sorted_col = $pmatable->getUiProp(PMA_Table::PROP_SORTED_COLUMN); // if the old column name is part of the remembered sort expression if (mb_strpos($sorted_col, PMA_Util::backquote($_REQUEST['field_orig'][$i])) !== false) { // delete the whole remembered sort expression $pmatable->removeUiProp(PMA_Table::PROP_SORTED_COLUMN); } if (isset($_REQUEST['field_adjust_privileges'][$i]) && !empty($_REQUEST['field_adjust_privileges'][$i]) && $_REQUEST['field_orig'][$i] != $_REQUEST['field_name'][$i]) { $adjust_privileges[$_REQUEST['field_orig'][$i]] = $_REQUEST['field_name'][$i]; } } } // end for $response = PMA_Response::getInstance(); if (count($changes) > 0 || isset($_REQUEST['preview_sql'])) { // Builds the primary keys statements and updates the table $key_query = ''; /** * this is a little bit more complex * * @todo if someone selects A_I when altering a column we need to check: * - no other column with A_I * - the column has an index, if not create one * */ // To allow replication, we first select the db to use // and then run queries on this db. if (!$GLOBALS['dbi']->selectDb($db)) { PMA_Util::mysqlDie($GLOBALS['dbi']->getError(), 'USE ' . PMA_Util::backquote($db) . ';', false, $err_url); } $sql_query = 'ALTER TABLE ' . PMA_Util::backquote($table) . ' '; $sql_query .= implode(', ', $changes) . $key_query; $sql_query .= ';'; // If there is a request for SQL previewing. if (isset($_REQUEST['preview_sql'])) { PMA_previewSQL(count($changes) > 0 ? $sql_query : ''); } $changedToBlob = array(); // While changing the Column Collation // First change to BLOB for ($i = 0; $i < $field_cnt; $i++) { if (isset($_REQUEST['field_collation'][$i]) && isset($_REQUEST['field_collation_orig'][$i]) && $_REQUEST['field_collation'][$i] !== $_REQUEST['field_collation_orig'][$i]) { $secondary_query = 'ALTER TABLE ' . PMA_Util::backquote($table) . ' CHANGE ' . PMA_Util::backquote($_REQUEST['field_orig'][$i]) . ' ' . PMA_Util::backquote($_REQUEST['field_orig'][$i]) . ' BLOB;'; $GLOBALS['dbi']->query($secondary_query); $changedToBlob[$i] = true; } else { $changedToBlob[$i] = false; } } // Then make the requested changes $result = $GLOBALS['dbi']->tryQuery($sql_query); if ($result !== false) { $changed_privileges = PMA_adjustColumnPrivileges($db, $table, $adjust_privileges); if ($changed_privileges) { $message = PMA_Message::success(__('Table %1$s has been altered successfully. Privileges ' . 'have been adjusted.')); } else { $message = PMA_Message::success(__('Table %1$s has been altered successfully.')); } $message->addParam($table); $response->addHTML(PMA_Util::getMessage($message, $sql_query, 'success')); } else { // An error happened while inserting/updating a table definition // Save the Original Error $orig_error = $GLOBALS['dbi']->getError(); $changes_revert = array(); // Change back to Orignal Collation and data type for ($i = 0; $i < $field_cnt; $i++) { if ($changedToBlob[$i]) { $changes_revert[] = 'CHANGE ' . PMA_Table::generateAlter(isset($_REQUEST['field_orig'][$i]) ? $_REQUEST['field_orig'][$i] : '', $_REQUEST['field_name'][$i], $_REQUEST['field_type_orig'][$i], $_REQUEST['field_length_orig'][$i], $_REQUEST['field_attribute_orig'][$i], isset($_REQUEST['field_collation_orig'][$i]) ? $_REQUEST['field_collation_orig'][$i] : '', isset($_REQUEST['field_null_orig'][$i]) ? $_REQUEST['field_null_orig'][$i] : 'NOT NULL', $_REQUEST['field_default_type_orig'][$i], $_REQUEST['field_default_value_orig'][$i], isset($_REQUEST['field_extra_orig'][$i]) ? $_REQUEST['field_extra_orig'][$i] : false, isset($_REQUEST['field_comments_orig'][$i]) ? $_REQUEST['field_comments_orig'][$i] : '', isset($_REQUEST['field_move_to_orig'][$i]) ? $_REQUEST['field_move_to_orig'][$i] : ''); } } $revert_query = 'ALTER TABLE ' . PMA_Util::backquote($table) . ' '; $revert_query .= implode(', ', $changes_revert) . ''; $revert_query .= ';'; // Column reverted back to original $GLOBALS['dbi']->query($revert_query); $response->isSuccess(false); $response->addJSON('message', PMA_Message::rawError(__('Query error') . ':<br />' . $orig_error)); $regenerate = true; } } include_once 'libraries/transformations.lib.php'; // update field names in relation if (isset($_REQUEST['field_orig']) && is_array($_REQUEST['field_orig'])) { foreach ($_REQUEST['field_orig'] as $fieldindex => $fieldcontent) { if ($_REQUEST['field_name'][$fieldindex] != $fieldcontent) { PMA_REL_renameField($db, $table, $fieldcontent, $_REQUEST['field_name'][$fieldindex]); } } } // update mime types if (isset($_REQUEST['field_mimetype']) && is_array($_REQUEST['field_mimetype']) && $GLOBALS['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]); } } } return $regenerate; }
/** * Function to handle foreign key updates * * @param array $destination_foreign_db destination foreign database * @param array $multi_edit_columns_name multi edit column names * @param array $destination_foreign_table destination foreign table * @param array $destination_foreign_column destination foreign column * @param array $options_array options array * @param string $table current table * @param array $existrel_foreign db, table, column * * @return string */ function PMA_handleUpdatesForForeignKeys($destination_foreign_db, $multi_edit_columns_name, $destination_foreign_table, $destination_foreign_column, $options_array, $table, $existrel_foreign) { $html_output = ''; $preview_sql_data = ''; $display_query = ''; $seen_error = false; $preview_sql = isset($_REQUEST['preview_sql']) ? true : false; foreach ($destination_foreign_db as $master_field_md5 => $foreign_db) { list($html, $sql_data) = PMA_handleUpdateForForeignKey($multi_edit_columns_name, $master_field_md5, $destination_foreign_table, $destination_foreign_column, $options_array, $existrel_foreign, $table, $seen_error, $display_query, $foreign_db, $preview_sql); $html_output .= $html; $preview_sql_data .= $sql_data; } // end foreach // If there is a request for SQL previewing. if ($preview_sql) { PMA_previewSQL($preview_sql_data); } if (!empty($display_query) && !$seen_error) { $GLOBALS['display_query'] = $display_query; $html_output = PMA_Util::getMessage(__('Your SQL query has been executed successfully.'), null, 'success'); } return $html_output; }
/** * Display the page * * @param string $message Message * @param string $sql_query SQL query * @param array $_url_params URL parameters * * @return void */ function PMA_changePassDisplayPage($message, $sql_query, $_url_params) { echo '<h1>' . __('Change password') . '</h1>' . "\n\n"; echo PMA_Util::getMessage($message, $sql_query, 'success'); echo '<a href="index.php' . PMA_URL_getCommon($_url_params) . ' target="_parent">' . "\n" . '<strong>' . __('Back') . '</strong></a>'; exit; }
/** * Show message for empty result or set the unique_condition * * @param array $rows MySQL returned rows * @param string $key_id ID in current key * @param array $where_clause_array array of where clauses * @param string $local_query query performed * @param array $result MySQL result handle * * @return boolean $has_unique_condition */ function PMA_showEmptyResultMessageOrSetUniqueCondition($rows, $key_id, $where_clause_array, $local_query, $result) { $has_unique_condition = false; // No row returned if (!$rows[$key_id]) { unset($rows[$key_id], $where_clause_array[$key_id]); PMA_Response::getInstance()->addHtml(PMA_Util::getMessage(__('MySQL returned an empty result set (i.e. zero rows).'), $local_query)); /** * @todo not sure what should be done at this point, but we must not * exit if we want the message to be displayed */ } else { // end if (no row returned) $meta = $GLOBALS['dbi']->getFieldsMeta($result[$key_id]); list($unique_condition, $tmp_clause_is_unique) = PMA_Util::getUniqueCondition($result[$key_id], count($meta), $meta, $rows[$key_id], true); if (!empty($unique_condition)) { $has_unique_condition = true; } unset($unique_condition, $tmp_clause_is_unique); } return $has_unique_condition; }
/** * Returns the html for binary log information. * * @param Array $url_params links parameters * * @return string */ function PMA_getLogInfo($url_params) { /** * Need to find the real end of rows? */ if (!isset($_REQUEST['pos'])) { $pos = 0; } else { /* We need this to be a integer */ $pos = (int) $_REQUEST['pos']; } $sql_query = 'SHOW BINLOG EVENTS'; if (!empty($_REQUEST['log'])) { $sql_query .= ' IN \'' . $_REQUEST['log'] . '\''; } $sql_query .= ' LIMIT ' . $pos . ', ' . (int) $GLOBALS['cfg']['MaxRows']; /** * Sends the query */ $result = $GLOBALS['dbi']->query($sql_query); /** * prepare some vars for displaying the result table */ // Gets the list of fields properties if (isset($result) && $result) { $num_rows = $GLOBALS['dbi']->numRows($result); } else { $num_rows = 0; } if (empty($_REQUEST['dontlimitchars'])) { $dontlimitchars = false; } else { $dontlimitchars = true; $url_params['dontlimitchars'] = 1; } //html output $html = PMA_Util::getMessage(PMA_Message::success(), $sql_query); $html .= '<table cellpadding="2" cellspacing="1" id="binlogTable">' . '<thead>' . '<tr>' . '<td colspan="6" class="center">'; $html .= PMA_getNavigationRow($url_params, $pos, $num_rows, $dontlimitchars); $html .= '</td>' . '</tr>' . '<tr>' . '<th>' . __('Log name') . '</th>' . '<th>' . __('Position') . '</th>' . '<th>' . __('Event type') . '</th>' . '<th>' . __('Server ID') . '</th>' . '<th>' . __('Original position') . '</th>' . '<th>' . __('Information') . '</th>' . '</tr>' . '</thead>' . '<tbody>'; $html .= PMA_getAllLogItemInfo($result, $dontlimitchars); $html .= '</tbody>' . '</table>'; return $html; }
/** * 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 = PMA_DBI_try_query($drop_item); if (!$result) { $errors[] = sprintf(__('The following query has failed: "%s"'), htmlspecialchars($drop_item)) . '<br />' . __('MySQL said: ') . PMA_DBI_getError(null); } else { $result = PMA_DBI_try_query($item_query); if (!$result) { $errors[] = sprintf(__('The following query has failed: "%s"'), htmlspecialchars($item_query)) . '<br />' . __('MySQL said: ') . PMA_DBI_getError(null); // We dropped the old item, but were unable to create the new one // Try to restore the backup query $result = PMA_DBI_try_query($create_item); if (!$result) { // OMG, this is really bad! We dropped the query, // failed to create a new one // and now even the backup query does not execute! // This should not happen, but we better handle // this just in case. $errors[] = __('Sorry, we failed to restore the dropped trigger.') . '<br />' . __('The backed up query was:') . "\"" . htmlspecialchars($create_item) . "\"" . '<br />' . __('MySQL said: ') . PMA_DBI_getError(null); } } else { $message = PMA_Message::success(__('Trigger %1$s has been modified.')); $message->addParam(PMA_Util::backquote($_REQUEST['item_name'])); $sql_query = $drop_item . $item_query; } } } else { // 'Add a new item' mode $result = PMA_DBI_try_query($item_query); if (!$result) { $errors[] = sprintf(__('The following query has failed: "%s"'), htmlspecialchars($item_query)) . '<br /><br />' . __('MySQL said: ') . PMA_DBI_getError(null); } else { $message = PMA_Message::success(__('Trigger %1$s has been created.')); $message->addParam(PMA_Util::backquote($_REQUEST['item_name'])); $sql_query = $item_query; } } } if (count($errors)) { $message = PMA_Message::error(__('<b>One or more errors have occured while processing your request:</b>')); $message->addString('<ul>'); foreach ($errors as $string) { $message->addString('<li>' . $string . '</li>'); } $message->addString('</ul>'); } $output = PMA_Util::getMessage($message, $sql_query); if ($GLOBALS['is_ajax_request']) { $response = PMA_Response::getInstance(); if ($message->isSuccess()) { $items = PMA_DBI_get_triggers($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(strtoupper($_REQUEST['item_name']))); } $response->addJSON('insert', $insert); $response->addJSON('message', $output); } else { $response->addJSON('message', $message); $response->isSuccess(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'; } } if ($item !== false) { // Show form $editor = PMA_TRI_getEditorForm($mode, $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(); } } } }
/** * Test for PMA_getExtraDataForAjaxBehavior * * @return void */ public function testPMAGetExtraDataForAjaxBehavior() { $password = "******"; $sql_query = "pma_sql_query"; $username = "******"; $hostname = "pma_hostname"; $GLOBALS['dbname'] = "pma_dbname"; $_REQUEST['adduser_submit'] = "adduser_submit"; $_REQUEST['change_copy'] = "change_copy"; $_REQUEST['validate_username'] = "******"; $_REQUEST['username'] = "******"; $_POST['update_privs'] = "update_privs"; //PMA_getExtraDataForAjaxBehavior $extra_data = PMA_getExtraDataForAjaxBehavior($password, $sql_query, $hostname, $username); //user_exists $this->assertEquals(false, $extra_data['user_exists']); //db_wildcard_privs $this->assertEquals(true, $extra_data['db_wildcard_privs']); //user_exists $this->assertEquals(false, $extra_data['db_specific_privs']); //new_user_initial $this->assertEquals('P', $extra_data['new_user_initial']); //sql_query $this->assertEquals(PMA_Util::getMessage(null, $sql_query), $extra_data['sql_query']); //new_user_string $this->assertContains(htmlspecialchars($hostname), $extra_data['new_user_string']); $this->assertContains(htmlspecialchars($username), $extra_data['new_user_string']); //new_privileges $this->assertContains(join(', ', PMA_extractPrivInfo(null, true)), $extra_data['new_privileges']); }
$column_name = $transformation['column_name']; foreach ($transformation_types as $type) { $file = PMA_securePath($transformation[$type]); $extra_data = PMA_transformEditedValues($db, $table, $transformation, $edited_values, $file, $column_name, $extra_data, $type); } } // end of loop for each $mime_map } // Need to check the inline edited value can be truncated by MySQL // without informing while saving $column_name = $_REQUEST['fields_name']['multi_edit'][0][0]; PMA_verifyWhetherValueCanBeTruncatedAndAppendExtraData($db, $table, $column_name, $extra_data); /**Get the total row count of the table*/ $_table = new PMA_Table($_REQUEST['table'], $_REQUEST['db']); $extra_data['row_count'] = $_table->countRecords(); $extra_data['sql_query'] = PMA_Util::getMessage($message, $GLOBALS['display_query']); $response = PMA_Response::getInstance(); $response->isSuccess($message->isSuccess()); $response->addJSON('message', $message); $response->addJSON($extra_data); exit; } if (!empty($return_to_sql_query)) { $disp_query = $GLOBALS['sql_query']; $disp_message = $message; unset($message); $GLOBALS['sql_query'] = $return_to_sql_query; } $scripts->addFile('tbl_change.js'); $scripts->addFile('big_ints.js'); $active_page = $goto_include;
// The part "SELECT `id`, `name` FROM `customers`" // is not modified by the next code segment, when exporting // the result set from a query such as // "SELECT `id`, `name` FROM `customers` WHERE id NOT IN // ( SELECT id FROM companies WHERE name LIKE '%u%')" if (!is_null($first_occurring_regex)) { $temp_sql_array = preg_split($first_occurring_regex, $sql_query); $sql_query = $temp_sql_array[0]; } unset($first_occurring_regex, $temp_sql_array); // Append the where clause using the primary key of each row if (is_array($where_clause) && count($where_clause) > 0) { $sql_query .= ' WHERE (' . implode(') OR (', $where_clause) . ')'; } if (!empty($analyzed_sql[0]['group_by_clause'])) { $sql_query .= ' GROUP BY ' . $analyzed_sql[0]['group_by_clause']; } if (!empty($analyzed_sql[0]['having_clause'])) { $sql_query .= ' HAVING ' . $analyzed_sql[0]['having_clause']; } if (!empty($analyzed_sql[0]['order_by_clause'])) { $sql_query .= ' ORDER BY ' . $analyzed_sql[0]['order_by_clause']; } } else { // Just crop LIMIT clause $sql_query = $analyzed_sql[0]['section_before_limit'] . $analyzed_sql[0]['section_after_limit']; } echo PMA_Util::getMessage(PMA_Message::success()); } $export_type = 'table'; require_once 'libraries/display_export.inc.php';
exit; } if ($GLOBALS['PMA_Config']->isGitRevision()) { if (isset($_REQUEST['git_revision']) && $GLOBALS['is_ajax_request'] == true) { PMA_printGitRevision(); exit; } echo '<div id="is_git_revision"></div>'; } // Handles some variables that may have been sent by the calling script $GLOBALS['db'] = ''; $GLOBALS['table'] = ''; $show_query = '1'; // Any message to display? if (!empty($message)) { echo PMA_Util::getMessage($message); unset($message); } $common_url_query = PMA_URL_getCommon(); $mysql_cur_user_and_host = ''; // when $server > 0, a server has been chosen so we can display // all MySQL-related information if ($server > 0) { include 'libraries/server_common.inc.php'; include 'libraries/StorageEngine.class.php'; // Use the verbose name of the server instead of the hostname // if a value is set $server_info = ''; if (!empty($cfg['Server']['verbose'])) { $server_info .= htmlspecialchars($cfg['Server']['verbose']); if ($GLOBALS['cfg']['ShowServerInfo']) {
/** * Handles editor requests for adding or editing an item * * @return void */ function PMA_RTN_handleEditor() { global $_GET, $_POST, $_REQUEST, $GLOBALS, $db, $errors; if (!empty($_REQUEST['editor_process_add']) || !empty($_REQUEST['editor_process_edit'])) { /** * Handle a request to create/edit a routine */ $sql_query = ''; $routine_query = PMA_RTN_getQueryFromRequest(); if (!count($errors)) { // set by PMA_RTN_getQueryFromRequest() // Execute the created query if (!empty($_REQUEST['editor_process_edit'])) { $isProcOrFunc = in_array($_REQUEST['item_original_type'], array('PROCEDURE', 'FUNCTION')); if (!$isProcOrFunc) { $errors[] = sprintf(__('Invalid routine type: "%s"'), htmlspecialchars($_REQUEST['item_original_type'])); } else { // Backup the old routine, in case something goes wrong $create_routine = $GLOBALS['dbi']->getDefinition($db, $_REQUEST['item_original_type'], $_REQUEST['item_original_name']); if (!defined('PMA_DRIZZLE') || !PMA_DRIZZLE) { if (isset($GLOBALS['proc_priv']) && $GLOBALS['proc_priv'] && isset($GLOBALS['flush_priv']) && $GLOBALS['flush_priv']) { // Backup the Old Privileges before dropping // if $_REQUEST['item_adjust_privileges'] set $privilegesBackup = array(); if (isset($_REQUEST['item_adjust_privileges']) && !empty($_REQUEST['item_adjust_privileges'])) { $privilegesBackupQuery = 'SELECT * FROM ' . PMA_Util::backquote('mysql') . '.' . PMA_Util::backquote('procs_priv') . ' where Routine_name = "' . $_REQUEST['item_original_name'] . '" AND Routine_type = "' . $_REQUEST['item_original_type'] . '";'; $privilegesBackup = $GLOBALS['dbi']->fetchResult($privilegesBackupQuery, 0); } } } $drop_routine = "DROP {$_REQUEST['item_original_type']} " . PMA_Util::backquote($_REQUEST['item_original_name']) . ";\n"; $result = $GLOBALS['dbi']->tryQuery($drop_routine); if (!$result) { $errors[] = sprintf(__('The following query has failed: "%s"'), htmlspecialchars($drop_routine)) . '<br />' . __('MySQL said: ') . $GLOBALS['dbi']->getError(null); } else { $result = $GLOBALS['dbi']->tryQuery($routine_query); if (!$result) { $errors[] = sprintf(__('The following query has failed: "%s"'), htmlspecialchars($routine_query)) . '<br />' . __('MySQL said: ') . $GLOBALS['dbi']->getError(null); // We dropped the old routine, // but were unable to create the new one // Try to restore the backup query $result = $GLOBALS['dbi']->tryQuery($create_routine); $errors = checkResult($result, __('Sorry, we failed to restore' . ' the dropped routine.'), $create_routine, $errors); } else { // Default value $resultAdjust = false; if (!defined('PMA_DRIZZLE') || !PMA_DRIZZLE) { if (isset($GLOBALS['proc_priv']) && $GLOBALS['proc_priv'] && isset($GLOBALS['flush_priv']) && $GLOBALS['flush_priv']) { // Insert all the previous privileges // but with the new name and the new type foreach ($privilegesBackup as $priv) { $adjustProcPrivilege = 'INSERT INTO ' . PMA_Util::backquote('mysql') . '.' . PMA_Util::backquote('procs_priv') . ' VALUES("' . $priv[0] . '", "' . $priv[1] . '", "' . $priv[2] . '", "' . $_REQUEST['item_name'] . '", "' . $_REQUEST['item_type'] . '", "' . $priv[5] . '", "' . $priv[6] . '", "' . $priv[7] . '");'; $resultAdjust = $GLOBALS['dbi']->query($adjustProcPrivilege); } } } if ($resultAdjust) { // Flush the Privileges $flushPrivQuery = 'FLUSH PRIVILEGES;'; $GLOBALS['dbi']->query($flushPrivQuery); $message = PMA_Message::success(__('Routine %1$s has been modified. Privileges have been adjusted.')); } else { $message = PMA_Message::success(__('Routine %1$s has been modified.')); } $message->addParam(PMA_Util::backquote($_REQUEST['item_name'])); $sql_query = $drop_routine . $routine_query; } } } } else { // 'Add a new routine' mode $result = $GLOBALS['dbi']->tryQuery($routine_query); if (!$result) { $errors[] = sprintf(__('The following query has failed: "%s"'), htmlspecialchars($routine_query)) . '<br /><br />' . __('MySQL said: ') . $GLOBALS['dbi']->getError(null); } else { $message = PMA_Message::success(__('Routine %1$s has been created.')); $message->addParam(PMA_Util::backquote($_REQUEST['item_name'])); $sql_query = $routine_query; } } } if (count($errors)) { $message = PMA_Message::error(__('One or more errors have occurred while' . ' processing your request:')); $message->addString('<ul>'); foreach ($errors as $string) { $message->addString('<li>' . $string . '</li>'); } $message->addString('</ul>'); } $output = PMA_Util::getMessage($message, $sql_query); if ($GLOBALS['is_ajax_request']) { $response = PMA_Response::getInstance(); if ($message->isSuccess()) { $routines = $GLOBALS['dbi']->getRoutines($db, $_REQUEST['item_type'], $_REQUEST['item_name']); $routine = $routines[0]; $response->addJSON('name', htmlspecialchars(mb_strtoupper($_REQUEST['item_name']))); $response->addJSON('new_row', PMA_RTN_getRowForList($routine)); $response->addJSON('insert', !empty($routine)); $response->addJSON('message', $output); } else { $response->isSuccess(false); $response->addJSON('message', $output); } exit; } } /** * Display a form used to add/edit a routine, if necessary */ // FIXME: this must be simpler than that if (count($errors) || empty($_REQUEST['editor_process_add']) && empty($_REQUEST['editor_process_edit']) && (!empty($_REQUEST['add_item']) || !empty($_REQUEST['edit_item']) || !empty($_REQUEST['routine_addparameter']) || !empty($_REQUEST['routine_removeparameter']) || !empty($_REQUEST['routine_changetype']))) { // Handle requests to add/remove parameters and changing routine type // This is necessary when JS is disabled $operation = ''; if (!empty($_REQUEST['routine_addparameter'])) { $operation = 'add'; } else { if (!empty($_REQUEST['routine_removeparameter'])) { $operation = 'remove'; } else { if (!empty($_REQUEST['routine_changetype'])) { $operation = 'change'; } } } // Get the data for the form (if any) if (!empty($_REQUEST['add_item'])) { $title = PMA_RTE_getWord('add'); $routine = PMA_RTN_getDataFromRequest(); $mode = 'add'; } else { if (!empty($_REQUEST['edit_item'])) { $title = __("Edit routine"); if (!$operation && !empty($_REQUEST['item_name']) && empty($_REQUEST['editor_process_edit'])) { $routine = PMA_RTN_getDataFromName($_REQUEST['item_name'], $_REQUEST['item_type']); if ($routine !== false) { $routine['item_original_name'] = $routine['item_name']; $routine['item_original_type'] = $routine['item_type']; } } else { $routine = PMA_RTN_getDataFromRequest(); } $mode = 'edit'; } } if ($routine !== false) { // Show form $editor = PMA_RTN_getEditorForm($mode, $operation, $routine); if ($GLOBALS['is_ajax_request']) { $response = PMA_Response::getInstance(); $response->addJSON('message', $editor); $response->addJSON('title', $title); $response->addJSON('param_template', PMA_RTN_getParameterRow()); $response->addJSON('type', $routine['item_type']); } else { echo "\n\n<h2>{$title}</h2>\n\n{$editor}"; } 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->isSuccess(false); $response->addJSON('message', $message); exit; } else { $message->display(); } } } }
} } if ($go_sql) { // parse sql query include_once 'libraries/parse_analyze.inc.php'; if (isset($ajax_reload) && $ajax_reload['reload'] === true) { $response = PMA_Response::getInstance(); $response->addJSON('ajax_reload', $ajax_reload); } PMA_executeQueryAndSendQueryResponse($analyzed_sql_results, false, $db, $table, null, $import_text, null, $analyzed_sql_results['is_affected'], null, null, null, null, $goto, $pmaThemeImage, null, null, null, $sql_query, null, null); } else { if ($result) { // Save a Bookmark with more than one queries (if Bookmark label given). if (!empty($_POST['bkm_label']) && !empty($import_text)) { PMA_storeTheQueryAsBookmark($db, $GLOBALS['cfg']['Bookmark']['user'], $import_text, $_POST['bkm_label'], isset($_POST['bkm_replace']) ? $_POST['bkm_replace'] : null); } $response = PMA_Response::getInstance(); $response->isSuccess(true); $response->addJSON('message', PMA_Message::success($msg)); $response->addJSON('sql_query', PMA_Util::getMessage($msg, $sql_query, 'success')); } else { if ($result == false) { $response = PMA_Response::getInstance(); $response->isSuccess(false); $response->addJSON('message', PMA_Message::error($msg)); } else { $active_page = $goto; include '' . $goto; } } }
/** * Displays the links */ if (isset($_REQUEST['viewing_mode']) && $_REQUEST['viewing_mode'] == 'db') { $GLOBALS['db'] = $_REQUEST['db'] = $_REQUEST['checkprivsdb']; $url_query .= '&goto=db_operations.php'; // Gets the database structure $sub_part = '_structure'; ob_start(); include 'libraries/db_info.inc.php'; $content = ob_get_contents(); ob_end_clean(); $response->addHTML($content . "\n"); } else { if (!empty($GLOBALS['message'])) { $response->addHTML(PMA_Util::getMessage($GLOBALS['message'])); unset($GLOBALS['message']); } } /** * Displays the page */ $response->addHTML(PMA_getHtmlForUserGroupDialog(isset($username) ? $username : null, $cfgRelation['menuswork'])); // export user definition if (isset($_REQUEST['export']) || isset($_REQUEST['submit_mult']) && $_REQUEST['submit_mult'] == 'export') { list($title, $export) = PMA_getListForExportUserDefinition(isset($username) ? $username : null, isset($hostname) ? $hostname : null); unset($username, $hostname, $grants, $one_grant); $response = PMA_Response::getInstance(); if ($GLOBALS['is_ajax_request']) { $response->addJSON('message', $export); $response->addJSON('title', $title);
$message->addParam($new); /* Check: Work on new table or on old table? */ if (isset($_REQUEST['submit_move']) || PMA_isValid($_REQUEST['switch_to_new'])) { $db = $_REQUEST['target_db']; $table = $_REQUEST['new_name']; } $reload = 1; } } else { /** * No new name for the table! */ $message = PMA_Message::error(__('The table name is empty!')); $result = false; } if ($GLOBALS['is_ajax_request'] == true) { $response = PMA_Response::getInstance(); $response->addJSON('message', $message); if ($message->isSuccess()) { $response->addJSON('db', $GLOBALS['db']); $response->addJSON('sql_query', PMA_Util::getMessage(null, $sql_query)); } else { $response->isSuccess(false); } exit; } /** * Back to the calling script */ $_message = $message; unset($message);
/** * Function to handle foreign key updates * * @param string $destination_foreign_db destination foreign database * @param string $multi_edit_columns_name multi edit column names * @param string $destination_foreign_table destination foreign table * @param string $destination_foreign_column destination foreign column * @param array $options_array options array * @param string $table current table * @param array $existrel_foreign db, table, column * * @return string */ function PMA_handleUpdatesForForeignKeys($destination_foreign_db, $multi_edit_columns_name, $destination_foreign_table, $destination_foreign_column, $options_array, $table, $existrel_foreign) { $html_output = ''; $display_query = ''; $seen_error = false; foreach ($destination_foreign_db as $master_field_md5 => $foreign_db) { $html_output .= PMA_handleUpdateForForeignKey($multi_edit_columns_name, $master_field_md5, $destination_foreign_table, $destination_foreign_column, $options_array, $existrel_foreign, $table, $seen_error, $display_query, $foreign_db); } // end foreach if (!empty($display_query) && !$seen_error) { $GLOBALS['display_query'] = $display_query; $html_output = PMA_Util::getMessage(__('Your SQL query has been executed successfully.'), null, 'success'); } return $html_output; }
exit; } } if (!empty($warning_messages)) { $_message = new PMA_Message(); $_message->addMessages($warning_messages); $_message->isError(true); if ($GLOBALS['ajax_request'] == true) { $response = PMA_Response::getInstance(); $response->isSuccess(false); $response->addJSON('message', $_message); exit; } unset($warning_messages); } $response->addHTML(PMA_Util::getMessage($_message, $sql_query, $_type)); unset($_message, $_type); } $url_params['goto'] = $url_params['back'] = 'tbl_operations.php'; /** * Get columns names */ $columns = $GLOBALS['dbi']->getColumns($GLOBALS['db'], $GLOBALS['table']); /** * Displays the page */ $response->addHTML('<div id="boxContainer" data-box-width="300">'); /** * Order the table */ $hideOrderTable = false;
/** * Returns the message to be displayed at the top of * the page, including the executed SQL query, if any. * * @return string */ public function getMessage() { $retval = ''; $message = ''; if (!empty($GLOBALS['message'])) { $message = $GLOBALS['message']; unset($GLOBALS['message']); } else { if (!empty($_REQUEST['message'])) { $message = $_REQUEST['message']; } } if (!empty($message)) { if (isset($GLOBALS['buffer_message'])) { $buffer_message = $GLOBALS['buffer_message']; } $retval .= PMA_Util::getMessage($message); if (isset($buffer_message)) { $GLOBALS['buffer_message'] = $buffer_message; } } return $retval; }
/** * This function return the extra data array for the ajax behavior * * @param string $password password * @param string $link_export export link * @param string $sql_query sql query * @param string $link_edit standard link for edit * @param string $hostname hostname * @param string $username username * * @return array $extra_data */ function PMA_getExtraDataForAjaxBehavior($password, $link_export, $sql_query, $link_edit, $hostname, $username) { if (isset($GLOBALS['dbname'])) { //if (preg_match('/\\\\(?:_|%)/i', $dbname)) { if (preg_match('/(?<!\\\\)(?:_|%)/i', $GLOBALS['dbname'])) { $dbname_is_wildcard = true; } else { $dbname_is_wildcard = false; } } $extra_data = array(); if (strlen($sql_query)) { $extra_data['sql_query'] = PMA_Util::getMessage(null, $sql_query); } if (isset($_REQUEST['adduser_submit']) || isset($_REQUEST['change_copy'])) { /** * generate html on the fly for the new user that was just created. */ $new_user_string = '<tr>' . "\n" . '<td> <input type="checkbox" name="selected_usr[]" ' . 'id="checkbox_sel_users_"' . 'value="' . htmlspecialchars($username) . '&#27;' . htmlspecialchars($hostname) . '" />' . '</td>' . "\n" . '<td><label for="checkbox_sel_users_">' . (empty($_REQUEST['username']) ? '<span style="color: #FF0000">' . __('Any') . '</span>' : htmlspecialchars($username)) . '</label></td>' . "\n" . '<td>' . htmlspecialchars($hostname) . '</td>' . "\n"; $new_user_string .= '<td>'; if (!empty($password) || isset($_POST['pma_pw'])) { $new_user_string .= __('Yes'); } else { $new_user_string .= '<span style="color: #FF0000">' . __('No') . '</span>'; } $new_user_string .= '</td>' . "\n"; $new_user_string .= '<td>' . '<code>' . join(', ', PMA_extractPrivInfo('', true)) . '</code>' . '</td>'; //Fill in privileges here $new_user_string .= '<td>'; if (isset($_POST['Grant_priv']) && $_POST['Grant_priv'] == 'Y') { $new_user_string .= __('Yes'); } else { $new_user_string .= __('No'); } $new_user_string .= '</td>'; $new_user_string .= '<td>' . sprintf($link_edit, urlencode($username), urlencode($hostname), '', '') . '</td>' . "\n"; $new_user_string .= '<td>' . sprintf($link_export, urlencode($username), urlencode($hostname), isset($_GET['initial']) ? $_GET['initial'] : '') . '</td>' . "\n"; $new_user_string .= '</tr>'; $extra_data['new_user_string'] = $new_user_string; /** * Generate the string for this alphabet's initial, to update the user * pagination */ $new_user_initial = strtoupper(substr($username, 0, 1)); $new_user_initial_string = '<a href="server_privileges.php?' . $GLOBALS['url_query'] . '&initial=' . $new_user_initial . '">' . $new_user_initial . '</a>'; $extra_data['new_user_initial'] = $new_user_initial; $extra_data['new_user_initial_string'] = $new_user_initial_string; } if (isset($_POST['update_privs'])) { $extra_data['db_specific_privs'] = false; $extra_data['db_wildcard_privs'] = false; if (isset($dbname_is_wildcard)) { $extra_data['db_specific_privs'] = !$dbname_is_wildcard; $extra_data['db_wildcard_privs'] = $dbname_is_wildcard; } $new_privileges = join(', ', PMA_extractPrivInfo('', true)); $extra_data['new_privileges'] = $new_privileges; } return $extra_data; }