-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaccount.php
49 lines (44 loc) · 2.03 KB
/
account.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
48
49
<?php
require "load.php";
$page = "account";
if ($logged == false && $level->login() && $level->signup()) {
$error = false;
if (isset($_POST["login"])) {
$return = $user->login($_POST["username"], $_POST["password"]);
if ($return !== true)
$error = true;
else
header("Location: account.php");
}
if (isset($_POST["signup"])) {
$return = $user->signup($_POST["username"], $_POST["password"], $_POST["email"]);
if ($return !== true) {
$error = true;
} else {
$token = genToken();
$activationLink = $config["url"] . "activate.php?token=" . $token;
$username = clean($_POST["username"]);
$email = clean($_POST["email"]);
$db->insert("activation", ["token" => $token, "email" => $email]);
$mail->setFrom($config["email"], $config["title"] . " Staff");
$mail->addAddress($email, $config["title"] . " Reader");
$mail->isHTML(true);
$mail->Subject = "Activate your account at " . $config["title"];
$mail->Body = "<b>Hello, {$username}</b><br>You just created an account on {$config["title"]}.<br>Please use the link below to activate it and gain access to all of the features:<br>{$activationLink}";
$mail->AltBody = "Hello {$username}, you just created an account on {$config["title"]}. Please activate it with this link to fully access our site: {$activationLink}";
$mail->send();
header("Location: account.php");
}
}
}
include "themes/{$thme}/parts/header.php";
echo $core->title("Account", $config["seperator"], $config["title"]);
include "themes/{$thme}/parts/menu.php";
if ($logged == false && $level->login() && $level->signup()) {
include "themes/{$thme}/render/login.php";
} elseif ($logged == true) {
include "themes/{$thme}/render/account.php";
} else {
include "themes/{$thme}/render/error.php";
}
include "themes/{$thme}/parts/footer.php";