-
Notifications
You must be signed in to change notification settings - Fork 0
/
activation.php
47 lines (34 loc) · 1.25 KB
/
activation.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
include "mysql.php";
if (isset($_GET['email']) && preg_match('/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/', $_GET['email'])) {
$email = $_GET['email'];
} else {
exit;
}
if (isset($_GET['key']) && (strlen($_GET['key']) == 32)) {
$key = $_GET['key'];
} else {
exit;
}
if (isset($email) && isset($key)) {
$sql = "SELECT `username` FROM `user` WHERE (`email` = '$email' AND `activationkey` = '$key') LIMIT 1";
$res = mysql_query($sql);
$username_temp = mysql_result($res, 0);
$sql = "SELECT `activationkey` FROM `user` WHERE (`email` = '$email' AND `username` = '" . $username_temp . "') LIMIT 1";
$res = mysql_query($sql);
$activationkey_temp = mysql_result($res, 0);
if ($activationkey_temp == $key) {
$sql = "UPDATE `user` SET `activated` = 1, `activationkey` = 1337 WHERE (`email` = '$email' AND `activationkey` = '$key') LIMIT 1";
$res = mysql_query($sql);
if ($res == true) {
echo '<div>Your account is now active. You may now <a href="login.php">Log in</a></div>';
} else {
echo '<div>Oops !Your account could not be activated. Please recheck the link or contact the system administrator.</div>';
}
} else {
echo '<div>An error occured!</div>';
}
} else {
echo '<div>An error Occured!</div>';
}
?>