/**
  * Test getNaviSettings
  *
  * @return void
  */
 function testGetNaviSettings()
 {
     $html = PageSettings::getNaviSettings();
     // Test some sample parts
     $this->assertContains('<div id="pma_navigation_settings">', $html);
     $this->assertContains('<input type="hidden" name="submit_save" value="Navi_panel" />', $html);
 }
Пример #2
0
 /**
  * Renders the navigation tree, or part of it
  *
  * @return string The navigation tree
  */
 public function getDisplay()
 {
     /* Init */
     $retval = '';
     if (!Response::getInstance()->isAjax()) {
         $header = new NavigationHeader();
         $retval = $header->getDisplay();
     }
     $tree = new NavigationTree();
     if (!Response::getInstance()->isAjax() || !empty($_REQUEST['full']) || !empty($_REQUEST['reload'])) {
         if ($GLOBALS['cfg']['ShowDatabasesNavigationAsTree']) {
             // provide database tree in navigation
             $navRender = $tree->renderState();
         } else {
             // provide legacy pre-4.0 navigation
             $navRender = $tree->renderDbSelect();
         }
     } else {
         $navRender = $tree->renderPath();
     }
     if (!$navRender) {
         $retval .= Message::error(__('An error has occurred while loading the navigation display'))->getDisplay();
     } else {
         $retval .= $navRender;
     }
     if (!Response::getInstance()->isAjax()) {
         // closes the tags that were opened by the navigation header
         $retval .= '</div>';
         // pma_navigation_tree
         $retval .= '<div id="pma_navi_settings_container">';
         if (!defined('PMA_DISABLE_NAVI_SETTINGS')) {
             $retval .= PageSettings::getNaviSettings();
         }
         $retval .= '</div>';
         //pma_navi_settings_container
         $retval .= '</div>';
         // pma_navigation_content
         $retval .= $this->_getDropHandler();
         $retval .= '</div>';
         // pma_navigation
     }
     return $retval;
 }
 /**
  * Index action
  *
  * @return void
  */
 public function indexAction()
 {
     // Add/Remove favorite tables using Ajax request.
     if ($GLOBALS['is_ajax_request'] && !empty($_REQUEST['favorite_table'])) {
         $this->addRemoveFavoriteTablesAction();
         return;
     }
     // If there is an Ajax request for real row count of a table.
     if ($GLOBALS['is_ajax_request'] && isset($_REQUEST['real_row_count']) && $_REQUEST['real_row_count'] == true) {
         $this->handleRealRowCountRequestAction();
         return;
     }
     // Drops/deletes/etc. multiple tables if required
     if (!empty($_POST['submit_mult']) && isset($_POST['selected_tbl']) || isset($_POST['mult_btn'])) {
         $this->multiSubmitAction();
     }
     $this->response->getHeader()->getScripts()->addFiles(array('db_structure.js', 'tbl_change.js', 'jquery/jquery-ui-timepicker-addon.js'));
     $this->_url_query .= '&amp;goto=db_structure.php';
     // Gets the database structure
     $sub_part = '_structure';
     list($tables, $num_tables, $total_num_tables, , $is_show_stats, $db_is_system_schema, , , $pos) = Util::getDbInfo($GLOBALS['db'], $sub_part);
     $this->_tables = $tables;
     // updating $tables seems enough for #11376, but updating other
     // variables too in case they may cause some other problem.
     $this->_num_tables = $num_tables;
     $this->_pos = $pos;
     $this->_db_is_system_schema = $db_is_system_schema;
     $this->_total_num_tables = $total_num_tables;
     $this->_is_show_stats = $is_show_stats;
     include_once 'libraries/replication.inc.php';
     PageSettings::showGroup('DbStructure');
     // 1. No tables
     if ($this->_num_tables == 0) {
         $this->response->addHTML(Message::notice(__('No tables found in database.')));
         if (empty($db_is_system_schema)) {
             $this->response->addHTML(PMA_getHtmlForCreateTable($this->db));
         }
         return;
     }
     // else
     // 2. Shows table information
     /**
      * Displays the tables list
      */
     $this->response->addHTML('<div id="tableslistcontainer">');
     $_url_params = array('pos' => $this->_pos, 'db' => $this->db);
     // Add the sort options if they exists
     if (isset($_REQUEST['sort'])) {
         $_url_params['sort'] = $_REQUEST['sort'];
     }
     if (isset($_REQUEST['sort_order'])) {
         $_url_params['sort_order'] = $_REQUEST['sort_order'];
     }
     $this->response->addHTML(Util::getListNavigator($this->_total_num_tables, $this->_pos, $_url_params, 'db_structure.php', 'frame_content', $GLOBALS['cfg']['MaxTableList']));
     $this->displayTableList();
     // display again the table list navigator
     $this->response->addHTML(Util::getListNavigator($this->_total_num_tables, $this->_pos, $_url_params, 'db_structure.php', 'frame_content', $GLOBALS['cfg']['MaxTableList']));
     $this->response->addHTML('</div><hr />');
     /**
      * Work on the database
      */
     /* DATABASE WORK */
     /* Printable view of a table */
     $this->response->addHTML(Template::get('database/structure/print_view_data_dictionary_link')->render(array('url_query' => $this->_url_query)));
     if (empty($this->_db_is_system_schema)) {
         $this->response->addHTML(PMA_getHtmlForCreateTable($this->db));
     }
 }
