-
Notifications
You must be signed in to change notification settings - Fork 159
/
Copy pathauth.php
37 lines (33 loc) · 881 Bytes
/
auth.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
<?php
function showLogin()
{
//if (isset($_SERVER['HTTP_REFERER'])) {
// error_log("auth.php referred by " . $_SERVER['HTTP_REFERER']);
//}
$header = 'Location: login.php';
$separator = '?';
if (isset($_REQUEST['lang'])) {
$header = $header . $separator . 'lang=' . $_REQUEST['lang'];
$separator = '&';
}
if (isset($_REQUEST['pin'])) {
$header = $header . $separator . 'pin=' . $_REQUEST['pin'];
$separator = '&';
}
header($header);
exit;
}
if (!isset($_SESSION)) {
session_start();
}
if (!isset($_SESSION['username'])) {
// empty session
showLogin();
} else {
require_once('DBConnector.class.php');
$dbcon = new palma\DBConnector();
if (!$dbcon->checkUser($_SESSION['username'])) {
// empty db (e.g. after PalMA restart) or old session
showLogin();
}
}