blob: d79b294eef1f888ac0b8d27f401c4a394c67fd9b (
plain) (
blame)
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
50
51
52
|
<?php
namespace Controller;
use Database;
use Exception;
function on_post() {
global $user_status;
$user_status = "";
try {
Database\User::fromDB($_POST["username"]);
$user_status = "User \"" . $_POST["username"] . "\" already exists!";
return;
}
catch(Exception $e) {}
try {
Database\User::create($_POST["username"], $_POST["password"], "User");
}
catch(Exception $e) {
$user_status = $e;
}
}
function on_delete() {
global $TOKEN;
global $METHOD;
global $user_status;
$user_status = "";
try {
Database\Cookie::fromDB($TOKEN);
}
catch (Exception $e) {
$user_status = 'Invalid token!';
return;
}
$to_delete = null;
try {
$to_delete = Database\User::fromDBuid($METHOD['uid']);
}
catch(Exception $e) {
$list_status = "The user you're trying to delete doesn't exist!";
return;
}
$to_delete->delete();
header('Location: /');
exit();
}
|