Guest User

Untitled

a guest
Jun 20th, 2018
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.46 KB | None | 0 0
  1. <?php
  2.  
  3. include "trunk/lagranj/config.php";
  4.  
  5. error_reporting (0);
  6.  
  7. $database_encoding = 'utf8';
  8.  
  9. $tbc = 2;
  10.  
  11. $realmd = mysql_connect("$host:$port", "$user", "$pass", True);
  12.  
  13. mysql_selectdb("$db1", $realmd);
  14.  
  15. ?>
  16.  
  17. <font color=#00CC00>
  18.  
  19. </font>
  20.  
  21. <center>
  22.  
  23. <form method=post action=reg.php onsubmit=\"return checkform(this)\">
  24.  
  25.     <th scope='col'><center>
  26.  
  27. <script type="text/javascript">
  28.  
  29. function isAlphaNumeric(value)
  30.  
  31. {
  32.  
  33.   if (value.match(/^[a-zA-Z0-9_]+$/))
  34.  
  35.     return true;
  36.  
  37.   return false;
  38.  
  39. }
  40.  
  41. function checkform(f)
  42.  
  43. {
  44.  
  45.   if (f.account.value == "")
  46.  
  47.   {
  48.  
  49.     alert("Введите логин");
  50.  
  51.     return false;
  52.  
  53.   }
  54.  
  55.   if (!isAlphaNumeric(f.account.value))
  56.  
  57.   {
  58.  
  59.     alert("Запрещенные символы в логине");
  60.  
  61.     return false;
  62.  
  63.   }
  64.  
  65.   if (f.password.value=="")
  66.  
  67.   {
  68.  
  69.     alert("Введите пароль");
  70.  
  71.     return false;
  72.  
  73.   }
  74.  
  75.   if (!isAlphaNumeric(f.password.value))
  76.  
  77.   {
  78.  
  79.     alert("Запрещенные символы в пароле");
  80.  
  81.     return false;
  82.  
  83.   }
  84.  
  85.   if (f.password2.value=="")
  86.  
  87.   {
  88.  
  89.     alert("Введите повтор пароля");
  90.  
  91.     return false;
  92.  
  93.   }
  94.  
  95.   if (f.password.value != f.password2.value)
  96.  
  97.   {
  98.  
  99.     alert("Пароли не совпадают!");
  100.  
  101.     return false;
  102.  
  103.   }
  104.  
  105.   if (f.email.value=="")
  106.  
  107.   {
  108.  
  109.     alert("Вы не ввели e-mail");
  110.  
  111.     return false;
  112.  
  113.   }
  114.  
  115.   if (f.keystring.value == "")
  116.  
  117.   {
  118.  
  119.     alert("Введите проверочный код");
  120.  
  121.     return false;
  122.  
  123.   }
  124.  
  125.   if (!isAlphaNumeric(f.keystring.value))
  126.  
  127.   {
  128.  
  129.     alert("Неправильно введен проверочный код");
  130.  
  131.     return false;
  132.  
  133.   }
  134.  
  135. }
  136.  
  137. </script>
  138.  
  139.                   <table><tr>
  140.  
  141.                   <td><LABEL for=account>Имя Аккаунта:</LABEL></td><td><INPUT id=account style="WIDTH: 175px" tabIndex="1" maxLength="12" size="18" name="account"></td>
  142.  
  143.                   </tr><tr>
  144.  
  145. <td><LABEL for=password>Пароль:</LABEL></td><td><INPUT id="password" style="WIDTH: 175px" tabIndex=2 type=password maxLength=12 size=18 name="password"></td>
  146.  
  147. </tr><tr>
  148.  
  149. <td><LABEL for=password2>Повтор Пароля:</LABEL></td><td><INPUT id='password' style='WIDTH: 175px' tabIndex=2 type=password maxLength=12 size=18 name='password2'></td>
  150.  
  151. </tr><tr>
  152.  
  153. <td><LABEL for=email>E-mail:</LABEL></td><td><INPUT id=email style="WIDTH: 175px" tabIndex=2 maxLength=50 size=18 name=email></td>
  154.  
  155. </tr><tr>
  156.  
  157. <td><LABEL action="" method="post" for=keystring><img src="./captcha/?<?php echo session_name()?>=<?php echo session_id()?>"></LABEL></td><td><input type="text" id=keystring style="WIDTH: 175px" tabIndex=2 maxLength=50 size=18 name="keystring"></td>
  158.  
  159. </tr><tr></table>
  160.  
  161. <br />
  162.  
  163. <input type="submit" name="submit" value="Готово" />
  164.    
  165. </th>
  166.  
  167. <?php
  168.  
  169. if (isset($_POST['account'])) {
  170.  
  171. if ($_POST['account'] && strlen($_POST['account'])<=20 && strlen($_POST['account'])>=3 && strlen($_POST['password'])>=3 && $_POST['password'] && $_POST['password2'] && $_POST['password']==$_POST['password2']) {
  172.  
  173.   if (!eregi("^[a-zA-Z0-9_]+$", $_POST['account']))
  174.  
  175.     die ("<p>Error: SQL-Injection</p>");
  176.  
  177.   if (!eregi("^[a-zA-Z0-9_]+$", $_POST['password']))
  178.  
  179.     die ("<p>Error: SQL-Injection</p>");
  180.  
  181.     $pass = ($_POST['password']);
  182.  
  183.     $username = ($_POST['account']);
  184.  
  185.     $result = mysql_query("SELECT * FROM account WHERE username='".$_POST['account']."'", $realmd);
  186.  
  187.     if (mysql_num_rows($result) != 0) {
  188.  
  189.         echo "<center><p><font color=#CC0000><b>Такой аккаунт уже существует!</b></font></p></center>";
  190.  
  191.     } else {
  192.  
  193.         if (!mysql_query("INSERT INTO account (username, sha_pass_hash, email, expansion) VALUES ('$username', SHA1(CONCAT(UPPER('$username'),':',UPPER('$pass')) ), '".$_POST['email']."', $tbc)", $realmd)) {echo "<center><p><font color=#CC0000><b>Ошибка</b></font></p></center>";} else {echo "<center><p><font color=#00CC00><b>Аккаунт успешно зарегистрирован!</b></font></p></center>";}
  194.  
  195.     }
  196.  
  197. } else {
  198.  
  199.     echo "<center><p><font color=#CC0000><b>Проверьте правильность ввода!</b></font></p></center>";
  200.  
  201. }
  202.  
  203. if(count($_POST)>0){
  204.  
  205.     if(isset($_SESSION['captcha_keystring']) && $_SESSION['captcha_keystring'] === $_POST['keystring']){
  206.  
  207.         echo "Correct";
  208.  
  209.     }else{
  210.  
  211.         echo "Wrong";
  212.  
  213.     }
  214.  
  215. }
  216.  
  217. unset($_SESSION['captcha_keystring']);
  218.  
  219. }
  220.  
  221. ?>
Add Comment
Please, Sign In to add comment