From d5d56ec1c0be9b42636fac33713ba2c7c3553ab1 Mon Sep 17 00:00:00 2001 From: adixon Date: Tue, 29 Aug 2017 14:36:01 -0400 Subject: [PATCH] CRM-21120 Add environment check for existence of mcrypt function CRM-21120 Use a function-name agnostic test for encrypting powers CRM-21120 syntax error, missing semi-colon CRM-21120 Comma problems --- CRM/Utils/Check/Component/Env.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/CRM/Utils/Check/Component/Env.php b/CRM/Utils/Check/Component/Env.php index db4e7194b9..df866185ed 100644 --- a/CRM/Utils/Check/Component/Env.php +++ b/CRM/Utils/Check/Component/Env.php @@ -120,6 +120,27 @@ class CRM_Utils_Check_Component_Env extends CRM_Utils_Check_Component { return $messages; } + /** + * @return array + */ + public function checkPhpEcrypt() { + $messages = array(); + $test_pass = 'iAmARandomString'; + $encrypted_test_pass = CRM_Utils_Crypt::encrypt($test_pass); + if ($encrypted_test_pass == base64_encode($test_pass)) { + $messages[] = new CRM_Utils_Check_Message( + __FUNCTION__, + ts('Your PHP does not include the recommended encryption functions. Some passwords will not be stored encrypted, and if you have recently upgraded from a PHP that does include these functions, your encrypted passwords will not be decrypted correctly. If you are using PHP 7.0 or earlier, you probably want to include the "%1" extension.', + array('1' => 'mcrypt') + ), + ts('PHP Missing Extension "mcrypt"'), + \Psr\Log\LogLevel::WARNING, + 'fa-server' + ); + } + return $messages; + } + /** * Check that the MySQL time settings match the PHP time settings. * -- 2.25.1