Advertisement
Guest User

Untitled

a guest
May 17th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 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 = sha_password($username,$_POST['password']);
  48.  
  49. $qry_check_username = mysql_query("SELECT username FROM `account` WHERE username='$username'");
  50.  
  51. if (check_for_symbols($_POST[password]) == TRUE || check_for_symbols($username) == TRUE || mysql_num_rows($qry_check_username) != 0){
  52. echo "Error with creating account, might already be in use or your username / password has invalid symbols in it.";
  53. }else{
  54. mysql_query("INSERT INTO account (username,sha_pass_hash) VALUES
  55. ('$username','$password')");// Insert into database.
  56. echo "Account created.";
  57. }
  58.  
  59.  
  60. }else{
  61. ///////////////Stop script, Start HTML//////////////////
  62. ?><style type="text/css">
  63. <!--
  64. body {
  65. background-color: #000000;
  66. }
  67. .style1 {color: #999900}
  68. .style2 {
  69. color: #996600;
  70. font-style: italic;
  71. font-weight: bold;
  72. font-size: 24px;
  73. }
  74. -->
  75. </style><title>FlameWoW Register Page</title>
  76.  
  77.  
  78. <form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="POST">
  79. <p align="center"><span class="style1">Username</span>
  80. <input type="text" name="username">
  81. </p>
  82. <p align="center"><span class="style1">Password</span>
  83. <input type="password" name="password">
  84. </p>
  85. <p align="center">
  86.  
  87. <input name="registration" type="submit" value="Register">
  88. </p>
  89. <p align="center" class="style2">set realmlist logon.flame-wow.org</p>
  90. </form>
  91.  
  92.  
  93. <?php
  94. // Do not remove this;)
  95. }
  96. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement