????JFIF??x?x????'
Server IP : 79.136.114.73 / Your IP : 3.22.79.2 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/rock_backup/ |
Upload File : |
<?php include 'setup.php'; $mysqli = new mysqli("www.astacus.se", "carlhoffstedt", "Astacus2020!", "energicontrol"); $url = 'https://api.sunrise-sunset.org/json?lat=58.533&lng=15.046&date=today'; $JSON = file_get_contents($url); $data = json_decode($JSON,true); $sunrise = $data['results']['sunrise']; $sunset = $data['results']['sunset']; $start = date("Y-m-d\TH:i:s",strtotime("-2 days")); $sql = "SELECT * FROM tblPriceControl WHERE Ethernet = '".$ethernet."' and startTime > '$start' order by startTime asc"; $result = $mysqli->query($sql); $arr = array(); $zerosInRow = 0; $onesInRow = 0; $searchOne = 0; while($obj = $result->fetch_object()){ $startTime = $obj->startTime; $OnOff = $obj->OnOff; $hour_timeseries = date("H",strtotime($startTime)); $hour_sunrise = date("H",strtotime($sunrise)) +2; $hour_sunset = date("H",strtotime($sunset)) + 2; if( !($hour_timeseries > $hour_sunrise && $hour_timeseries < $hour_sunset)){ if($OnOff == 0){ $zerosInRow++; }else{ $zerosInRow = 0; } if($searchOne == 1){ if($OnOff == 1){ $onesInRow++; }else{ $onesInRow = 0; } } echo($obj->startTime ." - ".$obj->OnOff. " - " .$zerosInRow." - " .$onesInRow."<br>"); if($zerosInRow == 3){ $searchOne = 1; } if($onesInRow == 3){ $searchOne = 0; $onesInRow = 0; $arr[] = $obj->startTime; } }else{ $zerosInRow = 0; $onesInRow = 0; echo("<br>"); } } // HouseId, ActiveTemp, OutsideTemp, InsideTemp, Exhaust, DateTime foreach ($arr as &$value) { echo("<br><br>Check 3 next hours from: ".$value."<br>"); $sql_insert = ""; $InsideTemp1 = 0; $InsideTemp4 = 0; $WindAverage = 0; $OutsideTempAverage = 0; $InsideTempAverage = 0; for ($i = 0; $i <= 2; $i++) { $DateTime = date("Y-m-d H:i:s",strtotime($value) -60*60*$i); $DateTimeT = date("Y-m-d\TH:i:s",strtotime($value) -60*60*$i); $sql = "SELECT AVG(Value) as Value FROM tblEcoguard WHERE Time = '$DateTime' and SensorType = 'T'"; $result2 = $mysqli->query($sql); $InsideTemp = -100; while($obj2 = $result2->fetch_object()){ $InsideTemp = $obj2->Value; if($i == 0){ $InsideTemp1 = $InsideTemp; } if($i == 2){ $InsideTemp4 = $InsideTemp; } $InsideTempAverage +=$InsideTemp; } // 23000636 = Ute Norr $sql = "SELECT * FROM tblEcoguard WHERE Time = '$DateTime' and SensorName = '23000636' and SensorType = 'OT'"; $result2 = $mysqli->query($sql); $OutsideTemp = -100; while($obj2 = $result2->fetch_object()){ $OutsideTemp = $obj2->Value; $OutsideTempAverage += $OutsideTemp; } // 23000636 = Ute Norr $sql = "SELECT * FROM tblWeatherControl WHERE startTime = '$DateTimeT' and Ethernet = '".$ethernet."' LIMIT 1"; $result2 = $mysqli->query($sql); while($obj2 = $result2->fetch_object()){ $WindAverage += $obj2->T_effektiv; } echo($DateTime. " - ".$InsideTemp . " - ".$OutsideTemp."<br>"); // $mysqli->query($sql); } if($InsideTemp1 > $InsideTemp4){ $TempChange = (($InsideTemp1 - $InsideTemp4) / 2); $OutsideTempAverage = $OutsideTempAverage / 2; $InsideTempAverage = $InsideTempAverage / 2; $WindAverage = $WindAverage / 2; $sql = "SELECT * FROM tblEnergyLog2 WHERE TimeDate = '$value' and Ethernet = '".$ethernet."' LIMIT 1"; $result2 = $mysqli->query($sql); $found = 0; while($obj2 = $result2->fetch_object()){ $found = 1; } if($found == 0){ $sql= "INSERT INTO tblEnergyLog2 VALUES(null,'$ethernet','$InsideTempAverage','$OutsideTempAverage','$TempChange','$WindAverage','Up','$value');"; $mysqli->query($sql); echo($sql."<br>"); } }else{ echo("SOME PROBLEM!!<br>"); } } ?>