Advertisement
Guest User

Untitled

a guest
Dec 4th, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.23 KB | None | 0 0
  1. <?php
  2.  
  3. include("inc/auth.php");
  4.  
  5. include("inc/login_validation.php");
  6.  
  7. $display_name = $_POST["display_name"];
  8. $username = $_POST["username"];
  9. $password = $_POST["password"];
  10. $password_two = $_POST["password_two"];
  11.  
  12. require_once "recaptchalib.php";
  13.  
  14. $secret = "6LfjyA0UAAAAAL3lTTdIJS7ui5tD1Fxf-3sG1xw9";
  15.  
  16. // empty response
  17. $response = null;
  18.  
  19. // check secret key
  20. $reCaptcha = new ReCaptcha($secret);
  21.  
  22. foreach ($_POST as $key => $value) {
  23. //echo '<p><strong>' . $key.':</strong> '.$value.'</p>';
  24. }
  25.  
  26. if($_POST["register_form"])
  27. {
  28. $display_name = $_POST["display_name"];
  29. $username = $_POST["username"];
  30. $username = strtolower($username);
  31. $email = $_POST["email"];
  32. $email = strtolower($email);
  33. $password = $_POST["password"];
  34. $password_two = $_POST["password_two"];
  35. $captcha = $_POST['g-recaptcha-response'];
  36.  
  37. if(!$username)
  38. {
  39. $error[] = "Please choose a username.";
  40. }
  41. if($username && !ctype_alnum($username))
  42. {
  43. $error[] = "Your username may only include letters and numbers.";
  44. }
  45. if(!$password)
  46. {
  47. $error[] = "Please choose a password.";
  48. }
  49. if($password != $password_two)
  50. {
  51. $error[] = "Your passwords do not match.";
  52. }
  53.  
  54. if($username)
  55. {
  56. $stmt = $conn->prepare("SELECT * FROM member WHERE username=:username");
  57. $stmt->bindParam(':username', $username);
  58. $stmt->execute();
  59. while($row = $stmt->fetch(PDO::FETCH_ASSOC))
  60. {
  61. $existing_username = $row['username'];
  62. }
  63. if($existing_username)
  64. {
  65. $error[] = "The username you have selected is already in use. Please try another.";
  66. }
  67. }
  68.  
  69. if($email)
  70. {
  71. $stmt = $conn->prepare("SELECT * FROM member WHERE email=:email");
  72. $stmt->bindParam(':email', $email);
  73. $stmt->execute();
  74. while($row = $stmt->fetch(PDO::FETCH_ASSOC))
  75. {
  76. $existing_email = $row['email'];
  77. }
  78. if($existing_email)
  79. {
  80. $error[] = "The email you have selected is already in use. Please try another.";
  81. }
  82. }
  83.  
  84. $arrlength = count($error);
  85. }
  86.  
  87. function new_member()
  88. {
  89. 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.";
  90.  
  91. // handle all the new member SQL inserts below
  92.  
  93. include("inc/auth.php");
  94.  
  95. $display_name = $_POST["display_name"];
  96. $username = $_POST["username"];
  97. $email = $_POST["email"];
  98. $password = $_POST["password"];
  99. $password_two = $_POST["password_two"];
  100.  
  101. $display_name = htmlspecialchars($display_name);
  102. $username = htmlspecialchars($username);
  103. // $member_number
  104. $join_date = time();
  105. $email = htmlspecialchars($email);
  106. $options = ['cost' => 14,];
  107. $final_password = password_hash($password, PASSWORD_BCRYPT, $options);
  108. $user_level = 0;
  109. $microtime = microtime();
  110. $hash = md5($microtime . $username);
  111. $active_videos = 0;
  112. $total_videos = 0;
  113. $active_content = 0;
  114. $total_content = 0;
  115. $active_length = 0;
  116. $total_length = 0;
  117. $active_alerts = 0;
  118. $unread_inbox = 0;
  119. $total_inbox = 0;
  120. $total_outbox = 0;
  121. $verified_email = 0;
  122. $avatar = "none.png";
  123. $subscriptions = 0;
  124. $subscribers = 0;
  125. $birth_day = "01";
  126. $birth_month = "January";
  127. $birth_year = "1901";
  128.  
  129. $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)");
  130. $stmt->bindParam(':display_name', $display_name);
  131. $stmt->bindParam(':username', $username);
  132. $stmt->bindParam(':join_date', $join_date);
  133. $stmt->bindParam(':email', $email);
  134. $stmt->bindParam(':password', $final_password);
  135. $stmt->bindParam(':user_level', $user_level);
  136. $stmt->bindParam(':hash', $hash);
  137. $stmt->bindParam(':active_videos', $active_videos);
  138. $stmt->bindParam(':total_videos', $total_videos);
  139. $stmt->bindParam(':active_content', $active_content);
  140. $stmt->bindParam(':total_content', $total_content);
  141. $stmt->bindParam(':active_length', $active_length);
  142. $stmt->bindParam(':total_length', $total_length);
  143. $stmt->bindParam(':active_alerts', $active_alerts);
  144. $stmt->bindParam(':unread_inbox', $unread_inbox);
  145. $stmt->bindParam(':total_inbox', $total_inbox);
  146. $stmt->bindParam(':total_outbox', $total_outbox);
  147. $stmt->bindParam(':verified_email', $verified_email);
  148. $stmt->bindParam(':avatar', $avatar);
  149. $stmt->bindParam(':subscriptions', $subscriptions);
  150. $stmt->bindParam(':subscribers', $subscribers);
  151. $stmt->bindParam(':birth_day', $birth_day);
  152. $stmt->bindParam(':birth_month', $birth_month);
  153. $stmt->bindParam(':birth_year', $birth_year);
  154. $stmt->execute();
  155.  
  156. $day = date("j");
  157. $month = strtolower(date("F"));
  158. $year = date("Y");
  159. $stats_month = "stats_".$month."_".$year;
  160. $stats_year = "stats_".$year;
  161. $day_of_month = date("j");
  162.  
  163. // update global stats
  164. $stmt = $conn->prepare("UPDATE global_stats SET total_member=total_member+1, active_member=active_member+1");
  165. $stmt->execute();
  166.  
  167. // update month stats
  168. $stmt = $conn->prepare("UPDATE $stats_month SET total_member=total_member+1, active_member=active_member+1 WHERE day=:day");
  169. $stmt->bindParam(':day', $day);
  170. $stmt->execute();
  171.  
  172. // update year stats
  173. $stmt = $conn->prepare("UPDATE $stats_year SET total_member=total_member+1, active_member=active_member+1 WHERE month=:month");
  174. $stmt->bindParam(':month', $month);
  175. $stmt->execute();
  176.  
  177. $to = $email;
  178. $subject = "HighRES Account Activation";
  179. $message = "Thank you for registering at http://highres.co/. Click on the link below to validate your account.\n\nhttp://highres.co/val/".$hash;
  180. $headers = "From: noreply@highres.co";
  181.  
  182. //mail($to, $subject, $message, $headers);
  183.  
  184. }
  185.  
  186. ?>
  187.  
  188. <!DOCTYPE html>
  189. <html>
  190. <?php //include("include/doctype.php"); ?>
  191. <head>
  192. <meta charset="UTF-8">
  193. <meta name="viewport" content="width=device-width, initial-scale=1">
  194. <link rel=”shortcut icon” href=”/favicon.ico” type=”image/x-icon”/>
  195. <meta name="google-site-verification" content="O-eYMPBOCxkGxiI6Kk4hYmGOjA3zclz9Er2BJcPhBaA"/>
  196. <meta name="google-site-verification" content="7p74bOiqiMXES-GRI8F7WrKELQvqCbvoe2VHz9Fp43s"/>
  197. <meta name="generator" content="HTML Tidy for Windows (vers 14 February 2006), see www.w3.org">
  198. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  199. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
  200. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  201. <title>
  202. HighRES
  203. </title>
  204. <link rel="stylesheet" type="text/css" href="bootstrap.css">
  205. <script src='https://www.google.com/recaptcha/api.js'></script>
  206. </head>
  207. <body>
  208. <?php
  209.  
  210. if (isset($_COOKIE["username"])) {
  211. include("inc/member_nav.php");
  212. }
  213. if (!isset($_COOKIE["username"])) {
  214. include("inc/guest_nav.php");
  215. }
  216.  
  217. ?>
  218. <div class="container-fluid" style="padding: 5px; border: 1px solid #737373;">
  219. <?php
  220.  
  221. for($x = 0; $x < $arrlength; $x++)
  222. {
  223. echo $error[$x];
  224. echo "<br /><br />";
  225. }
  226.  
  227. if(!$_POST["register_form"])
  228. {
  229. include("inc/register.php");
  230. }
  231. else if($_POST["register_form"] && $arrlength != 0)
  232. {
  233. include("inc/register.php");
  234. }
  235. else if($_POST["register_form"] && $arrlength == 0)
  236. {
  237. new_member();
  238. }
  239.  
  240. ?>
  241. </div>
  242. <?php include("inc/footer.php"); ?>
  243. </body>
  244. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement