-
Notifications
You must be signed in to change notification settings - Fork 1
/
inputSensorData.php
76 lines (44 loc) · 2.04 KB
/
inputSensorData.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
<?php
require_once 'AL_hidden_values.php';
require_once 'database_connection.php';
$info = $_GET["info"];
$data = $_GET["readings"];
$dateTimeArray= array();
$UTCArray = array ();
$MethodID = "1";
$QualityControlLevelID = "0";
$CensorCode = "nc";
$UTCOffset = "-7";
$parsedInfo = explode(",",$info);
$SourceID = $parsedInfo[0];
$SiteID= $parsedInfo[1];
$VariableID1 = $parsedInfo[2];
$VariableID2= $parsedInfo[3];
$PastTimeStamps = file_get_contents("DateRepository.txt");
$parsedData = explode(";",$data);
$sql7 ="INSERT INTO `datavalues`(`DataValue`, `LocalDateTime`, `UTCOffset`, `DateTimeUTC`, `SiteID`, `VariableID`, `CensorCode`, `MethodID`, `SourceID`, `QualityControlLevelID`) VALUES ";
for($i=0, $size=count($parsedData); $i<$size; ++$i){
$parsedMoreData = explode(",",$parsedData[$i]); //parses the individual data records
$mydate="20".$parsedMoreData[0].",".$parsedMoreData[1]; //formats the date so that it is 2014 instead of 14 and adds time value
$timestamp=strtotime($mydate);
$mydate = date('Y-m-d H:i:s', $timestamp);
array_push($dateTimeArray,$mydate);
if (strpos($PastTimeStamps, $mydate)!== false){
continue;
}
$ms = $UTCOffset * 3600;
$utctimestamp = $timestamp - ($ms);
$DateTimeUTC = date("Y-m-d H:i:s", $utctimestamp);
$sql7.="('$parsedMoreData[2]', '$mydate', '$UTCOffset', '$DateTimeUTC', '$SiteID', '$VariableID1', '$CensorCode', '$MethodID', '$SourceID', '$QualityControlLevelID'), ";
$sql7.="('$parsedMoreData[3]', '$mydate', '$UTCOffset', '$DateTimeUTC', '$SiteID', '$VariableID2', '$CensorCode', '$MethodID', '$SourceID', '$QualityControlLevelID'), ";
}
file_put_contents("DateRepository.txt", $dateTimeArray);
$sql7=substr($sql7,0,(strlen($sql7)-2));
echo ($sql7);
$result7 = @mysql_query($sql7,$connection)or die(mysql_error());
echo($result7);
echo ("tests");
require_once 'update_series_catalog_function.php';
update_series_catalog($SiteID, $VariableID1, $MethodID, $SourceID, $QualityControlLevelID);
update_series_catalog($SiteID, $VariableID2, $MethodID, $SourceID, $QualityControlLevelID);
?>