-
Notifications
You must be signed in to change notification settings - Fork 1
/
route.php
160 lines (156 loc) · 5.47 KB
/
route.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<?php
// Required configuration file
require '../config.php';
// Require Class
require 'Model/pengumuman.php';
require 'Model/pengaturan.php';
require 'Model/tingkat.php';
require 'Model/jurusan.php';
require 'Model/kelas.php';
require 'Model/siswa.php';
require 'Model/absensi.php';
// Signing access to all file
define('akses', TRUE);
// URL Modification
$res = preg_replace("/admin\//", '', $link);
$page = preg_replace("/admin\//", '', $link);
$page = preg_replace("/\//", "", $page);
$page = ucfirst($page);
$res = parse_url($res, PHP_URL_PATH);
// Routing
switch ($res) {
case '' :
require __DIR__ . '/dashboard.php';
break;
case '/' :
require __DIR__ . '/dashboard.php';
break;
case '/dashboard' :
require __DIR__ . '/dashboard.php';
break;
case '/pengumuman':
$pengumumans = $pengumuman->select_all($connection);
require __DIR__. '/top.php';
require __DIR__. '/pengumuman.php';
require __DIR__. '/bottom.php';
break;
case "/pengumuman/delete/all":
$pengumuman->delete_all($connection,"DELETE");
header("location:$url/admin/pengumuman");
break;
case "/pengumuman/delete":
$id = $_GET['id'];
$pengumuman->delete($connection,$id);
header("location:$url/admin/pengumuman");
break;
case "/pengumuman/post":
$data = $_POST['data'];
$pengumuman->insert($connection,$data);
header("location:$url/admin/pengumuman");
break;
case '/pengaturan':
$pengaturans = $pengaturan->all($connection);
require __DIR__. '/top.php';
require __DIR__. '/pengaturan.php';
require __DIR__. '/bottom.php';
break;
case '/pengaturan/edit':
$variable = $_POST['variable'];
$value = $_POST['value'];
$pengaturan->edit($connection,$variable,$value);
header("location:$url/admin/pengaturan");
case '/kelas':
$tingkats = $tingkat->select_all($connection);
$jurusans = $jurusan->select_all($connection);
$kelass = $kelas->select_all($connection);
require __DIR__. '/top.php';
require __DIR__. '/kelas.php';
require __DIR__. '/bottom.php';
break;
case '/kelas/tingkat/post':
$tk_baru = $_POST['tingkat'];
$tingkat->insert($connection,$tk_baru);
header("location:$url/admin/kelas");
break;
case '/kelas/tingkat/delete':
$id = $_GET['id'];
$tingkat->delete($connection,$id);
header("location:$url/admin/kelas");
break;
case '/kelas/jurusan/post':
$jr_baru = $_POST['jurusan'];
$jurusan->insert($connection,$jr_baru);
header("location:$url/admin/kelas");
break;
case '/kelas/jurusan/delete':
$id = $_GET['id'];
$jurusan->delete($connection,$id);
header("location:$url/admin/kelas");
break;
case '/kelas/kelas/post':
$kl_baru = $_POST['kelas'];
$kelas->insert($connection,$kl_baru);
header("location:$url/admin/kelas");
break;
case '/kelas/kelas/delete':
$id = $_GET['id'];
$kelas->delete($connection,$id);
header("location:$url/admin/kelas");
break;
case '/siswa':
$siswas = $siswa->select_all($connection);
$tingkats = $tingkat->select_all($connection);
$jurusans = $jurusan->select_all($connection);
$kelass = $kelas->select_all($connection);
require __DIR__. '/top.php';
require __DIR__. '/siswa.php';
require __DIR__. '/bottom.php';
break;
case '/siswa/post':
$siswas = array('nis' => $_POST['nis'],
'nama' => $_POST['nama'],
'tingkat' => $_POST['tingkat'],
'jurusan' => $_POST['jurusan'],
'kelas' => $_POST['kelas'],
'email_ortu' => $_POST['email']);
$siswa->insert($connection,$siswas);
header("location:$url/admin/siswa");
break;
case '/siswa/update':
$siswas = array('id' => $_POST['id'],
'nis' => $_POST['nis'],
'nama' => $_POST['nama'],
'tingkat' => $_POST['tingkat'],
'jurusan' => $_POST['jurusan'],
'kelas' => $_POST['kelas'],
'email_ortu' => $_POST['email']);
$siswa->update($connection,$siswas);
header("location:$url/admin/siswa");
break;
case '/siswa/delete':
$siswas = $_GET['id'];
$siswa->delete($connection,$siswas);
header("location:$url/admin/siswa");
break;
case '/siswa/delete/all':
$siswa->delete_all($connection);
header("location:$url/admin/siswa");
break;
case '/absensi':
$siswas = $siswa->select_all($connection);
$tingkats = $tingkat->select_all($connection);
$jurusans = $jurusan->select_all($connection);
$kelass = $kelas->select_all($connection);
$absens = $absen->select_all($connection);
$today = $absen->today($connection);
require __DIR__. '/top.php';
require __DIR__. '/absensi.php';
require __DIR__. '/bottom.php';
break;
// If the page is unavailable, then redirect user to error page 404
// If the user access the file directly, user will be redirected to error page 403
default:
http_response_code(404);
require '../404/index.html';
break;
}