Merge remote-tracking branch 'origin/master'

This commit is contained in:
Michal Čihař 2012-05-07 19:46:03 +02:00
commit 826efb4355
9 changed files with 233 additions and 139 deletions

View File

@ -101,14 +101,17 @@ function PMA_auth_fails()
// Check whether user has configured something
if ($GLOBALS['PMA_Config']->source_mtime == 0) {
echo '<p>' . sprintf(__('You probably did not create a configuration file. You might want to use the %1$ssetup script%2$s to create one.'), '<a href="setup/">', '</a>') . '</p>' . "\n";
} elseif (!isset($GLOBALS['errno']) || (isset($GLOBALS['errno']) && $GLOBALS['errno'] != 2002) && $GLOBALS['errno'] != 2003) {
// if we display the "Server not responding" error, do not confuse users
// by telling them they have a settings problem
// (note: it's true that they could have a badly typed host name, but
// anyway the current message tells that the server
// rejected the connection, which is not really what happened)
// 2002 is the error given by mysqli
// 2003 is the error given by mysql
} elseif (! isset($GLOBALS['errno'])
|| (isset($GLOBALS['errno']) && $GLOBALS['errno'] != 2002)
&& $GLOBALS['errno'] != 2003
) {
// if we display the "Server not responding" error, do not confuse users
// by telling them they have a settings problem
// (note: it's true that they could have a badly typed host name, but
// anyway the current message tells that the server
// rejected the connection, which is not really what happened)
// 2002 is the error given by mysqli
// 2003 is the error given by mysql
trigger_error(__('phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.'), E_USER_WARNING);
}
PMA_mysqlDie($conn_error, '', true, '', false);

View File

