'.$scrpt_vrsn_dt.PHP_EOL; # # ------------check if script is already running $string = str_replace('.php','',basename(__FILE__)); if (isset ($$string) ) {echo 'This info is already displayed'; return;} $$string = $string; # # -------------load weatherdata and all settings $scrpt = 'PWS_livedata.php'; $stck_lst .= basename(__FILE__).' ('.__LINE__.') include_once =>'.$scrpt.PHP_EOL; include_once $scrpt; # #------------------------------- script settings # $orange ='orange'; // css class for large text in the middle $orange = ''; # default text is black or silver #### 2020-12-15 # if (!isset ($KISS)) {$KISS = false;} // keep it simple graphs $my_KISS = $KISS; #$my_KISS = false; // to set for this block only. # -------------------------------- test settings #$lat = (float) "78.7836"; #$lat = (float) "50.7836"; #$lon = (float) "16.5278"; #$lon = (float) "4.5278"; # #------------ colors for small blks left / right $clr_light = '#e8c400'; # '#ff8841'; $clr_dark = 'dimgrey'; $clr_sun_up = '#e8c400'; # '#ecb454'; # # ----------------------------------- texts used $hrs_l = ' '.lang('hrs '); $min_l = ' '.lang('min '); $none = lang('none'); $dayl_l = lang('Daylight'); $sunr_l = lang('Sunrise'); $suns_l = lang('Sunset'); $azim_l = lang('Azimuth'); $drkl_l = lang('Darkness'); $elv_l = lang('Elevation'); $estim_l= lang('Estimated'); $tmrrw_l= lang('Tomorrow'); $td_l = lang('Today'); $spcl_l = lang('till midnight'); $tllsr_l= lang('Till Sunrise'); $dlght_l= lang('Of Daylight'); $t24h_s = lang('Midnight sun'); $t24h_d = lang('No sunshine today'); # $result = date_sun_info(time(), $lat, $lon); # echo '
'.time().print_r($result,true);
$nextday        = time() + 24*60*60;
$result2        = date_sun_info($nextday,$lat, $lon);  # echo '
'.print_r($result2,true); 
#
#
$Tyear          = date ('Y',$now);
$Tmonth         = date ('m',$now);
$Tday           = date ('d',$now);
$Ustart         = mktime (0,0,0,(int) $Tmonth,(int) $Tday,(int) $Tyear); 
$Uend           = $Ustart + 24*60*60;
$sunrise        = $sunset = true;    # echo '
'.print_r($result,true); exit;   #  echo date ('c',$Ustart); 
if ((int)$result['sunset']  === 1) // sun at 24:00  ((bool)$result['sunset']  === true)
     {  $result['sunset']  = $Uend;    
        $sunset = false;
        $dlght_l = $tllsr_l = $spcl_l;}
elseif ((bool)$result['sunset']  === false)
      { $sunset = false;
        $dlght_l = $tllsr_l = $spcl_l;}
if ((int)$result['sunrise'] === 1)  // sun at 00:00
     {  $result['sunrise'] = $Ustart;  
        $sunrise = false;
        $dlght_l = $tllsr_l = $spcl_l;}      
elseif ((bool)$result['sunrise'] === false)
      { $sunrise = false;
        $dlght_l = $tllsr_l = $spcl_l;}  
$light          = $result['sunset'] - $result['sunrise'];
if ( (int) $light == 0)
     {  $daylight       = $none;}
else {  $hrs            = gmdate('G',$light);
        if ((int) $hrs == 0) 
             {  $hrs = 24; $min = '';}
        else {  $min    = gmdate('i',$light).$min_l;}
        $daylight       = $hrs.$hrs_l.$min;}
#
$dark           = 24*60*60 - $light;
if ( (int) $dark == 0)
     {  $daydark        = $none;}
else {  $hrs            = gmdate('G',$dark);
        if ((int) $hrs == 0) 
             {  $hrs = 24; $min = '';}
        else {  $min    = gmdate('i',$dark).$min_l;}
        $daydark        = $hrs.$hrs_l.$min;}


$nextrise       = $result['sunrise'];
$now            = time();
#
if ($sunrise === true) {
        if ($now > $result['sunrise'] && (bool) $result2['sunrise'] <> false)
             {  $nextrise       = set_my_time($result2['sunrise'], true);  
                $nextrisetxt    = $tmrrw_l;}
        else {  $nextrisetxt    = $td_l ;
                $nextrise       = set_my_time($nextrise, true);} 
        }
$nextset        = $result['sunset'];
if ($sunset === true) { 
        if ($now > $nextset)
             {  $nextset        = set_my_time($result2['sunset'], true);
                $nextsettxt     = $tmrrw_l;;}
        else {  $nextsettxt     = $td_l;
                $nextset        = set_my_time($nextset, true);} 
}
$firstrise      =   $result['sunrise'];
$secondrise     =   $result2['sunrise'];    
$firstset       =   $result ['sunset']; 
#
$sun_color      = $clr_dark;
if ($now < $firstrise) 
    {   $time   = $firstrise - $now;
        $hrs    = gmdate ('G',$time);
        $min    = gmdate ('i',$time);
        $txt    = $tllsr_l;}
elseif ($now < $firstset)
    {   $time   = $firstset - $now;
        $hrs    = gmdate ('G',$time);
        $min    = gmdate ('i',$time);
        $sun_color      = $clr_sun_up;
        $txt    = $dlght_l;}
