1 | <?php
|
---|
2 |
|
---|
3 |
|
---|
4 | if (!isset($_POST['n']))
|
---|
5 | return header('HTTP/1.0 400 Syntax error.');
|
---|
6 |
|
---|
7 | // ================================================================
|
---|
8 | // Database interaction
|
---|
9 | // ================================================================
|
---|
10 |
|
---|
11 | function query($query)
|
---|
12 | {
|
---|
13 | $sql = mysql_query($query);
|
---|
14 | if (!$sql)
|
---|
15 | die(mysql_error());
|
---|
16 |
|
---|
17 | $rows = array();
|
---|
18 | while($row = mysql_fetch_assoc($sql))
|
---|
19 | $rows[] = $row;
|
---|
20 |
|
---|
21 | print(json_encode($rows).'\n');
|
---|
22 | }
|
---|
23 |
|
---|
24 | // ----------------------------------------------------------------
|
---|
25 |
|
---|
26 | $cut = "";
|
---|
27 | if (isset($_POST['t']))
|
---|
28 | {
|
---|
29 | $cut = $_POST['n'].' '.$_POST['t'];
|
---|
30 |
|
---|
31 | $d = new DateTime($cut);
|
---|
32 | if ($d->format("His")<120000)
|
---|
33 | {
|
---|
34 | $d->add(new DateInterval('P1D')); // PnYnMnDTnHnMnS
|
---|
35 | $cut = $d->format("Y-m-d H:i:s");
|
---|
36 | }
|
---|
37 |
|
---|
38 | $cut = " AND fStart>'".$cut."' ";
|
---|
39 | }
|
---|
40 |
|
---|
41 | // ----------------------------------------------------------------
|
---|
42 |
|
---|
43 | require_once 'config.php';
|
---|
44 |
|
---|
45 | $db = mysql_connect($dbhost,$dbuser,$dbpass);
|
---|
46 | if (!$db)
|
---|
47 | die(mysql_error());
|
---|
48 |
|
---|
49 | if (!mysql_select_db($dbname, $db))
|
---|
50 | die(mysql_error());
|
---|
51 |
|
---|
52 | /*mixed date_sunrise ( int $timestamp [, int $format = SUNFUNCS_RET_STRING [, float $latitude = ini_get("date.default_latitude") [, float $longitude = ini_get("date.default_longitude") [, float $zenith = ini_get("date.sunrise_zenith") [, float $gmt_offset = 0 ]]]]] )*/
|
---|
53 |
|
---|
54 | query("SELECT DISTINCT(DATE(ADDTIME(fStart, '-12:00'))) AS 'd' FROM Schedule");
|
---|
55 | query("SELECT fSourceKEY AS 'key', fSourceName AS 'val' FROM Source WHERE fSourceTypeKEY=1");
|
---|
56 | query("SELECT fMeasurementKEY AS 'key', fMeasurement AS 'val' FROM Measurement");
|
---|
57 | query("SELECT * FROM Schedule WHERE DATE(ADDTIME(fStart, '-12:00:00')) = '".$_POST['n']."'".$cut."ORDER BY fScheduleID ASC, fMeasurementID ASC");
|
---|
58 |
|
---|
59 | //sleep(3);
|
---|
60 |
|
---|
61 | //print($test1."|".$test2."|".$test3."|SELECT * FROM Schedule WHERE DATE(ADDTIME(fStart, '-12:00:00')) = '".$_POST['day']."'".$cut."ORDER BY fScheduleID ASC, fMeasurementID ASC\n");
|
---|
62 |
|
---|
63 | ?>
|
---|