From dc5a5a7cdfae8ba8e300b7db46eaa64fcc70824c Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 28 May 2014 20:35:01 +0200 Subject: [ticket/12352] Rename phpbb2_md5 driver to fit filenames of other drivers PHPBB3-12352 --- phpBB/phpbb/passwords/driver/md5_phpbb2.php | 125 ++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 phpBB/phpbb/passwords/driver/md5_phpbb2.php (limited to 'phpBB/phpbb/passwords/driver/md5_phpbb2.php') diff --git a/phpBB/phpbb/passwords/driver/md5_phpbb2.php b/phpBB/phpbb/passwords/driver/md5_phpbb2.php new file mode 100644 index 0000000000..41a589d3b8 --- /dev/null +++ b/phpBB/phpbb/passwords/driver/md5_phpbb2.php @@ -0,0 +1,125 @@ +request = $request; + $this->salted_md5 = $salted_md5; + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $php_ext; + } + + /** + * @inheritdoc + */ + public function get_prefix() + { + return self::PREFIX; + } + + /** + * @inheritdoc + */ + public function is_legacy() + { + return true; + } + + /** + * @inheritdoc + */ + public function hash($password, $user_row = '') + { + // Do not support hashing + return false; + } + + /** + * @inheritdoc + */ + public function check($password, $hash, $user_row = array()) + { + if (strlen($hash) != 32 && strlen($hash) != 34) + { + return false; + } + + // enable super globals to get literal value + // this is needed to prevent unicode normalization + $super_globals_disabled = $this->request->super_globals_disabled(); + if ($super_globals_disabled) + { + $this->request->enable_super_globals(); + } + + // in phpBB2 passwords were used exactly as they were sent, with addslashes applied + $password_old_format = isset($_REQUEST['password']) ? (string) $_REQUEST['password'] : ''; + $password_old_format = (!STRIP) ? addslashes($password_old_format) : $password_old_format; + $password_new_format = $this->request->variable('password', '', true); + + if ($super_globals_disabled) + { + $this->request->disable_super_globals(); + } + + if ($password == $password_new_format) + { + if (!function_exists('utf8_to_cp1252')) + { + include($this->phpbb_root_path . 'includes/utf/data/recode_basic.' . $this->php_ext); + } + + if (md5($password_old_format) === $hash || md5(\utf8_to_cp1252($password_old_format)) === $hash + || $this->salted_md5->check(md5($password_old_format), $hash) === true + || $this->salted_md5->check(md5(\utf8_to_cp1252($password_old_format)), $hash) === true) + { + return true; + } + } + + return false; + } + + /** + * @inheritdoc + */ + public function get_settings_only($hash, $full = false) + { + return false; + } +} -- cgit v1.2.1 From 4b3aacfd18a8a3334532f9fcc830affb5f12963b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 30 May 2014 00:22:55 +0200 Subject: [ticket/12352] Add get_settings_only method to passwords driver base PHPBB3-12352 --- phpBB/phpbb/passwords/driver/md5_phpbb2.php | 8 -------- 1 file changed, 8 deletions(-) (limited to 'phpBB/phpbb/passwords/driver/md5_phpbb2.php') diff --git a/phpBB/phpbb/passwords/driver/md5_phpbb2.php b/phpBB/phpbb/passwords/driver/md5_phpbb2.php index 41a589d3b8..093e3b4c65 100644 --- a/phpBB/phpbb/passwords/driver/md5_phpbb2.php +++ b/phpBB/phpbb/passwords/driver/md5_phpbb2.php @@ -114,12 +114,4 @@ class md5_phpbb2 extends base return false; } - - /** - * @inheritdoc - */ - public function get_settings_only($hash, $full = false) - { - return false; - } } -- cgit v1.2.1 From 94b2b64ca199f3db66818c3830c96ea9ff7eeff9 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 1 Jun 2014 21:36:53 +0200 Subject: [ticket/12352] Update file headers to fit new format PHPBB3-12352 --- phpBB/phpbb/passwords/driver/md5_phpbb2.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'phpBB/phpbb/passwords/driver/md5_phpbb2.php') diff --git a/phpBB/phpbb/passwords/driver/md5_phpbb2.php b/phpBB/phpbb/passwords/driver/md5_phpbb2.php index 093e3b4c65..de1993e8a1 100644 --- a/phpBB/phpbb/passwords/driver/md5_phpbb2.php +++ b/phpBB/phpbb/passwords/driver/md5_phpbb2.php @@ -1,17 +1,18 @@ +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ namespace phpbb\passwords\driver; -/** -* @package passwords -*/ class md5_phpbb2 extends base { const PREFIX = '$md5_phpbb2$'; -- cgit v1.2.1