Advertisement
Guest User

Untitled

a guest
Jul 18th, 2017
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.31 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.  
  88.     };
  89.  
  90.  
  91.     //  >>>>>>>>>>>>>>>>>>>>>>>>>>  shift indents back out  >>>>>>>>>>>>>>>>>>>>>>
  92.  
  93.  
  94.                         } else {
  95.  
  96.                             message("register an account",
  97.                                     "fatal error",
  98.                                     "your e-mail address contained ".
  99.                                     "invalid characters. no account ".
  100.                                     "was created.");
  101.  
  102.                         };
  103.  
  104.                     } else {
  105.  
  106.                         message("register an account", "fatal error",
  107.                                 "your e-mail address cannot be null. ".
  108.                                 "no account was created.");
  109.  
  110.                     };
  111.  
  112.                 } else {
  113.  
  114.                     message("register an account", "fatal error",
  115.                             "your e-mail address did not match. ".
  116.                             "no account was created.");
  117.  
  118.                 };
  119.  
  120.             } else {
  121.  
  122.                 message("register an account", "fatal error",
  123.                         "your username contained invalid characters. ".
  124.                         "no account was created.");
  125.  
  126.             };
  127.  
  128.         } else {
  129.  
  130.             message("register an account", "fatal error",
  131.                     "your username cannot be null. no account was created.");
  132.  
  133.         };
  134.  
  135.     } else {
  136.  
  137.         message("register an account", "fatal error",
  138.                 "your username was longer than 16 characters. no account was created.");
  139.     };
  140.  
  141. } else {
  142.  
  143.     echo <<<EOF
  144.             <form action="register.php" method="post">
  145.                 <table cellspacing="1" class="content">
  146.                     <tr>
  147.                         <th colspan="2">we'll e-mail you a password</th>
  148.                     </tr>
  149.                     <tr>
  150.                         <td>username:</td>
  151.                         <td><input type="text" name="username" maxlength="16" size="16" /></td>
  152.                     </tr>
  153.                     <tr>
  154.                         <td>e-mail:</td>
  155.                         <td><input type="text" name="email0" maxlength="64" size="32" /></td>
  156.                     </tr>
  157.                     <tr>
  158.                         <td>confirm e-mail:</td>
  159.                         <td><input type="text" name="email1" maxlength="64" size="32" /></td>
  160.                     </tr>
  161.                     <tr>
  162.                         <td>&nbsp;</td>
  163.                         <td>
  164.                             <input type="submit" value="register" />
  165.                             <input type="hidden" name="action" value="register" />
  166.                         </td>
  167.                     </tr>
  168.                 </table>
  169.             </form>
  170.  
  171. EOF;
  172.  
  173. };
  174.  
  175.  
  176.  
  177. require_once "include_footer.php";
  178.  
  179. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement