Merge branch 'master' of https://github.com/phpmyadmin/phpmyadmin into 0706_UT_serverView2

This commit is contained in:
xmujay 2013-07-12 23:21:34 +08:00
commit 7014c18a88
97 changed files with 52888 additions and 53395 deletions

View File

@ -33,6 +33,7 @@ phpMyAdmin - ChangeLog
- bug #3960 NavigationBarIconic config not honored
- bug #3985 Call to undefined function mb_detect_encoding
- bug #4007 Analyze option not shown for InnoDB tables
- bug #4015 Forcing a storage engine for configuration storage
4.0.4.1 (2013-06-30)
- [security] Global variables scope injection vulnerability (see PMASA-2013-7)

View File

@ -83,7 +83,7 @@ $titles = PMA_Util::buildActionTitles();
if ($num_tables == 0) {
$response->addHTML(
'<p>' . __('No tables found in database') . '</p>' . "\n"
'<p>' . __('No tables found in database.') . '</p>' . "\n"
);
if (empty($db_is_information_schema)) {
ob_start();

View File

@ -44,7 +44,7 @@ CREATE TABLE IF NOT EXISTS `pma__bookmark` (
`query` text NOT NULL,
PRIMARY KEY (`id`)
)
ENGINE=MyISAM COMMENT='Bookmarks'
COMMENT='Bookmarks'
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
-- --------------------------------------------------------
@ -65,7 +65,7 @@ CREATE TABLE IF NOT EXISTS `pma__column_info` (
PRIMARY KEY (`id`),
UNIQUE KEY `db_name` (`db_name`,`table_name`,`column_name`)
)
ENGINE=MyISAM COMMENT='Column information for phpMyAdmin'
COMMENT='Column information for phpMyAdmin'
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
-- --------------------------------------------------------
@ -84,7 +84,7 @@ CREATE TABLE IF NOT EXISTS `pma__history` (
PRIMARY KEY (`id`),
KEY `username` (`username`,`db`,`table`,`timevalue`)
)
ENGINE=MyISAM COMMENT='SQL history for phpMyAdmin'
COMMENT='SQL history for phpMyAdmin'
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
-- --------------------------------------------------------
@ -100,7 +100,7 @@ CREATE TABLE IF NOT EXISTS `pma__pdf_pages` (
PRIMARY KEY (`page_nr`),
KEY `db_name` (`db_name`)
)
ENGINE=MyISAM COMMENT='PDF relation pages for phpMyAdmin'
COMMENT='PDF relation pages for phpMyAdmin'
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
-- --------------------------------------------------------
@ -114,7 +114,7 @@ CREATE TABLE IF NOT EXISTS `pma__recent` (
`tables` text NOT NULL,
PRIMARY KEY (`username`)
)
ENGINE=MyISAM COMMENT='Recently accessed tables'
COMMENT='Recently accessed tables'
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
-- --------------------------------------------------------
@ -131,7 +131,7 @@ CREATE TABLE IF NOT EXISTS `pma__table_uiprefs` (
`last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`username`,`db_name`,`table_name`)
)
ENGINE=MyISAM COMMENT='Tables'' UI preferences'
COMMENT='Tables'' UI preferences'
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
-- --------------------------------------------------------
@ -150,7 +150,7 @@ CREATE TABLE IF NOT EXISTS `pma__relation` (
PRIMARY KEY (`master_db`,`master_table`,`master_field`),
KEY `foreign_field` (`foreign_db`,`foreign_table`)
)
ENGINE=MyISAM COMMENT='Relation table'
COMMENT='Relation table'
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
-- --------------------------------------------------------
@ -167,7 +167,7 @@ CREATE TABLE IF NOT EXISTS `pma__table_coords` (
`y` float unsigned NOT NULL default '0',
PRIMARY KEY (`db_name`,`table_name`,`pdf_page_number`)
)
ENGINE=MyISAM COMMENT='Table coordinates for phpMyAdmin PDF output'
COMMENT='Table coordinates for phpMyAdmin PDF output'
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
-- --------------------------------------------------------
@ -182,7 +182,7 @@ CREATE TABLE IF NOT EXISTS `pma__table_info` (
`display_field` varchar(64) NOT NULL default '',
PRIMARY KEY (`db_name`,`table_name`)
)
ENGINE=MyISAM COMMENT='Table information for phpMyAdmin'
COMMENT='Table information for phpMyAdmin'
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
-- --------------------------------------------------------
@ -200,7 +200,7 @@ CREATE TABLE IF NOT EXISTS `pma__designer_coords` (
`h` TINYINT,
PRIMARY KEY (`db_name`,`table_name`)
)
ENGINE=MyISAM COMMENT='Table coordinates for Designer'
COMMENT='Table coordinates for Designer'
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
-- --------------------------------------------------------
@ -222,7 +222,7 @@ CREATE TABLE IF NOT EXISTS `pma__tracking` (
`tracking_active` int(1) unsigned NOT NULL default '1',
PRIMARY KEY (`db_name`,`table_name`,`version`)
)
ENGINE=MyISAM ROW_FORMAT=COMPACT COMMENT='Database changes tracking for phpMyAdmin'
COMMENT='Database changes tracking for phpMyAdmin'
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
-- --------------------------------------------------------
@ -237,5 +237,5 @@ CREATE TABLE IF NOT EXISTS `pma__userconfig` (
`config_data` text NOT NULL,
PRIMARY KEY (`username`)
)
ENGINE=MyISAM COMMENT='User preferences storage for phpMyAdmin'
COMMENT='User preferences storage for phpMyAdmin'
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;

View File

@ -31,7 +31,7 @@ CREATE TABLE IF NOT EXISTS `pma__bookmark` (
`query` text NOT NULL,
PRIMARY KEY (`id`)
)
ENGINE=InnoDB COMMENT='Bookmarks'
COMMENT='Bookmarks'
COLLATE utf8_bin;
-- --------------------------------------------------------
@ -52,7 +52,7 @@ CREATE TABLE IF NOT EXISTS `pma__column_info` (
PRIMARY KEY (`id`),
UNIQUE KEY `db_name` (`db_name`,`table_name`,`column_name`)
)
ENGINE=InnoDB COMMENT='Column information for phpMyAdmin'
COMMENT='Column information for phpMyAdmin'
COLLATE utf8_bin;
-- --------------------------------------------------------
@ -71,7 +71,7 @@ CREATE TABLE IF NOT EXISTS `pma__history` (
PRIMARY KEY (`id`),
KEY `username` (`username`,`db`,`table`,`timevalue`)
)
ENGINE=InnoDB COMMENT='SQL history for phpMyAdmin'
COMMENT='SQL history for phpMyAdmin'
COLLATE utf8_bin;
-- --------------------------------------------------------
@ -87,7 +87,7 @@ CREATE TABLE IF NOT EXISTS `pma__pdf_pages` (
PRIMARY KEY (`page_nr`),
KEY `db_name` (`db_name`)
)
ENGINE=InnoDB COMMENT='PDF relation pages for phpMyAdmin'
COMMENT='PDF relation pages for phpMyAdmin'
COLLATE utf8_bin;
-- --------------------------------------------------------
@ -101,7 +101,7 @@ CREATE TABLE IF NOT EXISTS `pma__recent` (
`tables` text NOT NULL,
PRIMARY KEY (`username`)
)
ENGINE=InnoDB COMMENT='Recently accessed tables'
COMMENT='Recently accessed tables'
COLLATE utf8_bin;
-- --------------------------------------------------------
@ -118,7 +118,7 @@ CREATE TABLE IF NOT EXISTS `pma__table_uiprefs` (
`last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`username`,`db_name`,`table_name`)
)
ENGINE=InnoDB COMMENT='Tables'' UI preferences'
COMMENT='Tables'' UI preferences'
COLLATE utf8_bin;
-- --------------------------------------------------------
@ -137,7 +137,7 @@ CREATE TABLE IF NOT EXISTS `pma__relation` (
PRIMARY KEY (`master_db`,`master_table`,`master_field`),
KEY `foreign_field` (`foreign_db`,`foreign_table`)
)
ENGINE=InnoDB COMMENT='Relation table'
COMMENT='Relation table'
COLLATE utf8_bin;
-- --------------------------------------------------------
@ -154,7 +154,7 @@ CREATE TABLE IF NOT EXISTS `pma__table_coords` (
`y` float NOT NULL default '0',
PRIMARY KEY (`db_name`,`table_name`,`pdf_page_number`)
)
ENGINE=InnoDB COMMENT='Table coordinates for phpMyAdmin PDF output'
COMMENT='Table coordinates for phpMyAdmin PDF output'
COLLATE utf8_bin;
-- --------------------------------------------------------
@ -169,7 +169,7 @@ CREATE TABLE IF NOT EXISTS `pma__table_info` (
`display_field` varchar(64) NOT NULL default '',
PRIMARY KEY (`db_name`,`table_name`)
)
ENGINE=InnoDB COMMENT='Table information for phpMyAdmin'
COMMENT='Table information for phpMyAdmin'
COLLATE utf8_bin;
-- --------------------------------------------------------
@ -187,7 +187,7 @@ CREATE TABLE IF NOT EXISTS `pma__designer_coords` (
`h` INT,
PRIMARY KEY (`db_name`,`table_name`)
)
ENGINE=InnoDB COMMENT='Table coordinates for Designer'
COMMENT='Table coordinates for Designer'
COLLATE utf8_bin;
-- --------------------------------------------------------
@ -209,7 +209,6 @@ CREATE TABLE IF NOT EXISTS `pma__tracking` (
`tracking_active` int(1) NOT NULL default '1',
PRIMARY KEY (`db_name`,`table_name`,`version`)
)
ENGINE=InnoDB
COLLATE utf8_bin;
-- --------------------------------------------------------
@ -224,5 +223,5 @@ CREATE TABLE IF NOT EXISTS `pma__userconfig` (
`config_data` text NOT NULL,
PRIMARY KEY (`username`)
)
ENGINE=InnoDB COMMENT='User preferences storage for phpMyAdmin'
COMMENT='User preferences storage for phpMyAdmin'
COLLATE utf8_bin;

View File

@ -136,12 +136,12 @@ function PMA_current_version(data)
escapeHtml(data['version']),
escapeHtml(data['date'])
);
var klass = 'notice';
var htmlClass = 'notice';
if (Math.floor(latest / 10000) === Math.floor(current / 10000)) {
/* Security update */
klass = 'error';
htmlClass = 'error';
}
$('#maincontainer').after('<div class="' + klass + '">' + message + '</div>');
$('#maincontainer').after('<div class="' + htmlClass + '">' + message + '</div>');
}
if (latest === current) {
version_information_message = ' (' + PMA_messages.strUpToDate + ')';

View File

@ -256,7 +256,7 @@ $js_messages['enum_hint'] =__('Enter each value in a separate field');
$js_messages['enum_addValue'] =__('Add %d value(s)');
/* For import.js */
$js_messages['strImportCSV'] = __('Note: If the file contains multiple tables, they will be combined into one');
$js_messages['strImportCSV'] = __('Note: If the file contains multiple tables, they will be combined into one.');
/* For sql.js */
$js_messages['strHideQueryBox'] = __('Hide query box');

View File

@ -605,7 +605,7 @@ class PMA_Index
. PMA_Util::backquote($table) . ' DROP INDEX '
. PMA_Util::backquote($index->getName()) . ';';
$this_params['message_to_show'] = sprintf(
__('Index %s has been dropped'), $index->getName()
__('Index %s has been dropped.'), $index->getName()
);
$js_msg = PMA_jsFormat(

View File

@ -89,7 +89,7 @@ class PMA_Util
/**
* Returns an HTML IMG tag for a particular icon from a theme,
* which may be an actual file or an icon from a sprite.
* This function takes into account the ActionLinksMode
* This function takes into account the ActionLinksMode
* configuration setting and wraps the image tag in a span tag.
*
* @param string $icon name of icon file
@ -106,19 +106,19 @@ class PMA_Util
) {
$include_icon = $include_text = false;
if (in_array(
$GLOBALS['cfg'][$control_param],
$GLOBALS['cfg'][$control_param],
array('icons', 'both')
)
) {
) {
$include_icon = true;
}
}
if ($force_text
|| in_array(
$GLOBALS['cfg'][$control_param],
$GLOBALS['cfg'][$control_param],
array('text', 'both')
)
) {
$include_text = true;
$include_text = true;
}
// Sometimes use a span (we rely on this in js/sql.js). But for menu bar
// we don't need a span
@ -1811,10 +1811,10 @@ class PMA_Util
// the text that follows and if browser does not display
// images, the text is duplicated
$tab['text'] = self::getIcon(
$tab['icon'],
$tab['text'],
false,
true,
$tab['icon'],
$tab['text'],
false,
true,
'TabsMode'
);
@ -3438,7 +3438,7 @@ class PMA_Util
if ($files === false) {
PMA_Message::error(
__('The directory you set for upload work cannot be reached')
__('The directory you set for upload work cannot be reached.')
)->display();
} elseif (! empty($files)) {
$block_html .= "\n"
@ -4152,5 +4152,182 @@ class PMA_Util
}
return $regex;
}
/**
* Returns information with latest version from phpmyadmin.net
*
* @return JSON decoded object with the data
*/
public static function getLatestVersion()
{
global $cfg;
// wait 3s at most for server response, it's enough to get information
// from a working server
$connection_timeout = 3;
$response = '{}';
// Get response text from phpmyadmin.net or from the session
// Update cache every 6 hours
if (isset($_SESSION['cache']['version_check'])
&& time() < $_SESSION['cache']['version_check']['timestamp'] + 3600 * 6
) {
$save = false;
$response = $_SESSION['cache']['version_check']['response'];
} else {
$save = true;
$file = 'http://www.phpmyadmin.net/home_page/version.json';
if (ini_get('allow_url_fopen')) {
$context = array(
'http' => array(
'request_fulluri' => true,
'timeout' => $connection_timeout,
)
);
if (strlen($cfg['VersionCheckProxyUrl'])) {
$context['http']['proxy'] = $cfg['VersionCheckProxyUrl'];
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 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
);
curl_setopt(
$curl_handle,
CURLOPT_HEADER,
false
);
curl_setopt(
$curl_handle,
CURLOPT_RETURNTRANSFER,
true
);
curl_setopt(
$curl_handle,
CURLOPT_TIMEOUT,
$connection_timeout
);
$response = curl_exec($curl_handle);
}
}
if ($save) {
$_SESSION['cache']['version_check'] = array(
'response' => $response,
'timestamp' => time()
);
}
$data = json_decode($response);
if (is_object($data)
&& strlen($data->version)
&& strlen($data->date)
) {
if ($save) {
$_SESSION['cache']['version_check'] = array(
'response' => $response,
'timestamp' => time()
);
}
}
return $data;
}
/**
* Calculates numerical equivalent of phpMyAdmin version string
*
* @param string $version version
*
* @return mixed false on failure, integer on success
*/
public static function versionToInt($version)
{
$parts = explode('-', $version);
if (count($parts) > 1) {
$suffix = $parts[1];
} else {
$suffix = '';
}
$parts = explode('.', $parts[0]);
$result = 0;
if (count($parts) >= 1 && is_numeric($parts[0])) {
$result += 1000000 * $parts[0];
}
if (count($parts) >= 2 && is_numeric($parts[1])) {
$result += 10000 * $parts[1];
}
if (count($parts) >= 3 && is_numeric($parts[2])) {
$result += 100 * $parts[2];
}
if (count($parts) >= 4 && is_numeric($parts[3])) {
$result += 1 * $parts[3];
}
if (!empty($suffix)) {
$matches = array();
if (preg_match('/^(\D+)(\d+)$/', $suffix, $matches)) {
$suffix = $matches[1];
$result += intval($matches[2]);
}
switch ($suffix) {
case 'pl':
$result += 60;
break;
case 'rc':
$result += 30;
break;
case 'beta':
$result += 20;
break;
case 'alpha':
$result += 10;
break;
case 'dev':
$result += 0;
break;
}
} else {
$result += 50; // for final
}
return $result;
}
}
?>

View File

@ -198,41 +198,41 @@ $cfg_db['_overrides']['Servers/1/extension'] = extension_loaded('mysqli')
* Use only full paths and form ids
*/
$cfg_db['_validators'] = array(
'CharTextareaCols' => 'PMA_validatePositiveNumber',
'CharTextareaRows' => 'PMA_validatePositiveNumber',
'ExecTimeLimit' => 'PMA_validateNonNegativeNumber',
'Export/sql_max_query_size' => 'PMA_validatePositiveNumber',
'ForeignKeyMaxLimit' => 'PMA_validatePositiveNumber',
'Import/csv_enclosed' => array(array('PMA_validateByRegex', '/^.?$/')),
'Import/csv_escaped' => array(array('PMA_validateByRegex', '/^.$/')),
'Import/csv_terminated' => array(array('PMA_validateByRegex', '/^.$/')),
'Import/ldi_enclosed' => array(array('PMA_validateByRegex', '/^.?$/')),
'Import/ldi_escaped' => array(array('PMA_validateByRegex', '/^.$/')),
'Import/ldi_terminated' => array(array('PMA_validateByRegex', '/^.$/')),
'Import/skip_queries' => 'PMA_validateNonNegativeNumber',
'InsertRows' => 'PMA_validatePositiveNumber',
'NumRecentTables' => 'PMA_validateNonNegativeNumber',
'LimitChars' => 'PMA_validatePositiveNumber',
'LoginCookieValidity' => 'PMA_validatePositiveNumber',
'LoginCookieStore' => 'PMA_validateNonNegativeNumber',
'MaxDbList' => 'PMA_validatePositiveNumber',
'MaxNavigationItems' => 'PMA_validatePositiveNumber',
'MaxCharactersInDisplayedSQL' => 'PMA_validatePositiveNumber',
'MaxRows' => 'PMA_validatePositiveNumber',
'MaxTableList' => 'PMA_validatePositiveNumber',
'MemoryLimit' => array(array('PMA_validateByRegex', '/^\d+(?:[kmg])?$/i')),
'NavigationTreeTableLevel' => 'PMA_validatePositiveNumber',
'QueryHistoryMax' => 'PMA_validatePositiveNumber',
'QueryWindowWidth' => 'PMA_validatePositiveNumber',
'QueryWindowHeight' => 'PMA_validatePositiveNumber',
'RepeatCells' => 'PMA_validateNonNegativeNumber',
'Server' => 'PMA_validateServer',
'Server_pmadb' => 'PMA_validatePMAStorage',
'Servers/1/port' => 'PMA_validatePortNumber',
'Servers/1/hide_db' => 'PMA_validateRegex',
'TextareaCols' => 'PMA_validatePositiveNumber',
'TextareaRows' => 'PMA_validatePositiveNumber',
'TrustedProxies' => 'PMA_validateTrustedProxies');
'CharTextareaCols' => 'validatePositiveNumber',
'CharTextareaRows' => 'validatePositiveNumber',
'ExecTimeLimit' => 'validateNonNegativeNumber',
'Export/sql_max_query_size' => 'validatePositiveNumber',
'ForeignKeyMaxLimit' => 'validatePositiveNumber',
'Import/csv_enclosed' => array(array('validateByRegex', '/^.?$/')),
'Import/csv_escaped' => array(array('validateByRegex', '/^.$/')),
'Import/csv_terminated' => array(array('validateByRegex', '/^.$/')),
'Import/ldi_enclosed' => array(array('validateByRegex', '/^.?$/')),
'Import/ldi_escaped' => array(array('validateByRegex', '/^.$/')),
'Import/ldi_terminated' => array(array('validateByRegex', '/^.$/')),
'Import/skip_queries' => 'validateNonNegativeNumber',
'InsertRows' => 'validatePositiveNumber',
'NumRecentTables' => 'validateNonNegativeNumber',
'LimitChars' => 'validatePositiveNumber',
'LoginCookieValidity' => 'validatePositiveNumber',
'LoginCookieStore' => 'validateNonNegativeNumber',
'MaxDbList' => 'validatePositiveNumber',
'MaxNavigationItems' => 'validatePositiveNumber',
'MaxCharactersInDisplayedSQL' => 'validatePositiveNumber',
'MaxRows' => 'validatePositiveNumber',
'MaxTableList' => 'validatePositiveNumber',
'MemoryLimit' => array(array('validateByRegex', '/^\d+(?:[kmg])?$/i')),
'NavigationTreeTableLevel' => 'validatePositiveNumber',
'QueryHistoryMax' => 'validatePositiveNumber',
'QueryWindowWidth' => 'validatePositiveNumber',
'QueryWindowHeight' => 'validatePositiveNumber',
'RepeatCells' => 'validateNonNegativeNumber',
'Server' => 'validateServer',
'Server_pmadb' => 'validatePMAStorage',
'Servers/1/port' => 'validatePortNumber',
'Servers/1/hide_db' => 'validateRegex',
'TextareaCols' => 'validatePositiveNumber',
'TextareaRows' => 'validatePositiveNumber',
'TrustedProxies' => 'validateTrustedProxies');
/**
* Additional validators used for user preferences

View File

@ -447,6 +447,7 @@ function PMA_addJsValidate($field_id, $validators, &$js_array)
foreach ((array)$validators as $validator) {
$validator = (array)$validator;
$v_name = array_shift($validator);
$v_name = "PMA_" . $v_name;
$v_args = array();
foreach ($validator as $arg) {
$v_args[] = PMA_escapeJsString($arg);

View File

@ -109,6 +109,7 @@ class PMA_Validator
foreach ((array)$validators[$vid] as $validator) {
$vdef = (array) $validator;
$vname = array_shift($vdef);
$vname = "PMA_Validator::" . $vname;
$args = array_merge(array($vid, &$arguments), $vdef);
$r = call_user_func_array($vname, $args);

View File

@ -1180,7 +1180,7 @@ function PMA_getSelectOptionForUpload($vkey, $column)
if ($files === false) {
return '<font color="red">' . __('Error') . '</font><br />' . "\n"
. __('The directory you set for upload work cannot be reached') . "\n";
. __('The directory you set for upload work cannot be reached.') . "\n";
} elseif (!empty($files)) {
return "<br />\n"
. '<i>' . __('Or') . '</i>' . ' '

View File

@ -659,7 +659,7 @@ class AuthenticationCookie extends AuthenticationPlugin
$conn_error = __('Access denied');
} elseif (! empty($GLOBALS['no_activity'])) {
$conn_error = sprintf(
__('No activity within %s seconds; please log in again'),
__('No activity within %s seconds; please log in again.'),
$GLOBALS['cfg']['LoginCookieValidity']
);
} elseif ($GLOBALS['dbi']->getError()) {

View File

@ -251,7 +251,7 @@ class AuthenticationSignon extends AuthenticationPlugin
$_SESSION['PMA_single_signon_error_message'] = __('Access denied');
} elseif (! empty($GLOBALS['no_activity'])) {
$_SESSION['PMA_single_signon_error_message'] = sprintf(
__('No activity within %s seconds; please log in again'),
__('No activity within %s seconds; please log in again.'),
$GLOBALS['cfg']['LoginCookieValidity']
);
} elseif ($GLOBALS['dbi']->getError()) {

View File

@ -173,7 +173,7 @@ function Swekey_auth_error()
$res = Swekey_CheckOtp($swekey_id, $_SESSION['SWEKEY']['RND_TOKEN'], $swekey_otp);
unset($_SESSION['SWEKEY']['RND_TOKEN']);
if (! $res) {
$result = __('Hardware authentication failed') . ' (' . Swekey_GetLastError() . ')';
$result = __('Hardware authentication failed!') . ' (' . Swekey_GetLastError() . ')';
} else {
$_SESSION['SWEKEY']['AUTHENTICATED_SWEKEY'] = $swekey_id;
$_SESSION['SWEKEY']['FORCE_USER'] = $_SESSION['SWEKEY']['VALID_SWEKEYS'][$swekey_id];
@ -193,7 +193,7 @@ function Swekey_auth_error()
$_SESSION['SWEKEY']['RND_TOKEN'] = Swekey_GetFastRndToken();
if (strlen($_SESSION['SWEKEY']['RND_TOKEN']) != 64) {
$result = __('Hardware authentication failed') . ' (' . Swekey_GetLastError() . ')';
$result = __('Hardware authentication failed!') . ' (' . Swekey_GetLastError() . ')';
unset($_SESSION['SWEKEY']['CONF_LOADED']); // reload the conf file
}

View File

@ -480,7 +480,7 @@ function PMA_sqlQueryFormUpload()
echo '</div>';
if ($files === false) {
$errors[] = PMA_Message::error(__('The directory you set for upload work cannot be reached'));
$errors[] = PMA_Message::error(__('The directory you set for upload work cannot be reached.'));
} elseif (!empty($files)) {
echo '<div class="formelement">';
echo '<strong>' . __('web server upload directory:') .'</strong>' . "\n";

View File

@ -130,7 +130,7 @@ function PMA_SQP_throwError($message, $sql)
. __(
'There seems to be an error in your SQL query. The MySQL server '
. 'error output below, if there is any, may also help you in '
. 'diagnosing the problem'
. 'diagnosing the problem.'
)
. '</p>' . "\n"
. '<pre>' . "\n"

View File

@ -175,6 +175,10 @@ function PMA_readUserprefsFieldNames(array $forms = null)
{
static $names;
if (defined('TESTSUITE')) {
$names = null;
}
// return cached results
if ($names !== null) {
return $names;

1440
po/af.po

File diff suppressed because it is too large Load Diff

1442
po/ar.po

File diff suppressed because it is too large Load Diff

1440
po/az.po

File diff suppressed because it is too large Load Diff

1440
po/be.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1468
po/bg.po

File diff suppressed because it is too large Load Diff

2579
po/bn.po

File diff suppressed because it is too large Load Diff

1466
po/br.po

File diff suppressed because it is too large Load Diff

1438
po/bs.po

File diff suppressed because it is too large Load Diff

1446
po/ca.po

File diff suppressed because it is too large Load Diff

1444
po/ckb.po

File diff suppressed because it is too large Load Diff

1449
po/cs.po

File diff suppressed because it is too large Load Diff

1452
po/cy.po

File diff suppressed because it is too large Load Diff

1445
po/da.po

File diff suppressed because it is too large Load Diff

1452
po/de.po

File diff suppressed because it is too large Load Diff

1456
po/el.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1464
po/es.po

File diff suppressed because it is too large Load Diff

1448
po/et.po

File diff suppressed because it is too large Load Diff

1442
po/eu.po

File diff suppressed because it is too large Load Diff

1448
po/fa.po

File diff suppressed because it is too large Load Diff

1479
po/fi.po

File diff suppressed because it is too large Load Diff

1458
po/fr.po

File diff suppressed because it is too large Load Diff

1491
po/gl.po

File diff suppressed because it is too large Load Diff

1438
po/he.po

File diff suppressed because it is too large Load Diff

1452
po/hi.po

File diff suppressed because it is too large Load Diff

1442
po/hr.po

File diff suppressed because it is too large Load Diff

1460
po/hu.po

File diff suppressed because it is too large Load Diff

1444
po/hy.po

File diff suppressed because it is too large Load Diff

1455
po/ia.po

File diff suppressed because it is too large Load Diff

1446
po/id.po

File diff suppressed because it is too large Load Diff

1466
po/it.po

File diff suppressed because it is too large Load Diff

1448
po/ja.po

File diff suppressed because it is too large Load Diff

1448
po/ka.po

File diff suppressed because it is too large Load Diff

1444
po/kk.po

File diff suppressed because it is too large Load Diff

1444
po/kn.po

File diff suppressed because it is too large Load Diff

1442
po/ko.po

File diff suppressed because it is too large Load Diff

1454
po/lt.po

File diff suppressed because it is too large Load Diff

1440
po/lv.po

File diff suppressed because it is too large Load Diff

1440
po/mk.po

File diff suppressed because it is too large Load Diff

1444
po/ml.po

File diff suppressed because it is too large Load Diff

1440
po/mn.po

File diff suppressed because it is too large Load Diff

1438
po/ms.po

File diff suppressed because it is too large Load Diff

1474
po/nb.po

File diff suppressed because it is too large Load Diff

1457
po/nl.po

File diff suppressed because it is too large Load Diff

1444
po/pa.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1462
po/pl.po

File diff suppressed because it is too large Load Diff

1466
po/pt.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1450
po/ro.po

File diff suppressed because it is too large Load Diff

1460
po/ru.po

File diff suppressed because it is too large Load Diff

1460
po/si.po

File diff suppressed because it is too large Load Diff

1444
po/sk.po

File diff suppressed because it is too large Load Diff

1450
po/sl.po

File diff suppressed because it is too large Load Diff

1438
po/sq.po

File diff suppressed because it is too large Load Diff

1440
po/sr.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1446
po/sv.po

File diff suppressed because it is too large Load Diff

1444
po/ta.po

File diff suppressed because it is too large Load Diff

1448
po/te.po

File diff suppressed because it is too large Load Diff

1442
po/th.po

File diff suppressed because it is too large Load Diff

1444
po/tk.po

File diff suppressed because it is too large Load Diff

1453
po/tr.po

File diff suppressed because it is too large Load Diff

1440
po/tt.po

File diff suppressed because it is too large Load Diff

1440
po/ug.po

File diff suppressed because it is too large Load Diff

1487
po/uk.po

File diff suppressed because it is too large Load Diff

1452
po/ur.po

File diff suppressed because it is too large Load Diff

1474
po/uz.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -106,37 +106,11 @@ function PMA_version_check()
// version check messages should always be visible so let's make
// a unique message id each time we run it
$message_id = uniqid('version_check');
// wait 3s at most for server response, it's enough to get information
// from a working server
$connection_timeout = 3;
$url = 'http://phpmyadmin.net/home_page/version.php';
$context = stream_context_create(
array(
'http' => array('timeout' => $connection_timeout)
)
);
$data = @file_get_contents($url, null, $context);
if ($data === false) {
if (function_exists('curl_init')) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, $connection_timeout);
$data = curl_exec($ch);
curl_close($ch);
} else {
messages_set(
'error',
$message_id,
__('Version check'),
__('Neither URL wrapper nor CURL is available. Version check is not possible.')
);
return;
}
}
// Fetch data
$version_data = PMA_Util::getLatestVersion();
if (empty($data)) {
if (empty($version_data)) {
messages_set(
'error',
$message_id,
@ -146,17 +120,10 @@ function PMA_version_check()
return;
}
/* Format: version\ndate\n(download\n)* */
$data_list = explode("\n", $data);
$version = $version_data->version;
$date = $version_data->date;
if (count($data_list) > 1) {
$version = $data_list[0];
$date = $data_list[1];
} else {
$version = $date = '';
}
$version_upstream = version_to_int($version);
$version_upstream = PMA_Util::versionToInt($version);
if ($version_upstream === false) {
messages_set(
'error',
@ -167,7 +134,7 @@ function PMA_version_check()
return;
}
$version_local = version_to_int($GLOBALS['PMA_Config']->get('PMA_VERSION'));
$version_local = PMA_Util::versionToInt($GLOBALS['PMA_Config']->get('PMA_VERSION'));
if ($version_local === false) {
messages_set(
'error',
@ -206,55 +173,6 @@ function PMA_version_check()
}
}
/**
* Calculates numerical equivalent of phpMyAdmin version string
*
* @param string $version version
*
* @return mixed false on failure, integer on success
*/
function version_to_int($version)
{
$matches = array();
if (!preg_match('/^(\d+)\.(\d+)\.(\d+)((\.|-(pl|rc|dev|beta|alpha))(\d+)?(-dev)?)?$/', $version, $matches)) {
return false;
}
if (!empty($matches[6])) {
switch ($matches[6]) {
case 'pl':
$added = 60;
break;
case 'rc':
$added = 30;
break;
case 'beta':
$added = 20;
break;
case 'alpha':
$added = 10;
break;
case 'dev':
$added = 0;
break;
default:
messages_set(
'notice',
'version_match',
__('Version check'),
'Unknown version part: ' . htmlspecialchars($matches[6])
);
$added = 0;
break;
}
} else {
$added = 50; // for final
}
if (!empty($matches[7])) {
$added = $added + $matches[7];
}
return $matches[1] * 1000000 + $matches[2] * 10000 + $matches[3] * 100 + $added;
}
/**
* Checks whether config file is readable/writable
*

View File

@ -97,4 +97,68 @@ class PMA_Util_Test extends PHPUnit_Framework_TestCase
PMA_Util::pageselector("pma", 3)
);
}
/**
* Test version checking
*
* @return void
*
* @group large
*/
public function testGetLatestVersion()
{
$GLOBALS['cfg']['VersionCheckProxyUrl'] = '';
$version = PMA_Util::getLatestVersion();
$this->assertNotEmpty($version->version);
$this->assertNotEmpty($version->date);
}
/**
* Test version to int conversion.
*
* @param string $version Version string
* @param int $numberic Integer matching version
*
* @return void
*
* @dataProvider dataVersions
*/
public function testVersionToInt($version, $numeric)
{
$this->assertEquals(
$numeric,
PMA_Util::versionToInt($version)
);
}
/**
* Data provider for version parsing
*
* @return array with test data
*/
public function dataVersions()
{
return array(
array('1.0.0', 1000050),
array('2.0.0.2-dev', 2000002),
array('3.4.2.1', 3040251),
array('3.4.2-dev3', 3040203),
array('3.4.2-dev', 3040200),
array('3.4.2-pl', 3040260),
array('3.4.2-pl3', 3040263),
array('4.4.2-rc22', 4040252),
array('4.4.2-rc', 4040230),
array('4.4.22-beta22', 4042242),
array('4.4.22-beta', 4042220),
array('4.4.21-alpha22', 4042132),
array('4.4.20-alpha', 4042010),
array('4.40.20-alpha-dev', 4402010),
array('4.4a', 4000050),
array('4.4.4-test', 4040400),
array('4.1.0', 4010050),
array('4.0.1.3', 4000153),
array('4.1-dev', 4010000),
);
}
}

