-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
55 lines (50 loc) · 1.79 KB
/
index.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
<?php
session_start();
// $allowed_origins = array(
// "http://localhost:8000"
// );
// header('Access-Control-Allow-Origin: ' . $allowed_origins);
// header('Access-Control-Allow-Credentials: true');
// header('Access-Control-Allow-Headers: Content-Type');
if (isset($_COOKIE['dKEY'])) {
// PACKAGES ---------------------------
include_once $_SERVER['DOCUMENT_ROOT'] . '/JDS/class/standard.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/JDS/class/auth.php';
// ------------------------------------
// OBJECTS [reusable] -----------------
$std = new stdlib();
$auth = new auth();
// ------------------------------------
$dKEY = $std->db->escape_string($_COOKIE['dKEY']);
if ($auth->getUserIdByDeviceID($dKEY) != false && !isset($_GET['home'])) {
$_SESSION['userID'] = $auth->getUserIdByDeviceID($dKEY);
$_SESSION['logged_in'] = true;
header("location: ./?home");
}
}
?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<?php require $_SERVER['DOCUMENT_ROOT'] . '/JDS/section/header.php'; ?>
</head>
<body>
<div class="_prc_container"></div>
<div class="web_container">
<?php
if (count($_GET) == 0) header("location: ./?login");
else
if (isset($_GET['register'])) require $_SERVER['DOCUMENT_ROOT'] . '/JDS/section/page/register.php';
else
if (isset($_GET['login'])) require $_SERVER['DOCUMENT_ROOT'] . '/JDS/section/page/login.php';
else
if (isset($_GET['home'])) require $_SERVER['DOCUMENT_ROOT'] . '/JDS/section/page/home.php';
else
if (isset($_GET['logout'])) require $_SERVER['DOCUMENT_ROOT'] . '/JDS/section/page/logout.php';
else
echo "ERROR 404"; // error page
?>
</div>
<?php require $_SERVER['DOCUMENT_ROOT'] . '/JDS/section/footer.php'; ?>
</body>
</html>