-
Notifications
You must be signed in to change notification settings - Fork 1
/
strict-mode-timeout.php
190 lines (158 loc) · 5.56 KB
/
strict-mode-timeout.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
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
<?php
include_once("./server/db_connection.php");
include_once("./server/validation.php");
include_once("./server/functions.php");
session_start();
$aboutSite = $connection->query("SELECT * FROM `system_data`");
$aboutSite = $aboutSite->fetch_array(MYSQLI_ASSOC);
$mainLogo = 'http://' . $_SERVER['HTTP_HOST'] . $aboutSite['system_logo'];
if(isset($_POST['email']) && isset($_POST['password']))
{
$email = htmlspecialchars($_POST['email']);
$psw = htmlspecialchars($_POST['password']);
loginUser($email, $psw);
}
$uid = $_SESSION['user']['uid'];
$checkStrictMode = "SELECT * FROM `strict_mode` WHERE `uid`='$uid'";
$result = mysqli_query($connection, $checkStrictMode);
if(!$result){
header("Location: feed.php");
exit();
}
$result = mysqli_fetch_assoc($result);
if($result['strictMode']==1 && $result['autoRenew']==1)
{
$today = date("Y-m-d");
if(strtotime($result['today_date'])!=strtotime($today))
{
$renewStrictMode = "UPDATE `strict_mode` SET `today_date`='$today',`endStrictDate`='$today', `availableAccessSeconds`=`maxAccessSeconds` WHERE `uid`='$uid'";
mysqli_query($connection, $renewStrictMode);
header("Location: feed.php");
}
}else if($result['strictMode']==1 && $result['autoRenew']==0)
{
$today = date("Y-m-d");
if(strtotime($result['today_date'])!=strtotime($today))
{
$delete = "DELETE FROM `strict_mode` WHERE `uid`='$uid'";
mysqli_query($connection, $delete);
header("Location: feed.php");
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Timeout -
<?php echo $aboutSite['system_name']; ?>
</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="./assets/css/all.css">
<link rel="stylesheet" href="./assets/css/fontawesome.css">
<link
href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"
rel="stylesheet">
<link rel="stylesheet" href="./assets/css/login.css">
<link rel="shortcut icon" href="./assets/images/favicon.ico" type="image/x-icon">
<style>
/* ALEN : Content Space -----------------------*/
.body{
height: 80vh;
position: relative;
}
.wrapper{
position: absolute;
background-color: #295fff5e;
width: 100%;
height: 100%;
align-items: center;
justify-content: center;
display: none;
}
.modal{
background-color: #ffffff;
padding: 20px;
display: flex;
flex-direction: column;
text-align: center;
align-items: center;
justify-content: center;
border-radius: 8px;
width: 50%;
position: relative;
}
.modal-close{
height: 30px;
width: 30px;
position: absolute;
top: 0;
right: 0;
background-color: #FF204E;
cursor: pointer;
}
.modal-close:hover{
background-color: red;
}
.btn{
border: none;
}
.btn-green{
background-color: cadetblue;
}
.btn-red{
background-color: #FF204E;
}
</style>
</head>
<body>
<!-- Modal Wrapper -->
<div class="wrapper">
<div class="modal">
<span class="modal-close">x</span>
<form action="./server/api/strict-mode/removeStrictMode.php" method="POST">
<div class="modal-head">
<p class="modal-title">Are you sure you want to exit Strict mode?</p>
</div>
<hr>
<div>
<input class="btn btn-green" type="submit" value="Yes">
<button class="btn btn-red closeModal" type="button">No</button>
</div>
</form>
</div>
</div>
<div class="left">
<img id="logo" src="./<?php echo $aboutSite['system_logo']; ?>" alt="logo">
<h1>
<?php echo $aboutSite['system_name']; ?>
</h1>
<span id="description">
<?php echo $aboutSite['system_description']; ?>
</span>
</div>
<div class="right">
<span class="page-title">Strict Mode - Timeout</span>
<div class="signup-error">Strict Mode is Active till the end of <?php echo date("M d, Y"); ?>.</div>
<a href="feed.php">Reload</a>
<a style="padding: 20px; margin:20px;background-color:lightgreen;" href="logout.php">Logout</a>
<button id="exitStrictMode" style="border:none;padding: 5px; margin:20px;background-color: rgba(255, 0, 0, 0.45); border-radius:20px;cursor:pointer;">Exit Strict mode</button>
</div>
</body>
<script src="./assets/scripts/jquery.js"></script>
<script>
// ALEN : Update Modal Button -> Show Modal
$("#exitStrictMode").click(()=>{
$(".wrapper").css({"display":"flex"});
})
// ALEN : Hide Modal
$(".modal-close").click(()=>{
$(".wrapper").css({"display":"none"});
})
$(".closeModal").click(()=>{
$(".wrapper").css({"display":"none"});
})
</script>
</html>