From 622e8d9c269b6e2421201a760f20df486bfc3cfb Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Fri, 13 Mar 2026 15:14:53 +0530 Subject: [PATCH 01/13] Fixed: Upgrade the password hashing from MD5 to Bcrypt --- classes/AdminTab.php | 5 +- classes/Customer.php | 25 +++- classes/Employee.php | 30 +++-- classes/Hashing.php | 125 ++++++++++++++++++ classes/ObjectModel.php | 3 +- classes/Referrer.php | 2 +- classes/Validate.php | 15 ++- classes/controller/AdminController.php | 7 +- .../WebserviceSpecificManagementBookings.php | 3 +- controllers/admin/AdminImportController.php | 3 +- controllers/admin/AdminLoginController.php | 3 +- controllers/front/IdentityController.php | 2 +- controllers/front/PasswordController.php | 3 +- install/data/db_structure.sql | 6 +- install/fixtures/fashion/install.php | 3 +- install/models/install.php | 3 +- 16 files changed, 204 insertions(+), 34 deletions(-) create mode 100644 classes/Hashing.php diff --git a/classes/AdminTab.php b/classes/AdminTab.php index 6e277f73f..2f06fe13e 100644 --- a/classes/AdminTab.php +++ b/classes/AdminTab.php @@ -1179,9 +1179,10 @@ abstract class AdminTabCore if ($key == 'passwd' && Tools::getValue('id_'.$table) && empty($value)) { continue; } - /* Automatically encrypt password in MD5 */ + /* Automatically hash password */ if ($key == 'passwd' && !empty($value)) { - $value = Tools::encrypt($value); + $crypto = new Hashing(); + $value = $crypto->hash($value); } $object->{$key} = $value; } diff --git a/classes/Customer.php b/classes/Customer.php index 0c2ac0023..6ce60debc 100644 --- a/classes/Customer.php +++ b/classes/Customer.php @@ -167,7 +167,7 @@ class CustomerCore extends ObjectModel 'lastname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 32), 'firstname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 32), 'email' => array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'required' => true, 'size' => 128), - 'passwd' => array('type' => self::TYPE_STRING, 'validate' => 'isPasswd', 'required' => true, 'size' => 32), + 'passwd' => array('type' => self::TYPE_STRING, 'validate' => 'isHashedPassword', 'required' => true, 'size' => 60), 'last_passwd_gen' => array('type' => self::TYPE_STRING, 'copy_post' => false), 'id_gender' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'birthday' => array('type' => self::TYPE_DATE, 'validate' => 'isBirthDate'), @@ -374,7 +374,7 @@ class CustomerCore extends ObjectModel */ public function getByEmail($email, $passwd = null, $ignore_guest = true) { - if (!Validate::isEmail($email) || ($passwd && !Validate::isPasswd($passwd))) { + if (!Validate::isEmail($email) || ($passwd && !Validate::isHashedPassword($passwd))) { die(Tools::displayError()); } @@ -383,19 +383,28 @@ class CustomerCore extends ObjectModel FROM `'._DB_PREFIX_.'customer` WHERE `email` = \''.pSQL($email).'\' '.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).' - '.(isset($passwd) ? 'AND `passwd` = \''.pSQL(Tools::encrypt($passwd)).'\'' : '').' AND `deleted` = 0 '.($ignore_guest ? ' AND `is_guest` = 0' : '')); if (!$result) { return false; } + if (isset($passwd)) { + $crypto = new Hashing(); + if (!$crypto->checkHash($passwd, $result['passwd'])) { + return false; + } + } $this->id = $result['id_customer']; foreach ($result as $key => $value) { if (property_exists($this, $key)) { $this->{$key} = $value; } } + if (isset($passwd) && !$crypto->isFirstHash($passwd, $result['passwd'])) { + $this->passwd = $crypto->hash($passwd); + $this->update(); + } return $this; } @@ -560,7 +569,7 @@ class CustomerCore extends ObjectModel */ public static function checkPassword($id_customer, $passwd) { - if (!Validate::isUnsignedId($id_customer) || !Validate::isMd5($passwd)) { + if (!Validate::isUnsignedId($id_customer) || !Validate::isHashedPassword($passwd)) { die(Tools::displayError()); } $cache_id = 'Customer::checkPassword'.(int)$id_customer.'-'.$passwd; @@ -847,12 +856,13 @@ class CustomerCore extends ObjectModel if (empty($password)) { $password = Tools::passwdGen(8, 'RANDOM'); } - if (!Validate::isPasswd($password)) { + if (!Validate::isHashedPassword($password)) { return false; } $this->is_guest = 0; - $this->passwd = Tools::encrypt($password); + $crypto = new Hashing(); + $this->passwd = $crypto->hash($password); $this->cleanGroups(); $this->addGroups(array(Configuration::get('PS_CUSTOMER_GROUP'))); // add default customer group $this->id_default_group = (int) Configuration::get('PS_CUSTOMER_GROUP'); @@ -887,7 +897,8 @@ class CustomerCore extends ObjectModel public function setWsPasswd($passwd) { if ($this->id == 0 || $this->passwd != $passwd) { - $this->passwd = Tools::encrypt($passwd); + $crypto = new Hashing(); + $this->passwd = $crypto->hash($passwd); } return true; } diff --git a/classes/Employee.php b/classes/Employee.php index 778aea505..84e95fa7f 100644 --- a/classes/Employee.php +++ b/classes/Employee.php @@ -102,7 +102,7 @@ class EmployeeCore extends ObjectModel 'firstname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 32), 'email' => array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'required' => true, 'size' => 128), 'id_lang' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true), - 'passwd' => array('type' => self::TYPE_STRING, 'validate' => 'isPasswdAdmin', 'required' => true, 'size' => 32), + 'passwd' => array('type' => self::TYPE_STRING, 'validate' => 'isPasswdAdmin', 'required' => true, 'size' => 60), 'last_passwd_gen' => array('type' => self::TYPE_STRING), 'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'optin' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), @@ -273,7 +273,7 @@ class EmployeeCore extends ObjectModel */ public function getByEmail($email, $passwd = null, $active_only = true) { - if (!Validate::isEmail($email) || ($passwd != null && !Validate::isPasswd($passwd))) { + if (!Validate::isEmail($email) || ($passwd != null && !Validate::isHashedPassword($passwd))) { die(Tools::displayError()); } @@ -281,11 +281,17 @@ class EmployeeCore extends ObjectModel SELECT * FROM `'._DB_PREFIX_.'employee` WHERE `email` = \''.pSQL($email).'\' - '.($active_only ? ' AND `active` = 1' : '') - .($passwd !== null ? ' AND `passwd` = \''.Tools::encrypt($passwd).'\'' : '')); + '.($active_only ? ' AND `active` = 1' : '')); if (!$result) { return false; } + + if ($passwd !== null) { + $crypto = new Hashing(); + if (!$crypto->checkHash($passwd, $result['passwd'])) { + return false; + } + } $this->id = $result['id_employee']; $this->id_profile = $result['id_profile']; foreach ($result as $key => $value) { @@ -293,6 +299,11 @@ class EmployeeCore extends ObjectModel $this->{$key} = $value; } } + + if ($passwd !== null && !$crypto->isFirstHash($passwd, $result['passwd'])) { + $this->passwd = $crypto->hash($passwd); + $this->update(); + } return $this; } @@ -316,7 +327,7 @@ class EmployeeCore extends ObjectModel */ public static function checkPassword($id_employee, $passwd) { - if (!Validate::isUnsignedId($id_employee) || !Validate::isPasswd($passwd, 8)) { + if (!Validate::isUnsignedId($id_employee) || !Validate::isHashedPassword($passwd, 8)) { die(Tools::displayError()); } @@ -364,19 +375,20 @@ class EmployeeCore extends ObjectModel // validate and set password for the employee public function setWsPasswd($passwd) { + $crypto = new Hashing(); if ($this->id != 0) { if ($this->passwd != $passwd) { - if (!Validate::isPasswd($passwd, Validate::ADMIN_PASSWORD_LENGTH)) { + if (!Validate::isHashedPassword($passwd, Validate::ADMIN_PASSWORD_LENGTH)) { WebserviceRequest::getInstance()->setError(400, 'The password must be at least '.Validate::ADMIN_PASSWORD_LENGTH.' characters long.', 134); } else { - $this->passwd = Tools::encrypt($passwd); + $this->passwd = $crypto->hash($passwd); } } } else { - if (!Validate::isPasswd($passwd, Validate::ADMIN_PASSWORD_LENGTH)) { + if (!Validate::isHashedPassword($passwd, Validate::ADMIN_PASSWORD_LENGTH)) { WebserviceRequest::getInstance()->setError(400, 'The password must be at least '.Validate::ADMIN_PASSWORD_LENGTH.' characters long.', 134); } else { - $this->passwd = Tools::encrypt($passwd); + $this->passwd = $crypto->hash($passwd); } } diff --git a/classes/Hashing.php b/classes/Hashing.php new file mode 100644 index 000000000..ca8a245b5 --- /dev/null +++ b/classes/Hashing.php @@ -0,0 +1,125 @@ + + * @copyright 2007-2017 PrestaShop SA + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + * International Registered Trademark & Property of PrestaShop SA + */ + + +class HashingCore +{ + /** @var array should contain hashing methods */ + private $hashMethods = array(); + + /** + * Check if it's the first function of the array that was used for hashing + * + * @param string $passwd The password you want to check + * @param string $hash The hash you want to check + * @param string $staticSalt A static salt + * + * @return bool Result of the verify function + */ + public function isFirstHash($passwd, $hash, $staticSalt = _COOKIE_KEY_) + { + if (!count($this->hashMethods)) { + $this->initHashMethods(); + } + + $closure = reset($this->hashMethods); + + return $closure['verify']($passwd, $hash, $staticSalt); + } + + /** + * Iterate on hash_methods array and return true if it matches + * + * @param string $passwd The password you want to check + * @param string $hash The hash you want to check + * @param string $staticSalt A static salt + * + * @return bool `true` is returned if the function find a match else false + */ + public function checkHash($passwd, $hash, $staticSalt = _COOKIE_KEY_) + { + if (!count($this->hashMethods)) { + $this->initHashMethods(); + } + + foreach ($this->hashMethods as $closure) { + if ($closure['verify']($passwd, $hash, $staticSalt)) { + return true; + } + } + + return false; + } + + /** + * Hash the `$plaintextPassword` string and return the result of the 1st hashing method + * contained in Hashing::hashMethods + * + * @param string $plaintextPassword The password you want to hash + * @param string $staticSalt The static salt + * + * @return string + */ + public function hash($plaintextPassword, $staticSalt = _COOKIE_KEY_) + { + if (!count($this->hashMethods)) { + $this->initHashMethods(); + } + + $closure = reset($this->hashMethods); + + return $closure['hash']($plaintextPassword, $staticSalt, $closure['option']); + } + + /** + * Init hash methods + * + * @return void + */ + private function initHashMethods() + { + $this->hashMethods = array( + 'bcrypt' => array( + 'option' => array(), + 'hash' => function ($passwd, $staticSalt, $option) { + return password_hash($passwd, PASSWORD_BCRYPT); + }, + 'verify' => function ($passwd, $hash, $staticSalt) { + return password_verify($passwd, $hash); + }, + ), + 'md5' => array( + 'option' => array(), + 'hash' => function ($passwd, $staticSalt, $option) { + return md5($staticSalt.$passwd); + }, + 'verify' => function ($passwd, $hash, $staticSalt) { + return md5($staticSalt.$passwd) === $hash; + }, + ), + ); + } +} diff --git a/classes/ObjectModel.php b/classes/ObjectModel.php index e49faffa3..8c316c571 100644 --- a/classes/ObjectModel.php +++ b/classes/ObjectModel.php @@ -1188,7 +1188,8 @@ abstract class ObjectModelCore implements Core_Foundation_Database_EntityInterfa } if ($field == 'passwd') { if ($value = Tools::getValue($field)) { - $this->{$field} = Tools::encrypt($value); + $crypto = new Hashing(); + $this->{$field} = $crypto->hash($value); } } else { $this->{$field} = $value; diff --git a/classes/Referrer.php b/classes/Referrer.php index d6b347669..93641ae5f 100644 --- a/classes/Referrer.php +++ b/classes/Referrer.php @@ -53,7 +53,7 @@ class ReferrerCore extends ObjectModel 'primary' => 'id_referrer', 'fields' => array( 'name' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true, 'size' => 64), - 'passwd' => array('type' => self::TYPE_STRING, 'validate' => 'isPasswd', 'size' => 32), + 'passwd' => array('type' => self::TYPE_STRING, 'validate' => 'isPasswd', 'size' => 60), 'http_referer_regexp' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml', 'size' => 64), 'request_uri_regexp' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml', 'size' => 64), 'http_referer_like' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml', 'size' => 64), diff --git a/classes/Validate.php b/classes/Validate.php index b7178a8b5..d47f64b66 100644 --- a/classes/Validate.php +++ b/classes/Validate.php @@ -88,6 +88,19 @@ class ValidateCore return preg_match('/^[a-f0-9A-F]{32}$/', $md5); } + /** + * Check for password hash validity (legacy MD5 or bcrypt), or plaintext password. + * + * @param string $hash + * @return bool Validity is ok or not + */ + public static function isHashedPassword($hashedPasswd) + { + return self::isPasswd($hashedPasswd) + || Tools::strlen($hashedPasswd) == 32 + || Tools::strlen($hashedPasswd) == 60; + } + /** * Check for SHA1 string validity * @@ -1140,4 +1153,4 @@ class ValidateCore { return (preg_match('/^(?:'.Configuration::get('PS_INVOICE_PREFIX', Context::getContext()->language->id).')\s*([0-9]+)$/i', $id)); } -} \ No newline at end of file +} diff --git a/classes/controller/AdminController.php b/classes/controller/AdminController.php index 7e979e4d3..9388bf96e 100644 --- a/classes/controller/AdminController.php +++ b/classes/controller/AdminController.php @@ -3838,9 +3838,10 @@ class AdminControllerCore extends Controller if ($key == 'passwd' && Tools::getValue('id_'.$table) && empty($value)) { continue; } - /* Automatically encrypt password in MD5 */ + /* Automatically hash password */ if ($key == 'passwd' && !empty($value)) { - $value = Tools::encrypt($value); + $crypto = new Hashing(); + $value = $crypto->hash($value); } $object->{$key} = $value; } @@ -4817,4 +4818,4 @@ class AdminControllerCore extends Controller return 0; } } -} \ No newline at end of file +} diff --git a/classes/webservice/WebserviceSpecificManagementBookings.php b/classes/webservice/WebserviceSpecificManagementBookings.php index 10e52dab0..4e542bdcf 100644 --- a/classes/webservice/WebserviceSpecificManagementBookings.php +++ b/classes/webservice/WebserviceSpecificManagementBookings.php @@ -1378,7 +1378,8 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We $objCustomer->firstname = $customerDetails['firstname']; $objCustomer->lastname = $customerDetails['lastname']; $objCustomer->email = $customerDetails['email']; - $objCustomer->passwd = md5(time()._COOKIE_KEY_); + $crypto = new Hashing(); + $objCustomer->passwd = $crypto->hash(Tools::passwdGen(32, 'RANDOM')); $objCustomer->phone = (isset($customerDetails['phone']) ? $customerDetails['phone'] : ''); $objCustomer->cleanGroups(); $objCustomer->add(); diff --git a/controllers/admin/AdminImportController.php b/controllers/admin/AdminImportController.php index d2819efca..f7ba432e1 100644 --- a/controllers/admin/AdminImportController.php +++ b/controllers/admin/AdminImportController.php @@ -2835,7 +2835,8 @@ class AdminImportControllerCore extends AdminController AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $customer); if ($customer->passwd) { - $customer->passwd = Tools::encrypt($customer->passwd); + $crypto = new Hashing(); + $customer->passwd = $crypto->hash($customer->passwd); } $customers_shop = array(); diff --git a/controllers/admin/AdminLoginController.php b/controllers/admin/AdminLoginController.php index f48096f05..e438f022e 100644 --- a/controllers/admin/AdminLoginController.php +++ b/controllers/admin/AdminLoginController.php @@ -263,7 +263,8 @@ class AdminLoginControllerCore extends AdminController if (!count($this->errors)) { $pwd = Tools::passwdGen(10, 'RANDOM'); - $employee->passwd = Tools::encrypt($pwd); + $crypto = new Hashing(); + $employee->passwd = $crypto->hash($pwd); $employee->last_passwd_gen = date('Y-m-d H:i:s', time()); $params = array( diff --git a/controllers/front/IdentityController.php b/controllers/front/IdentityController.php index 917e301f4..9f8a1c904 100644 --- a/controllers/front/IdentityController.php +++ b/controllers/front/IdentityController.php @@ -71,7 +71,7 @@ class IdentityControllerCore extends FrontController $this->errors[] = Tools::displayError('This email address is not valid'); } elseif ($this->customer->email != $email && Customer::customerExists($email, true)) { $this->errors[] = Tools::displayError('An account using this email address has already been registered.'); - } elseif (!Tools::getIsset('old_passwd') || (Tools::encrypt($old_passwd) != $this->context->cookie->passwd)) { + } elseif (!Tools::getIsset('old_passwd') || !(new Hashing())->checkHash($old_passwd, $this->context->cookie->passwd)) { $this->errors[] = Tools::displayError('The password you entered is incorrect.'); } elseif (Tools::getValue('passwd') != Tools::getValue('confirmation')) { $this->errors[] = Tools::displayError('The password and confirmation do not match.'); diff --git a/controllers/front/PasswordController.php b/controllers/front/PasswordController.php index 317818c87..5bfd526ee 100644 --- a/controllers/front/PasswordController.php +++ b/controllers/front/PasswordController.php @@ -73,7 +73,8 @@ class PasswordControllerCore extends FrontController } elseif ((strtotime($customer->last_passwd_gen.'+'.(int)Configuration::get('PS_PASSWD_TIME_FRONT').' minutes') - time()) > 0) { Tools::redirect('index.php?controller=authentication&error_regen_pwd'); } else { - $customer->passwd = Tools::encrypt($password = Tools::passwdGen(MIN_PASSWD_LENGTH, 'RANDOM')); + $crypto = new Hashing(); + $customer->passwd = $crypto->hash($password = Tools::passwdGen(MIN_PASSWD_LENGTH, 'RANDOM')); $customer->last_passwd_gen = date('Y-m-d H:i:s', time()); if ($customer->update()) { Hook::exec('actionPasswordRenew', array('customer' => $customer, 'password' => $password)); diff --git a/install/data/db_structure.sql b/install/data/db_structure.sql index 7550fbcad..37b5d93da 100644 --- a/install/data/db_structure.sql +++ b/install/data/db_structure.sql @@ -593,7 +593,7 @@ CREATE TABLE `PREFIX_customer` ( `firstname` varchar(32) NOT NULL, `lastname` varchar(32) NOT NULL, `email` varchar(128) NOT NULL, - `passwd` varchar(32) NOT NULL, + `passwd` varchar(60) NOT NULL, `last_passwd_gen` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `birthday` date DEFAULT NULL, `newsletter` tinyint(1) unsigned NOT NULL DEFAULT '0', @@ -779,7 +779,7 @@ CREATE TABLE `PREFIX_employee` ( `lastname` varchar(32) NOT NULL, `firstname` varchar(32) NOT NULL, `email` varchar(128) NOT NULL, - `passwd` varchar(32) NOT NULL, + `passwd` varchar(60) NOT NULL, `last_passwd_gen` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `stats_date_from` date DEFAULT NULL, `stats_date_to` date DEFAULT NULL, @@ -1781,7 +1781,7 @@ CREATE TABLE `PREFIX_range_weight` ( CREATE TABLE `PREFIX_referrer` ( `id_referrer` int(10) unsigned NOT NULL auto_increment, `name` varchar(64) NOT NULL, - `passwd` varchar(32) DEFAULT NULL, + `passwd` varchar(60) DEFAULT NULL, `http_referer_regexp` varchar(64) DEFAULT NULL, `http_referer_like` varchar(64) DEFAULT NULL, `request_uri_regexp` varchar(64) DEFAULT NULL, diff --git a/install/fixtures/fashion/install.php b/install/fixtures/fashion/install.php index f7ef6fcca..e14ad92bf 100644 --- a/install/fixtures/fashion/install.php +++ b/install/fixtures/fashion/install.php @@ -35,7 +35,8 @@ class InstallFixturesFashion extends InstallXmlLoader public function createEntityCustomer($identifier, array $data, array $data_lang) { if ($identifier == 'John') { - $data['passwd'] = Tools::encrypt('123456789'); + $crypto = new Hashing(); + $data['passwd'] = $crypto->hash('123456789'); $data['last_passwd_gen'] = date('Y-m-d H:i:s'); $data['birthday'] = date('Y-m-d', strtotime('-30 years')); $data['newsletter_date_add'] = date('Y-m-d H:i:s'); diff --git a/install/models/install.php b/install/models/install.php index 4f48210c1..2a36638d8 100644 --- a/install/models/install.php +++ b/install/models/install.php @@ -566,7 +566,8 @@ class InstallModelInstall extends InstallAbstractModel $employee->firstname = Tools::ucfirst($data['admin_firstname']); $employee->lastname = Tools::ucfirst($data['admin_lastname']); $employee->email = $data['admin_email']; - $employee->passwd = md5(_COOKIE_KEY_.$data['admin_password']); + $crypto = new Hashing(); + $employee->passwd = $crypto->hash($data['admin_password']); $employee->last_passwd_gen = date('Y-m-d h:i:s', strtotime('-360 minutes')); $employee->bo_theme = 'default'; $employee->default_tab = 1; From c6fa793dd3f2b41621379c5a9d5425228b1bd83b Mon Sep 17 00:00:00 2001 From: varun kewlani Date: Thu, 26 Mar 2026 16:56:50 +0530 Subject: [PATCH 02/13] Updated: Added changes to get Qloapps detectable for builtwith --- themes/hotel-reservation-theme/header.tpl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/themes/hotel-reservation-theme/header.tpl b/themes/hotel-reservation-theme/header.tpl index bc3339ca1..8dc419a6b 100644 --- a/themes/hotel-reservation-theme/header.tpl +++ b/themes/hotel-reservation-theme/header.tpl @@ -37,7 +37,7 @@ {if isset($meta_keywords) AND $meta_keywords} {/if} - + @@ -77,7 +77,8 @@ - + + {if !isset($content_only) || !$content_only} {if isset($restricted_country_mode) && $restricted_country_mode}
From b4c79b484401adc41ece573eb060ae0719310a2e Mon Sep 17 00:00:00 2001 From: aradhana kumari Date: Fri, 20 Feb 2026 16:19:06 +0530 Subject: [PATCH 03/13] Added : Los info in the Product page in front-office --- controllers/front/ProductController.php | 36 +++++++++++++++++++ .../_partials/booking-form.tpl | 14 +++++++- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index e9fb16151..4865a8fa5 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -675,6 +675,7 @@ class ProductControllerCore extends FrontController 'id_room_type' => $idProduct, 'id_cart' => $idCart, 'id_guest' => $idGuest, + 'search_unavai' => 1, // Need to search unavailable rooms to check LOS restriction ); if (Configuration::get('PS_FRONT_ROOM_UNIT_SELECTION_TYPE') == HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) { $bookingParams['occupancy'] = $occupancy; @@ -693,9 +694,40 @@ class ProductControllerCore extends FrontController } $totalAvailableRooms = 0; + $losRestrictionFailed = false; + $losMinDays = 0; + $losMaxDays = 0; + $losFailedType = ''; // 'min' or 'max' to indicate which restriction failed if ($hotelRoomData = $objBookingDetail->dataForFrontSearch($bookingParams)) { $totalAvailableRooms = $hotelRoomData['stats']['num_avail']; $quantity = ($quantity > $totalAvailableRooms) ? $totalAvailableRooms : $quantity; + + // Check if rooms are unavailable due to LOS restriction + if ($totalAvailableRooms <= 0 && isset($hotelRoomData['rm_data'][$idProduct]['data']['unavailable'])) { + foreach ($hotelRoomData['rm_data'][$idProduct]['data']['unavailable'] as $unavailableRoom) { + if (isset($unavailableRoom['detail'])) { + foreach ($unavailableRoom['detail'] as $detail) { + if (isset($detail['id_status']) && $detail['id_status'] == HotelRoomInformation::STATUS_SEARCH_LOS_UNSATISFIED) { + $losRestrictionFailed = true; + // Get LOS restrictions for the room type + $objRoomTypeRestrictionDateRange = new HotelRoomTypeRestrictionDateRange(); + $losRestriction = $objRoomTypeRestrictionDateRange->getRoomTypeLengthOfStay($idProduct, $dateFrom); + if ($losRestriction) { + $losMinDays = isset($losRestriction['min_los']) ? $losRestriction['min_los'] : 0; + $losMaxDays = isset($losRestriction['max_los']) ? $losRestriction['max_los'] : 0; + // Determine which restriction failed + if ($losMinDays > 0 && $numDays < $losMinDays) { + $losFailedType = 'min'; + } elseif ($losMaxDays > 0 && $numDays > $losMaxDays) { + $losFailedType = 'max'; + } + } + break 2; + } + } + } + } + } } // calculate room type price first @@ -863,6 +895,10 @@ class ProductControllerCore extends FrontController $smartyVars['num_days'] = $numDays; $smartyVars['warning_count'] = $warningCount; $smartyVars['total_available_rooms'] = $totalAvailableRooms; + $smartyVars['los_restriction_failed'] = $losRestrictionFailed; + $smartyVars['los_min_days'] = $losMinDays; + $smartyVars['los_max_days'] = $losMaxDays; + $smartyVars['los_failed_type'] = $losFailedType; $smartyVars['has_room_type_demands'] = $roomTypeDemands ? true : false; // whether to show price breakup $smartyVars['rooms_price'] = $totalRoomPrice; $smartyVars['demands_price_per_room'] = $demandsPricePerRoom; diff --git a/themes/hotel-reservation-theme/_partials/booking-form.tpl b/themes/hotel-reservation-theme/_partials/booking-form.tpl index 0647736f3..c32760230 100644 --- a/themes/hotel-reservation-theme/_partials/booking-form.tpl +++ b/themes/hotel-reservation-theme/_partials/booking-form.tpl @@ -212,7 +212,19 @@ {/block} {else}
- {l s='All rooms sold out!'} + {if isset($los_restriction_failed) && $los_restriction_failed} + + {if isset($los_failed_type) && $los_failed_type == 'min'} + {l s='At least %d nights required.' sprintf=[$los_min_days]} + {elseif isset($los_failed_type) && $los_failed_type == 'max'} + {l s='Up to %d nights allowed.' sprintf=[$los_max_days]} + {else} + {l s='LOS is not match'} + {/if} + + {else} + {l s='All rooms sold out!'} + {/if}
{/if} {/if} From e551158041f12f99976467e837ff5dcb59f9f658 Mon Sep 17 00:00:00 2001 From: aradhana kumari Date: Thu, 26 Mar 2026 10:46:48 +0530 Subject: [PATCH 04/13] Update the text --- themes/hotel-reservation-theme/_partials/booking-form.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/hotel-reservation-theme/_partials/booking-form.tpl b/themes/hotel-reservation-theme/_partials/booking-form.tpl index c32760230..14a08ea3f 100644 --- a/themes/hotel-reservation-theme/_partials/booking-form.tpl +++ b/themes/hotel-reservation-theme/_partials/booking-form.tpl @@ -219,7 +219,7 @@ {elseif isset($los_failed_type) && $los_failed_type == 'max'} {l s='Up to %d nights allowed.' sprintf=[$los_max_days]} {else} - {l s='LOS is not match'} + {l s='Length of stay does not match the restrictions.'} {/if} {else} From f639f3814c15f1ecf3b5e364184813b03290ad25 Mon Sep 17 00:00:00 2001 From: aradhana kumari Date: Thu, 26 Mar 2026 18:02:27 +0530 Subject: [PATCH 05/13] gli-2586 --- controllers/front/ProductController.php | 50 +++++++++---------- .../_partials/booking-form.tpl | 8 ++- 2 files changed, 28 insertions(+), 30 deletions(-) diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index 4865a8fa5..1ae92a64f 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -695,39 +695,38 @@ class ProductControllerCore extends FrontController $totalAvailableRooms = 0; $losRestrictionFailed = false; - $losMinDays = 0; - $losMaxDays = 0; - $losFailedType = ''; // 'min' or 'max' to indicate which restriction failed + $losMinFailed = false; + $losMaxFailed = false; + // Initialize LOS values for the selected room type/date + $objRoomTypeRestrictionDateRange = new HotelRoomTypeRestrictionDateRange(); + $losRestriction = $objRoomTypeRestrictionDateRange->getRoomTypeLengthOfStay($idProduct, $dateFrom); + $losMinDays = (int) (($losRestriction && isset($losRestriction['min_los'])) ? $losRestriction['min_los'] : 0); + $losMaxDays = (int) (($losRestriction && isset($losRestriction['max_los'])) ? $losRestriction['max_los'] : 0); if ($hotelRoomData = $objBookingDetail->dataForFrontSearch($bookingParams)) { $totalAvailableRooms = $hotelRoomData['stats']['num_avail']; $quantity = ($quantity > $totalAvailableRooms) ? $totalAvailableRooms : $quantity; - // Check if rooms are unavailable due to LOS restriction - if ($totalAvailableRooms <= 0 && isset($hotelRoomData['rm_data'][$idProduct]['data']['unavailable'])) { + if ($totalAvailableRooms <= 0 && !empty($hotelRoomData['rm_data'][$idProduct]['data']['unavailable'])) { foreach ($hotelRoomData['rm_data'][$idProduct]['data']['unavailable'] as $unavailableRoom) { - if (isset($unavailableRoom['detail'])) { - foreach ($unavailableRoom['detail'] as $detail) { - if (isset($detail['id_status']) && $detail['id_status'] == HotelRoomInformation::STATUS_SEARCH_LOS_UNSATISFIED) { - $losRestrictionFailed = true; - // Get LOS restrictions for the room type - $objRoomTypeRestrictionDateRange = new HotelRoomTypeRestrictionDateRange(); - $losRestriction = $objRoomTypeRestrictionDateRange->getRoomTypeLengthOfStay($idProduct, $dateFrom); - if ($losRestriction) { - $losMinDays = isset($losRestriction['min_los']) ? $losRestriction['min_los'] : 0; - $losMaxDays = isset($losRestriction['max_los']) ? $losRestriction['max_los'] : 0; - // Determine which restriction failed - if ($losMinDays > 0 && $numDays < $losMinDays) { - $losFailedType = 'min'; - } elseif ($losMaxDays > 0 && $numDays > $losMaxDays) { - $losFailedType = 'max'; - } - } - break 2; - } + if (empty($unavailableRoom['detail'])) { + continue; + } + foreach ($unavailableRoom['detail'] as $detail) { + if (!empty($detail['id_status']) && $detail['id_status'] == HotelRoomInformation::STATUS_SEARCH_LOS_UNSATISFIED) { + $losRestrictionFailed = true; + break 2; } } } } + if ($losRestrictionFailed) { + // Determine which restriction failed + if ($losMinDays > 0 && $numDays < $losMinDays) { + $losMinFailed = true; + } elseif ($losMaxDays > 0 && $numDays > $losMaxDays) { + $losMaxFailed = true; + } + } } // calculate room type price first @@ -898,7 +897,8 @@ class ProductControllerCore extends FrontController $smartyVars['los_restriction_failed'] = $losRestrictionFailed; $smartyVars['los_min_days'] = $losMinDays; $smartyVars['los_max_days'] = $losMaxDays; - $smartyVars['los_failed_type'] = $losFailedType; + $smartyVars['los_min_failed'] = $losMinFailed; + $smartyVars['los_max_failed'] = $losMaxFailed; $smartyVars['has_room_type_demands'] = $roomTypeDemands ? true : false; // whether to show price breakup $smartyVars['rooms_price'] = $totalRoomPrice; $smartyVars['demands_price_per_room'] = $demandsPricePerRoom; diff --git a/themes/hotel-reservation-theme/_partials/booking-form.tpl b/themes/hotel-reservation-theme/_partials/booking-form.tpl index 14a08ea3f..b59c23e32 100644 --- a/themes/hotel-reservation-theme/_partials/booking-form.tpl +++ b/themes/hotel-reservation-theme/_partials/booking-form.tpl @@ -214,12 +214,10 @@
{if isset($los_restriction_failed) && $los_restriction_failed} - {if isset($los_failed_type) && $los_failed_type == 'min'} + {if isset($los_min_failed) && $los_min_failed} {l s='At least %d nights required.' sprintf=[$los_min_days]} - {elseif isset($los_failed_type) && $los_failed_type == 'max'} - {l s='Up to %d nights allowed.' sprintf=[$los_max_days]} - {else} - {l s='Length of stay does not match the restrictions.'} + {elseif isset($los_max_failed) && $los_max_failed} + {l s='Maximum stay allowed is %d nights.' sprintf=[$los_max_days]} {/if} {else} From 85878f6f078ef6856076bee81af7447191e0d58c Mon Sep 17 00:00:00 2001 From: aradhana kumari Date: Wed, 1 Apr 2026 19:38:40 +0530 Subject: [PATCH 06/13] Update the error message --- themes/hotel-reservation-theme/_partials/booking-form.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/hotel-reservation-theme/_partials/booking-form.tpl b/themes/hotel-reservation-theme/_partials/booking-form.tpl index b59c23e32..439363d23 100644 --- a/themes/hotel-reservation-theme/_partials/booking-form.tpl +++ b/themes/hotel-reservation-theme/_partials/booking-form.tpl @@ -215,7 +215,7 @@ {if isset($los_restriction_failed) && $los_restriction_failed} {if isset($los_min_failed) && $los_min_failed} - {l s='At least %d nights required.' sprintf=[$los_min_days]} + {l s='Minimum stay allowed is %d nights.' sprintf=[$los_min_days]} {elseif isset($los_max_failed) && $los_max_failed} {l s='Maximum stay allowed is %d nights.' sprintf=[$los_max_days]} {/if} From 9ff2bac9ed513529cc616b57b2dd6de7003c9350 Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Tue, 28 Apr 2026 11:03:49 +0530 Subject: [PATCH 07/13] Update password hashing algorithm --- classes/AdminTab.php | 4 +- classes/Customer.php | 16 +-- classes/Employee.php | 14 +- classes/Hashing.php | 125 ------------------ classes/ObjectModel.php | 4 +- classes/PasswordHashing.php | 122 +++++++++++++++++ classes/Validate.php | 2 +- classes/controller/AdminController.php | 4 +- .../WebserviceSpecificManagementBookings.php | 4 +- controllers/admin/AdminImportController.php | 4 +- controllers/admin/AdminLoginController.php | 4 +- controllers/front/IdentityController.php | 2 +- controllers/front/PasswordController.php | 4 +- install/fixtures/fashion/install.php | 4 +- install/models/install.php | 4 +- 15 files changed, 157 insertions(+), 160 deletions(-) delete mode 100644 classes/Hashing.php create mode 100644 classes/PasswordHashing.php diff --git a/classes/AdminTab.php b/classes/AdminTab.php index 2f06fe13e..0e54eac07 100644 --- a/classes/AdminTab.php +++ b/classes/AdminTab.php @@ -1181,8 +1181,8 @@ abstract class AdminTabCore } /* Automatically hash password */ if ($key == 'passwd' && !empty($value)) { - $crypto = new Hashing(); - $value = $crypto->hash($value); + $objHash = new PasswordHashing(); + $value = $objHash->passwordHash($value); } $object->{$key} = $value; } diff --git a/classes/Customer.php b/classes/Customer.php index 6ce60debc..232fb7192 100644 --- a/classes/Customer.php +++ b/classes/Customer.php @@ -390,8 +390,8 @@ class CustomerCore extends ObjectModel return false; } if (isset($passwd)) { - $crypto = new Hashing(); - if (!$crypto->checkHash($passwd, $result['passwd'])) { + $objHash = new PasswordHashing(); + if (!$objHash->validateHash($passwd, $result['passwd'])) { return false; } } @@ -401,8 +401,8 @@ class CustomerCore extends ObjectModel $this->{$key} = $value; } } - if (isset($passwd) && !$crypto->isFirstHash($passwd, $result['passwd'])) { - $this->passwd = $crypto->hash($passwd); + if (isset($passwd) && !$objHash->isPrimaryHash($passwd, $result['passwd'])) { + $this->passwd = $objHash->passwordHash($passwd); $this->update(); } return $this; @@ -861,8 +861,8 @@ class CustomerCore extends ObjectModel } $this->is_guest = 0; - $crypto = new Hashing(); - $this->passwd = $crypto->hash($password); + $objHash = new PasswordHashing(); + $this->passwd = $objHash->passwordHash($password); $this->cleanGroups(); $this->addGroups(array(Configuration::get('PS_CUSTOMER_GROUP'))); // add default customer group $this->id_default_group = (int) Configuration::get('PS_CUSTOMER_GROUP'); @@ -897,8 +897,8 @@ class CustomerCore extends ObjectModel public function setWsPasswd($passwd) { if ($this->id == 0 || $this->passwd != $passwd) { - $crypto = new Hashing(); - $this->passwd = $crypto->hash($passwd); + $objHash = new PasswordHashing(); + $this->passwd = $objHash->passwordHash($passwd); } return true; } diff --git a/classes/Employee.php b/classes/Employee.php index 84e95fa7f..7d1209fb2 100644 --- a/classes/Employee.php +++ b/classes/Employee.php @@ -287,8 +287,8 @@ class EmployeeCore extends ObjectModel } if ($passwd !== null) { - $crypto = new Hashing(); - if (!$crypto->checkHash($passwd, $result['passwd'])) { + $objHash = new PasswordHashing(); + if (!$objHash->validateHash($passwd, $result['passwd'])) { return false; } } @@ -300,8 +300,8 @@ class EmployeeCore extends ObjectModel } } - if ($passwd !== null && !$crypto->isFirstHash($passwd, $result['passwd'])) { - $this->passwd = $crypto->hash($passwd); + if ($passwd !== null && !$objHash->isPrimaryHash($passwd, $result['passwd'])) { + $this->passwd = $objHash->passwordHash($passwd); $this->update(); } return $this; @@ -375,20 +375,20 @@ class EmployeeCore extends ObjectModel // validate and set password for the employee public function setWsPasswd($passwd) { - $crypto = new Hashing(); + $objHash = new PasswordHashing(); if ($this->id != 0) { if ($this->passwd != $passwd) { if (!Validate::isHashedPassword($passwd, Validate::ADMIN_PASSWORD_LENGTH)) { WebserviceRequest::getInstance()->setError(400, 'The password must be at least '.Validate::ADMIN_PASSWORD_LENGTH.' characters long.', 134); } else { - $this->passwd = $crypto->hash($passwd); + $this->passwd = $objHash->passwordHash($passwd); } } } else { if (!Validate::isHashedPassword($passwd, Validate::ADMIN_PASSWORD_LENGTH)) { WebserviceRequest::getInstance()->setError(400, 'The password must be at least '.Validate::ADMIN_PASSWORD_LENGTH.' characters long.', 134); } else { - $this->passwd = $crypto->hash($passwd); + $this->passwd = $objHash->passwordHash($passwd); } } diff --git a/classes/Hashing.php b/classes/Hashing.php deleted file mode 100644 index ca8a245b5..000000000 --- a/classes/Hashing.php +++ /dev/null @@ -1,125 +0,0 @@ - - * @copyright 2007-2017 PrestaShop SA - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - - -class HashingCore -{ - /** @var array should contain hashing methods */ - private $hashMethods = array(); - - /** - * Check if it's the first function of the array that was used for hashing - * - * @param string $passwd The password you want to check - * @param string $hash The hash you want to check - * @param string $staticSalt A static salt - * - * @return bool Result of the verify function - */ - public function isFirstHash($passwd, $hash, $staticSalt = _COOKIE_KEY_) - { - if (!count($this->hashMethods)) { - $this->initHashMethods(); - } - - $closure = reset($this->hashMethods); - - return $closure['verify']($passwd, $hash, $staticSalt); - } - - /** - * Iterate on hash_methods array and return true if it matches - * - * @param string $passwd The password you want to check - * @param string $hash The hash you want to check - * @param string $staticSalt A static salt - * - * @return bool `true` is returned if the function find a match else false - */ - public function checkHash($passwd, $hash, $staticSalt = _COOKIE_KEY_) - { - if (!count($this->hashMethods)) { - $this->initHashMethods(); - } - - foreach ($this->hashMethods as $closure) { - if ($closure['verify']($passwd, $hash, $staticSalt)) { - return true; - } - } - - return false; - } - - /** - * Hash the `$plaintextPassword` string and return the result of the 1st hashing method - * contained in Hashing::hashMethods - * - * @param string $plaintextPassword The password you want to hash - * @param string $staticSalt The static salt - * - * @return string - */ - public function hash($plaintextPassword, $staticSalt = _COOKIE_KEY_) - { - if (!count($this->hashMethods)) { - $this->initHashMethods(); - } - - $closure = reset($this->hashMethods); - - return $closure['hash']($plaintextPassword, $staticSalt, $closure['option']); - } - - /** - * Init hash methods - * - * @return void - */ - private function initHashMethods() - { - $this->hashMethods = array( - 'bcrypt' => array( - 'option' => array(), - 'hash' => function ($passwd, $staticSalt, $option) { - return password_hash($passwd, PASSWORD_BCRYPT); - }, - 'verify' => function ($passwd, $hash, $staticSalt) { - return password_verify($passwd, $hash); - }, - ), - 'md5' => array( - 'option' => array(), - 'hash' => function ($passwd, $staticSalt, $option) { - return md5($staticSalt.$passwd); - }, - 'verify' => function ($passwd, $hash, $staticSalt) { - return md5($staticSalt.$passwd) === $hash; - }, - ), - ); - } -} diff --git a/classes/ObjectModel.php b/classes/ObjectModel.php index 8c316c571..e960ee837 100644 --- a/classes/ObjectModel.php +++ b/classes/ObjectModel.php @@ -1188,8 +1188,8 @@ abstract class ObjectModelCore implements Core_Foundation_Database_EntityInterfa } if ($field == 'passwd') { if ($value = Tools::getValue($field)) { - $crypto = new Hashing(); - $this->{$field} = $crypto->hash($value); + $objHash = new PasswordHashing(); + $this->{$field} = $objHash->passwordHash($value); } } else { $this->{$field} = $value; diff --git a/classes/PasswordHashing.php b/classes/PasswordHashing.php new file mode 100644 index 000000000..f327cc390 --- /dev/null +++ b/classes/PasswordHashing.php @@ -0,0 +1,122 @@ +passwordHashMethods)) { + $this->initPasswordHashMethods(); + } + + $closure = reset($this->passwordHashMethods); + + return $closure['verify']($passwd, $hash, $staticSalt); + } + + /** + * Validate a password against all supported hashing methods. + * + * @param string $passwd Plain-text password to validate. + * @param string $hash Stored password hash. + * @param string $staticSalt Static salt used by legacy hash methods. + * + * @return bool + */ + public function validateHash($passwd, $hash, $staticSalt = _COOKIE_KEY_) + { + if (!count($this->passwordHashMethods)) { + $this->initPasswordHashMethods(); + } + + foreach ($this->passwordHashMethods as $closure) { + if ($closure['verify']($passwd, $hash, $staticSalt)) { + return true; + } + } + + return false; + } + + /** + * Hash a plain-text password with the primary hashing method. + * + * @param string $plaintextPassword Password to hash. + * @param string $staticSalt Static salt reserved for legacy hash methods. + * + * @return string + */ + public function passwordHash($plaintextPassword, $staticSalt = _COOKIE_KEY_) + { + if (!count($this->passwordHashMethods)) { + $this->initPasswordHashMethods(); + } + + $closure = reset($this->passwordHashMethods); + + return $closure['hash']($plaintextPassword, $staticSalt, $closure['option']); + } + + /** + * Initialize the supported password hashing methods. + * + * @return void + */ + private function initPasswordHashMethods() + { + $this->passwordHashMethods = array( + 'bcrypt' => array( + 'option' => array(), + 'hash' => function ($passwd, $staticSalt, $option) { + return password_hash($passwd, PASSWORD_BCRYPT); + }, + 'verify' => function ($passwd, $hash, $staticSalt) { + return password_verify($passwd, $hash); + }, + ), + 'md5' => array( + 'option' => array(), + 'hash' => function ($passwd, $staticSalt, $option) { + return md5($staticSalt.$passwd); + }, + 'verify' => function ($passwd, $hash, $staticSalt) { + return md5($staticSalt.$passwd) === $hash; + }, + ), + ); + } +} diff --git a/classes/Validate.php b/classes/Validate.php index d47f64b66..84c789661 100644 --- a/classes/Validate.php +++ b/classes/Validate.php @@ -91,7 +91,7 @@ class ValidateCore /** * Check for password hash validity (legacy MD5 or bcrypt), or plaintext password. * - * @param string $hash + * @param string $hashedPasswd * @return bool Validity is ok or not */ public static function isHashedPassword($hashedPasswd) diff --git a/classes/controller/AdminController.php b/classes/controller/AdminController.php index 9388bf96e..cdcf6144b 100644 --- a/classes/controller/AdminController.php +++ b/classes/controller/AdminController.php @@ -3840,8 +3840,8 @@ class AdminControllerCore extends Controller } /* Automatically hash password */ if ($key == 'passwd' && !empty($value)) { - $crypto = new Hashing(); - $value = $crypto->hash($value); + $objHash = new PasswordHashing(); + $value = $objHash->passwordHash($value); } $object->{$key} = $value; } diff --git a/classes/webservice/WebserviceSpecificManagementBookings.php b/classes/webservice/WebserviceSpecificManagementBookings.php index 4e542bdcf..d8bece974 100644 --- a/classes/webservice/WebserviceSpecificManagementBookings.php +++ b/classes/webservice/WebserviceSpecificManagementBookings.php @@ -1378,8 +1378,8 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We $objCustomer->firstname = $customerDetails['firstname']; $objCustomer->lastname = $customerDetails['lastname']; $objCustomer->email = $customerDetails['email']; - $crypto = new Hashing(); - $objCustomer->passwd = $crypto->hash(Tools::passwdGen(32, 'RANDOM')); + $objHash = new PasswordHashing(); + $objCustomer->passwd = $objHash->passwordHash(Tools::passwdGen(32, 'RANDOM')); $objCustomer->phone = (isset($customerDetails['phone']) ? $customerDetails['phone'] : ''); $objCustomer->cleanGroups(); $objCustomer->add(); diff --git a/controllers/admin/AdminImportController.php b/controllers/admin/AdminImportController.php index f7ba432e1..d0934b671 100644 --- a/controllers/admin/AdminImportController.php +++ b/controllers/admin/AdminImportController.php @@ -2835,8 +2835,8 @@ class AdminImportControllerCore extends AdminController AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $customer); if ($customer->passwd) { - $crypto = new Hashing(); - $customer->passwd = $crypto->hash($customer->passwd); + $objHash = new PasswordHashing(); + $customer->passwd = $objHash->passwordHash($customer->passwd); } $customers_shop = array(); diff --git a/controllers/admin/AdminLoginController.php b/controllers/admin/AdminLoginController.php index e438f022e..6300da814 100644 --- a/controllers/admin/AdminLoginController.php +++ b/controllers/admin/AdminLoginController.php @@ -263,8 +263,8 @@ class AdminLoginControllerCore extends AdminController if (!count($this->errors)) { $pwd = Tools::passwdGen(10, 'RANDOM'); - $crypto = new Hashing(); - $employee->passwd = $crypto->hash($pwd); + $objHash = new PasswordHashing(); + $employee->passwd = $objHash->passwordHash($pwd); $employee->last_passwd_gen = date('Y-m-d H:i:s', time()); $params = array( diff --git a/controllers/front/IdentityController.php b/controllers/front/IdentityController.php index 9f8a1c904..b24881336 100644 --- a/controllers/front/IdentityController.php +++ b/controllers/front/IdentityController.php @@ -71,7 +71,7 @@ class IdentityControllerCore extends FrontController $this->errors[] = Tools::displayError('This email address is not valid'); } elseif ($this->customer->email != $email && Customer::customerExists($email, true)) { $this->errors[] = Tools::displayError('An account using this email address has already been registered.'); - } elseif (!Tools::getIsset('old_passwd') || !(new Hashing())->checkHash($old_passwd, $this->context->cookie->passwd)) { + } elseif (!Tools::getIsset('old_passwd') || !(new PasswordHashing())->validateHash($old_passwd, $this->context->cookie->passwd)) { $this->errors[] = Tools::displayError('The password you entered is incorrect.'); } elseif (Tools::getValue('passwd') != Tools::getValue('confirmation')) { $this->errors[] = Tools::displayError('The password and confirmation do not match.'); diff --git a/controllers/front/PasswordController.php b/controllers/front/PasswordController.php index 5bfd526ee..a2bb002b1 100644 --- a/controllers/front/PasswordController.php +++ b/controllers/front/PasswordController.php @@ -73,8 +73,8 @@ class PasswordControllerCore extends FrontController } elseif ((strtotime($customer->last_passwd_gen.'+'.(int)Configuration::get('PS_PASSWD_TIME_FRONT').' minutes') - time()) > 0) { Tools::redirect('index.php?controller=authentication&error_regen_pwd'); } else { - $crypto = new Hashing(); - $customer->passwd = $crypto->hash($password = Tools::passwdGen(MIN_PASSWD_LENGTH, 'RANDOM')); + $objHash = new PasswordHashing(); + $customer->passwd = $objHash->passwordHash($password = Tools::passwdGen(MIN_PASSWD_LENGTH, 'RANDOM')); $customer->last_passwd_gen = date('Y-m-d H:i:s', time()); if ($customer->update()) { Hook::exec('actionPasswordRenew', array('customer' => $customer, 'password' => $password)); diff --git a/install/fixtures/fashion/install.php b/install/fixtures/fashion/install.php index e14ad92bf..da0969f32 100644 --- a/install/fixtures/fashion/install.php +++ b/install/fixtures/fashion/install.php @@ -35,8 +35,8 @@ class InstallFixturesFashion extends InstallXmlLoader public function createEntityCustomer($identifier, array $data, array $data_lang) { if ($identifier == 'John') { - $crypto = new Hashing(); - $data['passwd'] = $crypto->hash('123456789'); + $objHash = new PasswordHashing(); + $data['passwd'] = $objHash->passwordHash('123456789'); $data['last_passwd_gen'] = date('Y-m-d H:i:s'); $data['birthday'] = date('Y-m-d', strtotime('-30 years')); $data['newsletter_date_add'] = date('Y-m-d H:i:s'); diff --git a/install/models/install.php b/install/models/install.php index 2a36638d8..461237b9c 100644 --- a/install/models/install.php +++ b/install/models/install.php @@ -566,8 +566,8 @@ class InstallModelInstall extends InstallAbstractModel $employee->firstname = Tools::ucfirst($data['admin_firstname']); $employee->lastname = Tools::ucfirst($data['admin_lastname']); $employee->email = $data['admin_email']; - $crypto = new Hashing(); - $employee->passwd = $crypto->hash($data['admin_password']); + $objHash = new PasswordHashing(); + $employee->passwd = $objHash->passwordHash($data['admin_password']); $employee->last_passwd_gen = date('Y-m-d h:i:s', strtotime('-360 minutes')); $employee->bo_theme = 'default'; $employee->default_tab = 1; From 0d206a4ec2b507baf58c2cb0cf9de6846506ff36 Mon Sep 17 00:00:00 2001 From: varun kewlani Date: Thu, 30 Apr 2026 16:10:53 +0530 Subject: [PATCH 08/13] added: X-Powered-By: QloApps in response header --- config/config.inc.php | 1 + 1 file changed, 1 insertion(+) diff --git a/config/config.inc.php b/config/config.inc.php index b8ef2014b..15619d9f7 100644 --- a/config/config.inc.php +++ b/config/config.inc.php @@ -45,6 +45,7 @@ ini_set('magic_quotes_sybase', 0); /* correct Apache charset (except if it's too late */ if (!headers_sent()) { header('Content-Type: text/html; charset=utf-8'); + header('X-Powered-By: QloApps'); } /* No settings file? goto installer... */ From 7cc463618ca64ac8d981fbe48973f8c4bda5a3cd Mon Sep 17 00:00:00 2001 From: varun kewlani Date: Thu, 30 Apr 2026 19:50:53 +0530 Subject: [PATCH 10/13] added: X-Built-With: QloApps to response header Co-authored-by: Name --- config/config.inc.php | 1 + 1 file changed, 1 insertion(+) diff --git a/config/config.inc.php b/config/config.inc.php index 15619d9f7..8bb387c59 100644 --- a/config/config.inc.php +++ b/config/config.inc.php @@ -46,6 +46,7 @@ ini_set('magic_quotes_sybase', 0); if (!headers_sent()) { header('Content-Type: text/html; charset=utf-8'); header('X-Powered-By: QloApps'); + header('X-Built-With: QloApps'); } /* No settings file? goto installer... */ From a02ea17652c859d9230fe6fe2ed5292f6b7a0946 Mon Sep 17 00:00:00 2001 From: aradhana kumari Date: Fri, 1 May 2026 13:16:44 +0530 Subject: [PATCH 11/13] Update the logic of minlos --- controllers/front/ProductController.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index 1ae92a64f..ef4f509f7 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -675,7 +675,7 @@ class ProductControllerCore extends FrontController 'id_room_type' => $idProduct, 'id_cart' => $idCart, 'id_guest' => $idGuest, - 'search_unavai' => 1, // Need to search unavailable rooms to check LOS restriction + 'search_unavai' => 1, ); if (Configuration::get('PS_FRONT_ROOM_UNIT_SELECTION_TYPE') == HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) { $bookingParams['occupancy'] = $occupancy; @@ -700,8 +700,8 @@ class ProductControllerCore extends FrontController // Initialize LOS values for the selected room type/date $objRoomTypeRestrictionDateRange = new HotelRoomTypeRestrictionDateRange(); $losRestriction = $objRoomTypeRestrictionDateRange->getRoomTypeLengthOfStay($idProduct, $dateFrom); - $losMinDays = (int) (($losRestriction && isset($losRestriction['min_los'])) ? $losRestriction['min_los'] : 0); - $losMaxDays = (int) (($losRestriction && isset($losRestriction['max_los'])) ? $losRestriction['max_los'] : 0); + $losMinDays = (int) ($losRestriction ? $losRestriction['min_los'] : 1); + $losMaxDays = (int) ($losRestriction ? $losRestriction['max_los'] : 0); if ($hotelRoomData = $objBookingDetail->dataForFrontSearch($bookingParams)) { $totalAvailableRooms = $hotelRoomData['stats']['num_avail']; $quantity = ($quantity > $totalAvailableRooms) ? $totalAvailableRooms : $quantity; @@ -721,7 +721,7 @@ class ProductControllerCore extends FrontController } if ($losRestrictionFailed) { // Determine which restriction failed - if ($losMinDays > 0 && $numDays < $losMinDays) { + if ($numDays < $losMinDays) { $losMinFailed = true; } elseif ($losMaxDays > 0 && $numDays > $losMaxDays) { $losMaxFailed = true; From 51d6bf2d99ab5da5951c924cccfec3f1073fb120 Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Tue, 5 May 2026 14:53:47 +0530 Subject: [PATCH 12/13] Added: Add hook in parent uninstall function Co-authored-by: Name --- classes/module/Module.php | 1 + 1 file changed, 1 insertion(+) diff --git a/classes/module/Module.php b/classes/module/Module.php index 0d328604c..6b08a164e 100644 --- a/classes/module/Module.php +++ b/classes/module/Module.php @@ -689,6 +689,7 @@ abstract class ModuleCore */ public function uninstall() { + Hook::exec('actionModuleUninstallBefore', array('object' => $this)); // Check module installation id validation if (!Validate::isUnsignedId($this->id)) { $this->_errors[] = Tools::displayError('The module is not installed.'); From 01715952a26e934b2b588053a98ac0cd43289c2f Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Tue, 12 May 2026 10:05:21 +0530 Subject: [PATCH 13/13] remove isHashPassword function from validate class and use isPasswd --- classes/Customer.php | 8 ++++---- classes/Employee.php | 8 ++++---- classes/Validate.php | 13 ------------- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/classes/Customer.php b/classes/Customer.php index 232fb7192..d5644633b 100644 --- a/classes/Customer.php +++ b/classes/Customer.php @@ -167,7 +167,7 @@ class CustomerCore extends ObjectModel 'lastname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 32), 'firstname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 32), 'email' => array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'required' => true, 'size' => 128), - 'passwd' => array('type' => self::TYPE_STRING, 'validate' => 'isHashedPassword', 'required' => true, 'size' => 60), + 'passwd' => array('type' => self::TYPE_STRING, 'validate' => 'isPasswd', 'required' => true, 'size' => 60), 'last_passwd_gen' => array('type' => self::TYPE_STRING, 'copy_post' => false), 'id_gender' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'birthday' => array('type' => self::TYPE_DATE, 'validate' => 'isBirthDate'), @@ -374,7 +374,7 @@ class CustomerCore extends ObjectModel */ public function getByEmail($email, $passwd = null, $ignore_guest = true) { - if (!Validate::isEmail($email) || ($passwd && !Validate::isHashedPassword($passwd))) { + if (!Validate::isEmail($email) || ($passwd && !Validate::isPasswd($passwd))) { die(Tools::displayError()); } @@ -569,7 +569,7 @@ class CustomerCore extends ObjectModel */ public static function checkPassword($id_customer, $passwd) { - if (!Validate::isUnsignedId($id_customer) || !Validate::isHashedPassword($passwd)) { + if (!Validate::isUnsignedId($id_customer)) { die(Tools::displayError()); } $cache_id = 'Customer::checkPassword'.(int)$id_customer.'-'.$passwd; @@ -856,7 +856,7 @@ class CustomerCore extends ObjectModel if (empty($password)) { $password = Tools::passwdGen(8, 'RANDOM'); } - if (!Validate::isHashedPassword($password)) { + if (!Validate::isPasswd($password)) { return false; } diff --git a/classes/Employee.php b/classes/Employee.php index 7d1209fb2..fa6b06a1a 100644 --- a/classes/Employee.php +++ b/classes/Employee.php @@ -273,7 +273,7 @@ class EmployeeCore extends ObjectModel */ public function getByEmail($email, $passwd = null, $active_only = true) { - if (!Validate::isEmail($email) || ($passwd != null && !Validate::isHashedPassword($passwd))) { + if (!Validate::isEmail($email) || ($passwd != null && !Validate::isPasswd($passwd))) { die(Tools::displayError()); } @@ -327,7 +327,7 @@ class EmployeeCore extends ObjectModel */ public static function checkPassword($id_employee, $passwd) { - if (!Validate::isUnsignedId($id_employee) || !Validate::isHashedPassword($passwd, 8)) { + if (!Validate::isUnsignedId($id_employee)) { die(Tools::displayError()); } @@ -378,14 +378,14 @@ class EmployeeCore extends ObjectModel $objHash = new PasswordHashing(); if ($this->id != 0) { if ($this->passwd != $passwd) { - if (!Validate::isHashedPassword($passwd, Validate::ADMIN_PASSWORD_LENGTH)) { + if (!Validate::isPasswd($passwd, Validate::ADMIN_PASSWORD_LENGTH)) { WebserviceRequest::getInstance()->setError(400, 'The password must be at least '.Validate::ADMIN_PASSWORD_LENGTH.' characters long.', 134); } else { $this->passwd = $objHash->passwordHash($passwd); } } } else { - if (!Validate::isHashedPassword($passwd, Validate::ADMIN_PASSWORD_LENGTH)) { + if (!Validate::isPasswd($passwd, Validate::ADMIN_PASSWORD_LENGTH)) { WebserviceRequest::getInstance()->setError(400, 'The password must be at least '.Validate::ADMIN_PASSWORD_LENGTH.' characters long.', 134); } else { $this->passwd = $objHash->passwordHash($passwd); diff --git a/classes/Validate.php b/classes/Validate.php index 84c789661..0d59c99e7 100644 --- a/classes/Validate.php +++ b/classes/Validate.php @@ -88,19 +88,6 @@ class ValidateCore return preg_match('/^[a-f0-9A-F]{32}$/', $md5); } - /** - * Check for password hash validity (legacy MD5 or bcrypt), or plaintext password. - * - * @param string $hashedPasswd - * @return bool Validity is ok or not - */ - public static function isHashedPassword($hashedPasswd) - { - return self::isPasswd($hashedPasswd) - || Tools::strlen($hashedPasswd) == 32 - || Tools::strlen($hashedPasswd) == 60; - } - /** * Check for SHA1 string validity *