www/getispindellog.php

Wed, 10 Aug 2022 15:40:20 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Wed, 10 Aug 2022 15:40:20 +0200
changeset 838
ce5f39b66a51
parent 837
b5e2ff72cc73
permissions
-rw-r--r--

Switch co2pressure graph to MySQL

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"]))
837
b5e2ff72cc73 Switch ispindel graph to MySQL
Michiel Broek <mbroek@mbse.eu>
parents: 627
diff changeset
6 $code = $_GET["code"];
580
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 else
837
b5e2ff72cc73 Switch ispindel graph to MySQL
Michiel Broek <mbroek@mbse.eu>
parents: 627
diff changeset
8 $code = "CB0111";
580
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9
837
b5e2ff72cc73 Switch ispindel graph to MySQL
Michiel Broek <mbroek@mbse.eu>
parents: 627
diff changeset
10 $connect = mysqli_connect(DBASE_HOST, DBASE_USER, DBASE_PASS, DBASE_NAME);
b5e2ff72cc73 Switch ispindel graph to MySQL
Michiel Broek <mbroek@mbse.eu>
parents: 627
diff changeset
11 if (! $connect) {
b5e2ff72cc73 Switch ispindel graph to MySQL
Michiel Broek <mbroek@mbse.eu>
parents: 627
diff changeset
12 die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
601
112c278be803 All graph displays now check if the log excists.
Michiel Broek <mbroek@mbse.eu>
parents: 580
diff changeset
13 }
837
b5e2ff72cc73 Switch ispindel graph to MySQL
Michiel Broek <mbroek@mbse.eu>
parents: 627
diff changeset
14 mysqli_set_charset($connect, "utf8" );
580
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15
837
b5e2ff72cc73 Switch ispindel graph to MySQL
Michiel Broek <mbroek@mbse.eu>
parents: 627
diff changeset
16 $query = "SELECT * FROM log_ispindel WHERE code='".$code."' ORDER BY datetime;";
b5e2ff72cc73 Switch ispindel graph to MySQL
Michiel Broek <mbroek@mbse.eu>
parents: 627
diff changeset
17 $result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect));
b5e2ff72cc73 Switch ispindel graph to MySQL
Michiel Broek <mbroek@mbse.eu>
parents: 627
diff changeset
18 while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
580
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19
837
b5e2ff72cc73 Switch ispindel graph to MySQL
Michiel Broek <mbroek@mbse.eu>
parents: 627
diff changeset
20 $logs[] = array(
b5e2ff72cc73 Switch ispindel graph to MySQL
Michiel Broek <mbroek@mbse.eu>
parents: 627
diff changeset
21 'date' => substr($row['datetime'],0,16),
b5e2ff72cc73 Switch ispindel graph to MySQL
Michiel Broek <mbroek@mbse.eu>
parents: 627
diff changeset
22 'temperature' => $row['temperature'],
b5e2ff72cc73 Switch ispindel graph to MySQL
Michiel Broek <mbroek@mbse.eu>
parents: 627
diff changeset
23 'plato' => $row['plato'],
b5e2ff72cc73 Switch ispindel graph to MySQL
Michiel Broek <mbroek@mbse.eu>
parents: 627
diff changeset
24 'sg' => $row['sg'],
b5e2ff72cc73 Switch ispindel graph to MySQL
Michiel Broek <mbroek@mbse.eu>
parents: 627
diff changeset
25 'battery' => $row['battery']
b5e2ff72cc73 Switch ispindel graph to MySQL
Michiel Broek <mbroek@mbse.eu>
parents: 627
diff changeset
26 );
580
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27 }
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 header("Content-type: application/json");
9cd6873bda75 Fixed ispindel_death. Added ispindel log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29 echo json_encode($logs);

mercurial