TNET Services, Inc. // and Ken True for the great Ajax Scripts and // Tom Chapman for all his work on Scripts and Brian // from Weather Display for loads of help and tags! // Without their great programs, code and scripts, none of this would be possible! // Thanks to all of them for allowing me to modify their great code and put it out! // www.BurnsvilleWeatherLIVE.com - scott@burnsvilleweatherlive.com // ------------------------------------------------------------------------------------------ // Version 6.80 - 17-Feb-2013 Modified first pannel to include Storm Prediction(US) animated image under forecast and moved Fire Danger under Rain/Snow. Several // other minor changes. Config File Change required. New Version of ajaxWDwx.js also required. Included many of the suggested changes // from Gerald Wilkins from www.gwwilkins.org, thanks for all your hard work Gerald! Added year to date Max Gust. Added Snow Melt to // Top section next to Snowflake if usesnow is false, thanks Jerry! Changed name of script to Burnsville Weather Live. Fixed issue // with Tide centerization. Added back Yesterday Hi/lo section. Many minor fixes and enhancements. // Vesrion 6.81 - 20-Mar-2013 Fixes from Jerry for Solar and Conversions in Java Script. Other minor changes and fixes. Added in Yesterday High/Low, Fix for CBI/FWI // that got messed up in 6.80. Now works fully with Metric/Imperial translations. // NOTE: MUST be used with ajaxWDwx3.js version 3.01 (formally 6.xx but renamed back to the 3.xx series I was supposed to be using) // Version 6.82 - 07-Sep-2013 Moved Storm Prediction Image to config to make setting the image easier for other countries and locals. Minor CSI and other fixes. Changed // FWI section to take 6 images and allow for a scale of 0-232 as shown in Weather Display. NOTE YOU WILL NEED TO FIX IMAGE NAMES (In main script // and Ajax) OR RE-NAME IMAGES FOR FWI // Version 6.90 - 30-Oct-2013 Relayout and additional items in Dew Point, Humidity. Added opional Rain Chart (new config file) and made a lot of code clean-ups // Added date translation to function "function mon_no($Tmonth)" below for multiple languages. Search for it to add more languages. // Added ability to see what version AjaxWDwx3.js version is being run in the station status section. // Version 6.91 - 10-Nov-2013 Added changes to ajaxWDwx3.js and Lightning Code only. Not needed if not using Lightning detection. Several minor changes. // Version 6.92 - 09-Feb-2014 Added Show Mobile Version Button option, will display mobile version if enabled. Updates to Lightning and Snow in CM // Fix for max gust showing year man instead of all time gust. // Version 6.93 - 10-Jun-2014 Fix for dewpoint not displaying right information. Fix for soil depth level 10 times higher then it should. Fix for C display rather then F. // Version 6.94 - 13-Oct-2015 Fix for new style icons lining up right. Thanks for Ken True for the fix!! // Minor updates to style code. // Version 6.95 - 05-JAN-2016 Update to work with WeatherDisplay 10.37R B307 and later. // Version 6.95a - 01-Jan-2018 Added support for DarkSky.net forecasts // Version 6.95b - 03-Apr-2019 Add WC/TWC forecast support + Replace Google chart sunpie with PHP version from G Willkins // Version 6.95c - 19-Apr-2019 updated moon phase calculations and tables to years 2018-2030 // Version 6.95d - 24-Mar-2021 added support for weewx-saratoga operation (moon info calcs) // also fixed metric/imperial displays on multiple displays // added suport for additional forecast scripts // added imperial/metric display for forecast temps but not text forecasts // // ----------------------------------------------------------------------------------------- // NOTE: Please do not remove the version link at the bottom of the script unless you have // donated something to me or your local food-shelf. That's all I ask in return for using // this script. I'll leave it up to you which you do. You don't need to send me anything // if you choose to donate to your local food shelf, your word is good for me! THANKS! // (Of course if you want to donate AND leave the link up, thats great too! :) ) Scott // ----------------------------------------------------------------------------------------- // //error_reporting(E_ALL); // --- settings for standalone use -------------------------- $tagsInterval = 1; // testtags.php upload interval in minutes $ajaxvers = "| Ajax 3.xx"; // Required ajaxWDwx3.js version for this script. Will display actual version (3.07) in station status section. $Lang = 'en'; $uomTemp = '°F'; $uomBaro = ' inHg'; $uomWind = ' mph'; $uomRain = ' in'; $uomSoil = ' in'; $uomPerHour = '/hr'; $uomHeight = ' ft'; $uomDistance = ' miles'; $uomSnow = ' in'; $imagesDir = 'ajax-images/'; // directory for ajax-images with trailing slash $condIconDir = './ajax-images/'; // directory for condition icons $condIconType = '.png'; // default type='.jpg' -- use '.gif' for animated icons from https://www.meteotreviglio.com/ // $timeFormat = 'D, d-M-Y g:ia T'; // Fri, 31-Mar-2006 6:35pm TZone $timeFormat = 'd-M-Y g:ia'; // Fri, 31-Mar-2006 6:35pm //$timeOnlyFormat = 'g:ia'; // h:mm[am|pm]; $timeOnlyFormat = 'g:i A'; // h:mm [AM|PM]; //$timeOnlyFormat = 'H:i'; // hh:mm $dateOnlyFormat = 'd-M-Y'; // d-Mon-YYYY $WDdateMDY = true; // true=dates by WD are 'month/day/year' // // false=dates by WD are 'day/month/year' $ourTZ = "America/Chicago"; //NOTE: this *MUST* be set correctly to // translate UTC times to your LOCAL time for the displays. // if (isset($_REQUEST['sce']) && ( strtolower($_REQUEST['sce']) == 'view' or strtolower($_REQUEST['sce']) == 'show')) { //--self downloader -- $filenameReal = __FILE__; $download_size = filesize($filenameReal); header('Pragma: public'); header('Cache-Control: private'); header('Cache-Control: no-cache, must-revalidate'); header("Content-type: text/plain"); header("Accept-Ranges: bytes"); header("Content-Length: $download_size"); header('Connection: close'); readfile($filenameReal); exit; } include_once("common.php"); // for language translation include_once("Settings.php"); if (file_exists('raintodate.php')) { include_once('raintodate.php'); } // for ytd/mtd rain calculations include_once("AltAjaxDashboardConfig6.php"); // for alt Dashboard configuration items include_once('get-aqi-rss.php'); // get AQI index value for dashboard display /* include_once('LincolnHiLo-Update.php'); // Get Today's HiLo Values global $theHigh,$highDate,$theLow,$lowDate; // Access these values include_once('LincolnAverages-Update.php'); global $avgHigh,$avgLow,$monthPrecip,$yearPrecip,$monthSnow,$yearSnow; */ include_once('noaarec.php'); // --- end of settings for standalone use // // overrides from Settings.php if available echo '\n"; global $SITE, $forwardTrans, $reverseTrans; $commaDecimal = false; if (isset($SITE['lang'])) { $Lang = $SITE['lang']; } if (isset($SITE['uomTemp'])) { $uomTemp = $SITE['uomTemp']; } if (isset($SITE['uomBaro'])) { $uomBaro = $SITE['uomBaro']; } if (isset($SITE['uomWind'])) { $uomWind = $SITE['uomWind']; } if (isset($SITE['uomRain'])) { $uomRain = $SITE['uomRain']; } if (isset($SITE['uomSnow'])) { $uomSnow = $SITE['uomSnow']; } if (isset($SITE['uomPerHour'])) { $uomPerHour = $SITE['uomPerHour']; } if (isset($SITE['imagesDir'])) { $imagesDir = $SITE['imagesDir']; } if (isset($SITE['timeFormat'])) { $timeFormat = $SITE['timeFormat']; } if (isset($SITE['timeOnlyFormat'])) { $timeOnlyFormat = $SITE['timeOnlyFormat']; } if (isset($SITE['dateOnlyFormat'])) { $dateOnlyFormat = $SITE['dateOnlyFormat']; } if (isset($SITE['WDdateMDY'])) { $WDdateMDY = $SITE['WDdateMDY']; } if (isset($SITE['tz'])) { $ourTZ = $SITE['tz']; } if (isset($SITE['UV'])) { $haveUV = $SITE['UV']; } if (isset($SITE['SOLAR'])) { $haveSolar = $SITE['SOLAR']; } if (isset($SITE['WXtags'])) { $WXtags = $SITE['WXtags']; } if (isset($SITE['fcstorg'])) { $fcstorg = $SITE['fcstorg']; } if (isset($SITE['fcstscript'])) { $fcstscript = $SITE['fcstscript']; } if (isset($SITE['UVscript'])) { $UVscript = $SITE['UVscript']; } if (isset($SITE['DavisVP'])) { $DavisVP = $SITE['DavisVP']; } if (isset($SITE['showSnow'])) { $showSnow = $SITE['showSnow']; } if (isset($SITE['commaDecimal'])) { $commaDecimal = $SITE['commaDecimal']; } if (isset($SITE['fcsticonsdir'])) { $fcstIconDir = $SITE['fcsticonsdir']; } if (isset($SITE['fcsticonstype'])) { $condIconType = $SITE['fcsticonstype']; } if (isset($SITE['moonIconsSet'])) { $moonIconsSet = $SITE['moonIconsSet']; } $moonHemisphere = 'NH'; if ($SITE['latitude'] < 0) { $moonHemisphere = 'SH';} // testing parameters// testing parameters print "\n"; $DebugMode = false; if (isset($_REQUEST['debug'])) { $DebugMode = strtolower($_REQUEST['debug']) == 'y'; } if (isset($_REQUEST['UV'])) { $haveUV = $_REQUEST['UV'] <> '0'; } if (isset($_REQUEST['solar'])) { $haveSolar = $_REQUEST['solar'] <> '0'; } if (isset($_REQUEST['snow'])) { $displaySnow = $_REQUEST['snow'] <> '0'; } $fcstby = isset($_REQUEST['fcstby']) ? strtoupper($_REQUEST['fcstby']) : ''; if ($fcstby == 'NWS') { $SITE['fcstscript'] = 'advforecast2.php'; // USA-only NWS Forecast script $SITE['fcstorg'] = 'NWS'; // set to 'NWS' for NOAA NWS $fcstorg = $fcstby; $fcstscript = $SITE['fcstscript']; } if ($fcstby == 'EC') { $SITE['fcstscript'] = 'ec-forecast.php'; // Canada forecasts from Environment Canada $SITE['fcstorg'] = 'EC'; // set to 'EC' for Environment Canada $fcstorg = $fcstby; $fcstscript = $SITE['fcstscript']; } if ($fcstby == 'WC') { $SITE['fcstscript'] = 'WC-forecast.php'; // Non-USA, Non-Canada Wunderground/TWC Forecast Script $SITE['fcstorg'] = 'WU/TWC'; // set to 'WU/TWC' for WeatherUnderground/TWC $fcstorg = $fcstby; $fcstscript = $SITE['fcstscript']; } if ($fcstby == 'AW') { $SITE['fcstscript'] = 'AW-forecast.php'; // Non-USA, Non-Canada Aerisweather Forecast Script $SITE['fcstorg'] = 'Aerisweather'; // set to 'Aerisweather' for Aerisweather.com $fcstorg = $fcstby; $fcstscript = $SITE['fcstscript']; } if ($fcstby == 'WXSIM') { $SITE['fcstscript'] = 'plaintext-parser.php'; // WXSIM forecast $SITE['fcstorg'] = 'WXSIM'; // set to 'WXSIM' for WXSIM forecast $fcstorg = $fcstby; $fcstscript = $SITE['fcstscript']; } if ($fcstby == 'DarkSky') { $SITE['fcstscript'] = 'DS-forecast.php'; // DarkSky forecast $SITE['fcstorg'] = 'DarkSky'; // set to 'DarkSky' for DarkSky forecast $fcstorg = $fcstby; $fcstscript = $SITE['fcstscript']; } // end of special testing parms print "\n"; // end of overrides from Settings.php include_once('season-include.php'); // Countdown timer to next season if (!isset($keepNarrow)) $keepNarrow = true; include_once($WXtags); // for the bulk of our data $doPrintNWS = false; // suppress printing of forecast by advforecast2.php $doPrint = false; // suppress printing of ec-forecast.php $doPrintWU = false; // suppress printing of WU-forecast.php $doPrintWC = false; // suppress printing of WC-forecast.php $doPrintDS = false; // suppress printing of DarkSky DS-forecast.php $doPrintAW = false; // suppress printing of Aerisweather AW-forecast.php include_once($fcstscript); // for the forecast icon stuff // copy forecast script variables to carterlake-style names if script used is not advforecast2.php if ($fcstorg == 'WU/TWC') { $forecasticons = $WCforecasticons; $forecasttemp = $WCforecasttemp; $forecasttitles = $WCforecasttitles; $forecasttext = $WCforecasttext; } else if ($fcstorg == 'Aerisweather') { $forecasticons = $AWforecasticons; $forecasttemp = $AWforecasttemp; $forecasttitles = $AWforecasttitles; $forecasttext = $AWforecasttext; } else if ($fcstorg == 'DarkSky') { $forecasticons = $DSforecasticons; $forecasttemp = $DSforecasttemp; $forecasttitles = $DSforecasttitles; $forecasttext = $DSforecasttext; } else if ($fcstorg == 'EC') { foreach ($forecasticon as $i => $temp) { $forecasticons[$i] = $forecasttitles[$i] . "
\n" . $forecasticon[$i] . "\n" . $forecasttext[$i] . "\n"; } $forecasttext = $forecastdetail; foreach ($forecastdays as $i => $temp) { $t = explode('
', $forecastdays[$i]); $forecasttitles[$i] = $t[0]; } } else if ($fcstorg == 'WXSIM') { $forecasticons = $WXSIMicons; $forecasttemp = $WXSIMtemp; $forecasttitles = $WXSIMday; $forecasttext = $WXSIMtext; } if (isset($SITE['WXSIM']) and $SITE['WXSIM'] == true and $fcstorg <> 'WXSIM') { $doPrint = false; include_once($SITE['WXSIMscript']); } // Fix Lightning testtag to split it to separate date and time tags for ajax update ability - New Version 6.91 //$lighteningcountlasttime = '19:07:43 2013/24/11'; $llst = explode(' ',$lighteningcountlasttime); $lastlightningstriketime = $llst[0]; $llsd = explode('/',trim($llst[1])); $lastlightningstrikedate = rdate($RecDateF,$llsd[2],$llsd[1],$llsd[0]); $freezing = false; // assume normal rain display //if ((isset($snowseasoncm) and isset($snowseasonin)) and // ($snowseasoncm > 0.0 or $snowseasonin > 0.0)) { // $displaySnow = true; //} $nowTemp = strip_units($temperature); $showChill = true; // Do not change this value manually, it is changed by the temperature if (strip_units($nowTemp) >= $coolVal) { $showChill = false; } $showHeat = false; // Do not change this value manually, it is changed by the temperature if (strip_units($nowTemp) >= $coolVal) { $showHeat = true; } print "\n"; if ($Lang <> 'en') { // try changing windrose graphics test for the Calm graphic $tfile = preg_replace('|^' . $wrName . '|', $wrName . $Lang . '-', $wrCalm); print "\n"; if (file_exists($imagesDir . $tfile)) { print "\n"; print '\n"; $wrCalm = $tfile; // change the PHP dashboard settings too $wrName = $wrName . $Lang . '-'; print "\n"; } } // --- end of settings ------------------- if (stristr($_SERVER["HTTP_HOST"], 'localhost') !== false) $ajaxDebug = true; // ajax debug messages else if (isset($_GET["progress"])) $ajaxDebug = true; else $ajaxDebug = false; $rest = substr($firstsnowseason, 0, 3); if ($rest == '0/0') $firstsnowseason = 'None Yet!'; // set first snow of season to 'Not Yet' rather then 0/0/20xx // Sample from WD: $moonage = "Moon age: 10 days,10 hours,41 minutes,80%"; // current age of the moon (days since new moon) // Sample from WD: $moonphase = "80%"; // Moon phase % /* old $moonagedays = preg_replace('|^Moon age:\s+(\d+)\s.*$|is', "\$1", $moonage); if ($moonphase == '') { // MAC version of WD is missing this value preg_match_all('|(\d+)|is', $moonage, $matches); $moonphase = $matches[1][3]; if (isset($matches[1][4])) { $moonphase .= '.' . $matches[1][4]; // pick up decimal; $moonphase = round($moonphase, 0); } $moonphase .= '%'; } */ if(isset($moonage)) { // Sample from WD: $moonage = "Moon age: 10 days,10 hours,41 minutes,80%"; // current age of the moon (days since new moon) // Sample from WD: $moonphase = "80%"; // Moon phase % $moonagedays = preg_replace('|^Moon age:\s+(\d+)\s.*$|is',"\$1",$moonage); if($moonphase == '') { // MAC version of WD is missing this value preg_match_all('|(\d+)|is',$moonage,$matches); $moonphase = $matches[1][3]; if(isset($matches[1][4])) { $moonphase .= '.' . $matches[1][4]; // pick up decimal; $moonphase = round($moonphase,0); } $moonphase .= '%'; } } else { // perform non-WD moon stuff $mooninfo = cGetMoonInfo(); /* Note: getMoonInfo() is located in common.php */ /* returns $mooninfo of: [age] => 9 days, 11 hours, 57 minutes [ill] => 65 [pic] => 8 [phase] => Waxing Gibbous [NM] => 1294131882 [NMGMT] => Tue, 04-Jan-2011 09:04 GMT [NMWD] => 09:04 GMT 04 January 2011 [Q1] => 1294831983 [Q1GMT] => Wed, 12-Jan-2011 11:33 GMT [Q1WD] => 11:33 GMT 12 January 2011 [FM] => 1295472210 [FMGMT] => Wed, 19-Jan-2011 21:23 GMT [FMWD] => 21:23 GMT 19 January 2011 [Q3] => 1298590089 [Q3GMT] => Thu, 24-Feb-2011 23:28 GMT [Q3WD] => 23:28 GMT 24 February 2011 [Q4] => 1296700310 [Q4GMT] => Thu, 03-Feb-2011 02:31 GMT [Q4WD] => 02:31 GMT 03 February 2011 [FM2] => 1298018189 [FM2GMT] => Fri, 18-Feb-2011 08:36 GMT [FM2WD] => 08:36 GMT 18 February 2011 */ print "\n"; if(!isset($moonphase)) {$moonphase = $mooninfo->ill.'%'; } if(!isset($newmoon)) {$newmoon = $mooninfo->NMWD; } if(!isset($nextnewmoon)) {$nextnewmoon = $mooninfo->Q4WD; } /*check this! */ if(!isset($firstquarter)) {$firstquarter = $mooninfo->Q1WD; } if(!isset($lastquarter)) {$lastquarter = $mooninfo->Q3WD; } if(!isset($fullmoon)) {$fullmoon = $mooninfo->FMWD; } if(!isset($moonphasename)) {$moonphasename = $mooninfo->phase;} if(!isset($moonagedays)) {$moonagedays = $mooninfo->pic; } if(!isset($moonage)) {$moonage = 'Moon age: '.$mooninfo->age.','.$mooninfo->ill.'%'; } if(file_exists("get-USNO-sunmoon.php")) { include_once("get-USNO-sunmoon.php"); $USNOdata = getUSNOsunmoon(); } if(isset($USNOdata['sunrise'])) {$sunrise = $USNOdata['sunrise']; } if(isset($USNOdata['sunrisedate'])) {$sunrisedate = $USNOdata['sunrisedate']; } if(isset($USNOdata['sunset'])) {$sunset = $USNOdata['sunset']; } if(isset($USNOdata['sunsetdate'])) {$sunsetdate = $USNOdata['sunsetdate']; } if(isset($USNOdata['moonrise'])) {$moonrise = $USNOdata['moonrise']; } if(isset($USNOdata['moonrisedate'])) {$moonrisedate= $USNOdata['moonrisedate']; } if(isset($USNOdata['moonset'])) {$moonset = $USNOdata['moonset']; } if(isset($USNOdata['moonsetdate'])) {$moonsetdate = $USNOdata['moonsetdate']; } if(isset($USNOdata['moonphase'])) {$moonphasename = $USNOdata['moonphase']; } if(isset($USNOdata['illumination'])) {$moonphase = $USNOdata['illumination']; } if(isset($USNOdata['hoursofpossibledaylight'])) {$hoursofpossibledaylight = $USNOdata['hoursofpossibledaylight'];} } # Set timezone in PHP5/PHP4 manner if (!function_exists('date_default_timezone_set')) { putenv("TZ=" . $ourTZ); # $Status .= "\n"; } else { date_default_timezone_set("$ourTZ"); # $Status .= "\n"; } $UpdateDate = date($timeFormat, strtotime("$date_year-$date_month-$date_day $time_hour:$time_minute:00")); // $UpdateDate = "$date_year-$date_month-$date_day $time_hour:$time_minute:00"; $monthname = langtransstr($monthname); // translate WD month name to selected language $dayname = langtransstr(substr($dayname, 0, 3)); // // Snow setup if ($snowtoday == '---' or $snowtoday == '') { $snowtoday = '0'; } if ($burntime == '---' or $burntime == '') { $burntime = 'N/A'; } if ($avgmonthrain1 == '') { $avgmonthrain1 = ${'avrain' . strtolower(strftime("%b"))}; $avgmonthsnow1 = ${'avsnow' . strtolower(strftime("%b"))}; $avgmonthtemp1 = ${'avtemp' . strtolower(strftime("%b"))}; } if (preg_match('|in|i', $uomSnow)) { // use USA measurements $sndiff = $snowmonthin - $avgmonthsnow1; //calculate difference in snow vs avg, inches $snowseason = $snowseasonin; // Snow for season you have entered under input daily weather, inches $snowmonth = $snowmonthin; // Snow for month you have entered under input daily weather, inches $snowtoday = $snowtodayin; // Snow for today you have entered under input daily weather, inches $snowyesterday = $snowyesterday; // Yesterdays' snow $snownow = $snownowin; // Current snow depth, inches. $apparentsolartemp = $apparentsolartempf; // Apparent Solar $avgmonthsnow1 = ($avgmonthsnow1 * .3937); //Removed for version 3 of the ajax script from Ken True (Thanks Tim for the find) } elseif (isset($snowseasoncm)) { // use Metric measurements $sndiff = $snowmonthcm - $avgmonthsnow1; //calculate difference in snow vs avg, cm $snowseason = $snowseasoncm; // Snow for season you have entered under input daily weather, cm $snowmonth = $snowmonthcm; // Snow for month you have entered under input daily weather, cm $snowtoday = $snowtodaycm; // Snow for today you have entered under input daily weather, cm $snowyesterday = $snowyesterday; // Yesterdays' snow $snownow = $snownowcm; // Current snow depth, cm. $apparentsolartemp = $apparentsolartempc; // Apparent Solar } if ((preg_match('|in|i', $uomRain) and strip_units($wetbulb) > 32) or (preg_match('|[A-Za-z]m|i', $uomRain) and strip_units($wetbulb) > 0)) { //Check to see if snow is possible $freezing = false; } else { $freezing = true; } //$displaySNOW = true; //if (!$useSNOW) { $freezing = false; } // if useSNOW is set to false, then never allow any snow related items to turn on. $rndiff = $monthrn - $avgmonthrain1; // calculate difference in rain vs avg $rndiff_mtd = $monthrn - $avg_mtd_rain; // calculate difference in rain vs avg month-to-date $sndiff = $snowmonthin - $avgmonthsnow1; //calculate difference in snow vs avg $decimalComma = (strpos($temperature, ',') !== false) ? true : false; // using comma for decimal point? //Setup up Lightning Over-ride if (($useLIGT) and ($lighteningcountlast5minutes > $minLcnt)) $S3C2 = $S3C2 + 6; // Lightning count in last 5 minutes indicates Lightning present if (($useSNOW) and ($snownow > 0)) $S3C2 = $S3C2 + 5; //Snow is on the ground //Detect Internet Explorer Browser for Sunlight Pie Chart //Determine use 'Rain' or 'Precip' based on $heatedRainGauge $precipSTR = 'Rain'; if ( $heatedRainGauge ) { for ($i=0; $i0)?'+':'-'; // 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 $result = array($changeinday2,$hrsOfSunLight); return $result; } } // end of get_changeinday() // ============================================================================= if (!function_exists('langtransstr')) { // Avoid fatally re-declaring this!!! function langtransstr($str) { // added return($str); } } // if (!function_exists('langtransstr')) { // Avoid fatally re-declaring this!!! function langtrans($str) { // added echo $str; return; } } // --- end of initialization code --------- print "\n"; ?>
|
:  
[ of updates]   [State: ]   [Status: ]   [Progress: N/A IN PACKED VERSION]
4':''); ?>
11?true:false))) { ?>
:



= $MHI))) { ?>

= 2)) { ?>













$SStartUpDay)?$SStartYr:$SStartYr+1; ?>








11?true:false))) { // Show Local Station Based New Record HIGH/LOW Image ?>
strip_units($thisDayMax)) { echo "\"Official"; } ?> "; } ?>
strip_units($maxtemp4today)) { echo "\"Station"; } ?> "; } ?>
<?php $t1 = fixupCondition($Currentsolardescription); echo $t1; ?>

'')) { // use calm instead $wr = $imagesDir . $wrCalm; $wrtext = $bftspeedtext; } ?> <?php echo $wrtext; ?>

:
"; ?> :
"; ?> 3:
"; ?> 2'); ?>:
"; break; case ($firewi < 35): echo "\"Fire"; break; case ($firewi < 64): echo "\"Fire"; break; case ($firewi < 122): echo "\"Fire"; break; case ($firewi <= 232): echo "\"Fire"; break; case ($firewi > 232): echo "\"Fire"; break; } // end switch ?> :4
:
of 232
"; break; case ($chandler < 50): echo "\"Chandler"; break; case ($chandler < 75): echo "\"Chandler"; break; case ($chandler < 90): echo "\"Chandler"; break; case ($chandler <= 97.5): echo "\"Chandler"; break; case ($chandler > 97.5): echo "\"Chandler"; break; } // end switch ?> 4
::
of 100
66 °F ↓' to // to 'Hi Low: 43°' // to 'Low: 43°F' // WCFcst '66°F' // to '66°F' // AWfcst '18.9°C' // to '18.9°C' // DSfcst '18°C
6°C' // to '18°C
6°C' global $uomTemp; $t = str_replace('°<',$uomTemp.'<',$intemp); // handle WXSIM w/no uom $t = preg_replace_callback('!([\d]+)\s*°(F|C)!Us', function ($M) { return ''.$M[1].'°'.$M[2].''; }, $t); print "\n"; return $t; } ?>

