CRM-21120 Add environment check for existence of mcrypt function
authoradixon <alan.g.dixon@gmail.com>
Tue, 29 Aug 2017 18:36:01 +0000 (14:36 -0400)
committerSeamus Lee <seamuslee001@gmail.com>
Sun, 27 May 2018 03:32:57 +0000 (13:32 +1000)
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

index db4e7194b9b749c7fa0ace9ad60df6d41a4938c4..df866185edcdd1d597856354eb4b9c9bc67f524a 100644 (file)
@@ -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.
    *