Author Topic: Common.php  (Read 493 times)

0 Members and 1 Guest are viewing this topic.

Offline n7xrd

  • Forecaster
  • *****
  • Posts: 366
    • Kamiah Weather
Common.php
« on: April 23, 2019, 08:47:57 AM »
So I ran the check fetch today and it said I needed to update the common.php file so I did once it was done my page only loaded the menu no ain part. I put the old file back and all is good again except it says I need to update again????   PHP V 7.0.33

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Common.php
« Reply #1 on: April 23, 2019, 10:16:02 AM »
You had added this
Code: [Select]
// Alternate $changeinday routine that finds $changeinday2
function get_changeinday() {
    global $hrsOfSunLight;
    global $SITE;
    global $displayTomorrow;

    $t = time()-86400; // Yesterday

    for ($i=0; $i<(2+($displayTomorrow?1:0)); $i++) { // Only loop twice if no $displayTomorrow
        $sun = date_sun_info($t, $SITE['latitude' ], $SITE["longitude"]);
        $srise  = $sun["sunrise"];
        $sset  = $sun["sunset"];
        // Now adjust for ST<>DST transitions
//        $stdstOffset[$i] = ((date("I",$t+(86400*$i))!=date("I",$t+(86400*($i+1))))?((date("I",$t+(86400*$i))>date("I",$t+(86400*($i+1))))?3600:-3600):0);
//        $sunhrs[$i] = $sset - $srise + $stdstOffset[$i];   // $sunhrs is time between sunrise and sunset + DST-ST offset
        $sunhrs[$i] = $sset - $srise;   // $sunhrs is time between sunrise and sunset
        $sh[$i] = floor($sunhrs[$i]/3600); // Sun Hours
        $sm[$i] = floor((($sunhrs[$i]/3600)-$sh[$i])*60); // Sun Minutes
        $ss[$i] = round(((((($sunhrs[$i]/3600)-$sh[$i])*60)-$sm[$i])*60),0); // Sun Seconds
        $hrsOfSunLight[$i] = $sh[$i].':'.$sm[$i].':'.$ss[$i]; // Assemble strings in array
        $t+=86400; // Next Day
    }

    $cindsign = (($sunhrs[1]-$sunhrs[0])>0)?'+':'-'; // Change IN Day sign

    $shdiff = ($cindsign=='-'?($sh[0] - $sh[1]):($sh[1] - $sh[0])); // Difference in hours
    $smdiff = ($cindsign=='-'?($sm[0] - $sm[1]):($sm[1] - $sm[0])); // Difference in minutes
    $ssdiff = ($cindsign=='-'?($ss[0] - $ss[1]):($ss[1] - $ss[0])); // Difference in seconds
    if ($ssdiff<0) { // negative number of seconds?
        $smdiff -= 1; // borrow
        $ssdiff += 60; // and carry
    }
    if ($smdiff<0) { // negative number of minutes?
        $shdiff -=1; // borrow
        $smdiff += 60; // and carry
    }
    $changeinday2 = $cindsign.$shdiff.':'.$smdiff.':'.$ssdiff; // Assemble cind string
    return $changeinday2;
}
// end of changeinday()

to the common.php V1.09 and that is not in the V1.10 common.php.  Add that code at the end of the V1.10 common.php and all should be well.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline n7xrd

  • Forecaster
  • *****
  • Posts: 366
    • Kamiah Weather
Re: Common.php
« Reply #2 on: April 23, 2019, 10:22:38 AM »
Thank you Ken worked like a charm!!!!!   [tup]

 

anything