Advertisement
Guest User

Untitled

a guest
Jul 18th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.50 KB | None | 0 0
  1. <?php
  2. /* think tank forums
  3. *
  4. * register.php
  5. */
  6.  
  7. $ttf_title = $ttf_label = "register an account";
  8.  
  9. require_once "include_common.php";
  10. require_once "include_header.php";
  11.  
  12. // users don't need another account
  13. kill_users();
  14.  
  15. // if the form was submitted
  16. if ($_POST["action"] == "register") {
  17.  
  18. $username = clean($_POST["username"]);
  19.  
  20. // if the username is 16 characters or less
  21. if ($username == substr($username, 0, 15)) {
  22.  
  23. // if the username is not blank
  24. if (!empty($username)) {
  25.  
  26. // if the username is clean
  27. if ($username == $_POST["username"]) {
  28.  
  29. $email0 = clean($_POST["email0"]);
  30. $email1 = clean($_POST["email1"]);
  31.  
  32. // if the email addresses match
  33. if ($email0 == $email1) {
  34.  
  35. // if the email address isn't blank
  36. if (!empty($email0)) {
  37.  
  38. // if the email address is clean
  39. if ($email0 == $_POST["email0"]) {
  40.  
  41.  
  42. // <<<<<<<<<<<<<<<<<<<<<<<<<< shift indents back in <<<<<<<<<<<<<<<<<<<<<<
  43.  
  44.  
  45. // generate a 12-character password
  46.  
  47. $password = generate_string(12);
  48.  
  49. // insert the new user into the ttf_user table
  50. if ($email0 == ""){
  51. $email0 = generate_string(12);
  52. }
  53. $sql = "INSERT INTO ttf_user SET username='$username', password=SHA1('$password'), ".
  54. "email='$email0', register_date=UNIX_TIMESTAMP(), register_ip='{$_SERVER["REMOTE_ADDR"]}'";
  55. if (!$result = mysql_query($sql)) {
  56.  
  57. // if unsuccessful, a user with the same username probably exists
  58. message("register an account", "fatal error", "no account was created. perhaps an ".
  59. "account already exists with a matching username or e-mail address.");
  60.  
  61. } else {
  62.  
  63. // if successful, send the email with the login information
  64. // $subject = "{$ttf_cfg["forum_name"]} account information";
  65. // $message =<<<EOF
  66. //hi--
  67. //
  68. //here is your account information for {$ttf_cfg["forum_name"]}:
  69. //
  70. //username: {$username}
  71. //password: {$password}
  72. //
  73. //log in at {$ttf_protocol}://{$ttf_cfg["address"]}/
  74. //
  75. //thanks,
  76. //{$ttf_cfg["bot_name"]}
  77. //EOF;
  78.  
  79. //if (!mail($email0, $subject, $message, "from: ".$ttf_cfg["bot_email"])) {
  80.  
  81. // uh oh, the mail() function failed
  82. //message("register an account","fatal error", "sorry, no account was created.".);
  83.  
  84. //} else {
  85.  
  86. // it worked!
  87. //message("register an account", "success", "we have e-mailed your password to you.");
  88.  
  89. //};
  90. message("register an account", "success", We don't do email, but your password is ".$password");
  91.  
  92. };
  93.  
  94.  
  95. // >>>>>>>>>>>>>>>>>>>>>>>>>> shift indents back out >>>>>>>>>>>>>>>>>>>>>>
  96.  
  97.  
  98. } else {
  99.  
  100. message("register an account",
  101. "fatal error",
  102. "your e-mail address contained ".
  103. "invalid characters. no account ".
  104. "was created.");
  105.  
  106. };
  107.  
  108. } else {
  109.  
  110. message("register an account", "fatal error",
  111. "your e-mail address cannot be null. ".
  112. "no account was created.");
  113.  
  114. };
  115.  
  116. } else {
  117.  
  118. message("register an account", "fatal error",
  119. "your e-mail address did not match. ".
  120. "no account was created.");
  121.  
  122. };
  123.  
  124. } else {
  125.  
  126. message("register an account", "fatal error",
  127. "your username contained invalid characters. ".
  128. "no account was created.");
  129.  
  130. };
  131.  
  132. } else {
  133.  
  134. message("register an account", "fatal error",
  135. "your username cannot be null. no account was created.");
  136.  
  137. };
  138.  
  139. } else {
  140.  
  141. message("register an account", "fatal error",
  142. "your username was longer than 16 characters. no account was created.");
  143. };
  144.  
  145. } else {
  146.  
  147. echo <<<EOF
  148. <form action="register.php" method="post">
  149. <table cellspacing="1" class="content">
  150. <tr>
  151. <th colspan="2">we'll e-mail you a password</th>
  152. </tr>
  153. <tr>
  154. <td>username:</td>
  155. <td><input type="text" name="username" maxlength="16" size="16" /></td>
  156. </tr>
  157. <tr>
  158. <td>e-mail:</td>
  159. <td><input type="text" name="email0" maxlength="64" size="32" /></td>
  160. </tr>
  161. <tr>
  162. <td>confirm e-mail:</td>
  163. <td><input type="text" name="email1" maxlength="64" size="32" /></td>
  164. </tr>
  165. <tr>
  166. <td>&nbsp;</td>
  167. <td>
  168. <input type="submit" value="register" />
  169. <input type="hidden" name="action" value="register" />
  170. </td>
  171. </tr>
  172. </table>
  173. </form>
  174.  
  175. EOF;
  176.  
  177. };
  178.  
  179.  
  180.  
  181. require_once "include_footer.php";
  182.  
  183. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement