????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/shellyctr/ |
Upload File : |
<?php //ini_set('display_errors', 1); //ini_set('display_startup_errors', 1); //error_reporting(E_ALL); $width = "<script>document.write(screen.width);</script>"; $Username = "carl.hoffstedt@astacus.se"; $mysqli = new mysqli("www.astacus.se", "carlhoffstedt", "Astacus2020!", "ShellyCTR"); $sql = "SELECT * FROM tblNordpool order by endTime desc LIMIT 1"; $result = $mysqli->query($sql); while($obj = $result->fetch_object()){ $latest_date = substr($obj->endTime,0,10); } $sql = "SELECT * FROM tblPriceControl, tblUsers WHERE tblPriceControl.Username = tblUsers.Username and tblUsers.Username = '".$Username."'"; $result = $mysqli->query($sql); while($obj = $result->fetch_object()){ $percent_off = $obj->Percent_off; $percent_on = $obj->Percent_on; $area = $obj->Area; $lat = $obj->lat; $lon = $obj->lon; $Controltype = $obj->Controltype; } ?> <!doctype html> <html> <head> <meta charset="utf-8"> <title>Namnlöst dokument</title> <script src="https://cdn.jsdelivr.net/npm/chart.js"></script> <script src="js/package/dist/utils.js"></script> <style> table, th, td { font-family: 'Gill Sans', 'Gill Sans MT', 'Myriad Pro', 'DejaVu Sans Condensed', 'Helvetica', 'Arial', 'sans-serif'; font-size: 8px; border-collapse: collapse; } .time { width: 10px; height: 1500px; margin: 0 <?php $t=date("G"); $i=date("i")/60; $t=$t+$i; $pos = 8 + 3.75*$t; echo($pos)?>%; background: #2FEC1E; z-index: 100; position: absolute; opacity: 50%; } </style> </head> <body> <div class="time">T</div> <center> <a href="?day=0">IDAG</a> <a href="?day=1">IMORGON</a> </center> <p> <canvas id="myChart" width="100%" ></canvas> <br> <canvas id="myChart2" width="100%" ></canvas> <?php $day = $_GET['day']; if($day == ""){ $day = 0; } $from = date("Y-m-d",strtotime("$day days"))." 00:00:00"; $to = date("Y-m-d",strtotime("$day days"))." 24:00:00"; $sql = "SELECT DISTINCT(endTime) FROM tblNordpool WHERE endTime >= '".$from."' and endTime <= '".$to."' order by endTime"; $result = $mysqli->query($sql); $json_labels_t = "["; $labels_arr = array(); $tariff_arr = array(); while($obj = $result->fetch_object()){ $timestamp = $obj->endTime; $json_labels_t = $json_labels_t . "'". $timestamp ."',"; $labels_arr[] = $timestamp; $month = date("n",strtotime($timestamp)); //1-12 $hour = date("G",strtotime($timestamp)); // 0-24 if($month >= 11 || $month <= 3){ if($hour >= 6 && $hour < 22){ $tariff = 0.536; }else{ $tariff = 0.20; } }else{ $tariff = 0.20; } $tariff_arr[] = $tariff; } $json_labels_t = $json_labels_t . "'". str_replace("23:00:00","24:00:00",$timestamp) ."',"; $json_labels_t = $json_labels_t . "]"; $moms = 1.25; $sql = "SELECT * FROM tblNordpool WHERE endTime >= '".$from."' and endTime <= '".$to."' and area = '$area' order by endTime"; $result = $mysqli->query($sql); $arr1 = array(); $x=0; while($obj = $result->fetch_object()){ $timestamp = $obj->endTime; $value = ($obj->value/1000 + $tariff_arr[$x])*$moms; $arr1[] = array($timestamp,$value); $x++; } $arr1[] = array($timestamp,$value); $json_data_t1 = "data : ["; foreach ($labels_arr as &$value) { $f1 = false; foreach ($arr1 as &$v1) { if($v1[0] == $value){ $json_data_t1 = $json_data_t1 . $v1[1].","; $f1 = true; } } if($f1 == false){ $json_data_t1 = $json_data_t1 .","; } } $json_data_t1 = $json_data_t1 . "]"; $sum = 0; foreach ($arr1 as &$v1) { $sum +=$v1[1]; } $average = $sum/count($arr1); $json_data_t7 = "data : ["; $f1 = false; foreach ($arr1 as &$v1) { $json_data_t7 = $json_data_t7 . $average.","; } if($f1 == false){ $json_data_t7 = $json_data_t7 .","; } $json_data_t7 = $json_data_t7 . "]"; ?> <?php if(date("Y-m-d") != $latest_date && $_GET['day'] == ""){ // echo("<script> show_tomorrow(); </script>"); } ?> <?php $json_data_t_effective_ohmigo = "data : ["; $sql = "SELECT * FROM tblWeatherControl WHERE Timestamp >= '".$from."' and Timestamp <= '".$to."' and Username = '".$Username."' and Controltype = 1 order by Timestamp"; $result = $mysqli->query($sql); while($obj = $result->fetch_object()){ $Value = $obj->Value; $json_data_t_effective_ohmigo = $json_data_t_effective_ohmigo . "'". $Value ."',"; } $json_data_t_effective_ohmigo = $json_data_t_effective_ohmigo . "]"; $json_data_t_effective_ohmigo_medel = "data : ["; $sql = "SELECT * FROM tblWeatherControl WHERE Timestamp >= '".$from."' and Timestamp <= '".$to."' and Username = '".$Username."' and Controltype = 4 order by Timestamp"; $result = $mysqli->query($sql); while($obj = $result->fetch_object()){ $Value = $obj->Value; $json_data_t_effective_ohmigo_medel = $json_data_t_effective_ohmigo_medel . "'". $Value ."',"; } $json_data_t_effective_ohmigo_medel = $json_data_t_effective_ohmigo_medel . "]"; $json_data_t5 = "data : ["; $sql = "SELECT * FROM tblShellyControl WHERE Timestamp >= '".$from."' and Timestamp <= '".$to."' and Username = '".$Username."' and Controltype = 1 order by Timestamp"; $result = $mysqli->query($sql); while($obj = $result->fetch_object()){ $Status = $obj->Status; if($Status == 0){ $json_data_t5 = $json_data_t5 . "'OFF',"; }else{ $json_data_t5 = $json_data_t5 . "'ON',"; } } $json_data_t5 = $json_data_t5 . "]"; $json_data_t6 = "data : ["; $sql = "SELECT * FROM tblWeatherControl WHERE Timestamp >= '".$from."' and Timestamp <= '".$to."' and Username = '".$Username."' order by Timestamp"; $result = $mysqli->query($sql); while($obj = $result->fetch_object()){ $Status = $obj->Sun; if($Status == 0){ $json_data_t6 = $json_data_t6 . "'OFF',"; }else{ $json_data_t6 = $json_data_t6 . "'ON',"; } } $json_data_t6 = $json_data_t6 . "]"; $sql = "SELECT * FROM tblSMHI WHERE endTime >= '".$from."' and endTime <= '".$to."' and Username = '".$Username."' order by endTime"; $result = $mysqli->query($sql); $json_labels_t2 = "["; $json_data_ws = "data : ["; $json_data_t = "data : ["; $json_data_t_effective = "data : ["; $json_data_tcc_mean = "data : ["; $json_data_t_effective_plus_temp = "data : ["; $json_data_tcc_mean_array = array(); $json_data_t_effective_array = array(); while($obj = $result->fetch_object()){ $timestamp = $obj->startTime; $json_labels_t2 = $json_labels_t2 . "'". $timestamp ."',"; $json_data_t = $json_data_t . $obj->t.","; $json_data_ws = $json_data_ws . $obj->ws.","; $json_data_t_effective = $json_data_t_effective . $obj->t_effective.","; $json_data_t_effective_array[] = $obj->t_effective; $json_data_t_effective_plus_temp = $json_data_t_effective_plus_temp . (($obj->t_effective + $obj->t)/2).","; if($obj->tcc_mean >= 5){ $sol = "'OFF'"; $json_data_tcc_mean_array[] = 0; }else{ $sol = "'ON'"; $json_data_tcc_mean_array[] = 1; } $json_data_tcc_mean = $json_data_tcc_mean . $sol.","; } $json_data_t = $json_data_t . "]"; $json_data_ws = $json_data_ws . "]"; $json_data_t_effective = $json_data_t_effective . "]"; $json_data_tcc_mean = $json_data_tcc_mean ."]"; $json_data_t_effective_plus_temp = $json_data_t_effective_plus_temp ."]"; $json_labels_t2 = $json_labels_t2 . "'". str_replace("23:00:00","24:00:00",$timestamp) ."',"; $json_labels_t2 = $json_labels_t2 . "]"; $from2= date("Y-m-d",strtotime(($day-1)." days"))." 23:00:00"; $sql = "SELECT * FROM tblShellyMeter WHERE Timestamp >= '".$from2."' and Timestamp <= '".$to."' and deviceId = '244cab41a8ef' order by Timestamp"; $result = $mysqli->query($sql); $json_data_t8 = "data : ["; $x=0; while($obj = $result->fetch_object()){ if($x == 0){ $old_value = ($obj->Value/1000); }else{ $json_data_t8 = $json_data_t8 . (($obj->Value/1000) - $old_value).","; $old_value = ($obj->Value/1000); } $x++; } $json_data_t8 = $json_data_t8 . "]"; $from2= date("Y-m-d",strtotime(($day-1)." days"))." 23:00:00"; $sql = "SELECT * FROM tblShellyMeter WHERE Timestamp >= '".$from2."' and Timestamp <= '".$to."' and deviceId = 'c8f09e87f288' order by Timestamp"; $result = $mysqli->query($sql); $json_data_t9 = "data : ["; $x=0; while($obj = $result->fetch_object()){ if($x == 0){ $old_value = ($obj->Value/1000); }else{ $json_data_t9 = $json_data_t9 . (($obj->Value/1000) - $old_value).","; $old_value = ($obj->Value/1000); } $x++; } $json_data_t9 = $json_data_t9 . "]"; ?> <script> const labels = <?php echo($json_labels_t);?>; const data = { labels: labels, datasets: [ { label: 'Medelpris', <?php echo($json_data_t7);?>, borderColor: '#FF00FF', backgroundColor: '#FF00FF', stepped: true, fill: false, yAxisID: 'y' }, { label: 'Förbrukning VP', <?php echo($json_data_t8);?>, borderColor: '#FF00FF', backgroundColor: '#FF00FF', stepped: false, fill: false, yAxisID: 'y3' }, { label: 'Förbrukning SPABAD', <?php echo($json_data_t9);?>, borderColor: '#00EEFF', backgroundColor: '#00EEFF', stepped: false, fill: false, yAxisID: 'y3' }, { label: '<?php echo($area);?>', <?php echo($json_data_t1);?>, borderColor: '#FF0000', backgroundColor: '#FF0000', stepped: true, fill: true, yAxisID: 'y' }, { label: 'Temperaturkurva OMHIGO (20 grader dyraste timmarna)', <?php echo($json_data_t_effective_ohmigo);?>, borderColor: '#FF0000', backgroundColor: '#FF0000', stepped: true, fill: false, yAxisID: 'y4' }, { label: 'Temperaturkurva OMHIGO (20 dyraste timmarna över medel minst varannan)', <?php echo($json_data_t_effective_ohmigo_medel);?>, borderColor: '#0000FF', backgroundColor: '#0000FF', stepped: true, fill: false, yAxisID: 'y4' }, { label: 'ON/OFF-reglering SPABAD', <?php echo($json_data_t5);?>, borderColor: '#005808', backgroundColor: '#005808', stepped: true, fill: false, yAxisID: 'y1' }, { label: 'SOLEN +2 grader', <?php echo($json_data_t6);?>, borderColor: '#f6ff00', backgroundColor: '#f6ff00', stepped: true, fill: false, yAxisID: 'y2' } ] }; const config = { maintainAspectRatio: true, type: 'line', data: data, options: { responsive: true, plugins: { title: { display: true, text: 'ELPRISOMRÅDEN <?php $latest_date_lable = $latest_date ; if($day == 0){ $latest_date_lable = date("Y-m-d") ; } echo($latest_date_lable );?>', }, }, scales: { y: { type: 'linear', position: 'left', stack: 'demo', stackWeight: 5, beginAtZero: true }, y3: { type: 'linear', position: 'left', stack: 'demo', stackWeight: 5, beginAtZero: true } , y4: { type: 'linear', position: 'left', stack: 'demo', stackWeight: 5, } , y1: { type: 'category', labels: ['ON', 'OFF'], offset: true, position: 'left', stack: 'demo', stackWeight: 1, }, y2: { type: 'category', labels: ['ON', 'OFF'], offset: true, position: 'left', stack: 'demo', stackWeight: 1, } } } }; const myChart = new Chart( document.getElementById('myChart'), config ); </script> <script> const labels2 = <?php echo($json_labels_t2);?>; const data2 = { labels: labels, datasets: [ { label: 'Temperatur', <?php echo($json_data_t);?>, borderColor: '#0060ff', backgroundColor: '#0060ff', stepped: false, fill: false, yAxisID: 'y' }, { label: 'Vind', <?php echo($json_data_ws);?>, borderColor: '#ff0000', backgroundColor: '#ff0000', stepped: false, fill: false, yAxisID: 'y' }, { label: 'Effektiv temperatur', <?php echo($json_data_t_effective);?>, borderColor: '#0000a9', backgroundColor: '#0000a9', stepped: false, fill: false, yAxisID: 'y' }, { label: 'Reglertemp ((effektiv_temp + temp) / 2)', <?php echo($json_data_t_effective_plus_temp);?>, borderColor: '#003401', backgroundColor: '#003401', stepped: false, fill: false, yAxisID: 'y' }, { label: 'Sol', <?php echo($json_data_tcc_mean);?>, borderColor: '#f6ff00', backgroundColor: '#f6ff00', stepped: true, fill: true, yAxisID: 'y2' }, ] }; const config2 = { maintainAspectRatio: true, type: 'line', data: data2, options: { responsive: true, plugins: { title: { display: true, text: 'VÄDERPROGNOS <?php $latest_date_lable = $latest_date ; if($day == 0){ $latest_date_lable = date("Y-m-d") ; } echo($latest_date_lable );?>', }, }, scales: { y2: { type: 'category', labels: ['ON', 'OFF'], offset: true, position: 'left', stack: 'demo', stackWeight: 1, }, y: { type: 'linear', position: 'left', stack: 'demo', stackWeight: 10, } } } }; const myChart2 = new Chart( document.getElementById('myChart2'), config2 ); </script> </body> </html>