diff --git a/login/templates/admin_config.tpl b/login/admin/config.tpl similarity index 100% rename from login/templates/admin_config.tpl rename to login/admin/config.tpl diff --git a/login/admin/index.php b/login/admin/index.php new file mode 100644 index 0000000..11b1a2d --- /dev/null +++ b/login/admin/index.php @@ -0,0 +1,4 @@ + \ No newline at end of file diff --git a/login/class/login.php b/login/class/login.php index 6d328b1..318363a 100644 --- a/login/class/login.php +++ b/login/class/login.php @@ -1,1220 +1,1264 @@ <]/'; - - /** - * Регулярное выражение для проверки даты - * - * @var string - */ - var $_regex_geb = '#(0[1-9]|[12][0-9]|3[01])([[:punct:]| ])(0[1-9]|1[012])\2(19|20)\d\d#'; - - /** - * Регулярное выражение для проверки e-Mail - * - * @var string - */ - var $_regex_email = '/^[\w.-]+@[a-z0-9.-]+\.(?:[a-z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|asia|jobs|museum)$/i'; - - /** - * Ссылка на страницу после регистрации без проверок - * - * @var string - */ - var $_reg_now = 'index.php?module=login&action=profile'; - - /** - * Ссылка на страницу после регистрации с проверкой Email - * - * @var string - */ - var $_reg_email = 'index.php?module=login&action=register&sub=registerfinal'; - - /** - * Ссылка на страницу после регистрации с проверкой администратором - * - * @var string - */ - var $_reg_admin = 'index.php?module=login&action=register&sub=thankadmin'; - - /** - * Конструктор - * - * @param string $tpl_dir путь к директории с шаблонами модуля - * @param string $lang_file путь к языковому файлу - * @return Login - */ - function Login($tpl_dir, $lang_file) + class Login { - $this->_tpl_dir = $tpl_dir; - $this->_lang_file = $lang_file; - } + public static $_sleep = 1; -/** - * ВНУТРЕННИЕ МЕТОДЫ - */ - - /** - * Получение параметра настройки модуля Авторизация - * - * @param string $field название параметра - * @return mixed значение параметра или массив параметров если не указан $field - */ - function _loginSettingsGet($field = '') - { - global $AVE_DB; + public static $_tpl_dir; - static $settings = null; + public static $_lang_file; - if ($settings === null) - { - $settings = $AVE_DB->Query(" - SELECT * - FROM " . PREFIX . "_module_login - WHERE Id = 1 - ")->FetchAssocArray(); - } + public static $_newuser_group = 4; - if ($field == '') return $settings; + #Регулярное выражение для проверки непечатаемых и нежелательных символов + public static $_regex = '/[^\x20-\xFF]|[><]/'; - return (isset($settings[$field]) ? $settings[$field] : null); - } + #Регулярное выражение для проверки даты + public static $_regex_geb = '#(0[1-9]|[12][0-9]|3[01])([[:punct:]| ])(0[1-9]|1[012])\2(19|20)\d\d#'; - /** - * Получение параметра "Обязательное поле" для формы авторизации - * - * @param string $field название поля БД в котором хранится параметр - * @return boolean - */ - function _loginFieldIsRequired($field) - { - return (bool)$this->_loginSettingsGet($field); - } + #Регулярное выражение для проверки e-Mail + public static $_regex_email = '/^[\w.-]+@[a-z0-9.-]+\.(?:[a-z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|asia|jobs|museum)$/i'; - /** - * Передать в Smarty признаки обязательных полей - * - */ - function _loginRequiredFieldFetch() - { - global $AVE_Template; + #Ссылка на страницу после регистрации без проверок + public static $_reg_now = 'index.php?module=login&action=profile'; - if ($this->_loginFieldIsRequired('login_require_company')) - { - $AVE_Template->assign('FirmName', 1); - } - if ($this->_loginFieldIsRequired('login_require_firstname')) + #Ссылка на страницу после регистрации с проверкой Email + public static $_reg_email = 'index.php?module=login&action=register&sub=final'; + + #Ссылка на страницу после регистрации с проверкой администратором + public static $_reg_admin = 'index.php?module=login&action=register&sub=thanks'; + + + /* ---------------------------------------------------------------------------------------------------------------------- */ + /* ---------------------------------------------------------------------------------------------------------------------- */ + /* ---------------------------------------------------------------------------------------------------------------------- */ + + + /* + |----------------------------------------------------------------------------------------------------------------------- + | _json + |----------------------------------------------------------------------------------------------------------------------- + | + | Return array in JSON format + | + */ + public static function _json ($data, $exit = false) { - $AVE_Template->assign('FirstName', 1); + header('Content-Type: application/json;charset=utf-8'); + + $json = json_encode($data); + + if ($json === false) + { + $json = json_encode(array('jsonError', json_last_error_msg())); + + if ($json === false) + { + $json = '{"jsonError": "unknown"}'; + } + + http_response_code(500); + } + + echo $json; + + if ($exit) + exit; } - if ($this->_loginFieldIsRequired('login_require_lastname')) + + + /* + |----------------------------------------------------------------------------------------------------------------------- + | _required + |----------------------------------------------------------------------------------------------------------------------- + | + | Получение параметра "Обязательное поле" для формы авторизации + | + | @param string $field название поля БД в котором хранится параметр + | @return boolean + | + */ + public static function _required ($field) { - $AVE_Template->assign('LastName', 1); + return (bool)self::settings($field); } - } - - /** - * Проверка наличия учетной записи с указанным email - * - * @param string $email проверяемый email - * @return boolean - */ - function _loginEmailExistCheck($email) - { - global $AVE_DB; - $exist = $AVE_DB->Query(" - SELECT 1 - FROM " . PREFIX . "_users - WHERE email = '" . addslashes($email) . "' - ")->NumRows(); - return (bool)$exist; - } + /* + |----------------------------------------------------------------------------------------------------------------------- + | _requiredfetch + |----------------------------------------------------------------------------------------------------------------------- + | + | Передать в Smarty признаки обязательных полей + | + */ + private static function _requiredfetch () + { + global $AVE_Template; - /** - * Проверка наличия учетной записи с проверяемым именем пользователя - * - * @param string $user_name проверяемое имя пользователя - * @return boolean - */ - function _loginUserNameExistsCheck($user_name) - { - global $AVE_DB; + if (self::_required('login_require_company')) + $AVE_Template->assign('company', 1); - $exist = $AVE_DB->Query(" - SELECT 1 - FROM " . PREFIX . "_users - WHERE user_name = '" . addslashes($user_name) . "' - LIMIT 1 - ")->NumRows(); + if (self::_required('login_require_firstname')) + $AVE_Template->assign('firstname', 1); - return (bool)$exist; - } + if (self::_required('login_require_lastname')) + $AVE_Template->assign('lastname', 1); - /** - * Проверка наличия в черном списке email - * - * @param unknown_type $email - * @return unknown - */ - function _loginEmailInBlacklistCheck($email) - { - if (empty($email)) return false; + } - $deny_emails = explode(',', chop($this->_loginSettingsGet('login_deny_email'))); - return !in_array($email, $deny_emails); - } + /* + |----------------------------------------------------------------------------------------------------------------------- + | _emailexist + |----------------------------------------------------------------------------------------------------------------------- + | + | Проверка наличия учетной записи с указанным email + | + | @param string $email проверяемый email + | @return boolean + | + */ + private static function _emailexist ($email) + { + global $AVE_DB; - /** - * Проверка наличия в черном списке доменного имени - * - * @param string $email email доменное имя которого надо проверить - * @return boolean - */ - function _loginEmailDomainInBlacklistCheck($email = '') - { - if (empty($email)) return false; + $exist = $AVE_DB->Query(" + SELECT 1 + FROM + " . PREFIX . "_users + WHERE + email = '" . $AVE_DB->EscStr($email) . "' + ")->NumRows(); - $deny_domains = explode(',', chop($this->_loginSettingsGet('login_deny_domain'))); - $domain = explode('@', $email); + return (bool)$exist; + } - return !in_array(@$domain[1], $deny_domains); - } -/** - * ВНЕШНИЕ МЕТОДЫ - */ + /* + |----------------------------------------------------------------------------------------------------------------------- + | _nameexists + |----------------------------------------------------------------------------------------------------------------------- + | + | Проверка наличия учетной записи с проверяемым именем пользователя + | + | @param string $user_name проверяемое имя пользователя + | @return boolean + | + */ + private static function _nameexists ($user_name) + { + global $AVE_DB; - /** - * Форма авторизации - * - */ - function loginLoginformShow() - { - global $AVE_Template; + $exist = $AVE_DB->Query(" + SELECT 1 + FROM + " . PREFIX . "_users + WHERE + user_name = '" . $AVE_DB->EscStr($user_name) . "' + LIMIT 1 + ")->NumRows(); - $AVE_Template->config_load($this->_lang_file, 'displayloginform'); + return (bool)$exist; + } - if ($this->_loginSettingsGet('login_status') == 1) $AVE_Template->assign('active', 1); - $AVE_Template->display($this->_tpl_dir . 'loginform.tpl'); - } + /* + |----------------------------------------------------------------------------------------------------------------------- + | _blacklist + |----------------------------------------------------------------------------------------------------------------------- + | + | Проверка наличия в черном списке email + | + | @param string $email + | @return boolean + | + */ + private static function _blacklist ($email) + { + if (empty($email)) + return false; - /** - * Панель пользователя - * - */ - function loginUserpanelShow() - { - global $AVE_Template; + $deny_emails = explode(',', chop(self::settings('login_deny_email'))); - $AVE_Template->config_load($this->_lang_file, 'displaypanel'); + return ! in_array($email, $deny_emails); + } - $AVE_Template->display($this->_tpl_dir . 'userpanel.tpl'); - } - /** - * Панель пользователя - * - */ - function loginUserInfo($user_id) - { - global $AVE_Template; + /* + |----------------------------------------------------------------------------------------------------------------------- + | _domaincheck + |----------------------------------------------------------------------------------------------------------------------- + | + | Проверка наличия в черном списке доменного имени + | + | @param string $email email доменное имя которого надо проверить + | @return boolean + | + */ + private static function _domaincheck ($email = '') + { + if (empty($email)) + return false; - $userinfo=get_user_rec_by_id(intval($user_id)); - $userinfo->avatar=getAvatar($user_id,100); - $AVE_Template->assign('user', $userinfo); - - $AVE_Template->config_load($this->_lang_file, 'userinfo'); + $deny_domains = explode(',', chop(self::settings('login_deny_domain'))); + $domain = explode('@', $email); - if (!defined('MODULE_CONTENT')) - { - define('MODULE_CONTENT', $AVE_Template->fetch($this->_tpl_dir . 'userinfo.tpl')); + return ! in_array(@$domain[1], $deny_domains); } - } - /** - * Выход из системы - * - */ - function loginUserLogout() - { - user_logout(); - $referer_link = get_referer_link(); - if (false === strstr($referer_link, 'module=login')) + /* + |----------------------------------------------------------------------------------------------------------------------- + | settings + |----------------------------------------------------------------------------------------------------------------------- + | + | Получение параметра настройки модуля Авторизация + | + */ + public static function settings ($field = '') { - header('Location:' . $referer_link); + global $AVE_DB; + + static $settings = null; + + if ($settings === null) + { + $sql = " + SELECT + * + FROM + " . PREFIX . "_module_login + WHERE + id = '1' + "; + + $settings = $AVE_DB->Query($sql, -1, 'modules/login', true, '.settings')->FetchAssocArray(); + } + + if ($field == '') + return $settings; + + return isset($settings[$field]) + ? $settings[$field] + : null; } - else + + /* + |----------------------------------------------------------------------------------------------------------------------- + | getlinks + |----------------------------------------------------------------------------------------------------------------------- + | + | Получение параметра настройки модуля Авторизация + | + */ + public static function getlinks () { - header('Location:' . get_home_link()); + global $AVE_DB; + + static $links = []; + + if (empty($links)) + { + $sql = $AVE_DB->Query(" + SELECT + module_action, + module_url + FROM + " . PREFIX . "_module_urls + WHERE + module_name = 'login' + "); + + while($row = $sql->FetchAssocArray()) + $links[$row['module_action']] = $row['module_url']; + } + + return $links; } - exit; - } - /** - * Авторизация пользователя - * - */ - function loginUserLogin() - { - global $AVE_Template; - if (empty($_SESSION['referer'])) + /* + |----------------------------------------------------------------------------------------------------------------------- + | form + |----------------------------------------------------------------------------------------------------------------------- + | + | Форма авторизации + | + */ + public static function form () { - $referer = get_referer_link(); - $_SESSION['referer'] = (false === strstr($referer, 'module=login')) ? $referer : get_home_link(); + global $AVE_Template; + + $AVE_Template->config_load(self::$_lang_file, 'loginform'); + + 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')); } - if (!empty($_POST['user_login']) && !empty($_POST['user_pass'])) + + /* + |----------------------------------------------------------------------------------------------------------------------- + | authorize + |----------------------------------------------------------------------------------------------------------------------- + | + | Авторизация пользователя + | + */ + public static function authorize () { - $result = user_login( - $_POST['user_login'], - $_POST['user_pass'], - 1, - (int)(isset($_POST['SaveLogin']) && $_POST['SaveLogin'] == 1) - ); - if ($result === true) + global $AVE_DB, $AVE_Template; + + if (empty($_SESSION['referer'])) { - header('Location:' . rewrite_link($_SESSION['referer'])); - unset($_SESSION['referer']); - exit; + $referer = get_referer_link(); + + $_SESSION['referer'] = (false === strstr($referer, 'module=login')) + ? $referer + : get_home_link(); } - elseif ($result === 3) + + $login = $AVE_DB->EscStr($_POST['user_login']); + + $password = $AVE_DB->EscStr($_POST['user_pass']); + + $keep_in = isset($_POST['keep_in']) + ? (int)$AVE_DB->EscStr($_POST['keep_in']) + : false; + + if (! empty($login) && !empty($password)) { - header('Location:' . ABS_PATH . 'index.php?module=login&action=register&sub=registerfinal'); - exit; + $result = user_login($login, $password,1, $keep_in); + + 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']); + + $AVE_Template->assign('login', false); + } } else - { - unset($_SESSION['user_id'], $_SESSION['user_pass']); + { + $AVE_Template->assign('login', false); + } + + if (self::settings('login_status') == 1) + $AVE_Template->assign('active', 1); + + $AVE_Template->config_load(self::$_lang_file, 'loginprocess'); - $AVE_Template->assign('login', false); + 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')); } } - else - { - $AVE_Template->assign('login', false); - } - if ($this->_loginSettingsGet('login_status') == 1) $AVE_Template->assign('active', 1); - $AVE_Template->config_load($this->_lang_file, 'loginprocess'); - - if (!defined('MODULE_CONTENT')) + /* + |----------------------------------------------------------------------------------------------------------------------- + | authorize + |----------------------------------------------------------------------------------------------------------------------- + | + | Выход из системы + | + */ + public static function logout () { - define('MODULE_CONTENT', $AVE_Template->fetch($this->_tpl_dir . 'process.tpl')); - } - } + user_logout(); - /** - * Регистрация новой учетной записи пользователя - * - */ - function loginNewUserRegister() - { - global $AVE_DB, $AVE_Template; + $referer_link = get_referer_link(); - if (isset($_SESSION['user_id']) || isset($_SESSION['user_pass'])) - { - header('Location:' . get_referer_link()); + if (false === strstr($referer_link, 'module=login')) + header('Location:' . $referer_link); + else + header('Location:' . get_home_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($this->_lang_file, 'registernew'); + /* + |----------------------------------------------------------------------------------------------------------------------- + | profile + |----------------------------------------------------------------------------------------------------------------------- + | + | Управление учетной записью пользователя + | + */ + public static function profile () + { + global $AVE_DB, $AVE_Template; - define('MODULE_TITLE', $AVE_Template->get_config_vars('LOGIN_TEXT_REGISTER')); + if (! isset($_SESSION['user_id']) || ! isset($_SESSION['user_pass'])) + { + header('Location:' . get_home_link()); + exit; + } - if ($this->_loginSettingsGet('login_antispam')) define('ANTISPAM', 1); + $AVE_Template->config_load(self::$_lang_file, 'myprofile'); - switch($this->_loginSettingsGet('login_status')) - { - case '1': - switch ($_REQUEST['sub']) - { - case 'register': - $error = array(); + if (isset($_REQUEST['sub']) && $_REQUEST['sub'] == 'update') + { + $errors = array(); - $_POST['user_name'] = (!empty($_POST['user_name'])) - ? trim($_POST['user_name']) - : ''; + if (self::_required('login_require_firstname') && empty($_POST['firstname'])) + $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_FN_EMPTY'); - $_POST['reg_email'] = (!empty($_POST['reg_email'])) - ? trim($_POST['reg_email']) - : ''; + if (preg_match(self::$_regex, $_POST['firstname'])) + $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_FIRSTNAME'); - $_POST['reg_email_return'] = (!empty($_POST['reg_email_return'])) - ? trim($_POST['reg_email_return']) - : ''; + if (self::_required('login_require_lastname') && empty($_POST['lastname'])) + $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_LN_EMPTY'); - // ЛОГИН - $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 ($this->_loginUserNameExistsCheck($_POST['user_name'])) - { - $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_L_INUSE'); - } - // EMAIL - if($_SESSION['loginza_auth']==1 && empty($_POST['reg_email'])){$_POST['reg_email']=$_POST['user_name'].'@'.ltrim($_SERVER['SERVER_NAME'],'www');} - if (empty($_POST['reg_email'])) - { - $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_EM_EMPTY'); - } - elseif (!preg_match($this->_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 ($this->_loginEmailExistCheck($_POST['reg_email'])) - { - $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_INUSE'); - } - if (!$this->_loginEmailDomainInBlacklistCheck($_POST['reg_email'])) - { - $error[] = $AVE_Template->get_config_vars('LOGIN_DOMAIN_FALSE'); - } - if (!$this->_loginEmailInBlacklistCheck($_POST['reg_email'])) - { - $error[] = $AVE_Template->get_config_vars('LOGIN_EMAIL_FALSE'); - } - } + if (preg_match(self::$_regex, $_POST['lastname'])) + $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_LASTNAME'); - // ПАРОЛЬ - if($_SESSION['loginza_auth']!=1){ - 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($this->_regex, $_POST['reg_pass'])) - { - $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_SYM_PASS'); - } - // ИМЯ - if ($this->_loginFieldIsRequired('login_require_firstname') && empty($_POST['reg_firstname'])) - { - $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_FN_EMPTY'); - } - if (!empty($_POST['reg_firstname']) && preg_match($this->_regex, $_POST['reg_firstname'])) - { - $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_FIRSTNAME'); - } + if (! empty($_POST['street']) && preg_match(self::$_regex, $_POST['street'])) + $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_STREET'); - // ФАМИЛИЯ - if ($this->_loginFieldIsRequired('login_require_lastname') && empty($_POST['reg_lastname'])) - { - $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_LN_EMPTY'); - } - if (!empty($_POST['reg_lastname']) && preg_match($this->_regex, $_POST['reg_lastname'])) - { - $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_LASTNAME'); - } + if (! empty($_POST['street_nr']) && preg_match(self::$_regex, $_POST['street_nr'])) + $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_HOUSE'); - 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 (! empty($_POST['zipcode']) && preg_match(self::$_regex, $_POST['zipcode'])) + $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_ZIP'); - if (defined('ANTISPAM')) $AVE_Template->assign('im', 1); + if (! empty($_POST['city']) && preg_match(self::$_regex, $_POST['city'])) + $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_TOWN'); - $this->_loginRequiredFieldFetch(); + if (! empty($_POST['phone']) && preg_match(self::$_regex, $_POST['phone'])) + $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_PHONE'); - $AVE_Template->assign('available_countries', get_country_list(1)); + 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(); + + if ($exist) + $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_INUSE'); + } - define('MODULE_CONTENT', $AVE_Template->fetch($this->_tpl_dir . 'register.tpl')); - } - else - { - $status = 0; + if (! empty($_POST['birthday']) && ! preg_match(self::$_regex_geb, $_POST['birthday'])) + $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_BIRTHDAY'); - $emailcode = md5(rand(100000,999999)); + if (! empty($_POST['birthday'])) + { + $birthday = preg_split('/[[:punct:]| ]/', $_POST['birthday']); - $log_reg_type=($_SESSION['loginza_auth']==1 ? 'now' : $this->_loginSettingsGet('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 = $this->_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=registerfinal" - . "&emc=" . $emailcode, - $email_body); - $email_body = str_replace("%HOST%", get_home_link(), $email_body); - $email_body = str_replace("%CODE%", $emailcode, $email_body); - $link = $this->_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 = $this->_reg_admin; - break; - } - $link=($_SESSION['loginza_auth']==1 ? $_SESSION['referer'] : $link); - $status=$_SESSION['loginza_auth']==1 ? '1' : (int)$status; - $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 = '" . ($_SESSION['loginza_auth']==1 ? $this->_newuser_loginza_group : $this->_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'] = $this->_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=".($_SESSION['loginza_auth']==1 ? $this->_newuser_loginza_group : $this->_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; - } + if (empty($birthday[0]) || $birthday[0] > 31) + $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_DATE'); - $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; + if (empty($birthday[1]) || $birthday[1] > 12) + $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_MONTH'); - case 'thankyou': - $AVE_Template->config_load($this->_lang_file); + if (empty($birthday[2]) || $birthday[2] > date("Y") || $birthday[2] < date("Y")-100) + $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_YEAR'); - define('MODULE_CONTENT', $AVE_Template->fetch($this->_tpl_dir . 'register_thankyou.tpl')); - break; + if (empty($errors)) + $_POST['birthday'] = $birthday[0] . '.' . $birthday[1] . '.' . $birthday[2]; + } - case 'registerfinal': - 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'] = $this->_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=".$this->_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; - } - } + 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']) . "' + "); - define('MODULE_CONTENT', $AVE_Template->fetch($this->_tpl_dir . 'register_final.tpl')); - break; + $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'; - case 'thankadmin': - $AVE_Template->config_load($this->_lang_file); + if (file_exists($new_a)) + { + @unlink($old_a); + @rename($new_a,$old_a); + } - define('MODULE_CONTENT', $AVE_Template->fetch($this->_tpl_dir . 'register_admin.tpl')); - break; + $AVE_Template->assign('password_changed', 1); + } + } - case '': - default : - if (defined('ANTISPAM')) $AVE_Template->assign('im', 1); + $sql = " + SELECT + * + FROM + " . PREFIX . "_users + WHERE + Id = '" . (int)$_SESSION['user_id'] . "' + LIMIT 1 + "; - $this->_loginRequiredFieldFetch(); + $user = $AVE_DB->Query($sql)->FetchAssocArray(); - $AVE_Template->assign('available_countries', get_country_list(1)); + $AVE_Template->assign('available_countries', get_country_list(1)); + $AVE_Template->assign('row', $user); - define('MODULE_CONTENT', $AVE_Template->fetch($this->_tpl_dir . 'register.tpl')); - break; - } - break; + self::_requiredfetch(); - case '0': - define('MODULE_CONTENT', $AVE_Template->get_config_vars('LOGIN_NOT_ACTIVE')); - break; + define('MODULE_TITLE', $AVE_Template->get_config_vars('LOGIN_CHANGE_DETAILS')); + define('MODULE_CONTENT', $AVE_Template->fetch(self::$_tpl_dir . 'profile.tpl')); } - } - /** - * Восстановление пароля - * - */ - function loginUserPasswordReminder() - { - global $AVE_DB, $AVE_Template; - if (isset($_SESSION['user_id'])) + /* + |----------------------------------------------------------------------------------------------------------------------- + | profile + |----------------------------------------------------------------------------------------------------------------------- + | + | Панель пользователя + | + */ + public static function info () { - header('Location:' . get_home_link()); - exit; - } + global $AVE_Template; - $AVE_Template->config_load($this->_lang_file, 'passwordreminder'); + $user_id = $_SESSION['user_id']; - define('MODULE_TITLE', $AVE_Template->get_config_vars('LOGIN_REMIND')); + $userinfo = get_user_rec_by_id(intval($user_id)); + $userinfo->avatar = getAvatar($user_id,100); - if (isset($_REQUEST['sub']) - && $_REQUEST['sub'] == 'confirm' - && !empty($_REQUEST['email'])) + $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')); + } + } + + + /* + |----------------------------------------------------------------------------------------------------------------------- + | profile + |----------------------------------------------------------------------------------------------------------------------- + | + | Управление модулем Авторизации + | + */ + public static function admin () { - $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) + 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 . "_users + UPDATE " . PREFIX . "_module_login SET - password = '" . addslashes($row_remind->new_pass) . "', - salt = '" . addslashes($row_remind->new_salt) . "' - WHERE email = '" . $_REQUEST['email'] . "' - AND new_pass = '" . $_REQUEST['code'] . "' + 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; } - $tpl_out = $AVE_Template->fetch($this->_tpl_dir . 'password_ok.tpl'); - define('MODULE_CONTENT', $tpl_out); + $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')); } - else + + + /* + |----------------------------------------------------------------------------------------------------------------------- + | reminder + |----------------------------------------------------------------------------------------------------------------------- + | + | Восстановление пароля + | + */ + public static function reminder () { - if (isset($_REQUEST['sub']) && $_REQUEST['sub'] == 'send' && !empty($_POST['f_mailreminder'])) + 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 - email, - user_name, - firstname, - lastname + new_pass, + new_salt FROM " . PREFIX . "_users - WHERE email = '" . $_POST['f_mailreminder'] . "' + WHERE email = '" . $_REQUEST['email'] . "' + AND new_pass != '' + AND new_pass = '" . $_REQUEST['code'] . "' 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 + password = '" . addslashes($row_remind->new_pass) . "', + salt = '" . addslashes($row_remind->new_salt) . "' + WHERE email = '" . $_REQUEST['email'] . "' + AND new_pass = '" . $_REQUEST['code'] . "' "); - - $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=passwordreminder" - . "&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' - ); } + + $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($this->_tpl_dir . 'password_lost.tpl')); + define('MODULE_CONTENT', $AVE_Template->fetch(self::$_tpl_dir . 'reminder.tpl')); + } } - } - /** - * Изменение пароля - * - */ - function loginUserPasswordChange() - { - global $AVE_DB, $AVE_Template; - - $AVE_Template->config_load($this->_lang_file, 'passwordchange'); - define('MODULE_TITLE', $AVE_Template->get_config_vars('LOGIN_PASSWORD_CHANGE')); - - if (!isset($_SESSION['user_id'])) + /* + |----------------------------------------------------------------------------------------------------------------------- + | change + |----------------------------------------------------------------------------------------------------------------------- + | + | Изменение пароля + | + */ + public static function change () { - header('Location:' . get_home_link()); - exit; - } + global $AVE_DB, $AVE_Template; - $salt = $AVE_DB->Query(" - SELECT salt - FROM " . PREFIX . "_users - WHERE Id = '" . $_SESSION['user_id'] . "' - LIMIT 1 - ")->GetCell(); + $AVE_Template->config_load(self::$_lang_file, 'passwordchange'); - if ($salt !== false && isset($_REQUEST['sub']) && $_REQUEST['sub'] == 'send') - { - $error = array(); + define('MODULE_TITLE', $AVE_Template->get_config_vars('LOGIN_PASSWORD_CHANGE')); - 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'] == '') + if (! isset($_SESSION['user_id'])) { - $error[] = $AVE_Template->get_config_vars('LOGIN_EMPTY_NEW_PASS'); + header('Location:' . get_home_link()); + exit; } - elseif (mb_strlen($_POST['new_pass']) < 5) + + $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[] = $AVE_Template->get_config_vars('LOGIN_WRONG_SHORT_PASS'); + $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); + } } - elseif ($_POST['new_pass_c'] == '') + + 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'])) { - $error[] = $AVE_Template->get_config_vars('LOGIN_EMPTY_NEW_PASS_C'); + header('Location:index.php'); + exit; } - elseif ($_POST['new_pass'] != $_POST['new_pass_c']) + + if (isset($_REQUEST['confirm']) && $_REQUEST['confirm'] == 1 && UGROUP != 1) { - $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_EQU_PASS'); + user_delete($_SESSION['user_id']); + unset($_SESSION['user_id']); + unset($_SESSION['user_pass']); + $AVE_Template->assign('delok', 1); } - elseif (preg_match('/[^\x21-\xFF]/', $_POST['new_pass'])) + + 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'])) { - $error[] = $AVE_Template->get_config_vars('LOGIN_WRONG_SYM_PASS'); + header('Location:' . get_referer_link()); + exit; } - if (count($error) > 0) + if (empty($_SESSION['referer'])) { - $AVE_Template->assign('errors', $error); + $referer = get_referer_link(); + $_SESSION['referer'] = (false === strstr($referer, 'module=login')) ? $referer : get_home_link(); } - else + + $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')) { - $newsalt = make_random_string(); - $md5_pass_salt = md5(md5($_POST['new_pass'] . $newsalt)); + 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'); + } - $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); - } - } + // 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'); - define('MODULE_CONTENT', $AVE_Template->fetch($this->_tpl_dir . 'password_change.tpl')); - } + // 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'); - /** - * Удаление учетной записи пользователя - * - */ - function loginUserAccountDelete() - { - global $AVE_Template; + // 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'); - $AVE_Template->config_load($this->_lang_file, 'delaccount'); + 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'); - define('MODULE_TITLE', $AVE_Template->get_config_vars('LOGIN_DELETE_ACCOUNT')); + unset($_SESSION['captcha_keystring']); + } - if (!isset($_SESSION['user_id']) || !isset($_SESSION['user_pass'])) - { - header('Location:index.php'); - exit; - } + if (count($error)) + { + $AVE_Template->assign('errors', $error); - if (isset($_REQUEST['delconfirm']) && $_REQUEST['delconfirm'] == 1 && UGROUP != 1) - { - user_delete($_SESSION['user_id']); - unset($_SESSION['user_id']); - unset($_SESSION['user_pass']); - $AVE_Template->assign('delok', 1); - } + if (defined('ANTISPAM')) + $AVE_Template->assign('im', 1); - if (defined('UGROUP') && UGROUP == 1) - { - $AVE_Template->assign('admin', 1); - } + self::_requiredfetch(); - $tpl_out = $AVE_Template->fetch($this->_tpl_dir . 'delete_account.tpl'); - define('MODULE_CONTENT', $tpl_out); - } + $AVE_Template->assign('available_countries', get_country_list(1)); - /** - * Управление учетной записью пользователя - * - */ - function loginUserProfileEdit() - { - global $AVE_DB, $AVE_Template; + define('MODULE_CONTENT', $AVE_Template->fetch(self::$_tpl_dir . 'register.tpl')); + } + else + { + $status = 0; - if (!isset($_SESSION['user_id']) || !isset($_SESSION['user_pass'])) - { - header('Location:'.get_home_link()); - exit; - } + $emailcode = md5(rand(100000,999999)); - $AVE_Template->config_load($this->_lang_file, 'myprofile'); + $log_reg_type = self::settings('login_reg_type'); - define('MODULE_TITLE', $AVE_Template->get_config_vars('LOGIN_CHANGE_DETAILS')); + 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; + } - if (isset($_REQUEST['sub']) && $_REQUEST['sub'] == 'update') - { - $errors = array(); + $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(); - if ($this->_loginFieldIsRequired('login_require_firstname') && empty($_POST['firstname'])) - { - $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_FN_EMPTY'); - } - if (preg_match($this->_regex, $_POST['firstname'])) - { - $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_FIRSTNAME'); - } + $_SESSION['user_name'] = get_username( + stripslashes($_POST['user_name']), + stripslashes($_POST['reg_firstname']), + stripslashes($_POST['reg_lastname']) + ); - if ($this->_loginFieldIsRequired('login_require_lastname') && empty($_POST['lastname'])) - { - $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_LN_EMPTY'); - } - if (preg_match($this->_regex, $_POST['lastname'])) - { - $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_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']); - if (!empty($_POST['street']) && preg_match($this->_regex, $_POST['street'])) - { - $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_STREET'); - } - if (!empty($_POST['street_nr']) && preg_match($this->_regex, $_POST['street_nr'])) - { - $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_HOUSE'); - } - if (!empty($_POST['zipcode']) && preg_match($this->_regex, $_POST['zipcode'])) - { - $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_ZIP'); - } - if (!empty($_POST['city']) && preg_match($this->_regex, $_POST['city'])) - { - $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_TOWN'); - } - if (!empty($_POST['phone']) && preg_match($this->_regex, $_POST['phone'])) - { - $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_PHONE'); - } - if (!empty($_POST['telefax']) && preg_match($this->_regex, $_POST['telefax'])) - { - $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_FAX'); - } + $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)); - if (!preg_match($this->_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(); + foreach ($user_group_permissions as $user_group_permission) + $_SESSION[$user_group_permission] = 1; + } - if ($exist) - { - $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_INUSE'); - } - } + $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; - if (!empty($_POST['birthday']) && !preg_match($this->_regex_geb, $_POST['birthday'])) - { - $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_BIRTHDAY'); - } + case 'thanks': + $AVE_Template->config_load(self::$_lang_file); - if (!empty($_POST['birthday'])) - { - $birthday = preg_split('/[[:punct:]| ]/', $_POST['birthday']); - if (empty($birthday[0]) || $birthday[0] > 31) - { - $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_DATE'); - } - if (empty($birthday[1]) || $birthday[1] > 12) - { - $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_MONTH'); - } - if (empty($birthday[2]) || $birthday[2] > date("Y") || $birthday[2] < date("Y")-100) - { - $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_YEAR'); - } + define('MODULE_CONTENT', $AVE_Template->fetch(self::$_tpl_dir . 'register_thankyou.tpl')); + break; - if (empty($errors)) - { - $_POST['birthday'] = $birthday[0] . '.' . $birthday[1] . '.' . $birthday[2]; - } - } + case 'final': + if (isset($_REQUEST['emc']) && $_REQUEST['emc'] != '') + { + $row = $AVE_DB->Query(" + SELECT * + FROM " . PREFIX . "_users + WHERE emc = '" . $_REQUEST['emc'] . "' + ")->FetchRow(); - if (!empty($errors)) - { - $AVE_Template->assign('errors', $errors); - } - else - { - $AVE_DB->Query(" - UPDATE " . PREFIX . "_users - SET - email = '" . $_POST['email'] . "', - street = '" . $_POST['street'] . "', - street_nr = '" . $_POST['street_nr'] . "', - zipcode = '" . $_POST['zipcode'] . "', - city = '" . $_POST['city'] . "', - phone = '" . $_POST['phone'] . "', - telefax = '" . $_POST['telefax'] . "', - firstname = '" . $_POST['firstname'] . "', - lastname = '" . $_POST['lastname'] . "', - country = '" . $_POST['country'] . "', - birthday = '" . $_POST['birthday'] . "', - company = '" . $_POST['company'] . "' - WHERE - Id = '" . (int)$_SESSION['user_id'] . "' - AND - password = '" . addslashes($_SESSION['user_pass']) . "' - "); - $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'; - if(file_exists($new_a)){ - @unlink($old_a); - @rename($new_a,$old_a); - } - $AVE_Template->assign('password_changed', 1); - } - } + 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; + } + } - $row = $AVE_DB->Query(" - SELECT * - FROM " . PREFIX . "_users - WHERE Id = '" . (int)$_SESSION['user_id'] . "' - LIMIT 1 - ")->FetchAssocArray(); + define('MODULE_CONTENT', $AVE_Template->fetch(self::$_tpl_dir . 'register_final.tpl')); + break; - $AVE_Template->assign('available_countries', get_country_list(1)); - $AVE_Template->assign('row', $row); + case 'admin': + $AVE_Template->config_load(self::$_lang_file); - $this->_loginRequiredFieldFetch(); + define('MODULE_CONTENT', $AVE_Template->fetch(self::$_tpl_dir . 'register_admin.tpl')); + break; - define('MODULE_CONTENT', $AVE_Template->fetch($this->_tpl_dir . 'myprofile.tpl')); - } + case '': + default : + if (defined('ANTISPAM')) + $AVE_Template->assign('im', 1); - /** - * Управление модулем Авторизации - * - */ - function loginSettingsEdit() - { - global $AVE_DB, $AVE_Template; + self::_requiredfetch(); - 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_Template->assign('available_countries', get_country_list(1)); - header('Location:index.php?do=modules&action=modedit&mod=login&moduleaction=1&cp=' . SESSION); - exit; + 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; + } } - $row = $this->_loginSettingsGet(); - $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->config_load($this->_lang_file, 'showconfig'); + /* + |----------------------------------------------------------------------------------------------------------------------- + | checkusername + |----------------------------------------------------------------------------------------------------------------------- + | + | + | + */ + public static function checkusername () + { + global $AVE_DB, $AVE_Template; - $AVE_Template->assign('content', $AVE_Template->fetch($this->_tpl_dir . 'admin_config.tpl')); - } + $errors = []; - function loginUsernameAjaxCheck() - { - global $AVE_Template; + $AVE_Template->config_load(self::$_lang_file, 'registernew'); - $errors = array(); + $user_name = $AVE_DB->EscStr($_POST['user_name']); - $AVE_Template->config_load($this->_lang_file, 'registernew'); + 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($_POST['username'])) - { - $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_L_EMPTY'); - } - elseif (!ctype_alnum($_POST['username'])) - { - $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_LOGIN'); - } - elseif ($this->_loginUserNameExistsCheck($_POST['username'])) - { - $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_L_INUSE'); + if (! empty($errors)) + self::_json($errors, true); } - if (!empty($errors)) - { - echo ''; - } - exit; - } + /* + |----------------------------------------------------------------------------------------------------------------------- + | checkemail + |----------------------------------------------------------------------------------------------------------------------- + | + | + | + */ + public static function checkemail () + { + global $AVE_DB, $AVE_Template; - function loginEmailAjaxCheck() - { - global $AVE_Template; + $errors = array(); - $errors = array(); + $AVE_Template->config_load(self::$_lang_file, 'registernew'); - $AVE_Template->config_load($this->_lang_file, 'registernew'); + $email = $AVE_DB->EscStr($_POST['email']); - if (empty($_POST['email'])) - { - $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_EM_EMPTY'); - } - elseif (!preg_match($this->_regex_email, $_POST['email'])) - { - $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_EMAIL'); - } - else - { - if ($this->_loginEmailExistCheck($_POST['email'])) - { - $errors[] = $AVE_Template->get_config_vars('LOGIN_WRONG_INUSE'); - } - if (!$this->_loginEmailDomainInBlacklistCheck($_POST['email'])) - { - $errors[] = $AVE_Template->get_config_vars('LOGIN_DOMAIN_FALSE'); - } - if (!$this->_loginEmailInBlacklistCheck($_POST['email'])) - { - $errors[] = $AVE_Template->get_config_vars('LOGIN_EMAIL_FALSE'); - } - } + 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)) - { - echo ''; + if (! empty($errors)) + self::_json($errors, true); } - - exit; } -} - ?> \ No newline at end of file diff --git a/login/img/ajax-loader.gif b/login/img/ajax-loader.gif deleted file mode 100644 index 941cf9b..0000000 Binary files a/login/img/ajax-loader.gif and /dev/null differ diff --git a/login/info.php b/login/info.php index d8deefc..2f6c1df 100644 --- a/login/info.php +++ b/login/info.php @@ -7,7 +7,7 @@ 'ModuleVersion' => '2.26.1', 'ModuleAutor' => 'AVE.cms Team', 'ModuleCopyright' => '© 2007-' . date('Y') . ' AVE.cms', - 'ModuleStatus' => 1, + 'ModuleStatus' => 1, 'ModuleIsFunction' => 1, 'ModuleTemplate' => 1, 'ModuleAdminEdit' => 1, diff --git a/login/lang/en.txt b/login/lang/en.txt deleted file mode 100644 index 8700e8b..0000000 --- a/login/lang/en.txt +++ /dev/null @@ -1,190 +0,0 @@ -[displayloginform] -LOGIN_NEW_REGISTER = "Registration" -LOGIN_PASSWORD_REMIND = "Forgot your password?" -LOGIN_PLEASE_LOGON = "Please log in to access advanced features." -LOGIN_REGISTER_INFO = "Registration on the site will allow you to access the sections, which are allowed only for registered users. This procedure will not take you much time." -LOGIN_REMINDER_INFO = "If you have forgotten your password, enter your E-mail address that was specified by you at registration and in the shortest time, we will send a new password." -LOGIN_SAVE_COOKIE = "Remember Me" -LOGIN_SAVE_ICON = "[?]" -LOGIN_SAVE_INFO = "Check the box if you want the system to automatically log on under your login information." -LOGIN_YOUR_EMAIL = "Login" -LOGIN_YOUR_PASSWORD = "password" -LOGIN_LOGIN_PANEL = "login panel" -LOGIN_BUTTON_LOGIN = "Login" -LOGIN_AUTORIZATION = "Authorization" - -[displaypanel] -LOGIN_ADMIN_LINK = "Control Panel" -LOGIN_CHANGE_DETAILS = "Profile Settings" -LOGIN_NEW_POST = "Write Post" -LOGIN_MY_POSTS = "My posts" -LOGIN_CHANGE_LINK = "Change Password" -LOGIN_DELETE_LINK = "Delete Account" -LOGIN_LOGOUT_LINK = "Quit" -LOGIN_WELCOME_TEXT = "Hello" -LOGIN_WYSIWYG_OFF = "Turn off the Editor" -LOGIN_WYSIWYG_ON = "Auto Editor" -LOGIN_USER_PANEL = "User Panel" - -[loginprocess] -LOGIN_BUTTON_ENTER = "Login" -LOGIN_NEW_REGISTER = "Registration" -LOGIN_PASSWORD = "password" -LOGIN_PASSWORD_REMIND = "Forgot your password?" -LOGIN_PLEASE_LOGON = "Please log in using your E-Mail and Password" -LOGIN_REGISTER_INFO = "Registration on the site will allow you to access the sections, which are allowed only for registered users. This procedure will not take you much time." -LOGIN_REMINDER_INFO = "If you have forgotten your password, enter your E-mail address that was specified by you at registration and in the shortest time, we will send a new password." -LOGIN_SAVE_COOKIE = "Remember Me" -LOGIN_SAVE_INFO = "Check the box if you want the system to automatically log on under your login information." -LOGIN_TEXT_FALSE_INFO = "You have entered invalid data in the authorization. Please try again." -LOGIN_TEXT_TRUE_INFO = "Thank you. You have successfully passed the authorization." -LOGIN_YOUR_MAIL = "Login" -LOGIN_AUTORIZATION = "Authorization" -LOGIN_BUTTON_LOGIN = "Login" - -[registernew] -LOGIN_BUTTON_FINAL = "Finish" -LOGIN_BUTTON_SUBMIT = "Continue" -LOGIN_CODE_FROM_MAIL = "Activation Code" -LOGIN_DOMAIN_FALSE = "The specified E-mail-domain is locked for the record." -LOGIN_EMAIL_FALSE = "The specified E-mail address is blocked for the record." -LOGIN_MAIL_CONFIRM = "Repeat E-mail:" -LOGIN_MESSAGE_1 = "Hello% NAME%,% N% Your account has been created successfully.% N%% N% You can pre-authorize online% HOST%, with the following data:% N%% N% Username:% NAME%% N% Password:% KENNWORT%% N% " -LOGIN_MESSAGE_2 = "Hello% NAME%.% N% Congratulations on your successful registration.% N%% N% You can pre-authorize online% HOST%, with the following data:% N%% N% Username:% NAME%% N % Password:% KENNWORT%% N% " -LOGIN_MESSAGE_3 = "% N% Note: Before you perform authorization, you will need to confirm your registration and your E-mail-address. Please click on the link below:% N%% REGLINK%% N% code to activate your account by hand:% CODE% " -LOGIN_MESSAGE_4 = "% N% Please note: Your account will only be available after the testing and activation of the Administration site. Once activated, you will be notified by E-mail address.% N%% N%% HOST%" -LOGIN_MESSAGE_5 = "Hello.% N% The site registered a new user with the following login information.% N%% N% Name:% NAME%% N% E-mail:% EMAIL%" -LOGIN_MESSAGE_7 = "Please note: Your account will only be available after the testing and activation of the Administration site. Once activated, you will be notified by E-mail address." -LOGIN_MESSAGE_OK = "Registration Complete! Now the system will try to implement automatic login. If the input is not implemented, you can manually enter your username and password." -LOGIN_MESSAGE_TEXT = "The registration process is almost complete. To activate your account, please enter the activation code that was sent to you E-mail message." -LOGIN_NOT_ACTIVE = "At the moment, user registration is temporarily disabled." -LOGIN_PASSWORD = "password" -LOGIN_REGISTER_OK = "Registration completed successfully" -LOGIN_SECURITY_CODE = "Security code" -LOGIN_SECURITY_CODER = "Please enter the code" -LOGIN_SUBJECT_ADMIN = "New Registration" -LOGIN_SUBJECT_USER = "Registration Data" -LOGIN_TEXT_REGISTER = "New Registration" -LOGIN_THANKYOU_TEXT = "Thank you for registering! In Your E-mail sent a message containing information about how to activate your account." -LOGIN_WROND_E_SCODE = "Security code field is not filled." -LOGIN_WROND_SCODE = "The specified security code is incorrect." -LOGIN_WRONG_EMAIL = "E-mail field is specified in an incorrect format." -LOGIN_WRONG_EM_EMPTY = "E-mail field blank." -LOGIN_WRONG_ER_EMPTY = "Field E-mail (confirmation) is not filled." -LOGIN_WRONG_FN_EMPTY = "The Name field is not filled." -LOGIN_WRONG_FIRSTNAME = "The Name field contains invalid characters." -LOGIN_WRONG_INUSE = "The specified E-mail address is already registered." -LOGIN_WRONG_LN_EMPTY = "Last Name field is not filled." -LOGIN_WRONG_LASTNAME = "Field Name contains invalid characters." -LOGIN_WRONG_L_EMPTY = "Username field is blank." -LOGIN_WRONG_LOGIN = "The field Username contains invalid characters." -LOGIN_WRONG_L_INUSE = "The specified login is already in use." -LOGIN_WRONG_PASS = "Password field is not filled." -LOGIN_WRONG_RETRY = "These E-mail addresses do not match." -LOGIN_WRONG_SHORT_PASS = "Password length at least 5 characters long." -LOGIN_WRONG_SYM_PASS = "The password contains invalid characters." -LOGIN_YOUR_COMPANY = "Organization" -LOGIN_YOUR_COUNTRY = "Country" -LOGIN_YOUR_FIRSTNAME = "Name" -LOGIN_YOUR_LASTNAME = "Last Name" -LOGIN_YOUR_LOGIN = "Login" -LOGIN_YOUR_MAIL = "E-mail" -LOGIN_TEXT_AUTHORIZATION = "Information for authorization" -LOGIN_TEXT_USER_INFO = "Personal Information" - -[passwordreminder] -LOGIN_BUTTON_NEWPASS = "Send password" -LOGIN_YOUR_MAIL = "E-mail" -LOGIN_ENTER_EMAIL = "Please enter your E-mail." -LOGIN_MESSAGE_6 = "Hello% NAME%.% N% You have requested the change your password online% HOST%.% N%% N% Your new password:% PASS%% N%% N% Please click on the link below to confirm the change password:% N%% LINK%% N%% N% If you did not request a password change, and the message is the message got to you in error, delete it. " -LOGIN_PASSWORD_RESTOR = "Your password was successfully changed." -LOGIN_REMIND = "password recovery" -LOGIN_REMINDER_INFO2 = "Please enter E-mail address that you used during registration. To the specified E-mail will be sent a new password." -LOGIN_REMINDER_INFO4 = "Please enter E-mail address" -LOGIN_REMINDER_INFO3 = "new password is sent to the E-mail address." -LOGIN_SUBJECT_REMINDER = "Your new password" - -[passwordchange] -LOGIN_CHANGE_PASSWORD = "Change Password" -LOGIN_EMPTY_NEW_PASS = "You did not enter a new password" -LOGIN_EMPTY_NEW_PASS_C = "You did not specify a value for confirming the new password" -LOGIN_EMPTY_OLD_PASS = "You did not enter the current password" -LOGIN_FOUND_ERROR = "In the process of changing passwords have the following error:" -LOGIN_NEW_PASSC = "Error: You did not enter a confirmation password value." -LOGIN_NEW_PASSWORD = "New Password" -LOGIN_NEW_PASSWORD_C = "Confirm Password" -LOGIN_NEW_PASS_EMPTY = "Error: You did not enter a new password." -LOGIN_OLD_PASSWORD = "Current password" -LOGIN_OLD_PASS_EMPTY = "Error: You did not enter the current password. Please correct the input." -LOGIN_PASSWORDS_NOEQU = "The passwords do not match. Please check the box." -LOGIN_PASSWORD_CHANGE = "Changing the current password" -LOGIN_PASSWORD_INFO = "Please enter the new password you want to use. Password must be at least 5 characters long." -LOGIN_PASSWORD_OK = "Password changed successfully!" -LOGIN_WRONG_EQU_PASS = "The value of the new password and confirmation do not match" -LOGIN_WRONG_OLD_PASS = "Current password is incorrect." -LOGIN_WRONG_SHORT_PASS = "Password length at least 5 characters long." -LOGIN_WRONG_SYM_PASS = "The password contains invalid characters." - -[delaccount] -LOGIN_ADMIN_ACCOUNT = "Sorry, but you can not delete your account because you are an Administrator. Please refer to the Chief Administrator of the site." -LOGIN_DELETE_ACCOUNT = "Delete your account" -LOGIN_DELETE_BUTTON = "Delete" -LOGIN_DELETE_CONFIRM = "Yes, I agree" -LOGIN_DELETE_INFO = "Everything is ready for the final disposal of your account from the system. Remember that deleting your account, you will lose access to the site, allowed only for registered users. Are you sure you want to delete my account?" -LOGIN_DELETE_OK = "Your account has been successfully removed." -LOGIN_DELETE_WARNING = "Attention!" - -[myprofile] -LOGIN_BUTTON_CHANGE = "Save" -LOGIN_CHANGED_OK = "Profile Settings saved successfully" -LOGIN_CHANGE_DETAILS = "Personal Information" -LOGIN_DATE_FORMAT = "(dd.mm.yyyy)" -LOGIN_DETAILS_INFO = "Profile Settings allow you to manage your personal data. Please fill in the fields, specifying the relevant information." -LOGIN_ERRORS = "During the registration process have the following error:" -LOGIN_WRONG_BIRTHDAY = "Date of Birth field is specified in an incorrect format." -LOGIN_WRONG_DATE = "Incorrect day of your birth ( DD . MM.GGGG)" -LOGIN_WRONG_EMAIL = "E-mail field is specified in an incorrect format." -LOGIN_WRONG_FAX = "Fax Field House is empty, or contains invalid simovly." -LOGIN_WRONG_FN_EMPTY = "The Name field is not filled." -LOGIN_WRONG_FIRSTNAME = "The Name field contains invalid characters." -LOGIN_WRONG_HOUSE = "The field house number is blank or contains invalid simovly." -LOGIN_WRONG_INUSE = "The specified E-mail address is already used in the system." -LOGIN_WRONG_LN_EMPTY = "Last Name field is not filled." -LOGIN_WRONG_LASTNAME = "Field Name contains invalid characters." -LOGIN_WRONG_MONTH = "Incorrect month of your birth (MM DD. . YYYY)" -LOGIN_WRONG_PHONE = "phone number field is blank or contains invalid simovly." -LOGIN_WRONG_STREET = "Field Street is empty or contains invalid characters." -LOGIN_WRONG_TOWN = "City Field is blank or contains invalid simovly." -LOGIN_WRONG_YEAR = "Incorrect year of your birth (YYYY DD.MM. )" -LOGIN_WRONG_ZIP = "Postal Code field is blank or contains invalid simovly." -LOGIN_YOUR_BIRTHDAY = "Birthday" -LOGIN_YOUR_COMPANY = "name" -LOGIN_YOUR_COUNTRY = "Country" -LOGIN_YOUR_FAX = "Fax" -LOGIN_YOUR_FIRSTNAME = "Name" -LOGIN_YOUR_HOUSE = "house number" -LOGIN_YOUR_LASTNAME = "Last Name" -LOGIN_YOUR_MAIL = "E-mail" -LOGIN_YOUR_PHONE = "Telephone" -LOGIN_YOUR_STREET = "Street" -LOGIN_YOUR_TOWN = "City" -LOGIN_YOUR_ZIP = "Zip code" - -[showconfig] -LOGIN_BLACK_DOMAINS = "Black list of domains:
Specify the domains from which prohibited registration. One domain on one line. " -LOGIN_BLACK_EMAILS = "Black List E-mail:
Enter E-mail addresses from which registration is prohibited. One E-mail address on line! " -LOGIN_BUTTON_SAVE = "Save Changes" -LOGIN_ENABLE_REGISTER = "Allow registration?" -LOGIN_MODULE_EDIT = "Configure module" -LOGIN_MODULE_INFO = "In this section you can configure the module in accordance with the required parameters, as well as to determine the lists of domain names and e-mail addresses will be allowed to register on the site." -LOGIN_MODULE_NAME = "Management module > Log in " -LOGIN_NO = "No" -LOGIN_REGISTRATION_TYPE = "Registration Type" -LOGIN_SHOW_COMPANY = "Show the field organization?" -LOGIN_SHOW_FIRSTNAME = "Display Name field?" -LOGIN_SHOW_LASTNAME = "Display Name field?" -LOGIN_TYPE_BYADMIN = "After confirming the Administrators' -LOGIN_TYPE_BYEMAIL = "After confirmation via E-mail" -LOGIN_TYPE_NOW = "Immediately after recording" -LOGIN_USE_SCODE = "Use the security code?" -LOGIN_YES = "Yes" diff --git a/login/lang/ru.txt b/login/lang/ru.txt index 0ffa5ff..f0ee8a9 100644 --- a/login/lang/ru.txt +++ b/login/lang/ru.txt @@ -2,17 +2,13 @@ MODULE_NAME = "Авторизация" MODULE_DESCRIPTION = "Данный модуль предназначен для регистрации пользователей на вашем сайте. Для вывода формы авторизации, разместите системный тег [mod_login] в нужном месте вашего шаблона. Также вы можете указать шаблон, в котором будет отображена форма для регистрации и авторизации." - - - -[displayloginform] +[loginform] LOGIN_NEW_REGISTER = "Регистрация" LOGIN_PASSWORD_REMIND = "Забыли пароль?" LOGIN_PLEASE_LOGON = "Пожалуйста, авторизуйтесь, для доступа к расширенным возможностям." LOGIN_REGISTER_INFO = "Регистрация на сайте позволит Вам получить доступ к разделам, которые разрешены для просмотра только зарегистрированным пользователям. Данная процедура не займет у Вас много времени." LOGIN_REMINDER_INFO = "Если Вы забыли свой пароль, введите E-mail адрес, который был указан Вами при регистрации и мы в кротчайшие сроки вышлем новый пароль." LOGIN_SAVE_COOKIE = "Запомнить меня" -LOGIN_SAVE_ICON = "[?]" LOGIN_SAVE_INFO = "Установите флажок, если Вы хотите, чтобы система автоматически осуществляла вход на основании ваших регистрационных данных." LOGIN_YOUR_EMAIL = "Логин:" LOGIN_YOUR_PASSWORD = "Пароль:" @@ -30,8 +26,21 @@ LOGIN_WELCOME_TEXT = "Здравствуйте " LOGIN_WYSIWYG_OFF = "Выключить редактор" LOGIN_WYSIWYG_ON = "Включить редактор" LOGIN_USER_PANEL = "Панель пользователя" +LOGIN_USER_PROFILE = "Посмотреть профиль" [userinfo] +LOGIN_YOUR_BIRTHDAY = "Дата рождения:" +LOGIN_YOUR_COMPANY = "Название организации:" +LOGIN_YOUR_COUNTRY = "Страна проживания:" +LOGIN_YOUR_FAX = "Факс:" +LOGIN_YOUR_FIRSTNAME = "Имя:" +LOGIN_YOUR_HOUSE = "Номер дома:" +LOGIN_YOUR_LASTNAME = "Фамилия:" +LOGIN_YOUR_MAIL = "E-mail:" +LOGIN_YOUR_PHONE = "Контактный телефон:" +LOGIN_YOUR_STREET = "Улица " +LOGIN_YOUR_TOWN = "Город:" +LOGIN_YOUR_ZIP = "Почтовый индекс" [loginprocess] LOGIN_BUTTON_ENTER = "Войти" diff --git a/login/lang/ua.txt b/login/lang/ua.txt deleted file mode 100644 index a6cb99e..0000000 --- a/login/lang/ua.txt +++ /dev/null @@ -1,188 +0,0 @@ -[displayloginform] -LOGIN_NEW_REGISTER = "Реєстрація" -LOGIN_PASSWORD_REMIND = "Забули пароль?" -LOGIN_PLEASE_LOGON = "Будь ласка, авторизуйтеся, використовуючи Ваші E-Mail і Пароль" -LOGIN_REGISTER_INFO = "Реєстрація на сайті дозволить Вам одержати доступ до розділів, які дозволені для перегляду тільки зареєстрованим користувачам. Дана процедура не займе у Вас багато часу." -LOGIN_REMINDER_INFO = "Якщо Ви забули свій пароль, введіть E-mail адресу, яка була зазначена Вами при реєстрації й ми в найкоротший термін надішлем новий пароль." -LOGIN_SAVE_COOKIE = "Запам’ятати мене" -LOGIN_SAVE_ICON = "[?]" -LOGIN_SAVE_INFO = "Встановіть прапорець, якщо Ви хочете, щоб система автоматично здійснювала вхід на підставі ваших реєстраційних даних." -LOGIN_YOUR_EMAIL = "E-mail:" -LOGIN_YOUR_PASSWORD = "Пароль:" -LOGIN_LOGIN_PANEL = "Панель авторизації" -LOGIN_BUTTON_LOGIN = "Увійти" -LOGIN_AUTORIZATION = "Авторизація" - -[displaypanel] -LOGIN_ADMIN_LINK = "Панель керування" -LOGIN_CHANGE_DETAILS = "Налаштування профілю" -LOGIN_CHANGE_LINK = "Змінити пароль" -LOGIN_DELETE_LINK = "Вилучити аккаунт" -LOGIN_LOGOUT_LINK = "Вийти" -LOGIN_WELCOME_TEXT = "Доброго дня" -LOGIN_WYSIWYG_OFF = "Вимкнути редактор" -LOGIN_WYSIWYG_ON = "Ввімкнути редактор" -LOGIN_USER_PANEL = "Панель користувача" - -[loginprocess] -LOGIN_BUTTON_ENTER = "Увійти" -LOGIN_NEW_REGISTER = "Реєстрація" -LOGIN_PASSWORD = "Ваш пароль:" -LOGIN_PASSWORD_REMIND = "Забули пароль?" -LOGIN_PLEASE_LOGON = "Будь ласка, авторизуйтеся, використовуючи Ваші E-Mail і Пароль" -LOGIN_REGISTER_INFO = "Реєстрація на сайті дозволить Вам одержати доступ до розділів, які дозволені для перегляду тільки зареєстрованим користувачам. Дана процедура не займе у Вас багато часу." -LOGIN_REMINDER_INFO = "Якщо Ви забули свій пароль, введіть E-mail адресу, яка була зазначена Вами при реєстрації й ми в найкоротший термін надішлем новий пароль." -LOGIN_SAVE_COOKIE = "Запам'ятати мене" -LOGIN_SAVE_INFO = "Всстановіть прапорець, якщо Ви прагнете, щоб система автоматично здійснювала вхід на підставі ваших реєстраційних даних." -LOGIN_TEXT_FALSE_INFO = "Ви вказали невірні дані при авторизації. Будь ласка, спробуйте ще раз." -LOGIN_TEXT_TRUE_INFO = "Дякуємо. Ви успішно пройшли авторизацію." -LOGIN_YOUR_MAIL = "Логін:" -LOGIN_AUTORIZATION = "Авторизація" -LOGIN_BUTTON_LOGIN = "Увійти" - -[registernew] -LOGIN_BUTTON_FINAL = "Завершити реєстрацію" -LOGIN_BUTTON_SUBMIT = "Продовжити реєстрацію" -LOGIN_CODE_FROM_MAIL = "Код активації:" -LOGIN_DOMAIN_FALSE = "Зазначений E-Mail-Домен заблокований для реєстрації." -LOGIN_EMAIL_FALSE = "Зазначена E-mail адреса заблокована для реєстрації." -LOGIN_MAIL_CONFIRM = "Повторіть E-mail:" -LOGIN_MESSAGE_1 = "Доброго дня %NAME%,%N%Ваш аккаунт успішно створений.%N%%N%Ви можете зробити авторизацію на сайті %HOST%, з наступними даними:%N%%N%Логін: %NAME% %N%Пароль: %KENNWORT% %N%" -LOGIN_MESSAGE_2 = "Доброго дня %NAME%.%N%Вітаємо Вас із успішною реєстрацією.%N%%N%Ви можете зробити авторизацію на сайті %HOST%, з наступними даними:%N%%N%Логін: %NAME% %N%Пароль: %KENNWORT% %N%" -LOGIN_MESSAGE_3 = "%N% Зверніть увагу! Перш ніж здійснювати авторизацію, Вам необхідно підтвердити Вашу реєстрацію й Вашу E-Mail-Адресу. Будь ласка, перейдіть по посиланню, яке зазначене нижче:%N%%REGLINK% %N%Код, для активації аккаунта вручну: %CODE%" -LOGIN_MESSAGE_4 = "%N% Зверніть увагу! Ваш аккаунт буде доступний, тільки після перевірки й активації Адміністрацією сайту. Після активації Ви отримаєте повідомлення на E-mail адреса.%N%%N%%HOST%" -LOGIN_MESSAGE_5 = "Доброго дня.%N%На сайті зареєструвався новий користувач із наступними реєстраційними даними.%N%%N%Ім’я: %NAME%%N%E-mail: %EMAIL%" -LOGIN_MESSAGE_7 = "Зверніть увагу! Ваш аккаунт буде доступний, тільки після перевірки й активації Адміністрацією сайту. Після активації Ви тримаєте повідомлення на E-mail адреса." -LOGIN_MESSAGE_OK = "Реєстрація завершена! Тепер система спробує здійснити автоматичний вхід. Якщо вхід не здійснений, Ви можете самостійно ввійти з вашим Логіном і паролем." -LOGIN_MESSAGE_TEXT = "Процес реєстрації майже закінчений. Для активації Вашого аккаунта, будь ласка, укажіть код активації, який був висланий Вам в E-mail повідомленні." -LOGIN_NOT_ACTIVE = "В даний момент реєстрація користувачів тимчасово відключена." -LOGIN_PASSWORD = "Ваш пароль:" -LOGIN_REGISTER_OK = "Реєстрація успішно завершена." -LOGIN_SECURITY_CODE = "Захисний код:" -LOGIN_SECURITY_CODER = "Введіть код:" -LOGIN_SUBJECT_ADMIN = "Реєстрація нового користувача" -LOGIN_SUBJECT_USER = "Реєстраційні дані" -LOGIN_TEXT_REGISTER = "Реєстрація нового користувача" -LOGIN_THANKYOU_TEXT = "Дякуємо за реєстрацію! На Ваш E-mail відправлене повідомлення, що містить інформацію про активацію Вашого аккаунта." -LOGIN_WROND_E_SCODE = "Поле Захисний код не заповнене." -LOGIN_WROND_SCODE = "Зазначений захисний код невірний." -LOGIN_WRONG_EMAIL = "Поле E-mail зазначене в невірному форматі." -LOGIN_WRONG_EM_EMPTY = "Поле E-mail (основне) не заповнене." -LOGIN_WRONG_ER_EMPTY = "Поле E-mail (підтверджуюче) не заповнене." -LOGIN_WRONG_FN_EMPTY = "Поле Ім'я не заповнене." -LOGIN_WRONG_FIRSTNAME = "Поле Ім'я не заповнене, або містить недопустимі символи." -LOGIN_WRONG_INUSE = "Зазначена E-mail адреса вже використовується в системі." -LOGIN_WRONG_LN_EMPTY = "Поле Прізвище не заповнене." -LOGIN_WRONG_LASTNAME = "Поле Прізвище не заповнене, або містить ненопустимі символи." -LOGIN_WRONG_L_EMPTY = "Поле Логін не заповнене." -LOGIN_WRONG_LOGIN = "Поле Логін не заповнене, або містить недопустимі символи." -LOGIN_WRONG_L_INUSE = "Зазначений Вами Логін уже використовується в системі. Будь ласка, придумайте інший Логін." -LOGIN_WRONG_PASS = "Поле Пароль не заповнене." -LOGIN_WRONG_RETRY = "Зазначені E-mail адреси не збігаються." -LOGIN_WRONG_SHORT_PASS= "Довжина пароля менш 5 символів." -LOGIN_WRONG_SYM_PASS = "Пароль містить недопустимі символи." -LOGIN_YOUR_COMPANY = "Назва організації:" -LOGIN_YOUR_COUNTRY = "Країна проживання:" -LOGIN_YOUR_FIRSTNAME = "Ім'я:" -LOGIN_YOUR_LASTNAME = "Прізвище:" -LOGIN_YOUR_LOGIN = "Логін:" -LOGIN_YOUR_MAIL = "E-mail:" -LOGIN_TEXT_AUTHORIZATION = "Інформація для авторизації" -LOGIN_TEXT_USER_INFO = "Персональна інформація" - -[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_PASSWORD_RESTOR = "Ваш пароль успішно змінений." -LOGIN_REMIND = "Відновлення паролю" -LOGIN_REMINDER_INFO2 = "Будь ласка, вкажіть E-mail адресу, яка була використаний при реєстрації. На зазначений E-mail буде надіслано новий пароль." -LOGIN_REMINDER_INFO4 = "Будь ласка, вкажіть E-mail адресу" -LOGIN_REMINDER_INFO3 = "Новий пароль надісланий на зазначену E-mail адресу." -LOGIN_SUBJECT_REMINDER= "Ваш новий пароль" - -[passwordchange] -LOGIN_CHANGE_PASSWORD = "Змінити пароль" -LOGIN_EMPTY_NEW_PASS = "Ви не вказали новий пароль" -LOGIN_EMPTY_NEW_PASS_C= "Ви не вказали підтверджувальне значення для нового пароля" -LOGIN_EMPTY_OLD_PASS = "Ви не вказали поточний пароль" -LOGIN_FOUND_ERROR = "В процесі зміни параметрів виникли наступні помилки:" -LOGIN_NEW_PASSC = "Помилка! Ви не вказали підтверджувальне значення пароля." -LOGIN_NEW_PASSWORD = "Новий пароль:" -LOGIN_NEW_PASSWORD_C = "Підтвердіть пароль:" -LOGIN_NEW_PASS_EMPTY = "Помилка! Ви не вказали новий пароль." -LOGIN_OLD_PASSWORD = "Поточний пароль:" -LOGIN_OLD_PASS_EMPTY = "Помилка! Ви не вказали поточний пароль. Будь ласка, перевірте правильність введення." -LOGIN_PASSWORDS_NOEQU = "Введені паролі не збігаються. Будь ласка, перевірте правильність Введення." -LOGIN_PASSWORD_CHANGE = "Зміна поточного пароля" -LOGIN_PASSWORD_INFO = "Будь ласка, вкажіть новий пароль, який Ви будете використовувати в системі. Нагадуємо, що пароль не повинен містити спеціальних символів і пробілів! Довжина пароля повинна бути не менш 5 символів." -LOGIN_PASSWORD_OK = "Пароль успішно змінений!" -LOGIN_WRONG_EQU_PASS = "Значення нового пароля й підтверджувального не збігаються" -LOGIN_WRONG_OLD_PASS = "Поточний пароль зазначений невірно." -LOGIN_WRONG_SHORT_PASS= "Довжина пароля менша 5 символів." -LOGIN_WRONG_SYM_PASS = "Пароль містить недопустимі символи." - -[delaccount] -LOGIN_ADMIN_ACCOUNT = "Вибачте, але Ви не можете вилучити свій аккаунт, тому що Ви є Адміністратором. Будь ласка, зверніться до Головного Адміністратора сайту." -LOGIN_DELETE_ACCOUNT = "Видалення Вашого аккаунта" -LOGIN_DELETE_BUTTON = "Вилучити" -LOGIN_DELETE_CONFIRM = "Так, я згідний" -LOGIN_DELETE_INFO = "Увага! Все готове для остаточного видалення Вашого аккаунта із системи. Пам’ятайте, що вилучивши свій аккаунт, Ви втратите свій доступ до розділів сайту, дозволеним для перегляду тільки зареєстрованим користувачам. Ви впвнені, що прагнете вилучити свій аккаунт?" -LOGIN_DELETE_OK = "Ваш аккаунт успішно вилучений із системи." -LOGIN_DELETE_WARNING = "Увага!" - -[myprofile] -LOGIN_BUTTON_CHANGE = "Зберегти зміни" -LOGIN_CHANGED_OK = "Параметри профілю успішно збережені" -LOGIN_CHANGE_DETAILS = "Налаштування профілю" -LOGIN_DATE_FORMAT = "(у форматі дд.мм.рррр)" -LOGIN_DETAILS_INFO = "Налаштування профілю дозволяють керувати Вашими особистими даними. Будь ласка, заповніть поля, вказавши відповідну інформацію." -LOGIN_ERRORS = "В процесі реєстрації виникли наступні помилки:" -LOGIN_WRONG_BIRTHDAY = "Поле Дата народження не заповнене, або зазначене в невірному форматі." -LOGIN_WRONG_DATE = "Невірно зазначений День Вашого народження (ДД.ММ.РРРР)" -LOGIN_WRONG_EMAIL = "Поле E-mail зазначене в невірному форматі." -LOGIN_WRONG_FAX = "Поле Факс будинку не заповнене, або містить недопустимі символи." -LOGIN_WRONG_FN_EMPTY = "Поле Имя не заполнено." -LOGIN_WRONG_FIRSTNAME = "Поле Ім'я не заповнене, або містить недопустимі символи." -LOGIN_WRONG_HOUSE = "Поле Номер будинку не заповнене, або містить недопустимі символи." -LOGIN_WRONG_INUSE = "Зазначена E-mail адреса вже використовується в системі." -LOGIN_WRONG_LN_EMPTY = "Поле Прізвище не заповнене." -LOGIN_WRONG_LASTNAME = "Поле Прізвище не заповнене, або містить ненопустимі символи." -LOGIN_WRONG_MONTH = "Невірно зазначений Місяць Вашого народження (ДД.ММРРРР)" -LOGIN_WRONG_PHONE = "Поле Номер телефону не заповнене, або містить недопустимі символи." -LOGIN_WRONG_STREET = "Поле Вулиця не заповнене, або містить недопустимі символи." -LOGIN_WRONG_TOWN = "Поле Місто не заповнене, або містить недопустимі символи." -LOGIN_WRONG_YEAR = "Невірно зазначений Рік Вашого народження (ДД.ММ.РРРР)" -LOGIN_WRONG_ZIP = "Поле Поштовий індекс не заповнене, або містить недопустимі символи." -LOGIN_YOUR_BIRTHDAY = "Дата Вашого народження:" -LOGIN_YOUR_COMPANY = "Назва організації:" -LOGIN_YOUR_COUNTRY = "Країна проживання:" -LOGIN_YOUR_FAX = "Факс:" -LOGIN_YOUR_FIRSTNAME = "Ім'я:" -LOGIN_YOUR_HOUSE = "Номер будинку:" -LOGIN_YOUR_LASTNAME = "Прізвище:" -LOGIN_YOUR_MAIL = "E-mail:" -LOGIN_YOUR_PHONE = "Контактний телефон:" -LOGIN_YOUR_STREET = "Вулиця " -LOGIN_YOUR_TOWN = "Місто:" -LOGIN_YOUR_ZIP = "Поштовий індекс" - -[showconfig] -LOGIN_BLACK_DOMAINS = "Чорний список доменів:
Вкажіть домени, з яких заборонена реєстрація. Один домен на один рядок" -LOGIN_BLACK_EMAILS = "Чорний список E-mail:
Укажіть E-mail адреси, з яких заборонена реєстрація. Одна E-mail адреса на рядок!" -LOGIN_BUTTON_SAVE = "Зберегти зміни" -LOGIN_ENABLE_REGISTER = "Дозволити реєстрацію?" -LOGIN_MODULE_EDIT = "Налаштування модуля" -LOGIN_MODULE_INFO = "У даному розділі Ви можете виконати налаштування модуля відповідно до необхідних параметрів, а також визначити списки доменних імен і e-mail адрес, які будуть заборонені при реєстрації на сайті." -LOGIN_MODULE_NAME = "Керування модулем  > Авторизація" -LOGIN_NO = "Ні" -LOGIN_REGISTRATION_TYPE = "Тип реєстрації:" -LOGIN_SHOW_COMPANY = "Показувати поле Організація?" -LOGIN_SHOW_FIRSTNAME = "Показувати поле Ім'я?" -LOGIN_SHOW_LASTNAME = "Показувати поле Прізвище?" -LOGIN_TYPE_BYADMIN = "Після підтвердження Aдмінистратором" -LOGIN_TYPE_BYEMAIL = "Після підтвердження через E-mail" -LOGIN_TYPE_NOW = "Відразу ж, після реєстрації" -LOGIN_USE_SCODE = "Використовувати захисний код?" -LOGIN_YES = "Так" diff --git a/login/module.php b/login/module.php index 8ad1159..038c9d6 100644 --- a/login/module.php +++ b/login/module.php @@ -1,218 +1,132 @@ identity='loginza_'.md5(trim($auth_data->identity)); - - if( isset( $auth_data->error_type ) || isset( $auth_data->error_message ) ) - return false; - //var_dump($auth_data); - $user_id=$AVE_DB->Query("SELECT * FROM ".PREFIX."_users where user_name='".$auth_data->identity."' LIMIT 1")->FetchRow(); - //die(); - if($user_id) { - user_login($auth_data->identity,''); - header('Location:' . rewrite_link($_SESSION['referer'])); - unset($_SESSION['referer']); - exit; - } - //Если у юзера есть фотовка - то делаем из нее аватарку - //лежать все будет в avatar_dir - //получить наличие аватарки мона путем md5($user_login) - if($auth_data->photo){ - $avatar=CURL_file_get_contents($auth_data->photo); - $avatar_dir=BASE_DIR.'/uploads/avatars'; - if(!file_exists($avatar_dir))mkdir($avatar_dir,0777,true); - if($avatar){ - $im = imagecreatefromstring($avatar); - if ($im !== false) { - imagejpeg($im,$avatar_dir.'/'.md5($auth_data->identity).'.jpg'); - } - } - } - //тут подставляем данные для последующей регистрации - $_POST['user_name']=$auth_data->identity; - $_POST['reg_email']=isset( $auth_data->email ) && $auth_data->email ? $auth_data->email : ''; - $fname=isset( $auth_data->name->full_name ) && $auth_data->name->full_name ? $auth_data->name->full_name : ''; - $fname=explode(' ',$fname); - $_POST['reg_firstname']=isset( $auth_data->name->first_name ) && $auth_data->name->first_name ? $auth_data->name->first_name : @$fname[0]; - $_POST['reg_lastname']=isset( $auth_data->name->last_name ) && $auth_data->name->last_name ? $auth_data->name->last_name : @$fname[1]; - $_REQUEST['action']='register'; - $_REQUEST['sub']='register'; - //Надо кудато положить флажок - что зашли через логинзу - $_SESSION['loginza_auth']=1; - //Тут на всякий случай похраним инфу о юзвере - $_SESSION['loginza_data']=$auth_data; - return $auth_data; -} - -/** - * Обработка тега модуля - * - */ -function mod_login() -{ - global $AVE_DB, $AVE_Template; - - $tpl_dir = BASE_DIR . '/modules/login/templates/'; - $lang_file = BASE_DIR . '/modules/login/lang/' . $_SESSION['user_language'] . '.txt'; - - if (isset($_SESSION['user_id']) && isset($_SESSION['user_pass'])) + function mod_login () { - $AVE_Template->config_load($lang_file, 'displaypanel'); + global $AVE_Template; - $AVE_Template->display($tpl_dir . 'userpanel.tpl'); - } - else - { - $AVE_Template->config_load($lang_file, 'displayloginform'); + require_once(BASE_DIR . '/modules/login/class/login.php'); - $active = $AVE_DB->Query(" - SELECT login_status - FROM " . PREFIX . "_module_login - WHERE Id = 1 - ")->GetCell(); + new Login; - $AVE_Template->assign('active', $active); + // Если прошли по ссылке, для показа формы, убираем вывод тега + if (isset($_REQUEST['module']) && $_REQUEST['module'] == 'login' && $_REQUEST['action'] == 'form') + return false; - $AVE_Template->display($tpl_dir . 'loginform.tpl'); - } -} + $tpl_dir = BASE_DIR . '/modules/login/public/'; + $lang_file = BASE_DIR . '/modules/login/lang/' . $_SESSION['user_language'] . '.txt'; + if (isset($_SESSION['user_id']) && isset($_SESSION['user_pass'])) + { + $avatar = getAvatar($_SESSION['user_id'],180); -if (!defined('ACP') && - !empty($_REQUEST['action']) && - isset($_REQUEST['module']) && $_REQUEST['module'] == 'login') -{ - global $login; + $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'); - loginza_check_token(); + $AVE_Template->config_load($lang_file, 'loginform'); + $AVE_Template->assign('active', $active); + $AVE_Template->display($tpl_dir . 'form.tpl'); + } - //die(); - if (isset($_REQUEST['print']) && $_REQUEST['print'] == 1) print_error(); + return true; + } - $tpl_dir = BASE_DIR . '/modules/login/templates/'; - $lang_file = BASE_DIR . '/modules/login/lang/' . $_SESSION['user_language'] . '.txt'; - if (! @require(BASE_DIR . '/modules/login/class/login.php')) module_error(); + //======================================================= + // Public functions + //======================================================= + if (! defined('ACP') && isset($_REQUEST['module']) && $_REQUEST['module'] == 'login' && ! empty($_REQUEST['action'])) + { + require_once(BASE_DIR . '/modules/login/class/login.php'); - $login = new Login($tpl_dir, $lang_file); + new Login; - switch($_REQUEST['action']) - { - case 'wys': - if (isset($_REQUEST['sub']) && $_REQUEST['sub'] == 'on') - { - if (check_permission('documents')) $_SESSION['user_adminmode'] = 1; - } - else - { - unset($_SESSION['user_adminmode']); - } + Login::$_tpl_dir = BASE_DIR . '/modules/login/public/'; - header('Location:' . get_referer_link()); - exit; + Login::$_lang_file = BASE_DIR . '/modules/login/lang/' . $_SESSION['user_language'] . '.txt'; - case 'wys_adm': - if (isset($_REQUEST['sub']) && $_REQUEST['sub'] == 'on') - { - if (check_permission('documents')) $_SESSION['user_adminmode'] = 1; - } - else - { - unset($_SESSION['user_adminmode']); - } + switch ($_REQUEST['action']) + { + case 'form': + Login::form(); + break; - header('Location:' . get_home_link()); - exit; + case 'authorize': + Login::authorize(); + break; - case 'login': - $login->loginUserLogin(); - break; + case 'logout': + Login::logout(); + break; - case 'logout': - $login->loginUserLogout(); - break; + case 'register': + Login::register(); + break; - case 'register': - $login->loginNewUserRegister(); - break; + case 'reminder': + Login::reminder(); + break; - case 'passwordreminder': - $login->loginUserPasswordReminder(); - break; + case 'change': + Login::change(); + break; - case 'passwordchange': - $login->loginUserPasswordChange(); - break; + case 'delete': + Login::delete(); + break; - case 'delaccount': - $login->loginUserAccountDelete(); - break; + case 'profile': + Login::profile(); + break; - case 'profile': - $login->loginUserProfileEdit(); - break; + case 'info': + Login::info(); + break; - case 'checkusername': - $login->loginUsernameAjaxCheck(); - break; + case 'checkusername': + Login::checkusername(); + break; - case 'checkemail': - $login->loginEmailAjaxCheck(); - break; - case 'userinfo': - $login->loginUserInfo(intval($_REQUEST['user'])); - break; + case 'checkemail': + Login::checkemail(); + break; + } } -} -if (defined('ACP') && !empty($_REQUEST['moduleaction'])) -{ - global $login; + //======================================================= + // The control module in the admin panel + //======================================================= + if ( + defined('ACP') + && (isset($_REQUEST['moduleaction']) && !empty($_REQUEST['moduleaction'])) + && (isset($_REQUEST['mod']) && $_REQUEST['mod'] == 'login') + ) + { + require_once(BASE_DIR . '/modules/login/class/login.php'); - $tpl_dir = BASE_DIR . '/modules/login/templates/'; - $lang_file = BASE_DIR . '/modules/login/lang/' . $_SESSION['admin_language'] . '.txt'; + new Login; - if (! @require(BASE_DIR . '/modules/login/class/login.php')) module_error(); + Login::$_tpl_dir = BASE_DIR . '/modules/login/admin/'; - $login = new Login($tpl_dir, $lang_file); + $lang_file = BASE_DIR . '/modules/login/lang/' . $_SESSION['admin_language'] . '.txt'; - switch($_REQUEST['moduleaction']) - { - case '1': - $login->loginSettingsEdit(); - break; + $AVE_Template->config_load($lang_file, 'showconfig'); + $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars()); + + switch($_REQUEST['moduleaction']) + { + case '1': + Login::admin(); + break; + } } -} ?> \ No newline at end of file diff --git a/login/templates/password_change.tpl b/login/public/change.tpl similarity index 96% rename from login/templates/password_change.tpl rename to login/public/change.tpl index 340e00b..ceb3dbe 100644 --- a/login/templates/password_change.tpl +++ b/login/public/change.tpl @@ -37,7 +37,7 @@ function check_password() {ldelim}

{#LOGIN_PASSWORD_OK#}

{else} -
+

{#LOGIN_PASSWORD_INFO#}

diff --git a/login/templates/delete_account.tpl b/login/public/delete.tpl similarity index 91% rename from login/templates/delete_account.tpl rename to login/public/delete.tpl index b1ecb43..6af42af 100644 --- a/login/templates/delete_account.tpl +++ b/login/public/delete.tpl @@ -16,9 +16,9 @@
{else} - +