From 8309413bfb6d8082ee7f544e949af97c10bfbfc3 Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Thu, 18 Apr 2013 19:47:32 +0100 Subject: [PATCH 01/37] Implemented rfe #1416 config.inc.php proxy settings for version_check.php --- doc/config.rst | 27 ++++++++++++++++++++++++++ libraries/config.default.php | 27 ++++++++++++++++++++++++++ libraries/config/messages.inc.php | 7 +++++++ libraries/config/setup.forms.php | 8 ++++++-- version_check.php | 32 ++++++++++++++++++++++++++++++- 5 files changed, 98 insertions(+), 3 deletions(-) diff --git a/doc/config.rst b/doc/config.rst index 7087ecf243..e1c8cc56c8 100644 --- a/doc/config.rst +++ b/doc/config.rst @@ -1013,6 +1013,33 @@ Generic settings This setting can be adjusted by your vendor. +.. config:option:: $cfg['VersionCheckProxyUrl'] + + :type: string + :default: "" + + The url of the proxy to be used when retrieving the information about + the latest version of phpMyAdmin. You need this if the server where + phpMyAdmin is installed does not have direct access to the internet. + The format is: "hostname:portnumber" + +.. config:option:: $cfg['VersionCheckProxyUser'] + + :type: string + :default: "" + + The username for authenticating with the proxy. By default, no + authentication is performed. If a username is supplied, Basic + Authentication will be performed. No other types of authentication + are currently supported. + +.. config:option:: $cfg['VersionCheckProxyPass'] + + :type: string + :default: "" + + The password for authenticating with the proxy. + .. config:option:: $cfg['MaxDbList'] :type: integer diff --git a/libraries/config.default.php b/libraries/config.default.php index 2d4c89baf0..a33688f77b 100644 --- a/libraries/config.default.php +++ b/libraries/config.default.php @@ -566,6 +566,33 @@ $cfg['ServerDefault'] = 1; */ $cfg['VersionCheck'] = VERSION_CHECK_DEFAULT; +/** + * The url of the proxy to be used when retrieving the information about + * the latest version of phpMyAdmin. You need this if the server where + * phpMyAdmin is installed does not have direct access to the internet. + * The format is: "hostname:portnumber" + * + * @global string $cfg['VersionCheckProxyUrl'] + */ +$cfg['VersionCheckProxyUrl'] = ""; + +/** + * The username for authenticating with the proxy. By default, no + * authentication is performed. If a username is supplied, Basic + * Authentication will be performed. No other types of authentication + * are currently supported. + * + * @global string $cfg['VersionCheckProxyUser'] + */ +$cfg['VersionCheckProxyUser'] = ""; + +/** + * The password for authenticating with the proxy. + * + * @global string $cfg['VersionCheckProxyPass'] + */ +$cfg['VersionCheckProxyPass'] = ""; + /** * maximum number of db's displayed in database list * diff --git a/libraries/config/messages.inc.php b/libraries/config/messages.inc.php index acb0674bc0..58558ae769 100644 --- a/libraries/config/messages.inc.php +++ b/libraries/config/messages.inc.php @@ -519,6 +519,13 @@ $strConfigUserprefsDeveloperTab_name = __('Enable the Developer tab in settings' $strConfigVersionCheckLink = __('Check for latest version'); $strConfigVersionCheck_desc = __('Enables check for latest version on main phpMyAdmin page'); $strConfigVersionCheck_name = __('Version check'); +$strConfigVersionCheckProxyUrl_desc = __('The url of the proxy to be used when retrieving the information about the latest version of phpMyAdmin. You need this if the server where phpMyAdmin is installed does not have direct access to the internet. The format is: "hostname:portnumber"'); +$strConfigVersionCheckProxyUrl_name = __('Version check proxy url'); +$strConfigVersionCheckProxyUser_desc = __('The username for authenticating with the proxy. By default, no authentication is performed. If a username is supplied, Basic Authentication will be performed. No other types of authentication are currently supported.'); +$strConfigVersionCheckProxyUser_name = __('Version check proxy username'); +$strConfigVersionCheckProxyPass_desc = __('The password for authenticating with the proxy'); +$strConfigVersionCheckProxyPass_name = __('Version check proxy password'); + $strConfigZipDump_desc = __('Enable [a@http://en.wikipedia.org/wiki/ZIP_(file_format)]ZIP[/a] compression for import and export operations'); $strConfigZipDump_name = __('ZIP'); diff --git a/libraries/config/setup.forms.php b/libraries/config/setup.forms.php index 5f42688808..18ee6533bc 100644 --- a/libraries/config/setup.forms.php +++ b/libraries/config/setup.forms.php @@ -124,7 +124,6 @@ $forms['Features']['Developer'] = array( 'Error_Handler/gather', 'DBG/sql'); $forms['Features']['Other_core_settings'] = array( - 'VersionCheck', 'NaturalOrder', 'InitialSlidersState', 'MaxDbList', @@ -137,7 +136,12 @@ $forms['Features']['Other_core_settings'] = array( 'MemoryLimit', 'SkipLockedTables', 'DisableMultiTableMaintenance', - 'UseDbSearch'); + 'UseDbSearch', + 'VersionCheck', + 'VersionCheckProxyUrl', + 'VersionCheckProxyUser', + 'VersionCheckProxyPass' +); $forms['Sql_queries']['Sql_queries'] = array( 'ShowSQL', 'Confirm', diff --git a/version_check.php b/version_check.php index 522e423daf..eac1fd2c44 100644 --- a/version_check.php +++ b/version_check.php @@ -21,9 +21,39 @@ if (isset($_SESSION['cache']['version_check']) $save = true; $file = 'http://www.phpmyadmin.net/home_page/version.json'; if (ini_get('allow_url_fopen')) { - $response = file_get_contents($file); + if (strlen($cfg['VersionCheckProxyUrl'])) { + $context = array( + 'http' => array( + 'proxy' => $cfg['VersionCheckProxyUrl'], + 'request_fulluri' => true + ) + ); + if (strlen($cfg['VersionCheckProxyUser'])) { + $auth = base64_encode( + $cfg['VersionCheckProxyUser'] . ':' . $cfg['VersionCheckProxyPass'] + ); + $context['http']['header'] = 'Proxy-Authorization: Basic ' . $auth; + } + $response = file_get_contents( + $file, + false, + stream_context_create($context) + ); + } else { + $response = file_get_contents($file); + } } else if (function_exists('curl_init')) { $curl_handle = curl_init($file); + if (strlen($cfg['VersionCheckProxyUrl'])) { + curl_setopt($curl_handle, CURLOPT_PROXY, $cfg['VersionCheckProxyUrl']); + if (strlen($cfg['VersionCheckProxyUser'])) { + curl_setopt( + $curl_handle, + CURLOPT_PROXYUSERPWD, + $cfg['VersionCheckProxyUser'] . ':' . $cfg['VersionCheckProxyPass'] + ); + } + } curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1); $response = curl_exec($curl_handle); } From c2ba8f7a80d27ece83caa4d7aedfa31893a39622 Mon Sep 17 00:00:00 2001 From: Samith Dassanayake Date: Wed, 8 May 2013 20:28:37 +0530 Subject: [PATCH 02/37] =?UTF-8?q?Moved=20duplicated=20codes=20in=20?= =?UTF-8?q?=E2=80=9Ctbl=5Faddfield.php=E2=80=9D=20and=20=E2=80=9Ctbl=5Fcre?= =?UTF-8?q?ate.php=E2=80=9D=20to=20single=20a=20file=20"create=5Faddfield.?= =?UTF-8?q?lib.php".=20Refactored=20the=20code=20using=20=E2=80=9CExtract?= =?UTF-8?q?=20method=E2=80=9D=20refactoring=20technique.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libraries/create_addfield.lib.php | 214 ++++++++++++++++++++++++++++++ tbl_addfield.php | 123 +---------------- tbl_create.php | 136 +------------------ 3 files changed, 226 insertions(+), 247 deletions(-) create mode 100644 libraries/create_addfield.lib.php diff --git a/libraries/create_addfield.lib.php b/libraries/create_addfield.lib.php new file mode 100644 index 0000000000..01a1cf4ab5 --- /dev/null +++ b/libraries/create_addfield.lib.php @@ -0,0 +1,214 @@ + diff --git a/tbl_addfield.php b/tbl_addfield.php index 259581025b..fda92124be 100644 --- a/tbl_addfield.php +++ b/tbl_addfield.php @@ -50,123 +50,10 @@ if (isset($_REQUEST['do_save_data'])) { //avoid an incorrect calling of PMA_updateColumns() via //tbl_structure.php below unset($_REQUEST['do_save_data']); - - $query = ''; - $definitions = array(); - - // Transforms the radio button field_key into 3 arrays - $field_cnt = count($_REQUEST['field_name']); - $field_primary = array(); - $field_index = array(); - $field_unique = array(); - $field_fulltext = array(); - for ($i = 0; $i < $field_cnt; ++$i) { - if (isset($_REQUEST['field_key'][$i]) - && strlen($_REQUEST['field_name'][$i]) - ) { - if ($_REQUEST['field_key'][$i] == 'primary_' . $i) { - $field_primary[] = $i; - } - if ($_REQUEST['field_key'][$i] == 'index_' . $i) { - $field_index[] = $i; - } - if ($_REQUEST['field_key'][$i] == 'unique_' . $i) { - $field_unique[] = $i; - } - if ($_REQUEST['field_key'][$i] == 'fulltext_' . $i) { - $field_fulltext[] = $i; - } - } // end if - } // end for - - // Builds the field creation statement and alters the table - for ($i = 0; $i < $field_cnt; ++$i) { - // '0' is also empty for php :-( - if (empty($_REQUEST['field_name'][$i]) - && $_REQUEST['field_name'][$i] != '0' - ) { - continue; - } - - $definition = ' ADD ' . PMA_Table::generateFieldSpec( - $_REQUEST['field_name'][$i], - $_REQUEST['field_type'][$i], - $i, - $_REQUEST['field_length'][$i], - $_REQUEST['field_attribute'][$i], - isset($_REQUEST['field_collation'][$i]) - ? $_REQUEST['field_collation'][$i] - : '', - isset($_REQUEST['field_null'][$i]) - ? $_REQUEST['field_null'][$i] - : 'NOT NULL', - $_REQUEST['field_default_type'][$i], - $_REQUEST['field_default_value'][$i], - isset($_REQUEST['field_extra'][$i]) - ? $_REQUEST['field_extra'][$i] - : false, - isset($_REQUEST['field_comments'][$i]) - ? $_REQUEST['field_comments'][$i] - : '', - $field_primary - ); - - if ($_REQUEST['field_where'] != 'last') { - // Only the first field can be added somewhere other than at the end - if ($i == 0) { - if ($_REQUEST['field_where'] == 'first') { - $definition .= ' FIRST'; - } else { - $definition .= ' AFTER ' - . PMA_Util::backquote($_REQUEST['after_field']); - } - } else { - $definition .= ' AFTER ' - . PMA_Util::backquote($_REQUEST['field_name'][$i-1]); - } - } - $definitions[] = $definition; - } // end for - - // Builds the primary keys statements and updates the table - if (count($field_primary)) { - $fields = array(); - foreach ($field_primary as $field_nr) { - $fields[] = PMA_Util::backquote($_REQUEST['field_name'][$field_nr]); - } - $definitions[] = ' ADD PRIMARY KEY (' . implode(', ', $fields) . ') '; - unset($fields); - } - - // Builds the indexes statements and updates the table - if (count($field_index)) { - $fields = array(); - foreach ($field_index as $field_nr) { - $fields[] = PMA_Util::backquote($_REQUEST['field_name'][$field_nr]); - } - $definitions[] = ' ADD INDEX (' . implode(', ', $fields) . ') '; - unset($fields); - } - - // Builds the uniques statements and updates the table - if (count($field_unique)) { - $fields = array(); - foreach ($field_unique as $field_nr) { - $fields[] = PMA_Util::backquote($_REQUEST['field_name'][$field_nr]); - } - $definitions[] = ' ADD UNIQUE (' . implode(', ', $fields) . ') '; - unset($fields); - } - - // Builds the fulltext statements and updates the table - if (count($field_fulltext)) { - $fields = array(); - foreach ($field_fulltext as $field_nr) { - $fields[] = PMA_Util::backquote($_REQUEST['field_name'][$field_nr]); - } - $definitions[] = ' ADD FULLTEXT (' . implode(', ', $fields) . ') '; - unset($fields); - } + + require_once 'libraries/create_addfield.lib.php'; + // get field addition statements + $sql_statement = PMA_getFieldCreationStatements(false); // To allow replication, we first select the db to use and then run queries // on this db. @@ -175,7 +62,7 @@ if (isset($_REQUEST['do_save_data'])) { PMA_DBI_getError(), 'USE ' . PMA_Util::backquote($db), '', $err_url ); $sql_query = 'ALTER TABLE ' . - PMA_Util::backquote($table) . ' ' . implode(', ', $definitions) . ';'; + PMA_Util::backquote($table) . ' ' . $sql_statement . ';'; $result = PMA_DBI_tryQuery($sql_query); if ($result === true) { diff --git a/tbl_create.php b/tbl_create.php index 510e16a191..036a83b40c 100644 --- a/tbl_create.php +++ b/tbl_create.php @@ -67,137 +67,15 @@ if (!PMA_DBI_selectDb($db)) { */ if (isset($_REQUEST['do_save_data'])) { $sql_query = ''; - - // Transforms the radio button field_key into 3 arrays - $field_cnt = count($_REQUEST['field_name']); - for ($i = 0; $i < $field_cnt; ++$i) { - if (isset($_REQUEST['field_key'][$i])) { - if ($_REQUEST['field_key'][$i] == 'primary_' . $i) { - $field_primary[] = $i; - } - if ($_REQUEST['field_key'][$i] == 'index_' . $i) { - $field_index[] = $i; - } - if ($_REQUEST['field_key'][$i] == 'unique_' . $i) { - $field_unique[] = $i; - } - } // end if - } // end for - - // Builds the fields creation statements - for ($i = 0; $i < $field_cnt; $i++) { - // '0' is also empty for php :-( - if (empty($_REQUEST['field_name'][$i]) - && $_REQUEST['field_name'][$i] != '0' - ) { - continue; - } - - $query = PMA_Table::generateFieldSpec( - $_REQUEST['field_name'][$i], - $_REQUEST['field_type'][$i], - $i, - $_REQUEST['field_length'][$i], - $_REQUEST['field_attribute'][$i], - isset($_REQUEST['field_collation'][$i]) - ? $_REQUEST['field_collation'][$i] - : '', - isset($_REQUEST['field_null'][$i]) - ? $_REQUEST['field_null'][$i] - : 'NOT NULL', - $_REQUEST['field_default_type'][$i], - $_REQUEST['field_default_value'][$i], - isset($_REQUEST['field_extra'][$i]) - ? $_REQUEST['field_extra'][$i] - : false, - isset($_REQUEST['field_comments'][$i]) - ? $_REQUEST['field_comments'][$i] - : '', - $field_primary, - '' - ); - - $query .= ', '; - $sql_query .= $query; - } // end for - unset($field_cnt, $query); - $sql_query = preg_replace('@, $@', '', $sql_query); - - // Builds the primary keys statements - $primary = ''; - $primary_cnt = (isset($field_primary) ? count($field_primary) : 0); - for ($i = 0; $i < $primary_cnt; $i++) { - $j = $field_primary[$i]; - if (isset($_REQUEST['field_name'][$j]) - && strlen($_REQUEST['field_name'][$j]) - ) { - $primary .= PMA_Util::backquote($_REQUEST['field_name'][$j]) . ', '; - } - } // end for - unset($primary_cnt); - $primary = preg_replace('@, $@', '', $primary); - if (strlen($primary)) { - $sql_query .= ', PRIMARY KEY (' . $primary . ')'; - } - unset($primary); - - // Builds the indexes statements - $index = ''; - $index_cnt = (isset($field_index) ? count($field_index) : 0); - for ($i = 0;$i < $index_cnt; $i++) { - $j = $field_index[$i]; - if (isset($_REQUEST['field_name'][$j]) - && strlen($_REQUEST['field_name'][$j]) - ) { - $index .= PMA_Util::backquote($_REQUEST['field_name'][$j]) . ', '; - } - } // end for - unset($index_cnt); - $index = preg_replace('@, $@', '', $index); - if (strlen($index)) { - $sql_query .= ', INDEX (' . $index . ')'; - } - unset($index); - - // Builds the uniques statements - $unique = ''; - $unique_cnt = (isset($field_unique) ? count($field_unique) : 0); - for ($i = 0; $i < $unique_cnt; $i++) { - $j = $field_unique[$i]; - if (isset($_REQUEST['field_name'][$j]) - && strlen($_REQUEST['field_name'][$j]) - ) { - $unique .= PMA_Util::backquote($_REQUEST['field_name'][$j]) . ', '; - } - } // end for - unset($unique_cnt); - $unique = preg_replace('@, $@', '', $unique); - if (strlen($unique)) { - $sql_query .= ', UNIQUE (' . $unique . ')'; - } - unset($unique); - - // Builds the FULLTEXT statements - $fulltext = ''; - $fulltext_cnt = (isset($field_fulltext) ? count($field_fulltext) : 0); - for ($i = 0; $i < $fulltext_cnt; $i++) { - $j = $field_fulltext[$i]; - if (isset($_REQUEST['field_name'][$j]) - && strlen($_REQUEST['field_name'][$j]) - ) { - $fulltext .= PMA_Util::backquote($_REQUEST['field_name'][$j]) . ', '; - } - } // end for - - $fulltext = preg_replace('@, $@', '', $fulltext); - if (strlen($fulltext)) { - $sql_query .= ', FULLTEXT (' . $fulltext . ')'; - } - unset($fulltext); - + + require_once 'libraries/create_addfield.lib.php'; + // get field addition statements + $sql_statement = PMA_getFieldCreationStatements(true); + $sql_statement = preg_replace('@, $@', '', $sql_statement); + // Builds the 'create table' statement $sql_query = 'CREATE TABLE ' . PMA_Util::backquote($db) . '.' - . PMA_Util::backquote($table) . ' (' . $sql_query . ')'; + . PMA_Util::backquote($table) . ' (' . $sql_statement . ')'; // Adds table type, character set, comments and partition definition if (!empty($_REQUEST['tbl_storage_engine']) From 73f674d7559c8715e7502eed1844a3e76b455dd0 Mon Sep 17 00:00:00 2001 From: Samith Dassanayake Date: Sun, 12 May 2013 19:30:36 +0530 Subject: [PATCH 03/37] Updated the description of the "create_addfield.lib.php" file --- libraries/create_addfield.lib.php | 3 ++- tbl_create.php | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/create_addfield.lib.php b/libraries/create_addfield.lib.php index 01a1cf4ab5..34df482dab 100644 --- a/libraries/create_addfield.lib.php +++ b/libraries/create_addfield.lib.php @@ -1,7 +1,7 @@ Date: Sun, 12 May 2013 22:54:23 +0530 Subject: [PATCH 04/37] Fixed #3902: Cannot browse when table name contains keyword 'call' --- ChangeLog | 1 + sql.php | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 0d5123cb2b..a93fdf1720 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,7 @@ phpMyAdmin - ChangeLog ====================== 4.0.2.0 (not yet released) +- bug #3902 Cannot browse when table name contains keyword "call" + center loading indicator for navigation refresh, related to bug #3920 - bug #3925 Table sorting in navigation panel is case-sensitive - bug #3915 Import of CSV file (Replace table data with file) with duplicate diff --git a/sql.php b/sql.php index 0fdde041a4..1a4f089fd3 100644 --- a/sql.php +++ b/sql.php @@ -646,7 +646,13 @@ if (isset($GLOBALS['show_as_php']) || ! empty($GLOBALS['validatequery'])) { } while (PMA_DBI_next_result()); $is_procedure = false; - if (stripos($full_sql_query, 'call') !== false) { + + // Since multpile query execution is anyway handled, + // ignore the where clause of the first sql statement + // which might contain a phrase like 'call ' + if (preg_match("/\bcall\b/i", $full_sql_query) + && empty($analyzed_sql[0]['where_clause']) + ) { $is_procedure = true; } From 529903e0dd9f5585a92118838928afba79c35147 Mon Sep 17 00:00:00 2001 From: "J.M" Date: Mon, 13 May 2013 11:27:56 +0200 Subject: [PATCH 05/37] Fix bug #3907 undefined variables, function parameter problems Thanks Rasmus Lerdorf for analyzing! --- changelog.php | 3 +- import.php | 1 + index.php | 2 +- libraries/DBQbe.class.php | 2 +- libraries/DisplayResults.class.php | 37 +++++++++++-------- libraries/TableSearch.class.php | 7 ++-- libraries/config/ConfigFile.class.php | 3 +- libraries/dbi/dummy.lib.php | 4 +- libraries/dbi/mysqli.dbi.lib.php | 10 ++--- libraries/operations.lib.php | 4 +- .../plugins/export/ExportHtmlword.class.php | 6 +-- libraries/plugins/export/ExportOdt.class.php | 2 +- libraries/plugins/import/ImportCsv.class.php | 8 ++-- libraries/plugins/import/ImportLdi.class.php | 2 +- libraries/plugins/import/ImportShp.class.php | 18 +++++---- libraries/replication_gui.lib.php | 2 +- .../schema/Visio_Relation_Schema.class.php | 6 +-- libraries/sql_query_form.lib.php | 4 +- libraries/sqlvalidator.class.php | 3 +- libraries/transformations.lib.php | 5 ++- server_replication.php | 2 +- server_status_advisor.php | 2 +- server_status_monitor.php | 8 ++-- 23 files changed, 79 insertions(+), 62 deletions(-) diff --git a/changelog.php b/changelog.php index 9dc60b6a1a..c216c7fe3d 100644 --- a/changelog.php +++ b/changelog.php @@ -11,7 +11,8 @@ */ require 'libraries/common.inc.php'; -$response = PMA_Response::getInstance()->disable(); +$response = PMA_Response::getInstance(); +$response->disable(); $filename = CHANGELOG_FILE; diff --git a/import.php b/import.php index 1de72fe5b4..9d193ae63d 100644 --- a/import.php +++ b/import.php @@ -36,6 +36,7 @@ $post_params = array( 'local_import_file' ); +// TODO: adapt full list of allowed parameters, as in export.php foreach ($post_params as $one_post_param) { if (isset($_POST[$one_post_param])) { $GLOBALS[$one_post_param] = $_POST[$one_post_param]; diff --git a/index.php b/index.php index 7789cc461c..96f6969710 100644 --- a/index.php +++ b/index.php @@ -208,7 +208,7 @@ echo ''; if ($server > 0) { echo '