diff options
| author | Benjamin Southall <applemansigloo@gmail.com> | 2019-02-26 10:58:36 +1000 |
|---|---|---|
| committer | Benjamin Southall <applemansigloo@gmail.com> | 2019-02-26 10:58:36 +1000 |
| commit | 7aae5ed3e9be434cce2aecada91c8d51a62e1719 (patch) | |
| tree | c70a629fbe3183e4e58ca9fc0bfa0731836de4f1 /inc/mod/auth.php | |
| parent | 67ef23d75893162da55c337fc02f816e69a6a586 (diff) | |
Handle mcrypt_create_iv deprectation by using randombytes in newer PHP versions
Diffstat (limited to 'inc/mod/auth.php')
| -rw-r--r-- | inc/mod/auth.php | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/inc/mod/auth.php b/inc/mod/auth.php index 2a264f18..5705c8a2 100644 --- a/inc/mod/auth.php +++ b/inc/mod/auth.php @@ -69,12 +69,13 @@ function test_password($password, $salt, $test) { } function generate_salt() { - // 128 bits of entropy - if (function_exists('random_bytes')) { - return strtr(base64_encode(random_bytes(16)), '+', '.'); - } else { + // mcrypt_create_iv() was deprecated in PHP 7.1.0, only use it if we're below that version number. + if (PHP_VERSION_ID < 70100) { + // 128 bits of entropy return strtr(base64_encode(mcrypt_create_iv(16, MCRYPT_DEV_URANDOM)), '+', '.'); } + // Otherwise, use random_bytes() + return strtr(base64_encode(random_bytes(16)), '+', '.'); } function login($username, $password) { @@ -210,8 +211,8 @@ function check_login($prompt = false) { } $mod = array( - 'id' => $user['id'], - 'type' => $user['type'], + 'id' => (int)$user['id'], + 'type' => (int)$user['type'], 'username' => $cookie[0], 'boards' => explode(',', $user['boards']) ); |
