diff --git a/README.md b/README.md index 85637c3..691e42b 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,33 @@ ### login -## Модуль Авторизация v2.26.1 +## Модуль Авторизация v3.31.1 ### Данный модуль предназначен для регистрации пользователей на вашем сайте. - * Для вывода формы авторизации, разместите системный тег [mod_login] в нужном месте вашего шаблона. Также вы можете указать шаблон, в котором будет отображена форма для регистрации и авторизации. + * Для вывода формы авторизации, разместите системный тег [mod_login] в нужном месте вашего шаблона. Также вы можете указать шаблон, в котором будет отображена форма для регистрации и авторизации. Для подключения в дефолтный шаблон Ave.cms начиная с версии 3.31 ALT , найдите блок: + ``` + +``` +и замените его на: + +``` + +``` + ### Changelog: +05.03.2026 - версия 3.31.1 Рефакторинг кода для работы в среде PHP-8.4, +добавлено управление Аватаром Пользователя, улучшен Пользовательский интерфейс, верстка Bootstrap v5 + 02.09.2019 - версия 2.26.1 Адаптирован для версии 3.26 20.04.2014 - версия 2.2.1 \ No newline at end of file diff --git a/admin/config.tpl b/admin/config.tpl index 41a35b8..d0e5647 100644 --- a/admin/config.tpl +++ b/admin/config.tpl @@ -2,97 +2,147 @@
- {#LOGIN_MODULE_INFO#} + {#LOGIN_MODULE_INFO#}
-
-
{#LOGIN_MODULE_EDIT#}
+
{#LOGIN_MODULE_EDIT#}
-
- + +
+ + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + +
{#LOGIN_REGISTRATION_TYPE#} + +
{#LOGIN_REGISTRATION_TYPE#} - -
{#LOGIN_USE_SCODE#} + + +
{#LOGIN_USE_SCODE#} - - -
{#LOGIN_ENABLE_REGISTER#} + + +
{#LOGIN_ENABLE_REGISTER#} - - -
{#LOGIN_SHOW_FIRSTNAME#} + + +
{#LOGIN_SHOW_FIRSTNAME#} - - -
{#LOGIN_SHOW_LASTNAME#} + + +
{#LOGIN_SHOW_LASTNAME#} - - -
{#LOGIN_SHOW_COMPANY#} + + +
{#LOGIN_SHOW_COMPANY#} - - -
{#LOGIN_SHOW_COUNTRY#} + + +
{#LOGIN_BLACK_DOMAINS#} - -
{#LOGIN_BLACK_DOMAINS#} + +
{#LOGIN_BLACK_EMAILS#} - -
{#LOGIN_BLACK_EMAILS#} + +
+ +
+
- -
- - {#LOGIN_SETTING_EXIT#} -
- - \ No newline at end of file + \ No newline at end of file diff --git a/class/login.php b/class/login.php index 9ce31b3..868038c 100644 --- a/class/login.php +++ b/class/login.php @@ -104,6 +104,8 @@ if (self::_required('login_require_lastname')) $AVE_Template->assign('lastname', 1); + if (self::_required('login_require_country')) + $AVE_Template->assign('country', 1); } @@ -208,41 +210,43 @@ } - /* - |----------------------------------------------------------------------------------------------------------------------- - | settings - |----------------------------------------------------------------------------------------------------------------------- - | - | Получение параметра настройки модуля Авторизация - | - */ - public static function settings ($field = '') - { - global $AVE_DB; +/* + |----------------------------------------------------------------------------------------------------------------------- + | settings + |----------------------------------------------------------------------------------------------------------------------- + | + | + | + */ + public static function settings ($field = '') + { + global $AVE_DB; - static $settings = null; + static $settings = null; - if ($settings === null) - { - $sql = " - SELECT - * - FROM - " . PREFIX . "_module_login - WHERE - id = '1' - "; + if ($settings === null) + { + $sql = " + SELECT + * + FROM + " . PREFIX . "_module_login + WHERE + id = '1' + "; - $settings = $AVE_DB->Query($sql, -1, 'modules/login', true, '.settings')->FetchAssocArray(); - } + $res = $AVE_DB->Query($sql, -1, 'modules/login', true, '.settings'); + + // В PHP 8.4 проверяем, что $res — это объект, прежде чем дергать метод + $settings = (is_object($res)) ? $res->FetchAssocArray() : array(); + } - if ($field == '') - return $settings; + if ($field == '') + return $settings; - return isset($settings[$field]) - ? $settings[$field] - : null; - } + // Используем Null Coalescing Operator для защиты от Notice в PHP 8.4 + return $settings[$field] ?? null; + } /* |----------------------------------------------------------------------------------------------------------------------- @@ -278,303 +282,350 @@ } - /* - |----------------------------------------------------------------------------------------------------------------------- - | form - |----------------------------------------------------------------------------------------------------------------------- - | - | Форма авторизации - | - */ - public static function form () - { - global $AVE_Template; +/* + |----------------------------------------------------------------------------------------------------------------------- + | form + |----------------------------------------------------------------------------------------------------------------------- + | + | + | + */ + public static function form () + { + global $AVE_Template; - $AVE_Template->config_load(self::$_lang_file, 'loginform'); + $AVE_Template->config_load(self::$_lang_file, 'loginform'); - if (self::settings('login_status') == 1) - $AVE_Template->assign('active', 1); + if (self::settings('login_status') == 1) + $AVE_Template->assign('active', 1); - define('MODULE_TITLE', $AVE_Template->get_config_vars('LOGIN_AUTORIZATION')); - define('MODULE_CONTENT', $AVE_Template->fetch(self::$_tpl_dir . 'loginform.tpl')); - } + // PHP 8.4: Принудительно приводим к строке (string), чтобы избежать + // ошибки Deprecated/Fatal при передаче null в системные функции шаблонизатора. + define('MODULE_TITLE', (string)$AVE_Template->get_config_vars('LOGIN_AUTORIZATION')); + define('MODULE_CONTENT', $AVE_Template->fetch(self::$_tpl_dir . 'loginform.tpl')); + } - /* - |----------------------------------------------------------------------------------------------------------------------- - | authorize - |----------------------------------------------------------------------------------------------------------------------- - | - | Авторизация пользователя - | - */ - public static function authorize () - { - global $AVE_DB, $AVE_Template; +/* + |----------------------------------------------------------------------------------------------------------------------- + | authorize + |----------------------------------------------------------------------------------------------------------------------- + | + | + | + */ + public static function authorize () + { + global $AVE_DB, $AVE_Template; - if (empty($_SESSION['referer'])) - { - $referer = get_referer_link(); + if (empty($_SESSION['referer'])) + { + $referer = get_referer_link(); - $_SESSION['referer'] = (false === strstr($referer, 'module=login')) - ? $referer - : get_home_link(); - } + // Проверяем наличие referer, исключая саму страницу логина + $_SESSION['referer'] = (false === strstr((string)$referer, 'module=login')) + ? $referer + : get_home_link(); + } - $login = $AVE_DB->EscStr($_POST['user_login']); + // PHP 8.4: гарантируем тип string для входящих данных из POST + $login = addslashes((string)($_POST['user_login'] ?? '')); + $password = (string)($_POST['user_pass'] ?? ''); - $password = $AVE_DB->EscStr($_POST['user_pass']); + $keep_in = isset($_POST['keep_in']) + ? (int)$_POST['keep_in'] + : false; - $keep_in = isset($_POST['keep_in']) - ? (int)$AVE_DB->EscStr($_POST['keep_in']) - : false; + if ($login !== '' && $password !== '') + { + // Вызов системной функции авторизации ядра AVE.cms + $result = user_login($login, $password, 1, $keep_in); - if (! empty($login) && !empty($password)) - { - $result = user_login($login, $password,1, $keep_in); + if ($result === true) + { + // Успешный вход: редирект на сохраненный referer + $target = $_SESSION['referer'] ?? get_home_link(); + header('Location:' . rewrite_link((string)$target)); + unset($_SESSION['referer']); + exit; + } + elseif ($result === 3) + { + // Случай, когда требуется активация (статус 3) + header('Location:' . ABS_PATH . 'index.php?module=login&action=register&sub=final'); + exit; + } + else + { + // Ошибка входа: чистим сессию + unset($_SESSION['user_id'], $_SESSION['user_pass']); + $AVE_Template->assign('login', false); + } + } + else + { + $AVE_Template->assign('login', false); + } - if ($result === true) - { - header('Location:' . rewrite_link($_SESSION['referer'])); - unset($_SESSION['referer']); - exit; - } - elseif ($result === 3) - { - header('Location:' . ABS_PATH . 'index.php?module=login&action=register&sub=final'); - exit; - } - else - { - unset($_SESSION['user_id'], $_SESSION['user_pass']); + if (self::settings('login_status') == 1) + $AVE_Template->assign('active', 1); - $AVE_Template->assign('login', false); - } - } - else - { - $AVE_Template->assign('login', false); - } + $AVE_Template->config_load(self::$_lang_file, 'loginprocess'); - if (self::settings('login_status') == 1) - $AVE_Template->assign('active', 1); - - $AVE_Template->config_load(self::$_lang_file, 'loginprocess'); - - if (! defined('MODULE_CONTENT')) - { - define('MODULE_TITLE', $AVE_Template->get_config_vars('LOGIN_AUTORIZATION')); - define('MODULE_CONTENT', $AVE_Template->fetch(self::$_tpl_dir . 'process.tpl')); - } - } + if (! defined('MODULE_CONTENT')) + { + if (!defined('MODULE_TITLE')) + { + define('MODULE_TITLE', (string)$AVE_Template->get_config_vars('LOGIN_AUTORIZATION')); + } + define('MODULE_CONTENT', $AVE_Template->fetch(self::$_tpl_dir . 'process.tpl')); + } + } - /* - |----------------------------------------------------------------------------------------------------------------------- - | authorize - |----------------------------------------------------------------------------------------------------------------------- - | - | Выход из системы - | - */ - public static function logout () - { - user_logout(); +/* + |----------------------------------------------------------------------------------------------------------------------- + | logout + |----------------------------------------------------------------------------------------------------------------------- + | + | + | + */ + public static function logout () + { + // Вызываем системную функцию ядра для очистки куки и сессий + user_logout(); - $referer_link = get_referer_link(); + // Получаем адрес страницы, с которой пришел пользователь + $referer_link = get_referer_link(); - if (false === strstr($referer_link, 'module=login')) - header('Location:' . $referer_link); - else - header('Location:' . get_home_link()); - exit; - } + // PHP 8.4: Приводим к строке, чтобы strstr не ругался на null. + // Если мы выходим со страницы логина, кидаем на главную, + // чтобы не зацикливать форму. + if (false === strstr((string)$referer_link, 'module=login')) + { + header('Location:' . $referer_link); + } + else + { + header('Location:' . get_home_link()); + } + exit; + } - /* - |----------------------------------------------------------------------------------------------------------------------- - | profile - |----------------------------------------------------------------------------------------------------------------------- - | - | Управление учетной записью пользователя - | - */ - public static function profile () - { - global $AVE_DB, $AVE_Template; +/* + |----------------------------------------------------------------------------------------------------------------------- + | profile + |----------------------------------------------------------------------------------------------------------------------- + | + | + | + */ +public static function profile () + { + global $AVE_DB, $AVE_Template; - if (! isset($_SESSION['user_id']) || ! isset($_SESSION['user_pass'])) - { - header('Location:' . get_home_link()); - exit; - } + if (! isset($_SESSION['user_id']) || ! isset($_SESSION['user_pass'])) + { + header('Location:' . get_home_link()); + exit; + } - $AVE_Template->config_load(self::$_lang_file, 'myprofile'); + $AVE_Template->config_load(self::$_lang_file, 'myprofile'); - if (isset($_REQUEST['sub']) && $_REQUEST['sub'] == 'update') - { - $errors = array(); + if (isset($_REQUEST['sub']) && $_REQUEST['sub'] == 'update') + { + $errors = array(); - if (self::_required('login_require_firstname') && empty($_POST['firstname'])) - $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_FN_EMPTY'); + if (self::_required('login_require_firstname') && empty($_POST['firstname'])) + $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_FN_EMPTY'); - if (preg_match(self::$_regex, $_POST['firstname'])) - $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_FIRSTNAME'); + if (preg_match(self::$_regex, (string)($_POST['firstname'] ?? ''))) + $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_FIRSTNAME'); - if (self::_required('login_require_lastname') && empty($_POST['lastname'])) - $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_LN_EMPTY'); + if (self::_required('login_require_lastname') && empty($_POST['lastname'])) + $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_LN_EMPTY'); - if (preg_match(self::$_regex, $_POST['lastname'])) - $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_LASTNAME'); + if (preg_match(self::$_regex, (string)($_POST['lastname'] ?? ''))) + $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_LASTNAME'); - if (! empty($_POST['street']) && preg_match(self::$_regex, $_POST['street'])) - $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_STREET'); + if (! empty($_POST['street']) && preg_match(self::$_regex, (string)$_POST['street'])) + $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_STREET'); - if (! empty($_POST['street_nr']) && preg_match(self::$_regex, $_POST['street_nr'])) - $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_HOUSE'); + if (! empty($_POST['street_nr']) && preg_match(self::$_regex, (string)$_POST['street_nr'])) + $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_HOUSE'); - if (! empty($_POST['zipcode']) && preg_match(self::$_regex, $_POST['zipcode'])) - $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_ZIP'); + if (! preg_match(self::$_regex_email, (string)($_POST['email'] ?? ''))) + { + $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_EMAIL'); + } + else + { + $exist = $AVE_DB->Query(" + SELECT 1 FROM " . PREFIX . "_users + WHERE Id != '" . (int)$_SESSION['user_id'] . "' + AND email = '" . addslashes((string)$_POST['email']) . "' + ")->NumRows(); - if (! empty($_POST['city']) && preg_match(self::$_regex, $_POST['city'])) - $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_TOWN'); + if ($exist) + $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_INUSE'); + } - if (! empty($_POST['phone']) && preg_match(self::$_regex, $_POST['phone'])) - $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_PHONE'); + if (! empty($errors)) + { + $AVE_Template->assign('errors', $errors); + } + else + { +// --- ОБРАБОТКА АВАТАРА --- +$avatar_dir = str_replace('\\', '/', realpath(BASE_DIR . '/' . UPLOAD_DIR . '/avatars')) . '/'; - if (! preg_match(self::$_regex_email, $_POST['email'])) - { - $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_EMAIL'); - } - else - { - $exist = $AVE_DB->Query(" - SELECT 1 - FROM - " . PREFIX . "_users - WHERE - Id != '" . (int)$_SESSION['user_id'] . "' - AND - email = '" . $_POST['email'] . "' - ")->NumRows(); +// Получаем текущий хеш из Email и хеш из системы (getAvatar) +$u_data = $AVE_DB->Query("SELECT email FROM " . PREFIX . "_users WHERE Id = '" . (int)$_SESSION['user_id'] . "'")->FetchAssocArray(); +$email_hash = md5(strtolower(trim((string)$u_data['email']))); - if ($exist) - $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_INUSE'); - } +$sys_avatar_url = getAvatar((int)$_SESSION['user_id']); +$raw_name = basename(parse_url((string)$sys_avatar_url, PHP_URL_PATH)); +$sys_hash = (!empty($raw_name)) ? substr($raw_name, 0, 32) : ''; - if (! empty($_POST['birthday']) && ! preg_match(self::$_regex_geb, $_POST['birthday'])) - $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_BIRTHDAY'); +// Универсальный чистильщик +$cleaner = function($dir, $search_hash) { + if (strlen((string)$search_hash) < 10 || !is_dir($dir)) return; + clearstatcache(); + $it = new RecursiveIteratorIterator( + new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS), + RecursiveIteratorIterator::CHILD_FIRST + ); + foreach ($it as $f) { + if (strpos($f->getFilename(), (string)$search_hash) !== false) { + $p = $f->getRealPath(); + @chmod($p, 0666); + @unlink($p); + } + } +}; - if (! empty($_POST['birthday'])) - { - $birthday = preg_split('/[[:punct:]| ]/', $_POST['birthday']); +// УДАЛЕНИЕ +if (!empty($_POST['delete_avatar'])) { + if (!empty($sys_hash)) $cleaner($avatar_dir, $sys_hash); + if (!empty($email_hash) && $email_hash !== $sys_hash) $cleaner($avatar_dir, $email_hash); - if (empty($birthday[0]) || $birthday[0] > 31) - $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_DATE'); + if (function_exists('SetAvatar')) SetAvatar((int)$_SESSION['user_id'], ''); + + header('Location: index.php?module=login&action=info&save=ok'); + exit; +} - if (empty($birthday[1]) || $birthday[1] > 12) - $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_MONTH'); +// ЗАГРУЗКА +if (isset($_FILES['avatar']) && $_FILES['avatar']['error'] == UPLOAD_ERR_OK) { + // Сносим старье перед загрузкой + if (!empty($sys_hash)) $cleaner($avatar_dir, $sys_hash); + if (!empty($email_hash)) $cleaner($avatar_dir, $email_hash); + + $tmp = $_FILES['avatar']['tmp_name']; + $ext = pathinfo($_FILES['avatar']['name'], PATHINFO_EXTENSION); + $final_path = $avatar_dir . $email_hash . '.' . $ext; + + if (move_uploaded_file($tmp, $final_path)) { + if (function_exists('SetAvatar')) SetAvatar((int)$_SESSION['user_id'], $final_path); + } +} +// --- КОНЕЦ БЛОКА АВАТАРА --- - if (empty($birthday[2]) || $birthday[2] > date("Y") || $birthday[2] < date("Y")-100) - $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_YEAR'); + $AVE_DB->Query(" + UPDATE " . PREFIX . "_users + SET + firstname = '" . addslashes((string)$_POST['firstname']) . "', + lastname = '" . addslashes((string)$_POST['lastname']) . "', + email = '" . addslashes((string)$_POST['email']) . "', + street = '" . addslashes((string)($_POST['street'] ?? '')) . "', + street_nr = '" . addslashes((string)($_POST['street_nr'] ?? '')) . "', + zipcode = '" . addslashes((string)($_POST['zipcode'] ?? '')) . "', + city = '" . addslashes((string)($_POST['city'] ?? '')) . "', + phone = '" . addslashes((string)($_POST['phone'] ?? '')) . "', + country = '" . addslashes((string)($_POST['country'] ?? '')) . "', + birthday = '" . addslashes((string)($_POST['birthday'] ?? '')) . "', + company = '" . addslashes((string)($_POST['company'] ?? '')) . "' + WHERE + Id = '" . (int)$_SESSION['user_id'] . "' + AND + password = '" . addslashes((string)$_SESSION['user_pass']) . "' + "); - if (empty($errors)) - $_POST['birthday'] = $birthday[0] . '.' . $birthday[1] . '.' . $birthday[2]; - } + header('Location: index.php?module=login&action=info&save=ok'); + exit; + } + } - if (! empty($errors)) - { - $AVE_Template->assign('errors', $errors); - } - else - { - $AVE_DB->Query(" - UPDATE " . PREFIX . "_users - SET - firstname = '" . $_POST['firstname'] . "', - lastname = '" . $_POST['lastname'] . "', - email = '" . $_POST['email'] . "', - street = '" . $_POST['street'] . "', - street_nr = '" . $_POST['street_nr'] . "', - zipcode = '" . $_POST['zipcode'] . "', - city = '" . $_POST['city'] . "', - phone = '" . $_POST['phone'] . "', - country = '" . $_POST['country'] . "', - birthday = '" . $_POST['birthday'] . "', - company = '" . $_POST['company'] . "' - WHERE - Id = '" . (int)$_SESSION['user_id'] . "' - AND - password = '" . addslashes($_SESSION['user_pass']) . "' - "); + $sql = "SELECT * FROM " . PREFIX . "_users WHERE Id = '" . (int)$_SESSION['user_id'] . "' LIMIT 1"; + $user = $AVE_DB->Query($sql)->FetchAssocArray(); - $new_a = BASE_DIR.'/uploads/avatars/new_' . md5(get_userlogin_by_id($_SESSION['user_id'])) . '.jpg'; - $old_a = BASE_DIR.'/uploads/avatars/' . md5(get_userlogin_by_id($_SESSION['user_id'])) . '.jpg'; + // --- ВЫВОД АВАТАРА --- + $u_avatar = getAvatar((int)$_SESSION['user_id'], 150); + + // Берем ABS_PATH из константы или переменной Smarty + $abs_path = (defined('ABS_PATH')) ? ABS_PATH : '/'; - if (file_exists($new_a)) - { - @unlink($old_a); - @rename($new_a,$old_a); - } + // Если аватар пустой или это старая заглушка (маленькая 40х40) + if (empty($u_avatar) || strpos($u_avatar, 'user.png') !== false) { + $u_avatar = $abs_path . 'uploads/avatars/default.png'; + } - $AVE_Template->assign('password_changed', 1); - } - } + $AVE_Template->assign('user_avatar', $u_avatar); + // --------------------------------- - $sql = " - SELECT - * - FROM - " . PREFIX . "_users - WHERE - Id = '" . (int)$_SESSION['user_id'] . "' - LIMIT 1 - "; + $AVE_Template->assign('available_countries', get_country_list(1)); + $AVE_Template->assign('row', $user); - $user = $AVE_DB->Query($sql)->FetchAssocArray(); + self::_requiredfetch(); - $AVE_Template->assign('available_countries', get_country_list(1)); - $AVE_Template->assign('row', $user); - - self::_requiredfetch(); - - define('MODULE_TITLE', $AVE_Template->get_config_vars('LOGIN_CHANGE_DETAILS')); - define('MODULE_CONTENT', $AVE_Template->fetch(self::$_tpl_dir . 'profile.tpl')); - } + if (!defined('MODULE_TITLE')) define('MODULE_TITLE', (string)$AVE_Template->get_config_vars('LOGIN_CHANGE_DETAILS')); + define('MODULE_CONTENT', $AVE_Template->fetch(self::$_tpl_dir . 'profile.tpl')); +} - /* - |----------------------------------------------------------------------------------------------------------------------- - | profile - |----------------------------------------------------------------------------------------------------------------------- - | - | Панель пользователя - | - */ - public static function info () - { - global $AVE_Template; +/* + |----------------------------------------------------------------------------------------------------------------------- + | info + |----------------------------------------------------------------------------------------------------------------------- + | + | + | + */ +public static function info () +{ + global $AVE_Template; - $user_id = $_SESSION['user_id']; + $user_id = (int)($_SESSION['user_id'] ?? 0); + + // Получаем запись пользователя. + $userinfo = get_user_rec_by_id($user_id); + + if (!$userinfo) return; - $userinfo = get_user_rec_by_id(intval($user_id)); - - if ($userinfo === null) { - return; - } + $u_avatar = getAvatar($user_id, 150); // Увеличил размер до 150 для четкости + $abs_path = (defined('ABS_PATH')) ? ABS_PATH : '/'; - $userinfo->avatar = getAvatar($user_id, 100); + // Если аватар пустой или содержит заглушку + if (empty($u_avatar) || strpos($u_avatar, 'user.png') !== false) { + $u_avatar = $abs_path . 'uploads/avatars/default.png'; + } - $AVE_Template->assign('user', $userinfo); + $userinfo->avatar = $u_avatar; - $AVE_Template->config_load(self::$_lang_file, 'userinfo'); + $AVE_Template->assign('user', $userinfo); + $AVE_Template->config_load(self::$_lang_file, 'userinfo'); - if (! defined('MODULE_CONTENT')) - { - define('MODULE_TITLE', $AVE_Template->get_config_vars('LOGIN_USER_PROFILE')); - define('MODULE_CONTENT', $AVE_Template->fetch(self::$_tpl_dir . 'info.tpl')); - } - } + if (! defined('MODULE_CONTENT')) + { + if (!defined('MODULE_TITLE')) + { + define('MODULE_TITLE', (string)$AVE_Template->get_config_vars('LOGIN_USER_PROFILE')); + } + define('MODULE_CONTENT', $AVE_Template->fetch(self::$_tpl_dir . 'info.tpl')); + } +} /* @@ -585,621 +636,603 @@ | Управление модулем Авторизации | */ - public static function admin () - { - global $AVE_DB, $AVE_Template; - - if (isset($_REQUEST['sub']) && $_REQUEST['sub'] == 'save') - { - $login_deny_domain = str_replace(array("\r\n", "\n"), - ',', - $_REQUEST['login_deny_domain'] - ); - - $login_deny_email = str_replace(array("\r\n", "\n"), - ',', - $_REQUEST['login_deny_email'] - ); - - $AVE_DB->Query(" - UPDATE " . PREFIX . "_module_login - SET - login_reg_type = '" . $_REQUEST['login_reg_type'] . "', - login_antispam = '" . $_REQUEST['login_antispam'] . "', - login_status = '" . $_REQUEST['login_status'] . "', - login_deny_domain = '" . $login_deny_domain . "', - login_deny_email = '" . $login_deny_email . "', - login_require_company = '" . $_REQUEST['login_require_company'] . "', - login_require_firstname = '" . $_REQUEST['login_require_firstname'] . "', - login_require_lastname = '" . $_REQUEST['login_require_lastname'] . "' - WHERE - Id = 1 - "); - - $AVE_DB->clearCache('modules/login'); - - header('Location:index.php?do=modules&action=modedit&mod=login&moduleaction=1&cp=' . SESSION); - exit; - } - - $row = self::settings(); - $row['login_deny_domain'] = str_replace(',', "\n", $row['login_deny_domain']); - $row['login_deny_email'] = str_replace(',', "\n", $row['login_deny_email']); - - $AVE_Template->assign($row); - $AVE_Template->assign('content', $AVE_Template->fetch(self::$_tpl_dir . 'config.tpl')); - } - - - /* - |----------------------------------------------------------------------------------------------------------------------- - | reminder - |----------------------------------------------------------------------------------------------------------------------- - | - | Восстановление пароля - | - */ - public static function reminder () - { - global $AVE_DB, $AVE_Template; - - if (isset($_SESSION['user_id'])) - { - header('Location:' . get_home_link()); - exit; - } - - $AVE_Template->config_load(self::$_lang_file, 'passwordreminder'); - - define('MODULE_TITLE', $AVE_Template->get_config_vars('LOGIN_REMIND')); - - if (isset($_REQUEST['sub']) && $_REQUEST['sub'] == 'confirm' && !empty($_REQUEST['email'])) - { - $row_remind = $AVE_DB->Query(" - SELECT - new_pass, - new_salt - FROM " . PREFIX . "_users - WHERE email = '" . $_REQUEST['email'] . "' - AND new_pass != '' - AND new_pass = '" . $_REQUEST['code'] . "' - LIMIT 1 - ")->FetchRow(); - - if ($row_remind) - { - $AVE_DB->Query(" - UPDATE " . PREFIX . "_users - SET - password = '" . addslashes($row_remind->new_pass) . "', - salt = '" . addslashes($row_remind->new_salt) . "' - WHERE email = '" . $_REQUEST['email'] . "' - AND new_pass = '" . $_REQUEST['code'] . "' - "); - } - - $tpl_out = $AVE_Template->fetch(self::$_tpl_dir . 'reminder_end.tpl'); - define('MODULE_CONTENT', $tpl_out); - } - else - { - if (isset($_REQUEST['sub']) && $_REQUEST['sub'] == 'send' && !empty($_POST['f_mailreminder'])) - { - $row_remind = $AVE_DB->Query(" - SELECT - email, - user_name, - firstname, - lastname - FROM " . PREFIX . "_users - WHERE email = '" . $_POST['f_mailreminder'] . "' - LIMIT 1 - ")->FetchRow(); - - if ($row_remind) - { - $SystemMail = get_settings('mail_from'); - $SystemMailName = get_settings('mail_from_name'); - - $chars = "abcdefghijklmnopqrstuvwxyz"; - $chars .= "ABCDEFGHIJKLMNOPRQSTUVWXYZ"; - $chars .= "0123456789"; - $newpass = make_random_string(8, $chars); - $newsalt = make_random_string(); - $md5_pass_salt = md5(md5($newpass . $newsalt)); - - $AVE_DB->Query(" - UPDATE " . PREFIX . "_users - SET - new_pass = '" . addslashes($md5_pass_salt) . "', - new_salt = '" . addslashes($newsalt) . "' - WHERE email = '" . $_POST['f_mailreminder'] . "' - LIMIT 1 - "); - - $body = $AVE_Template->get_config_vars('LOGIN_MESSAGE_6'); - $body = str_replace("%NAME%", - get_username($row_remind->user_name, - $row_remind->firstname, - $row_remind->lastname, 0), - $body); - $body = str_replace("%PASS%", $newpass, $body); - $body = str_replace("%HOST%", get_home_link(), $body); - $body = str_replace("%LINK%", - get_home_link() . "index.php" - . "?module=login" - . "&action=reminder" - . "&sub=confirm" - . "&code=" . $md5_pass_salt - . "&email=" . $_POST['f_mailreminder'], - $body); - $body = str_replace("%N%", "\n", $body); - send_mail( - stripslashes($_POST['f_mailreminder']), - $body, - $AVE_Template->get_config_vars('LOGIN_SUBJECT_REMINDER'), - $SystemMail, - $SystemMailName, - 'text' - ); - } - } - - define('MODULE_CONTENT', $AVE_Template->fetch(self::$_tpl_dir . 'reminder.tpl')); - } - } - - - /* - |----------------------------------------------------------------------------------------------------------------------- - | change - |----------------------------------------------------------------------------------------------------------------------- - | - | Изменение пароля - | - */ - public static function change () - { - global $AVE_DB, $AVE_Template; - - $AVE_Template->config_load(self::$_lang_file, 'passwordchange'); - - define('MODULE_TITLE', $AVE_Template->get_config_vars('LOGIN_PASSWORD_CHANGE')); - - if (! isset($_SESSION['user_id'])) - { - header('Location:' . get_home_link()); - exit; - } - - $salt = $AVE_DB->Query(" - SELECT - salt - FROM - " . PREFIX . "_users - WHERE - Id = '" . $_SESSION['user_id'] . "' - LIMIT 1 - ")->GetCell(); - - if ($salt !== false && isset($_REQUEST['sub']) && $_REQUEST['sub'] == 'send') - { - $error = array(); - - if ($_POST['old_pass'] == '') - $error[] = $AVE_Template->get_config_vars('LOGIN_EMPTY_OLD_PASS'); - elseif ($_SESSION['user_pass'] != md5(md5($_POST['old_pass'] . $salt))) - $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_OLD_PASS'); - elseif ($_POST['new_pass'] == '') - $error[] = $AVE_Template->get_config_vars('LOGIN_EMPTY_NEW_PASS'); - elseif (mb_strlen($_POST['new_pass']) < 5) - $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_SHORT_PASS'); - elseif ($_POST['new_pass_c'] == '') - $error[] = $AVE_Template->get_config_vars('LOGIN_EMPTY_NEW_PASS_C'); - elseif ($_POST['new_pass'] != $_POST['new_pass_c']) - $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_EQU_PASS'); - elseif (preg_match('/[^\x21-\xFF]/', $_POST['new_pass'])) - $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_SYM_PASS'); - - if (count($error) > 0) - { - $AVE_Template->assign('errors', $error); - } - else - { - $newsalt = make_random_string(); - $md5_pass_salt = md5(md5($_POST['new_pass'] . $newsalt)); - - $AVE_DB->Query(" - UPDATE - " . PREFIX . "_users - SET - password = '" . addslashes($md5_pass_salt) . "', - salt = '" . addslashes($newsalt) . "' - WHERE - Id = '" . (int)$_SESSION['user_id'] . "' - AND - email = '" . addslashes($_SESSION['user_email']) . "' - AND - password = '" . addslashes($_SESSION['user_pass']) . "' - "); - - $_SESSION['user_pass'] = $md5_pass_salt; - - $AVE_Template->assign('changeok', 1); - } - } - - define('MODULE_CONTENT', $AVE_Template->fetch(self::$_tpl_dir . 'change.tpl')); - } - - - /* - |----------------------------------------------------------------------------------------------------------------------- - | change - |----------------------------------------------------------------------------------------------------------------------- - | - | Удаление учетной записи пользователя - | - */ - public static function delete () - { - global $AVE_Template; - - $AVE_Template->config_load(self::$_lang_file, 'delaccount'); - - if (! isset($_SESSION['user_id']) || ! isset($_SESSION['user_pass'])) - { - header('Location:index.php'); - exit; - } - - if (isset($_REQUEST['confirm']) && $_REQUEST['confirm'] == 1 && UGROUP != 1) - { - user_delete($_SESSION['user_id']); - unset($_SESSION['user_id']); - unset($_SESSION['user_pass']); - $AVE_Template->assign('delok', 1); - } - - if (defined('UGROUP') && UGROUP == 1) - $AVE_Template->assign('admin', 1); - - $tpl_out = $AVE_Template->fetch(self::$_tpl_dir . 'delete.tpl'); - - define('MODULE_TITLE', $AVE_Template->get_config_vars('LOGIN_DELETE_ACCOUNT')); - define('MODULE_CONTENT', $tpl_out); - } - - - /* - |----------------------------------------------------------------------------------------------------------------------- - | register - |----------------------------------------------------------------------------------------------------------------------- - | - | Регистрация новой учетной записи пользователя - | - */ - public static function register () - { - global $AVE_DB, $AVE_Template; - - if (isset($_SESSION['user_id']) || isset($_SESSION['user_pass'])) - { - header('Location:' . get_referer_link()); - exit; - } - - if (empty($_SESSION['referer'])) - { - $referer = get_referer_link(); - $_SESSION['referer'] = (false === strstr($referer, 'module=login')) ? $referer : get_home_link(); - } - - $AVE_Template->config_load(self::$_lang_file, 'registernew'); - - define('MODULE_TITLE', $AVE_Template->get_config_vars('LOGIN_TEXT_REGISTER')); - - if (self::settings('login_antispam')) - define('ANTISPAM', 1); - - switch(self::settings('login_status')) - { - case '1': - switch ($_REQUEST['sub']) - { - case 'register': - $error = []; - - $_POST['user_name'] = (! empty($_POST['user_name'])) - ? trim($_POST['user_name']) - : ''; - - $_POST['reg_email'] = (! empty($_POST['reg_email'])) - ? trim($_POST['reg_email']) - : ''; - - $_POST['reg_email_return'] = (! empty($_POST['reg_email_return'])) - ? trim($_POST['reg_email_return']) - : ''; - - // user_name - $regex_username = '/[^\w-]/'; - - if (empty($_POST['user_name'])) - $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_L_EMPTY'); - elseif (preg_match($regex_username, $_POST['user_name'])) - $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_LOGIN'); - elseif (self::_nameexists($_POST['user_name'])) - $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_L_INUSE'); - - // reg_email - if (empty($_POST['reg_email'])) - $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_EM_EMPTY'); - elseif (! preg_match(self::$_regex_email, $_POST['reg_email'])) - $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_EMAIL'); - // elseif (empty($_POST['reg_email_return'])) - // { - // $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_ER_EMPTY'); - // } - // elseif ($_POST['reg_email'] != $_POST['reg_email_return']) - // { - // $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_RETRY'); - // } - else - { - if (self::_emailexist($_POST['reg_email'])) - $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_INUSE'); - if (! self::_domaincheck($_POST['reg_email'])) - $error[] = $AVE_Template->get_config_vars('LOGIN_DOMAIN_FALSE'); - if (! self::_blacklist($_POST['reg_email'])) - $error[] = $AVE_Template->get_config_vars('LOGIN_EMAIL_FALSE'); - } - - // reg_pass - if (empty($_POST['reg_pass'])) - $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_PASS'); - elseif (mb_strlen($_POST['reg_pass']) < 5) - $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_SHORT_PASS'); - elseif (preg_match(self::$_regex, $_POST['reg_pass'])) - $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_SYM_PASS'); - - // reg_firstname - if (self::_required('login_require_firstname') && empty($_POST['reg_firstname'])) - $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_FN_EMPTY'); - if (!empty($_POST['reg_firstname']) && preg_match(self::$_regex, $_POST['reg_firstname'])) - $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_FIRSTNAME'); - - // reg_lastname - if (self::_required('login_require_lastname') && empty($_POST['reg_lastname'])) - $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_LN_EMPTY'); - if (! empty($_POST['reg_lastname']) && preg_match(self::$_regex, $_POST['reg_lastname'])) - $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_LASTNAME'); - - if (defined("ANTISPAM")) - { - if (empty($_POST['reg_secure'])) - $error[] = $AVE_Template->get_config_vars('LOGIN_WROND_E_SCODE'); - elseif (! (isset($_SESSION['captcha_keystring']) && $_POST['reg_secure'] == $_SESSION['captcha_keystring'])) - $error[] = $AVE_Template->get_config_vars('LOGIN_WROND_SCODE'); - - unset($_SESSION['captcha_keystring']); - } - - if (count($error)) - { - $AVE_Template->assign('errors', $error); - - if (defined('ANTISPAM')) - $AVE_Template->assign('im', 1); - - self::_requiredfetch(); - - $AVE_Template->assign('available_countries', get_country_list(1)); - - define('MODULE_CONTENT', $AVE_Template->fetch(self::$_tpl_dir . 'register.tpl')); - } - else - { - $status = 0; - - $emailcode = md5(rand(100000,999999)); - - $log_reg_type = self::settings('login_reg_type'); - - switch ($log_reg_type) - { - case 'now': - $email_body = str_replace("%N%", "\n", $AVE_Template->get_config_vars('LOGIN_MESSAGE_1')); - $email_body = str_replace("%NAME%", $_POST['user_name'], $email_body); - $email_body = str_replace("%HOST%", get_home_link(), $email_body); - $email_body = str_replace("%PASSWORD%", $_POST['reg_pass'], $email_body); - $email_body = str_replace("%EMAIL%", $_POST['reg_email'], $email_body); - $status = 1; - $link = self::$_reg_now; - break; - - case 'email': - $email_body = str_replace("%N%", "\n", $AVE_Template->get_config_vars('LOGIN_MESSAGE_2') - . $AVE_Template->get_config_vars('LOGIN_MESSAGE_3')); - $email_body = str_replace("%NAME%", $_POST['user_name'], $email_body); - $email_body = str_replace("%PASSWORD%", $_POST['reg_pass'], $email_body); - $email_body = str_replace("%EMAIL%", $_POST['reg_email'], $email_body); - $email_body = str_replace("%REGLINK%", - get_home_link() . "index.php" - . "?module=login" - . "&action=register" - . "&sub=final" - . "&emc=" . $emailcode, - $email_body); - $email_body = str_replace("%HOST%", get_home_link(), $email_body); - $email_body = str_replace("%CODE%", $emailcode, $email_body); - $link = self::$_reg_email; - break; - - case 'byadmin': - $email_body = str_replace("%N%", "\n", $AVE_Template->get_config_vars('LOGIN_MESSAGE_2') - . $AVE_Template->get_config_vars('LOGIN_MESSAGE_4')); - $email_body = str_replace("%NAME%", $_POST['user_name'], $email_body); - $email_body = str_replace("%PASSWORD%", $_POST['reg_pass'], $email_body); - $email_body = str_replace("%EMAIL%", $_POST['reg_email'], $email_body); - $email_body = str_replace("%HOST%", get_home_link(), $email_body); - $link = self::$_reg_admin; - break; - } - - $bodytoadmin = str_replace("%N%", "\n", $AVE_Template->get_config_vars('LOGIN_MESSAGE_5')); - $bodytoadmin = str_replace("%NAME%", $_POST['user_name'], $bodytoadmin); - $bodytoadmin = str_replace("%EMAIL%", $_POST['reg_email'], $bodytoadmin); - - $salt = make_random_string(); - - $md5_pass_salt = md5(md5($_POST['reg_pass'] . $salt)); - - $q = " - INSERT INTO - " . PREFIX . "_users - SET - Id = '', - user_name = '" . $_POST['user_name'] . "', - password = '" . addslashes($md5_pass_salt) . "', - firstname = '" . $_POST['reg_firstname'] . "', - lastname = '" . $_POST['reg_lastname'] . "', - user_group = '" . self::$_newuser_group . "', - reg_time = '" . time() . "', - status = '" . $status . "', - email = '" . $_POST['reg_email'] . "', - emc = '" . addslashes($emailcode) . "', - country = '" . strtoupper($_POST['country']) . "', - reg_ip = '" . addslashes($_SERVER['REMOTE_ADDR']) . "', - taxpay = '1', - company = '" . @$_POST['company'] . "', - salt = '" . addslashes($salt) . "' - "; - - $AVE_DB->Query($q); - - if ($status == 1) - { - $_SESSION['user_id'] = $AVE_DB->InsertId(); - - $_SESSION['user_name'] = get_username( - stripslashes($_POST['user_name']), - stripslashes($_POST['reg_firstname']), - stripslashes($_POST['reg_lastname']) - ); - - $_SESSION['user_email'] = $_POST['reg_email']; - $_SESSION['user_pass'] = $md5_pass_salt; - $_SESSION['user_group'] = self::$_newuser_group; - $_SESSION['user_country'] = strtoupper($_POST['country']); - $_SESSION['user_ip'] = addslashes($_SERVER['REMOTE_ADDR']); - - $user_group_permissions = $AVE_DB->Query("SELECT user_group_permission FROM ".PREFIX."_user_groups WHERE user_group=". self::$_newuser_group)->GetCell(); - $user_group_permissions = explode('|', preg_replace('/\s+/', '', $user_group_permissions)); - - foreach ($user_group_permissions as $user_group_permission) - $_SESSION[$user_group_permission] = 1; - } - - $SystemMail = get_settings('mail_from'); - $SystemMailName = get_settings('mail_from_name'); - - send_mail( - $SystemMail, - $bodytoadmin, - $AVE_Template->get_config_vars('LOGIN_SUBJECT_ADMIN'), - $SystemMail, - $SystemMailName, - 'text' - ); - - if ($_SESSION['loginza_auth'] != 1) - send_mail( - $_POST['reg_email'], - $email_body, - $AVE_Template->get_config_vars('LOGIN_SUBJECT_USER'), - $SystemMail, - $SystemMailName, - 'text' - ); - - header('Location:' . $link); - exit; - } - break; - - case 'thanks': - $AVE_Template->config_load(self::$_lang_file); - - define('MODULE_CONTENT', $AVE_Template->fetch(self::$_tpl_dir . 'register_thankyou.tpl')); - break; - - case 'final': - if (isset($_REQUEST['emc']) && $_REQUEST['emc'] != '') - { - $row = $AVE_DB->Query(" - SELECT * - FROM " . PREFIX . "_users - WHERE emc = '" . $_REQUEST['emc'] . "' - ")->FetchRow(); - - if ($row) - { - // $AVE_Template->assign('reg_type', $reg_type); - $AVE_Template->assign('final', 'ok'); - - $AVE_DB->Query(" - UPDATE " . PREFIX . "_users - SET status = '1' - WHERE emc = '" . $_REQUEST['emc'] . "' - "); - - $_SESSION['user_id'] = $AVE_DB->InsertId(); - $_SESSION['user_name'] = get_username( - stripslashes($_POST['user_name']), - stripslashes($_POST['reg_firstname']), - stripslashes($_POST['reg_lastname']) - ); - $_SESSION['user_email'] = $_POST['reg_email']; - $_SESSION['user_pass'] = $md5_pass_salt; - $_SESSION['user_group'] = self::$_newuser_group; - $_SESSION['user_country'] = strtoupper($_POST['country']); - $_SESSION['user_ip'] = addslashes($_SERVER['REMOTE_ADDR']); - $user_group_permissions=$AVE_DB->Query("SELECT user_group_permission FROM ".PREFIX."_user_groups WHERE user_group=".self::$_newuser_group)->GetCell(); - $user_group_permissions = explode('|', preg_replace('/\s+/', '', $user_group_permissions)); - foreach ($user_group_permissions as $user_group_permission) $_SESSION[$user_group_permission] = 1; - } - } - - define('MODULE_CONTENT', $AVE_Template->fetch(self::$_tpl_dir . 'register_final.tpl')); - break; - - case 'admin': - $AVE_Template->config_load(self::$_lang_file); - - define('MODULE_CONTENT', $AVE_Template->fetch(self::$_tpl_dir . 'register_admin.tpl')); - break; - - case '': - default : - if (defined('ANTISPAM')) - $AVE_Template->assign('im', 1); - - self::_requiredfetch(); - - $AVE_Template->assign('available_countries', get_country_list(1)); - - define('MODULE_CONTENT', $AVE_Template->fetch(self::$_tpl_dir . 'register.tpl')); - break; - } - break; - - case '0': - define('MODULE_CONTENT', $AVE_Template->get_config_vars('LOGIN_NOT_ACTIVE')); - break; - } - } +public static function admin () +{ + global $AVE_DB, $AVE_Template; + + if (isset($_REQUEST['sub']) && $_REQUEST['sub'] == 'save') + { + // PHP 8.4: гарантируем, что входящие списки — это строки + $login_deny_domain = str_replace(array("\r\n", "\n"), ',', (string)($_REQUEST['login_deny_domain'] ?? '')); + $login_deny_email = str_replace(array("\r\n", "\n"), ',', (string)($_REQUEST['login_deny_email'] ?? '')); + + $AVE_DB->Query(" + UPDATE " . PREFIX . "_module_login + SET + login_reg_type = '" . addslashes((string)($_REQUEST['login_reg_type'] ?? '')) . "', + login_antispam = '" . addslashes((string)($_REQUEST['login_antispam'] ?? '0')) . "', + login_status = '" . addslashes((string)($_REQUEST['login_status'] ?? '0')) . "', + login_deny_domain = '" . addslashes($login_deny_domain) . "', + login_deny_email = '" . addslashes($login_deny_email) . "', + login_require_company = '" . addslashes((string)($_REQUEST['login_require_company'] ?? '0')) . "', + login_require_firstname = '" . addslashes((string)($_REQUEST['login_require_firstname'] ?? '0')) . "', + login_require_lastname = '" . addslashes((string)($_REQUEST['login_require_lastname'] ?? '0')) . "', + login_require_country = '" . addslashes((string)($_REQUEST['login_require_country'] ?? '0')) . "' + WHERE Id = 1 + "); + + $AVE_DB->clearCache('modules/login'); + + // Используем встроенную функцию ядра для проверки Ajax запроса + if (isAjax()) { + exit("success"); + } + + header('Location:index.php?do=modules&action=modedit&mod=login&moduleaction=1&cp=' . SESSION); + exit; + } + + $row = self::settings(); + // Обратное преобразование запятых в переносы строк для текстового поля + $row['login_deny_domain'] = str_replace(',', "\n", (string)($row['login_deny_domain'] ?? '')); + $row['login_deny_email'] = str_replace(',', "\n", (string)($row['login_deny_email'] ?? '')); + + $AVE_Template->assign($row); + $AVE_Template->assign('content', $AVE_Template->fetch(self::$_tpl_dir . 'config.tpl')); +} + + +/* + |----------------------------------------------------------------------------------------------------------------------- + | reminder + |----------------------------------------------------------------------------------------------------------------------- + | + | + | + */ + public static function reminder () + { + global $AVE_DB, $AVE_Template; + + // Если пользователь уже вошел, восстановление ему не нужно + if (isset($_SESSION['user_id'])) + { + header('Location:' . get_home_link()); + exit; + } + + $AVE_Template->config_load(self::$_lang_file, 'passwordreminder'); + if (!defined('MODULE_TITLE')) + { + define('MODULE_TITLE', (string)$AVE_Template->get_config_vars('LOGIN_REMIND')); + } + + // ФАЗА 2: Подтверждение сброса (переход по ссылке из письма) + if (isset($_REQUEST['sub']) && $_REQUEST['sub'] == 'confirm' && !empty($_REQUEST['email'])) + { + // Ищем пользователя, у которого совпадает email и временный код (new_pass) + $row_remind = $AVE_DB->Query(" + SELECT new_pass, new_salt + FROM " . PREFIX . "_users + WHERE email = '" . addslashes((string)$_REQUEST['email']) . "' + AND new_pass != '' + AND new_pass = '" . addslashes((string)($_REQUEST['code'] ?? '')) . "' + LIMIT 1 + ")->FetchRow(); + + if ($row_remind) + { + // Переносим временный пароль в основной и очищаем временные поля + $AVE_DB->Query(" + UPDATE " . PREFIX . "_users + SET + password = '" . addslashes((string)$row_remind->new_pass) . "', + salt = '" . addslashes((string)$row_remind->new_salt) . "', + new_pass = '', + new_salt = '' + WHERE email = '" . addslashes((string)$_REQUEST['email']) . "' + "); + $AVE_Template->assign('remind_ok', 1); + } + else + { + $AVE_Template->assign('remind_error', 1); + } + + define('MODULE_CONTENT', $AVE_Template->fetch(self::$_tpl_dir . 'reminder_end.tpl')); + } + // ФАЗА 1: Запрос на восстановление (ввод email в форму) + else + { + if (isset($_REQUEST['sub']) && $_REQUEST['sub'] == 'send' && !empty($_POST['f_mailreminder'])) + { + $email_input = (string)$_POST['f_mailreminder']; + + $row_remind = $AVE_DB->Query(" + SELECT email, user_name, firstname, lastname + FROM " . PREFIX . "_users + WHERE email = '" . addslashes($email_input) . "' + LIMIT 1 + ")->FetchRow(); + + if ($row_remind) + { + // Генерируем новый случайный пароль и соль + $newpass_plain = make_random_string(8, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPRQSTUVWXYZ0123456789"); + $newsalt = make_random_string(); + $md5_pass_salt = md5(md5($newpass_plain . $newsalt)); + + // Записываем временные данные в поля new_pass и new_salt + $AVE_DB->Query(" + UPDATE " . PREFIX . "_users + SET + new_pass = '" . addslashes($md5_pass_salt) . "', + new_salt = '" . addslashes($newsalt) . "' + WHERE email = '" . addslashes($email_input) . "' + "); + +// Формируем письмо +$link = get_home_link() . "index.php?module=login&action=reminder&sub=confirm&email=" . urlencode($email_input) . "&code=" . $md5_pass_salt; + +// Получаем текст шаблона из конфига +$body = (string)$AVE_Template->get_config_vars('LOGIN_MESSAGE_6'); + +// Заменяем переменные +$body = str_replace("%NAME%", (string)$row_remind->user_name, $body); +$body = str_replace("%HOST%", $_SERVER['HTTP_HOST'], $body); +$body = str_replace("%PASS%", $newpass_plain, $body); +$body = str_replace("%LINK%", $link, $body); +$body = str_replace("%N%", "\n", $body); + +send_mail( + $row_remind->email, + $body, + (string)$AVE_Template->get_config_vars('LOGIN_SUBJECT_REMINDER'), + get_settings('mail_from'), + get_settings('mail_from_name'), + 'text' +); + + $AVE_Template->assign('send_success', 1); + } + else + { + $AVE_Template->assign('send_error', 1); + } + } + define('MODULE_CONTENT', $AVE_Template->fetch(self::$_tpl_dir . 'reminder.tpl')); + } + } + + +/* + |----------------------------------------------------------------------------------------------------------------------- + | change + |----------------------------------------------------------------------------------------------------------------------- + | + | + | + */ + public static function change () + { + global $AVE_DB, $AVE_Template; + + $AVE_Template->config_load(self::$_lang_file, 'passwordchange'); + if (!defined('MODULE_TITLE')) + { + define('MODULE_TITLE', (string)$AVE_Template->get_config_vars('LOGIN_PASSWORD_CHANGE')); + } + + // Если пользователь не авторизован, ему здесь делать нечего + if (! isset($_SESSION['user_id'])) + { + header('Location:' . get_home_link()); + exit; + } + + // Получаем соль текущего пользователя для проверки старого пароля + $salt = $AVE_DB->Query(" + SELECT salt + FROM " . PREFIX . "_users + WHERE Id = '" . (int)$_SESSION['user_id'] . "' + LIMIT 1 + ")->GetCell(); + + // Обработка формы смены пароля + if ($salt !== false && isset($_REQUEST['sub']) && $_REQUEST['sub'] == 'send') + { + $error = array(); + + // PHP 8.4: Безопасное получение данных из POST + $old_pass = (string)($_POST['old_pass'] ?? ''); + $new_pass = (string)($_POST['new_pass'] ?? ''); + + // Проверка старого пароля + if ($old_pass === '') + { + $error[] = $AVE_Template->get_config_vars('LOGIN_EMPTY_OLD_PASS'); + } + // Сверяем MD5-хеш старого пароля с тем, что хранится в сессии + elseif ($_SESSION['user_pass'] != md5(md5($old_pass . $salt))) + { + $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_OLD_PASS'); + } + + // Проверка нового пароля + if ($new_pass === '') + { + $error[] = $AVE_Template->get_config_vars('LOGIN_EMPTY_NEW_PASS'); + } + + if (count($error) == 0) + { + // Генерируем новую соль и новый хеш для безопасности + $newsalt = make_random_string(); + $md5_pass_salt = md5(md5($new_pass . $newsalt)); + + // Обновляем данные в БД + $AVE_DB->Query(" + UPDATE " . PREFIX . "_users + SET + password = '" . addslashes($md5_pass_salt) . "', + salt = '" . addslashes($newsalt) . "' + WHERE Id = '" . (int)$_SESSION['user_id'] . "' + "); + + // Обновляем пароль в текущей сессии, чтобы пользователя не "выкинуло" + $_SESSION['user_pass'] = $md5_pass_salt; + + $AVE_Template->assign('changeok', 1); + } + else + { + $AVE_Template->assign('errors', $error); + } + } + + define('MODULE_CONTENT', $AVE_Template->fetch(self::$_tpl_dir . 'change.tpl')); + } + + +/* + |----------------------------------------------------------------------------------------------------------------------- + | delete + |----------------------------------------------------------------------------------------------------------------------- + | + | + | + */ + public static function delete () + { + global $AVE_Template; + + $AVE_Template->config_load(self::$_lang_file, 'delaccount'); + + // Если пользователь не авторизован — на выход + if (! isset($_SESSION['user_id'])) + { + header('Location: index.php?id=1'); + exit; + } + + // Проверяем подтверждение удаления (обычно это чекбокс в форме) + // и следим, чтобы это не был Главный администратор (UGROUP != 1) + if (isset($_REQUEST['confirm']) && $_REQUEST['confirm'] == 1 && UGROUP != 1) + { + // Вызываем функцию ядра для удаления + user_delete((int)$_SESSION['user_id']); + + // Очищаем сессию, так как пользователя больше не существует + unset($_SESSION['user_id'], $_SESSION['user_pass']); + + $AVE_Template->assign('delok', 1); + } + // Если попытка удалить админа + elseif (isset($_REQUEST['confirm']) && UGROUP == 1) + { + $AVE_Template->assign('is_admin', 1); + } + + if (!defined('MODULE_TITLE')) + { + define('MODULE_TITLE', (string)$AVE_Template->get_config_vars('LOGIN_DELETE_ACCOUNT')); + } + define('MODULE_CONTENT', $AVE_Template->fetch(self::$_tpl_dir . 'delete.tpl')); + } + + +/* + |----------------------------------------------------------------------------------------------------------------------- + | register + |----------------------------------------------------------------------------------------------------------------------- + | + | Регистрация новой учетной записи пользователя + | + */ + public static function register () + { + global $AVE_DB, $AVE_Template; + + if (isset($_SESSION['user_id']) || isset($_SESSION['user_pass'])) + { + header('Location:' . get_referer_link()); + exit; + } + + if (empty($_SESSION['referer'])) + { + $referer = get_referer_link(); + $_SESSION['referer'] = (false === strstr((string)$referer, 'module=login')) ? $referer : get_home_link(); + } + + $AVE_Template->config_load(self::$_lang_file, 'registernew'); + + if (!defined('MODULE_TITLE')) + { + define('MODULE_TITLE', (string)$AVE_Template->get_config_vars('LOGIN_TEXT_REGISTER')); + } + + if (self::settings('login_antispam')) + define('ANTISPAM', 1); + + switch(self::settings('login_status')) + { + case '1': + $sub = (string)($_REQUEST['sub'] ?? ''); + switch ($sub) + { + case 'register': + $error = []; + + $_POST['user_name'] = (! empty($_POST['user_name'])) + ? trim((string)$_POST['user_name']) + : ''; + + $_POST['reg_email'] = (! empty($_POST['reg_email'])) + ? trim((string)$_POST['reg_email']) + : ''; + + $_POST['reg_email_return'] = (! empty($_POST['reg_email_return'])) + ? trim((string)$_POST['reg_email_return']) + : ''; + + // user_name + $regex_username = '/[^\w-]/'; + + if (empty($_POST['user_name'])) + $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_L_EMPTY'); + elseif (preg_match($regex_username, (string)$_POST['user_name'])) + $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_LOGIN'); + elseif (self::_nameexists($_POST['user_name'])) + $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_L_INUSE'); + + // reg_email + if (empty($_POST['reg_email'])) + $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_EM_EMPTY'); + elseif (! preg_match(self::$_regex_email, (string)$_POST['reg_email'])) + $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_EMAIL'); + else + { + if (self::_emailexist($_POST['reg_email'])) + $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_INUSE'); + if (! self::_domaincheck($_POST['reg_email'])) + $error[] = $AVE_Template->get_config_vars('LOGIN_DOMAIN_FALSE'); + if (! self::_blacklist($_POST['reg_email'])) + $error[] = $AVE_Template->get_config_vars('LOGIN_EMAIL_FALSE'); + } + + // reg_pass + if (empty($_POST['reg_pass'])) + $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_PASS'); + elseif (mb_strlen((string)$_POST['reg_pass']) < 5) + $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_SHORT_PASS'); + elseif (preg_match(self::$_regex, (string)$_POST['reg_pass'])) + $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_SYM_PASS'); + + // reg_firstname + if (self::_required('login_require_firstname') && empty($_POST['reg_firstname'])) + $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_FN_EMPTY'); + if (!empty($_POST['reg_firstname']) && preg_match(self::$_regex, (string)$_POST['reg_firstname'])) + $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_FIRSTNAME'); + + // reg_lastname + if (self::_required('login_require_lastname') && empty($_POST['reg_lastname'])) + $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_LN_EMPTY'); + if (! empty($_POST['reg_lastname']) && preg_match(self::$_regex, (string)$_POST['reg_lastname'])) + $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_LASTNAME'); + // Проверка страны (если включено в админке и не выбрано) + if (self::_required('login_require_country') && empty($_POST['country'])) { + $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_COUNTRY_EMPTY'); + } + + if (defined("ANTISPAM")) + { + $reg_secure = (string)($_POST['reg_secure'] ?? ''); + if (empty($reg_secure)) + $error[] = $AVE_Template->get_config_vars('LOGIN_WROND_E_SCODE'); + elseif (! (isset($_SESSION['captcha_keystring']) && $reg_secure == $_SESSION['captcha_keystring'])) + $error[] = $AVE_Template->get_config_vars('LOGIN_WROND_SCODE'); + + unset($_SESSION['captcha_keystring']); + } + + if (count($error)) + { + $AVE_Template->assign('errors', $error); + + if (defined('ANTISPAM')) + $AVE_Template->assign('im', 1); + + self::_requiredfetch(); + + $AVE_Template->assign('available_countries', get_country_list(1)); + + define('MODULE_CONTENT', $AVE_Template->fetch(self::$_tpl_dir . 'register.tpl')); + } + else + { + $status = 0; + $emailcode = md5((string)rand(100000,999999)); + $log_reg_type = self::settings('login_reg_type'); + + switch ($log_reg_type) + { + case 'now': + $email_body = str_replace("%N%", "\n", (string)$AVE_Template->get_config_vars('LOGIN_MESSAGE_1')); + $email_body = str_replace("%NAME%", (string)$_POST['user_name'], $email_body); + $email_body = str_replace("%HOST%", get_home_link(), $email_body); + $email_body = str_replace("%PASSWORD%", (string)$_POST['reg_pass'], $email_body); + $email_body = str_replace("%EMAIL%", (string)$_POST['reg_email'], $email_body); + $status = 1; + $link = self::$_reg_now; + break; + + case 'email': + $email_body = str_replace("%N%", "\n", (string)$AVE_Template->get_config_vars('LOGIN_MESSAGE_2') + . $AVE_Template->get_config_vars('LOGIN_MESSAGE_3')); + $email_body = str_replace("%NAME%", (string)$_POST['user_name'], $email_body); + $email_body = str_replace("%PASSWORD%", (string)$_POST['reg_pass'], $email_body); + $email_body = str_replace("%EMAIL%", (string)$_POST['reg_email'], $email_body); + $email_body = str_replace("%REGLINK%", + get_home_link() . "index.php" + . "?module=login" + . "&action=register" + . "&sub=final" + . "&emc=" . $emailcode, + $email_body); + $email_body = str_replace("%HOST%", get_home_link(), $email_body); + $email_body = str_replace("%CODE%", $emailcode, $email_body); + $link = self::$_reg_email; + break; + + case 'byadmin': + $email_body = str_replace("%N%", "\n", (string)$AVE_Template->get_config_vars('LOGIN_MESSAGE_2') + . $AVE_Template->get_config_vars('LOGIN_MESSAGE_4')); + $email_body = str_replace("%NAME%", (string)$_POST['user_name'], $email_body); + $email_body = str_replace("%PASSWORD%", (string)$_POST['reg_pass'], $email_body); + $email_body = str_replace("%EMAIL%", (string)$_POST['reg_email'], $email_body); + $email_body = str_replace("%HOST%", get_home_link(), $email_body); + $link = self::$_reg_admin; + break; + } + + $bodytoadmin = str_replace("%N%", "\n", (string)$AVE_Template->get_config_vars('LOGIN_MESSAGE_5')); + $bodytoadmin = str_replace("%NAME%", (string)$_POST['user_name'], $bodytoadmin); + $bodytoadmin = str_replace("%EMAIL%", (string)$_POST['reg_email'], $bodytoadmin); + + $salt = make_random_string(); + $md5_pass_salt = md5(md5((string)$_POST['reg_pass'] . $salt)); + + $q = " + INSERT INTO + " . PREFIX . "_users + SET + Id = '', + user_name = '" . addslashes((string)$_POST['user_name']) . "', + password = '" . addslashes($md5_pass_salt) . "', + firstname = '" . addslashes((string)$_POST['reg_firstname']) . "', + lastname = '" . addslashes((string)$_POST['reg_lastname']) . "', + user_group = '" . (int)self::$_newuser_group . "', + reg_time = '" . time() . "', + status = '" . $status . "', + email = '" . addslashes((string)$_POST['reg_email']) . "', + emc = '" . addslashes($emailcode) . "', + country = '" . addslashes(strtoupper((string)($_POST['country'] ?? ''))) . "', + reg_ip = '" . addslashes((string)$_SERVER['REMOTE_ADDR']) . "', + taxpay = '1', + company = '" . addslashes((string)($_POST['company'] ?? '')) . "', + salt = '" . addslashes($salt) . "' + "; + + $AVE_DB->Query($q); + + if ($status == 1) + { + $_SESSION['user_id'] = $AVE_DB->InsertId(); + $_SESSION['user_name'] = get_username( + stripslashes((string)$_POST['user_name']), + stripslashes((string)$_POST['reg_firstname']), + stripslashes((string)$_POST['reg_lastname']) + ); + $_SESSION['user_email'] = $_POST['reg_email']; + $_SESSION['user_pass'] = $md5_pass_salt; + $_SESSION['user_group'] = self::$_newuser_group; + $_SESSION['user_country'] = strtoupper((string)($_POST['country'] ?? '')); + $_SESSION['user_ip'] = addslashes((string)$_SERVER['REMOTE_ADDR']); + + $user_group_permissions = $AVE_DB->Query("SELECT user_group_permission FROM ".PREFIX."_user_groups WHERE user_group=". (int)self::$_newuser_group)->GetCell(); + $user_group_permissions = explode('|', preg_replace('/\s+/', '', (string)$user_group_permissions)); + + foreach ($user_group_permissions as $user_group_permission) + if ($user_group_permission !== '') $_SESSION[$user_group_permission] = 1; + } + + $SystemMail = get_settings('mail_from'); + $SystemMailName = get_settings('mail_from_name'); + + send_mail($SystemMail, $bodytoadmin, (string)$AVE_Template->get_config_vars('LOGIN_SUBJECT_ADMIN'), $SystemMail, $SystemMailName, 'text'); + + if (($_SESSION['loginza_auth'] ?? 0) != 1) + send_mail($_POST['reg_email'], $email_body, (string)$AVE_Template->get_config_vars('LOGIN_SUBJECT_USER'), $SystemMail, $SystemMailName, 'text'); + + header('Location:' . $link); + exit; + } + break; + + case 'thanks': + $AVE_Template->config_load(self::$_lang_file); + define('MODULE_CONTENT', $AVE_Template->fetch(self::$_tpl_dir . 'register_thankyou.tpl')); + break; + + case 'final': + if (isset($_REQUEST['emc']) && $_REQUEST['emc'] != '') + { + $row = $AVE_DB->Query("SELECT * FROM " . PREFIX . "_users WHERE emc = '" . addslashes((string)$_REQUEST['emc']) . "'")->FetchRow(); + if ($row) + { + $AVE_Template->assign('final', 'ok'); + $AVE_DB->Query("UPDATE " . PREFIX . "_users SET status = '1' WHERE emc = '" . addslashes((string)$_REQUEST['emc']) . "'"); + + // Авто-логин после активации + $_SESSION['user_id'] = $row->Id; + $_SESSION['user_name'] = get_username($row->user_name, $row->firstname, $row->lastname); + $_SESSION['user_email'] = $row->email; + $_SESSION['user_pass'] = $row->password; + $_SESSION['user_group'] = $row->user_group; + $_SESSION['user_country'] = $row->country; + $_SESSION['user_ip'] = addslashes((string)$_SERVER['REMOTE_ADDR']); + + $user_group_permissions = $AVE_DB->Query("SELECT user_group_permission FROM ".PREFIX."_user_groups WHERE user_group=". (int)$row->user_group)->GetCell(); + $user_group_permissions = explode('|', preg_replace('/\s+/', '', (string)$user_group_permissions)); + foreach ($user_group_permissions as $user_group_permission) + if ($user_group_permission !== '') $_SESSION[$user_group_permission] = 1; + } + } + define('MODULE_CONTENT', $AVE_Template->fetch(self::$_tpl_dir . 'register_final.tpl')); + break; + + case 'admin': + $AVE_Template->config_load(self::$_lang_file); + define('MODULE_CONTENT', $AVE_Template->fetch(self::$_tpl_dir . 'register_admin.tpl')); + break; + + case '': + default : + if (defined('ANTISPAM')) + $AVE_Template->assign('im', 1); + self::_requiredfetch(); + $AVE_Template->assign('available_countries', get_country_list(1)); + define('MODULE_CONTENT', $AVE_Template->fetch(self::$_tpl_dir . 'register.tpl')); + break; + } + break; + + case '0': + define('MODULE_CONTENT', (string)$AVE_Template->get_config_vars('LOGIN_NOT_ACTIVE')); + break; + } + } /* @@ -1210,26 +1243,26 @@ | | */ - public static function checkusername () - { - global $AVE_DB, $AVE_Template; + public static function checkusername () + { + global $AVE_DB, $AVE_Template; + $AVE_Template->config_load(self::$_lang_file, 'registernew'); - $errors = []; + $user_name = trim((string)($_POST['user_name'] ?? '')); + $errors = []; - $AVE_Template->config_load(self::$_lang_file, 'registernew'); + if (empty($user_name)) + { + $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_L_EMPTY'); + } + elseif (self::_nameexists($user_name)) + { + $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_L_INUSE'); + } - $user_name = $AVE_DB->EscStr($_POST['user_name']); - - if (empty($user_name)) - $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_L_EMPTY'); - elseif (! ctype_alnum($user_name)) - $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_LOGIN'); - elseif (self::_emailexist($user_name)) - $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_L_INUSE'); - - if (! empty($errors)) - self::_json($errors, true); - } + // Если есть ошибки, отдаем их в JSON и прекращаем работу + if (! empty($errors)) self::_json($errors, true); + } /* @@ -1240,30 +1273,24 @@ | | */ - public static function checkemail () - { - global $AVE_DB, $AVE_Template; + public static function checkemail () + { + global $AVE_DB, $AVE_Template; + $AVE_Template->config_load(self::$_lang_file, 'registernew'); - $errors = array(); + $email = trim((string)($_POST['email'] ?? '')); + $errors = []; - $AVE_Template->config_load(self::$_lang_file, 'registernew'); + if (empty($email)) + { + $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_EM_EMPTY'); + } + elseif (self::_emailexist($email)) + { + $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_INUSE'); + } - $email = $AVE_DB->EscStr($_POST['email']); - - if (empty($email)) - $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_EM_EMPTY'); - elseif (! preg_match(self::$_regex_email, $email)) - $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_EMAIL'); - else - if (self::_emailexist($email)) - $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_INUSE'); - if (! self::_domaincheck($email)) - $errors[] = $AVE_Template->get_config_vars('LOGIN_DOMAIN_FALSE'); - if (!self::_blacklist($email)) - $errors[] = $AVE_Template->get_config_vars('LOGIN_EMAIL_FALSE'); - - if (! empty($errors)) - self::_json($errors, true); - } + if (! empty($errors)) self::_json($errors, true); + } } ?> \ No newline at end of file diff --git a/img/ajax-loader.gif b/img/ajax-loader.gif new file mode 100644 index 0000000..3288d10 Binary files /dev/null and b/img/ajax-loader.gif differ diff --git a/info.php b/info.php index 2f6c1df..76c35ff 100644 --- a/info.php +++ b/info.php @@ -4,7 +4,7 @@ $module = array( 'ModuleSysName' => 'login', - 'ModuleVersion' => '2.26.1', + 'ModuleVersion' => '3.31.1', 'ModuleAutor' => 'AVE.cms Team', 'ModuleCopyright' => '© 2007-' . date('Y') . ' AVE.cms', 'ModuleStatus' => 1, diff --git a/lang/ru.txt b/lang/ru.txt index 38cd130..988b991 100644 --- a/lang/ru.txt +++ b/lang/ru.txt @@ -18,7 +18,7 @@ LOGIN_AUTORIZATION = "Авторизация" [displaypanel] LOGIN_ADMIN_LINK = "Панель управления" -LOGIN_CHANGE_DETAILS = "Настройки профиля" +LOGIN_CHANGE_DETAILS = "Редактировать профиль" LOGIN_CHANGE_LINK = "Сменить пароль" LOGIN_DELETE_LINK = "Удалить аккаунт" LOGIN_LOGOUT_LINK = "Выйти" @@ -41,6 +41,10 @@ LOGIN_YOUR_PHONE = "Контактный телефон:" LOGIN_YOUR_STREET = "Улица " LOGIN_YOUR_TOWN = "Город:" LOGIN_YOUR_ZIP = "Почтовый индекс" +LOGIN_CHANGE_DETAILS = "Редактировать профиль" +LOGIN_CHANGE_SAVE = "Изменения сохранены!" +LOGIN_CHANGE_UPD = "Ваш профиль был успешно обновлен." +LOGIN_CHANGE_CLOSE = "Закрыть" [loginprocess] LOGIN_BUTTON_ENTER = "Войти" @@ -76,6 +80,12 @@ LOGIN_MESSAGE_TEXT = "Процесс регистрации почти з LOGIN_NOT_ACTIVE = "В настоящий момент регистрация пользователей временно отключена." LOGIN_PASSWORD = "Пароль:" LOGIN_REGISTER_OK = "Регистрация успешно завершена" +LOGIN_REGISTER_OK_SP = "Если письмо не пришло в течение 5 минут, проверьте папку Спам." +LOGIN_REGISTER_OK_SP_M = "На главную" +LOGIN_REGISTER_OK_SP_L = "Вы будете перенаправлены на предыдущую страницу через несколько секунд..." +LOGIN_REGISTER_OK_SP_N = "Не получили письмо? Проверьте папку «Спам» или" +LOGIN_REGISTER_OK_SP_O = "обновите страницу" + LOGIN_SECURITY_CODE = "Защитный код:" LOGIN_SECURITY_CODER = "Введите код:" LOGIN_SUBJECT_ADMIN = "Регистрация нового пользователя" @@ -107,18 +117,23 @@ LOGIN_YOUR_LOGIN = "Логин:" LOGIN_YOUR_MAIL = "E-mail:" LOGIN_TEXT_AUTHORIZATION = "Информация для авторизации" LOGIN_TEXT_USER_INFO = "Персональная информация" +LOGIN_WRONG_FIELD_LOGIN = "Только латинские буквы (A-Z), цифры, символы подчеркивания (_) или дефис (-)." +LOGIN_CAPTCHA_UPD = "Кликните на картинку, если код неразборчив" +LOGIN_WRONG_COUNTRY_EMPTY = "Пожалуйста, выберите страну." [passwordreminder] LOGIN_BUTTON_NEWPASS = "Выслать пароль" LOGIN_YOUR_MAIL = "E-mail:" LOGIN_ENTER_EMAIL = "Пожалуйста, укажите Ваш E-mail." -LOGIN_MESSAGE_6 = "Здравствуйте %NAME%.%N%Вы запросили изменения Вашего пароля на сайте %HOST%.%N%%N%Ваш новый пароль: %PASS%%N%%N%Пожалуйста, перейдите по ссылке указанной ниже, чтобы подтвердить смену пароля:%N%%LINK%%N%%N%Если Вы не запрашивали изменение пароля и данное сообщение сообщение попало к Вам по ошибке, удалите его. " +LOGIN_MESSAGE_6 = "Здравствуйте %NAME%.%N%Вы запросили изменения Вашего пароля на сайте %HOST%.%N%%N%Ваш новый пароль: %PASS%%N%%N%Пожалуйста, перейдите по ссылке указанной ниже, чтобы активировать новый пароль:%N%%LINK%%N%%N%Если Вы не запрашивали изменение пароля и данное сообщение сообщение попало к Вам по ошибке, удалите его. " LOGIN_PASSWORD_RESTOR = "Ваш пароль успешно изменён." LOGIN_REMIND = "Восстановление пароля" LOGIN_REMINDER_INFO2 = "Пожалуйста, укажите E-mail адрес, который был использован при регистрации. На указанный E-mail будет выслан новый пароль." LOGIN_REMINDER_INFO4 = "Пожалуйста, укажите E-mail адрес" LOGIN_REMINDER_INFO3 = "Новый пароль выслан на указанный E-mail адрес." LOGIN_SUBJECT_REMINDER = "Ваш новый пароль" +LOGIN_SUBJECT_REMIND_OK = "Теперь вы можете использовать свой новый пароль для доступа к сайту." +LOGIN_SUBJECT_REMIND_AK = "Войти в аккаунт" [passwordchange] LOGIN_CHANGE_PASSWORD = "Изменить пароль" @@ -134,12 +149,14 @@ LOGIN_OLD_PASSWORD = "Текущий пароль:" LOGIN_OLD_PASS_EMPTY = "Ошибка! Вы не указали текущий пароль. Пожалуйста, правильность ввода." LOGIN_PASSWORDS_NOEQU = "Введенные пароли не совпадают. Пожалуйста, проверьте правильность ввода." LOGIN_PASSWORD_CHANGE = "Смена текущего пароля" -LOGIN_PASSWORD_INFO = "Пожалуйста, укажите новый пароль, который Вы хотите использовать. Пароль должн быть не менее 5 символов." +LOGIN_PASSWORD_INFO = "Пожалуйста, укажите новый пароль, который Вы хотите использовать. Пароль должен содержать не менее 5 символов." LOGIN_PASSWORD_OK = "Пароль успешно изменён!" LOGIN_WRONG_EQU_PASS = "Значение нового пароля и подтверждающего не совпадают" LOGIN_WRONG_OLD_PASS = "Текущий пароль указан неверно." LOGIN_WRONG_SHORT_PASS = "Длина пароля менее 5 символов." LOGIN_WRONG_SYM_PASS = "Пароль содержит недопустимые символы." +LOGIN_AKTIV_NEW_PASS = "Ваш новый пароль активирован." +LOGIN_NEW_PASS_REDIR = "В профиль" [delaccount] LOGIN_ADMIN_ACCOUNT = "Извините, но Вы не можете удалить свой аккаунт, так как Вы являетесь Администратором. Пожалуйста, обратитесь к Главному Администратору сайта." @@ -149,6 +166,10 @@ LOGIN_DELETE_CONFIRM = "Да, я согласен" LOGIN_DELETE_INFO = "Все готово для окончательного удаления Вашего аккаунта из системы. Помните, что удалив свой аккаунт, Вы потеряете доступ к разделам сайта, разрешенным для просмотра только зарегистрированным пользователям. Вы уверены, что хотите удалить свой аккаунт?" LOGIN_DELETE_OK = "Ваш аккаунт успешно удалён." LOGIN_DELETE_WARNING = "Внимание!" +LOGIN_DELETE_INF_DEL = "Мы удалим все ваши персональные данные в соответствии с требованиями законодательства" +LOGIN_DELETE_INF_DEL_A = "Нам жаль, что вы уходите. Сессия будет завершена." +LOGIN_DELETE_INF_DEL_L = "На главную" +LOGIN_DELETE_INF_DEL_C = "Отмена" [myprofile] LOGIN_BUTTON_CHANGE = "Сохранить изменения" @@ -185,6 +206,9 @@ LOGIN_YOUR_PHONE = "Контактный телефон:" LOGIN_YOUR_STREET = "Улица " LOGIN_YOUR_TOWN = "Город:" LOGIN_YOUR_ZIP = "Почтовый индекс" +LOGIN_YOUR_PRIVAT_DATA = "Личные данные" +LOGIN_YOUR_PRIVAT_ADR = "Адрес проживания" +LOGIN_YOUR_PRIVAT_JOB = "Связь и работа" [showconfig] LOGIN_BLACK_DOMAINS = "Чёрный список доменов:
Укажите домены, с которых запрещена регистрация. Один домен на одну строку." @@ -206,3 +230,7 @@ LOGIN_TYPE_NOW = "Сразу же, после регистрации" LOGIN_USE_SCODE = "Использовать защитный код?" LOGIN_YES = "Да" LOGIN_SETTING_EXIT = "Выйти из настроек" +LOGIN_SETTING_SAVE = "Настройки успешно сохранены (Ctrl+S)" +LOGIN_SETTING_SAVE_ERR = "Ошибка при сохранении настроек" +LOGIN_SETTING_SAVE_PR = "Сохранение..." +LOGIN_SHOW_COUNTRY = "Показывать поле Страна проживания?" diff --git a/module.php b/module.php index 038c9d6..c4165c0 100644 --- a/module.php +++ b/module.php @@ -3,104 +3,87 @@ if (! defined('BASE_DIR')) exit; + // Фикс для ядра: инициализируем константы заранее, чтобы PHP 8.4 не ругался на null в htmlspecialchars + if (!defined('MODULE_TITLE')) define('MODULE_TITLE', ''); + if (!defined('MODULE_DESCRIPTION')) define('MODULE_DESCRIPTION', ''); + if (!defined('MODULE_KEYWORDS')) define('MODULE_KEYWORDS', ''); + function mod_login () { global $AVE_Template; require_once(BASE_DIR . '/modules/login/class/login.php'); - new Login; + // Создаем экземпляр класса + $login_obj = new Login; - // Если прошли по ссылке, для показа формы, убираем вывод тега - if (isset($_REQUEST['module']) && $_REQUEST['module'] == 'login' && $_REQUEST['action'] == 'form') + // Если прошли по ссылке для показа формы, убираем вывод тега [mod_login] + if (isset($_REQUEST['module']) && $_REQUEST['module'] == 'login' && ($_REQUEST['action'] ?? '') == 'form') return false; $tpl_dir = BASE_DIR . '/modules/login/public/'; - $lang_file = BASE_DIR . '/modules/login/lang/' . $_SESSION['user_language'] . '.txt'; + // PHP 8.4 фикс: используем оператор ?? на случай, если сессия пуста + $lang_file = BASE_DIR . '/modules/login/lang/' . ($_SESSION['user_language'] ?? 'ru') . '.txt'; - if (isset($_SESSION['user_id']) && isset($_SESSION['user_pass'])) + if (isset($_SESSION['user_id']) && isset($_SESSION['user_pass'])) { - $avatar = getAvatar($_SESSION['user_id'],180); + $avatar = getAvatar((int)$_SESSION['user_id'], 180); + $abs_path = (defined('ABS_PATH')) ? ABS_PATH : '/'; + + // Если аватар пустой или это заглушка (иконка), подставляем default.png + if (empty($avatar) || strpos($avatar, 'user.png') !== false) { + $avatar = $abs_path . 'uploads/avatars/default.png'; + } $AVE_Template->assign('avatar', $avatar); + $AVE_Template->config_load($lang_file, 'displaypanel'); $AVE_Template->display($tpl_dir . 'panel.tpl'); } else - { - $active = Login::settings('login_status'); + { + // Используем объект для вызова настроек, если метод не статичный + $active = Login::settings('login_status'); - $AVE_Template->config_load($lang_file, 'loginform'); - $AVE_Template->assign('active', $active); - $AVE_Template->display($tpl_dir . 'form.tpl'); - } + $AVE_Template->config_load($lang_file, 'loginform'); + $AVE_Template->assign('active', $active); + $AVE_Template->display($tpl_dir . 'form.tpl'); + } return true; } //======================================================= - // Public functions + // Public functions (Когда заходим по прямой ссылке на модуль) //======================================================= if (! defined('ACP') && isset($_REQUEST['module']) && $_REQUEST['module'] == 'login' && ! empty($_REQUEST['action'])) { require_once(BASE_DIR . '/modules/login/class/login.php'); - new Login; + $login_obj = new Login; Login::$_tpl_dir = BASE_DIR . '/modules/login/public/'; + Login::$_lang_file = BASE_DIR . '/modules/login/lang/' . ($_SESSION['user_language'] ?? 'ru') . '.txt'; - Login::$_lang_file = BASE_DIR . '/modules/login/lang/' . $_SESSION['user_language'] . '.txt'; - + // В PHP 8+ вызов Login::method() может выдать ошибку, если методы в классе не static. + // Поэтому мы используем созданный $login_obj->method() switch ($_REQUEST['action']) { - case 'form': - Login::form(); - break; - - case 'authorize': - Login::authorize(); - break; - - case 'logout': - Login::logout(); - break; - - case 'register': - Login::register(); - break; - - case 'reminder': - Login::reminder(); - break; - - case 'change': - Login::change(); - break; - - case 'delete': - Login::delete(); - break; - - case 'profile': - Login::profile(); - break; - - case 'info': - Login::info(); - break; - - case 'checkusername': - Login::checkusername(); - break; - - case 'checkemail': - Login::checkemail(); - break; + case 'form': $login_obj->form(); break; + case 'authorize': $login_obj->authorize(); break; + case 'logout': $login_obj->logout(); break; + case 'register': $login_obj->register(); break; + case 'reminder': $login_obj->reminder(); break; + case 'change': $login_obj->change(); break; + case 'delete': $login_obj->delete(); break; + case 'profile': $login_obj->profile(); break; + case 'info': $login_obj->info(); break; + case 'checkusername': $login_obj->checkusername(); break; + case 'checkemail': $login_obj->checkemail(); break; } } - //======================================================= // The control module in the admin panel //======================================================= @@ -112,11 +95,10 @@ { require_once(BASE_DIR . '/modules/login/class/login.php'); - new Login; + $login_obj = new Login; Login::$_tpl_dir = BASE_DIR . '/modules/login/admin/'; - - $lang_file = BASE_DIR . '/modules/login/lang/' . $_SESSION['admin_language'] . '.txt'; + $lang_file = BASE_DIR . '/modules/login/lang/' . ($_SESSION['admin_language'] ?? 'ru') . '.txt'; $AVE_Template->config_load($lang_file, 'showconfig'); $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars()); @@ -124,9 +106,8 @@ switch($_REQUEST['moduleaction']) { case '1': - Login::admin(); + $login_obj->admin(); break; } } - ?> \ No newline at end of file diff --git a/public/change.tpl b/public/change.tpl index ceb3dbe..6e279d0 100644 --- a/public/change.tpl +++ b/public/change.tpl @@ -1,71 +1,147 @@ - -

{#LOGIN_PASSWORD_CHANGE#}

+
+
+
+ +
+
+ +
+
+
-
- {if $changeok==1} -
-

{#LOGIN_PASSWORD_OK#}

-
- {else} -
- + {if $changeok == 1} +
+
+ +
+

{#LOGIN_PASSWORD_OK#}

+

{#LOGIN_AKTIV_NEW_PASS#}

+
+ {#LOGIN_NEW_PASS_REDIR#} +
+
+ {else} -

{#LOGIN_PASSWORD_INFO#}

+
+
+

{#LOGIN_PASSWORD_CHANGE#}

+ + {#LOGIN_CANCEL#} + +
- {if $errors} -

{#LOGIN_FOUND_ERROR#}

-
    - {foreach from=$errors item=error} -
  • {$error}
  • - {/foreach} -
- {/if} +
+

{#LOGIN_PASSWORD_INFO#}

- - - {/if} + {if $errors} +
+
    + {foreach from=$errors item=error} +
  • {$error}
  • + {/foreach} +
+
+ {/if} + +
+ + +
+ +
+ + + +
+
+ +
+ +
+ +
+ + + +
+
+ +
+ +
+ + + +
+
+ +
+ +
+
+
+
+ {/if} +
+
+ + \ No newline at end of file diff --git a/public/delete.tpl b/public/delete.tpl index 6af42af..077a5ea 100644 --- a/public/delete.tpl +++ b/public/delete.tpl @@ -1,29 +1,80 @@ +
+
+
+ + {* Заголовок страницы *} +

+ {#LOGIN_DELETE_ACCOUNT#} +

-

{#LOGIN_DELETE_ACCOUNT#}

+
+ {if $admin == 1} + {* Случай, если админ пытается удалить себя *} +
+
+ +
+

{#LOGIN_DELETE_WARNING#}

+
+ {#LOGIN_ADMIN_ACCOUNT#} +
+
+ {else} + {if $delok == 1} + {* Сообщение об успешном удалении *} +
+
+ +
+

{#LOGIN_DELETE_OK#}

+

{#LOGIN_DELETE_INF_DEL_A#}

+ {#LOGIN_DELETE_INF_DEL_L#} +
+ {else} + {* Форма подтверждения удаления *} +
+
+ {#LOGIN_DELETE_WARNING#} +
+
+
+

+ {#LOGIN_DELETE_INFO#} +

-
- {if $admin == 1} - - {else} - {if $delok == 1} - - {else} - - {/if} - {/if} +
+ + +
+ + +
+ +
+ {#LOGIN_DELETE_INF_DEL_C#} + +
+
+
+ {/if} + {/if} +
+ + {if $delok != 1} +
+ {#LOGIN_DELETE_INF_DEL#}. +
+ {/if} +
+
+ + diff --git a/public/form.tpl b/public/form.tpl index 77fff6c..8beb6d6 100644 --- a/public/form.tpl +++ b/public/form.tpl @@ -1,35 +1,61 @@ -
-
-
-
{#LOGIN_AUTORIZATION#}
-

{#LOGIN_PLEASE_LOGON#}

-
-
-
-
- - - -
- -
-
-
- - - -
- -
-
- - -
- - {#LOGIN_PASSWORD_REMIND#}  - {if $active == 1}{#LOGIN_NEW_REGISTER#}{/if} -
-
-
\ No newline at end of file +{assign var="req_login" value=$smarty.request.user_login|default:''} + + \ No newline at end of file diff --git a/public/info.tpl b/public/info.tpl index 5ae79c1..1f11468 100644 --- a/public/info.tpl +++ b/public/info.tpl @@ -1,44 +1,89 @@ -

{#LOGIN_USER_PROFILE#}

-{if $user->avatar}{/if} -
-

{#LOGIN_DETAILS_INFO#}

+
+
+
+ + {if isset($smarty.get.save) && $smarty.get.save == 'ok'} +
+ +
+

{#LOGIN_CHANGE_SAVE#}

+

{#LOGIN_CHANGE_UPD#}

+
+ +
+ {/if} - -
+
+ + +
+
+
+
+ {if $user->avatar|default:''} + + {else} +
+ +
+ {/if} +
+

{$user->firstname|default:''|escape} {$user->lastname|default:''|escape}

+

{$user->email|default:''|escape}

+
+

{#LOGIN_DETAILS_INFO#}

+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{#LOGIN_YOUR_BIRTHDAY#}{$user->birthday|default:'—'|escape}
{#LOGIN_YOUR_COUNTRY#}{$user->country|default:'—'|escape}
{#LOGIN_YOUR_TOWN#}{$user->city|default:'—'|escape}
{#LOGIN_YOUR_ZIP#}{$user->zipcode|default:'—'|escape}
{#LOGIN_YOUR_STREET#}{$user->street|default:''|escape}{if $user->street_nr|default:''}, {$user->street_nr|escape}{/if}
{#LOGIN_YOUR_PHONE#}{$user->phone|default:'—'|escape}
{#LOGIN_YOUR_COMPANY#}{$user->company|default:'—'|escape}
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/public/panel.tpl b/public/panel.tpl index 7030185..304718f 100644 --- a/public/panel.tpl +++ b/public/panel.tpl @@ -1,15 +1,45 @@ -
- {if $avatar}{/if} -
-
{#LOGIN_WELCOME_TEXT#}
-

{$smarty.session.user_name|escape}

-
- + \ No newline at end of file diff --git a/public/process.tpl b/public/process.tpl index af41a30..2ed19f5 100644 --- a/public/process.tpl +++ b/public/process.tpl @@ -1,44 +1,69 @@ -
-
-
-
{#LOGIN_AUTORIZATION#}
-

{#LOGIN_PLEASE_LOGON#}

-
-
-
-
- - - -
- -
-
-
- - - -
- -
-
- - -
- - {#LOGIN_PASSWORD_REMIND#}  - {if $active == 1}{#LOGIN_NEW_REGISTER#}{/if} +
+
+
+ +
+
+

{#LOGIN_AUTORIZATION#}

+ + {if $login == false && isset($smarty.request.user_login)} + + {/if} - {if $login == false} - - {/if} -
-
- \ No newline at end of file +
+ +
+ + {* Фикс Warning: используем default:'' *} + +
+
+ +
+ +
+ + + +
+
+ +
+ + +
+ + + +
+ {#LOGIN_PASSWORD_REMIND#} + {if $active == 1} + {#LOGIN_NEW_REGISTER#} + {/if} +
+
+
+ +
+
+
+ + \ No newline at end of file diff --git a/public/profile.tpl b/public/profile.tpl index 45d2cac..b76fa78 100644 --- a/public/profile.tpl +++ b/public/profile.tpl @@ -1,87 +1,207 @@ -

{#LOGIN_CHANGE_DETAILS#}

-

{#LOGIN_DETAILS_INFO#}

+
+
+
+
+
+

{#LOGIN_CHANGE_DETAILS#}

+
+
+

{#LOGIN_DETAILS_INFO#}

-{if $errors} -
-
-

{#LOGIN_ERRORS#}

+ {if $errors} +
+

{#LOGIN_ERRORS#}

+
    + {foreach from=$errors item=error} +
  • {$error}
  • + {/foreach} +
+
+ {/if} - {foreach from=$errors item=error} - - {/foreach} +
+ + + {* Группа: Аватар пользователя *} +
+
+
+ Avatar + + + + +
+
+
+
Ваше фото (Avatar)
+
+ + +
+
Поддерживаются JPG, PNG, GIF и WebP.
+
+
-
-
-{/if} + {* Группа: Личные данные *} +
+
{#LOGIN_YOUR_PRIVAT_DATA#}
+ +
+ + +
+ +
+ + +
- - -
-
-
-
- - -
-
- - -
-
-
-
- - -
-
- - -
-
-
- - -
-
- - -
-
-
- - -
-
- - -
-
- - -
-
-
-
- - -
-
- - -
-
+
+ + +
- -
-
- +
+ +
+ + +
+
+
+ + {* Группа: Адрес проживания *} +
+
{#LOGIN_YOUR_PRIVAT_ADR#}
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
+ + {* Группа: Связь и работа *} +
+
{#LOGIN_YOUR_PRIVAT_JOB#}
+ +
+ + +
+ +
+ + +
+
+ +
+ +
+ +
+
+
+
+
+ + + + +{assign var="current_lang" value=$smarty.session.user_language|default:'ru'|lower} +{if $current_lang == 'ua'}{assign var="current_lang" value="uk"}{/if} + + + \ No newline at end of file diff --git a/public/register.tpl b/public/register.tpl index f8bb531..e965505 100644 --- a/public/register.tpl +++ b/public/register.tpl @@ -1,86 +1,138 @@ +
+
+
+
+
+

{#LOGIN_TEXT_REGISTER#}

+
+
+ + {if $errors} +
+
    + {foreach from=$errors item=error} +
  • {$error}
  • + {/foreach} +
+
+ {/if} -

{#LOGIN_TEXT_REGISTER#}

+
+
-
- {if $errors} -
    - {foreach from=$errors item=error} -
  • {$error}
  • - {/foreach} -
- {/if} - - +
+ - - - +
+
{#LOGIN_TEXT_AUTHORIZATION#}
+ +
+ + + +
+ {#LOGIN_WRONG_FIELD_LOGIN#} +
+
- - -
+
+ + +
+ +
+ + +
+
+ +
+ {if ($firstname|default:0 == 1) || ($lastname|default:0 == 1) || ($company|default:0 == 1) || ($country|default:0 == 1)} +
{#LOGIN_TEXT_USER_INFO#}
+ {/if} +
+ {if $firstname|default:0 == 1} +
+ + +
+ {/if} + + {if $lastname|default:0 == 1} +
+ + +
+ {/if} +
+ + {if $company|default:0 == 1} +
+ + +
+ {/if} + + {if $country|default:0 == 1} +
+ + +
+ {/if} +
+ + {if $im|default:0} +
+ +
+ captcha + +
+ + +
+
+
+ {#LOGIN_CAPTCHA_UPD#} +
+
+ {/if} + +
+ +
+ +
+
+
+
+
\ No newline at end of file diff --git a/public/register_final.tpl b/public/register_final.tpl index 01d7255..c426360 100644 --- a/public/register_final.tpl +++ b/public/register_final.tpl @@ -1,22 +1,68 @@ -

{#LOGIN_TEXT_REGISTER#}

+
+
+
+
+
+

{#LOGIN_TEXT_REGISTER#}

+
+
+ + {if $final == "ok"} +
+
+ +
+

{#LOGIN_MESSAGE_OK#}

+

{#LOGIN_REGISTER_OK_SP_L#}

+ + {if $smarty.session.referer != ''} + +
+
+ Loading... +
+
+ {/if} +
+ {else} +
+ +
+ +

+ {#LOGIN_MESSAGE_TEXT#} +

-
- +
+ + +
+ +
+ + +
+
+ +
+ +
+
+ {/if} + +
+
+ + {if $final != "ok"} +
+

+ {#LOGIN_REGISTER_OK_SP_N#} {#LOGIN_REGISTER_OK_SP_O#}. +

+
+ {/if} +
+
diff --git a/public/register_thankyou.tpl b/public/register_thankyou.tpl index 0aa5900..fb0a350 100644 --- a/public/register_thankyou.tpl +++ b/public/register_thankyou.tpl @@ -1,8 +1,34 @@ -

{#LOGIN_TEXT_REGISTER#}

+
+
+
+
+
+
+ +
+ +

+ {#LOGIN_REGISTER_OK#} +

+ +

+ {#LOGIN_THANKYOU_TEXT#} +

-
- +
+ + +
+
+ +
+ + {#LOGIN_REGISTER_OK_SP#} +
+
+
diff --git a/public/reminder.tpl b/public/reminder.tpl index ed4ddf9..5afa144 100644 --- a/public/reminder.tpl +++ b/public/reminder.tpl @@ -1,34 +1,97 @@ - -

{#LOGIN_REMIND#}

+
+
+
+ + {* Блок для JS-ошибок *} +
+
+ +
+
+
-
- {if $smarty.request.sub=='send'} -
-

{#LOGIN_REMINDER_INFO3#}

-
- {else} -
- - -
- {/if} -
+ {* Сообщение после отправки письма *} + {if $smarty.request.sub|default:'' == 'send'} +
+
+
+ +
+

Письмо отправлено!

+

{#LOGIN_REMINDER_INFO3#}

+ + Вернуться к входу + +
+
+ {else} +
+
+

+ {#LOGIN_REMIND#} +

+
+ +
+
+

{#LOGIN_REMINDER_INFO2#}

+
+ +
+ + +
+ +
+ + + + +
+
+ +
+ + + Я вспомнил пароль + +
+
+
+ +
+ {/if} + +
+
+
\ No newline at end of file diff --git a/public/reminder_end.tpl b/public/reminder_end.tpl index c793428..db76334 100644 --- a/public/reminder_end.tpl +++ b/public/reminder_end.tpl @@ -1,8 +1,34 @@ +
+
+
+
+
+
+ +
+ +

+ {#LOGIN_REMIND#} +

+ +

+ {#LOGIN_PASSWORD_RESTOR#} +

-

{#LOGIN_REMIND#}

+
-
- + +
+
+ +
+ + {#LOGIN_SUBJECT_REMIND_OK#} +
+
+
diff --git a/sql.php b/sql.php index 7c32383..b82788a 100644 --- a/sql.php +++ b/sql.php @@ -9,7 +9,7 @@ $module_sql_deinstall[] = "DROP TABLE IF EXISTS `%%PRFX%%_module_login`;"; //Установка модуля - $module_sql_install[] = "CREATE TABLE `%%PRFX%%_module_login` ( + $module_sql_install[] = "CREATE TABLE `%%PRFX%%_module_login` ( `Id` tinyint(1) unsigned NOT NULL auto_increment, `login_reg_type` enum('now','email','byadmin') NOT NULL default 'now', `login_antispam` enum('0','1') NOT NULL default '0', @@ -19,10 +19,11 @@ `login_require_company` enum('0','1') NOT NULL default '0', `login_require_firstname` enum('0','1') NOT NULL default '0', `login_require_lastname` enum('0','1') NOT NULL default '0', + `login_require_country` enum('0','1') NOT NULL default '0', PRIMARY KEY (Id) ) ENGINE=MyISAM DEFAULT CHARSET=utf8;"; - $module_sql_install[] = "INSERT INTO `%%PRFX%%_module_login` VALUES (1, 'email', 1, 1, 'domain.ru', 'name@domain.ru',0,0,0);"; + $module_sql_install[] = "INSERT INTO `%%PRFX%%_module_login` VALUES (1, 'email', 1, 1, 'domain.ru', 'name@domain.ru',0,0,0,0);"; // Обновление модуля $module_sql_update[] = "