/** * Creates PMA tables in the given db, updates if already exists. * * @param string $db database * @param boolean $create whether to create tables if they don't exist. * * @return void */ function PMA_fixPMATables($db, $create = true) { $tablesToFeatures = array('pma__bookmark' => 'bookmarktable', 'pma__relation' => 'relation', 'pma__table_info' => 'table_info', 'pma__table_coords' => 'table_coords', 'pma__pdf_pages' => 'pdf_pages', 'pma__column_info' => 'column_info', 'pma__history' => 'history', 'pma__recent' => 'recent', 'pma__favorite' => 'favorite', 'pma__table_uiprefs' => 'table_uiprefs', 'pma__tracking' => 'tracking', 'pma__userconfig' => 'userconfig', 'pma__users' => 'users', 'pma__usergroups' => 'usergroups', 'pma__navigationhiding' => 'navigationhiding', 'pma__savedsearches' => 'savedsearches', 'pma__central_columns' => 'central_columns'); $existingTables = $GLOBALS['dbi']->getTables($db, $GLOBALS['controllink']); $createQueries = null; $foundOne = false; foreach ($tablesToFeatures as $table => $feature) { if (!in_array($table, $existingTables)) { if ($create) { if ($createQueries == null) { // first create $createQueries = PMA_getDefaultPMATableNames(); $GLOBALS['dbi']->selectDb($db); } $GLOBALS['dbi']->tryQuery($createQueries[$table]); if ($error = $GLOBALS['dbi']->getError()) { $GLOBALS['message'] = $error; return; } $GLOBALS['cfg']['Server'][$feature] = $table; } } else { $foundOne = true; $GLOBALS['cfg']['Server'][$feature] = $table; } } if (!$foundOne) { return; } $GLOBALS['cfg']['Server']['pmadb'] = $db; $_SESSION['relation'][$GLOBALS['server']] = PMA_checkRelationsParam(); $cfgRelation = PMA_getRelationsParam(); if ($cfgRelation['recentwork'] || $cfgRelation['favoritework']) { // Since configuration storage is updated, we need to // re-initialize the favorite and recent tables stored in the // session from the current configuration storage. include_once 'libraries/RecentFavoriteTable.class.php'; if ($cfgRelation['favoritework']) { $fav_tables = PMA_RecentFavoriteTable::getInstance('favorite'); $_SESSION['tmpval']['favorite_tables'][$GLOBALS['server']] = $fav_tables->getFromDb(); } if ($cfgRelation['recentwork']) { $recent_tables = PMA_RecentFavoriteTable::getInstance('recent'); $_SESSION['tmpval']['recent_tables'][$GLOBALS['server']] = $recent_tables->getFromDb(); } // Reload navi panel to update the recent/favorite lists. $GLOBALS['reload'] = true; } }
/** * Add recently used table and reload the navigation. * * @param string $db Database name where the table is located. * @param string $table The table name * * @return string */ private function _addRecentTable($db, $table) { $retval = ''; if ($this->_menuEnabled && mb_strlen($table) && $GLOBALS['cfg']['NumRecentTables'] > 0) { $tmp_result = PMA_RecentFavoriteTable::getInstance('recent')->add($db, $table); if ($tmp_result === true) { $retval = PMA_RecentFavoriteTable::getHtmlUpdateRecentTables(); } else { $error = $tmp_result; $retval = $error->getDisplay(); } } return $retval; }
/** * Add or remove favorite tables * * @param string $db current database * * @return void */ function PMA_addRemoveFavoriteTables($db) { $fav_instance = PMA_RecentFavoriteTable::getInstance('favorite'); if (isset($_REQUEST['favorite_tables'])) { $favorite_tables = json_decode($_REQUEST['favorite_tables'], true); } else { $favorite_tables = array(); } // Required to keep each user's preferences separate. $user = sha1($GLOBALS['cfg']['Server']['user']); // Request for Synchronization of favorite tables. if (isset($_REQUEST['sync_favorite_tables'])) { PMA_synchronizeFavoriteTables($fav_instance, $user, $favorite_tables); exit; } $changes = true; $msg = ''; $titles = PMA_Util::buildActionTitles(); $favorite_table = $_REQUEST['favorite_table']; $already_favorite = PMA_checkFavoriteTable($db, $favorite_table); if (isset($_REQUEST['remove_favorite'])) { if ($already_favorite) { // If already in favorite list, remove it. $fav_instance->remove($db, $favorite_table); } } elseif (isset($_REQUEST['add_favorite'])) { if (!$already_favorite) { if (count($fav_instance->getTables()) == $GLOBALS['cfg']['NumFavoriteTables']) { $changes = false; $msg = '<div class="error"><img src="themes/dot.gif" ' . 'title="" alt="" class="icon ic_s_error" />' . __("Favorite List is full!") . '</div>'; } else { // Otherwise add to favorite list. $fav_instance->add($db, $favorite_table); } } } $favorite_tables[$user] = $fav_instance->getTables(); $ajax_response = PMA_Response::getInstance(); $ajax_response->addJSON('changes', $changes); if ($changes) { $ajax_response->addJSON('user', $user); $ajax_response->addJSON('favorite_tables', json_encode($favorite_tables)); $ajax_response->addJSON('list', $fav_instance->getHtmlList()); $ajax_response->addJSON('anchor', PMA_getHtmlForFavoriteAnchor($db, array('TABLE_NAME' => $favorite_table), $titles)); } else { $ajax_response->addJSON('message', $msg); } }
$server_info .= ' ('; } } if ($GLOBALS['cfg']['ShowServerInfo'] || empty($cfg['Server']['verbose'])) { $server_info .= $GLOBALS['dbi']->getHostInfo(); } if (!empty($cfg['Server']['verbose']) && $GLOBALS['cfg']['ShowServerInfo']) { $server_info .= ')'; } $mysql_cur_user_and_host = $GLOBALS['dbi']->fetchValue('SELECT USER();'); // should we add the port info here? $short_server_info = !empty($GLOBALS['cfg']['Server']['verbose']) ? $GLOBALS['cfg']['Server']['verbose'] : $GLOBALS['cfg']['Server']['host']; } echo '<div id="maincontainer">' . "\n"; // Anchor for favorite tables synchronization. echo PMA_RecentFavoriteTable::getInstance('favorite')->getHtmlSyncFavoriteTables(); echo '<div id="main_pane_left">'; if ($server > 0 || count($cfg['Servers']) > 1) { if ($cfg['DBG']['demo']) { echo '<div class="group">'; echo '<h2>' . __('phpMyAdmin Demo Server') . '</h2>'; echo '<p style="margin: 0.5em 1em 0.5em 1em">'; printf(__('You are using the demo server. You can do anything here, but ' . 'please do not change root, debian-sys-maint and pma users. ' . 'More information is available at %s.'), '<a href="http://demo.phpmyadmin.net/">demo.phpmyadmin.net</a>'); echo '</p>'; echo '</div>'; } echo '<div class="group">'; echo '<h2>' . __('General Settings') . '</h2>'; echo '<ul>'; /** * Displays the MySQL servers choice form
/** * Display quick warp links, contain Recents and Favorites * * @return string HTML code */ private function _quickWarp() { $retval = '<div class="pma_quick_warp">'; if ($GLOBALS['cfg']['NumRecentTables'] > 0) { $retval .= PMA_RecentFavoriteTable::getInstance('recent')->getHtml(); } if ($GLOBALS['cfg']['NumFavoriteTables'] > 0) { $retval .= PMA_RecentFavoriteTable::getInstance('favorite')->getHtml(); } $retval .= '<div class="clearfloat"></div>'; $retval .= '</div>'; return $retval; }
/** * Checks and fixes configuration storage in current DB. * * @return void */ function PMA_checkAndFixPMATablesInCurrentDb() { if (isset($GLOBALS['db']) && !empty($GLOBALS['db'])) { if (isset($GLOBALS['cfg']['Server']['pmadb']) && empty($GLOBALS['cfg']['Server']['pmadb'])) { $default_tables = PMA_getDefaultPMATableNames(); if (PMA_searchPMATablesInDb($GLOBALS['db'], array_keys($default_tables))) { PMA_fixPMATables($GLOBALS['db']); // Since configuration storage is updated, we need to // re-initialize the favorite and recent tables stored in the // session from the current configuration storage. include_once 'libraries/RecentFavoriteTable.class.php'; $fav_tables = PMA_RecentFavoriteTable::getInstance('favorite'); $recent_tables = PMA_RecentFavoriteTable::getInstance('recent'); $_SESSION['tmpval']['favorite_tables'][$GLOBALS['server']] = $fav_tables->getFromDb(); $_SESSION['tmpval']['recent_tables'][$GLOBALS['server']] = $recent_tables->getFromDb(); // Reload navi panel to update the recent/favorite lists. $GLOBALS['reload'] = true; } } } }
<?php /* vim: set expandtab sw=4 ts=4 sts=4: */ /** * Browse recent and favourite tables chosen from navigation * * @package PhpMyAdmin */ require_once 'libraries/common.inc.php'; require_once 'libraries/RecentFavoriteTable.class.php'; PMA_RecentFavoriteTable::getInstance('recent')->removeIfInvalid($_REQUEST['db'], $_REQUEST['table']); PMA_RecentFavoriteTable::getInstance('favorite')->removeIfInvalid($_REQUEST['db'], $_REQUEST['table']); require 'sql.php';
$response->addHTML(PMA_URL_getHiddenInputs($db)); $response->addHTML(PMA_tableHeader($db_is_system_schema, $server_slave_status)); $i = $sum_entries = 0; $overhead_check = ''; $create_time_all = ''; $update_time_all = ''; $check_time_all = ''; $num_columns = $cfg['PropertiesNumColumns'] > 1 ? ceil($num_tables / $cfg['PropertiesNumColumns']) + 1 : 0; $row_count = 0; $sum_size = (double) 0; $overhead_size = (double) 0; $hidden_fields = array(); $odd_row = true; $sum_row_count_pre = ''; // Instance of PMA_RecentFavoriteTable class. $fav_instance = PMA_RecentFavoriteTable::getInstance('favorite'); foreach ($tables as $keyname => $current_table) { // Get valid statistics whatever is the table type $drop_query = ''; $drop_message = ''; $already_favorite = false; $overhead = ''; $table_is_view = false; $table_encoded = urlencode($current_table['TABLE_NAME']); // Sets parameters for links $tbl_url_query = $url_query . '&table=' . $table_encoded; // do not list the previous table's size info for a view list($current_table, $formatted_size, $unit, $formatted_overhead, $overhead_unit, $overhead_size, $table_is_view, $sum_size) = PMA_getStuffForEngineTypeTable($current_table, $db_is_system_schema, $is_show_stats, $table_is_view, $sum_size, $overhead_size); if (!PMA_Table::isMerge($db, $current_table['TABLE_NAME'])) { $sum_entries += $current_table['TABLE_ROWS']; }
/** * Add recently used table and reload the navigation. * * @param string $db Database name where the table is located. * @param string $table The table name * * @return string */ private function _addRecentTable($db, $table) { $retval = ''; if ($this->_menuEnabled && strlen($table) && $GLOBALS['cfg']['NumRecentTables'] > 0) { $tmp_result = PMA_RecentFavoriteTable::getInstance('recent')->add($db, $table); if ($tmp_result === true) { $params = array('ajax_request' => true, 'recent_table' => true); $url = 'index.php' . PMA_URL_getCommon($params); $retval = '<a class="hide" id="update_recent_tables"'; $retval .= ' href="' . $url . '"></a>'; } else { $error = $tmp_result; $retval = $error->getDisplay(); } } return $retval; }