Просмотр файла shcms/registration.php

Размер файла: 7.01Kb
  1. <?
  2. /*
  3. =============================================
  4. Движок: SHCMS Engine
  5. =============================================
  6. Название файла: Регистрация
  7. =============================================
  8. Official website: http://shcms.ru
  9. =============================================
  10. */
  11.  
  12. define('SHCMS', true);
  13. include_once'../system/inc/basic_settings.php';
  14. if(isset($user_id))
  15. {
  16. header("Refresh:1; url=/index.php");
  17. exit();
  18. }
  19. $t = mysql_fetch_array(mysql_query("SELECT * FROM settings_shcms"));
  20. if(!$t['act_reg']){$shcmsengine['title'] = 'Регистрация отключена';}
  21. else
  22. {$shcmsengine['title'] = 'Регистрация нового пользователя';}
  23. include_once'../template/head.php';
  24. if (!$t['act_reg']) {echo '<p class="errors">Регистрация временно отключена.</p>';
  25. include_once'../template/foot.php';
  26. exit;
  27. }
  28.  
  29. $reg_cap =mysql_query("SELECT captcha_reg FROM settings_shcms");
  30. $reg_cap2 = mysql_fetch_array($reg_cap);
  31.  
  32. if(isset($user_id))
  33. {
  34. header("Refresh: 1; url=/index.php");
  35. exit();
  36. }
  37.  
  38. $regi = mysql_fetch_array(mysql_query("SELECT * FROM users"));
  39. if(isset($_POST['submit'])){$submit = $_POST['submit']; if($submit==''){unset($submit);}}
  40. if(isset($_POST['login'])){$reg_login = $_POST['login']; if($reg_login==''){unset($reg_login);}}
  41. if(isset($_POST['password'])){$reg_password = $_POST['password'];if($reg_password == ''){unset($reg_password);}}
  42. if(isset($_POST['email'])){$email = $_POST['email'];}
  43. if(isset($_POST['pol'])){$pol = $_POST['pol'];}
  44.  
  45. if(isset($submit))
  46. {
  47. $reg_login = stripslashes($reg_login);
  48. $reg_password = stripslashes($reg_password);
  49. $email = stripslashes($email);
  50. $reg_login = htmlspecialchars($reg_login);
  51. $reg_password = htmlspecialchars($reg_password);
  52. $email = htmlspecialchars($email);
  53. $reg_login = trim($reg_login);
  54. $reg_password = trim($reg_password);
  55. $email = trim($email);
  56.  
  57. $date = date('d.m.Y');
  58. if(empty($reg_login))
  59. {
  60. echo '<div class="errors">Вы не ввели логин!</div>';
  61. include_once'../template/foot.php';
  62. exit();
  63. }
  64. elseif (mb_strlen($reg_login) < 2 || mb_strlen($reg_login) > 20)
  65. {
  66. echo '<div class="errors">Длина вашего логина должна быть не менее 2 символов!</div>';
  67. include_once'../template/foot.php';
  68. exit();
  69. }
  70. if(empty($reg_password))
  71. echo '<div class="errors">Вы не ввели пороль!</div>';
  72. elseif(mb_strlen($reg_password) < 5 or mb_strlen($reg_password) > 30)
  73. {
  74. echo '<div class="errors">Длина пароля должна быть не менее 5 символов!</div>';
  75. include_once'../template/foot.php';
  76. exit();
  77. }
  78. //Проверка логина
  79. if (!preg_match("#^([A-z0-9\-\_\ ])+$#ui", $reg_login))
  80. {
  81. echo '<div class="errors">В логине которую вы ввели присутствуют недопустимые символы!</div>';
  82. include_once'../template/foot.php';
  83. exit();
  84. }
  85. if (preg_match("/[^\da-zA-Z_]+/", $reg_password))
  86. {
  87. echo '<div class="errors">В пороле которую вы ввели присутствуют недопустимые символы!</div>';
  88. header('Refresh: 1; url=?' . $conservation . '&' );
  89. include_once'../template/foot.php';
  90. exit();
  91. }
  92. $req = mysql_query("SELECT * FROM `users` WHERE `login`='" . $mySQL->safesql($reg_login) . "';");
  93. if ($mySQL->num_rows($req) != 0) {
  94. echo '<div class="errors">Выбранный вами логин ('.$reg_login.') уже зарегистрировал другой пользователь</div>';
  95. include_once'../template/foot.php';
  96. exit();
  97. }
  98. else
  99. {
  100. echo '<div class="actshcms">Логин ('.$reg_login.') свободен и доступен для регистрации.</div>';
  101. }
  102. if(empty($reg_login) or empty($reg_password))
  103. {
  104. exit("Введите все данные");
  105. }
  106. if($reg_cap2['captcha_reg'] == 1)
  107. {
  108. $antibot = isset($_POST['kod']) ? trim($_POST['kod']) : '';
  109. if (empty($antibot) || strlen($antibot) < 3)
  110. {
  111. echo '<div class="errors">Код безопастности не введен!</div>';
  112. header('Refresh: 1; url=?' . $conservation . '&' );
  113. include_once'../template/foot.php';
  114. exit(); }
  115. elseif ($antibot != $_SESSION['code'])
  116. { echo '<div class="errors">Код безопасности не соответствует отображённому</div>';
  117. header('Refresh: 1; url=?' . $conservation . '&' );
  118. include_once'../template/foot.php';
  119. exit();
  120. }
  121. unset($_SESSION['code']);
  122. }
  123. if(isset($reg_login) && isset($reg_password))
  124. {
  125. $pass = md5(md5($reg_password));
  126. $ok_table = mysql_query("INSERT INTO users (login,password,datereg,ip,email,pol) VALUES ('$reg_login','$pass','$time_date','$vi_shcms','$email','$pol')");
  127. if($ok_table == true)
  128. {
  129. echo '<div class="link_reg">Вы успешно зарегистрировались на сайте '.$_SERVER['HTTP_HOST'].'<br/><br/><a href="http://'.$_SERVER['HTTP_HOST'].''.DIR_SHCMS.'authorization.php">Войти на сайт</a></div>';
  130. include_once'../template/foot.php';
  131. exit();
  132. }
  133. else
  134. {
  135. echo 'Ошибка регистрации';
  136. }
  137. }
  138. }
  139.  
  140. echo '<form action="?'.$conservation.'" method="post">';
  141. echo 'Логин: <small>[A-z 0-9 -_];</small><br/><input type="text" name="login" maxlength="20" value="'.$reg_login.'"><br/>';
  142. echo 'Пороль: <small>[5-30];</small><br/><input type="password" maxlength="30" name="password" value="'.$reg_password.'"><br/>';
  143. echo'Ваш пол:<br/> <select name="pol">';
  144. echo '<option value="1"'.((isset($regi['pol']) and $regi['pol'] == 1)?" selected='selected'":null).'>Мужской</option>';
  145. echo '<option value="2"'.((isset($regi['pol']) and $regi['pol'] == 2)?" selected='selected'":null).'>Женский</option>';
  146. echo '</select><br/>';
  147. echo 'Эл.почта: <br/><input type="text" name="email" maxlength="30" ><br/>';
  148. if($reg_cap2['captcha_reg'] == 1)
  149. {
  150. ?>
  151. <script type="text/javascript">
  152. src="/shcms/antibot.php?r=rand(1000,9999)";
  153. function reload(){
  154. document.captcha.src="/shcms/antibot.php?r=rand(1000,9999)";
  155. document.captcha.src=src+"?rand="+Math.random();
  156. }
  157. </script>
  158. <?
  159. echo '<img name="captcha" class="midside" alt="Включите эту картинку для отображения кода безопасности" src="'.DIR_SHCMS.'antibot.php?r=' . rand(1000, 9999) . ' "/><br />';
  160. ?><a href="javascript:void(0)" onclick="reload()">обновить, если не виден код</a><br/><?
  161. echo '<input type="text" style="width:115px" size="5" maxlength="5" name="kod"/><br/>';
  162. }
  163. if (mysql_num_rows($req) != 0)
  164. {
  165. echo '<input type="submit" value="Смена логина">';
  166. }
  167. else
  168. {
  169. echo '<input type="submit" name="submit"">';
  170. }
  171. echo '</form>';
  172.  
  173. echo '<small>* В логине доступны только английские символы.</small><br/>';
  174.  
  175.  
  176. include_once'../template/foot.php';
  177. ?>