2 Hr. Lightning Map Unavailable
:
:
:
:
:
:
:
:7
0) { // Show Rain Rates ?> 0)) { // Storm Rain is a Davis VP thing ?>

rain graph

2'); } else { echo langtrans('Today'); } ?>:
Rate ():
:
:
:

  :10

  :10
:
:1

  :11

  :11
:1

:


:  
: 0) { ?>
:
:
:
:
:

:
Sunlight Time Change Days if ($useSunlightPie) { //Make piechart if not using IE or if IE's Pie Chart is OK ?>
0?$cidsign = '+': $cidsign ='-'; if ($time_arr[1]< 5) { if ($displayYesterday) { $time_arr2 = explode(':', $hrsOfSunLight[0]); echo (int)$time_arr2[0] . " h " . (int)$time_arr2[1] . " m " . (int)$time_arr2[2]." s"; echo '
of Sunlight Yesterday
'; } $time_arr = explode(':', $hrsOfSunLight[1]); if ($displayTomorrow || $displayYesterday) { echo (int)$time_arr[0] . " h " . (int)$time_arr[1] . " m " . (int)$time_arr[2]." s"; } else { echo (int)$time_arr[0] . " hrs " . (int)$time_arr[1] . " min".'
'. (int)$time_arr[2]." sec"; } echo '
of Sunlight Today
'; ?>
0?'
'.(int)$time_arr[1] . " min ":' ') . $time_arr[2]; echo ((substr($time_arr[0],0,1) != "-")?' sec longer':' sec shorter').' than
yesterday
'; // '-' when getting shorter if ($displayTomorrow) { $time_arr3 = explode(':', $hrsOfSunLight[2]); echo (int)$time_arr3[0] . " h " . (int)$time_arr3[1] . " m " . (int)$time_arr3[2]." s"; echo '
of Sunlight Tomorrow
'; } else { #echo '
'; } ?>
(Noon) graph (Midnight)
Legend
 '; ?>
" ?>


= b51 $time_arr = explode(':', $changeinday); if (substr($time_arr[0], 0, 1) != "-") { // -0 when getting shorter echo '+'; } else { echo '-'; } echo (int) $time_arr[1] . ":" . $time_arr[2] . "
Min:Sec"; } else { // using version earlier than V10.37R b51 if (substr_count($changeinday, '-') == 0) { echo ("+" . "$changeinday"); } else { echo "$changeinday"; } ?>


Hours
' ?>
 '; ?>
'; $mooninfo = getMoonInfo(); if($DebugMode) { print "\n";} ?> phase); ?>
pic, 2, "0", STR_PAD_LEFT) . '.gif" alt ="' . $mooninfo->phase . ', ' . $mooninfo->age . ' in cycle" title="' . $mooninfo->phase . ', ' . $mooninfo->age . ' in cycle" width="60" height="60" style="border: 0;" />'; ?>
ill . "%"; ?>
: %
:
:
:
:
:
:
:
:
:
:
:
= $coolVal) echo " " . langtransstr('Cooling Degree Days') . " "; else echo " " . langtransstr('Heating Degree Days') . " "; ?> 3 = $coolVal) echo " " . langtransstr('Heat Index') . " "; else echo " " . langtransstr('Wind Chill') . " "; ?>
: = $coolVal) echo $cddday; else echo $hddday; ?>
: = $coolVal) echo $cddmonth; else echo $hddmonth; ?>
: = $coolVal) echo $cddyear; else echo $hddyear; ?>
= $coolVal) echo " " . langtransstr('Heating Degree Days') . " "; else echo " " . langtransstr('Cooling Degree Days') . " "; ?>
: = $coolVal) echo $hddyear; else echo $cddyear; ?>
'; foreach ($next_tides as $k => $v) { if ($k >= 0) { $mins_to_next_tide = $k; $tide_type = $v; break; } } echo ""; //echo $nexttidequarter; ?>
:
:
:
:
:
:
:

:

:
:
:
:
:
:2
:
2


PatioCam Image facing North
StreetCam Image facing South
"; $next_tide_time = date('h:i A T', strtotime("+$mins_to_next_tide minutes")); echo "

" . time_till_tide($mins_to_next_tide * 60) . " to " . $tide_type . " tide at
" . $next_tide_time . "

"; $mins_to_next_tide_rounded = round_tide_time($mins_to_next_tide); $tide_image = select_tide_image($mins_to_next_tide_rounded, $tide_type); echo "\"\"/
"; echo "
:
:
:
:
:
:
:
:
Quality
Index6:
" . $realValue1 . "


"; } if ($realValue1 == "") { echo "Data Not
Available


\"Data"; } else { getGraphic($realIndex1, $aqiLevels, $aqiGraphic, $imagesDir); } ?>
:
3" ?>
US AQI
9'; } else { $rightHead = 'Current Solar Energy'; } } $UVfcstDate = array_fill(0, 9, ''); // initialize the return arrays $UVfcstUVI = array_fill(0, 9, 'n/a'); if (isset($UVscript)) { // load up the UV forecast script @include_once($UVscript); } $UVptr = 0; // index for which day to use ?> 12) { // because the forecasts points at wrong day otherwise $evening = 1; // and forecast isn't for 'tomorrow'. } ?>
= 11) { $VPuv2 = 11; } ?> :

12) { // Display Summary if in the evening ?> :    @  :    @ 
= 11) { $VPuv2 = 11; } ?>

= 11) { $VPuv2 = 11; } ?>

= 11) { $VPuv2 = 11; } ?>

12) { // Display Summary if in the evening ?> :  
2 @  :    @ 
:

   Hrs
:   
W/m2
%
onclick="javascript:toggle_SI()" >W/m2 SI onclick="javascript:toggle_SI()" >Solar % SI onclick="javascript:toggle_SI()">W/m2 SI onclick="javascript:toggle_SI()">Solar % SI
onclick="javascript:toggle_SI()"> style="cursor:pointer" id="ajaxsiimg"> onclick="javascript:toggle_SI()"> style="cursor:pointer" id="ajaxsiimg2"> :

  W/m2
:
 W/m2
:
:
:
8   5 3 1) {?> 1) { // Display next sensor if required ?> 2) { // Display next sensor if required ?> 3) { // Display next sensor if required ?>
:
:
:
:
:
:
:
:
':'')?>:
: |
: |
: |
: |


:



1) {?>
:
:
:
Last Hr. Strikes Blitz Lightning Map 24 Hour Delta T
:
':'').$nextSeason.($useNextSeason==3?'':'
Begins')?>:

 
Support this Site!
:
:
:
:2
:
1) ? 's' : ''; print "$t in " . $monthname; ?>
1) ? 's' : ''; print "$t this season."; ?>2
:
: :


  " . $_array[1]; ?>   " . $_array[1]; ?>
  " . $_array[1]; ?>   " . $_array[1]; ?>

