-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathactivate.php
More file actions
86 lines (72 loc) · 2.09 KB
/
activate.php
File metadata and controls
86 lines (72 loc) · 2.09 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
/*
* NAME
*
* activate.php
*
* CONCEPT
*
* User activation page.
*
* NOTES
*
* This page serves two functions:
*
* 1. Solicit the activation key in a form.
* 2. Process the activation key.
*
* The key may be provided in the PATH_INFO.
*/
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
set_include_path(get_include_path() . PATH_SEPARATOR . 'project');
require "lib/ps.php";
DataStoreConnect();
Initialize();
if(isset($_SERVER['PATH_INFO']) &&
preg_match('%^/(.{20})$%', $_SERVER['PATH_INFO'], $matches)) {
$key = $matches[1];
}
$title = 'Activate';
preg_match('%^(.+)/[^/]+$%', $_SERVER['SCRIPT_NAME'], $matches);
$css = LIBDIR . "/ps.css";
$js = LIBDIR . "/ps.js";
$page = "<!doctype html>
<html lang=\"en\">
<head>
<title>$title</title>
<link rel=\"stylesheet\" href=\"$css\">
<script src=\"$js\"></script>
</head>
<body>
<header><h1>$title</h1></header>
<div id=\"poutine\">
<img src=\"" . ROOTDIR . '/' . IMAGEDIR . "/pattern-sphere-band.png\" id=\"gravy\">
";
if(isset($_POST['submit']) || isset($key)) {
// page was called with key in $PATH_INFO or form was submitted with a key
if(! isset($key))
$key = trim($_POST['key']);
$rval = $auth->activate($key);
if(isset($rval['error'])) {
print "$page\n<p class=\"alert\">{$rval['message']}</p>\n";
if($rval['error'] == 'Activation key has expired.') {
print "<p class=\"alert\">You can request a new one on <a href=\"" . ROOTDIR . "/register.php\">this page</a>.</p>\n";
} else if($rval['error'] == 'Activation key is invalid.') {
print "<p class=\"alert\">The activation key you entered (<code>$key</code>) is not valid. Click <a href=\"activate.php\">here</a> to try again.</p>\n";
} else {
print '<p><a href="' . ROOTDIR . '/log.php">Proceed to login page.</a></p>
';
}
}
} else {
print $page .
"<p>You should have received an activation key in your email. Enter it
below to activate your account.</p>\n" . ACTIVATIONFORM;
}
?>
</div>
<?=FOOT?>
</body>
</html>