-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
322 lines (263 loc) · 10.5 KB
/
Copy pathindex.php
File metadata and controls
322 lines (263 loc) · 10.5 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
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
<?php
session_start();
//print("Current1: ".$_SESSION['currentURL']);
// Check if cookie is set
if (isset($_COOKIE['privacyAccepted'])) {
$_SESSION['privacyAccepted'] = $_COOKIE['privacyAccepted'];
/*if ($_COOKIE['privacyAccepted']=="false") {
header("Location: bye.html");
exit();
}*/
} else {
$_SESSION['privacyAccepted'] = null;
}
?>
<?php
//if(isset($_POST['commit'])){
date_default_timezone_set('Africa/Kigali');
if(isset($_POST['commit'])){
$tdate=date("Y-m-d");
$time=date("H:i:s:a");
$userrole=$_POST['login'];
$userpsw=$_POST['password'];
//$userpsw=md5($userpsw);
$userpsw=hash('sha256', $userpsw);
include('connect.php');
$userrole=mysqli_real_escape_string($conn,$userrole);
$userrole=str_replace(",","",$userrole);
$userrole=str_replace("'","",$userrole);
$userrole=str_replace(";","",$userrole);
$userrole=str_replace("\"","",$userrole);
$userrole=str_replace("drop","",$userrole);
$userrole=str_replace("DROP","",$userrole);
$userrole=str_replace("delete","",$userrole);
$userrole=str_replace("DELETE","",$userrole);
$userrole=str_replace("INSERT","",$userrole);
$userrole=str_replace("insert","",$userrole);
$userrole=str_replace("update","",$userrole);
$userrole=str_replace("UPDATE","",$userrole);
$userrole=str_replace("truncate","",$userrole);
$userrole=str_replace("TRUNCATE","",$userrole);
$reslog=mysqli_query($conn,"SELECT * FROM users WHERE username='$userrole' AND password='$userpsw' AND authorized='YES'");
if($num=mysqli_num_rows($reslog)){
$ip="";
if(isset($_SERVER['REMOTE_HOST'])){//check
$ip = $_SERVER['REMOTE_HOST'];
}else{
$ip = $_SERVER['REMOTE_ADDR'];//else assign the real IP
}
// $result = json_decode(file_get_contents('http://ip-api.io/json/'.$ip));
//To display how data are mapped
//var_dump($result);
$other_info = "IP:".$ip;
// Country:".$result->country_name.", City:".$result->city.", Organisation:".$result->organisation;
while($row=mysqli_fetch_array($reslog)){
session_start();
//$_SESSION['timeout']=time();
$_SESSION['hruseridsession']=$row['userid'];
$_SESSION['hrusernamesession']=$row['username'];
$_SESSION['hrpasswordsession']=$row['password'];
$_SESSION['firstnamesession']=$row['firstname'];
$_SESSION['lastnamesession']=$row['lastname'];
$_SESSION['hrrolesession']=$row['role'];
$_SESSION['sitesession']=$row['site'];
$_SESSION['authorizedsession']=$row['authorized'];
$_SESSION['department']=$row['department'];
$_SESSION['position']=$row['position'];
$_SESSION['supervisor']=$row['supervisor'];
$_SESSION['headofdepartment']=$row['headofdepartment'];
$userId=$row['userid'];;
$loginDate=date("Y-m-d");
$log=mysqli_query($conn,"insert into user_login(user_id,date_and_time,other_info) values ('$userId','$loginDate','$other_info')");
}
if($_SESSION['currentURL']!==null) {
header("location:".$_SESSION['currentURL']);
}else {
header("location:homepage.php");
}
}
else{
?>
<script type="text/javascript">
alert("Please Check Username and Password or contact Administrator");
</script>
<?php
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Welcome to IMB/HR System</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--===============================================================================================-->
<link rel="icon" type="image/png" href="login/images/icons/favicon.ico"/>
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="login/vendor/bootstrap/css/bootstrap.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="login/fonts/font-awesome-4.7.0/css/font-awesome.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="login/vendor/animate/animate.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="login/vendor/css-hamburgers/hamburgers.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="login/vendor/select2/select2.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="login/css/util.css">
<link rel="stylesheet" type="text/css" href="login/css/main.css">
<!--===============================================================================================-->
<style>
.privacy-popup {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
background-color: #f9f9f9;
padding: 15px;
text-align: left;
box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1);
display: none;
font-size: 10px;
}
.privacy-popup button {
margin: 0 10px;
padding: 10px 20px;
border: none;
cursor: pointer;
}
#acceptBtn {
background-color: green;
color: white;
}
#denyBtn {
background-color: red;
color: white;
}
</style>
</head>
<body>
<!-- Privacy Notice -->
<div id="privacyNotice" class="privacy-popup">
<p><h4>Privacy Notice Summary</h4>
Effective Date: September 15, 2023<br><br>
At Partners In Health | Inshuti Mu Buzima (PIH|IMB), we prioritize your privacy. We collect personal information such as your name, email, and usage data to monitor system use, and contact you when needed. Your data is securely stored and shared only with authorized entities when legally required.
<br>
By continuing, you confirm that you have read and agree to our Privacy Notice, which outlines your rights, including access, rectification, and objection to data processing.</p>
<a href="privacynotice.html" target="_blank" title="Read Full Privacy Notice">Read Full Privacy Notice</a> <br>
<button id="acceptBtn">Accept</button>
<!-- <button id="denyBtn">Deny</button> -->
</div>
<div class="limiter">
<div class="container-login100">
<div class="wrap-login100">
<div class="login100-pic js-tilt" data-tilt>
<div style="text-align: center;"><img src="Group_181.png" alt="IMG" width="300"></div>
<!-- <img src="login/images/imblogo.png" alt="IMG"> -->
<span class="login100-form-title">
<font size="4">Human Resources System</font>
</span>
</div>
<form class="login100-form validate-form" method="post" action="index.php">
<span class="login100-form-title">
Member Login
</span>
<div class="wrap-input100 validate-input" data-validate = "Valid email is required: ex@abc.xyz">
<input class="input100" type="text" name="login" placeholder="User Name">
<span class="focus-input100"></span>
<span class="symbol-input100">
<i class="fa fa-envelope" aria-hidden="true"></i>
</span>
</div>
<div class="wrap-input100 validate-input" data-validate = "Password is required">
<input class="input100" type="password" name="password" placeholder="Password">
<span class="focus-input100"></span>
<span class="symbol-input100">
<i class="fa fa-lock" aria-hidden="true"></i>
</span>
</div>
<?php
if ($_COOKIE['privacyAccepted']=="true") {
?>
<div class="container-login100-form-btn" id="loginbtn">
<input type="submit" name="commit" value="Login" class="login100-form-btn">
</div>
<?php
}
?>
<div class="text-center p-t-12">
<!-- <span class="txt1">
Forgot/Change
</span> -->
<a class="txt2" href="changepassword.php">
Forgot/Change Password?
</a>
<br><br>
<a href="privacynotice.html" target="_blank" title="Read Full Privacy Notice">Privacy Notice</a>
</div>
</form>
</div>
</div>
</div>
<!--===============================================================================================-->
<script src="login/vendor/jquery/jquery-3.2.1.min.js"></script>
<!--===============================================================================================-->
<script src="login/vendor/bootstrap/js/popper.js"></script>
<script src="login/vendor/bootstrap/js/bootstrap.min.js"></script>
<!--===============================================================================================-->
<script src="login/vendor/select2/select2.min.js"></script>
<!--===============================================================================================-->
<script src="login/vendor/tilt/tilt.jquery.min.js"></script>
<script >
$('.js-tilt').tilt({
scale: 1.1
})
</script>
<!--===============================================================================================-->
<script src="login/js/main.js"></script>
<!-- <script src="script.js"></script> -->
<script type="text/javascript" >
document.addEventListener("DOMContentLoaded", function() {
const privacyPopup = document.getElementById("privacyNotice");
const acceptBtn = document.getElementById("acceptBtn");
const denyBtn = document.getElementById("denyBtn");
const loginbtn = document.getElementById("loginbtn");
// Check if session cookie exists
if (!getCookie("privacyAccepted")) {
privacyPopup.style.display = "block";
}
// Accept Button Click
acceptBtn.onclick = function() {
setCookie("privacyAccepted", "true", 30); // Set for 30 days
privacyPopup.style.display = "none";
location.reload();
loginbtn.style.display = "block";
};
// Deny Button Click
denyBtn.onclick = function() {
setCookie("privacyAccepted", "false", 30); // Set for 30 days
privacyPopup.style.display = "none";
window.location.href = "bye.html";
};
// Set Cookie Function
function setCookie(name, value, days) {
let date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
//date.setTime(date.getTime() + (60 * 1000));
document.cookie = name + "=" + value + ";expires=" + date.toUTCString() + ";path=/";
}
// Get Cookie Function
function getCookie(name) {
let cookieArr = document.cookie.split(";");
for (let i = 0; i < cookieArr.length; i++) {
let cookiePair = cookieArr[i].split("=");
if (name === cookiePair[0].trim()) {
return cookiePair[1];
}
}
return null;
}
});
</script>
</body>
</html>