forked from vvye/smwhacking
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsession.php
More file actions
46 lines (34 loc) · 1.07 KB
/
session.php
File metadata and controls
46 lines (34 loc) · 1.07 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
<?php
session_start();
require_once __DIR__ . '/inc/lang/de/strings.php';
require_once __DIR__ . '/inc/functions/environment.php';
require_once __DIR__ . '/inc/functions/engine.php';
require_once __DIR__ . '/inc/functions/template.php';
require_once __DIR__ . '/inc/functions/database.php';
$database = getDatabase();
require_once __DIR__ . '/inc/functions/session.php';
$baseUrl = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['REQUEST_URI']);
$previousPage = $_SESSION['referrer'];
unset($_SESSION['referrer']);
$previousPage = str_replace(['?p=login', '?p=finish-registration'], '?p=home', $previousPage);
if (isset($_GET['action']) && $_GET['action'] === 'login')
{
$loginSuccess = doLogin();
if (!$loginSuccess)
{
header('Location: ' . $baseUrl . '?p=login&error');
}
else
{
header('Location: ' . $previousPage);
}
}
else if (isset($_GET['action']) && $_GET['action'] === 'logout')
{
doLogout();
header('Location: ' . $baseUrl . '?p=home');
}
else
{
header('Location: ' . $baseUrl . '?p=home');
}