From 9986301d84e3de7f7a0be2914ae6d7d2b77ba89c Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Wed, 20 Mar 2013 21:04:06 -0400 Subject: [PATCH] Finally I do quick hack for PHP < 5.3.7 --- miniflux/check_setup.php | 6 +++--- miniflux/vendor/password.php | 18 ++++++++++++------ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/miniflux/check_setup.php b/miniflux/check_setup.php index 0aaa484..f65d47c 100644 --- a/miniflux/check_setup.php +++ b/miniflux/check_setup.php @@ -2,14 +2,14 @@ // PHP 5.3 minimum -if (version_compare(PHP_VERSION, '5.3.7') < 0) { +if (version_compare(PHP_VERSION, '5.3.0', '<')) { - die('This software require PHP 5.3.7 minimum'); + die('This software require PHP 5.3.0 minimum'); } // Short tags must be enabled for PHP < 5.4 -if (version_compare(PHP_VERSION, '5.4.0') < 0) { +if (version_compare(PHP_VERSION, '5.4.0', '<')) { if (! ini_get('short_open_tag')) { diff --git a/miniflux/vendor/password.php b/miniflux/vendor/password.php index 3d3fe0b..c6e84cb 100644 --- a/miniflux/vendor/password.php +++ b/miniflux/vendor/password.php @@ -12,6 +12,15 @@ if (!defined('PASSWORD_BCRYPT')) { define('PASSWORD_BCRYPT', 1); define('PASSWORD_DEFAULT', PASSWORD_BCRYPT); + if (version_compare(PHP_VERSION, '5.3.7', '<')) { + + define('PASSWORD_PREFIX', '$2a$'); + } + else { + + define('PASSWORD_PREFIX', '$2y$'); + } + /** * Hash the password using the specified algorithm * @@ -46,7 +55,7 @@ if (!defined('PASSWORD_BCRYPT')) { } } $required_salt_len = 22; - $hash_format = sprintf("$2y$%02d$", $cost); + $hash_format = sprintf("%s%02d$", PASSWORD_PREFIX, $cost); break; default: trigger_error(sprintf("password_hash(): Unknown password hashing algorithm: %s", $algo), E_USER_WARNING); @@ -154,10 +163,10 @@ if (!defined('PASSWORD_BCRYPT')) { 'algoName' => 'unknown', 'options' => array(), ); - if (substr($hash, 0, 4) == '$2y$' && strlen($hash) == 60) { + if (substr($hash, 0, 4) == PASSWORD_PREFIX && strlen($hash) == 60) { $return['algo'] = PASSWORD_BCRYPT; $return['algoName'] = 'bcrypt'; - list($cost) = sscanf($hash, "$2y$%d$"); + list($cost) = sscanf($hash, PASSWORD_PREFIX."%d$"); $return['options']['cost'] = $cost; } return $return; @@ -216,6 +225,3 @@ if (!defined('PASSWORD_BCRYPT')) { return $status === 0; } } - - -