Пример #4
0
<?php

/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
 * Server import page
 *
 * @package PhpMyAdmin
 */
use PMA\libraries\config\PageSettings;
use PMA\libraries\Response;
/**
 *
 */
require_once 'libraries/common.inc.php';
require_once 'libraries/config/user_preferences.forms.php';
require_once 'libraries/config/page_settings.forms.php';
PageSettings::showGroup('Import');
$response = PMA\libraries\Response::getInstance();
$header = $response->getHeader();
$scripts = $header->getScripts();
$scripts->addFile('import.js');
/**
 * Does the common work
 */
require 'libraries/server_common.inc.php';
require 'libraries/display_import.lib.php';
$response = Response::getInstance();
$response->addHTML(PMA_getImportDisplay('server', $db, $table, $max_upload_size));
Пример #5
0
/**
 * Displays form for editing and inserting new table rows
 *
 * @package PhpMyAdmin
 */
use PMA\libraries\config\PageSettings;
use PMA\libraries\Response;
use PMA\libraries\Util;
use PMA\libraries\URL;
/**
 * Gets the variables sent or posted to this script and displays the header
 */
require_once 'libraries/common.inc.php';
require_once 'libraries/config/user_preferences.forms.php';
require_once 'libraries/config/page_settings.forms.php';
PageSettings::showGroup('Edit');
/**
 * Ensures db and table are valid, else moves to the "parent" script
 */
require_once 'libraries/db_table_exists.inc.php';
/**
 * functions implementation for this script
 */
require_once 'libraries/insert_edit.lib.php';
require_once 'libraries/transformations.lib.php';
/**
 * Determine whether Insert or Edit and set global variables
 */
