Advertisement
Guest User

Untitled

a guest
Jun 5th, 2017
543
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.29 KB | None | 0 0
  1. <?php
  2.  
  3. #############################
  4. ##Copyright (c) TheJacob#####
  5. ##All Rights Reserved########
  6. ##thejacobpollack@gmail.com##
  7. #############################
  8.  
  9. #############################
  10. #############################
  11.  
  12. ##Configuration##
  13. $mssql_server = ""; //MSSQL name
  14. $mssql_username = ""; //MSSQL username
  15. $mssql_password = ""; //MSSQL password
  16. $mssql_account_db = ""; //MSSQL account database name
  17. $mssql_account_table = ""; //MSSQL account table name
  18. $mssql_username_column = ""; //MSSQL username column in account table
  19. $mssql_password_column = ""; //MSSQL password column in account table
  20. $hash = ""; //Hash code
  21. $random_text_text = "e=mc2"; //Random text they must enter to register
  22.  
  23. #############################
  24. #############################
  25.  
  26. ##Configuration Settings Check##
  27. if (($mssql_server == "") || ($mssql_username == "") || ($mssql_password == "") || ($mssql_account_db == "") || ($mssql_account_table == "") || ($mssql_username_column == "") || ($mssql_password_column == "") || ($hash == "") || ($random_text_text == "")) {
  28. die ("<strong>Please fill in all the configuration settings! For your own security and the functionality of the script, you cannot leave them blank.</strong>");
  29. }
  30.  
  31. ##Connect##
  32. $mssql_connect = mssql_connect($mssql_server, $mssql_username, $mssql_password) or die ("<strong>Cannot connect to the MSSQL Database.</strong>");
  33. $mssql_select = mssql_select_db($mssql_account_db) or die ("<strong>Cannot select the MSSQL Database.</strong>");
  34.  
  35. ##Function##
  36. function doesUsernameExist($username){
  37. $exit = FALSE;
  38. $result = @mssql_query("SELECT * FROM $mssql_account_table WHERE $mssql_username_column='$username'");
  39. if (mssql_num_rows($result) != 0){
  40. $exit = TRUE;
  41. }
  42. return $exit;
  43. }
  44.  
  45. $pusername = $_POST['username']; //Post wsername
  46. $ppassword = $_POST['password']; //Post password
  47. $prpassword = $_POST['rpassword']; //Post re-enter password
  48. $fpassword = md5($hash . $password); //Full/Final password
  49. $random_text = $_POST['random_text']; //Random text
  50.  
  51. if (isset($_POST['submit']) == true) {
  52. $username = preg_replace("/[^a-zA-Z0-9\-\_\!\$\#\@\^\&\*\(\)\^\+\ \.\?]/", "", $pusername);
  53. $password = preg_replace("/[^a-zA-Z0-9\-\_\!\$\#\@\^\&\*\(\)\^\+\ \.\?]/", "", $ppassword);
  54.  
  55. if ((isset($_POST['submit']) == true) and (strlen($pusername) < 3) || (strlen($pusername) > 15)) {
  56. echo "Your username must be between 3 and 15 characters in length.";
  57. }
  58.  
  59. else if ((isset($_POST['submit']) == true) and ((strlen($ppassword) < 3) || (strlen($ppassword) > 15) || (strlen($prpassword) < 3) || (strlen($prpassword) > 15))) {
  60. echo "The password must be between 3 and 15 characters in length.";
  61. }
  62.  
  63. else if ((isset($_POST['submit']) == true) and ($ppassword != $prpassword)) {
  64. echo "The passwords must be the same.";
  65. }
  66.  
  67. else if ((isset($_POST['submit']) == true) and (($pusername == $ppassword) || ($pusername == $prpassword))) {
  68. echo "The username and password cannot be the same.";
  69. }
  70.  
  71. else if ((isset($_POST['submit']) == true) and ($random_text != $random_text_text)) {
  72. echo "The random text must be filled in correctly. Please take another look at the random text.";
  73. } else {
  74. if ((isset($_POST['submit']) == true) and (!doesUsernameExist($username))) {
  75. $stmt = mssql_init('createaccount', $mssql_connect);
  76. mssql_bind($stmt, '@account', $username, SQLVARCHAR, false, false, 15);
  77. mssql_bind($stmt, '@password', $fpassword, SQLVARCHAR, false, false, 36);
  78. mssql_execute($stmt) or die ("<strong>Error occurred while executing the statement.</strong>");
  79. mssql_free_statement($stmt);
  80. echo "You've been successfully registered as <strong>" . $username . "</strong>!";
  81. } else {
  82. echo "The username already exists.";
  83. }
  84. }
  85. }
  86.  
  87. ?>
  88.  
  89. <form method ="post" action="#">
  90. <table>
  91.  
  92. <tr>
  93. <td><strong>Username</strong></td>
  94. </tr>
  95. <tr>
  96. <td><input name="username" type="username"></td>
  97. </tr>
  98. <tr>
  99. <td><strong>Password</strong></td>
  100. </tr>
  101. <tr>
  102. <td><input name="password" type="password"></td>
  103. </tr>
  104. <tr>
  105. <td><strong>Re-enter Password</strong></td>
  106. </tr>
  107. <tr>
  108. <td><input name="rpassword" type="password"></td>
  109. </tr>
  110. <tr>
  111. <td><strong>Please enter "<?php echo $random_text_text ?>" without the brackets below</strong></td>
  112. </tr>
  113. <tr>
  114. <td><input name="random_text" type="text"></td>
  115. </tr>
  116. <tr>
  117. <td><input name="submit" type="submit" value="Register"></td>
  118. </tr>
  119.  
  120. </table>
  121. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement