Guest User

Untitled

a guest
Jul 15th, 2018
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.95 KB | None | 0 0
  1. <?
  2. require_once("include/bittorrent.php");
  3. require_once("include/phpbb2Bridge.php");
  4.  
  5.  
  6. $id = 0 + $HTTP_GET_VARS["id"];
  7. $md5 = $HTTP_GET_VARS["secret"];
  8. if (!$id)
  9. httperr();
  10.  
  11. dbconn();
  12.  
  13. $res = mysql_query("SELECT COUNT(*) FROM users") or sqlerr(__FILE__, __LINE__);
  14. $arr = mysql_fetch_row($res);
  15. if ($arr[0] >= $invites)
  16. stderr("Error", "Sorry, user limit reached. Please try again later.");
  17.  
  18. $res = mysql_query("SELECT editsecret,email, status FROM users WHERE id = $id");
  19. $row = mysql_fetch_array($res);
  20.  
  21. if (!$row)
  22. httperr();
  23.  
  24. if ($row["status"] != "pending") {
  25. header("Refresh: 0; url=ok.php?type=confirmed");
  26. exit();
  27. }
  28.  
  29. $email = $row["email"];
  30.  
  31. $sec = hash_pad($row["editsecret"]);
  32. if ($md5 != md5($sec))
  33. httperr();
  34. if (empty($wantusername) || empty($wantpassword))
  35. //bark("Don't leave any fields blank.");
  36. if (!mkglobal("wantusername:wantpassword:passagain:country"))
  37. die();
  38.  
  39. function bark($msg) {
  40. stdhead();
  41. stdmsg("Signup failed!", $msg);
  42. stdfoot();
  43. exit;
  44. }
  45.  
  46. function validusername($username)
  47. {
  48. if ($username == "")
  49. return false;
  50.  
  51. // The following characters are allowed in user names
  52. $allowedchars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
  53.  
  54. for ($i = 0; $i < strlen($username); ++$i)
  55. if (strpos($allowedchars, $username[$i]) === false)
  56. return false;
  57.  
  58. return true;
  59. }
  60.  
  61. function isportopen($port)
  62. {
  63. global $HTTP_SERVER_VARS;
  64. $sd = @fsockopen($HTTP_SERVER_VARS["REMOTE_ADDR"], $port, $errno, $errstr, 1);
  65. if ($sd)
  66. {
  67. fclose($sd);
  68. return true;
  69. }
  70. else
  71. return false;
  72. }
  73.  
  74. if (empty($country))
  75. bark("You must select a country.");
  76.  
  77. if (strlen($wantusername) > 12)
  78. bark("Sorry, username is too long (max is 12 chars)");
  79.  
  80. if ($wantpassword != $passagain)
  81. bark("The passwords didn't match! Must've typoed. Try again.");
  82.  
  83. if (strlen($wantpassword) < 6)
  84. bark("Sorry, password is too short (min is 6 chars)");
  85.  
  86. if (strlen($wantpassword) > 40)
  87. bark("Sorry, password is too long (max is 40 chars)");
  88.  
  89. if ($wantpassword == $wantusername)
  90. bark("Sorry, password cannot be same as user name.");
  91.  
  92. if (!validusername($wantusername))
  93. bark("Invalid username.");
  94.  
  95. // make sure user agrees to everything...
  96. if ($HTTP_POST_VARS["rulesverify"] != "yes" || $HTTP_POST_VARS["faqverify"] != "yes" || $HTTP_POST_VARS["ageverify"] != "yes")
  97. stderr("Signup failed", "Sorry, you're not qualified to become a member of this site.");
  98.  
  99.  
  100. $secret = mksecret();
  101. $wantpasshash = md5($secret . $wantpassword . $secret);
  102.  
  103. $ret = mysql_query("UPDATE users SET username='$wantusername', passhash='$wantpasshash', status='confirmed', editsecret='', secret='$secret', country='$country' WHERE id=$id");
  104.  
  105. if (!$ret) {
  106. if (mysql_errno() == 1062)
  107. bark("Username already exists!");
  108. bark("Database Update Failed");
  109. }
  110.  
  111. //insert_phpBB2user($wantusername, md5($wantpassword), $email);
  112. //login_phpBB2user($wantusername, md5($wantpassword), TRUE);
  113.  
  114. logincookie($id, $wantpasshash);
  115.  
  116. header("Refresh: 0; url=ok.php?type=confirm");
  117.  
  118.  
  119. ?>
Add Comment
Please, Sign In to add comment