-
Notifications
You must be signed in to change notification settings - Fork 1
/
addAdditionalSensorValue.php
executable file
·69 lines (56 loc) · 1.39 KB
/
addAdditionalSensorValue.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?PHP
////////////////////////////////////////////////////
//
// WeatherOffice
//
// http://www.sourceforge.net/projects/weatheroffice
//
// Copyright (C) 04/2007 Mathias Zuckermann &
// Bernhard Heibler
//
// See COPYING for license info
//
////////////////////////////////////////////////////
function LeadingZero($value)
{
if($value < 10)
return ("0" . $value);
else
return (string)$value;
}
function GetCurrentDate()
{
$today = getdate();
$mon = LeadingZero($today['mon']);
$mday = LeadingZero($today['mday']);
return($today['year'] . "-" . $mon . "-" . $mday);
}
function GetCurrentTimestamp()
{
$today = getdate();
return GetTimestamp($today);
}
function GetTimestamp($today)
{
$mon = LeadingZero($today['mon']);
$mday = LeadingZero($today['mday']);
$hour = LeadingZero($today['hours']);
$min = LeadingZero($today['minutes']);
$sec = LeadingZero($today['seconds']);
return($today['year'] . $mon . $mday . $hour . $min . $sec);
}
include("weatherInclude.php");
$ts = GetCurrentTimestamp();
$id=$argv[1];
$result = $database->getSensorFromId($id);
$database->free();
$active = $result['Active'];
if($active)
{
$filename = $result['filename'];
$linenumber = $result['linenumber'];
$value = GetCurrentSensorValue($filename, $linenumber);
$database->addSensorsValue($id, $ts, $value);
}
$database->close();
?>