-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfetchdata.php
53 lines (44 loc) · 1.52 KB
/
fetchdata.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
<?php
/* AJAX Data Extraction Module */
if (isset($_POST["request"])) {
// Connect to Database
$con = mysql_connect('localhost', 'root', '');
if (!$con) die('Could not connect: ' . mysql_error());
mysql_select_db("chronos", $con);
// Generate Date
$date = date("Ymd");
// Extract PresetID
$sql = mysql_query("SELECT * FROM `schedule` WHERE date = $date");
while($result = mysql_fetch_array($sql))
$presetID = $result['presetID'];
switch ($_POST['request']) {
case "day_type":
if ($presetID == "") echo "N/A";
else {
$sql = mysql_query("SELECT * FROM `schedulepreset` WHERE id = $presetID");
while($result = mysql_fetch_array($sql))
echo $result['name'];
}
break;
case "period":
// Fetch Current Time - Check DST
if (date("I") == 0) $t = date("H:i:s", strtotime('1 hour'));
else $t = date("H:i:s");
// $t = $_POST['jikan'];
$t = "07:50:00";
$sql = mysql_query("SELECT * FROM `schedule_list` WHERE presetID = $presetID ORDER BY `schedule_list`.`order` ASC");
if ($sql) {
while ($result = mysql_fetch_array($sql))
if ($t >= $result['start_time'] && $t < $result['end_time']) echo $result['name'];
} else echo "N/A";
break;
case "ann_check":
$sql = mysql_query("SELECT * FROM 'announcement' WHERE init = 0");
while($result = mysql_fetch_array($sql))
echo $result['name'];
break;
}
// Reset the Request Parameter
unset($_POST['request']);
}
?>