@ -37,7 +37,9 @@ if (function_exists('mcrypt_encrypt')) {
* further decryption. I don't think necessary to have one iv
* per server so I don't put the server number in the cookie name.
*/
if (empty($_COOKIE['pma_mcrypt_iv']) || false === ($iv = base64_decode($_COOKIE['pma_mcrypt_iv'], true))) {
if (empty($_COOKIE['pma_mcrypt_iv'])
|| false === ($iv = base64_decode($_COOKIE['pma_mcrypt_iv'], true))
) {
srand((double) microtime() * 1000000);
$td = mcrypt_module_open(MCRYPT_BLOWFISH, '', MCRYPT_MODE_CBC, '');
if ($td === false) {
@ -50,8 +52,8 @@ if (function_exists('mcrypt_encrypt')) {
/**
* Encryption using blowfish algorithm (mcrypt)
*
* @param string original data
* @param string the secret
* @param string $data original data
* @param string $secret the secret
*
* @return string the encrypted result
*
@ -61,14 +63,16 @@ if (function_exists('mcrypt_encrypt')) {
function PMA_blowfish_encrypt($data, $secret)
{
global $iv;
return base64_encode(mcrypt_encrypt(MCRYPT_BLOWFISH, $secret, $data, MCRYPT_MODE_CBC, $iv));
return base64_encode(
mcrypt_encrypt(MCRYPT_BLOWFISH, $secret, $data, MCRYPT_MODE_CBC, $iv)
);
}
/**
* Decryption using blowfish algorithm (mcrypt)
*
* @param string encrypted data
* @param string the secret
* @param string $encdata encrypted data
* @param string $secret the secret
*
* @return string original data
*
@ -135,7 +139,9 @@ function PMA_auth()
}
/* No recall if blowfish secret is not configured as it would produce garbage */
if ($GLOBALS['cfg']['LoginCookieRecall'] && !empty($GLOBALS['cfg']['blowfish_secret'])) {
if ($GLOBALS['cfg']['LoginCookieRecall']
&& ! empty($GLOBALS['cfg']['blowfish_secret'])
) {
$default_user = $GLOBALS['PHP_AUTH_USER'];
$default_server = $GLOBALS['pma_auth_server'];
$autocomplete = '';
@ -171,10 +177,12 @@ function PMA_auth()
<a href="<?php echo PMA_linkURL('http://www.phpmyadmin.net/'); ?>" target="_blank" class="logo"><?php
$logo_image = $GLOBALS['pmaThemeImage'] . 'logo_right.png';
if (@file_exists($logo_image)) {
echo '<img src="' . $logo_image . '" id="imLogo" name="imLogo" alt="phpMyAdmin" border="0" />';
echo '<img src="' . $logo_image
. '" id="imLogo" name="imLogo" alt="phpMyAdmin" border="0" />';
} else {
echo '<img name="imLogo" id="imLogo" src="' . $GLOBALS['pmaThemeImage'] . 'pma_logo.png' . '" '
. 'border="0" width="88" height="31" alt="phpMyAdmin" />';
echo '<img name="imLogo" id="imLogo" src="'
. $GLOBALS['pmaThemeImage'] . 'pma_logo.png' . '" '
. 'border="0" width="88" height="31" alt="phpMyAdmin" />';
}
?></a>
<h1>
@ -388,8 +396,12 @@ function PMA_auth_check()
if (! empty($_REQUEST['pma_username'])) {
// The user just logged in
$GLOBALS['PHP_AUTH_USER'] = $_REQUEST['pma_username'];
$GLOBALS['PHP_AUTH_PW'] = empty($_REQUEST['pma_password']) ? '' : $_REQUEST['pma_password'];
if ($GLOBALS['cfg']['AllowArbitraryServer'] && isset($_REQUEST['pma_servername'])) {
$GLOBALS['PHP_AUTH_PW'] = empty($_REQUEST['pma_password'])
? ''
: $_REQUEST['pma_password'];
if ($GLOBALS['cfg']['AllowArbitraryServer']
&& isset($_REQUEST['pma_servername'])
) {
$GLOBALS['pma_auth_server'] = $_REQUEST['pma_servername'];
}
return true;
@ -536,10 +548,15 @@ function PMA_auth_set_user()
if ($GLOBALS['cfg']['AllowArbitraryServer']) {
if (! empty($GLOBALS['pma_auth_server'])) {
// Duration = one month for servername
$GLOBALS['PMA_Config']->setCookie('pmaServer-' . $GLOBALS['server'], $cfg['Server']['host']);
$GLOBALS['PMA_Config']->setCookie(
'pmaServer-' . $GLOBALS['server'],
$cfg['Server']['host']
);
} else {
// Delete servername cookie
$GLOBALS['PMA_Config']->removeCookie('pmaServer-' . $GLOBALS['server']);
$GLOBALS['PMA_Config']->removeCookie(
'pmaServer-' . $GLOBALS['server']
);
}
}
@ -569,7 +586,9 @@ function PMA_auth_set_user()
*/
PMA_clearUserCache();
PMA_sendHeaderLocation($redirect_url . PMA_generate_common_url($url_params, '&'));
PMA_sendHeaderLocation(
$redirect_url . PMA_generate_common_url($url_params, '&')
);
exit();
} // end if
@ -610,7 +629,8 @@ function PMA_auth_fails()
}
}
} elseif (PMA_DBI_getError()) {
$conn_error = '#' . $GLOBALS['errno'] . ' ' . __('Cannot log in to the MySQL server');
$conn_error = '#' . $GLOBALS['errno'] . ' '
. __('Cannot log in to the MySQL server');
} else {
$conn_error = __('Cannot log in to the MySQL server');
}

View File

@ -23,7 +23,9 @@
function PMA_auth()
{
/* Perform logout to custom URL */
if (!empty($_REQUEST['old_usr']) && !empty($GLOBALS['cfg']['Server']['LogoutURL'])) {
if (! empty($_REQUEST['old_usr'])
&& ! empty($GLOBALS['cfg']['Server']['LogoutURL'])
) {
PMA_sendHeaderLocation($GLOBALS['cfg']['Server']['LogoutURL']);
exit;
}
@ -119,7 +121,9 @@ function PMA_auth_check()
} elseif (PMA_getenv('AUTH_USER')) {
// WebSite Professional
$PHP_AUTH_USER = PMA_getenv('AUTH_USER');
} elseif (PMA_getenv('HTTP_AUTHORIZATION') && false === strpos(PMA_getenv('HTTP_AUTHORIZATION'), '<')) {
} elseif (PMA_getenv('HTTP_AUTHORIZATION')
&& false === strpos(PMA_getenv('HTTP_AUTHORIZATION'), '<')
) {
// IIS, might be encoded, see below; also prevent XSS
$PHP_AUTH_USER = PMA_getenv('HTTP_AUTHORIZATION');
} elseif (PMA_getenv('Authorization')) {

View File

@ -24,7 +24,9 @@ function PMA_auth()
unset($_SESSION['LAST_SIGNON_URL']);
if (empty($GLOBALS['cfg']['Server']['SignonURL'])) {
PMA_fatalError('You must set SignonURL!');
} elseif (!empty($_REQUEST['old_usr']) && !empty($GLOBALS['cfg']['Server']['LogoutURL'])) {
} elseif (! empty($_REQUEST['old_usr'])
&& ! empty($GLOBALS['cfg']['Server']['LogoutURL'])
) {
/* Perform logout to custom URL */
PMA_sendHeaderLocation($GLOBALS['cfg']['Server']['LogoutURL']);
} else {
@ -58,7 +60,9 @@ function PMA_auth_check()
global $PHP_AUTH_USER, $PHP_AUTH_PW;
/* Check if we're using same sigon server */
if (isset($_SESSION['LAST_SIGNON_URL']) && $_SESSION['LAST_SIGNON_URL'] != $GLOBALS['cfg']['Server']['SignonURL']) {
if (isset($_SESSION['LAST_SIGNON_URL'])
&& $_SESSION['LAST_SIGNON_URL'] != $GLOBALS['cfg']['Server']['SignonURL']
) {
return false;
}
@ -86,14 +90,16 @@ function PMA_auth_check()
/* Handle script based auth */
if (!empty($script_name)) {
if (! file_exists($script_name)) {
PMA_fatalError(__('Can not find signon authentication script:') . ' ' . $script_name);
PMA_fatalError(
__('Can not find signon authentication script:') . ' ' . $script_name
);
}
include $script_name;
list ($PHP_AUTH_USER, $PHP_AUTH_PW) = get_login_credentials($cfg['Server']['user']);
list ($PHP_AUTH_USER, $PHP_AUTH_PW)
= get_login_credentials($cfg['Server']['user']);
/* Does session exist? */
} elseif (isset($_COOKIE[$session_name])) {
} elseif (isset($_COOKIE[$session_name])) { /* Does session exist? */
/* End current session */
$old_session = session_name();
$old_id = session_id();
@ -158,7 +164,10 @@ function PMA_auth_check()
$GLOBALS['cfg']['Server']['port'] = $single_signon_port;
/* Configuration update */
$GLOBALS['cfg']['Server'] = array_merge($GLOBALS['cfg']['Server'], $single_signon_cfgupdate);
$GLOBALS['cfg']['Server'] = array_merge(
$GLOBALS['cfg']['Server'],
$single_signon_cfgupdate
);
/* Restore our token */
if (!empty($pma_token)) {

View File

@ -47,9 +47,9 @@ class Form
/**
* Constructor, reads default config values
*
* @param string $form_name
* @param array $form
* @param int $index arbitrary index, stored in Form::$index
* @param string $form_name
* @param array $form
* @param int $index arbitrary index, stored in Form::$index
*/
public function __construct($form_name, array $form, $index = null)
{
@ -60,7 +60,7 @@ class Form
/**
* Returns type of given option
*
* @param string $option_name path or field name
* @param string $option_name path or field name
*
* @return string|null one of: boolean, integer, double, string, select, array
*/
@ -75,7 +75,7 @@ class Form
/**
* Returns allowed values for select fields
*
* @param string $option_path
* @param string $option_path
*
* @return array
*/
@ -118,9 +118,11 @@ class Form
* array_walk callback function, reads path of form fields from
* array (see file comment in setup.forms.php or user_preferences.forms.inc)
*
* @param mixed $value
* @param mixed $key
* @param mixed $prefix
* @param mixed $value
* @param mixed $key
* @param mixed $prefix
*
* @return void
*/
private function _readFormPathsCallback($value, $key, $prefix)
{
@ -146,6 +148,8 @@ class Form
* Reads form paths to {@link $fields}
*
* @param array $form
*
* @return void
*/
protected function readFormPaths($form)
{
@ -167,6 +171,7 @@ class Form
/**
* Reads fields' types to $this->fieldsTypes
*
* @return void
*/
protected function readTypes()
{
@ -192,6 +197,8 @@ class Form
*
* @param string $form_name
* @param array $form
*
* @return void
*/
public function loadForm($form_name, $form)
{

View File

@ -112,10 +112,11 @@ class FormDisplay
/**
* Processes forms, returns true on successful save
*
* @param bool $allow_partial_save allows for partial form saving on failed validation
* @param bool $check_form_submit whether check for $_POST['submit_save']
* @param bool $allow_partial_save allows for partial form saving
* on failed validation
* @param bool $check_form_submit whether check for $_POST['submit_save']
*
* @return boolean
* @return boolean whether processing was successful
*/
public function process($allow_partial_save = true, $check_form_submit = true)
{
@ -133,6 +134,7 @@ class FormDisplay
/**
* Runs validation for all registered forms
*
* @return void
*/
private function _validate()
{
@ -177,7 +179,9 @@ class FormDisplay
* Outputs HTML for forms
*
* @param bool $tabbed_form
* @param bool $show_restore_default whether show "restore default" button besides the input field
* @param bool $show_restore_default whether show "restore default" button
* besides the input field
* @return void
*/
public function display($tabbed_form = false, $show_restore_default = false)
{
@ -279,14 +283,20 @@ class FormDisplay
* Prepares data for input field display and outputs HTML code
*
* @param Form $form
* @param string $field field name as it appears in $form
* @param string $system_path field path, eg. Servers/1/verbose
* @param string $work_path work path, eg. Servers/4/verbose
* @param string $translated_path work path changed so that it can be used as XHTML id
* @param bool $show_restore_default whether show "restore default" button besides the input field
* @param mixed $userprefs_allow whether user preferences are enabled for this field
* (null - no support, true/false - enabled/disabled)
* @param array &$js_default array which stores JavaScript code to be displayed
* @param string $field field name as it appears in $form
* @param string $system_path field path, eg. Servers/1/verbose
* @param string $work_path work path, eg. Servers/4/verbose
* @param string $translated_path work path changed so that it can be
* used as XHTML id
* @param bool $show_restore_default whether show "restore default" button
* besides the input field
* @param mixed $userprefs_allow whether user preferences are enabled
* for this field (null - no support,
* true/false - enabled/disabled)
* @param array &$js_default array which stores JavaScript code
* to be displayed
*
* @return void
*/
private function _displayFieldInput(
Form $form, $field, $system_path, $work_path,
@ -341,7 +351,8 @@ class FormDisplay
$value_default = (array) $value_default;
break;
case 'group':
if (substr($field, 7, 4) != 'end:') { // :group:end is changed to :group:end:{unique id} in Form class
// :group:end is changed to :group:end:{unique id} in Form class
if (substr($field, 7, 4) != 'end:') {
display_group_header(substr($field, 7));
} else {
display_group_footer();
@ -380,7 +391,8 @@ class FormDisplay
$js_line .= '[\'' . PMA_escapeJsString($value_default_js) . '\']';
break;
case 'list':
$js_line .= '\'' . PMA_escapeJsString(implode("\n", $value_default)) . '\'';
$js_line .= '\'' . PMA_escapeJsString(implode("\n", $value_default))
. '\'';
break;
}
$js_default[] = $js_line;
@ -394,6 +406,7 @@ class FormDisplay
/**
* Displays errors
*
* @return void
*/
public function displayErrors()
{
@ -416,7 +429,7 @@ class FormDisplay
/**
* Reverts erroneous fields to their default values
*
*
* @return void
*/
public function fixErrors()
{
@ -438,8 +451,8 @@ class FormDisplay
/**
* Validates select field and casts $value to correct type
*
* @param string $value
* @param array $allowed
* @param string $value
* @param array $allowed
*
* @return bool
*/
@ -450,7 +463,8 @@ class FormDisplay
: $value;
foreach ($allowed as $vk => $v) {
// equality comparison only if both values are numeric or not numeric
// (allows to skip 0 == 'string' equalling to true) or identity (for string-string)
// (allows to skip 0 == 'string' equalling to true)
// or identity (for string-string)
if (($vk == $value && !(is_numeric($value_cmp) xor is_numeric($vk)))
|| $vk === $value
) {
@ -467,10 +481,11 @@ class FormDisplay
/**
* Validates and saves form data to session
*
* @param array|string $forms array of form names
* @param bool $allow_partial_save allows for partial form saving on failed validation
* @param array|string $forms array of form names
* @param bool $allow_partial_save allows for partial form saving on
* failed validation
*
* @return boolean true on success (no errors and all saved)
* @return boolean true on success (no errors and all saved)
*/
public function save($forms, $allow_partial_save = true)
{
@ -547,12 +562,18 @@ class FormDisplay
break;
case 'select':
// special treatment for NavigationBarIconic and PropertiesIconic
if ($key === 'NavigationBarIconic' || $key === 'PropertiesIconic') {
if ($key === 'NavigationBarIconic'
|| $key === 'PropertiesIconic'
) {
if ($_POST[$key] !== 'both') {
settype($_POST[$key], 'boolean');
}
}
if (!$this->_validateSelect($_POST[$key], $form->getOptionValueList($system_path))) {
$successfully_validated = $this->_validateSelect(
$_POST[$key],
$form->getOptionValueList($system_path)
);
if (! $successfully_validated) {
$this->errors[$work_path][] = __('Incorrect value');
$result = false;
continue;
@ -598,7 +619,10 @@ class FormDisplay
$i = 0;
foreach ($values[$path] as $value) {
$matches = array();
if (preg_match("/^(.+):(?:[ ]?)(\\w+)$/", $value, $matches)) {
$match = preg_match(
"/^(.+):(?:[ ]?)(\\w+)$/", $value, $matches
);
if ($match) {
// correct 'IP: HTTP header' pair
$ip = trim($matches[1]);
$proxies[$ip] = trim($matches[2]);
@ -694,6 +718,7 @@ class FormDisplay
/**
* Fills out {@link userprefs_keys} and {@link userprefs_disallow}
*
* @return void
*/
private function _loadUserprefsInfo()
{
@ -712,6 +737,8 @@ class FormDisplay
*
* @param string $system_path
* @param array $opts
*
* @return void
*/
private function _setComments($system_path, array &$opts)
{
@ -720,7 +747,9 @@ class FormDisplay
$comment = '';
if (!function_exists('iconv')) {
$opts['values']['iconv'] .= ' (' . __('unavailable') . ')';
$comment = sprintf(__('"%s" requires %s extension'), 'iconv', 'iconv');
$comment = sprintf(
__('"%s" requires %s extension'), 'iconv', 'iconv'
);
}
if (!function_exists('recode_string')) {
$opts['values']['recode'] .= ' (' . __('unavailable') . ')';
@ -733,7 +762,10 @@ class FormDisplay
$opts['comment_warning'] = true;
}
// ZipDump, GZipDump, BZipDump - check function availability
if ($system_path == 'ZipDump' || $system_path == 'GZipDump' || $system_path == 'BZipDump') {
if ($system_path == 'ZipDump'
|| $system_path == 'GZipDump'
|| $system_path == 'BZipDump'
) {
$comment = '';
$funcs = array(
'ZipDump' => array('zip_open', 'gzcompress'),
@ -754,7 +786,9 @@ class FormDisplay
$opts['comment'] = $comment;
$opts['comment_warning'] = true;
}
if ($system_path == 'SQLQuery/Validate' && !$GLOBALS['cfg']['SQLValidator']['use']) {
if ($system_path == 'SQLQuery/Validate'
&& ! $GLOBALS['cfg']['SQLValidator']['use']
) {
$opts['comment'] = __('SQL Validator is disabled');
$opts['comment_warning'] = true;
}
@ -771,7 +805,9 @@ class FormDisplay
if (($system_path == 'MaxDbList' || $system_path == 'MaxTableList'
|| $system_path == 'QueryHistoryMax')
) {
$opts['comment'] = sprintf(__('maximum %s'), $GLOBALS['cfg'][$system_path]);
$opts['comment'] = sprintf(
__('maximum %s'), $GLOBALS['cfg'][$system_path]
);
}
}
}

View File

@ -9,9 +9,11 @@
/**
* Displays top part of the form
*
* @param string $action default: $_SERVER['REQUEST_URI']
* @param string $method 'post' or 'get'
* @param array $hidden_fields array of form hidden fields (key: field name)
* @param string $action default: $_SERVER['REQUEST_URI']
* @param string $method 'post' or 'get'
* @param array $hidden_fields array of form hidden fields (key: field name)
*
* @return void
*/
function display_form_top($action = null, $method = 'post', $hidden_fields = null)
{
@ -42,7 +44,9 @@ function display_form_top($action = null, $method = 'post', $hidden_fields = nul
* Displays form tabs which are given by an array indexed by fieldset id
* ({@link display_fieldset_top}), with values being tab titles.
*
* @param array $tabs
* @param array $tabs tab names
*
* @return void
*/
function display_tabs_top($tabs)
{
@ -66,8 +70,9 @@ function display_tabs_top($tabs)
* @param array $errors
* @param array $attributes
*/
function display_fieldset_top($title = '', $description = '', $errors = null, $attributes = array())
{
function display_fieldset_top($title = '', $description = '', $errors = null,
$attributes = array()
) {
global $_FormDisplayGroup;
$_FormDisplayGroup = 0;
@ -103,11 +108,12 @@ function display_fieldset_top($title = '', $description = '', $errors = null, $a
* o errors - error array
* o setvalue - (string) shows button allowing to set poredefined value
* o show_restore_default - (boolean) whether show "restore default" button
* o userprefs_allow - whether user preferences are enabled for this field (null - no support,
* true/false - enabled/disabled)
* o userprefs_allow - whether user preferences are enabled for this field
* (null - no support, true/false - enabled/disabled)
* o userprefs_comment - (string) field comment
* o values - key - value paris for <select> fields
* o values_escaped - (boolean) tells whether values array is already escaped (defaults to false)
* o values_escaped - (boolean) tells whether values array is already escaped
* (defaults to false)
* o values_disabled - (array)list of disabled values (keys from values)
* o comment - (string) tooltip comment
* o comment_warning - (bool) whether this comments warns about something
@ -121,8 +127,9 @@ function display_fieldset_top($title = '', $description = '', $errors = null, $a
* @param bool $value_is_default
* @param array $opts
*/
function display_input($path, $name, $description = '', $type, $value, $value_is_default = true, $opts = null)
{
function display_input($path, $name, $description = '', $type, $value,
$value_is_default = true, $opts = null
) {
global $_FormDisplayGroup;
static $base_dir; // Relative path to the root phpMyAdmin folder
static $icons; // An array of IMG tags used further below in the function
@ -166,11 +173,14 @@ function display_input($path, $name, $description = '', $type, $value, $value_is
}
}
$has_errors = isset($opts['errors']) && !empty($opts['errors']);
$option_is_disabled = !$is_setup_script && isset($opts['userprefs_allow']) && !$opts['userprefs_allow'];
$name_id = 'name="' . htmlspecialchars($path) . '" id="' . htmlspecialchars($path) . '"';
$option_is_disabled = ! $is_setup_script && isset($opts['userprefs_allow'])
&& ! $opts['userprefs_allow'];
$name_id = 'name="' . htmlspecialchars($path) . '" id="'
. htmlspecialchars($path) . '"';
$field_class = $type == 'checkbox' ? 'checkbox' : '';
if (!$value_is_default) {
$field_class .= ($field_class == '' ? '' : ' ') . ($has_errors ? 'custom field-error' : 'custom');
if (! $value_is_default) {
$field_class .= ($field_class == '' ? '' : ' ')
. ($has_errors ? 'custom field-error' : 'custom');
}
$field_class = $field_class ? ' class="' . $field_class . '"' : '';
$tr_class = $_FormDisplayGroup > 0
@ -217,57 +227,57 @@ function display_input($path, $name, $description = '', $type, $value, $value_is
<td>
<?php
switch ($type) {
case 'text':
echo '<input type="text" size="60" ' . $name_id . $field_class
. ' value="' . htmlspecialchars($value) . '" />';
break;
case 'short_text':
echo '<input type="text" size="25" ' . $name_id . $field_class
. ' value="' . htmlspecialchars($value) . '" />';
break;
case 'number_text':
echo '<input type="text" size="15" ' . $name_id . $field_class
. ' value="' . htmlspecialchars($value) . '" />';
break;
case 'checkbox':
echo '<span' . $field_class . '><input type="checkbox" ' . $name_id
. ($value ? ' checked="checked"' : '') . ' /></span>';
break;
case 'select':
echo '<select ' . $name_id . $field_class . '>';
$escape = !(isset($opts['values_escaped']) && $opts['values_escaped']);
$values_disabled = isset($opts['values_disabled'])
? array_flip($opts['values_disabled']) : array();
foreach ($opts['values'] as $opt_value_key => $opt_value) {
// set names for boolean values
if (is_bool($opt_value)) {
$opt_value = strtolower($opt_value ? __('Yes') : __('No'));
}
// escape if necessary
if ($escape) {
$display = htmlspecialchars($opt_value);
$display_value = htmlspecialchars($opt_value_key);
} else {
$display = $opt_value;
$display_value = $opt_value_key;
}
// compare with selected value
// boolean values are cast to integers when used as array keys
$selected = is_bool($value)
? (int) $value === $opt_value_key
: $opt_value_key === $value;
echo '<option value="' . $display_value . '"'
. ($selected ? ' selected="selected"' : '')
. (isset($values_disabled[$opt_value_key]) ? ' disabled="disabled"' : '')
. '>' . $display . '</option>';
case 'text':
echo '<input type="text" size="60" ' . $name_id . $field_class
. ' value="' . htmlspecialchars($value) . '" />';
break;
case 'short_text':
echo '<input type="text" size="25" ' . $name_id . $field_class
. ' value="' . htmlspecialchars($value) . '" />';
break;
case 'number_text':
echo '<input type="text" size="15" ' . $name_id . $field_class
. ' value="' . htmlspecialchars($value) . '" />';
break;
case 'checkbox':
echo '<span' . $field_class . '><input type="checkbox" ' . $name_id
. ($value ? ' checked="checked"' : '') . ' /></span>';
break;
case 'select':
echo '<select ' . $name_id . $field_class . '>';
$escape = !(isset($opts['values_escaped']) && $opts['values_escaped']);
$values_disabled = isset($opts['values_disabled'])
? array_flip($opts['values_disabled']) : array();
foreach ($opts['values'] as $opt_value_key => $opt_value) {
// set names for boolean values
if (is_bool($opt_value)) {
$opt_value = strtolower($opt_value ? __('Yes') : __('No'));
}
echo '</select>';
break;
case 'list':
echo '<textarea cols="40" rows="5" ' . $name_id . $field_class . '>'
. htmlspecialchars(implode("\n", $value))
. '</textarea>';
break;
// escape if necessary
if ($escape) {
$display = htmlspecialchars($opt_value);
$display_value = htmlspecialchars($opt_value_key);
} else {
$display = $opt_value;
$display_value = $opt_value_key;
}
// compare with selected value
// boolean values are cast to integers when used as array keys
$selected = is_bool($value)
? (int) $value === $opt_value_key
: $opt_value_key === $value;
echo '<option value="' . $display_value . '"'
. ($selected ? ' selected="selected"' : '')
. (isset($values_disabled[$opt_value_key]) ? ' disabled="disabled"' : '')
. '>' . $display . '</option>';
}
echo '</select>';
break;
case 'list':
echo '<textarea cols="40" rows="5" ' . $name_id . $field_class . '>'
. htmlspecialchars(implode("\n", $value))
. '</textarea>';
break;
}
if (isset($opts['comment']) && $opts['comment']) {
$class = 'field-comment-mark';
@ -278,7 +288,10 @@ function display_input($path, $name, $description = '', $type, $value, $value_is
<span class="<?php echo $class ?>" title="<?php echo htmlspecialchars($opts['comment']) ?>">i</span>
<?php
}
if ($is_setup_script && isset($opts['userprefs_comment']) && $opts['userprefs_comment']) {
if ($is_setup_script
&& isset($opts['userprefs_comment'])
&& $opts['userprefs_comment']
) {
?>
<a class="userprefs-comment" title="<?php echo htmlspecialchars($opts['userprefs_comment']) ?>"><?php echo $icons['tblops']; ?></a>
<?php

View File

@ -11,14 +11,15 @@
* for formatting. Takes variable number of arguments.
* Based on PMA_sanitize from sanitize.lib.php.
*
* @param string $lang_key key in $GLOBALS WITHOUT 'strSetup' prefix
* @param mixed $args,... arguments for sprintf
* @param string $lang_key key in $GLOBALS WITHOUT 'strSetup' prefix
* @param mixed $args,... arguments for sprintf
*
* @return string
*/
function PMA_lang($lang_key, $args = null)
{
$message = isset($GLOBALS["strConfig$lang_key"]) ? $GLOBALS["strConfig$lang_key"] : $lang_key;
$message = isset($GLOBALS["strConfig$lang_key"])
? $GLOBALS["strConfig$lang_key"] : $lang_key;
$message = PMA_sanitize($message);

View File

@ -52,7 +52,8 @@ $forms['Features']['Warnings'] = array(
'PmaNoRelation_DisableWarning',
'SuhosinDisableWarning',
'McryptDisableWarning');
// settings from this form are treated specially, see prefs_forms.php and user_preferences.lib.php
// settings from this form are treated specially,
// see prefs_forms.php and user_preferences.lib.php
$forms['Features']['Developer'] = array(
'Error_Handler/display',
'Error_Handler/gather',