www/getbrewlog.php

Mon, 25 Feb 2019 22:53:41 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Mon, 25 Feb 2019 22:53:41 +0100
changeset 295
cbace196bdbf
parent 294
1e09d1d102a8
child 296
69fadd1aded2
permissions
-rw-r--r--

Forgot one file in the install list

294
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 <?php
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 require_once('config.php');
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 if (isset($_GET["code"]))
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 $code = $_GET["code"];
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 else
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 $code = "CB0011";
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 $connect = mysqli_connect(DBASE_HOST, DBASE_USER, DBASE_PASS, DBASE_NAME);
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 if (! $connect) {
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 }
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 mysqli_set_charset($connect, "utf8" );
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 $query = "SELECT * FROM log_brews WHERE product_code='".$code."' ORDER BY datetime;";
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 $result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect));
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 $lines[] = array(
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20 'record' => $row['record'],
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21 'date' => substr($row['datetime'],0,16),
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22 'version' => $row['version'],
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23 'code' => $row['product_code'],
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24 'name' => $row['product_name'],
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25 'pv_mlt' => $row['temperature_mlt'],
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
26 'pv_bk' => $row['temperature_bk'],
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27 'pv_hlt' => $row['temperature_hlt'],
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 'pv_room' => $row['temperature_room'],
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29 'sp_mlt' => $row['setpoint_mlt'],
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30 'sp_bk' => $row['setpoint_bk'],
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31 'sp_hlt' => $row['setpoint_hlt'],
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32 'event' => $row['event']
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33 );
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
34 }
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
35
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
36 echo json_encode($lines);

mercurial