-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
84 lines (66 loc) · 1.77 KB
/
index.php
File metadata and controls
84 lines (66 loc) · 1.77 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
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
<?php
session_start();
require_once 'Database.php';
$database = new Database();
$db = $database->getConnection();
$database->createTables();
$page = $_GET['page'] ?? 'home';
if (isset($_GET['logout'])) {
session_destroy();
header('Location: index.php');
exit;
}
require_once 'includes/header.php';
switch ($page) {
case 'home':
include 'pages/home.php';
break;
case 'items':
include 'pages/items.php';
break;
case 'auth':
if (isset($_SESSION['customer_id']) || isset($_SESSION['admin_id'])) {
header('Location: index.php');
exit;
}
include 'pages/auth.php';
break;
case 'place_order':
if (!isset($_SESSION['customer_id'])) {
header('Location: index.php?page=auth');
exit;
}
include 'pages/place_order.php';
break;
case 'payments':
if (!isset($_SESSION['customer_id'])) {
header('Location: index.php?page=auth');
exit;
}
include 'pages/payments.php';
break;
case 'order_details':
if (!isset($_SESSION['customer_id'])) {
header('Location: index.php?page=auth');
exit;
}
include 'pages/order_details.php';
break;
case 'admin':
if (!isset($_SESSION['admin_id'])) {
echo '<script>alert("Please login as administrator to access admin panel"); window.location.href="?page=auth";</script>';
exit;
}
include 'pages/admin_dashboard.php';
break;
case 'contact':
include 'pages/contact.php';
break;
default:
header('Location: ?page=home');
exit;
break;
}
// Include footer
require_once 'includes/footer.php';
?>