????JFIF??x?x????'
| Server IP : 79.136.114.73 / Your IP : 216.73.216.57 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);
$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);
}
$day = $_GET['day'];
if($day == ""){
$day = 0;
}
$Username = "carl.hoffstedt@astacus.se";
$sql = "SELECT tblPriceControl.Username as Username, tblPriceControl.Area as Area, tblPriceControl.Percent_on as Percent_on, tblPriceControl.Percent_off as Percent_off, tblPriceControl.Controltype as Controltype FROM tblUsers,tblPriceControl WHERE tblPriceControl.Username = tblUsers.Username and tblUsers.Username = '".$Username."' ";
$result = $mysqli->query($sql);
while($obj = $result->fetch_object()){
$area = $obj->Area;
$percent_on = $obj->Percent_on;
$percent_off = $obj->Percent_off;
$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;
}
</style>
</head>
<body>
<center>
</center>
<canvas id="myChart" width="100%" ></canvas>
<?php
$from = date("Y-m-d",strtotime("$day days"))." 00:00:00";
$to = date("Y-m-d",strtotime("$day days"))." 24:00:00";
$sql = "SELECT * FROM tblNordpool WHERE endTime >= '".$from."' and endTime <= '".$to."' and area = '".$area."' 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();
while($obj = $result->fetch_object()){
$timestamp = $obj->endTime;
$value = ($obj->value/1000 + $tariff)*$moms;
$arr1[] = array($timestamp,$value);
}
$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 . "]";
$sql = "SELECT * FROM tblShellyControl WHERE Timestamp >= '".$from."' and Timestamp <= '".$to."' and Username = '".$Username."' and Controltype = '".$controltype."'";
$result = $mysqli->query($sql);
$arr2 = array();
while($obj = $result->fetch_object()){
$value = $obj->Status;
$timestamp = $obj->Timestamp;
$arr2[] = array($timestamp,$value);
}
$arr2[] = array($timestamp,$value);
$json_data_t2 = "data : [";
$f1 = false;
foreach ($arr2 as &$v1) {
if($v1[1] == 0){
$json_data_t2 = $json_data_t2 . "'OFF',";
$f1 = true;
}else{
$json_data_t2 = $json_data_t2 . "'ON',";
}
}
if($f1 == false){
$json_data_t2 = $json_data_t2 .",";
}
$json_data_t2 = $json_data_t2 . "]";
$sql = "SELECT * FROM tblWeatherControl WHERE Timestamp >= '".$from."' and Timestamp <= '".$to."' and Username = '".$Username."' ";
$result = $mysqli->query($sql);
$arr3 = array();
while($obj = $result->fetch_object()){
$value = $obj->Value;
$timestamp = $obj->Timestamp;
$arr3[] = array($timestamp,$value);
}
$arr3[] = array($timestamp,$value);
$json_data_t3 = "data : [";
$f1 = false;
foreach ($arr3 as &$v1) {
$json_data_t3 = $json_data_t3 . $v1[1].",";
}
if($f1 == false){
$json_data_t3 = $json_data_t3 .",";
}
$json_data_t3 = $json_data_t3 . "]";
?>
<script>
const labels = <?php echo($json_labels_t);?>;
const data = {
labels: labels,
datasets: [
{
label: 'SE<?php echo($area);?>',
<?php echo($json_data_t1);?>,
borderColor: '#FF0000',
backgroundColor: '#FF0000',
stepped: true,
fill: true,
yAxisID: 'y'
},
{
label: 'SPABAD: ON/OFF-reglering baserat <?php echo($controltype);?> i elområde <?php echo($area);?>',
<?php echo($json_data_t2);?>,
borderColor: '#005808',
backgroundColor: '#005808',
stepped: true,
fill: false,
yAxisID: 'y1'
}
,
{
label: 'NIBE: Temperaturreglering baserat på att exkludera de dyraste timmarna i elområde <?php echo($area);?>',
<?php echo($json_data_t3);?>,
borderColor: '#305808',
backgroundColor: '#305808',
stepped: true,
fill: false,
yAxisID: 'y2'
}
]
};
const config = {
maintainAspectRatio: true,
type: 'line',
data: data,
options: {
responsive: true,
plugins: {
title: {
display: true,
text: 'KÖRSCHEMA <?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,
},
y2: {
type: 'linear',
position: 'left',
stack: 'demo',
stackWeight: 5,
},
y1: {
type: 'category',
labels: ['ON', 'OFF'],
offset: true,
position: 'left',
stack: 'demo',
stackWeight: 1,
}
}
}
};
const myChart = new Chart(
document.getElementById('myChart'),
config
);
</script>
</div>
</body>
</html>