* Change for compatible openssl and mcrypt.

* Fix error when no isset canBeChanged var.
This commit is contained in:
wangyidong
2020-12-16 14:51:09 +08:00
parent a7669d60f4
commit d1b96633f1
2 changed files with 9 additions and 4 deletions
+8 -3
View File
@@ -320,7 +320,11 @@ class baseHelper
}
elseif(function_exists('openssl_encrypt'))
{
$encrypted = @openssl_encrypt($password, 'des-cbc', $secret);
/* Set password length to multiple of 8. For compatible mcrypt_encrypt function. */
$oversize = strlen($password) % 8;
if($oversize != 0) $password .= str_repeat("\0", 8 - $oversize);
$encrypted = @openssl_encrypt($password, 'DES-CBC', $secret, OPENSSL_ZERO_PADDING);
}
}
if(empty($encrypted)) $encrypted = $password;
@@ -346,15 +350,16 @@ class baseHelper
$secret = $config->encryptSecret;
if(function_exists('mcrypt_decrypt'))
{
$decryptedPassword = mcrypt_decrypt(MCRYPT_DES, $secret, base64_decode($password), MCRYPT_MODE_CBC);
$decryptedPassword = @mcrypt_decrypt(MCRYPT_DES, $secret, base64_decode($password), MCRYPT_MODE_CBC);
}
elseif(function_exists('openssl_decrypt'))
{
$decryptedPassword = openssl_decrypt($password, 'des-cbc', $secret);
$decryptedPassword = openssl_decrypt($password, 'DES-CBC', $secret, OPENSSL_ZERO_PADDING);
}
}
if(empty($decryptedPassword)) $decryptedPassword = $password;
$decryptedPassword = trim($decryptedPassword);
return $decryptedPassword;
}
+1 -1
View File
@@ -47,7 +47,7 @@
<ol class='histories-list'>
<?php $i = 1; ?>
<?php foreach($actions as $action):?>
<?php $canEditComment = (!empty($canBeChanged) and end($actions) == $action and trim($action->comment) != '' and $this->methodName == 'view' and $action->actor == $this->app->user->account and common::hasPriv('action', 'editComment'));?>
<?php $canEditComment = ((!isset($canBeChanged) or !empty($canBeChanged)) and end($actions) == $action and trim($action->comment) != '' and $this->methodName == 'view' and $action->actor == $this->app->user->account and common::hasPriv('action', 'editComment'));?>
<li value='<?php echo $i ++;?>'>
<?php
$action->actor = zget($users, $action->actor);