-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path19001654_lbs.php
117 lines (70 loc) · 1.94 KB
/
19001654_lbs.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
###[DEF]###
[name = Add2Datenarchiv ]
[e#1 important = Data ]
[e#2 important = Timestamp ]
[e#3 important = Microseconds #init=0 ]
[e#4 important = Datenarchiv ID ]
[a#1 = Error ]
[a#10 = Debug ]
###[/DEF]###
###[HELP]###
Inputs:
E1 - Data: Data to save
E2 - Timestamp: The Timestamp in Seconds since epoch (UNIX/POSIX Timestamp) with optional fraction after a decimal point
E3 - Microseconds: Microseconds of the Second (0-999999), only used if E2 has no fraction
E4 - Datenarchiv ID: The ID of the edomi Datenarchiv
Outputs:
A1 - Error reserved
A10 - Debug: The SQL-Query used
This LBS inserts data into a Datenarchiv with the given timestamp.
Tested with edomi 1.64 only. Use with caution!
Versions:
V0.10 2019-09-20 SirSydom
Open Issues:
- A1
Author:
SirSydom - [email protected]
Copyright (c) 2019 SirSydom
Github:
https://github.com/SirSydom/edomi_LBS_sirsydom/releases/tag/19001654_V0.10
Links:
Contributions:
###[/HELP]###
###[LBS]###
<?
function LB_LBSID($id)
{
if ($E=logic_getInputs($id))
{
if ($E[1]['refresh'] == 1 && $E[1]['value'] != null)
{
$archivDb='archivKoData';
$archivId=$E[4]['value'];
$value = $E[1]['value'];
$timestamp = $E[2]['value'];
$time_arr = explode(".", $timestamp);
if(count($time_arr) > 1)
{
$datetime = $time_arr[0];
$digits = strlen($time_arr[1]);
$ms = $time_arr[1] * pow(10,(6 - $digits));
}
else
{
$datetime = $timestamp;
$ms = $E[3]['value'];
}
$query = "INSERT INTO `archivKoData` (`datetime`, `ms`, `targetid`, `gavalue`) VALUES (FROM_UNIXTIME(" . $datetime . "), '" . $ms ."', '" . strVal($archivId) . "', '" . $value . "')";
$con = mysql_connect("localhost","root","");
mysql_select_db("edomiLive", $con);
$result = mysql_query($query, $con);
logic_setOutput($id,10,$query);
}
}
}
?>
###[/LBS]###
###[EXEC]###
<?
?>
###[/EXEC]###