-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtimer.php
More file actions
31 lines (27 loc) · 833 Bytes
/
Copy pathtimer.php
File metadata and controls
31 lines (27 loc) · 833 Bytes
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
<?php
//CORS Headers
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: *");
//HTTP inputs
$rest_json = file_get_contents("php://input");
$_POST = json_decode($rest_json, true);
$con = mysqli_connect("localhost", "root", "", "othscmsdb");
$sql = "SELECT * from timer";
$res = mysqli_query($con, $sql);
if(mysqli_num_rows($res)>0){
while($row = mysqli_fetch_assoc($res)){
if($row['paused']==1){
$newval = $row['timer']-$row['now'];
}else{
$newval = $row['timer']-time();
}
$response = $newval;
if($response<0){
$response = 0;
}
echo json_encode($response);
exit;
}
}
echo json_encode($response);
?>