Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
thilinaa committed May 7, 2012
2 parents 6f6f480 + 46ae483 commit e0c8291
Show file tree
Hide file tree
Showing 11 changed files with 246 additions and 146 deletions.
4 changes: 4 additions & 0 deletions libraries/PDF.class.php
Expand Up @@ -2,6 +2,8 @@
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* TCPDF wrapper class.
*
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
Expand All @@ -16,6 +18,8 @@

/**
* PDF export base class providing basic configuration.
*
* @package PhpMyAdmin
*/
class PMA_PDF extends TCPDF
{
Expand Down
16 changes: 9 additions & 7 deletions libraries/PMA.php
@@ -1,7 +1,8 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Enter description here...
* phpMyAdmin main Controller
*
* @package PhpMyAdmin
*
*/
Expand All @@ -14,8 +15,6 @@
/**
* phpMyAdmin main Controller
*
*
*
* @package PhpMyAdmin
*/
class PMA
Expand Down Expand Up @@ -44,7 +43,7 @@ class PMA
/**
* magic access to protected/inaccessible members/properties
*
* @param string $param
* @param string $param parameter name
*
* @return mixed
* @see http://php.net/language.oop5.overloading
Expand All @@ -69,8 +68,8 @@ public function __get($param)
/**
* magic access to protected/inaccessible members/properties
*
* @param string $param
* @param mixed $value
* @param string $param parameter name
* @param mixed $value value to set
*
* @return void
* @see http://php.net/language.oop5.overloading
Expand All @@ -95,7 +94,10 @@ public function __set($param, $value)
public function getDatabaseList()
{
if (null === $this->databases) {
$this->databases = new PMA_List_Database($this->userlink, $this->controllink);
$this->databases = new PMA_List_Database(
$this->userlink,
$this->controllink
);
}

return $this->databases;
Expand Down
19 changes: 11 additions & 8 deletions libraries/auth/config.auth.lib.php
Expand Up @@ -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);
Expand Down
52 changes: 36 additions & 16 deletions libraries/auth/cookie.auth.lib.php
Expand Up @@ -37,7 +37,9 @@
* 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) {
Expand All @@ -50,8 +52,8 @@
/**
* 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
*
Expand All @@ -61,14 +63,16 @@
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
*
Expand Down Expand Up @@ -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 = '';
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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']
);
}
}

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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');
}
Expand Down
8 changes: 6 additions & 2 deletions libraries/auth/http.auth.lib.php
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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')) {
Expand Down
23 changes: 16 additions & 7 deletions libraries/auth/signon.auth.lib.php
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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)) {
Expand Down
23 changes: 15 additions & 8 deletions libraries/config/Form.class.php
Expand Up @@ -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)
{
Expand All @@ -60,7 +60,7 @@ public function __construct($form_name, array $form, $index = null)
/**
* 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
*/
Expand All @@ -75,7 +75,7 @@ public function getOptionType($option_name)
/**
* Returns allowed values for select fields
*
* @param string $option_path
* @param string $option_path
*
* @return array
*/
Expand Down Expand Up @@ -118,9 +118,11 @@ public function getOptionValueList($option_path)
* 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)
{
Expand All @@ -146,6 +148,8 @@ private function _readFormPathsCallback($value, $key, $prefix)
* Reads form paths to {@link $fields}
*
* @param array $form
*
* @return void
*/
protected function readFormPaths($form)
{
Expand All @@ -167,6 +171,7 @@ protected function readFormPaths($form)
/**
* Reads fields' types to $this->fieldsTypes
*
* @return void
*/
protected function readTypes()
{
Expand All @@ -192,6 +197,8 @@ protected function readTypes()
*
* @param string $form_name
* @param array $form
*
* @return void
*/
public function loadForm($form_name, $form)
{
Expand Down

0 comments on commit e0c8291

Please sign in to comment.