-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog.php
103 lines (83 loc) · 2.64 KB
/
log.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
/* NAME
*
* log.php
*
* CONCEPT
*
* Combined login/logout page.
*
* A user arriving with valid credentials is assumed to be here
* to logout. We don't need any other information, so we simply call
* the logout method and then redirect to the top application page.
*
* A user arriving without credentials is here to login to an existing
* account.
*
* $Id: log.php,v 1.12 2023/03/22 20:43:25 rose Exp $
*/
if(isset($_POST) && isset($_POST['cancel'])) {
header('Location: ./');
}
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(is_array($project)) {
$atitle = $project['title'];
} else {
$atitle = 'Pattern Selection Projects';
}
$isLogged = $auth->isLogged();
if($isLogged) {
// This user is authenticated; they are presumed to be here to log out.
$hash = $_COOKIE['phpauth_session_cookie'];
$auth->logout($hash);
header('Location: ./');
exit;
}
// This user is not authenticated; offer a login form.
if(isset($_SERVER['HTTP_REFERER']) &&
preg_match('%//[^/]+(/.+)%', $_SERVER['HTTP_REFERER'], $matches))
$referer = "<input type=\"hidden\" name=\"referer\" value=\"$matches[1]\">\n";
else
$referer = '';
$title = 'Pattern Sphere Login';
?>
<!doctype html>
<html lang="en">
<head>
<title><?=$title?></title>
<link rel="stylesheet" href="<?=ROOTDIR?>/project/lib/ps.css">
<script src="<?=ROOTDIR?>/project/lib/ps.js"></script>
</head>
<body>
<header>
<h1><?=$title?></h1>
</header>
<div id="poutine">
<img src="images/pattern-sphere-band.png" id="gravy">
<h2 id="login">Login</h2>
<p>If you already have an account, enter your credentials below to login.
(If not, go <a href="register.php">here</a> to create one.)
Checking the "remember me" box will keep you logged in on the browser you
are using across sessions, and for about a month.</p>
<form method="POST" action="<?=ROOTDIR?>/login.php" class="gf">
<?=$referer?><div class="fieldlabel">Email address:</div>
<div><input type="text" size="35" name="email"></div>
<div class="fieldlabel">Password:</div>
<div><input type="password" name="password" id="logpassword"><input type="button" value="Unmask" id="logpassword-mask" onclick="Mask('logpassword')"></div>
<div class="fieldlabel">Remember me:</div>
<div><input type="checkbox" name="remember" value="Remember me"></div>
<div class="gs">
<input type="submit" name="login" value="Login">
<input type="submit" name="cancel" value="Cancel">
</div>
</form>
</div>
<?=FOOT?>
</body>
</html>