SHARE
TWEET

Untitled

a guest Jan 28th, 2016 107 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. if(basename($_SERVER["PHP_SELF"]) == "register.php"){
  3.     die("403 - Access Forbidden");
  4. }
  5. if(isset($_SESSION['id'])){
  6.     echo "<meta http-equiv=refresh content=\"0; url=?base=ucp\">";
  7. }
  8. else{
  9. echo "<h2 class=\"text-left\">Registration</h2><hr/>";
  10. if (@$_POST["register"] != "1") {
  11. ?>
  12.     <form action="?base=main&amp;page=register" method="POST" role="form">
  13.     <div class="form-group">
  14.         <label for="inputUser">Username</label>
  15.         <input type="text" name="musername" maxlength="12" class="form-control" id="inputUser" autocomplete="off" placeholder="Username" required>
  16.     </div>
  17.     <div class="form-group">
  18.         <label for="inputPass">Password</label>
  19.         <input type="password" name="mpass" maxlength="12" class="form-control" id="inputPass" autocomplete="off" placeholder="Password" required>
  20.     </div>
  21.     <div class="form-group">
  22.         <label for="inputConfirm">Confirm Password</label>
  23.         <input type="password" name="mpwcheck" maxlength="12" class="form-control" id="inputConfirm" autocomplete="off" placeholder="Confirm Password" required>
  24.     </div>
  25.     <div class="form-group">
  26.       <label for="inputEmail">Email</label>
  27.       <input type="email" name="memail" class="form-control" id="inputEmail" autocomplete="off" placeholder="Email" required="">
  28.       </div>
  29.   <div class=\"form-group\">
  30.     <label for=\"birthday\">Birthday</label>
  31.      <input type="text" name="mbirth" maxlength="10" class="form-control" id="birthday" autocomplete="off" placeholder="Birthday (YYYY-MM-DD)" required="">
  32.     </div>
  33.     <b>reCAPTCHA</b>
  34.     <?php
  35.         require_once('assets/config/recaptchalib.php');
  36.         $error = null;
  37.         $publickey = "6LemqAwAAAAAAF4dIpSjTB3GJt1ax0MRQ9FvOX_T";
  38.         $privatekey = "6LemqAwAAAAAAO69RT3j9M1eHPX_ahhmC6Gakuwb";
  39.         echo recaptcha_get_html($publickey, $error);
  40.     ?>
  41.         <br/>
  42.         <input type="submit" class="btn btn-primary" name="submit" alt="Register" value="Register &raquo;">
  43.         <input type="hidden" name="register" value="1">
  44.     </form>
  45. <?php
  46. } else {
  47.     if (!isset($_POST["musername"]) OR
  48.         !isset($_POST["mpass"]) OR
  49.         !isset($_POST["mpwcheck"]) OR
  50.         !isset($_POST["memail"]) OR
  51.     !isset($_POST["mbirth"]) OR
  52.         !isset($_POST["recaptcha_response_field"])) {
  53.         die ("<div class=\"alert alert-error\">Please fill in the correct ReCAPTCHA code!<br/><a href=\"?base=main&page=register\">&laquo; Go Back</a></div>");
  54.     }
  55.    
  56.     $getusername = $mysqli->real_escape_string($_POST["musername"]); # Get Username
  57.     $username = preg_replace("/[^A-Za-z0-9 ]/", '', $getusername); # Escape and Strip
  58.     $password = $_POST["mpass"]; # Get Password
  59.     $confirm_password =$_POST["mpwcheck"]; # Get Confirm Password
  60.     $email = $mysqli->real_escape_string($_POST["memail"]);
  61.   $birth = $_POST["mbirth"]; # Get Birthday
  62.     $ip = getRealIpAddr();
  63.    
  64.     $continue = false;
  65.    
  66.     require_once('assets/config/recaptchalib.php');
  67.  
  68.     $publickey = "6LemqAwAAAAAAF4dIpSjTB3GJt1ax0MRQ9FvOX_T";
  69.     $privatekey = "6LemqAwAAAAAAO69RT3j9M1eHPX_ahhmC6Gakuwb";
  70.    
  71.     $resp = null;
  72.     $danger = null;
  73.  
  74.     if ($_POST["recaptcha_response_field"]) {
  75.             $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
  76.             if ($resp->is_valid) {
  77.                 $continue = true;
  78.             }
  79.     }
  80.  
  81.     if (!$continue) {
  82.         echo ("<div class=\"alert alert-danger\">Please fill in the correct ReCAPTCHA code!<br/><a href=\"?base=main&page=register\">&laquo; Go Back</a></div>");
  83.     } else {
  84.         $select_user_result = $mysqli->query("SELECT id FROM accounts WHERE name='".$username."' OR email='".$email."' LIMIT 1");
  85.         $returned = $select_user_result->num_rows; 
  86.         if ($returned > 0) {
  87.             echo ("<div class=\"alert alert-danger\">This username or email is already used!<br/><a href=\"?base=main&page=register\">&laquo; Go Back</a></div>");
  88.         } else if ($password != $confirm_password) {
  89.             echo ("<div class=\"alert alert-danger\">Passwords didn't match!<br/><a href=\"?base=main&page=register\">&laquo; Go Back</a></div>");
  90.         } else if (strlen($password) < 4 || strlen($password) > 12) {
  91.             echo ("<div class=\"alert alert-danger\">Your password must be between 4-12 characters<br/><a href=\"?base=main&page=register\">&laquo; Go Back</a></div>");
  92.         } else if (strlen($username) < 4 || strlen($username) > 12) {
  93.             echo ("<div class=\"alert alert-danger\">Your username must be between 4-12 characters<br/><a href=\"?base=main&page=register\">&laquo; Go Back</a></div>");
  94.         } else if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
  95.             echo ("<div class=\"alert alert-danger\">Please fill in a valid email address.<br/><a href=\"?base=main&page=register\">&laquo; Go Back</a></div>");
  96.         } else {
  97.             //All data is ok
  98.             $password = sha1($password);
  99.             $insert_user_query = "INSERT INTO accounts (`name`, `password`, `ip`, `email`, `birthday`) VALUES ('".$username."', '".$password."', '".$ip."', '".$email."', '".$birth."')";
  100.             $mysqli->query($insert_user_query);
  101.             echo "
  102.             <div class=\"alert alert-success\"><b>Success!</b> Please login, and head to the downloads page to get started!</div>
  103.             ";
  104.         }
  105.     }
  106.     }
  107. }
  108. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top