forked from sordinho/Group-J---Digital-Student-Record
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
124 lines (108 loc) · 3.39 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
include 'config.php';
$site = new csite();
initialize_site($site);
$page = new cpage("DIGITAL RECORD SYSTEM");
$site->setPage($page);
$content = "";
if (isset($_POST['usergroup'])) {
$usr = new user();
if ($usr->select_usergroup($_POST['usergroup'])) {
$url = PLATFORM_PATH.$usr->get_base_url();
header("location: $url");
} else {
$usr->get_error(26);
}
}
if (isset($_SESSION['id']) && isset($_SESSION['username']) && !isset($_SESSION['usergroup']) && $_GET['select_usergroup']==1) {
$usr = new user();
$usergroup = $usr->retrieve_usergroups($usr->get_username());
foreach ($usergroup as $ug) {
$icon = "";
switch ($ug) {
case 'teacher':
$icon = "fas fa-briefcase";
break;
case 'parent':
$icon = "fas fa-child";
break;
case 'officer':
$icon = "fas fa-user-cog";
break;
case 'admin':
$icon = "fas fa-tools";
break;
}
$roles .= "
<div class='col col-sm col-md'>
<form method='POST' action='index.php'>
<button class='card-role rounded' style='border: none; background: none' type='submit' name='usergroup' value='$ug'>
<i class='$icon fa-2x'></i>
<div class='container-role'>
<h5><b>$ug</b></h5>
</div>
</button>
</form>
</div>
";
}
$content .= "
<div class=\"card text-center\" id='usergroup-selection'>
<div class=\"card-header\" style=\"background-color:rgba(108,108,108,0.9);color:white\">
<p class='h3'>Select a role for the login</p>
</div>
<div class=\"card-body row\">
$roles
</div>
</div>
";
} elseif (!isset($_SESSION['id']) && isset($_POST['username'])) {
/*if (!isset($_POST['usergroup'])) {
$url = 'location: '.PLATFORM_PATH.'/error.php?errorID=20';
header($url);
exit();
}*/
$content .= '<div class="article-clean">
<div class="d-flex justify-content-center">
<div class="spinner-grow text-warning" style="width: 10rem; height: 10rem;" role="status">
<span class="sr-only">Loading...</span>
</div>
</div>
<div class="text-center"><button type="button" class="btn btn-outline-warning">Loading...</button></div>
</div>';
$usr = new user;
$post_data["username"] = $_POST['username'];
$post_data["password"] = $_POST['password'];
$result = $usr->user_login($post_data);
switch ($result) {
case 1:
$url = $usr->get_base_url() . "index.php";
if ($usr->get_usergroup() == 'parent') {
$sparent = new sparent();
$sparent->retrieve_and_register_childs();
}
$content .= "<meta http-equiv='refresh' content='1; url=" . PLATFORM_PATH . $url . "' />";
break;
/*case -1:
$usr->get_error(11);
break;*/
case 2:
$url = PLATFORM_PATH."/index.php?select_usergroup=1";
$content .= "<meta http-equiv='refresh' content='1; url=" . $url . "' />";
// header("location: $url");
break;
default:
$usr->get_error(11);
break;
}
} else {
$usr = new user();
if (isset($_SESSION['id']) && isset($_SESSION['username']) && !isset($_SESSION['usergroup'])) {
$content .= "<meta http-equiv='refresh' content='0; url=" . PLATFORM_PATH . "/index.php?select_usergroup=1' />";
} elseif($usr->is_logged() && isset($_SESSION['usergroup'])){
$content .= "<meta http-equiv='refresh' content='0; url=" . PLATFORM_PATH . $usr->get_base_url() . "' />";
}
}
$page->setContent($content);
$site->render();
?>