From 7e5fddf4ae2893cc08428b3c3f37241ff85d2457 Mon Sep 17 00:00:00 2001 From: Aris Feryanto Date: Mon, 20 Jun 2011 13:21:07 +0700 Subject: [PATCH 1/5] Recent table: Add support for browser without javascript --- index.php | 2 +- libraries/RecentTable.class.php | 4 ++-- libraries/common.inc.php | 19 +++++++++++++++---- navigation.php | 12 +++++++++--- 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/index.php b/index.php index 36a611878e..070099b069 100644 --- a/index.php +++ b/index.php @@ -73,7 +73,7 @@ if (! strlen($GLOBALS['db'])) { } else { $_GET['db'] = $GLOBALS['db']; $_GET['table'] = $GLOBALS['table']; - $main_target = $GLOBALS['cfg']['DefaultTabTable']; + $main_target = isset($GLOBALS['goto']) ? $GLOBALS['goto'] : $GLOBALS['cfg']['DefaultTabTable']; } $url_query = PMA_generate_common_url($_GET); diff --git a/libraries/RecentTable.class.php b/libraries/RecentTable.class.php index b42a0aa832..9f1b3a6dd1 100644 --- a/libraries/RecentTable.class.php +++ b/libraries/RecentTable.class.php @@ -163,9 +163,9 @@ class PMA_RecentTable */ public function getHtmlSelect() { - $html = ''; - $html .= ''; $html .= $this->getHtmlSelectOption(); $html .= ''; diff --git a/libraries/common.inc.php b/libraries/common.inc.php index 5be5c76f48..2aa12582aa 100644 --- a/libraries/common.inc.php +++ b/libraries/common.inc.php @@ -508,10 +508,21 @@ if (PMA_isValid($_REQUEST['db'])) { */ $GLOBALS['table'] = ''; if (PMA_isValid($_REQUEST['table'])) { - // can we strip tags from this? - // only \ and / is not allowed in table names for MySQL - $GLOBALS['table'] = $_REQUEST['table']; - $GLOBALS['url_params']['table'] = $GLOBALS['table']; + // check if specified table contain db name + if (strpos($_REQUEST['table'], '.')) { + $splitted = explode('.', $_REQUEST['table']); + if (count($splitted) == 2) { // make sure the format is "db.table" + $GLOBALS['db'] = $splitted[0]; + $GLOBALS['url_params']['db'] = $GLOBALS['db']; + $GLOBALS['table'] = $splitted[1]; + $GLOBALS['url_params']['table'] = $GLOBALS['table']; + } + } else { + // can we strip tags from this? + // only \ and / is not allowed in table names for MySQL + $GLOBALS['table'] = $_REQUEST['table']; + $GLOBALS['url_params']['table'] = $GLOBALS['table']; + } } /** diff --git a/navigation.php b/navigation.php index af3f138bd3..b63f775053 100644 --- a/navigation.php +++ b/navigation.php @@ -194,9 +194,15 @@ require './libraries/navigation_header.inc.php'; // display recently used tables if ($GLOBALS['cfg']['LeftRecentTable'] > 0) { - echo '
'; - echo PMA_RecentTable::getInstance()->getHtmlSelect(); - echo '
'; + echo '
' . "\n" + .'
' . "\n" + .PMA_generate_common_hidden_inputs() . "\n" + .PMA_RecentTable::getInstance()->getHtmlSelect() + .'' . "\n" + .'
' . "\n" + .'
' . "\n"; } if (! $GLOBALS['server']) { From 6e65d3d7fc04653be59e133acfe5f10f5eb6cbc5 Mon Sep 17 00:00:00 2001 From: Aris Feryanto Date: Tue, 21 Jun 2011 10:54:48 +0700 Subject: [PATCH 2/5] Fix bug: Recent tables list doesn't honor current server --- libraries/RecentTable.class.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libraries/RecentTable.class.php b/libraries/RecentTable.class.php index 9f1b3a6dd1..6bdc7f0e83 100644 --- a/libraries/RecentTable.class.php +++ b/libraries/RecentTable.class.php @@ -46,11 +46,14 @@ class PMA_RecentTable $this->pma_table = PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) .".". PMA_backquote($GLOBALS['cfg']['Server']['recent']); } - if (! isset($_SESSION['tmp_user_values']['recent_tables'])) { - $_SESSION['tmp_user_values']['recent_tables'] = + $host = $GLOBALS['cfg']['Server']['host'] . + (empty($GLOBALS['cfg']['Server']['port']) ? + '' : ':' . $GLOBALS['cfg']['Server']['port']); + if (! isset($_SESSION['tmp_user_values']['recent_tables'][$host])) { + $_SESSION['tmp_user_values']['recent_tables'][$host] = isset($this->pma_table) ? $this->getFromDb() : array(); } - $this->tables =& $_SESSION['tmp_user_values']['recent_tables']; + $this->tables =& $_SESSION['tmp_user_values']['recent_tables'][$host]; } /** From 21b84f5c882cc1ac267d380f042218f184ce1781 Mon Sep 17 00:00:00 2001 From: Aris Feryanto Date: Tue, 21 Jun 2011 11:43:32 +0700 Subject: [PATCH 3/5] Recent tables: better checking of different server --- libraries/RecentTable.class.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/libraries/RecentTable.class.php b/libraries/RecentTable.class.php index 6bdc7f0e83..4e5bd27bff 100644 --- a/libraries/RecentTable.class.php +++ b/libraries/RecentTable.class.php @@ -46,14 +46,12 @@ class PMA_RecentTable $this->pma_table = PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) .".". PMA_backquote($GLOBALS['cfg']['Server']['recent']); } - $host = $GLOBALS['cfg']['Server']['host'] . - (empty($GLOBALS['cfg']['Server']['port']) ? - '' : ':' . $GLOBALS['cfg']['Server']['port']); - if (! isset($_SESSION['tmp_user_values']['recent_tables'][$host])) { - $_SESSION['tmp_user_values']['recent_tables'][$host] = + $server_id = $GLOBALS['server']; + if (! isset($_SESSION['tmp_user_values']['recent_tables'][$server_id])) { + $_SESSION['tmp_user_values']['recent_tables'][$server_id] = isset($this->pma_table) ? $this->getFromDb() : array(); } - $this->tables =& $_SESSION['tmp_user_values']['recent_tables'][$host]; + $this->tables =& $_SESSION['tmp_user_values']['recent_tables'][$server_id]; } /** From 24a257ffcea338546613bc60c6c0b6f98c99389e Mon Sep 17 00:00:00 2001 From: Aris Feryanto Date: Tue, 21 Jun 2011 12:25:31 +0700 Subject: [PATCH 4/5] Column reordering: add checking for different server --- js/makegrid.js | 1 + libraries/Table.class.php | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/js/makegrid.js b/js/makegrid.js index 80a62adf1c..6e16db9bee 100644 --- a/js/makegrid.js +++ b/js/makegrid.js @@ -314,6 +314,7 @@ db: window.parent.db, table: window.parent.table, token: window.parent.token, + server: window.parent.server, set_col_order: true, col_order: this.colOrder.toString(), table_create_time: this.tableCreateTime diff --git a/libraries/Table.class.php b/libraries/Table.class.php index cfc28d6ee5..cec5b66772 100644 --- a/libraries/Table.class.php +++ b/libraries/Table.class.php @@ -1286,15 +1286,16 @@ class PMA_Table */ protected function loadUiPrefs() { + $server_id = $GLOBALS['server']; // set session variable if it's still undefined - if (! isset($_SESSION['tmp_user_values']['table_uiprefs'][$this->db_name][$this->name])) { - $_SESSION['tmp_user_values']['table_uiprefs'][$this->db_name][$this->name] = + if (! isset($_SESSION['tmp_user_values']['table_uiprefs'][$server_id][$this->db_name][$this->name])) { + $_SESSION['tmp_user_values']['table_uiprefs'][$server_id][$this->db_name][$this->name] = // check whether we can get from pmadb (strlen($GLOBALS['cfg']['Server']['pmadb']) && strlen($GLOBALS['cfg']['Server']['table_uiprefs'])) ? $this->getUiPrefsFromDb() : array(); } - $this->uiprefs =& $_SESSION['tmp_user_values']['table_uiprefs'][$this->db_name][$this->name]; + $this->uiprefs =& $_SESSION['tmp_user_values']['table_uiprefs'][$server_id][$this->db_name][$this->name]; } /** From c5d1aae6f6565a69b65546ceab6113ede41c61da Mon Sep 17 00:00:00 2001 From: Aris Feryanto Date: Tue, 21 Jun 2011 12:37:20 +0700 Subject: [PATCH 5/5] Column reordering: better placement of code for displaying remembered column order --- libraries/display_tbl.lib.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php index 84e6f7ba9c..137d6f87dd 100644 --- a/libraries/display_tbl.lib.php +++ b/libraries/display_tbl.lib.php @@ -1180,6 +1180,14 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) { // name of the class added to all inline editable elements $inline_edit_class = 'inline_edit'; + // prepare to get the column order, if available + if (PMA_isSelect()) { + $pmatable = new PMA_Table($GLOBALS['table'], $GLOBALS['db']); + $col_order = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_ORDER); + } else { + $col_order = false; + } + // Correction University of Virginia 19991216 in the while below // Previous code assumed that all tables have keys, specifically that // the phpMyAdmin GUI should support row delete/edit only for such @@ -1341,14 +1349,6 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) { // 2. Displays the rows' values - if (PMA_isSelect()) { - // prepare to get the column order, if available - $pmatable = new PMA_Table($GLOBALS['table'], $GLOBALS['db']); - $col_order = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_ORDER); - } else { - $col_order = false; - } - for ($j = 0; $j < $fields_cnt; ++$j) { // assign $i with appropriate column order $i = $col_order ? $col_order[$j] : $j;