-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathauthenticate.php
101 lines (94 loc) · 3.12 KB
/
authenticate.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
<?php
include 'assets/backend/connect.php';
include 'assets/backend/core.php';
require 'assets/backend/data.php';
if(isset($_SESSION['user_id']) && !empty($_SESSION['user_id']))
{
if(isset($_POST['send'])){
$arr= array();
if(preg_replace( "/\r|\n/", "", $_POST["credential"] ) == "sub1"){
$queryg="SELECT * FROM attendence WHERE id=".$user_id;
$queryg_run=mysqli_query($con,$queryg);
$atten=mysqli_fetch_assoc($queryg_run);
$attenint=$atten[$_POST["credential"]]+1;
if(function_exists('date_default_timezone_set')) {
date_default_timezone_set("Asia/Kolkata");
}
$now = time(); // or your date as well
$your_date = strtotime($atten["sub1time"]);
$datediff = $now - $your_date;
$days = floor($datediff / (60 * 60 * 24));
// then use the date functions, not the other way around
$date = date("y/m/d H:i:s");
if($days>=1)
{
$queryu="UPDATE attendence SET sub1=".$attenint.", sub1time='".$date."' WHERE id=".$user_id;
if($queryu_run=mysqli_query($con,$queryu))
{
$arr['success'] = true;
}
}else {
$arr['success'] = "already";
}
}else if(preg_replace( "/\r|\n/", "", $_POST["credential"] ) == "sub2"){
$queryg="SELECT * FROM attendence WHERE id=".$user_id;
$queryg_run=mysqli_query($con,$queryg);
$atten=mysqli_fetch_assoc($queryg_run);
$attenint=$atten[$_POST["credential"]]+1;
if(function_exists('date_default_timezone_set')) {
date_default_timezone_set("Asia/Kolkata");
}
$now = time(); // or your date as well
$your_date = strtotime($atten["sub2time"]);
$datediff = $now - $your_date;
$days = floor($datediff / (60 * 60 * 24));
// then use the date functions, not the other way around
$date = date("y/m/d H:i:s");
if($days>=1)
{
$queryu="UPDATE attendence SET sub2=".$attenint.", sub2time='".$date."' WHERE id=".$user_id;
if($queryu_run=mysqli_query($con,$queryu))
{
$arr['success'] = true;
}
}else {
$arr['success'] = "already";
}
}else if(preg_replace( "/\r|\n/", "", $_POST["credential"] ) == "sub3"){
$queryg="SELECT * FROM attendence WHERE id=".$user_id;
$queryg_run=mysqli_query($con,$queryg);
$atten=mysqli_fetch_assoc($queryg_run);
$attenint=$atten[$_POST["credential"]]+1;
if(function_exists('date_default_timezone_set')) {
date_default_timezone_set("Asia/Kolkata");
}
$now = time(); // or your date as well
$your_date = strtotime($atten["sub3time"]);
$datediff = $now - $your_date;
$days = floor($datediff / (60 * 60 * 24));
// then use the date functions, not the other way around
$date = date("y/m/d H:i:s");
if($days>=1)
{
$queryu="UPDATE attendence SET sub3=".$attenint.", sub3time='".$date."' WHERE id=".$user_id;
if($queryu_run=mysqli_query($con,$queryu))
{
$arr['success'] = true;
}
}else {
$arr['success'] = "already";
}
}
else {
$arr['success'] = false;
}
//echo "<script>alert('ey')</script>";
echo json_encode($arr);
}
}else
{
echo '<script type="text/javascript">';
//echo 'window.location.href="login.php";';
echo '</script>';
}
?>