-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogme.php
More file actions
88 lines (75 loc) · 3.11 KB
/
logme.php
File metadata and controls
88 lines (75 loc) · 3.11 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
<?php
include "links.php";
if(isset($_POST['submitLog'])){
$username = $_POST['username'];
$statusNow = $_POST['statusNow'];
// Get the values from table to use them laters
$getSessionData = mysql_query("SELECT * FROM $tbName WHERE $clmUsrName = '$username' AND $selectTime");
while($showSessionData = mysql_fetch_array($getSessionData)){
$checkMorIn = $showSessionData['morChkIn'];
$checkMorOut = $showSessionData['morChkOut'];
$checkEveIn = $showSessionData['eveChkIn'];
$checkEveOut = $showSessionData['eveChkOut'];
}
switch($statusNow){
//If not logged In, lets login
case $lang['NO']:
if($checkMorIn == '00:00:00'){$canCheckMorIn = true;}else {$canCheckMorIn = false;}
if($checkEveIn == '00:00:00'){$canCheckEveIn = true;}else {$canCheckEveIn = false;}
if($canCheckMorIn){
if(time() > $morIn){
// Can login morning
mysql_query("UPDATE $tbName SET $clmStatus = '$yes',$morChkIn = CURTIME() WHERE $clmUsrName = '$username' AND $selectTime");
} else {
// Cannot login Morning
header("Location: " . $_SERVER['HTTP_REFERER'] . "?error=CANNOT_LOGIN&userTry=" . $username);
return false;
}
} else if ($canCheckEveIn){
if(time() > $eveIn){
//Can login Evening
mysql_query("UPDATE $tbName SET $clmStatus = '$yes',$eveChkIn = CURTIME() WHERE $clmUsrName = '$username' AND $selectTime");
} else {
// Cannot Login Evening
header("Location: " . $_SERVER['HTTP_REFERER'] . "?error=CANNOT_LOGIN&userTry=" . $username);
return false;
}
} else {
// Already Checked In ($canCheck_* is false here)
header("Location: " . $_SERVER['HTTP_REFERER'] . "?error=ALREADY_CHECKED_IN&userTry=" . $username);
return false;
}
break;
//If logged In, lets logout
case $lang['YES']:
if($checkMorOut == '00:00:00'){$canCheckMorOut = true;}else {$canCheckMorOut = false;}
if($checkEveOut == '00:00:00'){$canCheckEveOut = true;}else {$canCheckEveOut = false;}
if($canCheckMorOut){
if(time() > $morOut){
// Can check out of morning
mysql_query("UPDATE $tbName SET $clmStatus = '$no',$morChkOut = CURTIME() WHERE $clmUsrName = '$username' AND $selectTime");
} else {
// Cannot Check Out of Morning
header("Location: " . $_SERVER['HTTP_REFERER'] . "?error=CANT_LOGOUT&userTry=" . $username);
return false;
}
} else if ($canCheckEveOut){
if(time() > $eveOut){
// Can check out of evening
mysql_query("UPDATE $tbName SET $clmStatus = '$no', $eveChkOut = CURTIME() WHERE $clmUsrName = '$username' AND $selectTime");
} else {
// Cannot check out of evening
header("Location: " . $_SERVER['HTTP_REFERER'] . "?error=CANT_LOGOUT&userTry=" . $username);
return false;
}
} else {
// You are already Checked Out ($canCheckOut_* is false)
header("Location: " . $_SERVER['HTTP_REFERER'] . "?error=ALREADY_CHECKED_OUT&userTry=" . $username . "&alreadycheckin=yes");
return false;
}
break;
default: echo "Logging Error"; break;
}
header("Location: " . $_SERVER['HTTP_REFERER']);
}
?>