URL (as #...) // Version 1.03 - 03-Jun-2007 - added Wind dir/speed/units to icon image set // Version 1.04 - 27-Jul-2007 - added Beaufort wind scale output // Version 1.05 - 19-Aug-2009 - updated for PHP5 // Version 1.06 - 09-Jul-2010 - added humidex and frost displays // Version 1.07 - 07-Jan-2011 - corrected feed validation issues with the Cold! and Hot! displays in the title // Version 1.08 - 27-Dec-2011 - changed get_lang() calls to PPget_lang() calls // Version 1.09 - 24-Aug-2016 - added code to correct htmlspecialchars() call for some languages // Version 1.10 - 29-Jan-2019 - fixed HTTPS icon usage // $VersionRSS = "plaintext-rss.php Version 1.10 - 29-Jan-2019"; // // error_reporting(E_ALL); // uncomment to turn on full error reporting // // script available at http://saratoga-weather.org/scripts.php // // you may copy/modify/use this script as you see fit, // no warranty is expressed or implied. // // This script uses plaintext-parser.php to parse the plaintext.txt forecast output from WXSIM // (https://www.wxsim.com/) to create a RSS feed of the forecast from WXSIM. // // output: creates RSS 2.0 type feed // more info on RSS 2.0 available at http://cyber.law.harvard.edu/rss/rss.html // // NOTE: This script requires a working copy of plaintext-parser.php to be in the SAME directory // as this script. // // // Options on URL: // lang=en (default) - use English language // lang=ZZ - use 'ZZ' language translation file for conversion from English // note: there must be a plaintext-parser-lang-LL.txt file with the // conversion rules. A sample Dutch file is included (lang=nl). // // Settings --------------------------------------------------------------- // $ourTZ = "PST8PDT"; //NOTE: this *MUST* be set correctly to // translate UTC times to your LOCAL time for the displays. // https://saratoga-weather.org/timezone.txt has the list of timezone names // pick the one that is closest to your location and put in $ourTZ // also available is the list of country codes (helpful to pick your zone // from the timezone.txt table // https://saratoga-weather.org/country-codes.txt : list of country codes $ourLinkPage = '/WXSIM-forecast.php'; // set to your page name to display // // the full forecast using your template $ourEmail = 'webmaster@saratoga-weather.org (Ken True)'; // set to your email address // $absIconDir = '/forecast/images/'; // set to absolute web address of images // without './' or '../' and include // trailing '/' // ---- end of settings --------------------------------------------------- // // -------------------begin code ------------------------------------------ if (isset($_REQUEST['sce']) && strtolower($_REQUEST['sce']) == 'view' ) { //--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; } # Set timezone in PHP5/PHP4 manner if (!function_exists('date_default_timezone_set')) { if (! ini_get('safe_mode') ) { putenv("TZ=$ourTZ"); // set our timezone for 'as of' date on file } # $Status .= "\n"; } else { date_default_timezone_set("$ourTZ"); # $Status .= "\n"; } $GMTtimeFormat = 'D, d M Y H:i:s'; // Fri, 31 Mar 2006 14:03:22 for RSS Feed date/time //setup translation table for our $lang to the official XML languages for the XML //see http://xml.coverpages.org/iso639a.html and http://cyber.law.harvard.edu/rss/languages.html // for a list, If not included in the list, then the lang= ($lang) is used; // $XMLLanguages = array( //see http://xml.coverpages.org/iso639a.html and 'en' => 'en-us', 'dk' => 'da', 'gr' => 'el', 'se' => 'sv'); header("Content-Type: application/rss+xml"); $doPrint = false; require_once("plaintext-parser.php"); // don't change this.. must be in same directory // ----------------------------------------------------------------------------------- // Note: the following code uses variables defined and loaded by plaintext-parser.php // // $XMLlang = $lang; // $lang is from plaintext-parser.php after processing if (isset($XMLLanguages[$lang])) { $XMLlang = $XMLLanguages[$lang]; // for the } // Begin XML generation for RSS feed // note: $useCharSet is from plaintext-parser.php print ' '; print "\n"; print $Status; // print status from plaintext-parser.php comments print "\n"; $urlParts = parse_url($_SERVER['SCRIPT_URI']); $ourBase = $urlParts['scheme'] . '://' . $urlParts['host']; if (($urlParts['scheme'] == 'http' and $_SERVER['SERVER_PORT'] <> '80') or ($urlParts['scheme'] == 'https' and $_SERVER['SERVER_PORT'] <> '443')) { $ourBase .= ':' . $_SERVER['SERVER_PORT']; } if (!isset($PHP_SELF)) {$PHP_SELF = $_SERVER['SCRIPT_NAME']; } // now $ourBase has http://our.server.com // Use forecast date from WXSIM output (parsed by plaintext-parser.php) // as the timestamp for pubDate, lastBuildDate XML items // (note the $wDay, $wMon, $wYear, $wTime vars are set by plaintext-parser.php) $wdate = "$wDay-$wMon-$wYear $wTime:00 " . date('O',time()); $d = strtotime($wdate); $TStamp = gmdate($GMTtimeFormat,$d) . ' GMT'; $YEAR = date('Y',$d); $ISOdate = gmdate('Ymd',$d) . 'Z' . gmdate('Hi',$d); $GUID = 'fcst/' . gmdate('Ymd/Hi',$d) . '/N'; // Print the Channel parts of the RSS feed // print ' ' . PPget_lang("WXSIM Forecast for:") . " $WXSIMcity" . ' http://' . $_SERVER['SERVER_NAME'] . $ourLinkPage . ' ' . PPget_lang("Issued by:") . " $WXSIMstation. " . PPget_lang("Updated:") . " $WXSIMupdated" . ' '. $XMLlang .' ' . $ourEmail . ' ' . $VersionRSS . ' Copyright' . " $YEAR $WXSIMstation" . ' ' . $TStamp . ' 15 ' . $TStamp . ''; //generate the details for each forecast period as an for ($i=0;$i]+>|Uis','',$WXSIMtemp[$i]); // remove html from Temp. $temperature = preg_replace('|°|','',$temperature); // Feeds can't have html in title $day = preg_replace('| |Uis',' ',$WXSIMday[$i]); // strip out non valid stuff if ($WXSIMhumidex[$i] <> '') { $temperature .= ', '.PPget_lang('Humidex').': '.$WXSIMhumidex[$i]; } if ($WXSIMfrost[$i] <> '') { $temperature .= ', '.$WXSIMfrost[$i]; } if ($WXSIMuv[$i] <> '') { $temperature .= ', UV: ' . $WXSIMuv[$i]; } $detail = '
' . str_replace($iconDir,$ourBase . $absIconDir,$WXSIMicons[$i]) . '
' . str_replace($iconDir,$ourBase . $absIconDir,$WXSIMtemp[$i]) ; if ($WXSIMhumidex[$i] <> '') { $detail .= '
'.PPget_lang('Humidex').': '.$WXSIMhumidex[$i]; } if ($WXSIMfrost[$i] <> '') { $detail .= '
'.$WXSIMfrost[$i]; } if ($WXSIMprecip[$i] <> '') { $detail .= '
' . "$WXSIMprecip[$i]" ; } $detail .= '
' . $WXSIMwinddir[$i] . " " . $WXSIMwind[$i] . " " . $WXSIMwindunits[$i] ; if ($showBeaufort) { $detail .= '
' . $WXSIMBeaufort[$i] . '' ; } $detail .= '
' . PPset_UV_string($WXSIMuv[$i]) . '
' . $WXSIMtext[$i] . '
'; $tcond = strip_tags(preg_replace('|
|i',', ',$WXSIMcond[$i])); print ' '. strip_tags($day . ', ' . $tcond . ', ' . $temperature) .' http://' . $_SERVER['SERVER_NAME'] . $ourLinkPage . '#D' . $ISOdate . 'N' . $i . ' ' . $TStamp . ' ' . $GUID . $i . ' ' . @htmlspecialchars($detail, ENT_IGNORE ,strtoupper($useCharSet)) .' '; } // end of generation // finish the feed.. close the XML. print '
'; ?>