* adjust for encrypt password.
This commit is contained in:
@@ -164,6 +164,13 @@ if %requestType% == 'PATH_INFO' (
|
||||
echo %deletelog% > %baseDir%deletelog.bat
|
||||
echo deletelog.bat ok
|
||||
|
||||
:: encrypt.
|
||||
if exist "%baseDir%php\encrypt.php" (
|
||||
SET encrypt= %phpcli% %baseDir%php\encrypt.php %%*
|
||||
echo %encrypt% > %baseDir%encrypt.bat
|
||||
echo encrypt.bat ok
|
||||
)
|
||||
|
||||
:: create crond.bat
|
||||
SET cron= %phpcli% %baseDir%php\crond.php
|
||||
echo %cron% > %baseDir%crond.bat
|
||||
|
||||
@@ -167,6 +167,13 @@ fi
|
||||
echo $deletelog > $basePath/deletelog.sh
|
||||
echo "deletelog.sh ok"
|
||||
|
||||
# encrypt.
|
||||
if [ -f "$basePath/php/encrypt.php" ]; then
|
||||
encrypt="$phpcli $basePath/php/encrypt.php \$*"
|
||||
echo $encrypt > $basePath/encrypt.sh
|
||||
echo "encrypt.sh ok"
|
||||
fi
|
||||
|
||||
# cron
|
||||
if [ ! -d "$basePath/cron" ]; then
|
||||
mkdir $basePath/cron
|
||||
|
||||
@@ -267,6 +267,66 @@ class baseHelper
|
||||
return (function_exists('get_magic_quotes_gpc') and get_magic_quotes_gpc()) ? addslashes(json_encode($data)) : json_encode($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encrypt password
|
||||
*
|
||||
* @param string $password
|
||||
* @static
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public static function encryptPassword($password)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$encrypted = '';
|
||||
if(!empty($config->encryptSecret) and $password)
|
||||
{
|
||||
$secret = $config->encryptSecret;
|
||||
if(function_exists('mcrypt_encrypt'))
|
||||
{
|
||||
$encrypted = base64_encode(@mcrypt_encrypt(MCRYPT_DES, $secret, $password, MCRYPT_MODE_CBC));
|
||||
}
|
||||
elseif(function_exists('openssl_encrypt'))
|
||||
{
|
||||
$encrypted = @openssl_encrypt($password, 'des-cbc', $secret);
|
||||
}
|
||||
}
|
||||
if(empty($encrypted)) $encrypted = $password;
|
||||
|
||||
return $encrypted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrypt password.
|
||||
*
|
||||
* @param string $password
|
||||
* @static
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public static function decryptPassword($password)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$decryptedPassword = '';
|
||||
if(!empty($config->encryptSecret) and $password)
|
||||
{
|
||||
$secret = $config->encryptSecret;
|
||||
if(function_exists('mcrypt_decrypt'))
|
||||
{
|
||||
$decryptedPassword = mcrypt_decrypt(MCRYPT_DES, $secret, base64_decode($password), MCRYPT_MODE_CBC);
|
||||
}
|
||||
elseif(function_exists('openssl_decrypt'))
|
||||
{
|
||||
$decryptedPassword = openssl_decrypt($password, 'des-cbc', $secret);
|
||||
}
|
||||
}
|
||||
if(empty($decryptedPassword)) $decryptedPassword = $password;
|
||||
|
||||
return $decryptedPassword;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否是utf8编码
|
||||
* Judge a string is utf-8 or not.
|
||||
|
||||
@@ -2147,7 +2147,9 @@ class baseRouter
|
||||
}
|
||||
try
|
||||
{
|
||||
$dbh = new PDO($dsn, $params->user, $params->password, array(PDO::ATTR_PERSISTENT => $params->persistant));
|
||||
$dbPassword = helper::decryptPassword($params->password);
|
||||
|
||||
$dbh = new PDO($dsn, $params->user, $dbPassword, array(PDO::ATTR_PERSISTENT => $params->persistant));
|
||||
$dbh->exec("SET NAMES {$params->encoding}");
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user