Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include("inc/auth.php");
- include("inc/login_validation.php");
- $display_name = $_POST["display_name"];
- $username = $_POST["username"];
- $password = $_POST["password"];
- $password_two = $_POST["password_two"];
- require_once "recaptchalib.php";
- $secret = "6LfjyA0UAAAAAL3lTTdIJS7ui5tD1Fxf-3sG1xw9";
- // empty response
- $response = null;
- // check secret key
- $reCaptcha = new ReCaptcha($secret);
- foreach ($_POST as $key => $value) {
- //echo '<p><strong>' . $key.':</strong> '.$value.'</p>';
- }
- if($_POST["register_form"])
- {
- $display_name = $_POST["display_name"];
- $username = $_POST["username"];
- $username = strtolower($username);
- $email = $_POST["email"];
- $email = strtolower($email);
- $password = $_POST["password"];
- $password_two = $_POST["password_two"];
- $captcha = $_POST['g-recaptcha-response'];
- if(!$username)
- {
- $error[] = "Please choose a username.";
- }
- if($username && !ctype_alnum($username))
- {
- $error[] = "Your username may only include letters and numbers.";
- }
- if(!$password)
- {
- $error[] = "Please choose a password.";
- }
- if($password != $password_two)
- {
- $error[] = "Your passwords do not match.";
- }
- if($username)
- {
- $stmt = $conn->prepare("SELECT * FROM member WHERE username=:username");
- $stmt->bindParam(':username', $username);
- $stmt->execute();
- while($row = $stmt->fetch(PDO::FETCH_ASSOC))
- {
- $existing_username = $row['username'];
- }
- if($existing_username)
- {
- $error[] = "The username you have selected is already in use. Please try another.";
- }
- }
- if($email)
- {
- $stmt = $conn->prepare("SELECT * FROM member WHERE email=:email");
- $stmt->bindParam(':email', $email);
- $stmt->execute();
- while($row = $stmt->fetch(PDO::FETCH_ASSOC))
- {
- $existing_email = $row['email'];
- }
- if($existing_email)
- {
- $error[] = "The email you have selected is already in use. Please try another.";
- }
- }
- $arrlength = count($error);
- }
- function new_member()
- {
- echo "<p />Thank you for registering an account! You may now login with the username and password you provided.<p />An email has been sent to your email address containing a link to verify your account. This is not required to watch and comment on videos, but you will need to verify your acccount before uploading any videos.<p />You may verify your account at any time. If you do not receive the email, or need a new one, you can easily resend it through your account page.";
- // handle all the new member SQL inserts below
- include("inc/auth.php");
- $display_name = $_POST["display_name"];
- $username = $_POST["username"];
- $email = $_POST["email"];
- $password = $_POST["password"];
- $password_two = $_POST["password_two"];
- $display_name = htmlspecialchars($display_name);
- $username = htmlspecialchars($username);
- // $member_number
- $join_date = time();
- $email = htmlspecialchars($email);
- $options = ['cost' => 14,];
- $final_password = password_hash($password, PASSWORD_BCRYPT, $options);
- $user_level = 0;
- $microtime = microtime();
- $hash = md5($microtime . $username);
- $active_videos = 0;
- $total_videos = 0;
- $active_content = 0;
- $total_content = 0;
- $active_length = 0;
- $total_length = 0;
- $active_alerts = 0;
- $unread_inbox = 0;
- $total_inbox = 0;
- $total_outbox = 0;
- $verified_email = 0;
- $avatar = "none.png";
- $subscriptions = 0;
- $subscribers = 0;
- $birth_day = "01";
- $birth_month = "January";
- $birth_year = "1901";
- $stmt = $conn->prepare("INSERT INTO member VALUES (:display_name, :username, null, :join_date, :email, :password, :user_level, :hash, :active_videos, :total_videos, :active_content, :total_content, :active_length, :total_length, :active_alerts, :unread_inbox, :total_inbox, :total_outbox, :verified_email, :avatar, :subscriptions, :subscribers, :birth_day, :birth_month, :birth_year)");
- $stmt->bindParam(':display_name', $display_name);
- $stmt->bindParam(':username', $username);
- $stmt->bindParam(':join_date', $join_date);
- $stmt->bindParam(':email', $email);
- $stmt->bindParam(':password', $final_password);
- $stmt->bindParam(':user_level', $user_level);
- $stmt->bindParam(':hash', $hash);
- $stmt->bindParam(':active_videos', $active_videos);
- $stmt->bindParam(':total_videos', $total_videos);
- $stmt->bindParam(':active_content', $active_content);
- $stmt->bindParam(':total_content', $total_content);
- $stmt->bindParam(':active_length', $active_length);
- $stmt->bindParam(':total_length', $total_length);
- $stmt->bindParam(':active_alerts', $active_alerts);
- $stmt->bindParam(':unread_inbox', $unread_inbox);
- $stmt->bindParam(':total_inbox', $total_inbox);
- $stmt->bindParam(':total_outbox', $total_outbox);
- $stmt->bindParam(':verified_email', $verified_email);
- $stmt->bindParam(':avatar', $avatar);
- $stmt->bindParam(':subscriptions', $subscriptions);
- $stmt->bindParam(':subscribers', $subscribers);
- $stmt->bindParam(':birth_day', $birth_day);
- $stmt->bindParam(':birth_month', $birth_month);
- $stmt->bindParam(':birth_year', $birth_year);
- $stmt->execute();
- $day = date("j");
- $month = strtolower(date("F"));
- $year = date("Y");
- $stats_month = "stats_".$month."_".$year;
- $stats_year = "stats_".$year;
- $day_of_month = date("j");
- // update global stats
- $stmt = $conn->prepare("UPDATE global_stats SET total_member=total_member+1, active_member=active_member+1");
- $stmt->execute();
- // update month stats
- $stmt = $conn->prepare("UPDATE $stats_month SET total_member=total_member+1, active_member=active_member+1 WHERE day=:day");
- $stmt->bindParam(':day', $day);
- $stmt->execute();
- // update year stats
- $stmt = $conn->prepare("UPDATE $stats_year SET total_member=total_member+1, active_member=active_member+1 WHERE month=:month");
- $stmt->bindParam(':month', $month);
- $stmt->execute();
- $to = $email;
- $subject = "HighRES Account Activation";
- $message = "Thank you for registering at http://highres.co/. Click on the link below to validate your account.\n\nhttp://highres.co/val/".$hash;
- $headers = "From: noreply@highres.co";
- //mail($to, $subject, $message, $headers);
- }
- ?>
- <!DOCTYPE html>
- <html>
- <?php //include("include/doctype.php"); ?>
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <link rel=”shortcut icon” href=”/favicon.ico” type=”image/x-icon”/>
- <meta name="google-site-verification" content="O-eYMPBOCxkGxiI6Kk4hYmGOjA3zclz9Er2BJcPhBaA"/>
- <meta name="google-site-verification" content="7p74bOiqiMXES-GRI8F7WrKELQvqCbvoe2VHz9Fp43s"/>
- <meta name="generator" content="HTML Tidy for Windows (vers 14 February 2006), see www.w3.org">
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
- <title>
- HighRES
- </title>
- <link rel="stylesheet" type="text/css" href="bootstrap.css">
- <script src='https://www.google.com/recaptcha/api.js'></script>
- </head>
- <body>
- <?php
- if (isset($_COOKIE["username"])) {
- include("inc/member_nav.php");
- }
- if (!isset($_COOKIE["username"])) {
- include("inc/guest_nav.php");
- }
- ?>
- <div class="container-fluid" style="padding: 5px; border: 1px solid #737373;">
- <?php
- for($x = 0; $x < $arrlength; $x++)
- {
- echo $error[$x];
- echo "<br /><br />";
- }
- if(!$_POST["register_form"])
- {
- include("inc/register.php");
- }
- else if($_POST["register_form"] && $arrlength != 0)
- {
- include("inc/register.php");
- }
- else if($_POST["register_form"] && $arrlength == 0)
- {
- new_member();
- }
- ?>
- </div>
- <?php include("inc/footer.php"); ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement