Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Leaderboard

Popular Content

Showing content with the highest reputation on 02/02/2026 in all areas

  1. Якщо не етапі установки або через панель адміністрування створити користувача в паролі якого будуть використані спецсимволи, то користувач не зможе увійти - буде помилка пароля при вході. В OpenCart вбудований клас Request при отриманні даних з $_POST обробляє їх для захисту від XSS-атак, перетворюючи небезпечні символи HTML-сутності. Проблема в admin/controller/user/user.php в якому забули перед збереженням паролю зробити html_entity_decode При натисканні кнопки "Зберегти", у масиві $this->request->post['password'] спецсимволи вже замінені на HTML-сутності (наприклад, & перетворився на &). При збереженні: Контролер передає в модель addUser масив "як є". До бази даних записується хеш від рядка 123&amp456. При логіні: код робить html_entity_decode та намагається перевірити пароль 123&456. Підсумок: Хеші не збігаються. Вхід неможливий. Щоб виправити, потрібно декодувати пароль (додати html_entity_decode) перед тим, як передати його в модель для збереження в базу. Це потрібно зробити у методі add() та у методі edit() та ще й у validateForm(). Приклад для add() Знайти if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) { $this->model_user_user->addUser($this->request->post); Замінити if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) { // Декодуемо пароль перед збреженням $this->request->post['password'] = html_entity_decode($this->request->post['password'], ENT_QUOTES, 'UTF-8'); $this->model_user_user->addUser($this->request->post); Зробити по аналогії для метода edit() знайти if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) { $this->model_user_user->editUser($this->request->get['user_id'], $this->request->post); замінити if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) { // Декодуємо пароль перед збереженням (якщо його змінено) if ($this->request->post['password']) { $this->request->post['password'] = html_entity_decode($this->request->post['password'], ENT_QUOTES, 'UTF-8'); } $this->model_user_user->editUser($this->request->get['user_id'], $this->request->post); Для validateForm() знайти if ($this->request->post['password'] != $this->request->post['confirm']) { $this->error['confirm'] = $this->language->get('error_confirm'); } замінити if (html_entity_decode($this->request->post['password'], ENT_QUOTES, 'UTF-8') != html_entity_decode($this->request->post['confirm'], ENT_QUOTES, 'UTF-8')) { $this->error['confirm'] = $this->language->get('error_confirm'); }
    1 point
Guest
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.