Advertisement
Guest User

Untitled

a guest
Jul 18th, 2017
73
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. $sql = "INSERT INTO ttf_user SET username='$username', password=SHA1('$password'), ".
  51. "email='$email0', register_date=UNIX_TIMESTAMP(), register_ip='{$_SERVER["REMOTE_ADDR"]}'";
  52. if (!$result = mysql_query($sql)) {
  53.  
  54. // if unsuccessful, a user with the same username probably exists
  55. message("register an account", "fatal error", "no account was created. perhaps an ".
  56. "account already exists with a matching username or e-mail address.");
  57.  
  58. } else {
  59.  
  60. // if successful, send the email with the login information
  61. // $subject = "{$ttf_cfg["forum_name"]} account information";
  62. // $message =<<<EOF
  63. //hi--
  64. //
  65. //here is your account information for {$ttf_cfg["forum_name"]}:
  66. //
  67. //username: {$username}
  68. //password: {$password}
  69. //
  70. //log in at {$ttf_protocol}://{$ttf_cfg["address"]}/
  71. //
  72. //thanks,
  73. //{$ttf_cfg["bot_name"]}
  74. //EOF;
  75.  
  76. //if (!mail($email0, $subject, $message, "from: ".$ttf_cfg["bot_email"])) {
  77.  
  78. // uh oh, the mail() function failed
  79. //message("register an account","fatal error", "sorry, no account was created.".);
  80.  
  81. //} else {
  82.  
  83. // it worked!
  84. //message("register an account", "success", "we have e-mailed your password to you.");
  85.  
  86. //};
  87. message("register an account", "success", "We don't do email, but your password is ".$password);
  88. echo "We don't do email, but your password is ".$password;
  89.  
  90. };
  91.  
  92.  
  93. // >>>>>>>>>>>>>>>>>>>>>>>>>> shift indents back out >>>>>>>>>>>>>>>>>>>>>>
  94.  
  95.  
  96. } else {
  97.  
  98. message("register an account",
  99. "fatal error",
  100. "your e-mail address contained ".
  101. "invalid characters. no account ".
  102. "was created.");
  103.  
  104. };
  105.  
  106. } else {
  107.  
  108. message("register an account", "fatal error",
  109. "your e-mail address cannot be null. ".
  110. "no account was created.");
  111.  
  112. };
  113.  
  114. } else {
  115.  
  116. message("register an account", "fatal error",
  117. "your e-mail address did not match. ".
  118. "no account was created.");
  119.  
  120. };
  121.  
  122. } else {
  123.  
  124. message("register an account", "fatal error",
  125. "your username contained invalid characters. ".
  126. "no account was created.");
  127.  
  128. };
  129.  
  130. } else {
  131.  
  132. message("register an account", "fatal error",
  133. "your username cannot be null. no account was created.");
  134.  
  135. };
  136.  
  137. } else {
  138.  
  139. message("register an account", "fatal error",
  140. "your username was longer than 16 characters. no account was created.");
  141. };
  142.  
  143. } else {
  144.  
  145. echo <<<EOF
  146. <form action="register.php" method="post">
  147. <table cellspacing="1" class="content">
  148. <tr>
  149. <th colspan="2">we'll e-mail you a password</th>
  150. </tr>
  151. <tr>
  152. <td>username:</td>
  153. <td><input type="text" name="username" maxlength="16" size="16" /></td>
  154. </tr>
  155. <tr>
  156. <td>e-mail:</td>
  157. <td><input type="text" name="email0" maxlength="64" size="32" /></td>
  158. </tr>
  159. <tr>
  160. <td>confirm e-mail:</td>
  161. <td><input type="text" name="email1" maxlength="64" size="32" /></td>
  162. </tr>
  163. <tr>
  164. <td>&nbsp;</td>
  165. <td>
  166. <input type="submit" value="register" />
  167. <input type="hidden" name="action" value="register" />
  168. </td>
  169. </tr>
  170. </table>
  171. </form>
  172.  
  173. EOF;
  174.  
  175. };
  176.  
  177.  
  178.  
  179. require_once "include_footer.php";
  180.  
  181. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement