-
Notifications
You must be signed in to change notification settings - Fork 0
/
ss_temperature_room.php
38 lines (27 loc) · 1.01 KB
/
ss_temperature_room.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
<?php
require_once("/home/cacti/www_secure/db.php");
/* do NOT run this script through a web browser */
if (!isset($_SERVER["argv"][0]) || isset($_SERVER['REQUEST_METHOD']) || isset($_SERVER['REMOTE_ADDR'])) {
die("<br><strong>This script is only meant to run at the command line.</strong>");
}
$no_http_headers = true;
/* display ALL errors */
error_reporting(0);
if (!isset($called_by_script_server)) {
include_once(dirname(__FILE__) . "/../include/global.php");
array_shift($_SERVER['argv']);
print call_user_func_array("ss_temperature", $_SERVER['argv']);
}
function ss_temperature($room) {
$idb = db_link();
$query = "SELECT t.name as name, t.temperature as temperature FROM temperature t WHERE name IS NOT NULL and timestampdiff(minute, t.time, UTC_TIMESTAMP()) < 20";
$result = $idb->query($query);
$output = "";
while ($row = $result->fetch_object()) {
if ($row->name == $room) {
return 'Temperature:'.$row->temperature;
}
}
return "";
}
?>