From 450322c7dbc2afc02349af68f21f9465b3b97e62 Mon Sep 17 00:00:00 2001 From: hastenax Date: Thu, 2 Aug 2012 16:23:41 +0400 Subject: [PATCH 01/45] Update libraries/CommonFunctions.class.php added new function backquote_compat for improved mssql export support --- libraries/CommonFunctions.class.php | 51 +++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/libraries/CommonFunctions.class.php b/libraries/CommonFunctions.class.php index de5a172d42..2412fa7457 100644 --- a/libraries/CommonFunctions.class.php +++ b/libraries/CommonFunctions.class.php @@ -971,6 +971,57 @@ class PMA_CommonFunctions } // end of the 'backquote()' function + /** + * Adds quotes on both sides of a database, table or field name. + * in compatibility mode + * + * example: + * + * echo backquote('owner`s db'); // `owner``s db` + * + * + * + * @param mixed $a_name the database, table or field name to "backquote" + * or array of it + * @param boolean $do_it a flag to bypass this function (used by dump + * functions) + * + * @return mixed the "backquoted" database, table or field name + * + * @access public + */ + public function backquote_compat($a_name, $do_it = true) + { + + if (is_array($a_name)) { + foreach ($a_name as &$data) { + $data = $this->backquote_compat($data, $do_it); + } + return $a_name; + } + + if (! $do_it) { + global $PMA_SQPdata_forbidden_word; + + if (! in_array(strtoupper($a_name), $PMA_SQPdata_forbidden_word)) { + return $a_name; + } + } + + // @todo add more compatibility cases (ORACLE for example) + switch ($GLOBALS['sql_compatibility']) { + case 'MSSQL': $quote = '"'; break; + default: (isset($GLOBALS['sql_backquotes'])) ? $quote = "`" : $quote = ''; break; + } + + // '0' is also empty for php :-( + if (strlen($a_name) && $a_name !== '*') { + return $quote . $a_name . $quote; + } else { + return $a_name; + } + + } // end of the 'backquote_compat()' function /** * Defines the value depending on the user OS. From 0d1cd54dcce003cb2fac1c666fa1ee7c1cad0791 Mon Sep 17 00:00:00 2001 From: hastenax Date: Thu, 2 Aug 2012 16:28:26 +0400 Subject: [PATCH 02/45] Update libraries/plugins/export/ExportSql.class.php Extended MSSQL compatibility exporting mode. --- libraries/plugins/export/ExportSql.class.php | 73 +++++++++++++++----- 1 file changed, 54 insertions(+), 19 deletions(-) diff --git a/libraries/plugins/export/ExportSql.class.php b/libraries/plugins/export/ExportSql.class.php index 9a0a38add6..3f7b3e3820 100644 --- a/libraries/plugins/export/ExportSql.class.php +++ b/libraries/plugins/export/ExportSql.class.php @@ -698,7 +698,7 @@ class ExportSql extends ExportPlugin if (! PMA_exportOutputHandler( 'DROP DATABASE ' . (isset($GLOBALS['sql_backquotes']) - ? $common_functions->backquote($db) : $db) + ? $common_functions->backquote_compat($db) : $db) . ';' . $crlf )) { return false; @@ -706,7 +706,7 @@ class ExportSql extends ExportPlugin } $create_query = 'CREATE DATABASE ' . (isset($GLOBALS['sql_backquotes']) - ? $common_functions->backquote($db) : $db); + ? $common_functions->backquote_compat($db) : $db); $collation = PMA_getDbCollation($db); if (PMA_DRIZZLE) { $create_query .= ' COLLATE ' . $collation; @@ -729,7 +729,7 @@ class ExportSql extends ExportPlugin || PMA_DRIZZLE) ) { $result = PMA_exportOutputHandler( - 'USE ' . $common_functions->backquote($db) . ';' . $crlf + 'USE ' . $common_functions->backquote_compat($db) . ';' . $crlf ); } else { $result = PMA_exportOutputHandler('USE ' . $db . ';' . $crlf); @@ -751,7 +751,7 @@ class ExportSql extends ExportPlugin . $this->_exportComment( __('Database') . ': ' . (isset($GLOBALS['sql_backquotes']) - ? PMA_CommonFunctions::getInstance()->backquote($db) + ? PMA_CommonFunctions::getInstance()->backquote_compat($db) : '\'' . $db . '\'') ) . $this->_exportComment(); @@ -892,6 +892,8 @@ class ExportSql extends ExportPlugin $schema_create = ''; $auto_increment = ''; $new_crlf = $crlf; + + $compat = (isset($GLOBALS['sql_compatibility'])) ? $GLOBALS['sql_compatibility'] : 'NONE'; // need to use PMA_DBI_QUERY_STORE with PMA_DBI_num_rows() in mysqli $result = PMA_DBI_query( @@ -1040,13 +1042,28 @@ class ExportSql extends ExportPlugin } // Should we use IF NOT EXISTS? - if (isset($GLOBALS['sql_if_not_exists'])) { + // It always must be OFF for MSSQL compatibility mode + if (isset($GLOBALS['sql_if_not_exists']) && $compat != 'MSSQL') { $create_query = preg_replace( '/^CREATE TABLE/', 'CREATE TABLE IF NOT EXISTS', $create_query ); } + + // In MSSQL + // 1. DATE field doesn't exist, we will use datetime instead + // 2. UNSIGNED attribute doesn't exist + // 3. No length on int fields + if ($compat == 'MSSQL') { + $create_query = str_ireplace(' date ', ' datetime ', $create_query); + $create_query = str_ireplace(' unsigned ', ' ', $create_query); + $create_query = preg_replace( + '/ int\([0-9]*\) /', + ' int ', + $create_query + ); + } // Drizzle (checked on 2011.03.13) returns ROW_FORMAT surrounded // with quotes, which is not accepted by parser @@ -1107,19 +1124,19 @@ class ExportSql extends ExportPlugin . $this->_exportComment( __('Constraints for table') . ' ' - . $common_functions->backquote($table) + . $common_functions->backquote_compat($table) ) . $this->_exportComment(); } // let's do the work $sql_constraints_query .= 'ALTER TABLE ' - . $common_functions->backquote($table) . $crlf; + . $common_functions->backquote_compat($table) . $crlf; $sql_constraints .= 'ALTER TABLE ' - . $common_functions->backquote($table) . $crlf; + . $common_functions->backquote_compat($table) . $crlf; $sql_drop_foreign_keys .= 'ALTER TABLE ' - . $common_functions->backquote($db) . '.' - . $common_functions->backquote($table) . $crlf; + . $common_functions->backquote_compat($db) . '.' + . $common_functions->backquote_compat($table) . $crlf; $first = true; for ($j = $i; $j < $sql_count; $j++) { @@ -1190,7 +1207,7 @@ class ExportSql extends ExportPlugin $schema_create ); - $schema_create .= $auto_increment; + $schema_create .= ($compat != 'MSSQL') ? $auto_increment : ''; PMA_DBI_free_result($result); return $schema_create . ($add_semicolon ? ';' . $crlf : ''); @@ -1337,7 +1354,7 @@ class ExportSql extends ExportPlugin $common_functions = PMA_CommonFunctions::getInstance(); $formatted_table_name = (isset($GLOBALS['sql_backquotes'])) - ? $common_functions->backquote($table) : '\'' . $table . '\''; + ? $common_functions->backquote_compat($table) : '\'' . $table . '\''; $dump = $this->_possibleCRLF() . $this->_exportComment(str_repeat('-', 56)) . $this->_possibleCRLF() @@ -1422,7 +1439,7 @@ class ExportSql extends ExportPlugin $common_functions = PMA_CommonFunctions::getInstance(); $formatted_table_name = (isset($GLOBALS['sql_backquotes'])) - ? $common_functions->backquote($table) + ? $common_functions->backquote_compat($table) : '\'' . $table . '\''; // Do not export data for a VIEW @@ -1469,12 +1486,12 @@ class ExportSql extends ExportPlugin for ($j = 0; $j < $fields_cnt; $j++) { if (isset($analyzed_sql[0]['select_expr'][$j]['column'])) { - $field_set[$j] = $common_functions->backquote( + $field_set[$j] = $common_functions->backquote_compat( $analyzed_sql[0]['select_expr'][$j]['column'], $sql_backquotes ); } else { - $field_set[$j] = $common_functions->backquote( + $field_set[$j] = $common_functions->backquote_compat( $fields_meta[$j]->name, $sql_backquotes ); @@ -1490,7 +1507,7 @@ class ExportSql extends ExportPlugin $schema_insert .= 'IGNORE '; } // avoid EOL blank - $schema_insert .= $common_functions->backquote( + $schema_insert .= $common_functions->backquote_compat( $table, $sql_backquotes ) . ' SET'; @@ -1524,7 +1541,7 @@ class ExportSql extends ExportPlugin && $sql_command == 'INSERT' ) { $truncate = 'TRUNCATE TABLE ' - . $common_functions->backquote( + . $common_functions->backquote_compat( $table, $sql_backquotes ) . ";"; @@ -1541,18 +1558,25 @@ class ExportSql extends ExportPlugin } else { $truncate = ''; } + + // We need to SET IDENTITY_INSERT ON for MSSQL + if (isset($GLOBALS['sql_compatibility']) + && $GLOBALS['sql_compatibility'] == 'MSSQL') { + $sql_command = 'SET IDENTITY_INSERT '. $common_functions->backquote_compat($table). ' ON ;'.$crlf.$sql_command; + } + // scheme for inserting fields if ($GLOBALS['sql_insert_syntax'] == 'complete' || $GLOBALS['sql_insert_syntax'] == 'both' ) { $fields = implode(', ', $field_set); $schema_insert = $sql_command . $insert_delayed .' INTO ' - . $common_functions->backquote($table, $sql_backquotes) + . $common_functions->backquote_compat($table, $sql_backquotes) // avoid EOL blank . ' (' . $fields . ') VALUES'; } else { $schema_insert = $sql_command . $insert_delayed .' INTO ' - . $common_functions->backquote($table, $sql_backquotes) + . $common_functions->backquote_compat($table, $sql_backquotes) . ' VALUES'; } } @@ -1707,11 +1731,22 @@ class ExportSql extends ExportPlugin } } // end while + if ($current_row > 0) { if (! PMA_exportOutputHandler(';' . $crlf)) { return false; } } + + // We need to SET IDENTITY_INSERT ON for MSSQL + if (isset($GLOBALS['sql_compatibility']) + && $GLOBALS['sql_compatibility'] == 'MSSQL') + if (! PMA_exportOutputHandler( + $crlf . 'SET IDENTITY_INSERT ' . $common_functions->backquote_compat($table) . ' OFF;' . $crlf + )) { + return false; + } + } // end if ($result != false) PMA_DBI_free_result($result); From b210f1339ea8c1fa6b8a506b78b32a3c149000d1 Mon Sep 17 00:00:00 2001 From: hastenax Date: Thu, 2 Aug 2012 16:31:01 +0400 Subject: [PATCH 03/45] Update libraries/plugins/export/ExportSql.class.php Extended MSSQL compatibility features. --- libraries/plugins/export/ExportSql.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/plugins/export/ExportSql.class.php b/libraries/plugins/export/ExportSql.class.php index 3f7b3e3820..5a68594923 100644 --- a/libraries/plugins/export/ExportSql.class.php +++ b/libraries/plugins/export/ExportSql.class.php @@ -1738,7 +1738,7 @@ class ExportSql extends ExportPlugin } } - // We need to SET IDENTITY_INSERT ON for MSSQL + // We need to SET IDENTITY_INSERT OFF for MSSQL if (isset($GLOBALS['sql_compatibility']) && $GLOBALS['sql_compatibility'] == 'MSSQL') if (! PMA_exportOutputHandler( From 335218a8bc2e37bb18b687867228ff3722a25e83 Mon Sep 17 00:00:00 2001 From: hastenax Date: Thu, 2 Aug 2012 16:49:23 +0400 Subject: [PATCH 04/45] Update libraries/CommonFunctions.class.php Misprint correction. --- libraries/CommonFunctions.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/CommonFunctions.class.php b/libraries/CommonFunctions.class.php index 2412fa7457..bd982b066a 100644 --- a/libraries/CommonFunctions.class.php +++ b/libraries/CommonFunctions.class.php @@ -977,7 +977,7 @@ class PMA_CommonFunctions * * example: * - * echo backquote('owner`s db'); // `owner``s db` + * echo backquote_compat('owner`s db'); // `owner``s db` * * * From a54bee033d5dd5c392579aa145970b65c6a4be3c Mon Sep 17 00:00:00 2001 From: hastenax Date: Thu, 2 Aug 2012 17:25:05 +0400 Subject: [PATCH 05/45] Update libraries/plugins/export/ExportSql.class.php Rewrited for new method backqoute_compat with SQL $compatibility param. --- libraries/plugins/export/ExportSql.class.php | 54 +++++++++++--------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/libraries/plugins/export/ExportSql.class.php b/libraries/plugins/export/ExportSql.class.php index 5a68594923..de1f456b8e 100644 --- a/libraries/plugins/export/ExportSql.class.php +++ b/libraries/plugins/export/ExportSql.class.php @@ -693,12 +693,12 @@ class ExportSql extends ExportPlugin global $crlf; $common_functions = PMA_CommonFunctions::getInstance(); - + $compat = (isset($GLOBALS['sql_compatibility'])) ? $GLOBALS['sql_compatibility'] : 'NONE'; if (isset($GLOBALS['sql_drop_database'])) { if (! PMA_exportOutputHandler( 'DROP DATABASE ' . (isset($GLOBALS['sql_backquotes']) - ? $common_functions->backquote_compat($db) : $db) + ? $common_functions->backquote_compat($db, true, $compat) : $db) . ';' . $crlf )) { return false; @@ -706,7 +706,7 @@ class ExportSql extends ExportPlugin } $create_query = 'CREATE DATABASE ' . (isset($GLOBALS['sql_backquotes']) - ? $common_functions->backquote_compat($db) : $db); + ? $common_functions->backquote_compat($db, true, $compat) : $db); $collation = PMA_getDbCollation($db); if (PMA_DRIZZLE) { $create_query .= ' COLLATE ' . $collation; @@ -729,7 +729,7 @@ class ExportSql extends ExportPlugin || PMA_DRIZZLE) ) { $result = PMA_exportOutputHandler( - 'USE ' . $common_functions->backquote_compat($db) . ';' . $crlf + 'USE ' . $common_functions->backquote_compat($db, true, $compat) . ';' . $crlf ); } else { $result = PMA_exportOutputHandler('USE ' . $db . ';' . $crlf); @@ -747,11 +747,12 @@ class ExportSql extends ExportPlugin */ public function exportDBHeader($db) { + $compat = (isset($GLOBALS['sql_compatibility'])) ? $GLOBALS['sql_compatibility'] : 'NONE'; $head = $this->_exportComment() . $this->_exportComment( __('Database') . ': ' . (isset($GLOBALS['sql_backquotes']) - ? PMA_CommonFunctions::getInstance()->backquote_compat($db) + ? PMA_CommonFunctions::getInstance()->backquote_compat($db, true, $compat) : '\'' . $db . '\'') ) . $this->_exportComment(); @@ -1124,19 +1125,19 @@ class ExportSql extends ExportPlugin . $this->_exportComment( __('Constraints for table') . ' ' - . $common_functions->backquote_compat($table) + . $common_functions->backquote_compat($table, true, $compat) ) . $this->_exportComment(); } // let's do the work $sql_constraints_query .= 'ALTER TABLE ' - . $common_functions->backquote_compat($table) . $crlf; + . $common_functions->backquote_compat($table, true, $compat) . $crlf; $sql_constraints .= 'ALTER TABLE ' - . $common_functions->backquote_compat($table) . $crlf; + . $common_functions->backquote_compat($table, true, $compat) . $crlf; $sql_drop_foreign_keys .= 'ALTER TABLE ' - . $common_functions->backquote_compat($db) . '.' - . $common_functions->backquote_compat($table) . $crlf; + . $common_functions->backquote_compat($db, true, $compat) . '.' + . $common_functions->backquote_compat($table, true, $compat) . $crlf; $first = true; for ($j = $i; $j < $sql_count; $j++) { @@ -1352,9 +1353,10 @@ class ExportSql extends ExportPlugin ) { $common_functions = PMA_CommonFunctions::getInstance(); - + $compat = (isset($GLOBALS['sql_compatibility'])) ? $GLOBALS['sql_compatibility'] : 'NONE'; + $formatted_table_name = (isset($GLOBALS['sql_backquotes'])) - ? $common_functions->backquote_compat($table) : '\'' . $table . '\''; + ? $common_functions->backquote_compat($table, true, $compat) : '\'' . $table . '\''; $dump = $this->_possibleCRLF() . $this->_exportComment(str_repeat('-', 56)) . $this->_possibleCRLF() @@ -1436,10 +1438,12 @@ class ExportSql extends ExportPlugin public function exportData($db, $table, $crlf, $error_url, $sql_query) { global $current_row, $sql_backquotes; - + + $compat = (isset($GLOBALS['sql_compatibility'])) ? $GLOBALS['sql_compatibility'] : 'NONE'; + $common_functions = PMA_CommonFunctions::getInstance(); $formatted_table_name = (isset($GLOBALS['sql_backquotes'])) - ? $common_functions->backquote_compat($table) + ? $common_functions->backquote_compat($table, true, $compat) : '\'' . $table . '\''; // Do not export data for a VIEW @@ -1488,12 +1492,14 @@ class ExportSql extends ExportPlugin if (isset($analyzed_sql[0]['select_expr'][$j]['column'])) { $field_set[$j] = $common_functions->backquote_compat( $analyzed_sql[0]['select_expr'][$j]['column'], - $sql_backquotes + $sql_backquotes, + $compat ); } else { $field_set[$j] = $common_functions->backquote_compat( $fields_meta[$j]->name, - $sql_backquotes + $sql_backquotes, + $compat ); } } @@ -1509,7 +1515,8 @@ class ExportSql extends ExportPlugin // avoid EOL blank $schema_insert .= $common_functions->backquote_compat( $table, - $sql_backquotes + $sql_backquotes, + $compat ) . ' SET'; } else { // insert or replace @@ -1543,7 +1550,8 @@ class ExportSql extends ExportPlugin $truncate = 'TRUNCATE TABLE ' . $common_functions->backquote_compat( $table, - $sql_backquotes + $sql_backquotes, + $compat ) . ";"; $truncatehead = $this->_possibleCRLF() . $this->_exportComment() @@ -1562,7 +1570,7 @@ class ExportSql extends ExportPlugin // We need to SET IDENTITY_INSERT ON for MSSQL if (isset($GLOBALS['sql_compatibility']) && $GLOBALS['sql_compatibility'] == 'MSSQL') { - $sql_command = 'SET IDENTITY_INSERT '. $common_functions->backquote_compat($table). ' ON ;'.$crlf.$sql_command; + $sql_command = 'SET IDENTITY_INSERT '. $common_functions->backquote_compat($table, true, $compat). ' ON ;'.$crlf.$sql_command; } // scheme for inserting fields @@ -1571,12 +1579,12 @@ class ExportSql extends ExportPlugin ) { $fields = implode(', ', $field_set); $schema_insert = $sql_command . $insert_delayed .' INTO ' - . $common_functions->backquote_compat($table, $sql_backquotes) + . $common_functions->backquote_compat($table, $sql_backquotes, $compat) // avoid EOL blank . ' (' . $fields . ') VALUES'; } else { $schema_insert = $sql_command . $insert_delayed .' INTO ' - . $common_functions->backquote_compat($table, $sql_backquotes) + . $common_functions->backquote_compat($table, $sql_backquotes, $compat) . ' VALUES'; } } @@ -1738,11 +1746,11 @@ class ExportSql extends ExportPlugin } } - // We need to SET IDENTITY_INSERT OFF for MSSQL + // We need to SET IDENTITY_INSERT ON for MSSQL if (isset($GLOBALS['sql_compatibility']) && $GLOBALS['sql_compatibility'] == 'MSSQL') if (! PMA_exportOutputHandler( - $crlf . 'SET IDENTITY_INSERT ' . $common_functions->backquote_compat($table) . ' OFF;' . $crlf + $crlf . 'SET IDENTITY_INSERT ' . $common_functions->backquote_compat($table, true, $compat) . ' OFF;' . $crlf )) { return false; } From 93d8688340f8859d51aff82c803fb745d5f5904c Mon Sep 17 00:00:00 2001 From: hastenax Date: Thu, 2 Aug 2012 17:26:47 +0400 Subject: [PATCH 06/45] Update libraries/CommonFunctions.class.php Added new $compatibility param for backquote_compat method. --- libraries/CommonFunctions.class.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libraries/CommonFunctions.class.php b/libraries/CommonFunctions.class.php index bd982b066a..609cd37dd6 100644 --- a/libraries/CommonFunctions.class.php +++ b/libraries/CommonFunctions.class.php @@ -977,7 +977,7 @@ class PMA_CommonFunctions * * example: * - * echo backquote_compat('owner`s db'); // `owner``s db` + * echo backquote('owner`s db'); // `owner``s db` * * * @@ -985,12 +985,13 @@ class PMA_CommonFunctions * or array of it * @param boolean $do_it a flag to bypass this function (used by dump * functions) - * + * @param string $compatibility string compatibility mode (used by dump + * functions) * @return mixed the "backquoted" database, table or field name * * @access public */ - public function backquote_compat($a_name, $do_it = true) + public function backquote_compat($a_name, $do_it = true, $compatibility = 'MSSQL') { if (is_array($a_name)) { @@ -1009,7 +1010,7 @@ class PMA_CommonFunctions } // @todo add more compatibility cases (ORACLE for example) - switch ($GLOBALS['sql_compatibility']) { + switch ($compatibility) { case 'MSSQL': $quote = '"'; break; default: (isset($GLOBALS['sql_backquotes'])) ? $quote = "`" : $quote = ''; break; } From b062ebdec7f2bf2cc1145af70145878beed44ccc Mon Sep 17 00:00:00 2001 From: hastenax Date: Thu, 2 Aug 2012 23:15:28 +0400 Subject: [PATCH 07/45] Update test/libraries/common/PMA_quoting_slashing_test.php Added test for PMA_CommonFunctions::getInstance()->backquote_compat function. --- .../common/PMA_quoting_slashing_test.php | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/test/libraries/common/PMA_quoting_slashing_test.php b/test/libraries/common/PMA_quoting_slashing_test.php index 151273a1c4..2c69693827 100644 --- a/test/libraries/common/PMA_quoting_slashing_test.php +++ b/test/libraries/common/PMA_quoting_slashing_test.php @@ -114,6 +114,41 @@ class PMA_quoting_slashing_test extends PHPUnit_Framework_TestCase $this->assertEquals($b, PMA_CommonFunctions::getInstance()->backquote($a)); } + /** + * data provider for backquote_compat test + * + * @return array + */ + public function backquote_compatDataProvider() + { + return array( + array('0', '"0"'), + array('test', '"test"'), + array('te`st', '"te`st"'), + array(array('test', 'te`st', '', '*'), array('"test"', '"te`st"', '', '*')) + ); + } + + /** + * backquote_compat test with different param $compatibility (NONE, MSSQL) + * @dataProvider backquote_compatDataProvider + */ + public function testBackquote_compat($a, $b) + { + // Test bypass quoting (used by dump functions) + $this->assertEquals($a, PMA_CommonFunctions::getInstance()->backquote_compat($a, 'NONE', false)); + + // Test backquote (backquoting will be enabled only if isset $GLOBALS['sql_backquotes'] + $this->assertEquals($a, PMA_CommonFunctions::getInstance()->backquote_compat($a, 'NONE')); + + // Run tests in MSSQL compatibility mode + // Test bypass quoting (used by dump functions) + $this->assertEquals($a, PMA_CommonFunctions::getInstance()->backquote_compat($a, 'MSSQL', false)); + + // Test backquote + $this->assertEquals($b, PMA_CommonFunctions::getInstance()->backquote_compat($a, 'MSSQL')); + } + public function testBackquoteForbidenWords() { global $PMA_SQPdata_forbidden_word; From da855d34d00021d7f07e216f2b127336982fd704 Mon Sep 17 00:00:00 2001 From: hastenax Date: Thu, 2 Aug 2012 23:18:13 +0400 Subject: [PATCH 08/45] Update libraries/plugins/export/ExportSql.class.php Rewrited, backquote_compat parameters order changed. Prevented multiple IDENTITY_INSERTs. --- libraries/plugins/export/ExportSql.class.php | 89 ++++++++++---------- 1 file changed, 46 insertions(+), 43 deletions(-) diff --git a/libraries/plugins/export/ExportSql.class.php b/libraries/plugins/export/ExportSql.class.php index de1f456b8e..3857b3310b 100644 --- a/libraries/plugins/export/ExportSql.class.php +++ b/libraries/plugins/export/ExportSql.class.php @@ -698,15 +698,15 @@ class ExportSql extends ExportPlugin if (! PMA_exportOutputHandler( 'DROP DATABASE ' . (isset($GLOBALS['sql_backquotes']) - ? $common_functions->backquote_compat($db, true, $compat) : $db) + ? $common_functions->backquote_compat($db, $compat) : $db) . ';' . $crlf )) { return false; } } $create_query = 'CREATE DATABASE ' - . (isset($GLOBALS['sql_backquotes']) - ? $common_functions->backquote_compat($db, true, $compat) : $db); + . (isset($GLOBALS['sql_backquotes']) + ? $common_functions->backquote_compat($db, $compat) : $db); $collation = PMA_getDbCollation($db); if (PMA_DRIZZLE) { $create_query .= ' COLLATE ' . $collation; @@ -729,7 +729,7 @@ class ExportSql extends ExportPlugin || PMA_DRIZZLE) ) { $result = PMA_exportOutputHandler( - 'USE ' . $common_functions->backquote_compat($db, true, $compat) . ';' . $crlf + 'USE ' . $common_functions->backquote_compat($db, $compat) . ';' . $crlf ); } else { $result = PMA_exportOutputHandler('USE ' . $db . ';' . $crlf); @@ -752,7 +752,7 @@ class ExportSql extends ExportPlugin . $this->_exportComment( __('Database') . ': ' . (isset($GLOBALS['sql_backquotes']) - ? PMA_CommonFunctions::getInstance()->backquote_compat($db, true, $compat) + ? PMA_CommonFunctions::getInstance()->backquote_compat($db, $compat) : '\'' . $db . '\'') ) . $this->_exportComment(); @@ -893,7 +893,7 @@ class ExportSql extends ExportPlugin $schema_create = ''; $auto_increment = ''; $new_crlf = $crlf; - + $compat = (isset($GLOBALS['sql_compatibility'])) ? $GLOBALS['sql_compatibility'] : 'NONE'; // need to use PMA_DBI_QUERY_STORE with PMA_DBI_num_rows() in mysqli @@ -1051,8 +1051,8 @@ class ExportSql extends ExportPlugin $create_query ); } - - // In MSSQL + + // In MSSQL // 1. DATE field doesn't exist, we will use datetime instead // 2. UNSIGNED attribute doesn't exist // 3. No length on int fields @@ -1063,8 +1063,8 @@ class ExportSql extends ExportPlugin '/ int\([0-9]*\) /', ' int ', $create_query - ); - } + ); + } // Drizzle (checked on 2011.03.13) returns ROW_FORMAT surrounded // with quotes, which is not accepted by parser @@ -1125,19 +1125,19 @@ class ExportSql extends ExportPlugin . $this->_exportComment( __('Constraints for table') . ' ' - . $common_functions->backquote_compat($table, true, $compat) + . $common_functions->backquote_compat($table, $compat) ) . $this->_exportComment(); } // let's do the work $sql_constraints_query .= 'ALTER TABLE ' - . $common_functions->backquote_compat($table, true, $compat) . $crlf; + . $common_functions->backquote_compat($table, $compat) . $crlf; $sql_constraints .= 'ALTER TABLE ' - . $common_functions->backquote_compat($table, true, $compat) . $crlf; + . $common_functions->backquote_compat($table, $compat) . $crlf; $sql_drop_foreign_keys .= 'ALTER TABLE ' - . $common_functions->backquote_compat($db, true, $compat) . '.' - . $common_functions->backquote_compat($table, true, $compat) . $crlf; + . $common_functions->backquote_compat($db, $compat) . '.' + . $common_functions->backquote_compat($table, $compat) . $crlf; $first = true; for ($j = $i; $j < $sql_count; $j++) { @@ -1354,9 +1354,9 @@ class ExportSql extends ExportPlugin $common_functions = PMA_CommonFunctions::getInstance(); $compat = (isset($GLOBALS['sql_compatibility'])) ? $GLOBALS['sql_compatibility'] : 'NONE'; - + $formatted_table_name = (isset($GLOBALS['sql_backquotes'])) - ? $common_functions->backquote_compat($table, true, $compat) : '\'' . $table . '\''; + ? $common_functions->backquote_compat($table, $compat) : '\'' . $table . '\''; $dump = $this->_possibleCRLF() . $this->_exportComment(str_repeat('-', 56)) . $this->_possibleCRLF() @@ -1438,12 +1438,12 @@ class ExportSql extends ExportPlugin public function exportData($db, $table, $crlf, $error_url, $sql_query) { global $current_row, $sql_backquotes; - + $compat = (isset($GLOBALS['sql_compatibility'])) ? $GLOBALS['sql_compatibility'] : 'NONE'; - + $common_functions = PMA_CommonFunctions::getInstance(); $formatted_table_name = (isset($GLOBALS['sql_backquotes'])) - ? $common_functions->backquote_compat($table, true, $compat) + ? $common_functions->backquote_compat($table, $compat) : '\'' . $table . '\''; // Do not export data for a VIEW @@ -1492,14 +1492,14 @@ class ExportSql extends ExportPlugin if (isset($analyzed_sql[0]['select_expr'][$j]['column'])) { $field_set[$j] = $common_functions->backquote_compat( $analyzed_sql[0]['select_expr'][$j]['column'], - $sql_backquotes, - $compat + $compat, + $sql_backquotes ); } else { $field_set[$j] = $common_functions->backquote_compat( $fields_meta[$j]->name, - $sql_backquotes, - $compat + $compat, + $sql_backquotes ); } } @@ -1515,8 +1515,8 @@ class ExportSql extends ExportPlugin // avoid EOL blank $schema_insert .= $common_functions->backquote_compat( $table, - $sql_backquotes, - $compat + $compat, + $sql_backquotes ) . ' SET'; } else { // insert or replace @@ -1550,8 +1550,8 @@ class ExportSql extends ExportPlugin $truncate = 'TRUNCATE TABLE ' . $common_functions->backquote_compat( $table, - $sql_backquotes, - $compat + $compat, + $sql_backquotes ) . ";"; $truncatehead = $this->_possibleCRLF() . $this->_exportComment() @@ -1566,25 +1566,19 @@ class ExportSql extends ExportPlugin } else { $truncate = ''; } - - // We need to SET IDENTITY_INSERT ON for MSSQL - if (isset($GLOBALS['sql_compatibility']) - && $GLOBALS['sql_compatibility'] == 'MSSQL') { - $sql_command = 'SET IDENTITY_INSERT '. $common_functions->backquote_compat($table, true, $compat). ' ON ;'.$crlf.$sql_command; - } - + // scheme for inserting fields if ($GLOBALS['sql_insert_syntax'] == 'complete' || $GLOBALS['sql_insert_syntax'] == 'both' ) { $fields = implode(', ', $field_set); $schema_insert = $sql_command . $insert_delayed .' INTO ' - . $common_functions->backquote_compat($table, $sql_backquotes, $compat) + . $common_functions->backquote_compat($table, $compat, $sql_backquotes) // avoid EOL blank . ' (' . $fields . ') VALUES'; } else { $schema_insert = $sql_command . $insert_delayed .' INTO ' - . $common_functions->backquote_compat($table, $sql_backquotes, $compat) + . $common_functions->backquote_compat($table, $compat, $sql_backquotes) . ' VALUES'; } } @@ -1618,6 +1612,14 @@ class ExportSql extends ExportPlugin if (! PMA_exportOutputHandler($head)) { return false; } + } + // We need to SET IDENTITY_INSERT ON for MSSQL + if (isset($GLOBALS['sql_compatibility']) + && $GLOBALS['sql_compatibility'] == 'MSSQL' + && $current_row == 0) { + if (! PMA_exportOutputHandler('SET IDENTITY_INSERT '. $common_functions->backquote_compat($table, $compat). ' ON ;'.$crlf)) { + return false; + } } $current_row++; for ($j = 0; $j < $fields_cnt; $j++) { @@ -1739,22 +1741,23 @@ class ExportSql extends ExportPlugin } } // end while - + if ($current_row > 0) { if (! PMA_exportOutputHandler(';' . $crlf)) { return false; } } - - // We need to SET IDENTITY_INSERT ON for MSSQL + + // We need to SET IDENTITY_INSERT ON for MSSQL if (isset($GLOBALS['sql_compatibility']) - && $GLOBALS['sql_compatibility'] == 'MSSQL') + && $GLOBALS['sql_compatibility'] == 'MSSQL' + && $current_row > 0) if (! PMA_exportOutputHandler( - $crlf . 'SET IDENTITY_INSERT ' . $common_functions->backquote_compat($table, true, $compat) . ' OFF;' . $crlf + $crlf . 'SET IDENTITY_INSERT ' . $common_functions->backquote_compat($table, $compat) . ' OFF;' . $crlf )) { return false; } - + } // end if ($result != false) PMA_DBI_free_result($result); From 2bc1d1d4bd1065a3c7336d2adcfb3ce4259fa1c6 Mon Sep 17 00:00:00 2001 From: hastenax Date: Thu, 2 Aug 2012 23:19:33 +0400 Subject: [PATCH 09/45] Update libraries/CommonFunctions.class.php Refactored, changed backquote_compat parameters order. --- libraries/CommonFunctions.class.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libraries/CommonFunctions.class.php b/libraries/CommonFunctions.class.php index 609cd37dd6..c7a01bb324 100644 --- a/libraries/CommonFunctions.class.php +++ b/libraries/CommonFunctions.class.php @@ -974,7 +974,7 @@ class PMA_CommonFunctions /** * Adds quotes on both sides of a database, table or field name. * in compatibility mode - * + * * example: * * echo backquote('owner`s db'); // `owner``s db` @@ -983,20 +983,20 @@ class PMA_CommonFunctions * * @param mixed $a_name the database, table or field name to "backquote" * or array of it - * @param boolean $do_it a flag to bypass this function (used by dump - * functions) * @param string $compatibility string compatibility mode (used by dump * functions) + * @param boolean $do_it a flag to bypass this function (used by dump + * functions) * @return mixed the "backquoted" database, table or field name * * @access public */ - public function backquote_compat($a_name, $do_it = true, $compatibility = 'MSSQL') + public function backquote_compat($a_name, $compatibility = 'MSSQL', $do_it = true) { if (is_array($a_name)) { foreach ($a_name as &$data) { - $data = $this->backquote_compat($data, $do_it); + $data = $this->backquote_compat($data, $compatibility, $do_it); } return $a_name; } @@ -1008,7 +1008,7 @@ class PMA_CommonFunctions return $a_name; } } - + // @todo add more compatibility cases (ORACLE for example) switch ($compatibility) { case 'MSSQL': $quote = '"'; break; @@ -1022,7 +1022,7 @@ class PMA_CommonFunctions return $a_name; } - } // end of the 'backquote_compat()' function + } // end of the 'backquote_compat()' function /** * Defines the value depending on the user OS. From 0249919c15d132f39374f6fdb40533827411a853 Mon Sep 17 00:00:00 2001 From: hastenax Date: Tue, 7 Aug 2012 16:09:34 +0400 Subject: [PATCH 10/45] Update libraries/plugins/export/ExportSql.class.php Fixed issue with int, date, unsigned text inside DEFAULT field value. --- libraries/plugins/export/ExportSql.class.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/libraries/plugins/export/ExportSql.class.php b/libraries/plugins/export/ExportSql.class.php index 3857b3310b..8e96bd9768 100644 --- a/libraries/plugins/export/ExportSql.class.php +++ b/libraries/plugins/export/ExportSql.class.php @@ -1057,13 +1057,17 @@ class ExportSql extends ExportPlugin // 2. UNSIGNED attribute doesn't exist // 3. No length on int fields if ($compat == 'MSSQL') { - $create_query = str_ireplace(' date ', ' datetime ', $create_query); - $create_query = str_ireplace(' unsigned ', ' ', $create_query); - $create_query = preg_replace( - '/ int\([0-9]*\) /', - ' int ', - $create_query - ); + $create_query = str_ireplace( "\" date DEFAULT NULL,\n", '" datetime DEFAULT NULL,'."\n", $create_query); + $create_query = str_ireplace( "\" date NOT NULL,\n", '" datetime NOT NULL,'."\n", $create_query); + $create_query = preg_replace( '/" date NOT NULL DEFAULT \'([^\'])/', '" datetime NOT NULL DEFAULT \'$1', $create_query); + + $create_query = str_ireplace( ") unsigned NOT NULL,\n", ') NOT NULL,'."\n", $create_query); + $create_query = str_ireplace( ") unsigned DEFAULT NULL,\n", ') DEFAULT NULL,'."\n", $create_query); + $create_query = preg_replace( '/\) unsigned NOT NULL DEFAULT \'([^\'])/', ') NOT NULL DEFAULT \'$1', $create_query); + + $create_query = preg_replace( '/" int\([0-9]*\) DEFAULT NULL,\n/', '" int DEFAULT NULL,'."\n", $create_query); + $create_query = preg_replace( '/" int\([0-9]*\) NOT NULL,\n/', '" int NOT NULL,'."\n", $create_query); + $create_query = preg_replace( '/" int\([0-9]*\) NOT NULL DEFAULT \'([^\'])/', '" int NOT NULL DEFAULT \'$1', $create_query); } // Drizzle (checked on 2011.03.13) returns ROW_FORMAT surrounded From a0b17d99c7ae75974d3720793ea51c7dd56dbc88 Mon Sep 17 00:00:00 2001 From: hastenax Date: Tue, 7 Aug 2012 16:53:11 +0400 Subject: [PATCH 11/45] Update libraries/plugins/export/ExportSql.class.php Fixed DEFAULT field value replacing issue. --- libraries/plugins/export/ExportSql.class.php | 23 ++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/libraries/plugins/export/ExportSql.class.php b/libraries/plugins/export/ExportSql.class.php index 8e96bd9768..ec98df2d1c 100644 --- a/libraries/plugins/export/ExportSql.class.php +++ b/libraries/plugins/export/ExportSql.class.php @@ -1055,19 +1055,34 @@ class ExportSql extends ExportPlugin // In MSSQL // 1. DATE field doesn't exist, we will use datetime instead // 2. UNSIGNED attribute doesn't exist - // 3. No length on int fields + // 3. No length on INT and FLOAT fields + // 4. No KEY and INDEX inside CREATE TABLE if ($compat == 'MSSQL') { + //first we need to replace all lines ended with '" date ...,\n' + //last preg_replace preserve us from situation with date text inside DEFAULT field value $create_query = str_ireplace( "\" date DEFAULT NULL,\n", '" datetime DEFAULT NULL,'."\n", $create_query); $create_query = str_ireplace( "\" date NOT NULL,\n", '" datetime NOT NULL,'."\n", $create_query); $create_query = preg_replace( '/" date NOT NULL DEFAULT \'([^\'])/', '" datetime NOT NULL DEFAULT \'$1', $create_query); + //next we need to replace all lines ended with ') unsigned ...," + //last preg_replace preserve us from situation with unsigned text inside DEFAULT field value $create_query = str_ireplace( ") unsigned NOT NULL,\n", ') NOT NULL,'."\n", $create_query); $create_query = str_ireplace( ") unsigned DEFAULT NULL,\n", ') DEFAULT NULL,'."\n", $create_query); $create_query = preg_replace( '/\) unsigned NOT NULL DEFAULT \'([^\'])/', ') NOT NULL DEFAULT \'$1', $create_query); - $create_query = preg_replace( '/" int\([0-9]*\) DEFAULT NULL,\n/', '" int DEFAULT NULL,'."\n", $create_query); - $create_query = preg_replace( '/" int\([0-9]*\) NOT NULL,\n/', '" int NOT NULL,'."\n", $create_query); - $create_query = preg_replace( '/" int\([0-9]*\) NOT NULL DEFAULT \'([^\'])/', '" int NOT NULL DEFAULT \'$1', $create_query); + // we need to replace all lines ended with '" int([0-9]{1,}) ...," + //last preg_replace preserve us from situation with int([0-9]{1,}) text inside DEFAULT field value + $create_query = preg_replace( '/" int\([0-9]+\) DEFAULT NULL,\n/', '" int DEFAULT NULL,'."\n", $create_query); + $create_query = preg_replace( '/" int\([0-9]+\) NOT NULL,\n/', '" int NOT NULL,'."\n", $create_query); + $create_query = preg_replace( '/" int\([0-9]+\) NOT NULL DEFAULT \'([^\'])/', '" int NOT NULL DEFAULT \'$1', $create_query); + + // we need to replace all lines ended with '" float([0-9,]{1,}) ...," + //last preg_replace preserve us from situation with float([0-9,]{1,}) text inside DEFAULT field value + $create_query = preg_replace( '/" float\([0-9,]+\) DEFAULT NULL,\n/', '" float DEFAULT NULL,'."\n", $create_query); + $create_query = preg_replace( '/" float\([0-9,]+\) NOT NULL,\n/', '" float NOT NULL,'."\n", $create_query); + $create_query = preg_replace( '/" float\([0-9,]+\) NOT NULL DEFAULT \'([^\'])/', '" float NOT NULL DEFAULT \'$1', $create_query); + + // @todo remove indexes from CREATE TABLE } // Drizzle (checked on 2011.03.13) returns ROW_FORMAT surrounded From 967166f0d7b93912482d174824d49d900839d7d0 Mon Sep 17 00:00:00 2001 From: hastenax Date: Tue, 7 Aug 2012 17:38:38 +0400 Subject: [PATCH 12/45] Update libraries/plugins/export/ExportSql.class.php Removed length on TINYINT fields. --- libraries/plugins/export/ExportSql.class.php | 28 ++++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/libraries/plugins/export/ExportSql.class.php b/libraries/plugins/export/ExportSql.class.php index ec98df2d1c..33ac9d124e 100644 --- a/libraries/plugins/export/ExportSql.class.php +++ b/libraries/plugins/export/ExportSql.class.php @@ -1055,31 +1055,31 @@ class ExportSql extends ExportPlugin // In MSSQL // 1. DATE field doesn't exist, we will use datetime instead // 2. UNSIGNED attribute doesn't exist - // 3. No length on INT and FLOAT fields + // 3. No length on INT, TINYINT and FLOAT fields // 4. No KEY and INDEX inside CREATE TABLE if ($compat == 'MSSQL') { - //first we need to replace all lines ended with '" date ...,\n' + //first we need to replace all lines ended with '" DATE ...,\n' //last preg_replace preserve us from situation with date text inside DEFAULT field value - $create_query = str_ireplace( "\" date DEFAULT NULL,\n", '" datetime DEFAULT NULL,'."\n", $create_query); - $create_query = str_ireplace( "\" date NOT NULL,\n", '" datetime NOT NULL,'."\n", $create_query); + $create_query = preg_replace( "/\" date DEFAULT NULL(,)?\n/", '" datetime DEFAULT NULL$1'."\n", $create_query); + $create_query = preg_replace( "/\" date NOT NULL(,)?\n/", '" datetime NOT NULL$1'."\n", $create_query); $create_query = preg_replace( '/" date NOT NULL DEFAULT \'([^\'])/', '" datetime NOT NULL DEFAULT \'$1', $create_query); - //next we need to replace all lines ended with ') unsigned ...," + //next we need to replace all lines ended with ') UNSIGNED ...,' //last preg_replace preserve us from situation with unsigned text inside DEFAULT field value - $create_query = str_ireplace( ") unsigned NOT NULL,\n", ') NOT NULL,'."\n", $create_query); - $create_query = str_ireplace( ") unsigned DEFAULT NULL,\n", ') DEFAULT NULL,'."\n", $create_query); + $create_query = preg_replace( "/\) unsigned NOT NULL(,)?\n/", ') NOT NULL$1'."\n", $create_query); + $create_query = preg_replace( "/\) unsigned DEFAULT NULL(,)?\n/", ') DEFAULT NULL$1'."\n", $create_query); $create_query = preg_replace( '/\) unsigned NOT NULL DEFAULT \'([^\'])/', ') NOT NULL DEFAULT \'$1', $create_query); - // we need to replace all lines ended with '" int([0-9]{1,}) ...," + // we need to replace all lines ended with '" INT|TINYINT([0-9]{1,}) ...,' //last preg_replace preserve us from situation with int([0-9]{1,}) text inside DEFAULT field value - $create_query = preg_replace( '/" int\([0-9]+\) DEFAULT NULL,\n/', '" int DEFAULT NULL,'."\n", $create_query); - $create_query = preg_replace( '/" int\([0-9]+\) NOT NULL,\n/', '" int NOT NULL,'."\n", $create_query); - $create_query = preg_replace( '/" int\([0-9]+\) NOT NULL DEFAULT \'([^\'])/', '" int NOT NULL DEFAULT \'$1', $create_query); + $create_query = preg_replace( '/" (int|tinyint)\([0-9]+\) DEFAULT NULL(,)?\n/', '" $1 DEFAULT NULL$2'."\n", $create_query); + $create_query = preg_replace( '/" (int|tinyint)\([0-9]+\) NOT NULL(,)?\n/', '" $1 NOT NULL$2'."\n", $create_query); + $create_query = preg_replace( '/" (int|tinyint)\([0-9]+\) NOT NULL DEFAULT \'([^\'])/', '" $1 NOT NULL DEFAULT \'$2', $create_query); - // we need to replace all lines ended with '" float([0-9,]{1,}) ...," + // we need to replace all lines ended with '" FLOAT([0-9,]{1,}) ...,' //last preg_replace preserve us from situation with float([0-9,]{1,}) text inside DEFAULT field value - $create_query = preg_replace( '/" float\([0-9,]+\) DEFAULT NULL,\n/', '" float DEFAULT NULL,'."\n", $create_query); - $create_query = preg_replace( '/" float\([0-9,]+\) NOT NULL,\n/', '" float NOT NULL,'."\n", $create_query); + $create_query = preg_replace( '/" float\([0-9,]+\) DEFAULT NULL(,)?\n/', '" float DEFAULT NULL$1'."\n", $create_query); + $create_query = preg_replace( '/" float\([0-9,]+\) NOT NULL(,)?\n/', '" float NOT NULL$1'."\n", $create_query); $create_query = preg_replace( '/" float\([0-9,]+\) NOT NULL DEFAULT \'([^\'])/', '" float NOT NULL DEFAULT \'$1', $create_query); // @todo remove indexes from CREATE TABLE From 1167d32baf4a47f747695916be55a70f8abdffca Mon Sep 17 00:00:00 2001 From: hastenax Date: Tue, 7 Aug 2012 17:55:36 +0400 Subject: [PATCH 13/45] Update libraries/plugins/export/ExportSql.class.php Removed length on SMALLINT and BIGINT fields. --- libraries/plugins/export/ExportSql.class.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libraries/plugins/export/ExportSql.class.php b/libraries/plugins/export/ExportSql.class.php index 33ac9d124e..68d6b988cc 100644 --- a/libraries/plugins/export/ExportSql.class.php +++ b/libraries/plugins/export/ExportSql.class.php @@ -1055,7 +1055,7 @@ class ExportSql extends ExportPlugin // In MSSQL // 1. DATE field doesn't exist, we will use datetime instead // 2. UNSIGNED attribute doesn't exist - // 3. No length on INT, TINYINT and FLOAT fields + // 3. No length on INT, TINYINT, SMALLINT, BIGINT and no precision on FLOAT fields // 4. No KEY and INDEX inside CREATE TABLE if ($compat == 'MSSQL') { //first we need to replace all lines ended with '" DATE ...,\n' @@ -1072,17 +1072,17 @@ class ExportSql extends ExportPlugin // we need to replace all lines ended with '" INT|TINYINT([0-9]{1,}) ...,' //last preg_replace preserve us from situation with int([0-9]{1,}) text inside DEFAULT field value - $create_query = preg_replace( '/" (int|tinyint)\([0-9]+\) DEFAULT NULL(,)?\n/', '" $1 DEFAULT NULL$2'."\n", $create_query); - $create_query = preg_replace( '/" (int|tinyint)\([0-9]+\) NOT NULL(,)?\n/', '" $1 NOT NULL$2'."\n", $create_query); - $create_query = preg_replace( '/" (int|tinyint)\([0-9]+\) NOT NULL DEFAULT \'([^\'])/', '" $1 NOT NULL DEFAULT \'$2', $create_query); + $create_query = preg_replace( '/" (int|tinyint|smallint|bigint)\([0-9]+\) DEFAULT NULL(,)?\n/', '" $1 DEFAULT NULL$2'."\n", $create_query); + $create_query = preg_replace( '/" (int|tinyint|smallint|bigint)\([0-9]+\) NOT NULL(,)?\n/', '" $1 NOT NULL$2'."\n", $create_query); + $create_query = preg_replace( '/" (int|tinyint|smallint|bigint)\([0-9]+\) NOT NULL DEFAULT \'([^\'])/', '" $1 NOT NULL DEFAULT \'$2', $create_query); // we need to replace all lines ended with '" FLOAT([0-9,]{1,}) ...,' //last preg_replace preserve us from situation with float([0-9,]{1,}) text inside DEFAULT field value - $create_query = preg_replace( '/" float\([0-9,]+\) DEFAULT NULL(,)?\n/', '" float DEFAULT NULL$1'."\n", $create_query); - $create_query = preg_replace( '/" float\([0-9,]+\) NOT NULL(,)?\n/', '" float NOT NULL$1'."\n", $create_query); - $create_query = preg_replace( '/" float\([0-9,]+\) NOT NULL DEFAULT \'([^\'])/', '" float NOT NULL DEFAULT \'$1', $create_query); + $create_query = preg_replace( '/" float\([0-9]+,[0-9,]+\) DEFAULT NULL(,)?\n/', '" float DEFAULT NULL$1'."\n", $create_query); + $create_query = preg_replace( '/" float\([0-9,]+,[0-9,]+\) NOT NULL(,)?\n/', '" float NOT NULL$1'."\n", $create_query); + $create_query = preg_replace( '/" float\([0-9,]+,[0-9,]+\) NOT NULL DEFAULT \'([^\'])/', '" float NOT NULL DEFAULT \'$1', $create_query); - // @todo remove indexes from CREATE TABLE + // @todo remove indexes from CREATE TABLE } // Drizzle (checked on 2011.03.13) returns ROW_FORMAT surrounded From a0786385cd7da5820808629ae1db19a66487ad9c Mon Sep 17 00:00:00 2001 From: hastenax Date: Wed, 8 Aug 2012 11:55:21 +0400 Subject: [PATCH 14/45] Update libraries/plugins/export/ExportSql.class.php Formatting and removed DOUBLE datatype, used FLOAT instead. --- libraries/plugins/export/ExportSql.class.php | 22 +++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/libraries/plugins/export/ExportSql.class.php b/libraries/plugins/export/ExportSql.class.php index 68d6b988cc..828f82a97a 100644 --- a/libraries/plugins/export/ExportSql.class.php +++ b/libraries/plugins/export/ExportSql.class.php @@ -1053,10 +1053,11 @@ class ExportSql extends ExportPlugin } // In MSSQL - // 1. DATE field doesn't exist, we will use datetime instead + // 1. DATE field doesn't exists, we will use DATETIME instead // 2. UNSIGNED attribute doesn't exist // 3. No length on INT, TINYINT, SMALLINT, BIGINT and no precision on FLOAT fields // 4. No KEY and INDEX inside CREATE TABLE + // 5. DOUBLE field doesn't exists, we will use FLOAT instead if ($compat == 'MSSQL') { //first we need to replace all lines ended with '" DATE ...,\n' //last preg_replace preserve us from situation with date text inside DEFAULT field value @@ -1076,11 +1077,14 @@ class ExportSql extends ExportPlugin $create_query = preg_replace( '/" (int|tinyint|smallint|bigint)\([0-9]+\) NOT NULL(,)?\n/', '" $1 NOT NULL$2'."\n", $create_query); $create_query = preg_replace( '/" (int|tinyint|smallint|bigint)\([0-9]+\) NOT NULL DEFAULT \'([^\'])/', '" $1 NOT NULL DEFAULT \'$2', $create_query); - // we need to replace all lines ended with '" FLOAT([0-9,]{1,}) ...,' + // we need to replace all lines ended with '" FLOAT|DOUBLE([0-9,]{1,}) ...,' //last preg_replace preserve us from situation with float([0-9,]{1,}) text inside DEFAULT field value $create_query = preg_replace( '/" float\([0-9]+,[0-9,]+\) DEFAULT NULL(,)?\n/', '" float DEFAULT NULL$1'."\n", $create_query); $create_query = preg_replace( '/" float\([0-9,]+,[0-9,]+\) NOT NULL(,)?\n/', '" float NOT NULL$1'."\n", $create_query); $create_query = preg_replace( '/" float\([0-9,]+,[0-9,]+\) NOT NULL DEFAULT \'([^\'])/', '" float NOT NULL DEFAULT \'$1', $create_query); + $create_query = preg_replace( '/" double DEFAULT NULL(,)?\n/', '" float DEFAULT NULL$1'."\n", $create_query); + $create_query = preg_replace( '/" double NOT NULL(,)?\n/', '" float NOT NULL$1'."\n", $create_query); + $create_query = preg_replace( '/" double NOT NULL DEFAULT \'([^\'])/', '" float NOT NULL DEFAULT \'$1', $create_query); // @todo remove indexes from CREATE TABLE } @@ -1636,7 +1640,11 @@ class ExportSql extends ExportPlugin if (isset($GLOBALS['sql_compatibility']) && $GLOBALS['sql_compatibility'] == 'MSSQL' && $current_row == 0) { - if (! PMA_exportOutputHandler('SET IDENTITY_INSERT '. $common_functions->backquote_compat($table, $compat). ' ON ;'.$crlf)) { + if (! PMA_exportOutputHandler('SET IDENTITY_INSERT ' + . $common_functions->backquote_compat( + $table, + $compat) + . ' ON ;'.$crlf)) { return false; } } @@ -1767,12 +1775,16 @@ class ExportSql extends ExportPlugin } } - // We need to SET IDENTITY_INSERT ON for MSSQL + // We need to SET IDENTITY_INSERT OFF for MSSQL if (isset($GLOBALS['sql_compatibility']) && $GLOBALS['sql_compatibility'] == 'MSSQL' && $current_row > 0) if (! PMA_exportOutputHandler( - $crlf . 'SET IDENTITY_INSERT ' . $common_functions->backquote_compat($table, $compat) . ' OFF;' . $crlf + $crlf . 'SET IDENTITY_INSERT ' + . $common_functions->backquote_compat( + $table, + $compat) + . ' OFF;' . $crlf )) { return false; } From 9e4a839bc4d2ddb6e5723cb8d696362827d90d3e Mon Sep 17 00:00:00 2001 From: hastenax Date: Thu, 9 Aug 2012 14:41:50 +0400 Subject: [PATCH 15/45] Update libraries/plugins/export/ExportSql.class.php Fixed DOUBLE precision issue. --- libraries/plugins/export/ExportSql.class.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/libraries/plugins/export/ExportSql.class.php b/libraries/plugins/export/ExportSql.class.php index 828f82a97a..7195d642cd 100644 --- a/libraries/plugins/export/ExportSql.class.php +++ b/libraries/plugins/export/ExportSql.class.php @@ -1079,12 +1079,9 @@ class ExportSql extends ExportPlugin // we need to replace all lines ended with '" FLOAT|DOUBLE([0-9,]{1,}) ...,' //last preg_replace preserve us from situation with float([0-9,]{1,}) text inside DEFAULT field value - $create_query = preg_replace( '/" float\([0-9]+,[0-9,]+\) DEFAULT NULL(,)?\n/', '" float DEFAULT NULL$1'."\n", $create_query); - $create_query = preg_replace( '/" float\([0-9,]+,[0-9,]+\) NOT NULL(,)?\n/', '" float NOT NULL$1'."\n", $create_query); - $create_query = preg_replace( '/" float\([0-9,]+,[0-9,]+\) NOT NULL DEFAULT \'([^\'])/', '" float NOT NULL DEFAULT \'$1', $create_query); - $create_query = preg_replace( '/" double DEFAULT NULL(,)?\n/', '" float DEFAULT NULL$1'."\n", $create_query); - $create_query = preg_replace( '/" double NOT NULL(,)?\n/', '" float NOT NULL$1'."\n", $create_query); - $create_query = preg_replace( '/" double NOT NULL DEFAULT \'([^\'])/', '" float NOT NULL DEFAULT \'$1', $create_query); + $create_query = preg_replace( '/" (float|double)(\([0-9]+,[0-9,]+\))? DEFAULT NULL(,)?\n/', '" float DEFAULT NULL$3'."\n", $create_query); + $create_query = preg_replace( '/" (float|double)(\([0-9,]+,[0-9,]+\))? NOT NULL(,)?\n/', '" float NOT NULL$3'."\n", $create_query); + $create_query = preg_replace( '/" (float|double)(\([0-9,]+,[0-9,]+\))? NOT NULL DEFAULT \'([^\'])/', '" float NOT NULL DEFAULT \'$3', $create_query); // @todo remove indexes from CREATE TABLE } From 50d1a4884306ae6705f0bb665ba71da24089b6fe Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Thu, 9 Aug 2012 13:08:31 -0400 Subject: [PATCH 16/45] Fix for trigger page vulnerability, see PMASA-2012-4 --- libraries/rte/rte_triggers.lib.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libraries/rte/rte_triggers.lib.php b/libraries/rte/rte_triggers.lib.php index 0a9d27ceaf..92eb22dadf 100644 --- a/libraries/rte/rte_triggers.lib.php +++ b/libraries/rte/rte_triggers.lib.php @@ -317,7 +317,9 @@ function PMA_TRI_getEditorForm($mode, $item) } else if ($mode == 'edit' && $value == $item['item_table']) { $selected = " selected='selected'"; } - $retval .= " $value\n"; + $retval .= ""; + $retval .= htmlspecialchars($value); + $retval .= "\n"; } $retval .= " \n"; $retval .= " \n"; From ee306681d0d5ac09b6fc62a7d573020af083e856 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Thu, 9 Aug 2012 13:13:08 -0400 Subject: [PATCH 17/45] Fix for Empty and Drop vulnerabilities on db Structure and Operations, see PMASA-2012-4 --- js/db_structure.js | 4 ++-- js/functions.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/js/db_structure.js b/js/db_structure.js index b87c42210e..4c7ccb2f4f 100644 --- a/js/db_structure.js +++ b/js/db_structure.js @@ -276,7 +276,7 @@ $(document).ready(function() { /** * @var question String containing the question to be asked for confirmation */ - var question = 'TRUNCATE ' + curr_table_name; + var question = 'TRUNCATE ' + escapeHtml(curr_table_name); $this_anchor.PMA_confirm(question, $this_anchor.attr('href'), function(url) { @@ -335,7 +335,7 @@ $(document).ready(function() { } else { question += 'TABLE'; } - question += ' ' + curr_table_name; + question += ' ' + escapeHtml(curr_table_name); $this_anchor.PMA_confirm(question, $this_anchor.attr('href'), function(url) { diff --git a/js/functions.js b/js/functions.js index 1bb944544c..06281c2508 100644 --- a/js/functions.js +++ b/js/functions.js @@ -3342,7 +3342,7 @@ $(document).ready(function() { /** * @var question String containing the question to be asked for confirmation */ - var question = PMA_messages['strDropTableStrongWarning'] + '\n' + PMA_messages['strDoYouReally'] + ' :\n' + 'DROP TABLE ' + window.parent.table; + var question = PMA_messages['strDropTableStrongWarning'] + '\n' + PMA_messages['strDoYouReally'] + ' :\n' + 'DROP TABLE ' + escapeHtml(window.parent.table); $(this).PMA_confirm(question, $(this).attr('href') ,function(url) { @@ -3373,7 +3373,7 @@ $(document).ready(function() { /** * @var question String containing the question to be asked for confirmation */ - var question = PMA_messages['strTruncateTableStrongWarning'] + '\n' + PMA_messages['strDoYouReally'] + ' :\n' + 'TRUNCATE TABLE ' + window.parent.table; + var question = PMA_messages['strTruncateTableStrongWarning'] + '\n' + PMA_messages['strDoYouReally'] + ' :\n' + 'TRUNCATE TABLE ' + escapeHtml(window.parent.table); $(this).PMA_confirm(question, $(this).attr('href') ,function(url) { From dca22c5046aa16899042592b40a0af7b5c4f1fc7 Mon Sep 17 00:00:00 2001 From: Dieter Adriaenssens Date: Fri, 10 Aug 2012 16:04:54 +0200 Subject: [PATCH 18/45] [security] properly escape name of newly created table, see PMASA-2012-4 --- tbl_create.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tbl_create.php b/tbl_create.php index 63cd26a1da..7caade9ea7 100644 --- a/tbl_create.php +++ b/tbl_create.php @@ -272,7 +272,9 @@ if (isset($_REQUEST['do_save_data'])) { $new_table_string .= ' ' . "\n"; $new_table_string .= ''; - $new_table_string .= ''. $table . ''; + $new_table_string .= '' + . htmlspecialchars($table) . ''; if (PMA_Tracker::isActive()) { $truename = str_replace(' ', ' ', htmlspecialchars($table)); From 1aec25f5f2163029da51da39a1d13dcb20fb00ea Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Fri, 10 Aug 2012 16:26:11 +0200 Subject: [PATCH 19/45] [security] properly escape query error message when creating new trigger, see PMASA-2012-4 --- libraries/rte/rte_triggers.lib.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libraries/rte/rte_triggers.lib.php b/libraries/rte/rte_triggers.lib.php index 92eb22dadf..4e344ce474 100644 --- a/libraries/rte/rte_triggers.lib.php +++ b/libraries/rte/rte_triggers.lib.php @@ -100,8 +100,12 @@ function PMA_TRI_handleEditor() // 'Add a new item' mode $result = PMA_DBI_try_query($item_query); if (! $result) { - $errors[] = sprintf(__('The following query has failed: "%s"'), $item_query) . '

