/** * Main function for the routines functionality * * @param string $type 'FUNCTION' for functions, * 'PROCEDURE' for procedures, * null for both * * @return void */ function PMA_RTN_main($type) { global $db; PMA_RTN_setGlobals(); /** * Process all requests */ PMA_RTN_handleEditor(); PMA_RTN_handleExecute(); PMA_RTN_handleExport(); /** * Display a list of available routines */ if (!PMA_isValid($type, array('FUNCTION', 'PROCEDURE'))) { $type = null; } $items = $GLOBALS['dbi']->getRoutines($db, $type); echo PMA_RTE_getList('routine', $items); /** * Display the form for adding a new routine, if the user has the privileges. */ echo PMA_RTN_getFooterLinks(); /** * Display a warning for users with PHP's old "mysql" extension. */ if (!PMA\libraries\DatabaseInterface::checkDbExtension('mysqli')) { trigger_error(__('You are using PHP\'s deprecated \'mysql\' extension, ' . 'which is not capable of handling multi queries. ' . '[strong]The execution of some stored routines may fail![/strong] ' . 'Please use the improved \'mysqli\' extension to ' . 'avoid any problems.'), E_USER_WARNING); } }
/** * Main function for the routines functionality * * @param string $type 'FUNCTION' for functions, * 'PROCEDURE' for procedures, * null for both * * @return void */ function PMA_RTN_main($type) { global $db; PMA_RTN_setGlobals(); /** * Process all requests */ PMA_RTN_handleEditor(); PMA_RTN_handleExecute(); PMA_RTN_handleExport(); /** * Display a list of available routines */ $columns = "`SPECIFIC_NAME`, `ROUTINE_NAME`, `ROUTINE_TYPE`, "; $columns .= "`DTD_IDENTIFIER`, `ROUTINE_DEFINITION`"; $where = "ROUTINE_SCHEMA='" . PMA_Util::sqlAddSlashes($db) . "'"; if (PMA_isValid($type, array('FUNCTION', 'PROCEDURE'))) { $where .= " AND `ROUTINE_TYPE`='" . $type . "'"; } $items = $GLOBALS['dbi']->fetchResult("SELECT {$columns} FROM `INFORMATION_SCHEMA`.`ROUTINES` WHERE {$where};"); echo PMA_RTE_getList('routine', $items); /** * Display the form for adding a new routine, if the user has the privileges. */ echo PMA_RTN_getFooterLinks(); /** * Display a warning for users with PHP's old "mysql" extension. */ if ($GLOBALS['cfg']['Server']['extension'] === 'mysql') { trigger_error(__('You are using PHP\'s deprecated \'mysql\' extension, ' . 'which is not capable of handling multi queries. ' . '[strong]The execution of some stored routines may fail![/strong] ' . 'Please use the improved \'mysqli\' extension to ' . 'avoid any problems.'), E_USER_WARNING); } }
/** * checks given $var and returns it if valid, or $default of not valid * given $var is also checked for type being 'similar' as $default * or against any other type if $type is provided * * <code> * // $_REQUEST['db'] not set * echo PMA_ifSetOr($_REQUEST['db'], ''); // '' * // $_REQUEST['sql_query'] not set * echo PMA_ifSetOr($_REQUEST['sql_query']); // null * // $cfg['ForceSSL'] not set * echo PMA_ifSetOr($cfg['ForceSSL'], false, 'boolean'); // false * echo PMA_ifSetOr($cfg['ForceSSL']); // null * // $cfg['ForceSSL'] set to 1 * echo PMA_ifSetOr($cfg['ForceSSL'], false, 'boolean'); // false * echo PMA_ifSetOr($cfg['ForceSSL'], false, 'similar'); // 1 * echo PMA_ifSetOr($cfg['ForceSSL'], false); // 1 * // $cfg['ForceSSL'] set to true * echo PMA_ifSetOr($cfg['ForceSSL'], false, 'boolean'); // true * </code> * * @param mixed &$var param to check * @param mixed $default default value * @param mixed $type var type or array of values to check against $var * * @return mixed $var or $default * * @see PMA_isValid() */ function PMA_ifSetOr(&$var, $default = null, $type = 'similar') { if (!PMA_isValid($var, $type, $default)) { return $default; } return $var; }
/** * Returns the singleton instance of geometric class of the given type. * * @param string $type type of the geometric object * * @return PMA_GIS_Geometry the singleton instance of geometric class * of the given type * * @access public * @static */ public static function factory($type) { include_once './libraries/gis/GIS_Geometry.class.php'; $type_lower = strtolower($type); $file = './libraries/gis/GIS_' . ucfirst($type_lower) . '.class.php'; if (!PMA_isValid($type_lower, PMA_Util::getGISDatatypes()) || !file_exists($file)) { return false; } if (include_once $file) { switch (strtoupper($type)) { case 'MULTIPOLYGON': return PMA_GIS_Multipolygon::singleton(); case 'POLYGON': return PMA_GIS_Polygon::singleton(); case 'MULTIPOINT': return PMA_GIS_Multipoint::singleton(); case 'POINT': return PMA_GIS_Point::singleton(); case 'MULTILINESTRING': return PMA_GIS_Multilinestring::singleton(); case 'LINESTRING': return PMA_GIS_Linestring::singleton(); case 'GEOMETRYCOLLECTION': return PMA_GIS_Geometrycollection::singleton(); default: return false; } } else { return false; } }
/** * returns a tab for tabbed navigation. * If the variables $link and $args ar left empty, an inactive tab is created * * @param array $tab array with all options * @param array $url_params * * @return string html code for one tab, a link if valid otherwise a span * * @access public */ function PMA_generate_html_tab($tab, $url_params = array(), $base_dir = '') { // default values $defaults = array('text' => '', 'class' => '', 'active' => null, 'link' => '', 'sep' => '?', 'attr' => '', 'args' => '', 'warning' => '', 'fragment' => '', 'id' => ''); $tab = array_merge($defaults, $tab); // determine additionnal style-class if (empty($tab['class'])) { if (!empty($tab['active']) || PMA_isValid($GLOBALS['active_page'], 'identical', $tab['link'])) { $tab['class'] = 'active'; } elseif (is_null($tab['active']) && empty($GLOBALS['active_page']) && basename($GLOBALS['PMA_PHP_SELF']) == $tab['link'] && empty($tab['warning'])) { $tab['class'] = 'active'; } } if (!empty($tab['warning'])) { $tab['class'] .= ' error'; $tab['attr'] .= ' title="' . htmlspecialchars($tab['warning']) . '"'; } // If there are any tab specific URL parameters, merge those with // the general URL parameters if (!empty($tab['url_params']) && is_array($tab['url_params'])) { $url_params = array_merge($url_params, $tab['url_params']); } // build the link if (!empty($tab['link'])) { $tab['link'] = htmlentities($tab['link']); $tab['link'] = $tab['link'] . PMA_generate_common_url($url_params); if (!empty($tab['args'])) { foreach ($tab['args'] as $param => $value) { $tab['link'] .= PMA_get_arg_separator('html') . urlencode($param) . '=' . urlencode($value); } } } if (!empty($tab['fragment'])) { $tab['link'] .= $tab['fragment']; } // display icon, even if iconic is disabled but the link-text is missing if (($GLOBALS['cfg']['MainPageIconic'] || empty($tab['text'])) && isset($tab['icon'])) { // avoid generating an alt tag, because it only illustrates // the text that follows and if browser does not display // images, the text is duplicated $tab['text'] = PMA_getImage(htmlentities($tab['icon'])) . $tab['text']; } elseif (empty($tab['text'])) { // check to not display an empty link-text $tab['text'] = '?'; trigger_error('empty linktext in function ' . __FUNCTION__ . '()', E_USER_NOTICE); } //Set the id for the tab, if set in the params $id_string = empty($tab['id']) ? '' : ' id="' . $tab['id'] . '" '; $out = '<li' . ($tab['class'] == 'active' ? ' class="active"' : '') . '>'; if (!empty($tab['link'])) { $out .= '<a class="tab' . htmlentities($tab['class']) . '"' . $id_string . ' href="' . $tab['link'] . '" ' . $tab['attr'] . '>' . $tab['text'] . '</a>'; } else { $out .= '<span class="tab' . htmlentities($tab['class']) . '"' . $id_string . '>' . $tab['text'] . '</span>'; } $out .= '</li>'; return $out; }
<?php require_once 'libraries/common.inc.php'; if (!isset($_REQUEST['get_gis_editor']) && !isset($_REQUEST['generate'])) { include_once 'libraries/header_http.inc.php'; include_once 'libraries/header_meta_style.inc.php'; } require_once 'libraries/gis/pma_gis_factory.php'; require_once 'libraries/gis_visualization.lib.php'; // Get data if any posted $gis_data = array(); if (PMA_isValid($_REQUEST['gis_data'], 'array')) { $gis_data = $_REQUEST['gis_data']; } $gis_types = array('POINT', 'MULTIPOINT', 'LINESTRING', 'MULTILINESTRING', 'POLYGON', 'MULTIPOLYGON', 'GEOMETRYCOLLECTION'); // Extract type from the initial call and make sure that it's a valid one. // Extract from field's values if availbale, if not use the column type passed. if (!isset($gis_data['gis_type'])) { if (isset($_REQUEST['type']) && $_REQUEST['type'] != '') { $gis_data['gis_type'] = strtoupper($_REQUEST['type']); } if (isset($_REQUEST['value']) && trim($_REQUEST['value']) != '') { $start = substr($_REQUEST['value'], 0, 1) == "'" ? 1 : 0; $gis_data['gis_type'] = substr($_REQUEST['value'], $start, strpos($_REQUEST['value'], "(") - $start); } if (!isset($gis_data['gis_type']) || !in_array($gis_data['gis_type'], $gis_types)) { $gis_data['gis_type'] = $gis_types[0]; } } $geom_type = $gis_data['gis_type']; // Generate parameters from value passed.
/** * Move or copy a table * * @param string $db current database name * @param string $table current table name * * @return void */ function PMA_moveOrCopyTable($db, $table) { /** * Selects the database to work with */ $GLOBALS['dbi']->selectDb($db); /** * $_REQUEST['target_db'] could be empty in case we came from an input field * (when there are many databases, no drop-down) */ if (empty($_REQUEST['target_db'])) { $_REQUEST['target_db'] = $db; } /** * A target table name has been sent to this script -> do the work */ if (PMA_isValid($_REQUEST['new_name'])) { if ($db == $_REQUEST['target_db'] && $table == $_REQUEST['new_name']) { if (isset($_REQUEST['submit_move'])) { $message = Message::error(__('Can\'t move table to same one!')); } else { $message = Message::error(__('Can\'t copy table to same one!')); } } else { Table::moveCopy($db, $table, $_REQUEST['target_db'], $_REQUEST['new_name'], $_REQUEST['what'], isset($_REQUEST['submit_move']), 'one_table'); if (isset($_REQUEST['adjust_privileges']) && !empty($_REQUEST['adjust_privileges'])) { if (isset($_REQUEST['submit_move'])) { PMA_AdjustPrivileges_renameOrMoveTable($db, $table, $_REQUEST['target_db'], $_REQUEST['new_name']); } else { PMA_AdjustPrivileges_copyTable($db, $table, $_REQUEST['target_db'], $_REQUEST['new_name']); } if (isset($_REQUEST['submit_move'])) { $message = Message::success(__('Table %s has been moved to %s. Privileges have been ' . 'adjusted.')); } else { $message = Message::success(__('Table %s has been copied to %s. Privileges have been ' . 'adjusted.')); } } else { if (isset($_REQUEST['submit_move'])) { $message = Message::success(__('Table %s has been moved to %s.')); } else { $message = Message::success(__('Table %s has been copied to %s.')); } } $old = PMA\libraries\Util::backquote($db) . '.' . PMA\libraries\Util::backquote($table); $message->addParam($old); $new = PMA\libraries\Util::backquote($_REQUEST['target_db']) . '.' . PMA\libraries\Util::backquote($_REQUEST['new_name']); $message->addParam($new); /* Check: Work on new table or on old table? */ if (isset($_REQUEST['submit_move']) || PMA_isValid($_REQUEST['switch_to_new'])) { } } } else { /** * No new name for the table! */ $message = Message::error(__('The table name is empty!')); } if ($GLOBALS['is_ajax_request'] == true) { $response = PMA\libraries\Response::getInstance(); $response->addJSON('message', $message); if ($message->isSuccess()) { $response->addJSON('db', $GLOBALS['db']); } else { $response->setRequestStatus(false); } exit; } }
/** * Outputs dropdown with values of foreign fields * * @param array $disp_row array of the displayed row * @param string $foreign_field the foreign field * @param string $foreign_display the foreign field to display * @param string $data the current data of the dropdown (field in row) * @param int $max maximum number of items in the dropdown * * @return string the <option value=""><option>s * * @access public */ function PMA_foreignDropdown($disp_row, $foreign_field, $foreign_display, $data, $max = null) { if (null === $max) { $max = $GLOBALS['cfg']['ForeignKeyMaxLimit']; } $foreign = array(); // collect the data foreach ($disp_row as $relrow) { $key = $relrow[$foreign_field]; // if the display field has been defined for this foreign table if ($foreign_display) { $value = $relrow[$foreign_display]; } else { $value = ''; } // end if ($foreign_display) $foreign[$key] = $value; } // end foreach // put the dropdown sections in correct order $top = array(); $bottom = array(); if ($foreign_display) { if (PMA_isValid($GLOBALS['cfg']['ForeignKeyDropdownOrder'], 'array')) { if (PMA_isValid($GLOBALS['cfg']['ForeignKeyDropdownOrder'][0])) { $top = PMA_buildForeignDropdown($foreign, $data, $GLOBALS['cfg']['ForeignKeyDropdownOrder'][0]); } if (PMA_isValid($GLOBALS['cfg']['ForeignKeyDropdownOrder'][1])) { $bottom = PMA_buildForeignDropdown($foreign, $data, $GLOBALS['cfg']['ForeignKeyDropdownOrder'][1]); } } else { $top = PMA_buildForeignDropdown($foreign, $data, 'id-content'); $bottom = PMA_buildForeignDropdown($foreign, $data, 'content-id'); } } else { $top = PMA_buildForeignDropdown($foreign, $data, 'id-only'); } // beginning of dropdown $ret = '<option value=""> </option>'; $top_count = count($top); if ($max == -1 || $top_count < $max) { $ret .= implode('', $top); if ($foreign_display && $top_count > 0) { // this empty option is to visually mark the beginning of the // second series of values (bottom) $ret .= '<option value=""> </option>'; } } if ($foreign_display) { $ret .= implode('', $bottom); } return $ret; }
*/ $is_show_stats = $cfg['ShowStats']; /** * @global bool whether selected db is information_schema */ $db_is_information_schema = false; if ($db == 'information_schema') { $is_show_stats = false; $db_is_information_schema = true; } /** * @global array information about tables in db */ $tables = array(); // When used in Nested table group mode, only show tables matching the given groupname if (PMA_isValid($tbl_group) && !$cfg['ShowTooltipAliasTB']) { $tbl_group_sql = ' LIKE "' . PMA_escape_mysql_wildcards($tbl_group) . '%"'; } else { $tbl_group_sql = ''; } if ($cfg['ShowTooltip']) { $tooltip_truename = array(); $tooltip_aliasname = array(); } // Special speedup for newer MySQL Versions (in 4.0 format changed) if (true === $cfg['SkipLockedTables']) { $db_info_result = PMA_DBI_query('SHOW OPEN TABLES FROM ' . PMA_backquote($db) . ';'); // Blending out tables in use if ($db_info_result && PMA_DBI_num_rows($db_info_result) > 0) { while ($tmp = PMA_DBI_fetch_row($db_info_result)) { // if in use memorize tablename
/** * Sets criteria tables and columns * * @return void */ private function _setCriteriaTablesAndColumns() { // The tables list sent by a previously submitted form if (PMA_isValid($_REQUEST['TableList'], 'array')) { foreach ($_REQUEST['TableList'] as $each_table) { $this->_criteriaTables[$each_table] = ' selected="selected"'; } } // end if $all_tables = $GLOBALS['dbi']->query('SHOW TABLES FROM ' . Util::backquote($this->_db) . ';', null, DatabaseInterface::QUERY_STORE); $all_tables_count = $GLOBALS['dbi']->numRows($all_tables); if (0 == $all_tables_count) { Message::error(__('No tables found in database.'))->display(); exit; } // The tables list gets from MySQL while (list($table) = $GLOBALS['dbi']->fetchRow($all_tables)) { $columns = $GLOBALS['dbi']->getColumns($this->_db, $table); if (empty($this->_criteriaTables[$table]) && !empty($_REQUEST['TableList'])) { $this->_criteriaTables[$table] = ''; } else { $this->_criteriaTables[$table] = ' selected="selected"'; } // end if // The fields list per selected tables if ($this->_criteriaTables[$table] == ' selected="selected"') { $each_table = Util::backquote($table); $this->_columnNames[] = $each_table . '.*'; foreach ($columns as $each_column) { $each_column = $each_table . '.' . Util::backquote($each_column['Field']); $this->_columnNames[] = $each_column; // increase the width if necessary $this->_form_column_width = max(mb_strlen($each_column), $this->_form_column_width); } // end foreach } // end if } // end while $GLOBALS['dbi']->freeResult($all_tables); // sets the largest width found $this->_realwidth = $this->_form_column_width . 'ex'; }
$options = array_intersect($_REQUEST['view']['with'], $view_with_options); if (count($options)) { $sql_query .= $sep . ' WITH ' . implode(' ', $options); } } if (PMA_DBI_try_query($sql_query)) { $message = PMA_Message::success(); require './' . $cfg['DefaultTabDatabase']; exit; } else { $message = PMA_Message::rawError(PMA_DBI_getError()); } } // prefill values if not already filled from former submission $view = array('or_replace' => '', 'algorithm' => '', 'name' => '', 'column_names' => '', 'as' => $sql_query, 'with' => array()); if (PMA_isValid($_REQUEST['view'], 'array')) { $view = array_merge($view, $_REQUEST['view']); } /** * Displays top menu links * We use db links because a VIEW is not necessarily on a single table */ $num_tables = 0; require_once './libraries/db_links.inc.php'; $url_params['db'] = $GLOBALS['db']; $url_params['reload'] = 1; /** * Displays the page */ ?> <!-- CREATE VIEW options -->
$message = PMA_Message::error(__('Can\'t copy table to same one!')); } $result = false; } else { $result = PMA_Table::moveCopy($db, $table, $_REQUEST['target_db'], $_REQUEST['new_name'], $_REQUEST['what'], isset($_REQUEST['submit_move']), 'one_table'); if (isset($_REQUEST['submit_move'])) { $message = PMA_Message::success(__('Table %s has been moved to %s.')); } else { $message = PMA_Message::success(__('Table %s has been copied to %s.')); } $old = PMA_Util::backquote($db) . '.' . PMA_Util::backquote($table); $message->addParam($old); $new = PMA_Util::backquote($_REQUEST['target_db']) . '.' . PMA_Util::backquote($_REQUEST['new_name']); $message->addParam($new); /* Check: Work on new table or on old table? */ if (isset($_REQUEST['submit_move']) || PMA_isValid($_REQUEST['switch_to_new'])) { $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);
<?php /* vim: set expandtab sw=4 ts=4 sts=4: */ /** * URL redirector to avoid leaking Referer with some sensitive information. * * @package PhpMyAdmin */ /** * Gets core libraries and defines some variables */ define('PMA_MINIMUM_COMMON', true); require_once './libraries/common.inc.php'; if (!PMA_isValid($_GET['url']) || !preg_match('/^https?:\\/\\/[^\\n\\r]*$/', $_GET['url'])) { header('Location: ' . $cfg['PmaAbsoluteUri']); } else { header('Location: ' . $_GET['url']); } die;
/** * * @uses $_SESSION['userconf']['disp_direction'] * @uses $_REQUEST['disp_direction'] * @uses $GLOBALS['cfg']['DefaultDisplay'] * @uses $_SESSION['userconf']['repeat_cells'] * @uses $_REQUEST['repeat_cells'] * @uses $GLOBALS['cfg']['RepeatCells'] * @uses $_SESSION['userconf']['max_rows'] * @uses $_REQUEST['session_max_rows'] * @uses $GLOBALS['cfg']['MaxRows'] * @uses $_SESSION['userconf']['pos'] * @uses $_REQUEST['pos'] * @uses $_SESSION['userconf']['dontlimitchars'] * @uses $_REQUEST['dontlimitchars'] * @uses PMA_isValid() * @uses $GLOBALS['sql_query'] * @todo make maximum remembered queries configurable * @todo move/split into SQL class!? * @todo currently this is called twice unnecessary * @todo ignore LIMIT and ORDER in query!? */ function PMA_displayTable_checkConfigParams() { $sql_key = md5($GLOBALS['sql_query']); $_SESSION['userconf']['query'][$sql_key]['sql'] = $GLOBALS['sql_query']; if (PMA_isValid($_REQUEST['disp_direction'], array('horizontal', 'vertical', 'horizontalflipped'))) { $_SESSION['userconf']['query'][$sql_key]['disp_direction'] = $_REQUEST['disp_direction']; unset($_REQUEST['disp_direction']); } elseif (empty($_SESSION['userconf']['query'][$sql_key]['disp_direction'])) { $_SESSION['userconf']['query'][$sql_key]['disp_direction'] = $GLOBALS['cfg']['DefaultDisplay']; } if (PMA_isValid($_REQUEST['repeat_cells'], 'numeric')) { $_SESSION['userconf']['query'][$sql_key]['repeat_cells'] = $_REQUEST['repeat_cells']; unset($_REQUEST['repeat_cells']); } elseif (empty($_SESSION['userconf']['query'][$sql_key]['repeat_cells'])) { $_SESSION['userconf']['query'][$sql_key]['repeat_cells'] = $GLOBALS['cfg']['RepeatCells']; } if (PMA_isValid($_REQUEST['session_max_rows'], 'numeric') || $_REQUEST['session_max_rows'] == 'all') { $_SESSION['userconf']['query'][$sql_key]['max_rows'] = $_REQUEST['session_max_rows']; unset($_REQUEST['session_max_rows']); } elseif (empty($_SESSION['userconf']['query'][$sql_key]['max_rows'])) { $_SESSION['userconf']['query'][$sql_key]['max_rows'] = $GLOBALS['cfg']['MaxRows']; } if (PMA_isValid($_REQUEST['pos'], 'numeric')) { $_SESSION['userconf']['query'][$sql_key]['pos'] = $_REQUEST['pos']; unset($_REQUEST['pos']); } elseif (empty($_SESSION['userconf']['query'][$sql_key]['pos'])) { $_SESSION['userconf']['query'][$sql_key]['pos'] = 0; } if (PMA_isValid($_REQUEST['dontlimitchars'], array('0', '1'))) { $_SESSION['userconf']['query'][$sql_key]['dontlimitchars'] = (int) $_REQUEST['dontlimitchars']; unset($_REQUEST['dontlimitchars']); } elseif (empty($_SESSION['userconf']['query'][$sql_key]['dontlimitchars'])) { $_SESSION['userconf']['query'][$sql_key]['dontlimitchars'] = 0; } // move current query to the last position, to be removed last // so only least executed query will be removed if maximum remembered queries // limit is reached $tmp = $_SESSION['userconf']['query'][$sql_key]; unset($_SESSION['userconf']['query'][$sql_key]); $_SESSION['userconf']['query'][$sql_key] = $tmp; // do not exceed a maximum number of queries to remember if (count($_SESSION['userconf']['query']) > 10) { array_shift($_SESSION['userconf']['query']); //echo 'deleting one element ...'; } // populate query configuration $_SESSION['userconf']['dontlimitchars'] = $_SESSION['userconf']['query'][$sql_key]['dontlimitchars']; $_SESSION['userconf']['pos'] = $_SESSION['userconf']['query'][$sql_key]['pos']; $_SESSION['userconf']['max_rows'] = $_SESSION['userconf']['query'][$sql_key]['max_rows']; $_SESSION['userconf']['repeat_cells'] = $_SESSION['userconf']['query'][$sql_key]['repeat_cells']; $_SESSION['userconf']['disp_direction'] = $_SESSION['userconf']['query'][$sql_key]['disp_direction']; /* * debugging echo '<pre>'; var_dump($_SESSION['userconf']); echo '</pre>'; */ }
$is_show_stats = $cfg['ShowStats']; /** * @global bool whether selected db is information_schema */ $db_is_information_schema = false; if (PMA_is_system_schema($db)) { $is_show_stats = false; $db_is_information_schema = true; } /** * @global array information about tables in db */ $tables = array(); // When used in Nested table group mode, // only show tables matching the given groupname if (PMA_isValid($_REQUEST['tbl_group'])) { $tbl_group_sql = ' LIKE "' . PMA_Util::escapeMysqlWildcards($_REQUEST['tbl_group']) . '%"'; } else { $tbl_group_sql = ''; } $tooltip_truename = array(); $tooltip_aliasname = array(); // Special speedup for newer MySQL Versions (in 4.0 format changed) if (true === $cfg['SkipLockedTables']) { $db_info_result = PMA_DBI_query('SHOW OPEN TABLES FROM ' . PMA_Util::backquote($db) . ';'); // Blending out tables in use if ($db_info_result && PMA_DBI_num_rows($db_info_result) > 0) { while ($tmp = PMA_DBI_fetch_row($db_info_result)) { // if in use memorize tablename if (preg_match('@in_use=[1-9]+@i', $tmp[1])) { $sot_cache[$tmp[0]] = true;
/** * Generate the hashing function * * @return string $hashing_function */ function PMA_changePassHashingFunction() { if (PMA_isValid($_REQUEST['authentication_plugin'], 'identical', 'mysql_old_password')) { $hashing_function = 'OLD_PASSWORD'; } else { $hashing_function = 'PASSWORD'; } return $hashing_function; }
$query_to_display = ''; } } $sql_query = ''; /** * prepare JavaScript functionality */ $response = PMA_Response::getInstance(); $response->getFooter()->setMinimal(); $header = $response->getHeader(); $header->disableMenu(); $header->setBodyId('bodyquerywindow'); $scripts = $header->getScripts(); $scripts->addFile('common.js'); $scripts->addFile('querywindow.js'); if (PMA_isValid($_REQUEST['auto_commit'], 'identical', 'true')) { $scripts->addEvent('load', 'PMA_queryAutoCommit'); } // always set focus to the textarea if ($querydisplay_tab == 'sql' || $querydisplay_tab == 'full') { $scripts->addEvent('load', 'PMA_querywindowSetFocus'); } echo '<div id="querywindowcontainer">'; if ($tabs) { echo PMA_Util::getHtmlTabs($tabs, array(), 'topmenu', true); unset($tabs); } echo PMA_getHtmlForSqlQueryForm($query_to_display, $querydisplay_tab); // Hidden forms and query frame interaction stuff $_sql_history = PMA_getHistory($GLOBALS['cfg']['Server']['user']); if (!empty($_sql_history) && ($querydisplay_tab == 'history' || $querydisplay_tab == 'full')) {
$data = array(); $result = $GLOBALS['dbi']->tryQuery($sql_query); $fields_meta = $GLOBALS['dbi']->getFieldsMeta($result); while ($row = $GLOBALS['dbi']->fetchAssoc($result)) { $data[] = $row; } $keys = array_keys($data[0]); $numeric_types = array('int', 'real'); $numeric_column_count = 0; foreach ($keys as $idx => $key) { if (in_array($fields_meta[$idx]->type, $numeric_types)) { $numeric_column_count++; } } if ($numeric_column_count == 0) { $response->isSuccess(false); $response->addJSON('message', __('No numeric columns present in the table to plot.')); exit; } // get settings if any posted $chartSettings = array(); if (PMA_isValid($_REQUEST['chartSettings'], 'array')) { $chartSettings = $_REQUEST['chartSettings']; } $url_params['db'] = $GLOBALS['db']; $url_params['reload'] = 1; /** * Displays the page */ $htmlString = PMA_getHtmlForTableChartDisplay($url_query, $url_params, $keys, $fields_meta, $numeric_types, $numeric_column_count, $sql_query); $response->addHTML($htmlString);
/** * Saves query in history * * @return void */ private function _setHistory() { if (!PMA_isValid($_REQUEST['no_history']) && empty($GLOBALS['error_message']) && !empty($GLOBALS['sql_query'])) { PMA_setHistory(PMA_ifSetOr($GLOBALS['db'], ''), PMA_ifSetOr($GLOBALS['table'], ''), $GLOBALS['cfg']['Server']['user'], $GLOBALS['sql_query']); } }
break; default: $type = gettype($compare); } } elseif ($type === 'equal') { $type = gettype($compare); } // do the check if ($type === 'length' || $type === 'scalar') { $is_scalar = is_scalar($var); if ($is_scalar && $type === 'length') { return (bool) strlen($var); } return $is_scalar; } if ($type === 'numeric') { return is_numeric($var); } if (gettype($var) === $type) { return true; } return false; } $var = user_input(); // symbolic $type = user_input(); // symbolic $compare = user_input(); // symbolic $result = PMA_isValid($var, $type, $compare); label("after-call");
/** * Checks the posted options for viewing query results * and sets appropriate values in the session. * * @todo make maximum remembered queries configurable * @todo move/split into SQL class!? * @todo currently this is called twice unnecessary * @todo ignore LIMIT and ORDER in query!? * * @return void * * @access public * * @see sql.php file */ public function setConfigParamsForDisplayTable() { $sql_md5 = md5($this->__get('sql_query')); $query = array(); if (isset($_SESSION['tmpval']['query'][$sql_md5])) { $query = $_SESSION['tmpval']['query'][$sql_md5]; } $query['sql'] = $this->__get('sql_query'); if (empty($query['repeat_cells'])) { $query['repeat_cells'] = $GLOBALS['cfg']['RepeatCells']; } // as this is a form value, the type is always string so we cannot // use PMA_isValid($_REQUEST['session_max_rows'], 'integer') if (PMA_isValid($_REQUEST['session_max_rows'], 'numeric')) { $query['max_rows'] = (int) $_REQUEST['session_max_rows']; unset($_REQUEST['session_max_rows']); } elseif ($_REQUEST['session_max_rows'] == self::ALL_ROWS) { $query['max_rows'] = self::ALL_ROWS; unset($_REQUEST['session_max_rows']); } elseif (empty($query['max_rows'])) { $query['max_rows'] = $GLOBALS['cfg']['MaxRows']; } if (PMA_isValid($_REQUEST['pos'], 'numeric')) { $query['pos'] = $_REQUEST['pos']; unset($_REQUEST['pos']); } elseif (empty($query['pos'])) { $query['pos'] = 0; } if (PMA_isValid($_REQUEST['pftext'], array(self::DISPLAY_PARTIAL_TEXT, self::DISPLAY_FULL_TEXT))) { $query['pftext'] = $_REQUEST['pftext']; unset($_REQUEST['pftext']); } elseif (empty($query['pftext'])) { $query['pftext'] = self::DISPLAY_PARTIAL_TEXT; } if (PMA_isValid($_REQUEST['relational_display'], array(self::RELATIONAL_KEY, self::RELATIONAL_DISPLAY_COLUMN))) { $query['relational_display'] = $_REQUEST['relational_display']; unset($_REQUEST['relational_display']); } elseif (empty($query['relational_display'])) { // The current session value has priority over a // change via Settings; this change will be apparent // starting from the next session $query['relational_display'] = $GLOBALS['cfg']['RelationalDisplay']; } if (PMA_isValid($_REQUEST['geoOption'], array(self::GEOMETRY_DISP_WKT, self::GEOMETRY_DISP_WKB, self::GEOMETRY_DISP_GEOM))) { $query['geoOption'] = $_REQUEST['geoOption']; unset($_REQUEST['geoOption']); } elseif (empty($query['geoOption'])) { $query['geoOption'] = self::GEOMETRY_DISP_GEOM; } if (isset($_REQUEST['display_binary'])) { $query['display_binary'] = true; unset($_REQUEST['display_binary']); } elseif (isset($_REQUEST['display_options_form'])) { // we know that the checkbox was unchecked unset($query['display_binary']); } elseif (isset($_REQUEST['full_text_button'])) { // do nothing to keep the value that is there in the session } else { // selected by default because some operations like OPTIMIZE TABLE // and all queries involving functions return "binary" contents, // according to low-level field flags $query['display_binary'] = true; } if (isset($_REQUEST['display_blob'])) { $query['display_blob'] = true; unset($_REQUEST['display_blob']); } elseif (isset($_REQUEST['display_options_form'])) { // we know that the checkbox was unchecked unset($query['display_blob']); } if (isset($_REQUEST['hide_transformation'])) { $query['hide_transformation'] = true; unset($_REQUEST['hide_transformation']); } elseif (isset($_REQUEST['display_options_form'])) { // we know that the checkbox was unchecked unset($query['hide_transformation']); } // move current query to the last position, to be removed last // so only least executed query will be removed if maximum remembered // queries limit is reached unset($_SESSION['tmpval']['query'][$sql_md5]); $_SESSION['tmpval']['query'][$sql_md5] = $query; // do not exceed a maximum number of queries to remember if (count($_SESSION['tmpval']['query']) > 10) { array_shift($_SESSION['tmpval']['query']); //echo 'deleting one element ...'; } // populate query configuration $_SESSION['tmpval']['pftext'] = $query['pftext']; $_SESSION['tmpval']['relational_display'] = $query['relational_display']; $_SESSION['tmpval']['geoOption'] = $query['geoOption']; $_SESSION['tmpval']['display_binary'] = isset($query['display_binary']); $_SESSION['tmpval']['display_blob'] = isset($query['display_blob']); $_SESSION['tmpval']['hide_transformation'] = isset($query['hide_transformation']); $_SESSION['tmpval']['pos'] = $query['pos']; $_SESSION['tmpval']['max_rows'] = $query['max_rows']; $_SESSION['tmpval']['repeat_cells'] = $query['repeat_cells']; }
/** * returns details about the PROCEDUREs or FUNCTIONs for a specific database * or details about a specific routine * * @param string $db db name * @param string $which PROCEDURE | FUNCTION or null for both * @param string $name name of the routine (to fetch a specific routine) * * @return array information about ROCEDUREs or FUNCTIONs */ public function getRoutines($db, $which = null, $name = '') { $routines = array(); if (!$GLOBALS['cfg']['Server']['DisableIS']) { $query = "SELECT" . " `ROUTINE_SCHEMA` AS `Db`," . " `SPECIFIC_NAME` AS `Name`," . " `ROUTINE_TYPE` AS `Type`," . " `DEFINER` AS `Definer`," . " `LAST_ALTERED` AS `Modified`," . " `CREATED` AS `Created`," . " `SECURITY_TYPE` AS `Security_type`," . " `ROUTINE_COMMENT` AS `Comment`," . " `CHARACTER_SET_CLIENT` AS `character_set_client`," . " `COLLATION_CONNECTION` AS `collation_connection`," . " `DATABASE_COLLATION` AS `Database Collation`," . " `DTD_IDENTIFIER`" . " FROM `information_schema`.`ROUTINES`" . " WHERE `ROUTINE_SCHEMA` " . Util::getCollateForIS() . " = '" . Util::sqlAddSlashes($db) . "'"; if (PMA_isValid($which, array('FUNCTION', 'PROCEDURE'))) { $query .= " AND `ROUTINE_TYPE` = '" . $which . "'"; } if (!empty($name)) { $query .= " AND `SPECIFIC_NAME`" . " = '" . Util::sqlAddSlashes($name) . "'"; } $result = $this->fetchResult($query); if (!empty($result)) { $routines = $result; } } else { if ($which == 'FUNCTION' || $which == null) { $query = "SHOW FUNCTION STATUS" . " WHERE `Db` = '" . Util::sqlAddSlashes($db) . "'"; if (!empty($name)) { $query .= " AND `Name` = '" . Util::sqlAddSlashes($name) . "'"; } $result = $this->fetchResult($query); if (!empty($result)) { $routines = array_merge($routines, $result); } } if ($which == 'PROCEDURE' || $which == null) { $query = "SHOW PROCEDURE STATUS" . " WHERE `Db` = '" . Util::sqlAddSlashes($db) . "'"; if (!empty($name)) { $query .= " AND `Name` = '" . Util::sqlAddSlashes($name) . "'"; } $result = $this->fetchResult($query); if (!empty($result)) { $routines = array_merge($routines, $result); } } } $ret = array(); foreach ($routines as $routine) { $one_result = array(); $one_result['db'] = $routine['Db']; $one_result['name'] = $routine['Name']; $one_result['type'] = $routine['Type']; $one_result['definer'] = $routine['Definer']; $one_result['returns'] = isset($routine['DTD_IDENTIFIER']) ? $routine['DTD_IDENTIFIER'] : ""; $ret[] = $one_result; } // Sort results by name $name = array(); foreach ($ret as $value) { $name[] = $value['name']; } array_multisort($name, SORT_ASC, $ret); return $ret; }
/** * Checks if a dropdown box has been used for selecting a database / table */ if (PMA_isValid($_REQUEST['pred_tablename'])) { $tablename = $_REQUEST['pred_tablename']; unset($pred_tablename); } elseif (PMA_isValid($_REQUEST['tablename'])) { $tablename = $_REQUEST['tablename']; } else { unset($tablename); } if (PMA_isValid($_REQUEST['pred_dbname'])) { $dbname = $_REQUEST['pred_dbname']; unset($pred_dbname); } elseif (PMA_isValid($_REQUEST['dbname'])) { $dbname = $_REQUEST['dbname']; } else { unset($dbname); unset($tablename); } if (isset($dbname)) { $db_and_table = PMA_backquote(PMA_unescape_mysql_wildcards($dbname)) . '.'; if (isset($tablename)) { $db_and_table .= PMA_backquote($tablename); } else { $db_and_table .= '*'; } } else { $db_and_table = '*.*';
/** * Creates some globals from $_REQUEST * * @param string $param db|table * * @return void */ function PMA_setGlobalDbOrTable($param) { $GLOBALS[$param] = ''; if (PMA_isValid($_REQUEST[$param])) { // can we strip tags from this? // only \ and / is not allowed in db names for MySQL $GLOBALS[$param] = $_REQUEST[$param]; $GLOBALS['url_params'][$param] = $GLOBALS[$param]; } }
/** * Update DB information: DB, Table, isWildcard * * @return array */ function PMA_getDataForDBInfo() { $username = null; $hostname = null; $dbname = null; $tablename = null; $dbname_is_wildcard = null; if (isset($_REQUEST['username'])) { $username = $_REQUEST['username']; } if (isset($_REQUEST['hostname'])) { $hostname = $_REQUEST['hostname']; } /** * Checks if a dropdown box has been used for selecting a database / table */ if (PMA_isValid($_REQUEST['pred_tablename'])) { $tablename = $_REQUEST['pred_tablename']; } elseif (PMA_isValid($_REQUEST['tablename'])) { $tablename = $_REQUEST['tablename']; } else { unset($tablename); } if (isset($_REQUEST['pred_dbname'])) { $is_valid_pred_dbname = true; foreach ($_REQUEST['pred_dbname'] as $key => $db_name) { if (!PMA_isValid($db_name)) { $is_valid_pred_dbname = false; break; } } } if (isset($_REQUEST['dbname'])) { $is_valid_dbname = true; if (is_array($_REQUEST['dbname'])) { foreach ($_REQUEST['dbname'] as $key => $db_name) { if (!PMA_isValid($db_name)) { $is_valid_dbname = false; break; } } } else { if (!PMA_isValid($_REQUEST['dbname'])) { $is_valid_dbname = false; } } } if (isset($is_valid_pred_dbname) && $is_valid_pred_dbname) { $dbname = $_REQUEST['pred_dbname']; // If dbname contains only one database. if (count($dbname) == 1) { $dbname = $dbname[0]; } } elseif (isset($is_valid_dbname) && $is_valid_dbname) { $dbname = $_REQUEST['dbname']; } else { unset($dbname); unset($tablename); } if (isset($dbname)) { if (is_array($dbname)) { $db_and_table = $dbname; foreach ($db_and_table as $key => $db_name) { $db_and_table[$key] .= '.'; } } else { $unescaped_db = PMA_Util::unescapeMysqlWildcards($dbname); $db_and_table = PMA_Util::backquote($unescaped_db) . '.'; } if (isset($tablename)) { $db_and_table .= PMA_Util::backquote($tablename); } else { if (is_array($db_and_table)) { foreach ($db_and_table as $key => $db_name) { $db_and_table[$key] .= '*'; } } else { $db_and_table .= '*'; } } } else { $db_and_table = '*.*'; } // check if given $dbname is a wildcard or not if (isset($dbname)) { //if (preg_match('/\\\\(?:_|%)/i', $dbname)) { if (!is_array($dbname) && preg_match('/(?<!\\\\)(?:_|%)/i', $dbname)) { $dbname_is_wildcard = true; } else { $dbname_is_wildcard = false; } } return array($username, $hostname, isset($dbname) ? $dbname : null, isset($tablename) ? $tablename : null, $db_and_table, $dbname_is_wildcard); }
: array_fill(0, $col_cnt, ''); $and_or_row = isset($_REQUEST['and_or_row']) ? $_REQUEST['and_or_row'] : array_fill(0, $col_cnt, ''); $and_or_col = isset($_REQUEST['and_or_col']) ? $_REQUEST['and_or_col'] : array_fill(0, $col_cnt, ''); // minimum width $form_column_width = 12; $col = max($col_cnt + $add_col, 0); $row = max($rows + $add_row, 0); // The tables list sent by a previously submitted form if (PMA_isValid($_REQUEST['TableList'], 'array')) { foreach ($_REQUEST['TableList'] as $each_table) { $tbl_names[$each_table] = ' selected="selected"'; } } // end if // this was a work in progress, deactivated for now //$columns = PMA_DBI_get_columns_full($GLOBALS['db']); //$tables = PMA_DBI_get_columns_full($GLOBALS['db']); /** * Prepares the form */ $tbl_result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', null, PMA_DBI_QUERY_STORE);
* Store currently selected recent table. * Affect $GLOBALS['db'] and $GLOBALS['table'] */ if (PMA_isValid($_REQUEST['selected_recent_table'])) { $recent_table = json_decode($_REQUEST['selected_recent_table'], true); $GLOBALS['db'] = $recent_table['db']; $GLOBALS['url_params']['db'] = $GLOBALS['db']; $GLOBALS['table'] = $recent_table['table']; $GLOBALS['url_params']['table'] = $GLOBALS['table']; } /** * SQL query to be executed * @global string $GLOBALS['sql_query'] */ $GLOBALS['sql_query'] = ''; if (PMA_isValid($_REQUEST['sql_query'])) { $GLOBALS['sql_query'] = $_REQUEST['sql_query']; } //$_REQUEST['set_theme'] // checked later in this file LABEL_theme_setup //$_REQUEST['server']; // checked later in this file //$_REQUEST['lang']; // checked by LABEL_loading_language_file /******************************************************************************/ /* loading language file LABEL_loading_language_file */ /** * lang detection is done here */ require './libraries/select_lang.lib.php'; // Defines the cell alignment values depending on text direction if ($GLOBALS['text_dir'] == 'ltr') { $GLOBALS['cell_align_left'] = 'left'; $GLOBALS['cell_align_right'] = 'right';
/** * * @uses $_SESSION['tmp_user_values']['disp_direction'] * @uses $_REQUEST['disp_direction'] * @uses $GLOBALS['cfg']['DefaultDisplay'] * @uses $_SESSION['tmp_user_values']['repeat_cells'] * @uses $_REQUEST['repeat_cells'] * @uses $GLOBALS['cfg']['RepeatCells'] * @uses $_SESSION['tmp_user_values']['max_rows'] * @uses $_REQUEST['session_max_rows'] * @uses $GLOBALS['cfg']['MaxRows'] * @uses $_SESSION['tmp_user_values']['pos'] * @uses $_REQUEST['pos'] * @uses $_SESSION['tmp_user_values']['display_text'] * @uses $_REQUEST['display_text'] * @uses $_SESSION['tmp_user_values']['relational_display'] * @uses $_REQUEST['relational_display'] * @uses $_SESSION['tmp_user_values']['display_binary'] * @uses $_REQUEST['display_binary'] * @uses $_SESSION['tmp_user_values']['display_binary_as_hex'] * @uses $_REQUEST['display_binary_as_hex'] * @uses $_SESSION['tmp_user_values']['display_blob'] * @uses $_REQUEST['display_blob'] * @uses PMA_isValid() * @uses $GLOBALS['sql_query'] * @todo make maximum remembered queries configurable * @todo move/split into SQL class!? * @todo currently this is called twice unnecessary * @todo ignore LIMIT and ORDER in query!? */ function PMA_displayTable_checkConfigParams() { $sql_key = md5($GLOBALS['sql_query']); $_SESSION['tmp_user_values']['query'][$sql_key]['sql'] = $GLOBALS['sql_query']; if (PMA_isValid($_REQUEST['disp_direction'], array('horizontal', 'vertical', 'horizontalflipped'))) { $_SESSION['tmp_user_values']['query'][$sql_key]['disp_direction'] = $_REQUEST['disp_direction']; unset($_REQUEST['disp_direction']); } elseif (empty($_SESSION['tmp_user_values']['query'][$sql_key]['disp_direction'])) { $_SESSION['tmp_user_values']['query'][$sql_key]['disp_direction'] = $GLOBALS['cfg']['DefaultDisplay']; } if (PMA_isValid($_REQUEST['repeat_cells'], 'numeric')) { $_SESSION['tmp_user_values']['query'][$sql_key]['repeat_cells'] = $_REQUEST['repeat_cells']; unset($_REQUEST['repeat_cells']); } elseif (empty($_SESSION['tmp_user_values']['query'][$sql_key]['repeat_cells'])) { $_SESSION['tmp_user_values']['query'][$sql_key]['repeat_cells'] = $GLOBALS['cfg']['RepeatCells']; } if (PMA_isValid($_REQUEST['session_max_rows'], 'numeric') || $_REQUEST['session_max_rows'] == 'all') { $_SESSION['tmp_user_values']['query'][$sql_key]['max_rows'] = $_REQUEST['session_max_rows']; unset($_REQUEST['session_max_rows']); } elseif (empty($_SESSION['tmp_user_values']['query'][$sql_key]['max_rows'])) { $_SESSION['tmp_user_values']['query'][$sql_key]['max_rows'] = $GLOBALS['cfg']['MaxRows']; } if (PMA_isValid($_REQUEST['pos'], 'numeric')) { $_SESSION['tmp_user_values']['query'][$sql_key]['pos'] = $_REQUEST['pos']; unset($_REQUEST['pos']); } elseif (empty($_SESSION['tmp_user_values']['query'][$sql_key]['pos'])) { $_SESSION['tmp_user_values']['query'][$sql_key]['pos'] = 0; } if (PMA_isValid($_REQUEST['display_text'], array('P', 'F'))) { $_SESSION['tmp_user_values']['query'][$sql_key]['display_text'] = $_REQUEST['display_text']; unset($_REQUEST['display_text']); } elseif (empty($_SESSION['tmp_user_values']['query'][$sql_key]['display_text'])) { $_SESSION['tmp_user_values']['query'][$sql_key]['display_text'] = 'P'; } if (PMA_isValid($_REQUEST['relational_display'], array('K', 'D'))) { $_SESSION['tmp_user_values']['query'][$sql_key]['relational_display'] = $_REQUEST['relational_display']; unset($_REQUEST['relational_display']); } elseif (empty($_SESSION['tmp_user_values']['query'][$sql_key]['relational_display'])) { $_SESSION['tmp_user_values']['query'][$sql_key]['relational_display'] = 'K'; } if (isset($_REQUEST['display_binary'])) { $_SESSION['tmp_user_values']['query'][$sql_key]['display_binary'] = true; unset($_REQUEST['display_binary']); } elseif (isset($_REQUEST['display_options_form'])) { // we know that the checkbox was unchecked unset($_SESSION['tmp_user_values']['query'][$sql_key]['display_binary']); } else { // selected by default because some operations like OPTIMIZE TABLE // and all queries involving functions return "binary" contents, // according to low-level field flags $_SESSION['tmp_user_values']['query'][$sql_key]['display_binary'] = true; } if (isset($_REQUEST['display_binary_as_hex'])) { $_SESSION['tmp_user_values']['query'][$sql_key]['display_binary_as_hex'] = true; unset($_REQUEST['display_binary_as_hex']); } elseif (isset($_REQUEST['display_options_form'])) { // we know that the checkbox was unchecked unset($_SESSION['tmp_user_values']['query'][$sql_key]['display_binary_as_hex']); } else { // display_binary_as_hex config option if (isset($GLOBALS['cfg']['DisplayBinaryAsHex']) && true === $GLOBALS['cfg']['DisplayBinaryAsHex']) { $_SESSION['tmp_user_values']['query'][$sql_key]['display_binary_as_hex'] = true; } } if (isset($_REQUEST['display_blob'])) { $_SESSION['tmp_user_values']['query'][$sql_key]['display_blob'] = true; unset($_REQUEST['display_blob']); } elseif (isset($_REQUEST['display_options_form'])) { // we know that the checkbox was unchecked unset($_SESSION['tmp_user_values']['query'][$sql_key]['display_blob']); } if (isset($_REQUEST['hide_transformation'])) { $_SESSION['tmp_user_values']['query'][$sql_key]['hide_transformation'] = true; unset($_REQUEST['hide_transformation']); } elseif (isset($_REQUEST['display_options_form'])) { // we know that the checkbox was unchecked unset($_SESSION['tmp_user_values']['query'][$sql_key]['hide_transformation']); } // move current query to the last position, to be removed last // so only least executed query will be removed if maximum remembered queries // limit is reached $tmp = $_SESSION['tmp_user_values']['query'][$sql_key]; unset($_SESSION['tmp_user_values']['query'][$sql_key]); $_SESSION['tmp_user_values']['query'][$sql_key] = $tmp; // do not exceed a maximum number of queries to remember if (count($_SESSION['tmp_user_values']['query']) > 10) { array_shift($_SESSION['tmp_user_values']['query']); //echo 'deleting one element ...'; } // populate query configuration $_SESSION['tmp_user_values']['display_text'] = $_SESSION['tmp_user_values']['query'][$sql_key]['display_text']; $_SESSION['tmp_user_values']['relational_display'] = $_SESSION['tmp_user_values']['query'][$sql_key]['relational_display']; $_SESSION['tmp_user_values']['display_binary'] = isset($_SESSION['tmp_user_values']['query'][$sql_key]['display_binary']) ? true : false; $_SESSION['tmp_user_values']['display_binary_as_hex'] = isset($_SESSION['tmp_user_values']['query'][$sql_key]['display_binary_as_hex']) ? true : false; $_SESSION['tmp_user_values']['display_blob'] = isset($_SESSION['tmp_user_values']['query'][$sql_key]['display_blob']) ? true : false; $_SESSION['tmp_user_values']['hide_transformation'] = isset($_SESSION['tmp_user_values']['query'][$sql_key]['hide_transformation']) ? true : false; $_SESSION['tmp_user_values']['pos'] = $_SESSION['tmp_user_values']['query'][$sql_key]['pos']; $_SESSION['tmp_user_values']['max_rows'] = $_SESSION['tmp_user_values']['query'][$sql_key]['max_rows']; $_SESSION['tmp_user_values']['repeat_cells'] = $_SESSION['tmp_user_values']['query'][$sql_key]['repeat_cells']; $_SESSION['tmp_user_values']['disp_direction'] = $_SESSION['tmp_user_values']['query'][$sql_key]['disp_direction']; /* * debugging echo '<pre>'; var_dump($_SESSION['tmp_user_values']); echo '</pre>'; */ }
/** * Gets HTML to display import dialogs * * @param String $import_type Import type: server|database|table * @param String $db Selected DB * @param String $table Selected Table * @param int $max_upload_size Max upload size * * @return string $html */ function PMA_getImportDisplay($import_type, $db, $table, $max_upload_size) { global $SESSION_KEY; include_once './libraries/file_listing.lib.php'; include_once './libraries/plugin_interface.lib.php'; include_once './libraries/display_import_ajax.lib.php'; list($SESSION_KEY, $upload_id, $plugins) = PMA_uploadProgressSetup(); /* Scan for plugins */ /* @var $import_list ImportPlugin[] */ $import_list = PMA_getPlugins("import", 'libraries/plugins/import/', $import_type); /* Fail if we didn't find any plugin */ if (empty($import_list)) { Message::error(__('Could not load import plugins, please check your installation!'))->display(); exit; } if (PMA_isValid($_REQUEST['offset'], 'numeric')) { $offset = $_REQUEST['offset']; } if (isset($_REQUEST['timeout_passed'])) { $timeout_passed = $_REQUEST['timeout_passed']; } $local_import_file = ''; if (isset($_REQUEST['local_import_file'])) { $local_import_file = $_REQUEST['local_import_file']; } $timeout_passed_str = isset($timeout_passed) ? $timeout_passed : null; $offset_str = isset($offset) ? $offset : null; return PMA_getHtmlForImport($upload_id, $import_type, $db, $table, $max_upload_size, $import_list, $timeout_passed_str, $offset_str, $local_import_file); }
/** * Generate the hashing function * * @return string $hashing_function */ function PMA_changePassHashingFunction() { if (PMA_isValid($_REQUEST['pw_hash'], 'identical', 'old')) { $hashing_function = 'OLD_PASSWORD'; } else { $hashing_function = 'PASSWORD'; } return $hashing_function; }