Размер файла: 7.01Kb
- <?
- /*
- =============================================
- Движок: SHCMS Engine
- =============================================
- Название файла: Регистрация
- =============================================
- Official website: http://shcms.ru
- =============================================
- */
-
- define('SHCMS', true);
- include_once'../system/inc/basic_settings.php';
- if(isset($user_id))
- {
- header("Refresh:1; url=/index.php");
- exit();
- }
- $t = mysql_fetch_array(mysql_query("SELECT * FROM settings_shcms"));
- if(!$t['act_reg']){$shcmsengine['title'] = 'Регистрация отключена';}
- else
- {$shcmsengine['title'] = 'Регистрация нового пользователя';}
- include_once'../template/head.php';
- if (!$t['act_reg']) {echo '<p class="errors">Регистрация временно отключена.</p>';
- include_once'../template/foot.php';
- exit;
- }
-
- $reg_cap =mysql_query("SELECT captcha_reg FROM settings_shcms");
- $reg_cap2 = mysql_fetch_array($reg_cap);
-
- if(isset($user_id))
- {
- header("Refresh: 1; url=/index.php");
- exit();
- }
-
- $regi = mysql_fetch_array(mysql_query("SELECT * FROM users"));
- if(isset($_POST['submit'])){$submit = $_POST['submit']; if($submit==''){unset($submit);}}
- if(isset($_POST['login'])){$reg_login = $_POST['login']; if($reg_login==''){unset($reg_login);}}
- if(isset($_POST['password'])){$reg_password = $_POST['password'];if($reg_password == ''){unset($reg_password);}}
- if(isset($_POST['email'])){$email = $_POST['email'];}
- if(isset($_POST['pol'])){$pol = $_POST['pol'];}
-
- if(isset($submit))
- {
- $reg_login = stripslashes($reg_login);
- $reg_password = stripslashes($reg_password);
- $email = stripslashes($email);
- $reg_login = htmlspecialchars($reg_login);
- $reg_password = htmlspecialchars($reg_password);
- $email = htmlspecialchars($email);
- $reg_login = trim($reg_login);
- $reg_password = trim($reg_password);
- $email = trim($email);
-
- $date = date('d.m.Y');
- if(empty($reg_login))
- {
- echo '<div class="errors">Вы не ввели логин!</div>';
- include_once'../template/foot.php';
- exit();
- }
- elseif (mb_strlen($reg_login) < 2 || mb_strlen($reg_login) > 20)
- {
- echo '<div class="errors">Длина вашего логина должна быть не менее 2 символов!</div>';
- include_once'../template/foot.php';
- exit();
- }
- if(empty($reg_password))
- echo '<div class="errors">Вы не ввели пороль!</div>';
- elseif(mb_strlen($reg_password) < 5 or mb_strlen($reg_password) > 30)
- {
- echo '<div class="errors">Длина пароля должна быть не менее 5 символов!</div>';
- include_once'../template/foot.php';
- exit();
- }
- //Проверка логина
- if (!preg_match("#^([A-z0-9\-\_\ ])+$#ui", $reg_login))
- {
- echo '<div class="errors">В логине которую вы ввели присутствуют недопустимые символы!</div>';
- include_once'../template/foot.php';
- exit();
- }
- if (preg_match("/[^\da-zA-Z_]+/", $reg_password))
- {
- echo '<div class="errors">В пороле которую вы ввели присутствуют недопустимые символы!</div>';
- header('Refresh: 1; url=?' . $conservation . '&' );
- include_once'../template/foot.php';
- exit();
- }
- $req = mysql_query("SELECT * FROM `users` WHERE `login`='" . $mySQL->safesql($reg_login) . "';");
- if ($mySQL->num_rows($req) != 0) {
- echo '<div class="errors">Выбранный вами логин ('.$reg_login.') уже зарегистрировал другой пользователь</div>';
- include_once'../template/foot.php';
- exit();
- }
- else
- {
- echo '<div class="actshcms">Логин ('.$reg_login.') свободен и доступен для регистрации.</div>';
- }
-
- if(empty($reg_login) or empty($reg_password))
- {
- exit("Введите все данные");
- }
-
- if($reg_cap2['captcha_reg'] == 1)
- {
- $antibot = isset($_POST['kod']) ? trim($_POST['kod']) : '';
- if (empty($antibot) || strlen($antibot) < 3)
- {
- echo '<div class="errors">Код безопастности не введен!</div>';
- header('Refresh: 1; url=?' . $conservation . '&' );
- include_once'../template/foot.php';
- exit(); }
- elseif ($antibot != $_SESSION['code'])
- { echo '<div class="errors">Код безопасности не соответствует отображённому</div>';
- header('Refresh: 1; url=?' . $conservation . '&' );
- include_once'../template/foot.php';
- exit();
- }
- unset($_SESSION['code']);
- }
-
- if(isset($reg_login) && isset($reg_password))
- {
- $pass = md5(md5($reg_password));
- $ok_table = mysql_query("INSERT INTO users (login,password,datereg,ip,email,pol) VALUES ('$reg_login','$pass','$time_date','$vi_shcms','$email','$pol')");
- if($ok_table == true)
- {
- echo '<div class="link_reg">Вы успешно зарегистрировались на сайте '.$_SERVER['HTTP_HOST'].'<br/><br/><a href="http://'.$_SERVER['HTTP_HOST'].''.DIR_SHCMS.'authorization.php">Войти на сайт</a></div>';
- include_once'../template/foot.php';
- exit();
-
- }
- else
- {
- echo 'Ошибка регистрации';
- }
- }
-
-
-
- }
-
-
- echo '<form action="?'.$conservation.'" method="post">';
- echo 'Логин: <small>[A-z 0-9 -_];</small><br/><input type="text" name="login" maxlength="20" value="'.$reg_login.'"><br/>';
- echo 'Пороль: <small>[5-30];</small><br/><input type="password" maxlength="30" name="password" value="'.$reg_password.'"><br/>';
- echo'Ваш пол:<br/> <select name="pol">';
- echo '<option value="1"'.((isset($regi['pol']) and $regi['pol'] == 1)?" selected='selected'":null).'>Мужской</option>';
- echo '<option value="2"'.((isset($regi['pol']) and $regi['pol'] == 2)?" selected='selected'":null).'>Женский</option>';
- echo '</select><br/>';
- echo 'Эл.почта: <br/><input type="text" name="email" maxlength="30" ><br/>';
- if($reg_cap2['captcha_reg'] == 1)
- {
- ?>
- <script type="text/javascript">
- src="/shcms/antibot.php?r=rand(1000,9999)";
- function reload(){
- document.captcha.src="/shcms/antibot.php?r=rand(1000,9999)";
- document.captcha.src=src+"?rand="+Math.random();
- }
- </script>
- <?
-
-
- echo '<img name="captcha" class="midside" alt="Включите эту картинку для отображения кода безопасности" src="'.DIR_SHCMS.'antibot.php?r=' . rand(1000, 9999) . ' "/><br />';
- ?><a href="javascript:void(0)" onclick="reload()">обновить, если не виден код</a><br/><?
- echo '<input type="text" style="width:115px" size="5" maxlength="5" name="kod"/><br/>';
- }
- if (mysql_num_rows($req) != 0)
- {
- echo '<input type="submit" value="Смена логина">';
- }
- else
- {
- echo '<input type="submit" name="submit"">';
- }
- echo '</form>';
-
- echo '<small>* В логине доступны только английские символы.</small><br/>';
-
-
- include_once'../template/foot.php';
- ?>