' - . __('MySQL said: ') . PMA_DBI_getError(null); + $errors[] = sprintf( + __('The following query has failed: "%s"'), + htmlspecialchars($item_query) + ) + . '

' + . __('MySQL said: ') . PMA_DBI_getError(null); } else { $message = PMA_Message::success(__('Trigger %1$s has been created.')); $message->addParam(PMA_backquote($_REQUEST['item_name'])); From 1228f48c78ea12d0973a3d5a5ed5c3a91d9b1c7b Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Sat, 11 Aug 2012 13:31:04 +0530 Subject: [PATCH 20/45] bug #3555104 [edit] Cannot copy a DB with table & views --- ChangeLog | 1 + libraries/Table.class.php | 1 + 2 files changed, 2 insertions(+) diff --git a/ChangeLog b/ChangeLog index b88ef558a6..653e6ae3ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -15,6 +15,7 @@ phpMyAdmin - ChangeLog - [interface] Designer sometimes places tables on the top menu - bug #3546277 [core] Call to undefined function __() when config file has wrong permissions - bug #3540922 [edit] Error searching table with many fields +- bug #3555104 [edit] Cannot copy a DB with table & views 3.5.2.1 (2012-08-03) - [security] Fixed local path disclosure vulnerability, see PMASA-2012-3 diff --git a/libraries/Table.class.php b/libraries/Table.class.php index 7793347f96..92a303847c 100644 --- a/libraries/Table.class.php +++ b/libraries/Table.class.php @@ -782,6 +782,7 @@ class PMA_Table for (++$i; $i <= $last; $i++) { if ($parsed_sql[$i]['type'] == $table_delimiter && $parsed_sql[$i]['data'] == $backquoted_source_db + && $parsed_sql[$i - 1]['type'] != 'punct_qualifier' ) { $parsed_sql[$i]['data'] = $target_for_view; } From 4612247ac1c42233119d83fe3a66735cff16f212 Mon Sep 17 00:00:00 2001 From: Nathan Wu Date: Fri, 10 Aug 2012 09:39:38 +0200 Subject: [PATCH 21/45] Translated using Weblate. --- po/zh_TW.po | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/po/zh_TW.po b/po/zh_TW.po index 7d974a319a..274c5d451c 100644 --- a/po/zh_TW.po +++ b/po/zh_TW.po @@ -4,15 +4,16 @@ msgstr "" "Project-Id-Version: phpMyAdmin 3.5.2-dev\n" "Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2012-06-04 13:42+0200\n" -"PO-Revision-Date: 2012-05-23 10:16+0200\n" -"Last-Translator: MoA Chung \n" -"Language-Team: chinese_traditional \n" +"PO-Revision-Date: 2012-08-10 09:38+0200\n" +"Last-Translator: Nathan Wu \n" +"Language-Team: Chinese (Taiwan) " +"\n" "Language: zh_TW\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Weblate 1.0\n" +"X-Generator: Weblate 1.2\n" #: browse_foreigners.php:35 browse_foreigners.php:53 js/messages.php:353 #: libraries/display_tbl.lib.php:359 server_privileges.php:1677 @@ -246,7 +247,7 @@ msgstr "查看資料庫的轉存(大綱)" #: db_export.php:30 db_printview.php:94 db_qbe.php:101 db_tracking.php:48 #: export.php:354 navigation.php:296 msgid "No tables found in database." -msgstr "資料庫中沒有表" +msgstr "資料庫中沒有資料。" #: db_export.php:40 db_search.php:319 server_export.php:26 msgid "Select All" @@ -281,7 +282,7 @@ msgstr "刪除資料庫" #: db_operations.php:450 #, php-format msgid "Database %s has been dropped." -msgstr "已被刪除資料庫 %s" +msgstr "資料庫 %s 已被刪除。" #: db_operations.php:455 msgid "Drop the database (DROP)" From e084583f4e6b89eed2b83eead6a8b09b26fa168c Mon Sep 17 00:00:00 2001 From: Ashiyane Digital Security Team Date: Sat, 11 Aug 2012 04:26:49 +0200 Subject: [PATCH 22/45] Translated using Weblate. --- po/fa.po | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/po/fa.po b/po/fa.po index c2bdf28804..626667b539 100644 --- a/po/fa.po +++ b/po/fa.po @@ -4,7 +4,7 @@ msgstr "" "Project-Id-Version: phpMyAdmin 3.5.2-dev\n" "Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2012-06-04 13:42+0200\n" -"PO-Revision-Date: 2012-08-03 00:13+0200\n" +"PO-Revision-Date: 2012-08-11 04:26+0200\n" "Last-Translator: Ashiyane Digital Security Team \n" "Language-Team: Persian \n" "Language: fa\n" @@ -2454,7 +2454,7 @@ msgstr "" #: libraries/File.class.php:284 msgid "The uploaded file was only partially uploaded." -msgstr "" +msgstr "فایل آپلود شده کاملا آپلود نشده." #: libraries/File.class.php:287 msgid "Missing a temporary folder." @@ -2480,7 +2480,7 @@ msgstr "" #: libraries/File.class.php:508 msgid "Error while moving uploaded file." -msgstr "" +msgstr "خطا در موقع جابجا کردن فایل آپلود شده." #: libraries/File.class.php:516 msgid "Cannot read (moved) upload file." @@ -2567,11 +2567,11 @@ msgstr[1] "" #: libraries/PDF.class.php:81 msgid "Error while creating PDF:" -msgstr "" +msgstr " PDF خطا در موقع درست کردن " #: libraries/RecentTable.class.php:107 msgid "Could not save recent table" -msgstr "" +msgstr "جدول اخیر ذخیره نشد" #: libraries/RecentTable.class.php:142 msgid "Recent tables" @@ -2579,7 +2579,7 @@ msgstr "جدول های اخیر" #: libraries/RecentTable.class.php:149 msgid "There are no recent tables" -msgstr "" +msgstr "جدول های اخیری وجود ندارد." #: libraries/StorageEngine.class.php:203 msgid "" @@ -2603,11 +2603,11 @@ msgstr "" #: libraries/Table.class.php:329 msgid "unknown table status: " -msgstr "" +msgstr " :وضعیت جدول ناشناس" #: libraries/Table.class.php:1120 msgid "Invalid database" -msgstr "" +msgstr " پایگاه داده نامعتبر " #: libraries/Table.class.php:1134 tbl_get_field.php:25 msgid "Invalid table name" From 7444b78a45aab4e7e158042a2d0811ba3e522d63 Mon Sep 17 00:00:00 2001 From: Anusuk Sangubon Date: Wed, 8 Aug 2012 08:31:03 +0200 Subject: [PATCH 23/45] Translated using Weblate. --- po/th.po | 80 +++++++++++++++++++++++++++++++------------------------- 1 file changed, 45 insertions(+), 35 deletions(-) diff --git a/po/th.po b/po/th.po index 915adb022a..00c2668d5d 100644 --- a/po/th.po +++ b/po/th.po @@ -4,15 +4,15 @@ msgstr "" "Project-Id-Version: phpMyAdmin 3.5.2-dev\n" "Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2012-06-04 13:42+0200\n" -"PO-Revision-Date: 2012-04-21 15:20+0200\n" -"Last-Translator: Setthawut Sawaengkit \n" -"Language-Team: thai \n" +"PO-Revision-Date: 2012-08-08 08:31+0200\n" +"Last-Translator: Anusuk Sangubon \n" +"Language-Team: Thai \n" "Language: th\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Weblate 0.10\n" +"X-Generator: Weblate 1.2\n" #: browse_foreigners.php:35 browse_foreigners.php:53 js/messages.php:353 #: libraries/display_tbl.lib.php:359 server_privileges.php:1677 @@ -1844,7 +1844,7 @@ msgstr "เวลาที่ทำคำสั่ง" #: js/messages.php:288 libraries/display_tbl.lib.php:423 #, php-format msgid "%d is not valid row number." -msgstr "" +msgstr "%d ไม่ใช่หมายเลขแถวที่ถูกต้อง" #: js/messages.php:291 libraries/config/FormDisplay.tpl.php:355 #: libraries/schema/User_Schema.class.php:352 @@ -1875,8 +1875,9 @@ msgid "Hovering over a point will show its label." msgstr "นำตัวชี้วางเพื่อแสดงคำกำกับ" #: js/messages.php:304 +#, fuzzy msgid "To zoom in, select a section of the plot with the mouse." -msgstr "" +msgstr "เมื่อต้องการย่อ/ขยาย เลือกส่วนของจุดโดยใช้เมาส์" #: js/messages.php:306 msgid "Click reset zoom link to come back to original state." @@ -1887,8 +1888,9 @@ msgid "Click a data point to view and possibly edit the data row." msgstr "คลิก จุดข้อมูล เพื่อดูหรือแก้ไขแถวข้อมูล" #: js/messages.php:310 +#, fuzzy msgid "The plot can be resized by dragging it along the bottom right corner." -msgstr "ขนาดจุดสามารถเปลี่ยนได้ที่ขวาล่าง" +msgstr "จุดสามารถปรับขนาดได้ โดยการลากไปมุมขวาด้านล่าง" #: js/messages.php:312 msgid "Select two columns" @@ -2363,8 +2365,8 @@ msgid "" "Error moving the uploaded file, see [a@./Documentation." "html#faq1_11@Documentation]FAQ 1.11[/a]" msgstr "" -"มีข้อผิดพลาดขนาดย้ายไฟล์อัพหลด กรุณาดู [a@./Documentation.html#faq1_11@Documentation]" -"FAQ 1.11[/a]" +"มีข้อผิดพลาดระหว่างการอัพโหลด กรุณาดู " +"[a@./Documentation.html#faq1_11@Documentation]FAQ 1.11[/a]" #: libraries/File.class.php:508 msgid "Error while moving uploaded file." @@ -2522,17 +2524,19 @@ msgstr "" "['MaxTableUiprefs'] %s)" #: libraries/Table.class.php:1533 -#, php-format +#, fuzzy, php-format msgid "" "Cannot save UI property \"%s\". The changes made will not be persistent " "after you refresh this page. Please check if the table structure has been " "changed." msgstr "" +"ไม่สามารถบันทึกคุณสมบัติ UI \"% s\" ได้ การเปลี่ยนแปลงจะมีผล " +"หลังจากคุณรีเฟรชหน้านี้ โปรดตรวจสอบหากมีการเปลี่ยนโครงสร้างของตาราง" #: libraries/Theme.class.php:145 #, php-format msgid "No valid image path for theme %s found!" -msgstr "" +msgstr "ไม่มีเส้นทางรูปภาพที่ถูกต้องสำหรับชุดรูปแบบ %s ที่พบ" #: libraries/Theme.class.php:352 msgid "No preview available." @@ -2540,30 +2544,30 @@ msgstr "ไม่สามารถแสดงตัวอย่างได้ #: libraries/Theme.class.php:355 msgid "take it" -msgstr "" +msgstr "ลงมือ" #: libraries/Theme_Manager.class.php:110 -#, php-format +#, fuzzy, php-format msgid "Default theme %s not found!" -msgstr "" +msgstr "เริ่มต้นชุดรูปแบบ %s ไม่พบ" #: libraries/Theme_Manager.class.php:151 #, php-format msgid "Theme %s not found!" -msgstr "" +msgstr "ชุดรูปแบบ %s ไม่พบ" #: libraries/Theme_Manager.class.php:217 -#, php-format +#, fuzzy, php-format msgid "Theme path not found for theme %s!" -msgstr "" +msgstr "เส้นทางของชุดรูปแบบ %s ไม่พบ" #: libraries/Theme_Manager.class.php:296 themes.php:20 themes.php:27 msgid "Theme" -msgstr "" +msgstr "ชุดรูปแบบ" #: libraries/auth/config.auth.lib.php:71 msgid "Cannot connect: invalid settings." -msgstr "" +msgstr "ไม่สามารถเชื่อมต่อ: ตั้งค่าไม่ถูกต้อง" #: libraries/auth/config.auth.lib.php:87 #: libraries/auth/cookie.auth.lib.php:172 libraries/auth/http.auth.lib.php:64 @@ -2577,6 +2581,8 @@ msgid "" "You probably did not create a configuration file. You might want to use the " "%1$ssetup script%2$s to create one." msgstr "" +"คุณคงไม่ได้สร้างแฟ้มการกำหนดค่า คุณอาจต้องการใช้ %1$ssetup script%2$s " +"เพื่อสร้างอย่างใดอย่างหนึ่ง" #: libraries/auth/config.auth.lib.php:111 msgid "" @@ -2585,6 +2591,10 @@ msgid "" "configuration and make sure that they correspond to the information given by " "the administrator of the MySQL server." msgstr "" +"phpMyAdmin พยายามเชื่อมต่อไปยังเซิร์ฟเวอร์ MySQL " +"และเซิร์ฟเวอร์ได้ปฏิเสธการเชื่อมต่อดังกล่าว คุณควรตรวจสอบโฮสต์ " +"ชื่อผู้ใช้และรหัสผ่านในการกำหนดค่าของคุณ และให้แน่ใจว่าค่าต่างๆ " +"สอดคล้องกับข้อมูลที่กำหนดไว้ โดยผู้ดูแลระบบของเซิร์ฟเวอร์ MySQL แล้ว" #: libraries/auth/cookie.auth.lib.php:35 msgid "Failed to use Blowfish from mcrypt!" @@ -2631,13 +2641,13 @@ msgstr "ต้องอนุญาตใช้ใช้ 'คุ๊กกี้' #: libraries/auth/signon.auth.lib.php:235 msgid "" "Login without a password is forbidden by configuration (see AllowNoPassword)" -msgstr "" +msgstr "ห้ามกำหนดค่า สำหรับการเข้าสู่ระบบโดยไม่มีรหัสผ่าน (ดู AllowNoPassword)" #: libraries/auth/cookie.auth.lib.php:572 #: libraries/auth/signon.auth.lib.php:239 #, php-format msgid "No activity within %s seconds; please log in again" -msgstr "" +msgstr "ไม่มีกิจกรรมภายใน %s วินาที กรุณาล็อกอินอีกครั้ง" #: libraries/auth/cookie.auth.lib.php:582 #: libraries/auth/cookie.auth.lib.php:584 @@ -2651,25 +2661,25 @@ msgstr "อนุญาตให้เข้าใช้ไม่ได้ ช #: libraries/auth/signon.auth.lib.php:88 msgid "Can not find signon authentication script:" -msgstr "" +msgstr "สามารถค้นหา signon สำหรับตรวจสอบสคริปต์:" #: libraries/auth/swekey/swekey.auth.lib.php:116 #, php-format msgid "File %s does not contain any key id" -msgstr "" +msgstr "แฟ้ม %s ไม่ควรประกอบไปด้วยรหัสคีย์ใดๆ" #: libraries/auth/swekey/swekey.auth.lib.php:156 #: libraries/auth/swekey/swekey.auth.lib.php:176 msgid "Hardware authentication failed" -msgstr "" +msgstr "ตรวจสอบฮาร์ดแวร์ล้มเหลว" #: libraries/auth/swekey/swekey.auth.lib.php:163 msgid "No valid authentication key plugged" -msgstr "" +msgstr "ไม่มีคีย์รับรองความถูกต้อง" #: libraries/auth/swekey/swekey.auth.lib.php:195 msgid "Authenticating..." -msgstr "" +msgstr "กำลังตรวจสอบ..." #: libraries/blobstreaming.lib.php:272 msgid "PBMS error" @@ -2677,15 +2687,15 @@ msgstr "" #: libraries/blobstreaming.lib.php:306 msgid "PBMS connection failed:" -msgstr "" +msgstr "การเชื่อมต่อล้มเหลว PBMS:" #: libraries/blobstreaming.lib.php:361 msgid "PBMS get BLOB info failed:" -msgstr "" +msgstr "PBMS รับข้อมูล BLOB ล้มเหลว:" #: libraries/blobstreaming.lib.php:373 msgid "PBMS get BLOB Content-Type failed" -msgstr "" +msgstr "PBMS รับรูปแบบ Content-Type ล้มเหลว" #: libraries/blobstreaming.lib.php:401 msgid "View image" @@ -2693,24 +2703,24 @@ msgstr "" #: libraries/blobstreaming.lib.php:408 msgid "Play audio" -msgstr "" +msgstr "เล่นเสียง" #: libraries/blobstreaming.lib.php:417 msgid "View video" -msgstr "" +msgstr "ดูวิดีโอ" #: libraries/blobstreaming.lib.php:423 msgid "Download file" -msgstr "" +msgstr "ดาวน์โหลดไฟล์" #: libraries/blobstreaming.lib.php:494 #, php-format msgid "Could not open file: %s" -msgstr "" +msgstr "ไม่สามารถเปิดแฟ้ม: %s" #: libraries/bookmark.lib.php:73 msgid "shared" -msgstr "" +msgstr "ใช้ร่วมกัน" #: libraries/build_html_for_db.lib.php:26 #: libraries/config/messages.inc.php:185 libraries/export/xml.php:51 @@ -2761,7 +2771,7 @@ msgstr "ตรวจสอบสิทธิ" #: libraries/common.inc.php:151 msgid "possible exploit" -msgstr "" +msgstr "ใช้ประโยชน์ได้" #: libraries/common.inc.php:160 msgid "numeric key detected" From 2d3ae33c9afabbfcb434c45c4266ef11f9adc82b Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Sat, 11 Aug 2012 13:34:35 +0530 Subject: [PATCH 24/45] Fix indentation --- libraries/Table.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/Table.class.php b/libraries/Table.class.php index d15c81405b..8ee1275a6c 100644 --- a/libraries/Table.class.php +++ b/libraries/Table.class.php @@ -845,7 +845,7 @@ class PMA_Table // this a view definition; we just found the first db name // that follows DEFINER VIEW // so change it for the new db name - $parsed_sql[$i]['data'] = $target_for_view; + $parsed_sql[$i]['data'] = $target_for_view; // then we have to find all references to the source db // and change them to the target db, ensuring we stay into // the $parsed_sql limits From b02f8ca01810f313d6f16aa8c2f41c2f49387176 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Sat, 11 Aug 2012 13:36:10 +0530 Subject: [PATCH 25/45] File is being conditionally included; use "include_once" instead --- libraries/Table.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/Table.class.php b/libraries/Table.class.php index 8ee1275a6c..2114b97d10 100644 --- a/libraries/Table.class.php +++ b/libraries/Table.class.php @@ -782,7 +782,7 @@ class PMA_Table // do not create the table if dataonly if ($what != 'dataonly') { - require_once "libraries/plugin_interface.lib.php"; + include_once "libraries/plugin_interface.lib.php"; // get Export SQL instance $export_sql_plugin = PMA_getPlugin( "export", From 6984256915ff1a55324a7e3e0d9817ba24edce48 Mon Sep 17 00:00:00 2001 From: Ashiyane Digital Security Team Date: Sat, 11 Aug 2012 04:26:50 +0200 Subject: [PATCH 26/45] Translated using Weblate. --- po/fa.po | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/po/fa.po b/po/fa.po index ba20af2b15..a9cfaaa97f 100644 --- a/po/fa.po +++ b/po/fa.po @@ -4,10 +4,10 @@ msgstr "" "Project-Id-Version: phpMyAdmin 4.0.0-dev\n" "Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2012-08-10 12:59+0200\n" -"PO-Revision-Date: 2012-08-03 00:13+0200\n" +"PO-Revision-Date: 2012-08-11 04:26+0200\n" "Last-Translator: Ashiyane Digital Security Team \n" -"Language-Team: Persian \n" +"Language-Team: Persian " +"\n" "Language: fa\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -2839,7 +2839,7 @@ msgstr "" #: libraries/File.class.php:279 msgid "The uploaded file was only partially uploaded." -msgstr "" +msgstr "فایل آپلود شده کاملا آپلود نشده." #: libraries/File.class.php:282 msgid "Missing a temporary folder." @@ -2865,7 +2865,7 @@ msgstr "" #: libraries/File.class.php:485 msgid "Error while moving uploaded file." -msgstr "" +msgstr "خطا در موقع جابجا کردن فایل آپلود شده." #: libraries/File.class.php:493 msgid "Cannot read (moved) upload file." @@ -3059,11 +3059,11 @@ msgstr[1] "" #: libraries/PDF.class.php:88 msgid "Error while creating PDF:" -msgstr "" +msgstr " PDF خطا در موقع درست کردن " #: libraries/RecentTable.class.php:112 msgid "Could not save recent table" -msgstr "" +msgstr "جدول اخیر ذخیره نشد" #: libraries/RecentTable.class.php:147 msgid "Recent tables" @@ -3071,7 +3071,7 @@ msgstr "جدول های اخیر" #: libraries/RecentTable.class.php:154 msgid "There are no recent tables" -msgstr "" +msgstr "جدول های اخیری وجود ندارد." #: libraries/StorageEngine.class.php:214 msgid "" @@ -3095,7 +3095,7 @@ msgstr "" #: libraries/Table.class.php:345 msgid "unknown table status: " -msgstr "" +msgstr " :وضعیت جدول ناشناس" #: libraries/Table.class.php:756 #, fuzzy, php-format @@ -3109,7 +3109,7 @@ msgstr "جستجو در پايگاه‌داده" #: libraries/Table.class.php:1191 msgid "Invalid database" -msgstr "" +msgstr " پایگاه داده نامعتبر " #: libraries/Table.class.php:1205 tbl_get_field.php:31 msgid "Invalid table name" From 06430452d7b6f4e700efa346414a05ea03d4865e Mon Sep 17 00:00:00 2001 From: gilberto dos santos alves Date: Fri, 10 Aug 2012 22:16:54 +0200 Subject: [PATCH 27/45] Translated using Weblate. --- po/pt_BR.po | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/po/pt_BR.po b/po/pt_BR.po index cec8c31bec..cf04e9ab61 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -4,15 +4,16 @@ msgstr "" "Project-Id-Version: phpMyAdmin 4.0.0-dev\n" "Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2012-08-10 12:59+0200\n" -"PO-Revision-Date: 2012-07-16 22:05+0200\n" -"Last-Translator: Bruno Rafael \n" -"Language-Team: brazilian_portuguese \n" +"PO-Revision-Date: 2012-08-10 22:16+0200\n" +"Last-Translator: gilberto dos santos alves \n" +"Language-Team: Portuguese (Brazil) " +"\n" "Language: pt_BR\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" -"X-Generator: Weblate 1.1\n" +"X-Generator: Weblate 1.2\n" #: browse_foreigners.php:36 browse_foreigners.php:60 js/messages.php:354 #: libraries/DisplayResults.class.php:816 @@ -2175,7 +2176,7 @@ msgstr "Segundo" #: libraries/Advisor.class.php:67 #, php-format msgid "PHP threw following error: %s" -msgstr "" +msgstr "PHP apresentou o seguinte erro: %s" #: libraries/Advisor.class.php:89 #, php-format @@ -2185,7 +2186,7 @@ msgstr "" #: libraries/Advisor.class.php:106 #, php-format msgid "Failed calculating value for rule '%s'" -msgstr "" +msgstr "O Cálculo para a regra '%s' falhou" #: libraries/Advisor.class.php:125 #, php-format From 62ea33921dd2a66f03cf80c120b3cee8c10da332 Mon Sep 17 00:00:00 2001 From: Chanaka Indrajith Date: Sat, 11 Aug 2012 23:35:45 +0530 Subject: [PATCH 28/45] Sortable ability for server processlist --- server_status.php | 140 +++++++++++++++--- .../jquery/jquery-ui-1.8.16.custom.css | 2 +- 2 files changed, 118 insertions(+), 24 deletions(-) diff --git a/server_status.php b/server_status.php index da775b9d3f..f0cfe15b16 100644 --- a/server_status.php +++ b/server_status.php @@ -1257,6 +1257,45 @@ function printServerTraffic() } else { $full_text_link = 'server_status.php' . PMA_generate_common_url(array('full' => 1)); } + + // This array contains display name and real column name of each + // sortable column in the table + $sortable_columns = array( + array( + 'column_name' => __('ID'), + 'order_by_field' => 'Id' + ), + array( + 'column_name' => __('User'), + 'order_by_field' => 'User' + ), + array( + 'column_name' => __('Host'), + 'order_by_field' => 'Host' + ), + array( + 'column_name' => __('Database'), + 'order_by_field' => 'db' + ), + array( + 'column_name' => __('Command'), + 'order_by_field' => 'Command' + ), + array( + 'column_name' => __('Time'), + 'order_by_field' => 'Time' + ), + array( + 'column_name' => __('Status'), + 'order_by_field' => 'State' + ), + array( + 'column_name' => __('SQL query'), + 'order_by_field' => 'Info' + ) + ); + $sortable_columns_count = count($sortable_columns); + if (PMA_DRIZZLE) { $sql_query = "SELECT p.id AS Id, @@ -1269,47 +1308,102 @@ function printServerTraffic() " . ($show_full_sql ? 's.query' : 'left(p.info, ' . (int)$GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] . ')') . " AS Info FROM data_dictionary.PROCESSLIST p " . ($show_full_sql ? 'LEFT JOIN data_dictionary.SESSIONS s ON s.session_id = p.id' : ''); + if (!empty($_REQUEST['order_by_field']) + && !empty($_REQUEST['sort_order']) + ) { + $sql_query .= ' ORDER BY p.' . $_REQUEST['order_by_field'] . ' ' . $_REQUEST['sort_order']; + } } else { $sql_query = $show_full_sql ? 'SHOW FULL PROCESSLIST' : 'SHOW PROCESSLIST'; + if (!empty($_REQUEST['order_by_field']) + && !empty($_REQUEST['sort_order']) + ) { + $sql_query = 'SELECT * FROM `INFORMATION_SCHEMA`.`PROCESSLIST` ORDER BY `' + . $_REQUEST['order_by_field'] . '` ' . $_REQUEST['sort_order']; + } } + $result = PMA_DBI_query($sql_query); /** * Displays the page */ ?> - +
- - - - - - - - - - + + + - - <?php echo $show_full_sql ? __('Truncate Shown Queries') : __('Show Full Queries'); ?> - - - - + + + + + diff --git a/themes/pmahomme/jquery/jquery-ui-1.8.16.custom.css b/themes/pmahomme/jquery/jquery-ui-1.8.16.custom.css index a087015598..4abfd610b0 100644 --- a/themes/pmahomme/jquery/jquery-ui-1.8.16.custom.css +++ b/themes/pmahomme/jquery/jquery-ui-1.8.16.custom.css @@ -60,7 +60,7 @@ .ui-widget .ui-widget { font-size: 1em; } .ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: Verdana,Arial,sans-serif; font-size: 1em; } .ui-widget-content { border: 1px solid #aaaaaa; background: #ffffff url(images/ui-bg_flat_75_ffffff_40x100.png) 50% 50% repeat-x; color: #222222; } -.ui-widget-content a { color: #222222; } +.ui-widget-content a { color: #235A81; } .ui-widget-header { border: 1px solid #aaaaaa; background: #cccccc url(images/ui-bg_highlight-soft_75_cccccc_1x100.png) 50% 50% repeat-x; color: #222222; font-weight: bold; } .ui-widget-header a { color: #222222; } From d56335691cf1c1d8be3453904a885038da0a8c93 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Sun, 12 Aug 2012 06:40:36 +0530 Subject: [PATCH 29/45] [security] Properly escape content of tooltips in GIS visualization --- js/tbl_gis_visualization.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/tbl_gis_visualization.js b/js/tbl_gis_visualization.js index 3000e883c0..38722a474e 100644 --- a/js/tbl_gis_visualization.js +++ b/js/tbl_gis_visualization.js @@ -297,7 +297,7 @@ $(document).ready(function() { */ $('.polygon, .multipolygon, .point, .multipoint, .linestring, .multilinestring, ' + '.geometrycollection').live('mousemove', function(event) { - contents = $.trim($(this).attr('name')); + contents = $.trim(escapeHtml($(this).attr('name'))); $("#tooltip").remove(); if (contents != '') { $('
' + contents + '
').css({ From 20b196daf5a694eed69edd27807c1bd0f74cf61c Mon Sep 17 00:00:00 2001 From: Chanaka Indrajith Date: Sun, 12 Aug 2012 10:10:14 +0530 Subject: [PATCH 30/45] Fixed some code violations in PMA_DisplayResults class --- libraries/DisplayResults.class.php | 91 +++++++++++++++++------------- 1 file changed, 53 insertions(+), 38 deletions(-) diff --git a/libraries/DisplayResults.class.php b/libraries/DisplayResults.class.php index d67237f1a5..1b8eac4fdb 100644 --- a/libraries/DisplayResults.class.php +++ b/libraries/DisplayResults.class.php @@ -183,7 +183,7 @@ class PMA_DisplayResults */ public function __get($property) { - if(array_key_exists($property, $this->_property_array)) { + if (array_key_exists($property, $this->_property_array)) { return $this->_property_array[$property]; } } @@ -193,13 +193,13 @@ class PMA_DisplayResults * Set values for any property of this class * * @param string $property name of the property - * @param $value value to set + * @param any $value value to set * * @return void */ public function __set($property, $value) { - if(array_key_exists($property, $this->_property_array)) { + if (array_key_exists($property, $this->_property_array)) { $this->_property_array[$property] = $value; } } @@ -858,8 +858,8 @@ class PMA_DisplayResults $onsubmit = 'onsubmit="return ' . ($_SESSION['tmp_user_values']['pos'] - + $_SESSION['tmp_user_values']['max_rows'] - < $this->__get('_unlim_num_rows') + + $_SESSION['tmp_user_values']['max_rows'] + < $this->__get('_unlim_num_rows') && $this->__get('_num_rows') >= $_SESSION['tmp_user_values']['max_rows']) ? 'true' : 'false' . '"'; @@ -951,11 +951,12 @@ class PMA_DisplayResults /** * Get the headers of the results table * - * @param array &$is_display which elements to display - * @param array $analyzed_sql the analyzed query - * @param string $sort_expression sort expression - * @param string $sort_expression_nodirection sort expression without direction - * @param string $sort_direction sort direction + * @param array &$is_display which elements to display + * @param array $analyzed_sql the analyzed query + * @param string $sort_expression sort expression + * @param string $sort_expression_nodirection sort expression without direction + * @param string $sort_direction sort direction + * @param boolean $is_limited_display with limited operations or not * * @return string html content * @@ -2438,11 +2439,12 @@ class PMA_DisplayResults /** * Prepare the body of the results table * - * @param integer &$dt_result the link id associated to the query - * which results have to be displayed - * @param array &$is_display which elements to display - * @param array $map the list of relations - * @param array $analyzed_sql the analyzed query + * @param integer &$dt_result the link id associated to the query + * which results have to be displayed + * @param array &$is_display which elements to display + * @param array $map the list of relations + * @param array $analyzed_sql the analyzed query + * @param boolean $is_limited_display with limited operations or not * * @return string $table_body_html html content * @@ -2795,17 +2797,16 @@ class PMA_DisplayResults ) { $parsed_sql = PMA_SQP_parse($row[$i]); - $row[$i] = PMA_CommonFunctions::getInstance()->formatSql($parsed_sql, $row[$i]); + $row[$i] = PMA_CommonFunctions::getInstance()->formatSql( + $parsed_sql, $row[$i] + ); include_once $this->sytax_highlighting_column_info[strtolower($this->__get('_db'))][strtolower($this->__get('_table'))][strtolower($meta->name)][0]; $transformation_plugin = new $this->sytax_highlighting_column_info[strtolower($this->__get('_db'))][strtolower($this->__get('_table'))][strtolower($meta->name)][1](null); $transform_options = PMA_transformation_getOptions( - isset($mime_map[$meta->name] - ['transformation_options'] - ) - ? $mime_map[$meta->name] - ['transformation_options'] - : '' + isset($mime_map[$meta->name]['transformation_options']) + ? $mime_map[$meta->name]['transformation_options'] + : '' ); $meta->mimetype = str_replace( @@ -2822,7 +2823,9 @@ class PMA_DisplayResults && ($this->_isFieldNeedToLink(strtolower($meta->name))) ) { - $linking_url = $this->_getSpecialLinkUrl($row[$i], $row_info, strtolower($meta->name)); + $linking_url = $this->_getSpecialLinkUrl( + $row[$i], $row_info, strtolower($meta->name) + ); include_once "libraries/plugins/transformations/Text_Plain_Link.class.php"; $transformation_plugin = new Text_Plain_Link(null); @@ -3036,7 +3039,8 @@ class PMA_DisplayResults * * @return boolean */ - private function _isNeedToSytaxHighlight($field) { + private function _isNeedToSytaxHighlight($field) + { if (! empty($this->sytax_highlighting_column_info[strtolower($this->__get('_db'))][strtolower($this->__get('_table'))][strtolower($field)])) { return true; } @@ -3050,7 +3054,8 @@ class PMA_DisplayResults * * @return boolean */ - private function _isFieldNeedToLink($field) { + private function _isFieldNeedToLink($field) + { if (! empty($GLOBALS['special_schema_links'][strtolower($this->__get('_db'))][strtolower($this->__get('_table'))][$field])) { return true; } @@ -3071,14 +3076,19 @@ class PMA_DisplayResults { $linking_url_params = array(); - $link_relations = $GLOBALS['special_schema_links'][strtolower($this->__get('_db'))][strtolower($this->__get('_table'))][$field_name]; + $link_relations = $GLOBALS['special_schema_links'] + [strtolower($this->__get('_db'))] + [strtolower($this->__get('_table'))] + [$field_name]; if (! is_array($link_relations['link_param'])) { $linking_url_params[$link_relations['link_param']] = $column_value; } else { // Consider only the case of creating link for column field // sql query need to be pass as url param - $sql = 'SELECT `'.$column_value.'` FROM `'. $row_info[$link_relations['link_param'][1]] .'`.`'. $row_info[$link_relations['link_param'][2]] .'`'; + $sql = 'SELECT `'.$column_value.'` FROM `' + . $row_info[$link_relations['link_param'][1]] .'`.`' + . $row_info[$link_relations['link_param'][2]] .'`'; $linking_url_params[$link_relations['link_param'][0]] = $sql; } @@ -3090,13 +3100,16 @@ class PMA_DisplayResults // If param_info is an array, set the key and value // from that array if (is_array($new_param['param_info'])) { - $linking_url_params[$new_param['param_info'][0]] = $new_param['param_info'][1]; + $linking_url_params[$new_param['param_info'][0]] + = $new_param['param_info'][1]; } else { - $linking_url_params[$new_param['param_info']] = $row_info[strtolower($new_param['column_name'])]; + + $linking_url_params[$new_param['param_info']] + = $row_info[strtolower($new_param['column_name'])]; // Special case 1 - when executing routines, according // to the type of the routine, url param changes - if (!empty($row_info['routine_type'])){ + if (!empty($row_info['routine_type'])) { if (strtolower($row_info['routine_type']) == self::ROUTINE_PROCEDURE) { $linking_url_params['execute_routine'] = 1; } else if (strtolower($row_info['routine_type']) == self::ROUTINE_FUNCTION) { @@ -3109,7 +3122,8 @@ class PMA_DisplayResults } - return $link_relations['default_page'] . PMA_generate_common_url($linking_url_params); + return $link_relations['default_page'] + . PMA_generate_common_url($linking_url_params); } @@ -3644,7 +3658,6 @@ class PMA_DisplayResults if ((PMA_strlen($column) > $GLOBALS['cfg']['LimitChars']) && ($_SESSION['tmp_user_values']['display_text'] == self::DISPLAY_PARTIAL_TEXT) && ! $this->_isNeedToSytaxHighlight(strtolower($meta->name)) - ) { $column = PMA_substr($column, 0, $GLOBALS['cfg']['LimitChars']) . '...'; @@ -4434,12 +4447,13 @@ class PMA_DisplayResults * Prepare a table of results returned by a SQL query. * This function is called by the "sql.php" script. * - * @param integer &$dt_result the link id associated to the query - * which results have to be displayed - * @param array &$the_disp_mode the display mode - * @param array $analyzed_sql the analyzed query + * @param integer &$dt_result the link id associated to the query + * which results have to be displayed + * @param array &$the_disp_mode the display mode + * @param array $analyzed_sql the analyzed query + * @param boolean $is_limited_display With limited operations or not * - * @return sting Generated HTML content for resulted table + * @return sting $table_html Generated HTML content for resulted table * * @access public * @@ -5070,7 +5084,8 @@ class PMA_DisplayResults $links_html .= "\n"; $links_html .= '' . "\n"; + .' value="' . htmlspecialchars($this->__get('_sql_query')) . '" />' + . "\n"; if (! empty($url_query)) { $links_html .= ' Date: Thu, 9 Aug 2012 13:13:08 -0400 Subject: [PATCH 31/45] Fix for Empty and Drop vulnerabilities on db Structure and Operations, see PMASA-2012-4 --- js/db_structure.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/db_structure.js b/js/db_structure.js index 4affd75bd2..5938ae40cc 100644 --- a/js/db_structure.js +++ b/js/db_structure.js @@ -75,7 +75,7 @@ $(document).ready(function() { /** * @var question String containing the question to be asked for confirmation */ - var question = 'TRUNCATE ' + curr_table_name; + var question = 'TRUNCATE ' + escapeHtml(curr_table_name); $this_anchor.PMA_confirm(question, $this_anchor.attr('href'), function(url) { @@ -125,7 +125,7 @@ $(document).ready(function() { /** * @var question String containing the question to be asked for confirmation */ - var question = 'DROP TABLE ' + curr_table_name; + var question = 'DROP TABLE ' + escapeHtml(curr_table_name); $this_anchor.PMA_confirm(question, $this_anchor.attr('href'), function(url) { From e094f34bed5ef3fd9a4a3cd08e01ff59a260c730 Mon Sep 17 00:00:00 2001 From: Dieter Adriaenssens Date: Fri, 10 Aug 2012 16:04:54 +0200 Subject: [PATCH 32/45] [security] properly escape name of newly created table, see PMASA-2012-4 --- tbl_create.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tbl_create.php b/tbl_create.php index 4d3171ad99..c402386583 100644 --- a/tbl_create.php +++ b/tbl_create.php @@ -287,7 +287,9 @@ if (isset($_REQUEST['do_save_data'])) { $new_table_string .= '
' . "\n"; $new_table_string .= '
+
+ + onmouseout="$('.soimg').toggle()" onmouseover="$('.soimg').toggle()" + + > + + + + + Descending + Ascending + + + + + + + <?php echo $show_full_sql ? __('Truncate Shown Queries') : __('Show Full Queries'); ?> + + + +
'; - $new_table_string .= ''. $table . ''; + $new_table_string .= '' + . htmlspecialchars($table) . ''; if (PMA_Tracker::isActive()) { $truename = str_replace(' ', ' ', htmlspecialchars($table)); From cc97d82fd15771dfee07445323db3473c2e2da60 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Sun, 12 Aug 2012 09:14:23 -0400 Subject: [PATCH 33/45] 3.4.11.1 release --- ChangeLog | 3 +++ Documentation.html | 4 ++-- README | 2 +- libraries/Config.class.php | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index f7d873a5c7..6ad3a07025 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,9 @@ phpMyAdmin - ChangeLog ====================== +3.4.11.1 (2012-08-12) +- [security] Fixed XSS vulnerabilities, see PMASA-2012-4 + 3.4.11.0 (2012-04-14) - bug #3486970 [import] Exception on XML import - bug #3488777 [navi] $cfg['ShowTooltipAliasTB'] and blank names in navigation diff --git a/Documentation.html b/Documentation.html index 30568fc3c7..461b2eae2b 100644 --- a/Documentation.html +++ b/Documentation.html @@ -9,7 +9,7 @@ vim: expandtab ts=4 sw=4 sts=4 tw=78 - phpMyAdmin 3.4.11 - Documentation + phpMyAdmin 3.4.11.1 - Documentation @@ -17,7 +17,7 @@ vim: expandtab ts=4 sw=4 sts=4 tw=78 diff --git a/README b/README index b6ff898fb0..33d529a98a 100644 --- a/README +++ b/README @@ -1,7 +1,7 @@ phpMyAdmin - Readme =================== -Version 3.4.11 +Version 3.4.11.1 A set of PHP-scripts to manage MySQL over the web. diff --git a/libraries/Config.class.php b/libraries/Config.class.php index 8f815b83b5..fe6528800f 100644 --- a/libraries/Config.class.php +++ b/libraries/Config.class.php @@ -96,7 +96,7 @@ class PMA_Config */ function checkSystem() { - $this->set('PMA_VERSION', '3.4.11'); + $this->set('PMA_VERSION', '3.4.11.1'); /** * @deprecated */ From 6f200703a3f9e16126822b6add2138f93cec2aac Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Sun, 12 Aug 2012 09:17:02 -0400 Subject: [PATCH 34/45] Fix merge conflicts --- ChangeLog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ChangeLog b/ChangeLog index 059c87e895..c00a0e0479 100644 --- a/ChangeLog +++ b/ChangeLog @@ -116,6 +116,9 @@ phpMyAdmin - ChangeLog - bug #3497151 [interface] Duplicate inline query edit box - bug #3504567 [mime] Description of the transformation missing in the tooltip +3.4.11.1 (2012-08-12) +- [security] Fixed XSS vulnerabilities, see PMASA-2012-4 + 3.4.11.0 (2012-04-14) - bug #3486970 [import] Exception on XML import - bug #3488777 [navi] $cfg['ShowTooltipAliasTB'] and blank names in navigation From 5289a032cec12ef9f840652a84efc0af7f6c9bbe Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Sun, 12 Aug 2012 09:22:10 -0400 Subject: [PATCH 35/45] 3.5.2.2 release --- ChangeLog | 3 +++ Documentation.html | 4 ++-- README | 2 +- libraries/Config.class.php | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index c00a0e0479..bb2882b3c9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,9 @@ phpMyAdmin - ChangeLog ====================== +3.5.2.2 (2012-08-12) +- [security] Fixed XSS vulnerabilities, see PMASA-2012-4 + 3.5.2.1 (2012-08-03) - [security] Fixed local path disclosure vulnerability, see PMASA-2012-3 diff --git a/Documentation.html b/Documentation.html index 2ef68212e8..5ae012e845 100644 --- a/Documentation.html +++ b/Documentation.html @@ -9,7 +9,7 @@ vim: expandtab ts=4 sw=4 sts=4 tw=78 - phpMyAdmin 3.5.2.1 - Documentation + phpMyAdmin 3.5.2.2 - Documentation @@ -17,7 +17,7 @@ vim: expandtab ts=4 sw=4 sts=4 tw=78 diff --git a/README b/README index 234d78db36..abba0ce36e 100644 --- a/README +++ b/README @@ -1,7 +1,7 @@ phpMyAdmin - Readme =================== -Version 3.5.2.1 +Version 3.5.2.2 A set of PHP-scripts to manage MySQL over the web. diff --git a/libraries/Config.class.php b/libraries/Config.class.php index e37ff5e8c4..96c9477c7e 100644 --- a/libraries/Config.class.php +++ b/libraries/Config.class.php @@ -98,7 +98,7 @@ class PMA_Config */ function checkSystem() { - $this->set('PMA_VERSION', '3.5.2.1'); + $this->set('PMA_VERSION', '3.5.2.2'); /** * @deprecated */ From fde2a58babca31808f43eed0ff9f24d3c40e208f Mon Sep 17 00:00:00 2001 From: Chanaka Indrajith Date: Sun, 12 Aug 2012 23:56:31 +0530 Subject: [PATCH 36/45] Improve some tests for functions in PMA_DisplayResults class --- test/classes/PMA_DisplayResults_test.php | 257 ++++++++++++++++++++++- 1 file changed, 256 insertions(+), 1 deletion(-) diff --git a/test/classes/PMA_DisplayResults_test.php b/test/classes/PMA_DisplayResults_test.php index d47c2e5ffc..f259e879ba 100644 --- a/test/classes/PMA_DisplayResults_test.php +++ b/test/classes/PMA_DisplayResults_test.php @@ -1397,6 +1397,261 @@ class PMA_DisplayResults_test extends PHPUnit_Framework_TestCase ) ); } + + + /** + * Data provider for testIsNeedToSytaxHighlight + * + * @return array parameters and output + */ + public function dataProviderForTestIsNeedToSytaxHighlight() + { + return array( + array( + 'information_schema', + 'processlist', + array( + 'information_schema' => array( + 'processlist' => array( + 'info' => array( + 'libraries/plugins/transformations/Text_Plain_Formatted.class.php', + 'Text_Plain_Formatted', + 'Text_Plain' + ) + ) + ) + ), + 'info', + true + ), + array( + 'incorrect_database', + 'processlist', + array( + 'information_schema' => array( + 'processlist' => array( + 'info' => array( + 'libraries/plugins/transformations/Text_Plain_Formatted.class.php', + 'Text_Plain_Formatted', + 'Text_Plain' + ) + ) + ) + ), + 'info', + false + ) + ); + } + + + /** + * Test _isNeedToSytaxHighlight + * + * @param string $db the database name + * @param string $table the table name + * @param array $data predifined data of columns need to sytax highlighted + * @param string $field the field name + * @param boolean $output output of _isNeedToSytaxHighlight + * + * @dataProvider dataProviderForTestIsNeedToSytaxHighlight + */ + public function testIsNeedToSytaxHighlight($db, $table, $data, $field, $output) + { + $this->object->__set('_db', $db); + $this->object->__set('_table', $table); + $this->object->__set('sytax_highlighting_column_info', $data); + + + $this->assertEquals( + $output, + $this->_callPrivateFunction( + '_isNeedToSytaxHighlight', + array($field) + ) + ); + + } + + + /** + * Data provider for testIsFieldNeedToLink + * + * @return array parameters and output + */ + public function dataProviderForTestIsFieldNeedToLink() + { + return array( + array( + 'mysql', + 'proc', + 'db', + true + ), + array( + 'incorrect_database', + 'processlist', + 'info', + false + ) + ); + } + + + /** + * Test _isFieldNeedToLink + * + * @param string $db the database name + * @param string $table the table name + * @param string $field the field name + * @param boolean $output output of _isFieldNeedToLink + * + * @dataProvider dataProviderForTestIsFieldNeedToLink + */ + public function testIsFieldNeedToLink($db, $table, $field, $output) + { + + $GLOBALS['special_schema_links'] = array( + 'mysql' => array( + 'proc' => array( + 'db' => array( + 'link_param' => 'db', + 'default_page' => 'index.php' + ) - + ) + ) + ); + + $this->object->__set('_db', $db); + $this->object->__set('_table', $table); + + $this->assertEquals( + $output, + $this->_callPrivateFunction( + '_isFieldNeedToLink', + array($field) + ) + ); + + } + + + /** + * Data provider for testGetSpecialLinkUrl + * + * @return array parameters and output + */ + public function dataProviderForTestGetSpecialLinkUrl() + { + return array( + array( + 'information_schema', + 'routines', + 'circumference', + array( + 'routine_name' => 'circumference', + 'routine_schema' => 'data', + 'routine_type' => 'FUNCTION' + ), + 'routine_name', + 'db_routines.php?item_name=circumference&db=data&execute_dialog=1&item_type=FUNCTION&lang=en&token=token' + ), + array( + 'information_schema', + 'routines', + 'area', + array( + 'routine_name' => 'area', + 'routine_schema' => 'data', + 'routine_type' => 'PROCEDURE' + ), + 'routine_name', + 'db_routines.php?item_name=area&db=data&execute_routine=1&item_type=PROCEDURE&lang=en&token=token' + ), + array( + 'information_schema', + 'columns', + 'CHARACTER_SET_NAME', + array( + 'table_schema' => 'information_schema', + 'table_name' => 'CHARACTER_SETS' + ), + 'column_name', + 'index.php?sql_query=SELECT+%60CHARACTER_SET_NAME%60+FROM+%60information_schema%60.%60CHARACTER_SETS%60&db=information_schema&test_name=value&lang=en&token=token' + ) + ); + } + + + /** + * Test _getSpecialLinkUrl + * + * @param string $db the database name + * @param string $table the table name + * @param string $column_value column value + * @param array $row_info information about row + * @param string $field_name column name + * @param boolean $output output of _getSpecialLinkUrl + * + * @dataProvider dataProviderForTestGetSpecialLinkUrl + */ + public function testGetSpecialLinkUrl( + $db, $table, $column_value, $row_info, $field_name, $output + ) { + + $GLOBALS['special_schema_links'] = array( + 'information_schema' => array( + 'routines' => array( + 'routine_name' => array( + 'link_param' => 'item_name', + 'link_dependancy_params' => array( + 0 => array( + 'param_info' => 'db', + 'column_name' => 'routine_schema' + ), + 1 => array( + 'param_info' => 'item_type', + 'column_name' => 'routine_type' + ) + ), + 'default_page' => 'db_routines.php' + ) + ), + 'columns' => array( + 'column_name' => array( + 'link_param' => array( + 'sql_query', + 'table_schema', + 'table_name' + ), + 'link_dependancy_params' => array( + 0 => array( + 'param_info' => 'db', + 'column_name' => 'table_schema' + ), + 1 => array( + 'param_info' => array('test_name', 'value') + ) + ), + 'default_page' => 'index.php' + ) + ) + ) + ); + + $this->object->__set('_db', $db); + $this->object->__set('_table', $table); + + $this->assertEquals( + $output, + $this->_callPrivateFunction( + '_getSpecialLinkUrl', + array($column_value, $row_info, $field_name) + ) + ); + + } + + } From 29ea192a8101e9c5effde1fa674d6592973a9c48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 13 Aug 2012 07:19:37 +0200 Subject: [PATCH 37/45] These look obviously wrong --- po/th.po | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/po/th.po b/po/th.po index cdd277c2c0..684eb90cb4 100644 --- a/po/th.po +++ b/po/th.po @@ -3371,7 +3371,7 @@ msgid "" msgstr "" #: libraries/Types.class.php:331 libraries/Types.class.php:729 -#, php-format +#, php-format, fuzzy msgid "" "A variable-length (%s) string, the effective maximum length is subject to " "the maximum row size" @@ -3380,6 +3380,7 @@ msgstr "" "เพื่อสร้างอย่างใดอย่างหนึ่ง" #: libraries/Types.class.php:333 +#, fuzzy msgid "" "A TEXT column with a maximum length of 255 (2^8 - 1) characters, stored with " "a one-byte prefix indicating the length of the value in bytes" From c26356e9cadef294b1b9a958f5b8d3514f6e4293 Mon Sep 17 00:00:00 2001 From: Alex Marin Date: Mon, 13 Aug 2012 09:34:06 +0300 Subject: [PATCH 38/45] oop: fix properties object in plugin_interface --- libraries/plugin_interface.lib.php | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/libraries/plugin_interface.lib.php b/libraries/plugin_interface.lib.php index d0b9c45aaf..b3a1e93b47 100644 --- a/libraries/plugin_interface.lib.php +++ b/libraries/plugin_interface.lib.php @@ -189,7 +189,8 @@ function PMA_pluginGetChoice($section, $name, &$list, $cfgname = null) $ret .= ' selected="selected"'; } - if (method_exists($plugin->getProperties(), 'getText')) { + $properties = $plugin->getProperties(); + if ($properties != null) { $text = $plugin->getProperties()->getText(); } $ret .= ' value="' . $plugin_name . '">' @@ -242,8 +243,13 @@ function PMA_pluginGetOneOption( // for main groups $ret .= '
'; - if ($propertyGroup->getText() != null) { - $ret .= '

' . PMA_getString($propertyGroup->getText()) . '

'; + + if (method_exists($propertyGroup, 'getText')) { + $text = $propertyGroup->getText(); + } + + if ($text != null) { + $ret .= '

' . PMA_getString($text) . '

'; } $ret .= '
    '; } @@ -447,17 +453,20 @@ function PMA_pluginGetOptions($section, &$list) $default = PMA_pluginGetDefault('Export', 'format'); // Options for plugins that support them foreach ($list as $plugin) { + $properties = $plugin->getProperties(); + if ($properties != null) { + $text = $properties->getText(); + $options = $properties->getOptions(); + } + $plugin_name = strtolower(substr(get_class($plugin), strlen($section))); $ret .= '
    '; - $ret .= '

    ' . PMA_getString($plugin->getProperties()->getText()) - . '

    '; + $ret .= '

    ' . PMA_getString($text) . '

    '; $no_options = true; - if ($plugin->getProperties()->getOptions() != null - && count($plugin->getProperties()->getOptions()) > 0 - ) { - foreach ($plugin->getProperties()->getOptions()->getProperties() + if ($options != null && count($options) > 0) { + foreach ($options->getProperties() as $propertyMainGroup ) { // check for hidden properties From 8ebbab0c30f5808913eea8850ba63c720746f75f Mon Sep 17 00:00:00 2001 From: Alex Marin Date: Mon, 13 Aug 2012 09:42:22 +0300 Subject: [PATCH 39/45] oop: fix getTableDefStandIn for ExportSql --- libraries/plugins/export/ExportSql.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/plugins/export/ExportSql.class.php b/libraries/plugins/export/ExportSql.class.php index 9a0a38add6..43168a7922 100644 --- a/libraries/plugins/export/ExportSql.class.php +++ b/libraries/plugins/export/ExportSql.class.php @@ -705,7 +705,7 @@ class ExportSql extends ExportPlugin } } $create_query = 'CREATE DATABASE ' - . (isset($GLOBALS['sql_backquotes']) + . (isset($GLOBALS['sql_backquotes']) ? $common_functions->backquote($db) : $db); $collation = PMA_getDbCollation($db); if (PMA_DRIZZLE) { @@ -1395,7 +1395,7 @@ class ExportSql extends ExportPlugin ) . $this->_exportComment(); // export a stand-in definition to resolve view dependencies - $dump .= getTableDefStandIn($db, $table, $crlf); + $dump .= $this->getTableDefStandIn($db, $table, $crlf); } // end switch // this one is built by getTableDef() to use in table copy/move From bd18f6fb26e03187eda5d2359d1f2cdc3e7786cf Mon Sep 17 00:00:00 2001 From: shanyan baishui Date: Mon, 13 Aug 2012 10:40:13 +0200 Subject: [PATCH 40/45] Translated using Weblate. --- po/zh_CN.po | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/po/zh_CN.po b/po/zh_CN.po index 086163c645..5027e12607 100644 --- a/po/zh_CN.po +++ b/po/zh_CN.po @@ -4,10 +4,10 @@ msgstr "" "Project-Id-Version: phpMyAdmin 4.0.0-dev\n" "Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2012-08-10 12:59+0200\n" -"PO-Revision-Date: 2012-08-04 06:39+0200\n" +"PO-Revision-Date: 2012-08-13 10:40+0200\n" "Last-Translator: shanyan baishui \n" -"Language-Team: Chinese (China) \n" +"Language-Team: Chinese (China) " +"\n" "Language: zh_CN\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -1367,13 +1367,11 @@ msgid "Total time:" msgstr "总时间:" #: js/messages.php:188 -#, fuzzy #| msgid "Profiling" msgid "Profiling results" -msgstr "概要" +msgstr "性能分析结果" #: js/messages.php:189 -#, fuzzy #| msgid "Table" msgctxt "Display format" msgid "Table" @@ -2255,11 +2253,11 @@ msgstr "连接到 SQL 校验器失败!" #: libraries/CommonFunctions.class.php:1256 #: libraries/config/messages.inc.php:491 msgid "Explain SQL" -msgstr "解释 SQL" +msgstr "解析 SQL" #: libraries/CommonFunctions.class.php:1264 msgid "Skip Explain SQL" -msgstr "略过解释 SQL" +msgstr "略过解析 SQL" #: libraries/CommonFunctions.class.php:1303 msgid "Without PHP Code" @@ -2300,7 +2298,7 @@ msgstr "快速编辑" #: libraries/CommonFunctions.class.php:1480 sql.php:1067 msgid "Profiling" -msgstr "概要" +msgstr "性能分析" #. l10n: Short week day name #: libraries/CommonFunctions.class.php:1750 From bb982053899718f94471ce3f5728ab963c11dda3 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Mon, 13 Aug 2012 07:51:35 -0400 Subject: [PATCH 41/45] Fix merge conflicts for security patch --- js/db_structure.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/js/db_structure.js b/js/db_structure.js index 8b0629713e..223e02ea12 100644 --- a/js/db_structure.js +++ b/js/db_structure.js @@ -307,7 +307,7 @@ $(function() { */ var question = PMA_messages.strTruncateTableStrongWarning + ' ' - + $.sprintf(PMA_messages.strDoYouReally, 'TRUNCATE ' + curr_table_name); + + $.sprintf(PMA_messages.strDoYouReally, 'TRUNCATE ' + escapeHtml(curr_table_name)); $this_anchor.PMA_confirm(question, $this_anchor.attr('href'), function(url) { @@ -366,10 +366,10 @@ $(function() { if (! is_view) { question = PMA_messages.strDropTableStrongWarning + ' ' - + $.sprintf(PMA_messages.strDoYouReally, 'DROP TABLE ' + curr_table_name); + + $.sprintf(PMA_messages.strDoYouReally, 'DROP TABLE ' + escapeHtml(curr_table_name)); } else { question = - $.sprintf(PMA_messages.strDoYouReally, 'DROP VIEW ' + curr_table_name); + $.sprintf(PMA_messages.strDoYouReally, 'DROP VIEW ' + escapeHtml(curr_table_name)); } $this_anchor.PMA_confirm(question, $this_anchor.attr('href'), function(url) { From aa3071a95d4c2e3e5bec3e2e19230c229f548f47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 13 Aug 2012 14:13:25 +0200 Subject: [PATCH 42/45] Saner color for error messages (and consistent with default theme) --- setup/styles.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup/styles.css b/setup/styles.css index c6798c74e2..9f2d2ec943 100644 --- a/setup/styles.css +++ b/setup/styles.css @@ -176,7 +176,7 @@ div.notice { .error { border: 1px solid maroon !important; color: #000; - background: #fcf; + background: pink; } h1.error, From cabc50d872e1e4c401f831ee117a8d8a087b95be Mon Sep 17 00:00:00 2001 From: shanyan baishui Date: Mon, 13 Aug 2012 12:11:06 +0200 Subject: [PATCH 43/45] Translated using Weblate. --- po/zh_CN.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/po/zh_CN.po b/po/zh_CN.po index 5027e12607..676fdff124 100644 --- a/po/zh_CN.po +++ b/po/zh_CN.po @@ -4,7 +4,7 @@ msgstr "" "Project-Id-Version: phpMyAdmin 4.0.0-dev\n" "Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2012-08-10 12:59+0200\n" -"PO-Revision-Date: 2012-08-13 10:40+0200\n" +"PO-Revision-Date: 2012-08-13 12:11+0200\n" "Last-Translator: shanyan baishui \n" "Language-Team: Chinese (China) " "\n" @@ -1375,7 +1375,7 @@ msgstr "性能分析结果" #| msgid "Table" msgctxt "Display format" msgid "Table" -msgstr "表" +msgstr "表格" #: js/messages.php:190 msgid "Chart" From 30ed38d00c557530bbcfc2ab58cd4002fe74cdcf Mon Sep 17 00:00:00 2001 From: shanyan baishui Date: Mon, 13 Aug 2012 12:11:05 +0200 Subject: [PATCH 44/45] Translated using Weblate. --- po/zh_CN.po | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/po/zh_CN.po b/po/zh_CN.po index 8861c9a550..4da3de4bc4 100644 --- a/po/zh_CN.po +++ b/po/zh_CN.po @@ -4,7 +4,7 @@ msgstr "" "Project-Id-Version: phpMyAdmin 3.5.2-dev\n" "Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2012-06-04 13:42+0200\n" -"PO-Revision-Date: 2012-08-04 06:39+0200\n" +"PO-Revision-Date: 2012-08-13 12:11+0200\n" "Last-Translator: shanyan baishui \n" "Language-Team: Chinese (China) " "\n" @@ -1574,17 +1574,15 @@ msgid "Total time:" msgstr "总时间:" #: js/messages.php:192 -#, fuzzy #| msgid "Profiling" msgid "Profiling results" -msgstr "概要" +msgstr "性能分析结果" #: js/messages.php:193 -#, fuzzy #| msgid "Table" msgctxt "Display format" msgid "Table" -msgstr "表" +msgstr "表格" #: js/messages.php:194 msgid "Chart" @@ -2869,11 +2867,11 @@ msgstr "连接到 SQL 校验器失败!" #: libraries/common.lib.php:1171 libraries/config/messages.inc.php:485 msgid "Explain SQL" -msgstr "解释 SQL" +msgstr "解析 SQL" #: libraries/common.lib.php:1175 msgid "Skip Explain SQL" -msgstr "略过解释 SQL" +msgstr "略过解析 SQL" #: libraries/common.lib.php:1210 msgid "Without PHP Code" @@ -2907,7 +2905,7 @@ msgstr "快速编辑" #: libraries/common.lib.php:1373 sql.php:895 msgid "Profiling" -msgstr "概要" +msgstr "性能分析" #. l10n: Short week day name #: libraries/common.lib.php:1634 From dae3543da1361cbfe3cf3b8a8cfeedfabbe34b1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 13 Aug 2012 20:17:59 +0200 Subject: [PATCH 45/45] Various coding style improvements (issue #88) --- libraries/plugins/export/ExportSql.class.php | 139 +++++++++++++++---- 1 file changed, 109 insertions(+), 30 deletions(-) diff --git a/libraries/plugins/export/ExportSql.class.php b/libraries/plugins/export/ExportSql.class.php index b822c8c7d6..305a830100 100644 --- a/libraries/plugins/export/ExportSql.class.php +++ b/libraries/plugins/export/ExportSql.class.php @@ -693,7 +693,11 @@ class ExportSql extends ExportPlugin global $crlf; $common_functions = PMA_CommonFunctions::getInstance(); - $compat = (isset($GLOBALS['sql_compatibility'])) ? $GLOBALS['sql_compatibility'] : 'NONE'; + if (isset($GLOBALS['sql_compatibility'])) { + $compat = $GLOBALS['sql_compatibility']; + } else { + $compat = 'NONE'; + } if (isset($GLOBALS['sql_drop_database'])) { if (! PMA_exportOutputHandler( 'DROP DATABASE ' @@ -729,7 +733,8 @@ class ExportSql extends ExportPlugin || PMA_DRIZZLE) ) { $result = PMA_exportOutputHandler( - 'USE ' . $common_functions->backquote_compat($db, $compat) . ';' . $crlf + 'USE ' . $common_functions->backquote_compat($db, $compat) + . ';' . $crlf ); } else { $result = PMA_exportOutputHandler('USE ' . $db . ';' . $crlf); @@ -747,7 +752,11 @@ class ExportSql extends ExportPlugin */ public function exportDBHeader($db) { - $compat = (isset($GLOBALS['sql_compatibility'])) ? $GLOBALS['sql_compatibility'] : 'NONE'; + if (isset($GLOBALS['sql_compatibility'])) { + $compat = $GLOBALS['sql_compatibility']; + } else { + $compat = 'NONE'; + } $head = $this->_exportComment() . $this->_exportComment( __('Database') . ': ' @@ -894,7 +903,11 @@ class ExportSql extends ExportPlugin $auto_increment = ''; $new_crlf = $crlf; - $compat = (isset($GLOBALS['sql_compatibility'])) ? $GLOBALS['sql_compatibility'] : 'NONE'; + if (isset($GLOBALS['sql_compatibility'])) { + $compat = $GLOBALS['sql_compatibility']; + } else { + $compat = 'NONE'; + } // need to use PMA_DBI_QUERY_STORE with PMA_DBI_num_rows() in mysqli $result = PMA_DBI_query( @@ -1055,33 +1068,88 @@ class ExportSql extends ExportPlugin // In MSSQL // 1. DATE field doesn't exists, we will use DATETIME instead // 2. UNSIGNED attribute doesn't exist - // 3. No length on INT, TINYINT, SMALLINT, BIGINT and no precision on FLOAT fields + // 3. No length on INT, TINYINT, SMALLINT, BIGINT and no precision on + // FLOAT fields // 4. No KEY and INDEX inside CREATE TABLE // 5. DOUBLE field doesn't exists, we will use FLOAT instead if ($compat == 'MSSQL') { - //first we need to replace all lines ended with '" DATE ...,\n' - //last preg_replace preserve us from situation with date text inside DEFAULT field value - $create_query = preg_replace( "/\" date DEFAULT NULL(,)?\n/", '" datetime DEFAULT NULL$1'."\n", $create_query); - $create_query = preg_replace( "/\" date NOT NULL(,)?\n/", '" datetime NOT NULL$1'."\n", $create_query); - $create_query = preg_replace( '/" date NOT NULL DEFAULT \'([^\'])/', '" datetime NOT NULL DEFAULT \'$1', $create_query); + // first we need to replace all lines ended with '" DATE ...,\n' + // last preg_replace preserve us from situation with date text + // inside DEFAULT field value + $create_query = preg_replace( + "/\" date DEFAULT NULL(,)?\n/", + '" datetime DEFAULT NULL$1' . "\n", + $create_query + ); + $create_query = preg_replace( + "/\" date NOT NULL(,)?\n/", + '" datetime NOT NULL$1' . "\n", + $create_query + ); + $create_query = preg_replace( + '/" date NOT NULL DEFAULT \'([^\'])/', + '" datetime NOT NULL DEFAULT \'$1', + $create_query + ); - //next we need to replace all lines ended with ') UNSIGNED ...,' - //last preg_replace preserve us from situation with unsigned text inside DEFAULT field value - $create_query = preg_replace( "/\) unsigned NOT NULL(,)?\n/", ') NOT NULL$1'."\n", $create_query); - $create_query = preg_replace( "/\) unsigned DEFAULT NULL(,)?\n/", ') DEFAULT NULL$1'."\n", $create_query); - $create_query = preg_replace( '/\) unsigned NOT NULL DEFAULT \'([^\'])/', ') NOT NULL DEFAULT \'$1', $create_query); + // next we need to replace all lines ended with ') UNSIGNED ...,' + // last preg_replace preserve us from situation with unsigned text + // inside DEFAULT field value + $create_query = preg_replace( + "/\) unsigned NOT NULL(,)?\n/", + ') NOT NULL$1' . "\n", + $create_query + ); + $create_query = preg_replace( + "/\) unsigned DEFAULT NULL(,)?\n/", + ') DEFAULT NULL$1' . "\n", + $create_query + ); + $create_query = preg_replace( + '/\) unsigned NOT NULL DEFAULT \'([^\'])/', + ') NOT NULL DEFAULT \'$1', + $create_query + ); - // we need to replace all lines ended with '" INT|TINYINT([0-9]{1,}) ...,' - //last preg_replace preserve us from situation with int([0-9]{1,}) text inside DEFAULT field value - $create_query = preg_replace( '/" (int|tinyint|smallint|bigint)\([0-9]+\) DEFAULT NULL(,)?\n/', '" $1 DEFAULT NULL$2'."\n", $create_query); - $create_query = preg_replace( '/" (int|tinyint|smallint|bigint)\([0-9]+\) NOT NULL(,)?\n/', '" $1 NOT NULL$2'."\n", $create_query); - $create_query = preg_replace( '/" (int|tinyint|smallint|bigint)\([0-9]+\) NOT NULL DEFAULT \'([^\'])/', '" $1 NOT NULL DEFAULT \'$2', $create_query); + // we need to replace all lines ended with + // '" INT|TINYINT([0-9]{1,}) ...,' last preg_replace preserve us + // from situation with int([0-9]{1,}) text inside DEFAULT field + // value + $create_query = preg_replace( + '/" (int|tinyint|smallint|bigint)\([0-9]+\) DEFAULT NULL(,)?\n/', + '" $1 DEFAULT NULL$2' . "\n", + $create_query + ); + $create_query = preg_replace( + '/" (int|tinyint|smallint|bigint)\([0-9]+\) NOT NULL(,)?\n/', + '" $1 NOT NULL$2' . "\n", + $create_query + ); + $create_query = preg_replace( + '/" (int|tinyint|smallint|bigint)\([0-9]+\) NOT NULL DEFAULT \'([^\'])/', + '" $1 NOT NULL DEFAULT \'$2', + $create_query + ); - // we need to replace all lines ended with '" FLOAT|DOUBLE([0-9,]{1,}) ...,' - //last preg_replace preserve us from situation with float([0-9,]{1,}) text inside DEFAULT field value - $create_query = preg_replace( '/" (float|double)(\([0-9]+,[0-9,]+\))? DEFAULT NULL(,)?\n/', '" float DEFAULT NULL$3'."\n", $create_query); - $create_query = preg_replace( '/" (float|double)(\([0-9,]+,[0-9,]+\))? NOT NULL(,)?\n/', '" float NOT NULL$3'."\n", $create_query); - $create_query = preg_replace( '/" (float|double)(\([0-9,]+,[0-9,]+\))? NOT NULL DEFAULT \'([^\'])/', '" float NOT NULL DEFAULT \'$3', $create_query); + // we need to replace all lines ended with + // '" FLOAT|DOUBLE([0-9,]{1,}) ...,' + // last preg_replace preserve us from situation with + // float([0-9,]{1,}) text inside DEFAULT field value + $create_query = preg_replace( + '/" (float|double)(\([0-9]+,[0-9,]+\))? DEFAULT NULL(,)?\n/', + '" float DEFAULT NULL$3' . "\n", + $create_query + ); + $create_query = preg_replace( + '/" (float|double)(\([0-9,]+,[0-9,]+\))? NOT NULL(,)?\n/', + '" float NOT NULL$3' . "\n", + $create_query + ); + $create_query = preg_replace( + '/" (float|double)(\([0-9,]+,[0-9,]+\))? NOT NULL DEFAULT \'([^\'])/', + '" float NOT NULL DEFAULT \'$3', + $create_query + ); // @todo remove indexes from CREATE TABLE } @@ -1152,12 +1220,15 @@ class ExportSql extends ExportPlugin // let's do the work $sql_constraints_query .= 'ALTER TABLE ' - . $common_functions->backquote_compat($table, $compat) . $crlf; + . $common_functions->backquote_compat($table, $compat) + . $crlf; $sql_constraints .= 'ALTER TABLE ' - . $common_functions->backquote_compat($table, $compat) . $crlf; + . $common_functions->backquote_compat($table, $compat) + . $crlf; $sql_drop_foreign_keys .= 'ALTER TABLE ' . $common_functions->backquote_compat($db, $compat) . '.' - . $common_functions->backquote_compat($table, $compat) . $crlf; + . $common_functions->backquote_compat($table, $compat) + . $crlf; $first = true; for ($j = $i; $j < $sql_count; $j++) { @@ -1373,7 +1444,11 @@ class ExportSql extends ExportPlugin ) { $common_functions = PMA_CommonFunctions::getInstance(); - $compat = (isset($GLOBALS['sql_compatibility'])) ? $GLOBALS['sql_compatibility'] : 'NONE'; + if (isset($GLOBALS['sql_compatibility'])) { + $compat = $GLOBALS['sql_compatibility']; + } else { + $compat = 'NONE'; + } $formatted_table_name = (isset($GLOBALS['sql_backquotes'])) ? $common_functions->backquote_compat($table, $compat) : '\'' . $table . '\''; @@ -1459,7 +1534,11 @@ class ExportSql extends ExportPlugin { global $current_row, $sql_backquotes; - $compat = (isset($GLOBALS['sql_compatibility'])) ? $GLOBALS['sql_compatibility'] : 'NONE'; + if (isset($GLOBALS['sql_compatibility'])) { + $compat = $GLOBALS['sql_compatibility']; + } else { + $compat = 'NONE'; + } $common_functions = PMA_CommonFunctions::getInstance(); $formatted_table_name = (isset($GLOBALS['sql_backquotes']))