list($insert_mode, $where_clause, $where_clause_array, $where_clauses, $result, $rows, $found_unique_key, $after_insert) = PMA_determineInsertOrEdit(isset($where_clause) ? $where_clause : null, $db, $table);
// Increase number of rows if unsaved rows are more
if (!empty($unsaved_values) && count($rows) < count($unsaved_values)) {
Пример #6
0
 *          that returns 0 rows - to prevent cyclic redirects or includes
 * @package PhpMyAdmin
 */
use PMA\libraries\config\PageSettings;
use PMA\libraries\Response;
use PMA\libraries\Util;
use PMA\libraries\URL;
/**
 * Gets some core libraries
 */
require_once 'libraries/common.inc.php';
require_once 'libraries/check_user_privileges.lib.php';
require_once 'libraries/sql.lib.php';
require_once 'libraries/config/user_preferences.forms.php';
require_once 'libraries/config/page_settings.forms.php';
PageSettings::showGroup('Browse');
$response = Response::getInstance();
$header = $response->getHeader();
$scripts = $header->getScripts();
$scripts->addFile('jquery/jquery-ui-timepicker-addon.js');
$scripts->addFile('jquery/jquery.uitablefilter.js');
$scripts->addFile('tbl_change.js');
$scripts->addFile('indexes.js');
$scripts->addFile('gis_data_editor.js');
$scripts->addFile('multi_column_sort.js');
/**
 * Set ajax_reload in the response if it was already set
 */
if (isset($ajax_reload) && $ajax_reload['reload'] === true) {
    $response->addJSON('ajax_reload', $ajax_reload);
}
Пример #7
0
/**
 * object the server export page
 *
 * @package PhpMyAdmin
 */
use PMA\libraries\config\PageSettings;
use PMA\libraries\Response;
/**
 * Does the common work
 */
require_once 'libraries/common.inc.php';
require_once 'libraries/config/user_preferences.forms.php';
require_once 'libraries/config/page_settings.forms.php';
require_once 'libraries/server_common.inc.php';
require_once 'libraries/display_export.lib.php';
PageSettings::showGroup('Export');
$response = Response::getInstance();
$header = $response->getHeader();
$scripts = $header->getScripts();
$scripts->addFile('export.js');
$export_page_title = __('View dump (schema) of databases') . "\n";
$select_item = isset($tmp_select) ? $tmp_select : '';
$multi_values = PMA_getHtmlForExportSelectOptions($select_item);
require_once 'libraries/display_export.lib.php';
if (!isset($sql_query)) {
    $sql_query = '';
}
if (!isset($num_tables)) {
    $num_tables = 0;
}
if (!isset($unlim_num_rows)) {
 /**
  * Index action
  *
  * @return void
  */
 public function indexAction()
 {
     PageSettings::showGroup('TableStructure');
     /**
      * Function implementations for this script
      */
     include_once 'libraries/check_user_privileges.lib.php';
     include_once 'libraries/index.lib.php';
     include_once 'libraries/sql.lib.php';
     include_once 'libraries/bookmark.lib.php';
     $this->response->getHeader()->getScripts()->addFiles(array('tbl_structure.js', 'indexes.js'));
     /**
      * Handle column moving
      */
     if (isset($_REQUEST['move_columns']) && is_array($_REQUEST['move_columns']) && $this->response->isAjax()) {
         $this->moveColumns();
         return;
     }
     /**
      * handle MySQL reserved words columns check
      */
     if (isset($_REQUEST['reserved_word_check'])) {
         if ($GLOBALS['cfg']['ReservedWordDisableWarning'] === false) {
             $columns_names = $_REQUEST['field_name'];
             $reserved_keywords_names = array();
             foreach ($columns_names as $column) {
                 if (SqlParser\Context::isKeyword(trim($column), true)) {
                     $reserved_keywords_names[] = trim($column);
                 }
             }
             if (SqlParser\Context::isKeyword(trim($this->table), true)) {
                 $reserved_keywords_names[] = trim($this->table);
             }
             if (count($reserved_keywords_names) == 0) {
                 $this->response->setRequestStatus(false);
             }
             $this->response->addJSON('message', sprintf(_ngettext('The name \'%s\' is a MySQL reserved keyword.', 'The names \'%s\' are MySQL reserved keywords.', count($reserved_keywords_names)), implode(',', $reserved_keywords_names)));
         } else {
             $this->response->setRequestStatus(false);
         }
         return;
     }
     /**
      * A click on Change has been made for one column
      */
     if (isset($_REQUEST['change_column'])) {
         $this->displayHtmlForColumnChange(null, 'tbl_structure.php');
         return;
     }
     /**
      * Adding or editing partitioning of the table
      */
     if (isset($_REQUEST['edit_partitioning']) && !isset($_REQUEST['save_partitioning'])) {
         $this->displayHtmlForPartitionChange();
         return;
     }
     /**
      * handle multiple field commands if required
      *
      * submit_mult_*_x comes from IE if <input type="img" ...> is used
      */
     $submit_mult = $this->getMultipleFieldCommandType();
     if (!empty($submit_mult)) {
         if (isset($_REQUEST['selected_fld'])) {
             if ($submit_mult == 'browse') {
                 // browsing the table displaying only selected columns
                 $this->displayTableBrowseForSelectedColumns($GLOBALS['goto'], $GLOBALS['pmaThemeImage']);
             } else {
                 // handle multiple field commands
                 // handle confirmation of deleting multiple columns
                 $action = 'tbl_structure.php';
                 $GLOBALS['selected'] = $_REQUEST['selected_fld'];
                 list($what_ret, $query_type_ret, $is_unset_submit_mult, $mult_btn_ret, $centralColsError) = $this->getDataForSubmitMult($submit_mult, $_REQUEST['selected_fld'], $action);
                 //update the existing variables
                 // todo: refactor mult_submits.inc.php such as
                 // below globals are not needed anymore
                 if (isset($what_ret)) {
                     $GLOBALS['what'] = $what_ret;
                     global $what;
                 }
                 if (isset($query_type_ret)) {
                     $GLOBALS['query_type'] = $query_type_ret;
                     global $query_type;
                 }
                 if ($is_unset_submit_mult) {
                     unset($submit_mult);
                 }
                 if (isset($mult_btn_ret)) {
                     $GLOBALS['mult_btn'] = $mult_btn_ret;
                     global $mult_btn;
                 }
                 include 'libraries/mult_submits.inc.php';
                 /**
                  * if $submit_mult == 'change', execution will have stopped
                  * at this point
                  */
                 if (empty($message)) {
                     $message = Message::success();
                 }
                 $this->response->addHTML(Util::getMessage($message, $sql_query));
             }
         } else {
             $this->response->setRequestStatus(false);
             $this->response->addJSON('message', __('No column selected.'));
         }
     }
     // display secondary level tabs if necessary
     $engine = $this->table_obj->getStatusInfo('ENGINE');
     $this->response->addHTML(Template::get('table/secondary_tabs')->render(array('url_params' => array('db' => $this->db, 'table' => $this->table), 'engine' => $engine)));
     $this->response->addHTML('<div id="structure_content">');
     /**
      * Modifications have been submitted -> updates the table
      */
     if (isset($_REQUEST['do_save_data'])) {
         $regenerate = $this->updateColumns();
         if ($regenerate) {
             // This happens when updating failed
             // @todo: do something appropriate
         } else {
             // continue to show the table's structure
             unset($_REQUEST['selected']);
         }
     }
     /**
      * Modifications to the partitioning have been submitted -> updates the table
      */
     if (isset($_REQUEST['save_partitioning'])) {
         $this->updatePartitioning();
     }
     /**
      * Adding indexes
      */
     if (isset($_REQUEST['add_key']) || isset($_REQUEST['partition_maintenance'])) {
         //todo: set some variables for sql.php include, to be eliminated
         //after refactoring sql.php
         $db = $this->db;
         $table = $this->table;
         $cfg = $GLOBALS['cfg'];
         $is_superuser = $GLOBALS['dbi']->isSuperuser();
         $pmaThemeImage = $GLOBALS['pmaThemeImage'];
         include 'sql.php';
         $GLOBALS['reload'] = true;
     }
     /**
      * Gets the relation settings
      */
     $cfgRelation = PMA_getRelationsParam();
     /**
      * Runs common work
      */
     // set db, table references, for require_once that follows
     // got to be eliminated in long run
     $db =& $this->db;
     $table =& $this->table;
     include_once 'libraries/tbl_common.inc.php';
     $this->_db_is_system_schema = $db_is_system_schema;
     $this->_url_query = $url_query . '&amp;goto=tbl_structure.php&amp;back=tbl_structure.php';
     $url_params['goto'] = 'tbl_structure.php';
     $url_params['back'] = 'tbl_structure.php';
     /**
      * Gets tables information
      */
     include_once 'libraries/tbl_info.inc.php';
     // 2. Gets table keys and retains them
     // @todo should be: $server->db($db)->table($table)->primary()
     $primary = Index::getPrimary($this->table, $this->db);
     $columns_with_index = $this->dbi->getTable($this->db, $this->table)->getColumnsWithIndex(Index::UNIQUE | Index::INDEX | Index::SPATIAL | Index::FULLTEXT);
     $columns_with_unique_index = $this->dbi->getTable($this->db, $this->table)->getColumnsWithIndex(Index::UNIQUE);
     // 3. Get fields
     $fields = (array) $this->dbi->getColumns($this->db, $this->table, null, true);
     // Get more complete field information
     // For now, this is done just for MySQL 4.1.2+ new TIMESTAMP options
     // but later, if the analyser returns more information, it
     // could be executed for any MySQL version and replace
     // the info given by SHOW FULL COLUMNS FROM.
     //
     // We also need this to correctly learn if a TIMESTAMP is NOT NULL, since
     // SHOW FULL COLUMNS or INFORMATION_SCHEMA incorrectly says NULL
     // and SHOW CREATE TABLE says NOT NULL (tested
     // in MySQL 4.0.25 and 5.0.21, http://bugs.mysql.com/20910).
     $show_create_table = $this->table_obj->showCreate();
     $parser = new SqlParser\Parser($show_create_table);
     /**
      * @var CreateStatement $stmt
      */
     $stmt = $parser->statements[0];
     $create_table_fields = SqlTable::getFields($stmt);
     //display table structure
     $this->response->addHTML($this->displayStructure($cfgRelation, $columns_with_unique_index, $url_params, $primary, $fields, $columns_with_index, $create_table_fields));
     $this->response->addHTML('</div>');
 }
Пример #9
0
 /**
  * Get HTML for navigation settings
  * @return string
  */
 public static function getNaviSettings()
 {
     $object = new PageSettings('Navi_panel', 'pma_navigation_settings');
     $response = Response::getInstance();
     $response->addHTML($object->getErrorHTML());
     return $object->getHTML();
 }
 /**
  * Index action
  *
  * @return void
  */
 public function indexAction()
 {
     // Add/Remove favorite tables using Ajax request.
     if ($GLOBALS['is_ajax_request'] && !empty($_REQUEST['favorite_table'])) {
         $this->addRemoveFavoriteTablesAction();
         return;
     }
     $this->response->getHeader()->getScripts()->addFiles(array('db_structure.js', 'tbl_change.js', 'jquery/jquery-ui-timepicker-addon.js'));
     // Drops/deletes/etc. multiple tables if required
     if (!empty($_POST['submit_mult']) && isset($_POST['selected_tbl']) || isset($_POST['mult_btn'])) {
         $action = 'db_structure.php';
         $err_url = 'db_structure.php' . PMA_URL_getCommon(array('db' => $this->db));
         // see bug #2794840; in this case, code path is:
         // db_structure.php -> libraries/mult_submits.inc.php -> sql.php
         // -> db_structure.php and if we got an error on the multi submit,
         // we must display it here and not call again mult_submits.inc.php
         if (!isset($_POST['error']) || false === $_POST['error']) {
             include 'libraries/mult_submits.inc.php';
         }
         if (empty($_POST['message'])) {
             $_POST['message'] = Message::success();
         }
     }
     $this->_url_query .= '&amp;goto=db_structure.php';
     // Gets the database structure
     $sub_part = '_structure';
     list($tables, $num_tables, $total_num_tables, , $is_show_stats, $db_is_system_schema, $tooltip_truename, $tooltip_aliasname, $pos) = Util::getDbInfo($GLOBALS['db'], isset($sub_part) ? $sub_part : '');
     $this->_tables = $tables;
     // updating $tables seems enough for #11376, but updating other
     // variables too in case they may cause some other problem.
     $this->_num_tables = $num_tables;
     $this->_pos = $pos;
     $this->_db_is_system_schema = $db_is_system_schema;
     $this->_total_num_tables = $total_num_tables;
     $this->_is_show_stats = $is_show_stats;
     // If there is an Ajax request for real row count of a table.
     if ($GLOBALS['is_ajax_request'] && isset($_REQUEST['real_row_count']) && $_REQUEST['real_row_count'] == true) {
         $this->handleRealRowCountRequestAction();
         return;
     }
     include_once 'libraries/replication.inc.php';
     PageSettings::showGroup('DbStructure');
     $db_collation = PMA_getDbCollation($this->db);
     $titles = Util::buildActionTitles();
     // 1. No tables
     if ($this->_num_tables == 0) {
         $this->response->addHTML(Message::notice(__('No tables found in database.')));
         if (empty($db_is_system_schema)) {
             $this->response->addHTML(PMA_getHtmlForCreateTable($this->db));
         }
         return;
     }
     // else
     // 2. Shows table information
     /**
      * Displays the tables list
      */
     $this->response->addHTML('<div id="tableslistcontainer">');
     $_url_params = array('pos' => $this->_pos, 'db' => $this->db);
     // Add the sort options if they exists
     if (isset($_REQUEST['sort'])) {
         $_url_params['sort'] = $_REQUEST['sort'];
     }
     if (isset($_REQUEST['sort_order'])) {
         $_url_params['sort_order'] = $_REQUEST['sort_order'];
     }
     $this->response->addHTML(Util::getListNavigator($this->_total_num_tables, $this->_pos, $_url_params, 'db_structure.php', 'frame_content', $GLOBALS['cfg']['MaxTableList']));
     // table form
     $this->response->addHTML(Template::get('database/structure/table_header')->render(array('db' => $this->db, 'db_is_system_schema' => $this->_db_is_system_schema, 'replication' => $GLOBALS['replication_info']['slave']['status'])));
     $i = $sum_entries = 0;
     $overhead_check = '';
     $create_time_all = '';
     $update_time_all = '';
     $check_time_all = '';
     $num_columns = $GLOBALS['cfg']['PropertiesNumColumns'] > 1 ? ceil($this->_num_tables / $GLOBALS['cfg']['PropertiesNumColumns']) + 1 : 0;
     $row_count = 0;
     $sum_size = (double) 0;
     $overhead_size = (double) 0;
     $hidden_fields = array();
     $odd_row = true;
     $overall_approx_rows = false;
     // Instance of RecentFavoriteTable class.
     $fav_instance = RecentFavoriteTable::getInstance('favorite');
     foreach ($this->_tables as $keyname => $current_table) {
         // Get valid statistics whatever is the table type
         $drop_query = '';
         $drop_message = '';
         $overhead = '';
         $table_is_view = false;
         $table_encoded = urlencode($current_table['TABLE_NAME']);
         // Sets parameters for links
         $tbl_url_query = $this->_url_query . '&amp;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) = $this->getStuffForEngineTypeTable($current_table, $sum_size, $overhead_size);
         $curTable = $this->dbi->getTable($this->db, $current_table['TABLE_NAME']);
         if (!$curTable->isMerge()) {
             $sum_entries += $current_table['TABLE_ROWS'];
         }
         if (isset($current_table['Collation'])) {
             $collation = '<dfn title="' . PMA_getCollationDescr($current_table['Collation']) . '">' . $current_table['Collation'] . '</dfn>';
         } else {
             $collation = '---';
         }
         if ($this->_is_show_stats) {
             if ($formatted_overhead != '') {
                 $overhead = '<a href="tbl_structure.php' . $tbl_url_query . '#showusage">' . '<span>' . $formatted_overhead . '</span>&nbsp;' . '<span class="unit">' . $overhead_unit . '</span>' . '</a>' . "\n";
                 $overhead_check .= "markAllRows('row_tbl_" . ($i + 1) . "');";
             } else {
                 $overhead = '-';
             }
         }
         // end if
         $showtable = $this->dbi->getTable($this->db, $current_table['TABLE_NAME'])->getStatusInfo(null, true);
         if ($GLOBALS['cfg']['ShowDbStructureCreation']) {
             $create_time = isset($showtable['Create_time']) ? $showtable['Create_time'] : '';
             if ($create_time && (!$create_time_all || $create_time < $create_time_all)) {
                 $create_time_all = $create_time;
             }
         }
         if ($GLOBALS['cfg']['ShowDbStructureLastUpdate']) {
             // $showtable might already be set from ShowDbStructureCreation,
             // see above
             $update_time = isset($showtable['Update_time']) ? $showtable['Update_time'] : '';
             if ($update_time && (!$update_time_all || $update_time < $update_time_all)) {
                 $update_time_all = $update_time;
             }
         }
         if ($GLOBALS['cfg']['ShowDbStructureLastCheck']) {
             // $showtable might already be set from ShowDbStructureCreation,
             // see above
             $check_time = isset($showtable['Check_time']) ? $showtable['Check_time'] : '';
             if ($check_time && (!$check_time_all || $check_time < $check_time_all)) {
                 $check_time_all = $check_time;
             }
         }
         $truename = htmlspecialchars(!empty($tooltip_truename) && isset($tooltip_truename[$current_table['TABLE_NAME']]) ? $tooltip_truename[$current_table['TABLE_NAME']] : $current_table['TABLE_NAME']);
         $truename = str_replace(' ', '&nbsp;', $truename);
         $i++;
         $row_count++;
         if ($table_is_view) {
             $hidden_fields[] = '<input type="hidden" name="views[]" value="' . htmlspecialchars($current_table['TABLE_NAME']) . '" />';
         }
         /*
          * Always activate links for Browse, Search and Empty, even if
          * the icons are greyed, because
          * 1. for views, we don't know the number of rows at this point
          * 2. for tables, another source could have populated them since the
          *    page was generated
          *
          * I could have used the PHP ternary conditional operator but I find
          * the code easier to read without this operator.
          */
         $may_have_rows = $current_table['TABLE_ROWS'] > 0 || $table_is_view;
         $browse_table = Template::get('database/structure/browse_table')->render(array('tbl_url_query' => $tbl_url_query, 'title' => $may_have_rows ? $titles['Browse'] : $titles['NoBrowse']));
         $search_table = Template::get('database/structure/search_table')->render(array('tbl_url_query' => $tbl_url_query, 'title' => $may_have_rows ? $titles['Search'] : $titles['NoSearch']));
         $browse_table_label = Template::get('database/structure/browse_table_label')->render(array('tbl_url_query' => $tbl_url_query, 'title' => htmlspecialchars($current_table['TABLE_COMMENT']), 'truename' => $truename));
         $empty_table = '';
         if (!$this->_db_is_system_schema) {
             $empty_table = '&nbsp;';
             if (!$table_is_view) {
                 $empty_table = Template::get('database/structure/empty_table')->render(array('tbl_url_query' => $tbl_url_query, 'sql_query' => urlencode('TRUNCATE ' . Util::backquote($current_table['TABLE_NAME'])), 'message_to_show' => urlencode(sprintf(__('Table %s has been emptied.'), htmlspecialchars($current_table['TABLE_NAME']))), 'title' => $may_have_rows ? $titles['Empty'] : $titles['NoEmpty']));
             }
             $drop_query = sprintf('DROP %s %s', $table_is_view || $current_table['ENGINE'] == null ? 'VIEW' : 'TABLE', Util::backquote($current_table['TABLE_NAME']));
             $drop_message = sprintf($table_is_view || $current_table['ENGINE'] == null ? __('View %s has been dropped.') : __('Table %s has been dropped.'), str_replace(' ', '&nbsp;', htmlspecialchars($current_table['TABLE_NAME'])));
         }
         $tracking_icon = '';
         if (Tracker::isActive()) {
             $is_tracked = Tracker::isTracked($GLOBALS["db"], $truename);
             if ($is_tracked || Tracker::getVersion($GLOBALS["db"], $truename) > 0) {
                 $tracking_icon = Template::get('database/structure/tracking_icon')->render(array('url_query' => $this->_url_query, 'truename' => $truename, 'is_tracked' => $is_tracked));
             }
         }
         if ($num_columns > 0 && $this->_num_tables > $num_columns && $row_count % $num_columns == 0) {
             $row_count = 1;
             $odd_row = true;
             $this->response->addHTML('</tr></tbody></table>');
             $this->response->addHTML(Template::get('database/structure/table_header')->render(array('db' => $this->db, 'db_is_system_schema' => $this->_db_is_system_schema, 'replication' => $GLOBALS['replication_info']['slave']['status'])));
         }
         $do = $ignored = false;
         if ($GLOBALS['replication_info']['slave']['status']) {
             $nbServSlaveDoDb = count($GLOBALS['replication_info']['slave']['Do_DB']);
             $nbServSlaveIgnoreDb = count($GLOBALS['replication_info']['slave']['Ignore_DB']);
             $searchDoDBInTruename = array_search($truename, $GLOBALS['replication_info']['slave']['Do_DB']);
             $searchDoDBInDB = array_search($this->db, $GLOBALS['replication_info']['slave']['Do_DB']);
             $do = strlen($searchDoDBInTruename) > 0 || strlen($searchDoDBInDB) > 0 || $nbServSlaveDoDb == 1 && $nbServSlaveIgnoreDb == 1 || $this->hasTable($GLOBALS['replication_info']['slave']['Wild_Do_Table'], $truename);
             $searchDb = array_search($this->db, $GLOBALS['replication_info']['slave']['Ignore_DB']);
             $searchTable = array_search($truename, $GLOBALS['replication_info']['slave']['Ignore_Table']);
             $ignored = strlen($searchTable) > 0 || strlen($searchDb) > 0 || $this->hasTable($GLOBALS['replication_info']['slave']['Wild_Ignore_Table'], $truename);
         }
         // Handle favorite table list. ----START----
         $already_favorite = $this->checkFavoriteTable($current_table['TABLE_NAME']);
         if (isset($_REQUEST['remove_favorite'])) {
             if ($already_favorite) {
                 // If already in favorite list, remove it.
                 $favorite_table = $_REQUEST['favorite_table'];
                 $fav_instance->remove($this->db, $favorite_table);
             }
         }
         if (isset($_REQUEST['add_favorite'])) {
             if (!$already_favorite) {
                 // Otherwise add to favorite list.
                 $favorite_table = $_REQUEST['favorite_table'];
                 $fav_instance->add($this->db, $favorite_table);
             }
         }
         // Handle favorite table list. ----ENDS----
         $show_superscript = '';
         // there is a null value in the ENGINE
         // - when the table needs to be repaired, or
         // - when it's a view
         //  so ensure that we'll display "in use" below for a table
         //  that needs to be repaired
         $approx_rows = false;
         if (isset($current_table['TABLE_ROWS']) && ($current_table['ENGINE'] != null || $table_is_view)) {
             // InnoDB table: we did not get an accurate row count
             $approx_rows = !$table_is_view && $current_table['ENGINE'] == 'InnoDB' && !$current_table['COUNTED'];
         }
         $this->response->addHTML(Template::get('database/structure/structure_table_row')->render(array('db' => $this->db, 'curr' => $i, 'odd_row' => $odd_row, 'table_is_view' => $table_is_view, 'current_table' => $current_table, 'browse_table_label' => $browse_table_label, 'tracking_icon' => $tracking_icon, 'server_slave_status' => $GLOBALS['replication_info']['slave']['status'], 'browse_table' => $browse_table, 'tbl_url_query' => $tbl_url_query, 'search_table' => $search_table, 'db_is_system_schema' => $this->_db_is_system_schema, 'titles' => $titles, 'empty_table' => $empty_table, 'drop_query' => $drop_query, 'drop_message' => $drop_message, 'collation' => $collation, 'formatted_size' => $formatted_size, 'unit' => $unit, 'overhead' => $overhead, 'create_time' => isset($create_time) ? $create_time : '', 'update_time' => isset($update_time) ? $update_time : '', 'check_time' => isset($check_time) ? $check_time : '', 'is_show_stats' => $this->_is_show_stats, 'ignored' => $ignored, 'do' => $do, 'colspan_for_structure' => $GLOBALS['colspan_for_structure'], 'approx_rows' => $approx_rows, 'show_superscript' => $show_superscript, 'already_favorite' => $this->checkFavoriteTable($current_table['TABLE_NAME']))));
         $odd_row = !$odd_row;
         $overall_approx_rows = $overall_approx_rows || $approx_rows;
     }
     // end foreach
     // Show Summary
     $this->response->addHTML('</tbody>');
     $this->response->addHTML(Template::get('database/structure/body_for_table_summary')->render(array('num_tables' => $this->_num_tables, 'server_slave_status' => $GLOBALS['replication_info']['slave']['status'], 'db_is_system_schema' => $this->_db_is_system_schema, 'sum_entries' => $sum_entries, 'db_collation' => $db_collation, 'is_show_stats' => $this->_is_show_stats, 'sum_size' => $sum_size, 'overhead_size' => $overhead_size, 'create_time_all' => $create_time_all, 'update_time_all' => $update_time_all, 'check_time_all' => $check_time_all, 'approx_rows' => $overall_approx_rows)));
     $this->response->addHTML('</table>');
     //check all
     $this->response->addHTML(Template::get('database/structure/check_all_tables')->render(array('pmaThemeImage' => $GLOBALS['pmaThemeImage'], 'text_dir' => $GLOBALS['text_dir'], 'overhead_check' => $overhead_check, 'db_is_system_schema' => $this->_db_is_system_schema, 'hidden_fields' => $hidden_fields)));
     $this->response->addHTML('</form>');
     //end of form
     // display again the table list navigator
     $this->response->addHTML(Util::getListNavigator($this->_total_num_tables, $this->_pos, $_url_params, 'db_structure.php', 'frame_content', $GLOBALS['cfg']['MaxTableList']));
     $this->response->addHTML('</div><hr />');
     /**
      * Work on the database
      */
     /* DATABASE WORK */
     /* Printable view of a table */
     $this->response->addHTML(Template::get('database/structure/print_view_data_dictionary_link')->render(array('url_query' => $this->_url_query)));
     if (empty($db_is_system_schema)) {
         $this->response->addHTML(PMA_getHtmlForCreateTable($this->db));
     }
 }
Пример #11
0
<?php

/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
 * Database SQL executor
 *
 * @package PhpMyAdmin
 */
use PMA\libraries\config\PageSettings;
/**
 *
 */
require_once 'libraries/common.inc.php';
require_once 'libraries/config/user_preferences.forms.php';
require_once 'libraries/config/page_settings.forms.php';
PageSettings::showGroup('Sql_queries');
/**
 * Runs common work
 */
$response = PMA\libraries\Response::getInstance();
$header = $response->getHeader();
$scripts = $header->getScripts();
$scripts->addFile('makegrid.js');
$scripts->addFile('jquery/jquery.uitablefilter.js');
$scripts->addFile('sql.js');
require 'libraries/db_common.inc.php';
require_once 'libraries/sql_query_form.lib.php';
// After a syntax error, we return to this script
// with the typed query in the textarea.
$goto = 'db_sql.php';
$back = 'db_sql.php';
 *
 * @package PhpMyAdmin-Navigation
 */
// Include common functionalities
use PMA\libraries\config\PageSettings;
use PMA\libraries\navigation\Navigation;
require_once './libraries/common.inc.php';
// Also initialises the collapsible tree class
$response = PMA\libraries\Response::getInstance();
$navigation = new Navigation();
if (!$response->isAjax()) {
    $response->addHTML(PMA\libraries\Message::error(__('Fatal error: The navigation can only be accessed via AJAX')));
    exit;
}
if (isset($_REQUEST['getNaviSettings']) && $_REQUEST['getNaviSettings']) {
    $response->addJSON('message', PageSettings::getNaviSettings());
    exit;
}
$cfgRelation = PMA_getRelationsParam();
if ($cfgRelation['navwork']) {
    if (isset($_REQUEST['hideNavItem'])) {
        if (!empty($_REQUEST['itemName']) && !empty($_REQUEST['itemType']) && !empty($_REQUEST['dbName'])) {
            $navigation->hideNavigationItem($_REQUEST['itemName'], $_REQUEST['itemType'], $_REQUEST['dbName'], !empty($_REQUEST['tableName']) ? $_REQUEST['tableName'] : null);
        }
        exit;
    }
    if (isset($_REQUEST['unhideNavItem'])) {
        if (!empty($_REQUEST['itemName']) && !empty($_REQUEST['itemType']) && !empty($_REQUEST['dbName'])) {
            $navigation->unhideNavigationItem($_REQUEST['itemName'], $_REQUEST['itemType'], $_REQUEST['dbName'], !empty($_REQUEST['tableName']) ? $_REQUEST['tableName'] : null);
        }
        exit;