else {  $time   = $secondrise - $now;
        $hrs    = gmdate ('G',$time);
        $min    = gmdate ('i',$time);
        $txt    = $tllsr_l;}
#
function get_azimuth ()
    {   global $lat, $lon, $TZ,$azimuth,$elevation,$sunazi, $echo ,$stck_lst, $sundir;
        $scrpt          = './others/azimuth.php'; 
        $stck_lst      .= basename(__FILE__).' ('.__LINE__.') include_once =>'.$scrpt.PHP_EOL;
        include_once $scrpt;
        $azimuth        = round($sunazi[25],1);
        $elevation      = round($sunpos[25],1); 
        $sundir         = lang ($sundir);}
#        
$azimuth=$elevation=0;
get_azimuth ();
#
# ---------------- the date time
echo '
' .$online.set_my_time_lng(time(),true).'
'.PHP_EOL; # # ------------- the block itself echo '

'.PHP_EOL; # # ---------------- left column
height: 40px; echo '
' .$dayl_l.'
' .$daylight.'' .'
'.PHP_EOL; if ($sunrise === true ) { echo '
' .$sunr_l.'
' .$nextrise.'
' .$nextrisetxt .'
'.PHP_EOL;} echo '
' .$azim_l.'
' .$azimuth.'° '.$sundir.'' .'
'.PHP_EOL; echo '
'.PHP_EOL; # # ---------------- middle area echo '
'.PHP_EOL; # echo return_clock(); # if ($my_KISS == true && $current_theme == 'dark') { $txt_clr= 'color: silver;';} else { $txt_clr= 'color: black;'; } # echo '
'.PHP_EOL; if ($sunrise === true && $sunset === true ) { echo '
'.$estim_l.'
'.$hrs.' '.$hrs_l.' '.$min.' '.$min_l.'
'.$txt.'
'.PHP_EOL;} elseif ((bool) $result['sunrise'] === true) { echo '
'.$t24h_s.'
'.PHP_EOL;} else { echo '
'.$t24h_d.'
'.PHP_EOL;} echo '
'.PHP_EOL; # # ---------------- right column echo '
'.PHP_EOL; echo '
' .$drkl_l.'
' .$daydark.'' .'
'.PHP_EOL; if ($sunset === true ) { echo '
' .$suns_l.'
' .$nextset.'
' .$nextsettxt .'
'.PHP_EOL; } echo '
' .$elv_l.'
' .$elevation.'°' .'
'.PHP_EOL; # # ---------------- end of PWS_module_content echo '
'.PHP_EOL; # ---------------- end of html # if (isset ($_REQUEST['test']) ) { echo ''.PHP_EOL; echo ''.PHP_EOL; $stck_lst='';} # function return_clock() { global $result, $clockformat, $current_theme, $sun_color, $my_KISS; # $clockformat = '24'; $h = (int) date ('H',$result['sunrise']); $m = round (date ('i',$result['sunrise']) / 60,1); $rotate = -15 * (18 - $h - $m ); # echo '$rotate='.$rotate; exit; $h = (int) date ('H'); $m = round (date ('i') / 60,1); $rotate2= -15 * (18 - $h - $m ); #echo '$rotate2='.$rotate2; exit; $black = 24* 3600 - ($result['sunset'] - $result['sunrise']); $black = round ( $black / 3600, 1); # echo $black; exit; $yellow = 24 - $black; if ($my_KISS == true) {$rad = 48;} else {$rad = 63;} $from = round ( $yellow * $rad * 2 * M_PI / 24 ); #echo PHP_EOL.__LINE__." ".'$from='.$from; $to = ceil(2* $rad * M_PI); # echo PHP_EOL.__LINE__." ".'$to='.$to.' $from ='.$from; #$rotate = 90; $arr_fr = array (' 8px;','>01<', '>02<', '>03<', '>04<', '>05<', '>06<', '>6<' , '>07<', '>08<', '>09<', '>10<', '>11<', '>12<', '>13<', '>14<', '>15<', '>16<', '>17<', '>18<', '>19<', '>20<', '>21<', '>22<', '>23<', '>24<'); $arr_to = array (' 6px;','>1am<','>2am<','>3am<','>4am<','>5am<','>6am<','>6am<','>7am<','>8am<','>9am<','>10am<','>11am<','>12pm<','>1pm<','>2pm<','>3pm<','>4pm<','>5pm<','>6pm<','>7pm<','>8pm<','>9pm<','>10pm<','>11pm<','>12am<'); if ($clockformat <> '12') {$arr_fr = $arr_to = array();} # if ($current_theme <> 'dark') { $dial_clr = 'rgb(250, 250, 250)'; $dial_txt = 'rgb(40, 40, 40)'; $white_clr = 'rgb(229, 229, 229)';} else { $dial_clr = 'rgb(90, 90, 90)'; $dial_txt = 'rgb(255, 255, 255)'; $white_clr = 'rgb(160, 160, 160)';} # $return = ' '; if (isset ($my_KISS) && $my_KISS == true ) { $return .= str_replace ($arr_fr,$arr_to,' 12 24 6 18'); } else {$return .= ' ' .str_replace ($arr_fr,$arr_to,' 11 13 10 14 09 15 08 16 07 17 06 18 05 19 04 20 03 21 02 22 01 23').' '.PHP_EOL; for ($n = 0; $n< 12; $n++) { $rotate = round( ($n * 360 /24),1); $return .= ' '.PHP_EOL; } $return .= ' '; } // eo SVG extra $return .= ' '; echo $return; }