-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserAuth.php
More file actions
executable file
·99 lines (99 loc) · 2.58 KB
/
UserAuth.php
File metadata and controls
executable file
·99 lines (99 loc) · 2.58 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
ini_set("session.cookie_httponly", True);
session_start();
$expire = 1800;
if (isset($_SESSION['lastAction'])){
$inactive = time() - $_SESSION['lastAction'];
if ($inactive >= $expire){
session_unset();
session_destroy();
}
else{
$_SESSION['lastAction'] = time();
}
}
else{
//header("location:login");
}
if (isset($_SESSION['user'])){
require_once('database.php');
$pageName = strtolower(basename($_SERVER['PHP_SELF'], ".php"));
$query = 'SELECT * FROM Users WHERE ID = ?';
$stmt = $conn->prepare($query);
$stmt->bind_param('i', $_SESSION['userID']);
$stmt->execute();
$result = $stmt->get_result();
$row = mysqli_fetch_assoc($result);
$role = $row['Role'];
switch ($pageName){
case "addBreed":
if ($role != "1" && $role != "2"){
header("location:login");
}
break;
case "editBreed":
if ($role != "1" && $role != "2"){
header("location:login");
}
break;
case "addGene":
if ($role != "1" && $role != "2"){
header("location: Dashboard");
}
break;
case "editGene":
if ($role != "1" && $role != "2"){
header("location: Dashboard");
}
break;
case "addSNP":
if ($role != "1" && $role != "2"){
header("location: Dashboard");
}
break;
case "editSNP":
if ($role != "1" && $role != "2"){
header("location: Dashboard");
}
break;
case "addTraitValue":
if ($role != "1" && $role != "2"){
header("location: Dashboard");
}
break;
case "editTraitValue":
if ($role != "1" && $role != "2"){
header("location: Dashboard");
}
break;
case "addUser":
if ($role != "1"){
header("location: Dashboard");
}
break;
case "editUser":
if ($role != "1"){
header("location: Dashboard");
}
break;
case "Users":
if ($role != "1"){
header("location: Dashboard");
}
break;
case "User":
if ($role != "1"){
header("location: Dashboard");
}
break;
case "editUser":
if ($role != "1"){
header("location: Dashboard");
}
break;
}
}
else{
//header("location:login");
}
?>