Advertisement
Guest User

Untitled

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