www/getispindellog.php

Sat, 25 Sep 2021 10:42:54 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sat, 25 Sep 2021 10:42:54 +0200
changeset 778
e64fd38c469c
parent 627
f1a7c14d5601
permissions
-rw-r--r--

If during styles import the CATEGORY_NUMBER is empty, insert 0 in the database instead.

580
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 <?php
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 require_once('config.php');
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 if (isset($_GET["code"]))
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 $code = $_GET["code"] . ' ' . $_GET["name"];
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 else
627
f1a7c14d5601 3 decimal places for the SG
Michiel Broek <mbroek@mbse.eu>
parents: 601
diff changeset
8 $code = "CB0081 Keuls";
580
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 $filename = 'log/ispindel/' . $code . '.log';
601
112c278be803 All graph displays now check if the log excists.
Michiel Broek <mbroek@mbse.eu>
parents: 580
diff changeset
11 if (! file_exists($filename)) {
112c278be803 All graph displays now check if the log excists.
Michiel Broek <mbroek@mbse.eu>
parents: 580
diff changeset
12 header("Content-type: application/json");
112c278be803 All graph displays now check if the log excists.
Michiel Broek <mbroek@mbse.eu>
parents: 580
diff changeset
13 echo '{}';
112c278be803 All graph displays now check if the log excists.
Michiel Broek <mbroek@mbse.eu>
parents: 580
diff changeset
14 exit;
112c278be803 All graph displays now check if the log excists.
Michiel Broek <mbroek@mbse.eu>
parents: 580
diff changeset
15 }
112c278be803 All graph displays now check if the log excists.
Michiel Broek <mbroek@mbse.eu>
parents: 580
diff changeset
16
580
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 /*
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 * 2014-11-15 18:39:12,TEMPERATURE,PLATO,SG,BATTERY,ANGLE,INVERVAL,UUID
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20 * | | | | |
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21 * datetime + | | | |
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22 * temperature ------------+ | | |
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23 * density plato --------------------+ | |
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24 * density sg ----------------------------+ |
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25 * battery ------------------------------------+
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
26 */
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27 $handle = @fopen($filename, "r");
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 if ($handle) {
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29 $lines = 0;
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30 while (($buffer = fgets($handle, 4096)) !== false) {
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32 $buffer = preg_replace( "/\r|\n/", "", $buffer);
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33 $row = explode(",", $buffer);
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
34 $lines++;
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
35
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
36 $logs[] = array(
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
37 'date' => $row[0],
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
38 'temperature' => $row[1],
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
39 'plato' => $row[2],
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
40 'sg' => $row[3],
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
41 'battery' => $row[4]
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
42 );
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
43 }
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
44 if (!feof($handle)) {
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
45 echo "Error: unexpected fgets() fail\n";
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
46 }
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
47 fclose($handle);
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
48 }
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
49 header("Content-type: application/json");
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
50 echo json_encode($logs);

mercurial