Advertisement
Guest User

Untitled

a guest
May 17th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.73 KB | None | 0 0
  1. <?php
  2. /*Config*/
  3.  
  4. $realmd = array(
  5. 'db_host'=> 'localhost', //ip of db realm
  6. 'db_username' => 'root',//realm user
  7. 'db_password' => 'root',//realm password
  8. 'db_name'=> 'realmd',//realm db name
  9. );
  10.  
  11.  
  12. ///////////////Start script//////////////////
  13.  
  14. /*
  15. Function name: CHECK FOR SYMBOLS
  16. Description: return TRUE if matches. ( True = OK ) ( False = NOT OK)
  17. */
  18. function check_for_symbols($string){
  19. $len=strlen($string);
  20. $alowed_chars="abcdefghijklmnopqrstuvwxyzæøåABCDEFGHIJKLMNOPQRSTUVWXYZÆØÅ";
  21. for($i=0;$i<$len;$i++)if(!strstr($alowed_chars,$string[$i]))return TRUE;
  22. return FALSE;
  23.  
  24. }
  25. /*
  26. Function name: OUTPUT USERNAME:PASSWORD AS SHA1 crypt
  27. Description: obious.
  28. */
  29. function sha_password($user,$pass){
  30. $user = strtoupper($user);
  31. $pass = strtoupper($pass);
  32.  
  33. return SHA1($user.':'.$pass);
  34. }
  35.  
  36. if ($_POST['registration']){
  37. /*Connect and Select*/
  38. $realmd_bc_new_connect = mysql_connect($realmd[db_host],$realmd[db_username],$realmd[db_password]);
  39. $selectdb = mysql_select_db($realmd[db_name],$realmd_bc_new_connect);
  40. if (!$realmd_bc_new_connect || !$selectdb){
  41. echo "Could NOT connect to db, please check the config part of the file!";
  42. die;
  43. }
  44.  
  45. /*Checks*/
  46. $username = $_POST['username'];
  47. $password =$_POST['password'];
  48. $password2 =$_POST['password2'];
  49. $email = $_POST['email'];
  50.  
  51. if ($username==NULL | $password==NULL | $password2==NULL | $email==NULL){
  52. echo "Some empty field.";
  53. echo "Try again.";
  54. }
  55. else{
  56. // ¿Same pass?
  57. if ($password!=$password2) {
  58. echo "Pass not match";
  59. }
  60. else
  61. {
  62. $qry_check_username = mysql_query("SELECT username FROM `account` WHERE username='$username'");
  63.  
  64. if (check_for_symbols($_POST[password]) == TRUE || check_for_symbols($username) == TRUE || mysql_num_rows($qry_check_username) != 0)
  65. {
  66. echo "Error with creating account, might already be in use or your username / password has invalid symbols in it.";
  67. }
  68. else
  69. {
  70. $password = sha_password($username,$_POST['password']);
  71.  
  72. mysql_query("INSERT INTO account (username,sha_pass_hash,email) VALUES ('$username', '$password', '$email)");
  73.  
  74. echo "Account created.";
  75. }
  76.  
  77.  
  78. }else{
  79. ///////////////Stop script, Start HTML//////////////////
  80. ?><title>FlameWoW Register Page ::: Enjoy Your Stay :::</title>
  81.  
  82.  
  83. <form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="POST">
  84. <p align="center">Username
  85. <input type="text" name="username">
  86. </p>
  87. <p align="center">Password
  88. <input type="password" name="password">
  89. </p>
  90. <p align="center">Retype Password
  91. <input type="password2" name="password2">
  92. </p>
  93. <p align="center">E-mail :
  94. <input type="email" name="email">
  95. </p>
  96. <p align="center">
  97.  
  98. <input type="submit" name="registration">
  99. </p>
  100. </form>
  101.  
  102.  
  103. <?php
  104. // Do not remove this;)
  105. }
  106. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement