-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
106 lines (80 loc) · 2.23 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
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
104
105
106
<?php
/*************************************************************************
*
* EHACKB RFID SYSTEM
* __________________
*
* [2014] - [2015] Arnaud Coel
* All Rights Reserved.
*
*/
define("main", true);
session_start();
ini_set("display_errors", 1);
include("lib/user.php");
include("class/Database.class.php");
include("class/Pos.class.php");
include("class/Logger.class.php");
$db2 = new pos\Database("127.0.0.1", "root", "root", "ehackb_pos");
$pos = new pos\Pos($db2->getDbObject());
$log = new helpers\Logger($db2->getDbObject());
if (isset($_POST['username']) && isset($_POST['password']) && isset($_POST['rfid']))
authenticateUser($_POST['username'], $_POST['password'], $_POST['rfid'], $db2, $log);
if (!isset($_GET['page']))
$_GET['page'] = "";
if ($_GET['page'] == "logout") {
session_destroy();
header("Location: index.php?page=login");
exit;
}
if ($_GET['page'] == "authenticate" && isset($_SESSION['authenticated'])) {
header("Location: ?page=home");
exit;
}
if (!isset($_SESSION['authenticated']) && $_GET['page'] != "authenticate") {
header("Location: ?page=authenticate");
exit;
}
if (isset($_GET['return'])) {
$id = $_GET['return'];
$update = $db2->getDbObject()->prepare("UPDATE loans SET returned = (returned ^ 1) WHERE id = ?");
if ($update->execute(array($id)))
header("Location: ?page=loaning&loan=success");
else
header("Location: ?page=loaning&loan=error");
}
/*
* Page initialization
*/
include "partials/header.php";
switch ($_GET['page']) {
case 'authenticate':
include "partials/authenticate.php";
break;
case 'admin':
include "partials/admin.php";
break;
case 'registration':
include "partials/registration.php";
break;
case 'cashier':
include "partials/cashier.php";
break;
case 'salestat':
include "partials/salestat.php";
break;
case 'loaning':
include "partials/loaning.php";
break;
case 'home':
include "partials/home.php";
break;
case 'logout':
session_destroy();
break;
default:
include "partials/404.php";
break;
}
include "partials/footer.php";
$db2->close();