This repository has been archived by the owner on Nov 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaction.php
65 lines (58 loc) · 1.6 KB
/
action.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
include_once('includes/queries.php');
if (!isset($_GET['code']) || empty($_GET['code'])) {
errorpage(
'Bad request',
'Your request could not be processed',
'400 Bad Request');
}
$actiondata = find_action_data($_GET['code']);
if ($actiondata === NULL) {
errorpage(
'Invalid action code',
'The action code in the URL you tried to access is not valid. ' .
'Maybe you entered a wrong code or the code has expired.',
'404 Not Found');
}
$cuid = $actiondata['cuid'];
$atype = $actiondata['atype'];
$adata = $actiondata['adata'];
function activate_account($cuid) {
if (set_user_active($cuid)) {
flash("Your account has been activated successfully.", FLASH_SUCCESS);
}
}
function reset_password($cuid) {
if (!isset($_SESSION)) {
session_start();
}
$_SESSION['reset_password_uid'] = $cuid;
redirect_to('auth/changepassword');
}
function change_email($cuid, $email) {
if (set_user_email($cuid, $email)) {
flash("Your email address has been changed successfully.", FLASH_SUCCESS);
}
}
switch ($atype) {
case $ACTION_TYPES['activate_mail']:
delete_action($_GET['code']);
activate_account($cuid);
redirect_to('index');
break;
case $ACTION_TYPES['reset_password']:
delete_action($_GET['code']);
reset_password($cuid);
break;
case $ACTION_TYPES['change_email']:
delete_action($_GET['code']);
change_email($cuid, $adata);
redirect_to('index');
break;
default:
errorpage(
'Bad request',
'Your request could not be processed',
'400 Bad Request');
}
?>