· 8 years ago · May 04, 2017, 07:54 PM
1<?php
2
3require_once('recaptchalib.php');
4
5/*
6 [README UPDATES]
7
8 Kevin, make sure you straighten the code style up so everything
9 isn't so messy. Also, fix where it shows "Fields are Empty" because
10 it shows it at all times when the fields are are already filled. I suggest
11 checking that with "!isset" instead of "!empty" since isset is more secure.
12
13*/
14
15$pageTitle = 'CPPS.one - Register';
16
17include('./includes/config.php');
18
19/*if(isset($_SESSION["userId"])){
20 header("Location: http://play.cpps.one/");
21 die();
22}*/
23
24if(isset($_POST) && !empty($_POST)){
25 if(isset($_POST["bite_username"],$_POST["bite_email"], $_POST["bite_password"], $_POST["bite_repassword"], $_POST["penguinColor"], $_POST["g-recaptcha-response"]) && !empty($_POST["bite_username"]) && !empty($_POST["bite_email"]) && !empty($_POST["bite_password"]) && !empty($_POST["bite_repassword"]) && !empty($_POST["penguinColor"]) && !empty($_POST["g-recaptcha-response"])){
26
27 $username = $_POST["bite_username"];
28 $email = $_POST["bite_email"];
29 $password = $_POST["bite_password"];
30 $repassword = $_POST["bite_repassword"];
31 $color = $_POST["penguinColor"];
32 //$betakey = $_POST["bite_beta"];
33 $captcha = $_POST["g-recaptcha-response"];
34
35 $checkUser = $database->prepare("SELECT Username from users WHERE Username = :username");
36 $checkUser->bindValue(':username', $username);
37 $checkUser->execute();
38 $userTaken = $checkUser->rowCount() > 0;
39
40 $checkEmail = $database->prepare("SELECT Email from users WHERE Email = :email");
41 $checkEmail->bindValue(':email', $email);
42 $checkEmail->execute();
43 $emailTaken = $checkEmail->rowCount() > 0;
44
45 if($userTaken)
46 {
47 $error = 'Woops username already in use';
48 }
49 if($emailTaken)
50 {
51 $error = 'Woops email already in use';
52 }
53 if(!ctype_alnum($username))
54 {
55 $error = "Username can only contain numbers and letters.";
56 }
57 if($password != $repassword)
58 {
59 $error = "Passwords do not match !";
60 }
61 if(!$captcha)
62 {
63 $error = 'Please fill out the captcha';
64 die();
65 }
66
67 $secretKey = "6LdZQB4UAAAAANz9FWtP2f1e9ZnGpP1ogCVFkgOM";
68 $ip = $_SERVER['REMOTE_ADDR'];
69 $response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secretKey."&response=".$captcha."&remoteip=".$ip);
70 $responseKeys = json_decode($response, true);
71
72 if(intval($responseKeys["success"]) !== 1) {
73 $error = 'You are spammer ! Get the @$%K out';
74 //die();
75 }
76 /*else
77 {
78 $checkBetaKey = $database->prepare("SELECT * FROM betakeys WHERE betakey = :key AND used = 0");
79 $checkBetaKey->bindValue(":key", $betakey);
80 $checkBetaKey->execute();
81 $Count = $checkBetaKey->rowCount();
82 if($Count == 0)
83 {
84 $error = 'This beta key is invalid or has been already used.';
85 }*/
86 else
87 {
88 //$updateKey = $database->prepare("UPDATE betakeys SET used = 1 WHERE betakey = :key");
89 //$updateKey->bindValue(":key", $betakey);
90 //$updateKey->execute();
91
92 $insertUser = $database->prepare("INSERT INTO users (Username, Email, RegisteredTime, Password, Color) VALUES (:secu_username, :secu_email, :registered_time, :secu_password, :color)");
93 $insertUser->bindValue(":secu_username", $username);
94 $insertUser->bindValue(":secu_email", $email);
95 $insertUser->bindValue(":registered_time", time());
96 $insertUser->bindValue(":secu_password", md5($password));
97 $insertUser->bindValue(":color", $color);
98 $insertUser->execute();
99
100 $newID = $database->lastInsertId();
101
102 $_SESSION["userId"] = $newID;
103
104 //header("Location: http://play.cpps.one/");
105
106 //echo '<center><div class="alert alert-success">You have successfully registered '.$username.'. Your ID is '.$newID.'</div></center>';
107
108 echo '<script language="javascript">';
109 echo 'alert("You have successfully registered !")';
110 echo '</script>';
111
112 }
113 //}
114
115 }
116 else
117 {
118 $error = "Please complete all the fields.";
119 }
120}
121
122?>
123<?php
124
125include ('./includes/header.php');
126
127 ?>
128<div>
129<center>
130 <br /><img src="./assets/img/create_account.png" style="margin-left: -392px;width: 1920px;margin-top: -71px;">
131 <h3>Create an Account</h3>
132 <br />
133 <br />
134<p>We have officially opened the register. If your ID is lower than 200, you're a VIP User. Forever.</p><br><br>
135</center>
136</div>
137
138 <?php
139
140 if(isset($error)){
141 echo '<center><div class="alert alert-danger">'.$error.'</div></center>';
142 }
143
144 ?>
145
146
147<div class="register-form">
148
149<form method="POST" action="">
150 <div class="form-group">
151 <input type="text" class="form-control" name="bite_username" placeholder="Username" style="width: 385px;">
152 </div>
153 <div class="form-group">
154 <input type="text" class="form-control" name="bite_email" placeholder="Email" style="width: 385px;">
155 </div>
156 <div class="form-group">
157 <input type="password" class="form-control" name="bite_password" placeholder="Password" style="width: 385px;">
158 </div>
159 <div class="form-group">
160 <input type="password" class="form-control" name="bite_repassword" placeholder="Confirm Password" style="width: 385px;">
161 </div>
162 <div style="margin-left:152px;">
163 </div>
164 <div class="form-group">
165 </div>
166 <div style="margin-left:150px;"><div class="g-recaptcha" data-sitekey="6LdZQB4UAAAAAFbWe2TLWyap1I4A8slSVnJ-Qhug"></div></div><br>
167 <input type="submit" class="btn btn-success" value="Sign Up" style="width: 111px; margin-left: 151px;margin-top: -16px;"></input>
168 <input type="hidden" value="1" id="penguinColorInput" name="penguinColor" />
169</form>
170
171<div class="foo blue" id="c1" style="opacity: 1;" onclick="changeImage('./colors/1.png')"></div>
172<div class="foo green" id="c2" style="opacity: 0.5;" onclick="changeImage('./colors/2.png')"></div>
173<div class="foo pink" id="c3" style="opacity: 0.5;" onclick="changeImage('./colors/3.png')"></div>
174<div class="foo black" id="c4" style="opacity: 0.5;" onclick="changeImage('./colors/4.png')"></div>
175<div class="foo red" id="c5" style="opacity: 0.5;" onclick="changeImage('./colors/5.png')"></div>
176<div class="foo orange" id="c6" style="opacity: 0.5;" onclick="changeImage('./colors/6.png')"></div>
177<div class="foo yellow" id="c7" style="opacity: 0.5;" onclick="changeImage('./colors/7.png')"></div>
178<br>
179<div class="foo purple" id="c8" style="opacity: 0.5;" onclick="changeImage('./colors/8.png')"></div>
180<div class="foo brown" id="c9" style="opacity: 0.5;" onclick="changeImage('./colors/9.png')"></div>
181<div class="foo lightpink" id="c10" style="opacity: 0.5;" onclick="changeImage('./colors/10.png')"></div>
182<div class="foo darkgreen" id="c11" style="opacity: 0.5;" onclick="changeImage('./colors/11.png')"></div>
183<div class="foo lightblue" id="c12" style="opacity: 0.5;" onclick="changeImage('./colors/12.png')"></div>
184<div class="foo lightgreen" id="c13" style="opacity: 0.5;" onclick="changeImage('./colors/13.png')"></div>
185<div class="foo grey" id="c14" style="opacity: 0.5;" onclick="changeImage('./colors/14.png')"></div>
186
187<img id="imgDisp" alt="" src="colors/1.png" style="margin-left:687px;margin-top: -834px;"/>
188
189</div>
190<script>
191function changeImage(imgName)
192{
193 image = document.getElementById('imgDisp');
194 image.src = imgName;
195 var colorId = imgName.replace("./colors/", "");
196 colorId = colorId.replace(".png", "");
197 document.getElementById("penguinColorInput").value = colorId;
198
199 for (i = 1; i < 15; i++) {
200 document.getElementById("c" + i).style.opacity = 0.5;
201 }
202 document.getElementById("c" + colorId).style.opacity = 1;
203}
204</script>
205
206<?php
207
208include ('./includes/footer.php');
209
210?>