View File

@ -39,6 +39,7 @@ class PMA_ConfigGenerator_Test extends PHPUnit_Framework_TestCase
$GLOBALS['server'] = 0;
$cf = ConfigFile::getInstance();
$_SESSION['ConfigFile0'] = array('a', 'b', 'c');
$_SESSION['ConfigFile0']['Servers'] = array(
array(1, 2, 3)
);

View File

@ -233,6 +233,7 @@ class PMA_FormDisplay_Tpl_Test extends PHPUnit_Framework_TestCase
$opts['doc'] = "http://doclink";
$opts['wiki'] = "http://wikilink";
$opts['comment'] = "testComment";
$opts['comment_warning'] = true;
$opts['show_restore_default'] = true;
ob_start();
PMA_displayInput(
@ -319,7 +320,7 @@ class PMA_FormDisplay_Tpl_Test extends PHPUnit_Framework_TestCase
$this->assertTag(
$this->_getTagArray(
'<span class="field-comment-mark" title="testComment">',
'<span class="field-comment-mark field-comment-warning" title="testComment">',
array('content' => 'i')
),
$result
@ -771,9 +772,9 @@ class PMA_FormDisplay_Tpl_Test extends PHPUnit_Framework_TestCase
$this->assertEquals(
array(
'validateField(\'testID\', \'\\\';\', true, [\'\\\\r\\\\n\\\\\\\'' .
'validateField(\'testID\', \'PMA_\\\';\', true, [\'\\\\r\\\\n\\\\\\\'' .
'<scrIpt></\\\' + \\\'script>\'])',
'validateField(\'testID\', \'\', true)'
'validateField(\'testID\', \'PMA_\', true)'
),
$js
);

View File

@ -23,7 +23,7 @@ class PMA_SetupIndex_Test extends PHPUnit_Framework_TestCase
{
/**
* Test for messages_begin()
*
*
* @return void
*/
public function testMessagesBegin()
@ -70,7 +70,7 @@ class PMA_SetupIndex_Test extends PHPUnit_Framework_TestCase
/**
* Test for messages_set
*
*
* @return void
*/
public function testMessagesSet()
@ -90,7 +90,7 @@ class PMA_SetupIndex_Test extends PHPUnit_Framework_TestCase
/**
* Test for messages_end
*
*
* @return void
*/
public function testMessagesEnd()
@ -119,7 +119,7 @@ class PMA_SetupIndex_Test extends PHPUnit_Framework_TestCase
/**
* Test for messages_show_html
*
*
* @return void
*/
public function testMessagesShowHTML()
@ -149,7 +149,7 @@ class PMA_SetupIndex_Test extends PHPUnit_Framework_TestCase
'<script type="text/javascript">',
$result
);
$this->assertContains(
"hiddenMessages.push('0');",
$result
@ -163,7 +163,7 @@ class PMA_SetupIndex_Test extends PHPUnit_Framework_TestCase
/**
* Test for PMA_version_check
*
*
* @return void
*/
public function testPMAVersionCheckCase1()
@ -211,11 +211,11 @@ class PMA_SetupIndex_Test extends PHPUnit_Framework_TestCase
/**
* Test for PMA_version_check
*
*
* @return void
*/
public function testPMAVersionCheckCase2()
{
{
$pmaconfig = $this->getMockBuilder('PMA_Config')
->disableOriginalConstructor()
->getMock();
@ -228,7 +228,7 @@ class PMA_SetupIndex_Test extends PHPUnit_Framework_TestCase
$GLOBALS['PMA_Config'] = $pmaconfig;
PMA_version_check();
$this->assertArrayHasKey(
'notice',
$_SESSION['messages']
@ -259,11 +259,11 @@ class PMA_SetupIndex_Test extends PHPUnit_Framework_TestCase
/**
* Test for PMA_version_check
*
*
* @return void
*/
public function testPMAVersionCheckCase3()
{
{
$pmaconfig = $this->getMockBuilder('PMA_Config')
->disableOriginalConstructor()
->getMock();
@ -276,7 +276,7 @@ class PMA_SetupIndex_Test extends PHPUnit_Framework_TestCase
$GLOBALS['PMA_Config'] = $pmaconfig;
PMA_version_check();
$this->assertArrayHasKey(
'notice',
$_SESSION['messages']
@ -305,57 +305,13 @@ class PMA_SetupIndex_Test extends PHPUnit_Framework_TestCase
);
}
/**
* Test for version_to_int
*
* @param string $version Version String
* @param int $expected Expected int
*
* @return void
* @dataProvider versionToIntProvider
*/
public function testVersionToInt($version, $expected)
{
$this->assertEquals(
version_to_int($version),
$expected
);
}
/**
* Data Provider for testVersionToInt
*
* @return array Test data
*/
public function versionToIntProvider()
{
return array(
array('1.0.0', 1000050),
array('2.0.0.2-dev', 2000052),
array('3.4.2.1', 3040251),
array('3.4.2-dev3', 3040203),
array('3.4.2-dev', 3040200),
array('3.4.2-pl', 3040260),
array('3.4.2-pl3', 3040263),
array('4.4.2-rc22', 4040252),
array('4.4.2-rc', 4040230),
array('4.4.22-beta22', 4042242),
array('4.4.22-beta', 4042220),
array('4.4.21-alpha22', 4042132),
array('4.4.20-alpha', 4042010),
array('4.40.20-alpha-dev', 4402010),
array('4.4a', false),
array('4.4.4-test', false)
);
}
/**
* Test for check_config_rw
*
*
* @return void
*/
public function testCheckConfigRW()
{
{
if (!function_exists('runkit_constant_redefine')) {
$this->markTestSkipped('Cannot redefine constant');
}
@ -374,9 +330,9 @@ class PMA_SetupIndex_Test extends PHPUnit_Framework_TestCase
$is_readable = false;
$is_writable = false;
$file_exists = false;
check_config_rw($is_readable, $is_writable, $file_exists);
$this->assertTrue(
$is_readable
);
@ -395,7 +351,7 @@ class PMA_SetupIndex_Test extends PHPUnit_Framework_TestCase
);
check_config_rw($is_readable, $is_writable, $file_exists);
$this->assertTrue(
$is_readable
);
@ -417,11 +373,11 @@ class PMA_SetupIndex_Test extends PHPUnit_Framework_TestCase
/**
* Test for perform_config_checks
*
*
* @return void
*/
public function testPerformConfigChecks()
{
{
$GLOBALS['cfg']['AvailableCharsets'] = array();
$GLOBALS['cfg']['ServerDefault'] = 0;
@ -453,7 +409,7 @@ class PMA_SetupIndex_Test extends PHPUnit_Framework_TestCase
$_SESSION[$sessionID]['GZipDump'] = true;
$_SESSION[$sessionID]['BZipDump'] = true;
$_SESSION[$sessionID]['ZipDump'] = true;
$noticeArrayKeys = array(
'TempDir',
'SaveDir',
@ -501,13 +457,13 @@ class PMA_SetupIndex_Test extends PHPUnit_Framework_TestCase
$_SESSION['messages']['error']
);
}
// Case 2
unset($_SESSION['messages']);
unset($_SESSION[$sessionID]);
$_SESSION[$sessionID]['Servers'] = array(
'1' => array(
'host' => 'localhost',
@ -549,7 +505,7 @@ class PMA_SetupIndex_Test extends PHPUnit_Framework_TestCase
// Case 3
$_SESSION[$sessionID]['blowfish_secret'] = 'sec';
$_SESSION[$sessionID]['Servers'] = array(
'1' => array(
'host' => 'localhost',

View File

@ -293,16 +293,26 @@ class PMA_User_Preferences_Test extends PHPUnit_Framework_TestCase
/**
* Test for PMA_readUserprefsFieldNames
* This test would only work when executed with other tests.
* This is to test "static" nature of this function
*
* @return void
*/
public function testReadUserprefsFieldNames()
{
$this->assertCount(
216,
PMA_readUserprefsFieldNames()
);
$forms = array(
'form1' => array(
array('Servers/1/hide_db', 'bar'),
array('test' => 'val')
)
);
$this->assertEquals(
array('Servers/1/hide_db', 'bar', 'test'),
PMA_readUserprefsFieldNames(array())
PMA_readUserprefsFieldNames($forms)
);
}

View File

@ -9,69 +9,16 @@
// Sets up the session
define('PMA_MINIMUM_COMMON', true);
require_once 'libraries/common.inc.php';
// Get response text from phpmyadmin.net or from the session
// Update cache every 6 hours
if (isset($_SESSION['cache']['version_check'])
&& time() < $_SESSION['cache']['version_check']['timestamp'] + 3600 * 6
) {
$save = false;
$response = $_SESSION['cache']['version_check']['response'];
} else {
$save = true;
$file = 'http://www.phpmyadmin.net/home_page/version.json';
if (ini_get('allow_url_fopen')) {
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);
}
}
require_once 'libraries/Util.class.php';
// Always send the correct headers
header('Content-type: application/json; charset=UTF-8');
// Save and forward the response only if in valid format
$data = json_decode($response);
if (is_object($data) && strlen($data->version) && strlen($data->date)) {
if ($save) {
$_SESSION['cache']['version_check'] = array(
'response' => $response,
'timestamp' => time()
);
}
echo $response;
}
$version = PMA_Util::getLatestVersion();
echo json_encode(array(
'version' => $version->version,
'date' => $version->date,
));
?>