" . $vpissstatus . ""; echo "ISS:" . $lowvolt . " | "; } else echo "ISS:" . $vpissstatus . " | "; if ($useVPst) { // Show Vantage Pro status data $lowvolt = "" . $vpconsolebattery . ""; if ($vpconsolebattery < 3.6) echo "CON:" . $lowvolt . " | "; else echo "CON:" . $vpconsolebattery . " | "; echo "RCP:" . $vpreception2; } // end $useVPst ?>
|
:  
1 .   2 .   3 .   2 .   4 .   5 .   6 .   7 .   8 .   9 .   10 .   11 .
    -     &
" . reformat_forecast_temp($forecasttemp[0]); ?> $fcstorg " . langtransstr ('forecast') . ": " . $forecasttext[0] . "
\n"; if ($fcstorg <> 'WXSIM' and isset($WXSIMtext[0])) { print ' WXSIM ' . langtransstr('forecast') . ': ' . $WXSIMtext[0] . "
\n"; } if (($useVPfc) && ($vpforecasttext <> '')) { print ' ' . langtransstr('VP2 automated forecast') . ': ' . ucfirst($vpforecasttext) . ""; } ?>
" . reformat_forecast_temp($forecasttemp[1]); ?> $fcstorg " . langtransstr('forecast') . ": " . $forecasttext[1]; if ($fcstorg <> 'WXSIM' and isset($WXSIMtext[1])) { print '
WXSIM ' . langtransstr('forecast') . ': ' . $WXSIMtext[1] . "
\n"; } ?>
 
www.meteotreviglio.com  "; } if ($useSeasonCntDwn) { echo langtransstr('Season Countdown Timer by')." Curly"; } ?>
Murry Conarroe
"; }?> - Script by: Scott of BurnsvilleWeatherLIVE.com
Now supported by Saratoga-weather.org Download
\n"; // input dates are assumed to be in English only if (isset($SITE['monthNames'])) { // convert TO English for strtotime() echo "\n"; foreach ($EnglishMonths as $i => $monthEN) { $utcstr = preg_replace('| '.$SITE['monthNames'][$i].' |i'," $monthEN ",$utcstr); } echo "\n"; } $utc = strtotime($utcstr); $lclstr = date($Fdate,$utc); if (isset($SITE['langMonths'])) { // convert From English for return (will only work if long-format month names in $timeFormat) echo "\n"; foreach ($EnglishMonths as $i => $monthEN) { $lclstr = preg_replace('| '.$monthEN.' |i',' '.$SITE['langMonths'][$i].' ',$lclstr); } echo "\n"; } return ($lclstr); } function mon_three($Tmonth) { // Added for version 6.90 Burnsville Weather Live switch ($Tmonth) { case 1: $MMM = langtransstr("Jan"); break; case 2: $MMM = langtransstr("Feb"); break; case 3: $MMM = langtransstr("Mar"); break; case 4: $MMM = langtransstr("Apr"); break; case 5: $MMM = langtransstr("May"); break; case 6: $MMM = langtransstr("Jun"); break; case 7: $MMM = langtransstr("Jul"); break; case 8: $MMM = langtransstr("Aug"); break; case 9: $MMM = langtransstr("Sep"); break; case 10: $MMM = langtransstr("Oct"); break; case 11: $MMM = langtransstr("Nov"); break; case 12: $MMM = langtransstr("Dec"); break; } return $MMM; } function mon_no($Tmonth) { // Added for version 6.90 Burnsville Weather Live //English, Danish, Dutch, Finnish, French, German, German (Swiss), Italian, Norwegian, Polish, Spanish, Swedish //Strings for each month MUST start with x and be three characters long. Add to the end of the file. I did not //repeat the month abbreviation if it was the same as another language. Case matters!! $monthJan = "xJanjantamjargenstyene"; $monthFeb = "xFebfebhelfévlut"; $monthMar = "xMarmarmaaMärMer"; $monthApr = "xApraprhuhavrkwiabr"; $monthMay = "xMaymajmeitoumaiMaimagmaj"; $monthJun = "xJunjunkesjuigiucze"; $monthJul = "xJuljulheijuiluglip"; $monthAug = "xAugaugeloaoûagosieago"; $monthSep = "xSepsepsyysetwrz"; $monthOct = "xOctoktlokOktottpa?d"; $monthNov = "xNovnovmarlis"; $monthDec = "xDecdecjoudécDezdicdesgru"; $MMM = 0; //print "[" . $Tmonth . "]"; //$Tmonth = trim($Tmonth); $Tmonth = substr($Tmonth, 0, 3); //print "[" . $Tmonth . "]"; switch (FALSE) { case (strpos($monthJan, $Tmonth, 1) === False): $MMM = 1; break; case (strpos($monthFeb, $Tmonth, 1) === False): $MMM = 2; break; case (strpos($monthMar, $Tmonth, 1) === False): $MMM = 3; break; case (strpos($monthApr, $Tmonth, 1) === False): $MMM = 4; break; case (strpos($monthMay, $Tmonth, 1) === False): $MMM = 5; break; case (strpos($monthJun, $Tmonth, 1) === False): $MMM = 6; break; case (strpos($monthJul, $Tmonth, 1) === False): $MMM = 7; break; case (strpos($monthAug, $Tmonth, 1) === False): $MMM = 8; break; case (strpos($monthSep, $Tmonth, 1) === False): $MMM = 9; break; case (strpos($monthOct, $Tmonth, 1) === False): $MMM = 10; break; case (strpos($monthNov, $Tmonth, 1) === False): $MMM = 11; break; case (strpos($monthDec, $Tmonth, 1) === False): $MMM = 12; break; } return $MMM; } // Pull month only, as a number, out of strings with full date in them (NEW version 6.90) // if $dtyp = 1 then date is in 25 December 2013 format // if $dtyp = 2 then date is in Dec 25 2013 format function split_to_mon($dtyp, $datetofix) { $datetofix = trim($datetofix); $d = explode(' ', $datetofix); if ($dtyp == 1) { $fmonth = mon_no(trim($d[1])); } else { $fmonth = mon_no(trim($d[0])); } //print "$d[0], $d[1], $d[2]"; return $fmonth; } function split_hash_date($datetofix) { // Added for version 6.90 Burnsville Weather Live global $datefmt; $dmy = 2; if ($datefmt == 'd/m/y') { $dmy = 1; } $datetofix = trim($datetofix); $d = explode('/', $datetofix); if ($dmy == 1) { $fdate[0] = $d[0]; $fdate[1] = $d[1]; } else { $fdate[0] = $d[1]; $fdate[1] = $d[0]; } $fdate[2] = $d[2]; //print "$fdate[0], $fdate[1], $fdate[2]"; return array($fdate[0], $fdate[1], $fdate[2]); } // Pull day only out of strings with full date in them (NEW version 6.90) // if $dtyp = 1 then date is in 25 December 2013 format // if $dtyp = 2 then date is i, Dec 25 2013 format function split_to_day($dtyp, $datetofix) { $d = explode(' ', ltrim($datetofix)); if ($dtyp == 1) { $fday = (int)$d[0]; } else { $fday = (int)$d[1]; } return $fday; } // Pull year only out of strings with full date in them (NEW version 6.90) function split_to_year($datetofix) { $d = explode(' ', ltrim($datetofix)); $fyear = $d[2]; return $fyear; } // Assign unique image id to reliably clear browser cache /* function getUniqueImageURL($image_url){ $timestamp = time(); if(strpos($image_url, '?')){ $image_url = str_replace('?', "?$timestamp&", $image_url); } else{ $image_url .= "?$timestamp"; } return $image_url; } */ // Detect Internet Explorer function fix_record2($RecDateF, $rtfdata) { // NEW in 6.90 BurnsvilleWeather Live Originally by www.lokaltvader.se & modified by www.gwwilkins.org global $datefmt; $dmy = 2; if ($datefmt == 'd/m/y') { $dmy = 1; } //print ("[" . $datefmt . "]"); $tempinfo = explode(":", $rtfdata); $rtemp = substr($rtfdata, 0, (strpos($rtfdata, ".") + 2)); $rtfdate = rdate($RecDateF, (split_to_mon($dmy, $tempinfo[1])), (split_to_day($dmy, $tempinfo[1])), (split_to_year($tempinfo[1]))); return array($rtemp, $rtfdate); } /* function fix_record2($RecDateF, $rtfdata) { // NEW in 6.90 BurnsvilleWeather Live Originally by www.lokaltvader.se & modified by www.gwwilkins.org and // rewritten by saratoga-weather.org /* $warmestdayonrecord = '104.2 F on: Sep 06 2020'; $warmestnightonrecord = '91.0F on: Jun 20 2011'; $coldestdayonrecord = '38.8F on: Dec 08 2013'; $coldestnightonrecord = '30.9F on: Dec 10 2013'; $warmestdayonrecord = '106.0°F on: 2 Sep 2017'; //Warmest Day on Record $coldestdayonrecord = '43.2°F on: 9 Jan 2021'; //coldest Day on Record $warmestnightonrecord = '74.6°F on: 16 Aug 2020'; //Warmest Night on Record $coldestnightonrecord = '29.8°F on: 24 Feb 2018'; //coldest Night on Record switch (ltrim($RecDateF)) { case 0: // $recDateF not found or set see config file. $Fdate = "00-Err-0000"; break; case 1: // Dec-25-2013 $Fdate = 'M-d-Y'; break; case 2: // 15-Dec-2013 $Fdate = 'd-M-Y'; break; case 3: // 12/25/2013 $Fdate = 'm/d/Y'; break; case 4: // 25/12/2013 $Fdate = 'd/m/Y'; break; case 5: // Dec-25 $Fdate = 'M-d'; break; case 6: // 15-Dec $Fdate = 'd-M'; break; case 7: // 12-25-2013 $Fdate = 'm-d-Y'; break; case 8: // 25-12-2013 $Fdate = 'd-m-Y'; break; } if(preg_match('!^([\d+]).*([F|C])\s+on:\s+(.*)$!',$rtfdata,$M)) { $rtemp = $M[1].$M[2]; $rtfdate = date($Fdate,strtotime($M[3])); } return array($rtemp, $rtfdate); } */ // generate an up/down arrow to show differences function gen_difference($nowTemp, $yesterTemp, $Legend, $textUP, $textDN, $id = "") { global $imagesDir; $diff = round(strip_units($nowTemp) - strip_units($yesterTemp), 3); $absDiff = abs($diff); $diffStr = sprintf("%01.0f", $diff); $absDiffStr = sprintf("%01.0f", $absDiff); if ($diff == 0) { // no change $msg = "No Change"; $image = "\"$msg\""; } elseif ($diff > 0) { // today is greater $msg = sprintf($textUP, $absDiff); $image = "\"$msg\""; } else { // today is lesser $msg = sprintf($textDN, $absDiff); $image = "\"$msg\""; } $idS = $idE = ""; if (!empty($id)) { $idS = ''; $idE = ''; } if ($Legend) { return ($idS . $diff . $Legend . $idE . $image); } else { return $image; } } //========================================================================= // decode UV to word+color for display function get_UVrange($inUV) { // figure out a text value and color for UV exposure text // 0 to 2 Low // 3 to 5 Moderate // 6 to 7 High // 8 to 10 Very High // 11+ Extreme if (strpos($inUV, ',') !== false) { $uv = preg_replace('|,|', '.', $inUV); } else { $uv = $inUV; } switch (TRUE) { case ($uv == 0): $uv = langtransstr('None'); break; case (($uv > 0) and ($uv < 3)): $uv = ' ' . langtransstr('Low') . ' '; break; case (($uv >= 3) and ($uv < 6)): $uv = ' ' . langtransstr('Medium') . ' '; break; case (($uv >= 6 ) and ($uv < 8)): $uv = ' ' . langtransstr('High') . ' '; break; case (($uv >= 8 ) and ($uv < 11)): $uv = ' ' . langtransstr('Very High') . ' '; break; case (($uv >= 11) ): $uv = ' ' . langtransstr('Extreme') . ' '; break; } // end switch return $uv; } // end get_UVrange function get_SoilMoisture($VPsoilmoisture) { switch (TRUE) { case (($VPsoilmoisture >= 0) and ($VPsoilmoisture < 11)): $sm = '1'; break; case (($VPsoilmoisture >= 11) and ($VPsoilmoisture < 26)): $sm = '2'; break; case (($VPsoilmoisture >= 26) and ($VPsoilmoisture < 61)): $sm = '3'; break; case (($VPsoilmoisture >= 61) and ($VPsoilmoisture < 101)): $sm = '4'; break; case (($VPsoilmoisture >= 101) and ($VPsoilmoisture < 201)): $sm = '5'; break; case ($VPsoilmoisture > 200): $sm = '6'; break; $sm = '7'; } // end switch return $sm; } // end get_SoilMoisture function get_SoilTemperature($st) { global $uomTemp; $um = substr($uomTemp, -1); $soiltemp = strip_units($st); // convert soiltemp to numbers only switch (TRUE) { case ((($um == 'F') and ($soiltemp < 20)) or (($um == 'C') and ($soiltemp < -6.7))): $gi = '1'; break; case ((($um == 'F') and (($soiltemp >= 20) and ($soiltemp < 33))) or (($um == 'C') and (($soiltemp >= -6.7) and ($soiltemp < .6)))): $gi = '2'; break; case ((($um == 'F') and (($soiltemp >= 33) and ($soiltemp < 50))) or (($um == 'C') and (($soiltemp >= .6) and ($soiltemp < 10)))): $gi = '3'; break; case ((($um == 'F') and (($soiltemp >= 50) and ($soiltemp < 60))) or (($um == 'C') and (($soiltemp >= 10) and ($soiltemp < 15.5)))): $gi = '4'; break; case ((($um == 'F') and (($soiltemp >= 60) and ($soiltemp < 70))) or (($um == 'C') and (($soiltemp >= 15.5) and ($soiltemp < 21.1)))): $gi = '5'; break; case ((($um == 'F') and (($soiltemp >= 70) and ($soiltemp < 120))) or (($um == 'C') and (($soiltemp >= 21.1) and ($soiltemp < 48.)))): $gi = '6'; break; default: $gi = '0'; break; } // end switch return $gi; } // end get_SoilTemperature //========================================================================= // change the hh:mm AM/PM to h:mmam/pm format function fixup_time($WDtime) { global $timeOnlyFormat, $DebugMode; if ($WDtime == "00:00: AM") { return ''; } $t = explode(':', $WDtime); if (preg_match('/p/i', $WDtime)) { $t[0] = $t[0] + 12; } if ($t[0] > 23) { $t[0] = 12; } if (preg_match('/^12.*a/i', $WDtime)) { $t[0] = 0; } $t2 = join(':', $t); // put time back to gether; $t2 = preg_replace('/[^\d\:]/is', '', $t2); // strip out the am/pm if any $r = date($timeOnlyFormat, strtotime($t2)); if ($DebugMode) { $r = "" . $r; $r = '' . $r . ''; } return ($r); } //========================================================================= // adjust WD date to desired format // function fixup_date($WDdate) { global $timeFormat, $timeOnlyFormat, $dateOnlyFormat, $WDdateMDY, $DebugMode; $d = explode('/', $WDdate); // expect ##/##/## form if (!isset($d[2])) { $d = explode('-', $WDdate); } // try ##-##-#### form instead if (!isset($d[2])) { $d = explode('.', $WDdate); } // try ##.##.#### form instead if ($d[2] > 70 and $d[2] <= 99) { $d[2] += 1900; } // 2 digit dates 70-99 are 1970-1999 if ($d[2] < 99) { $d[2] += 2000; } // 2 digit dates (left) are assumed 20xx dates. if ($WDdateMDY) { $new = sprintf('%04d-%02d-%02d', $d[2], $d[0], $d[1]); // M/D/YYYY -> YYYY-MM-DD } else { $new = sprintf('%04d-%02d-%02d', $d[2], $d[1], $d[0]); // D/M/YYYY -> YYYY-MM-DD } $r = date($dateOnlyFormat, strtotime($new)); if ($DebugMode) { $r = "" . $r; $r = '' . $r . ''; } return ($r); } //========================================================================= // strip trailing units from a measurement // i.e. '30.01 in. Hg' becomes '30.01' function strip_units($data) { preg_match('/([\d\,\.\+\-]+)/', $data, $t); return $t[1]; } //========================================================================= // decode WD %moonage% tag and return a text description for the moon phase name // "Moon age: 10 days,10 hours,41 minutes,80%" function moonphase($WDmoonage) { preg_match_all('|(\d+)|is', $WDmoonage, $matches); // print "\n"; $mdays = $matches[1][0]; $mhours = $matches[1][1]; $mmins = $matches[1][2]; $mpct = $matches[1][3]; $mdaysd = $mdays + ($mhours / 24) + ($mmins / 1440); // Definitions from https://www.answers.com/topic/lunar-phase // * Dark Moon - Not visible // * New Moon - Not visible, or traditionally, the first visible crescent of the Moon // * Waxing Crescent Moon - Right 1-49% visible // * First Quarter Moon - Right 50% visible // * Waxing gibbous Moon - Right 51-99% visible // * Full Moon - Fully visible // * Waning gibbous Moon - Left 51-99% visible // * Third Quarter Moon - Left 50% visible // * Waning Crescent Moon - Left 1-49% visible // * New Moon - Not visible if ($mdaysd <= 29.53 / 2) { // increasing illumination $ph = "Waxing"; $qtr = "First"; } else { // decreasing illumination $ph = "Waning"; $qtr = "Last"; } if ($mpct < 1) { return("New Moon"); } if ($mpct <= 49) { return("$ph Crescent"); } if ($mpct < 51) { return("$qtr Quarter"); } if ($mpct < 99) { return("$ph Gibbous"); } return("Full Moon"); } //========================================================================= // pick the NOAA style condition icon based on iconnumber function newIcon($numb) { global $condIconDir, $condIconType; $iconList = array( "skc.png", // 0 imagesunny.visible "nskc.png", // 1 imageclearnight.visible "bkn.png", // 2 imagecloudy.visible "sct.png", // 3 imagecloudy2.visible "nbkn.png", // 4 imagecloudynight.visible "sct.png", // 5 imagedry.visible "fg.png", // 6 imagefog.visible "hazy.png", // 7 imagehaze.visible "ra.png", // 8 imageheavyrain.visible "few.png", // 9 imagemainlyfine.visible "mist.png", // 10 imagemist.visible "nfg.png", // 11 imagenightfog.visible "nra.png", // 12 imagenightheavyrain.visible "novc.png", // 13 imagenightovercast.visible "nra.png", // 14 imagenightrain.visible "nshra.png", // 15 imagenightshowers.visible "nsn.png", // 16 imagenightsnow.visible "ntsra.png", // 17 imagenightthunder.visible "ovc.png", // 18 imageovercast.visible "sct.png", // 19 imagepartlycloudy.visible "ra.png", // 20 imagerain.visible "ra.png", // 21 imagerain2.visible "shra.png", // 22 imageshowers2.visible "ip.png", // 23 imagesleet.visible "ip.png", // 24 imagesleetshowers.visible "sn.png", // 25 imagesnow.visible "sn.png", // 26 imagesnowmelt.visible "sn.png", // 27 imagesnowshowers2.visible "skc.png", // 28 imagesunny.visible "scttsra.png", // 29 imagethundershowers.visible "hi_tsra.png", // 30 imagethundershowers2.visible "tsra.png", // 31 imagethunderstorms.visible "nsvrtsra.png", // 32 imagetornado.visible "wind.png", // 33 imagewindy.visible "ra1.png", // 34 stopped rainning "windyrain.png" // 35 windy/rain ); $tempicon = $iconList[$numb]; if ($condIconType <> '.png') { $tempicon = preg_replace('|\.png|', $condIconType, $tempicon); } return($tempicon); } // Function to process %Currentsolarcondition% string and // remove duplicate stuff, then fix capitalization, and translate from English if needed // function fixupCondition($inCond) { global $DebugMode; $Cond = str_replace('_', ' ', $inCond); $Cond = strtolower($Cond); $Cond = preg_replace('| -|', '', $Cond); $Cond = trim($Cond); $dt = ''; $vals = array(); if (strpos($Cond, '/') !== false) { $dt .= "\n"; $vals = explode("/", $Cond); } if (strpos($Cond, ',') !== false) { $dt .= "\n"; $vals = explode(",", $Cond); } $ocnt = count($vals); if ($ocnt < 1) { $inCond = (langtransstr(trim($inCond))); $inCond = preg_replace('|/$|', '', $inCond); return $inCond; } foreach ($vals as $k => $v) { if ($DebugMode) { $dt .= "\n"; } $v = ucfirst(strtolower(trim($v))); $vals[$k] = langtransstr($v); if ($DebugMode) { $dt .= "\n"; } } if ($vals[0] == '') { $junk = array_shift($vals); } if (isset($vals[2]) and $vals[0] == $vals[2]) { $junk = array_pop($vals); } reset($vals); $t = join(', ', $vals); // return($Cond . "' orig=$ocnt n=" . count($vals) ." t='$t'"); if ($DebugMode) { $t = "" . $dt . $t; } $t = (langtransstr($t)); $t = preg_replace('|/$|', '', $t); return $t; } // ----------------------------------------------------------------------------- // MOON FUNTIONS . // ----------------------------------------------------------------------------- function getMoonInfo($hh = 0, $mm = 0, $ss = 0, $MM = 0, $DD = 0, $YY = 0) { // very crude way of determining moon phase (but very accurate) // ------------- start of USNO moon data ----------------------------- // PHP tables generated from USNO moon ephemeris data https://api.usno.navy.mil/moon/phase?date=1/1/yyyy&nump=60 // for years 2009 to 2030 // Ken True - Saratoga-weather.org generated by get-USNO-moonphases.php - Version 2.01 - 19-Apr-2019 on 19 April 2019 09:31 PDT $newMoons = array(// unixtime values in UTC/GMT /* 2009 */ /* 26-Jan-2009 07:55 */ 1232956500, 1235525700, 1238083560, 1240629780, 1243167060, 1245699300, 1248230100, 1250762520, 1253299440, 1255843980, 1258398840, 1260964920, /* 2010 */ /* 15-Jan-2010 07:11 */ 1263539460, 1266115860, 1268686860, 1271248140, 1273799040, 1276341300, 1278877200, 1281409680, 1283941800, 1286477040, 1289019120, 1291570560, /* 2011 */ /* 04-Jan-2011 09:03 */ 1294131780, 1296700260, 1299271560, 1301841120, 1304405460, 1306962180, 1309510440, 1312051200, 1314587040, 1317121740, 1319658960, 1322201400, 1324749960, /* 2012 */ /* 23-Jan-2012 07:39 */ 1327304340, 1329863700, 1332427020, 1334992680, 1337557620, 1340118120, 1342671840, 1345218840, 1347761460, 1350302520, 1352844480, 1355388120, /* 2013 */ /* 11-Jan-2013 19:44 */ 1357933440, 1360480800, 1363031460, 1365586500, 1368145680, 1370706960, 1373267640, 1375825860, 1378380960, 1380933240, 1383483000, 1386030120, /* 2014 */ /* 01-Jan-2014 11:14 */ 1388574840, 1391117880, 1393660800, 1396205100, 1398752040, 1401302400, 1403856480, 1406414520, 1408975980, 1411539240, 1414101420, 1416659520, 1419212160, /* 2015 */ /* 20-Jan-2015 13:14 */ 1421759640, 1424303220, 1426844160, 1429383420, 1431922380, 1434463500, 1437009840, 1439563980, 1442126460, 1444694760, 1447264020, 1449829740, /* 2016 */ /* 10-Jan-2016 01:30 */ 1452389400, 1454942340, 1457488440, 1460028240, 1462562940, 1465095600, 1467630060, 1470170640, 1472720580, 1475280660, 1477849080, 1480421880, 1482994380, /* 2017 */ /* 28-Jan-2017 00:07 */ 1485562020, 1488121080, 1490669820, 1493208960, 1495741440, 1498271460, 1500803160, 1503340200, 1505885400, 1508440320, 1511005320, 1513578600, /* 2018 */ /* 17-Jan-2018 02:17 */ 1516155420, 1518728700, 1521292320, 1523843820, 1526384880, 1528918980, 1531450080, 1533981480, 1536516060, 1539056820, 1541606520, 1544167200, /* 2019 */ /* 06-Jan-2019 01:28 */ 1546738080, 1549314240, 1551888240, 1554454200, 1557009900, 1559556120, 1562094960, 1564629120, 1567161420, 1569695160, 1572233880, 1574780760, 1577337180, /* 2020 */ /* 24-Jan-2020 21:42 */ 1579902120, 1582471920, 1585042080, 1587608760, 1590169140, 1592721660, 1595266380, 1597804920, 1600340400, 1602876660, 1605416820, 1607962560, /* 2021 */ /* 13-Jan-2021 05:00 */ 1610514000, 1613070360, 1615630860, 1618194660, 1620759600, 1623322380, 1625879820, 1628430600, 1630975920, 1633518300, 1636060440, 1638603780, /* 2022 */ /* 02-Jan-2022 18:33 */ 1641148380, 1643694360, 1646242500, 1648794240, 1651350480, 1653910200, 1656471120, 1659030900, 1661588220, 1664142840, 1666694940, 1669244220, 1671790620, /* 2023 */ /* 21-Jan-2023 20:53 */ 1674334380, 1676876760, 1679419380, 1681963920, 1684511580, 1687063020, 1689618720, 1692178680, 1694742000, 1697306100, 1699867620, 1702423920, /* 2024 */ /* 11-Jan-2024 11:57 */ 1704974220, 1707519540, 1710061200, 1712600460, 1715138520, 1717677480, 1720220220, 1722769980, 1725328500, 1727894940, 1730465220, 1733034060, 1735597620, /* 2025 */ /* 29-Jan-2025 12:36 */ 1738154160, 1740703500, 1743245880, 1745782260, 1748314920, 1750847460, 1753384260, 1755929160, 1758484440, 1761049500, 1763621220, 1766194980, /* 2026 */ /* 18-Jan-2026 19:52 */ 1768765920, 1771329660, 1773883380, 1776426720, 1778961660, 1781492040, 1784022180, 1786556220, 1789097220, 1791647400, 1794207720, 1796777520, /* 2027 */ /* 07-Jan-2027 20:24 */ 1799353440, 1801929360, 1804498140, 1807055460, 1809601080, 1812138000, 1814670120, 1817201100, 1819734060, 1822271760, 1824816960, 1827372240, 1829938320, /* 2028 */ /* 26-Jan-2028 15:12 */ 1832512320, 1835087820, 1837657860, 1840218420, 1842768960, 1845311220, 1847847720, 1850381040, 1852914240, 1855450620, 1857993480, 1860545160, /* 2029 */ /* 14-Jan-2029 17:24 */ 1863105840, 1865673060, 1868242740, 1870810800, 1873374120, 1875930600, 1878479460, 1881021360, 1883558640, 1886094840, 1888633440, 1891176720, /* 2030 */ /* 04-Jan-2030 02:49 */ 1893725340, 1896278820, 1898836440, 1901397720, 1903961520, 1906525260, 1909085640, 1911640260, 1914188820, 1916733240, 1919276220, 1921819560, 1924363920 ); /* end of newMoons array */ $Q1Moons = array(// unixtime values in UTC/GMT /* 2009 */ /* 02-Feb-2009 23:13 */ 1233616380, 1236152760, 1238682840, 1241210640, 1243740120, 1246274880, 1248818400, 1251373320, 1253940600, 1256517720, 1259098740, 1261676160, /* 2010 */ /* 23-Jan-2010 10:53 */ 1264243980, 1266799320, 1269342000, 1271874000, 1274398980, 1276921740, 1279447800, 1281982440, 1284529800, 1287091620, 1289666340, 1292248740, /* 2011 */ /* 12-Jan-2011 11:31 */ 1294831860, 1297408680, 1299973500, 1302523500, 1305059580, 1307585460, 1310106540, 1312628880, 1315157940, 1317698100, 1320251880, 1322819520, /* 2012 */ /* 01-Jan-2012 06:15 */ 1325398500, 1327983000, 1330564860, 1333136460, 1335693420, 1338236160, 1340767800, 1343292960, 1345816440, 1348342860, 1350876720, 1353421860, 1355980740, /* 2013 */ /* 18-Jan-2013 23:45 */ 1358552700, 1361133060, 1363714020, 1366288260, 1368851640, 1371403440, 1373944680, 1376477760, 1379005680, 1381532520, 1384063020, 1386601920, /* 2014 */ /* 08-Jan-2014 03:39 */ 1389152340, 1391714520, 1394285220, 1396859460, 1399432500, 1402000740, 1404561540, 1407113400, 1409656260, 1412191980, 1414723680, 1417255560, 1419791460, /* 2015 */ /* 27-Jan-2015 04:48 */ 1422334080, 1424884440, 1427442180, 1430006100, 1432574340, 1435143720, 1437710640, 1440271860, 1442825940, 1445373060, 1447914420, 1450451640, /* 2016 */ /* 16-Jan-2016 23:26 */ 1452986760, 1455522360, 1458061380, 1460606340, 1463158920, 1465719000, 1468284720, 1470853260, 1473421740, 1475987580, 1478548260, 1481101380, /* 2017 */ /* 05-Jan-2017 19:47 */ 1483645620, 1486181940, 1488713520, 1491244740, 1493779620, 1496320920, 1498870260, 1501428180, 1503994380, 1506567180, 1509142920, 1511715780, 1514280000, /* 2018 */ /* 24-Jan-2018 22:20 */ 1516832400, 1519373340, 1521905700, 1524433560, 1526960940, 1529491860, 1532029920, 1534578480, 1537139700, 1539712920, 1542293640, 1544874540, /* 2019 */ /* 14-Jan-2019 06:45 */ 1547448300, 1550010360, 1552559220, 1555095960, 1557623520, 1560146340, 1562669700, 1565199060, 1567739400, 1570294020, 1572862980, 1575442680, /* 2020 */ /* 03-Jan-2020 04:45 */ 1578026700, 1580607720, 1583179020, 1585736460, 1588279080, 1590809400, 1593332160, 1595853120, 1598378280, 1600912500, 1603459380, 1606020300, 1608594060, /* 2021 */ /* 20-Jan-2021 21:01 */ 1611176460, 1613760420, 1616337600, 1618901940, 1621451580, 1623988440, 1626516660, 1629040740, 1631565540, 1634095500, 1636634760, 1639186500, /* 2022 */ /* 09-Jan-2022 18:11 */ 1641751860, 1644328200, 1646909100, 1649486880, 1652055660, 1654613280, 1657160040, 1659697560, 1662228480, 1664756040, 1667284620, 1669818960, 1672363200, /* 2023 */ /* 28-Jan-2023 15:19 */ 1674919140, 1677485160, 1680057120, 1682630400, 1685200920, 1687765800, 1690322820, 1692871020, 1695411120, 1697945340, 1700477400, 1703011140, /* 2024 */ /* 18-Jan-2024 03:52 */ 1705549920, 1708095660, 1710648660, 1713208380, 1715773680, 1718342280, 1720910940, 1723475940, 1726034700, 1728586500, 1731131700, 1733671560, /* 2025 */ /* 06-Jan-2025 23:56 */ 1736207760, 1738742520, 1741278660, 1743819300, 1746366720, 1748922060, 1751484600, 1754052060, 1756621500, 1759190040, 1761754860, 1764313140, 1766862600, /* 2026 */ /* 26-Jan-2026 04:47 */ 1769402820, 1771936020, 1774466280, 1776997920, 1779534660, 1782078900, 1784631900, 1787193960, 1789764240, 1792339920, 1794916080, 1797486120, /* 2027 */ /* 15-Jan-2027 20:34 */ 1800045240, 1802591880, 1805127900, 1807656960, 1810183440, 1812711360, 1815244740, 1817787240, 1820341860, 1822909620, 1825488000, 1828070520, /* 2028 */ /* 05-Jan-2028 01:40 */ 1830649200, 1833217800, 1835773320, 1838315700, 1840847160, 1843371360, 1845893400, 1848418800, 1850952960, 1853500200, 1856062380, 1858637640, 1861220700, /* 2029 */ /* 22-Jan-2029 19:23 */ 1863804180, 1866381000, 1868945580, 1871495400, 1874031360, 1876557240, 1879078440, 1881600900, 1884130140, 1886670540, 1889224500, 1891792140, /* 2030 */ /* 11-Jan-2030 14:06 */ 1894370760, 1896954540, 1899535620, 1902106620, 1904663460, 1907206560, 1909738920, 1912264980, 1914789300, 1917316560, 1919850960, 1922396220, 1924954560 ); /* end of Q1Moons array */ $fullMoons = array(// unixtime values in UTC/GMT /* 2009 */ /* 09-Feb-2009 14:49 */ 1234190940, 1236739080, 1239288960, 1241841660, 1244398320, 1246958460, 1249520100, 1252080180, 1254636600, 1257189240, 1259739000, 1262286780, /* 2010 */ /* 30-Jan-2010 06:18 */ 1264832280, 1267375080, 1269915900, 1272457080, 1275001620, 1277551800, 1280108220, 1282669500, 1285233420, 1287797760, 1290360420, 1292919180, /* 2011 */ /* 19-Jan-2011 21:21 */ 1295472060, 1298018160, 1300558200, 1303094640, 1305630540, 1308168840, 1310712000, 1313261820, 1315819620, 1318385160, 1320956160, 1323527760, /* 2012 */ /* 09-Jan-2012 07:30 */ 1326094200, 1328651640, 1331199540, 1333739940, 1336275300, 1338808320, 1341341520, 1343878020, 1346421480, 1348975140, 1351540140, 1354113960, 1356690060, /* 2013 */ /* 27-Jan-2013 04:38 */ 1359261480, 1361823960, 1364376420, 1366919820, 1369455900, 1371987120, 1374516900, 1377049500, 1379589180, 1382139480, 1384701360, 1387272480, /* 2014 */ /* 16-Jan-2014 04:52 */ 1389847920, 1392421980, 1394989680, 1397547720, 1400094960, 1402632660, 1405164300, 1407694140, 1410226680, 1412765460, 1415312580, 1417868820, /* 2015 */ /* 05-Jan-2015 04:53 */ 1420433580, 1423004940, 1425578700, 1428149100, 1430710920, 1433261940, 1435803600, 1438339380, 1440873300, 1443408600, 1445947500, 1448491440, 1451041860, /* 2016 */ /* 24-Jan-2016 01:46 */ 1453599960, 1456165200, 1458734460, 1461302640, 1463865240, 1466420520, 1468968960, 1471512360, 1474052700, 1476591780, 1479131520, 1481673900, /* 2017 */ /* 12-Jan-2017 11:34 */ 1484220840, 1486773180, 1489330440, 1491890880, 1494452520, 1497013800, 1499573220, 1502129460, 1504681380, 1507228800, 1509772980, 1512316020, /* 2018 */ /* 02-Jan-2018 02:24 */ 1514859840, 1517405220, 1519951860, 1522499820, 1525049880, 1527603540, 1530161580, 1532722800, 1535284560, 1537843920, 1540399500, 1542951540, 1545500940, /* 2019 */ /* 21-Jan-2019 05:16 */ 1548047760, 1550591580, 1553132580, 1555672320, 1558213860, 1560760260, 1563313080, 1565872140, 1568435580, 1571000880, 1573565640, 1576127520, /* 2020 */ /* 10-Jan-2020 19:21 */ 1578684060, 1581233580, 1583776080, 1586313300, 1588848300, 1591384320, 1593924240, 1596470340, 1599024120, 1601586300, 1604155740, 1606728600, 1609298880, /* 2021 */ /* 28-Jan-2021 19:16 */ 1611861360, 1614413820, 1616957280, 1619494260, 1622027640, 1624560000, 1627094220, 1629633720, 1632182100, 1634741820, 1637312220, 1639888500, /* 2022 */ /* 17-Jan-2022 23:48 */ 1642463280, 1645030560, 1647587820, 1650135300, 1652674440, 1655207520, 1657737480, 1660268160, 1662803940, 1665348900, 1667905320, 1670472480, /* 2023 */ /* 06-Jan-2023 23:08 */ 1673046480, 1675621680, 1678192800, 1680755640, 1683308040, 1685850120, 1688384340, 1690914720, 1693445700, 1695981420, 1698524640, 1701076560, 1703637180, /* 2024 */ /* 25-Jan-2024 17:54 */ 1706205240, 1708777800, 1711350000, 1713916140, 1716472380, 1719018480, 1721557020, 1724091960, 1726626840, 1729164360, 1731706080, 1734253320, /* 2025 */ /* 13-Jan-2025 22:27 */ 1736807220, 1739368380, 1741935300, 1744503720, 1747068960, 1749627840, 1752179820, 1754726100, 1757268540, 1759808820, 1762348740, 1764890040, /* 2026 */ /* 03-Jan-2026 10:03 */ 1767434580, 1769983740, 1772537880, 1775095920, 1777656180, 1780217100, 1782777360, 1785335760, 1787890680, 1790441340, 1792987920, 1795531980, 1798075680, /* 2027 */ /* 22-Jan-2027 12:17 */ 1800620220, 1803165780, 1805712240, 1808260020, 1810810740, 1813365840, 1815925500, 1818487740, 1821049380, 1823608020, 1826162760, 1828714140, /* 2028 */ /* 12-Jan-2028 04:03 */ 1831262580, 1833807840, 1836349560, 1838888760, 1841428140, 1843970940, 1846519860, 1849075800, 1851637620, 1854203100, 1856769420, 1859334000, 1861894080, /* 2029 */ /* 30-Jan-2029 06:03 */ 1864447380, 1866993000, 1869531960, 1872067020, 1874601420, 1877138520, 1879680960, 1882230660, 1884788940, 1887355620, 1889928180, 1892501160, /* 2030 */ /* 19-Jan-2030 15:54 */ 1895068440, 1897626000, 1900173360, 1902712800, 1905247140, 1907779260, 1910311920, 1912848240, 1915391880, 1917946020, 1920511800, 1923086400 ); /* end of fullMoons array */ $Q3Moons = array(// unixtime values in UTC/GMT /* 2009 */ /* 16-Feb-2009 21:37 */ 1234820220, 1237398420, 1239975360, 1242545160, 1245104100, 1247651580, 1250189700, 1252721760, 1255251360, 1257782160, 1260317580, /* 2010 */ /* 07-Jan-2010 10:39 */ 1262860740, 1265413680, 1267976520, 1270546620, 1273119300, 1275689580, 1278254100, 1280811540, 1283361720, 1285905120, 1288442760, 1290976560, 1293509880, /* 2011 */ /* 26-Jan-2011 12:57 */ 1296046620, 1298589960, 1301141220, 1303699620, 1306263120, 1308829680, 1311397320, 1313963640, 1316525940, 1319081400, 1321628940, 1324169280, /* 2012 */ /* 16-Jan-2012 09:08 */ 1326704880, 1329239040, 1331774700, 1334314200, 1336859220, 1339411260, 1341971280, 1344538500, 1347110100, 1349681580, 1352248560, 1354807860, /* 2013 */ /* 05-Jan-2013 03:58 */ 1357358280, 1359899760, 1362433980, 1364963820, 1367493240, 1370026680, 1372567980, 1375119780, 1377682500, 1380254100, 1382830800, 1385407680, 1387979280, /* 2014 */ /* 24-Jan-2014 05:19 */ 1390540740, 1393089300, 1395625560, 1398153120, 1400677140, 1403203140, 1405735680, 1408278360, 1410833100, 1413400320, 1415978100, 1418561460, /* 2015 */ /* 13-Jan-2015 09:46 */ 1421142360, 1423713000, 1426268880, 1428810240, 1431340560, 1433864520, 1436387040, 1438912980, 1441446840, 1443992760, 1446553440, 1449128400, /* 2016 */ /* 02-Jan-2016 05:30 */ 1451712600, 1454297280, 1456873860, 1459437420, 1461986940, 1464523920, 1467051540, 1469574000, 1472096460, 1474624560, 1477163640, 1479717180, 1482285360, /* 2017 */ /* 19-Jan-2017 22:13 */ 1484863980, 1487446380, 1490025480, 1492595820, 1495153980, 1497699180, 1500233160, 1502759700, 1505283900, 1507811100, 1510346160, 1512892260, /* 2018 */ /* 08-Jan-2018 22:25 */ 1515450300, 1518018840, 1520594400, 1523171820, 1525745340, 1528309920, 1530863460, 1533406680, 1535942220, 1538473500, 1541004000, 1543537140, 1546076040, /* 2019 */ /* 27-Jan-2019 21:10 */ 1548623400, 1551180480, 1553746200, 1556317080, 1558888440, 1561455960, 1564017480, 1566572160, 1569120060, 1571661540, 1574197860, 1576731420, /* 2020 */ /* 17-Jan-2020 12:58 */ 1579265880, 1581805020, 1584351240, 1586904960, 1589464980, 1592029440, 1594596540, 1597164300, 1599729960, 1602290340, 1604843160, 1607387760, /* 2021 */ /* 06-Jan-2021 09:37 */ 1609925820, 1612460220, 1614994200, 1617530520, 1620071400, 1622618640, 1625173860, 1627737360, 1630307580, 1632880620, 1635451500, 1638016080, 1640571840, /* 2022 */ /* 25-Jan-2022 13:41 */ 1643118060, 1645655520, 1648186620, 1650714960, 1653244980, 1655781060, 1658326740, 1660883760, 1663451520, 1666026900, 1668605220, 1671180960, /* 2023 */ /* 15-Jan-2023 02:10 */ 1673748600, 1676304060, 1678846080, 1681377060, 1683901680, 1686425460, 1688953680, 1691490480, 1694038860, 1696600080, 1699173420, 1701755340, /* 2024 */ /* 04-Jan-2024 03:30 */ 1704339000, 1706915880, 1709479380, 1712027700, 1714562820, 1717089180, 1719611580, 1722135060, 1724664360, 1727203800, 1729756980, 1732325280, 1734905880, /* 2025 */ /* 21-Jan-2025 20:31 */ 1737491460, 1740072720, 1742642940, 1745199300, 1747742340, 1750274340, 1752799080, 1755321120, 1757845980, 1760379180, 1762925280, 1765486320, /* 2026 */ /* 10-Jan-2026 15:48 */ 1768060080, 1770640980, 1773221880, 1775796660, 1778361000, 1780912800, 1783452540, 1785982860, 1788508260, 1791033900, 1793564880, 1796105280, 1798657140, /* 2027 */ /* 29-Jan-2027 10:55 */ 1801220100, 1803791760, 1806368040, 1808943480, 1811512680, 1814072040, 1816620900, 1819160820, 1821694800, 1824226140, 1826758080, 1829293860, /* 2028 */ /* 18-Jan-2028 19:26 */ 1831836360, 1834387680, 1836948180, 1839515820, 1842086580, 1844656020, 1847220960, 1849779900, 1852332360, 1854878220, 1857417960, 1859953140, /* 2029 */ /* 07-Jan-2029 13:26 */ 1862486760, 1865022720, 1867564260, 1870113060, 1872668880, 1875230340, 1877795820, 1880363700, 1882931580, 1885496220, 1888054320, 1890604080, 1893145740, /* 2030 */ /* 26-Jan-2030 18:14 */ 1895681640, 1898215080, 1900749060, 1903286340, 1905829020, 1908379140, 1910938020, 1913505300, 1916078160, 1918651800, 1921221120, 1923782460 ); /* end of Q3Moons array */ // ------------- end of USNO moon data ----------------------------- if ($hh==0) $hh=idate("H"); if ($mm==0) $mm=idate("i"); if ($ss==0) $ss=idate("s"); if ($MM==0) $MM=idate("m"); if ($DD==0) $DD=idate("d"); if ($YY==0) $YY=idate("Y"); $date = mktime($hh, $mm, $ss, $MM, $DD, $YY); // Unix date from local time @$info->date = $date; $info->datetxt = gmdate('D, d-M-Y H:i T',$date); if ($date < $newMoons[1]) { $info->error = "Date must be after " .date("r",$newMoons[1]); return $info; } if ($date > $newMoons[count($newMoons)-1]) { $info->error = "Date must be before ".date("r",$newMoons[count($newMoons)-1]); return $info; } foreach ($newMoons as $mi=>$newMoon) { // find next New Moon from given date if ($newMoon>$date) {break;} } // Get Moon dates $NM = $newMoons [$mi - 1]; // previous new moon $Q1 = $Q1Moons [$mi - 1]; // 1st Q end $Q2 = $fullMoons[$mi-1]; // 2nd Q end - Full moon $Q3 = $Q3Moons [$mi - 1]; // 3rd Q end $Q4 = $newMoons [$mi]; // 4th Q end - next new moon // Divide each phase into 7 periods (4 phases x 7 = 28 periods) $Q1p = round(($Q1 - $NM) / 7); $Q2p = round(($Q2 - $Q1) / 7); $Q3p = round(($Q3 - $Q2) / 7); $Q4p = round(($Q4 - $Q3) / 7); // Determine start and end times for major phases (lasting 1 period of 28) $NMe = $NM + ($Q1p / 2); // 0% .... - New moon $Q1s = $Q1-($Q1p/2); $Q1e = $Q1+($Q2p/2); // 50% 1stQ - First Quarter $Q2s = $Q2-($Q2p/2); $Q2e = $Q2+($Q3p/2); //100% 2ndQ - Full moon $Q3s = $Q3-($Q3p/2); $Q3e = $Q3+($Q4p/2); // 50% 3rdQ - Last Quarter $NMs = $Q4 - ($Q4p / 2); // 0% 4thQ - New Moon // Determine age of moon in days since last new moon $age = ($date - $newMoons[$mi - 1]) / 86400; // age in days since last new moon $dd = intval($age); $hh = intval(($age - $dd) * 24); $mm = intval(((($age - $dd) * 24) - $hh) * 60); $info->age = $dd . ' days, ' . $hh . ' hours, ' . $mm . ' minutes'; // Illumination switch (true) { // Determine moon age in degrees (0 to 360) case ($date<=$Q1): $ma = ($date - $NM) * (90 / ($Q1 - $NM))+ 0; break; // NM to Q1 case ($date<=$Q2): $ma = ($date - $Q1) * (90 / ($Q2 - $Q1))+ 90; break; // Q1 to FM case ($date<=$Q3): $ma = ($date - $Q2) * (90 / ($Q3 - $Q2))+180; break; // FM to Q3 case ($date<=$Q4): $ma = ($date - $Q3) * (90 / ($Q4 - $Q3))+270; break; // Q3 to NM } $info->ill = abs(round(100 * (1 + cos($ma * (M_PI / 180))) / 2) - 100); // Deterime picture number (0-27) and moon phase switch (true) { case ($date<=$NMe): $pic = 0; $ph = 'New Moon'; break; case ($date< $Q1s): $pic = 1 +(($date-$NMe)/$Q1p); $ph = 'Waxing Crescent'; break; // Waxing Crescent case ($date<=$Q1e): $pic = 7; $ph = 'First Quarter'; break; case ($date< $Q2s): $pic = 7.5+(($date-$Q1e)/$Q2p); $ph = 'Waxing Gibbous'; break; case ($date<=$Q2e): $pic = 14; $ph = 'Full Moon'; break; case ($date< $Q3s): $pic = 14.5+(($date-$Q2e)/$Q3p); $ph = 'Waning Gibbous'; break; case ($date<=$Q3e): $pic = 21; $ph = 'Last Quarter'; break; case ($date< $NMs): $pic = 21.5+(($date-$Q3e)/$Q4p); $ph = 'Waning Crescent'; break; // Waning Crecent default : $pic = 0; $ph = 'New Moon'; } $info->pic = round($pic); $info->phase = $ph; $info->NM = $NM; $info->NMGMT = gmdate('D, d-M-Y H:i T',$NM); $info->NMWD = gmdate('H:i T d F Y',$NM); $info->Q1 = $Q1; $info->Q1GMT = gmdate('D, d-M-Y H:i T',$Q1); $info->Q1WD = gmdate('H:i T d F Y',$Q1); $info->FM = $Q2; $info->FMGMT = gmdate('D, d-M-Y H:i T',$Q2); $info->FMWD = gmdate('H:i T d F Y',$Q2); $info->Q3 = $Q3; $info->Q3GMT = gmdate('D, d-M-Y H:i T',$Q3); $info->Q3WD = gmdate('H:i T d F Y',$Q3); $info->Q4 = $Q4; $info->Q4GMT = gmdate('D, d-M-Y H:i T',$Q4); $info->Q4WD = gmdate('H:i T d F Y',$Q4); $info->FM2 = $fullMoons[$mi]; $info->FM2GMT = gmdate('D, d-M-Y H:i T',$fullMoons[$mi]); $info->FM2WD = gmdate('H:i T d F Y',$fullMoons[$mi]); # tman1991 mods for cell.php add-on $moonD = array($NM , $Q1 , $Q2 , $Q3 , $Q4 , $Q1Moons[$mi] , $fullMoons[$mi], $Q3Moons[$mi] ); $moonP = array("New Moon", "First Quarter", "Full Moon", "Last Quarter", "New Moon", "First Quarter", "Full Moon" , "Last Quarter"); $moonI = array("NM" , "Q1" , "FM" , "Q3" , "NM" , "Q1" , "FM" , "Q3" ); foreach($moonD as $key=>$mdate) { if ($mdate>$date) { $info->moons[] = array ($moonP[$key], $mdate, $moonI[$key], date("r",$mdate)); } } # end tman1991 mods for cell.php add-on return $info; } // The following function are for the TIDE module function next_tide_info($tideinfo, $day) { global $time_offset_next_tide; //$tideinfo = ' High Tide: 2049 6.0'; //make an array out of the string, split on the space char after removing multiple spaces $t_arr = explode(" ", preg_replace('/\s\s+/', ' ', trim($tideinfo))); //print_r ($t_arr); //Array ( [0] => High [1] => Tide: [2] => 2049 [3] => 6.0 ) // now time in seconds $time_now = (time() - ($time_offset_next_tide * (60 * 60))); // get tide time in seconds. $t_hr = substr($t_arr[2], 0, 2); $t_min = substr($t_arr[2], -2); $t_time = strtotime(date("Y-m-d", $time_now + (86400 * $day)) . " $t_hr:$t_min:" . date('s')); // next tide in minutes $t_diff = round(($t_time - $time_now) / 60); $next_t1 = array( "$t_diff" => strtolower($t_arr[0]), ); return $next_t1; } // end function mins_to_next_tide function round_tide_time($mins_to_next_tide) { if ($mins_to_next_tide <= 0) return 0; if ($mins_to_next_tide >= 360) return 360; //echo "mins_to_next_tide: $mins_to_next_tide
"; $mins_to_next_tide = (round($mins_to_next_tide / 15) * 15); return $mins_to_next_tide; } // end function round_tide_time global $nexttidequarter; function select_tide_image($mins_to_next_tide, $high_or_low) { global $nexttidequarter; if ($high_or_low == 'high') $nexttidequarter = "High$mins_to_next_tide"; if ($high_or_low == 'low') $nexttidequarter = "Low$mins_to_next_tide"; if ($mins_to_next_tide <= 0) return $high_or_low . '_0.jpg'; if ($mins_to_next_tide >= 360) return $high_or_low . '_360.jpg'; return $high_or_low . '_' . $mins_to_next_tide . '.jpg'; } // end function select_tide_image function time_till_tide($time) { // takes a time diff like 6740 secs and formats to '1 hour, 52 minutes' $hrs = (int) intval($time / 3600); $time = (int) intval($time - (3600 * $hrs)); $mns = (int) intval($time / 60); $time = (int) intval($time - (60 * $mns)); $secs = (int) intval($time / 1); $hrs == 1 and $string .= "$hrs hour, "; $hrs > 1 and $string .= "$hrs hours, "; $string .= sprintf("%01d minutes", $mns); return $string; } function tide_data($numb) { global $tidefile, $yearDate, $convertRF; $tideD = implode('', file($tidefile)); $time = time(); // Get tide records by date, cut to length and split // If year is included in date if ($yearDate == "yes") { $tidedate = strstr($tideD, date("l Y-m-d", $time + (86400 * $numb))); $tideEnd = strpos($tideD, date("l Y-m-d", $time + (86400 * ($numb + 1)))); } else { $tidedate = strstr($tideD, date("l m-d", $time + (86400 * $numb))); $tideEnd = strpos($tideD, date("l m-d", $time + (86400 * ($numb + 1)))); //$tidedate = strstr($tideD, date("D m-d", $time + (86400 * $numb))); //$tideEnd = strpos($tideD, date("D m-d", $time + (86400 * ($numb + 1)))); } // The last tide will not show because it is not followed by a date. So we will // set the end possition to a fixed leangth if (!$tideEnd == false) { $tide = substr($tidedate, 0, $tideEnd); } else { $tide = substr($tidedate, 0, 280); } // Check if tides are in rising/falling format if (strstr($tide, "Rising")) { $risingFormat = "yes"; //$tide = substr($tidedate, 0, $tideEnd); } $tide = explode("\n", $tide); // Check if sunrise info is included if (strstr($tide[1], "Sunrise")) { $tide = $tide[0] . "|" . $tide[3] . "|" . $tide[4] . "|" . $tide[5] . "|" . $tide[6] . "|" . $tide[7] . "|" . $tide[8] . "|" . $tide[9] . "|" . $tide[10]; $tide = explode("|", $tide); } else { $tide = $tide[0] . "|" . $tide[1] . "|" . $tide[2] . "|" . $tide[3] . "|" . $tide[4] . "|" . $tide[5] . "|" . $tide[6] . "|" . $tide[7] . "|" . $tide[8]; $tide = explode("|", $tide); } return $tide; } // eof minutes to next tide // END OF ALL TIDE FUNCTIONS // ----------------------------------------------------------------------------- // Calculate Local Time from UTC time string // Code by Cienega32 - LasCruces-Weather.com modified by SE Lincoln Weather // ----------------------------------------------------------------------------- function utc_to_local_time($uTCTime) { global $timeOnlyFormat; $localTR = array(); $offset = date_offset_get(new DateTime); // TZ offset $timeArray = explode(' UTC ',$uTCTime); $utcTime= $timeArray[0] . ' ' . $timeArray[1]; // ' UTC' stripped out $timeString = strtotime($utcTime)+$offset; // Convert to local time $localTR[0] = date($timeOnlyFormat.' T',$timeString); // Hour:Min am/pm TZ string $localTR[1] = date('j M Y',$timeString); // dd Mon yyyy string return $localTR; } // end of utc_to_local_time // ----------------------------------------------------------------------------- // The following functions were added by SE Lincoln Weather as part of ajax-dashboard69x // ----------------------------------------------------------------------------- // Keep images fresh // Adds timestamp to image making it unique // ----------------------------------------------------------------------------- /* if (!function_exists('getUniqueImageURL')) { function getUniqueImageURL($image_url){ $timestamp = time(); if(strpos($image_url, '?')){ $image_url = str_replace('?', "?$timestamp&", $image_url); } else{ $image_url .= "?$timestamp"; } return $image_url; } } // end of getUniqueImageURL */ // ----------------------------------------------------------------------------- // CHANGE IN DAYLENGTH FUNCTION: computes length of yesterday, today, & tomorrow // and then the change in day length from yesterday to today // Written by SE Lincoln Weather . // ----------------------------------------------------------------------------- // Alternate $changeinday routine that finds $changeinday2 if (!function_exists('get_changeinday')) { // Avoid fatally re-declaring this!!! function get_changeinday() { $hrsOfSunLight = array(); 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"]; $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 $result = array($changeinday2,$hrsOfSunLight); return $result; } } // end of changeinday() // ============================================================================= // Uncomment the next two functions if you get an error message that says // Fatal error: Call to undefined function langtransstr() // // function langtransstr($str) { // added // return($str); // } // // function langtrans($str) { // added // echo $str; // return; // } // end of functions //========================================================================= ?>