????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/rock_backup/app/ |
Upload File : |
<?php
include '../setup.php';
$mysqli = new mysqli("www.astacus.se", "carlhoffstedt", "Astacus2020!", "energicontrol");
if($_GET['day'] == ""){
$day = 0;
$show_date = date("Y-m-d");
}else{
$day = $_GET['day'];
$show_date = date("Y-m-d", strtotime("$day days"));
}
if($_GET['day'] == ""){
$day1 = -1;
$day2 = +1;
}else{
$day1 = $_GET['day']-1;
$day2 = $_GET['day']+1;
}
?>
<!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;
}
</style>
</head>
<body>
<center>
<a href="?day=<?php echo($day1);?>"><-- <?php echo(date("Y-m-d",strtotime(($day-1)." day")));?></a> | <strong><?php echo($show_date);?></strong> | <a href="?day=<?php echo($day2);?>"><?php echo(date("Y-m-d",strtotime(($day+1)." day")));?> --></a>
</center>
<div align="center">
<canvas id="myChart" width="100%"></canvas>
</div>
<?php
$date_from30 = "startTime >= '".date('Y-m-d',strtotime("-30 days"))."'";
$sql = "SELECT * FROM tblNordpool WHERE $date_from30 and area = 'SE3' order by startTime";
$result = $mysqli->query($sql);
$sum = 0;
$x = 0;
while($obj = $result->fetch_object()){
$price = ($obj->value)/(1000*1);
$sum += $price;
$x++;
}
$average_price = $sum/$x;
$day = -1*$_GET['day'];
$time18 = date("H");
if($time18 >= 18){
$a=0-$day;
$b=1-$day;
}else{
$a=-1-$day;
$b=0-$day;
}
$from = date("Y-m-d",strtotime("$a days"))."T18:00:00Z";
$to = date("Y-m-d",strtotime("$b days"))."T17:00:00Z";
$sql = "SELECT * FROM tblNordpool WHERE startTime >= '".$from."' and startTime <= '".$to."' and area = 'SE3' order by startTime";
$result = $mysqli->query($sql);
$json_data_t1 = "data : [";
$json_data_t2 = "data : [";
$json_labels_t = "[";
$array_t = array();
$array_price = array();
$array_lable = array();
$array_time_for_later = array();
$x = 0;
$indexDate=0;
$highest = 0;
while($obj = $result->fetch_object()){
$json_data_t1 = $json_data_t1 . ($obj->value/1000).",";
$array_price[] = $obj->value/1000;
$lable = date("H:i",strtotime(trim($obj->startTime,"Z")));
$time_for_later = date("Y-m-d H:00:00",strtotime(trim($obj->startTime,"Z")));
$array_time_for_later[] = $time_for_later;
$json_labels_t = $json_labels_t . "'".$lable ."',";
$json_data_t2 = $json_data_t2 . $average_price .",";
if($obj->startTime == $timeNow){
$indexDate = $x;
}
if($highest < $obj->value/1000 ){
$highest = $obj->value/1000;
}
$x++;
}
$json_data_t1 = $json_data_t1 . "]";
$json_data_t2 = $json_data_t2 . "]";
$json_labels_t = $json_labels_t . "]";
$from = date("Y-m-d",strtotime("$a days"))."T18:00:00";
$to = date("Y-m-d",strtotime("$b days"))."T17:00:00";
$sql = "SELECT Distinct (startTime) as startTime, OnOff FROM tblPriceControl WHERE startTime >= '".$from."' and startTime <= '".$to."' order by startTime";
$result = $mysqli->query($sql);
$json_data_t3 = "data : [";
$json_data_t4 = "data : [";
$x = 0;
$array_kw = array();
//$array_kw[]=0;
while($obj = $result->fetch_object()){
if($obj->OnOff == 0){
$ONOFF = "'OFF'";
}else{
$ONOFF = "'ON'";
}
$json_data_t3 = $json_data_t3 . $ONOFF.",";
$found = 0;
$sql = "SELECT * FROM tblEcoguard WHERE SensorName = '00016774' AND SensorType = 'ELEC'";
$result2 = $mysqli->query($sql);
while($obj2 = $result2->fetch_object()){
$Time = $obj2->Time;
$d = date("Y-m-d\TH:i:s",strtotime($Time));
//echo($d."<br>");
if($d == $obj->startTime){
$json_data_t4 = $json_data_t4 . $obj2->Value.",";
$found = 1;
$array_kw[] = $obj2->Value;
if($highest < $obj2->Value ){
$highest = $obj2->Value;
}
}
}
if($found == 0){
$json_data_t4 = $json_data_t4 ."0,";
$array_kw[] = 0;
}
$x++;
}
$json_data_t3 = $json_data_t3 . "]";
$json_data_t4 = $json_data_t4 . "]";
$from = date("Y-m-d",strtotime("$a days"))."T18:00:00";
$to = date("Y-m-d",strtotime("$b days"))."T17:00:00";
$sql = "SELECT Distinct (startTime) as startTime, Sun FROM tblWeatherControl WHERE startTime >= '".$from."' and startTime <= '".$to."' order by startTime";
$result = $mysqli->query($sql);
$json_data_t5 = "data : [";
$x = 0;
while($obj = $result->fetch_object()){
if($obj->Sun == 0){
$SUN = "'OFF'";
}else{
$SUN = "'ON'";
}
$json_data_t5 = $json_data_t5 . $SUN.",";
}
$json_data_t5 = $json_data_t5 . "]";
//2022-10-27T18:00:00
//2022-10-28 14:45:00
?>
<script>
const labels = <?php echo($json_labels_t);?>;
const data = {
labels: labels,
datasets: [
{
label: 'Medelpris senaste 30 dagarna',
<?php echo($json_data_t2);?>,
borderColor: '#00FF00',
backgroundColor: '#00FF00',
},
{
label: 'Elförbrukning',
<?php echo($json_data_t4);?>,
borderColor: '#00FFFF',
backgroundColor: '#00FFFF',
stepped: true,
},
{
label: 'Värmepump får köras vid ON',
<?php echo($json_data_t3);?>,
borderColor: '#0000FF',
backgroundColor: '#0000FF',
stepped: true,
yAxisID: 'y2',
}, {
label: 'Elpris',
<?php echo($json_data_t1);?>,
borderColor: '#FF0000',
backgroundColor: '#FF0000',
stepped: true,
fill: true,
}, {
label: 'Solinstrålning',
<?php echo($json_data_t5);?>,
borderColor: '#fff600',
backgroundColor: '#fff600',
stepped: true,
yAxisID: 'y2',
}
,{
label: 'Tiden just nu',
borderColor: '#e4ff00',
backgroundColor: '#e4ff00',
type: 'bar',
data: [
{x: "<?php echo(date("H:00"));?>", y: <?php echo($highest);?>}
],
maxBarThickness: 150,
}
]
};
const config = {
maintainAspectRatio: true,
type: 'line',
data: data,
options: {
responsive: true,
plugins: {
title: {
display: true,
text: 'Körschema Värmepump',
},
},
scales: {
y: {
type: 'linear',
position: 'left',
stack: 'demo',
stackWeight: 2,
},
y2: {
type: 'category',
labels: ['ON', 'OFF'],
offset: true,
position: 'left',
stack: 'demo',
stackWeight: 1,
}
}
},
};
const myChart = new Chart(
document.getElementById('myChart'),
config
);
</script>
<table width="97%" border="0" align="center" bordercolor="#000000" >
<tbody>
<tr>
<td width="5"></td>
<td width="*">
<table width="100%" border="0" align="center">
<tbody>
<tr >
<?php
$x = 0;
$tot =0;
$kw_tot = 0;
array_pop($array_price);
foreach($array_price as &$price) {
$kw = $array_kw[$x];
$kw_tot+= $kw;
$tot += $price*$kw;
$totmedel += $average_price*$kw;
?>
<td width="4%" align="center"><?php echo(round($price*$kw,2));?> kr</td>
<?php
$x++;
} ?>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<div style="font-family: 'Gill Sans', 'Gill Sans MT', 'Myriad Pro', 'DejaVu Sans Condensed', Helvetica, Arial, 'sans-serif';">
<center>
<?php echo("<br>TOTAL FÖRBRUKNING: ". $kw_tot . " kWh <br>");?>
<?php
/*
$result = $mysqli->query("SELECT * FROM tblGraphLog Where DateLog = '".$show_date ."'");
$found = 0;
while($obj = $result->fetch_object()){
$found = 1;
}
*/
$result2 = $mysqli->query("SELECT * FROM tblAverageTemp WHERE Ethernet = '$ethernet'");
$COUNT = 0;
$VALUE =0;
$SensorText = "";
while($obj2 = $result2->fetch_object()){
$SensorText .= " SensorName = '". $obj2->SensorName."' or";
$COUNT++;
}
$SensorText = substr($SensorText,0,strlen($SensorText) - 3);
$sql = "SELECT * FROM tblEcoguard WHERE SensorType = 'T' and ( $SensorText ) ORDER BY Time DESC LIMIT 10";
$sensor_name_arr = array();
$result3 = $mysqli->query($sql);
while($obj3 = $result3->fetch_object()){
if(!in_array($row['SensorName'],$sensor_name_arr)){
$VALUE += round( $obj3->Value, 2 );
$sensor_name_arr[] = $obj3->SensorNAme;
$COUNT++;
}
}
$AverageTemp = $VALUE / $COUNT;
echo("<br><br>MEDELTEMP: ".$AverageTemp );
?>
</center>
</div>
<div align="center">
<canvas id="myChart2" width="100%"></canvas>
</div>
<?php
$result2 = $mysqli->query("SELECT * FROM tblAverageTemp WHERE Ethernet = '$ethernet'");
$COUNT = 0;
$SensorText = "";
while($obj2 = $result2->fetch_object()){
$SensorText .= " SensorName = '". $obj2->SensorName."' or";
}
$SensorText = substr($SensorText,0,strlen($SensorText) - 3);
$json_data_t2 = "data : [";
$json_labels_t = "[";
$x = 0;
foreach ($array_time_for_later as &$time_for){
$VALUE = "";
$result3 = $mysqli->query("SELECT AVG(Value) as Value FROM tblEcoguard WHERE SensorType = 'T' and ( $SensorText ) and Time = '".$time_for."' ORDER BY Time DESC LIMIT 1");
while($obj3 = $result3->fetch_object()){
$VALUE = round($obj3->Value,2);
}
if($VALUE == 0){
$VALUE = "";
}
$json_data_t2 = $json_data_t2 . $VALUE .",";
//unset($VALUE );
$lable = date("H:i",strtotime($time_for));
$json_labels_t = $json_labels_t . "'".$lable ."',";
$x++;
}
$json_data_t2 = $json_data_t2 . "]";
$json_labels_t = $json_labels_t . "]";
?>
<script>
const labels2 = <?php echo($json_labels_t);?>;
const data2 = {
labels: labels2,
datasets: [
{
label: 'Medeltemperatur',
<?php echo($json_data_t2);?>,
borderColor: '#00FF00',
backgroundColor: '#00FF00',
}
]
};
const config2 = {
maintainAspectRatio: true,
type: 'line',
data: data2,
options: {
responsive: true,
plugins: {
title: {
display: true,
text: 'Körschema Värmepump',
},
},
scales: {
y: {
type: 'linear',
position: 'left',
stack: 'demo',
stackWeight: 2,
}
}
},
};
const myChart2 = new Chart(
document.getElementById('myChart2'),
config2
);
</script>
<center>ASTACUS AB</center>
</body>
</html>