and from output // heading=n - (default)='y' suppress printing of heading (forecast city/by/date) // icons=n - (default)='y' suppress printing of the icons+conditions+temp+wind+UV // text=n - (default)='y' suppress printing of the periods/forecast text // // // You can also invoke these options directly in the PHP like this // // $doInclude = true; // include("plaintext-parser.php"); for just the text // or ------------ // $doPrint = false; // include("plaintext-parser.php"); for setting up the $WXSIM... variables without printing // // or ------------ // $doInclude = true; // $doPrintHeading = true; // $doPrintIcons = true; // $doPrintText = false // include("plaintext-parser.php"); include mode, print only heading and icon set // // Variables returned (useful for printing an icon or forecast or two...) // // $WXSIMcity - Name of city from WXSIM Forecast header // $WXSIMstation - (in settings below) Name of forecaster or weather station // $WXSIMupdated - Time of forecast from WXSIM Forecast header // // The following variables exist for $i=0 to $i= number of forecast periods minus 1 // a loop of for ($i=0;$i and Short legend. // the following were added in V1.03: // $WXSIMwinddir[$i]- Wind direction ( may be something like 'SSE' or 'NW->N' ) (translated) // $WXSIMwind[$i] - Wind speed (may be something like '10' or '7->4' or '10-16->6' ) // $WXSIMgust[$i] - Wind gust // $WXSIMwindunits[$i] - Wind speed units (mph, kph, mps, kts) (translated) // $WXSIMBeaufort[$i] - Beaufort scale for max wind speed 'n Bft' or 'Light air' (translated) // $WXSIMhumidex[$i] - humidex number (or '' if not present in forecast) // $WXSIMfrost[$i] - frost forecast (or '' if not present in forecast) // $WXSIMheatidx[$i] - heat-index forecast (or '' if not present in forecast) // $WXSIMwindchill[$i] - wind-chill forecast (or '' if not present in forecast) // Note: // // Settings --------------------------------------------------------------- #$iconDir ='./forecast/images/'; // directory for carterlake icons $iconDir =''; $iconType = '.gif'; // default type='.jpg' -- use '.gif' for animated icons from http://www.meteotreviglio.com/ $WXSIMstation = "Saratoga-Weather.org"; // name of your weather station #$plaintextFile = './plaintext.txt'; // location of the WXSIM plaintext.txt $plaintextFile = '../plaintext.txt'; $plaintextFile = $plaintext; // added to have file located outside root #$lang = 'en'; // default language is 'en' = English $lang = 'nl'; #$tempDegrees = '°'; // set to '' to omit degree sign $tempDegrees = ''; // // or set to '°', '°F' or '°C' $maxIcons = 6; // set to maximum number of icons to display $maxWidth = '640px'; // max width of tables (could be '100%') $minPoP = '40'; // PoP must be this or above to display // // rain icon, otherwise sky icon w/PoP displayed. $showBeaufort = 'T'; // set to false to not display Beaufort at all // // ='V' for 'n Bft', ='T' for translated name $showHumidex = true; // =true to display Humidex (Hdx), =false to suppress display $showFrost = true; // =true to display frost, =false to suppress display $showHeatIDX = true; // =true to display Heat-Index (HI), =false to suppress display $showHotIconF = 100; // show Hot icon if Heat-Index >= value $showHotIconC = 37.7; // show Hot icon if Humidex >= value // $showWindChill = true; // =true to display Wind-Chill, =false to suppress display $showColdvalF = 26; // show Cold! if Wind-Chill <= value in F $showColdvalC = -3; // show Cold! if Wind-Chill <= value in C $uomTemp = 'C'; // ='C' if forecast temperature in Centigrade, ='F' if in Fahrenheit $ourTZ = 'America/Los_Angeles'; // your timezone // ---- end of settings --------------------------------------------------- // // overrides from Settings.php if available global $SITE; if (isset($SITE['fcsticonsdir'])) {$iconDir = $SITE['fcsticonsdir'];} if (isset($SITE['fcsticonstype'])) {$iconType = $SITE['fcsticonstype'];} if (isset($SITE['lang'])) {$lang = $SITE['lang'];} if (isset($SITE['uomTemp'])) {$uomTemp = $SITE['uomTemp'];} if (isset($SITE['tz'])) {$ourTZ = $SITE['tz'];} // end of overrides from Settings.php // // -------------------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')) { putenv("TZ=" . $ourTZ); } else { date_default_timezone_set("$ourTZ"); } $Status = "\n"; $doTranslate = true; if (isset($_REQUEST['lang']) ) { $lang=strtolower($_REQUEST['lang']); // if ($lang == 'en') { $doTranslate = false; }; } global $doDebug; $doDebug = false; if (isset($_REQUEST['debug']) ) { $doDebug = substr(strtolower($_REQUEST['debug']),0,1) == 'y'; } $printHeading = true; $printIcons = true; $printText = true; if (isset($doPrintHeading)) { $printHeading = $doPrintHeading; } if (isset($_REQUEST['heading']) ) { $printHeading = substr(strtolower($_REQUEST['heading']),0,1) == 'y'; } if (isset($doPrintIcons)) { $printIcons = $doPrintIcons; } if (isset($_REQUEST['icons']) ) { $printIcons = substr(strtolower($_REQUEST['icons']),0,1) == 'y'; } if (isset($doPrintText)) { $printText = $doPrintText; } if (isset($_REQUEST['text']) ) { $printText = substr(strtolower($_REQUEST['text']),0,1) == 'y'; } if (isset($showIconsMax)) { $maxIcons = $showIconsMax; } if (isset($_REQUEST['maxicons']) ) { $maxIcons = $_REQUEST['maxicons']; $maxIcons = preg_replace('|[^\d]+|is','',$maxIcons); } $useCharSet = 'iso-8859-1'; $UTFLang = ',gr,ru,cn,jp,he,'; // languages needing UTF-8 character set for display $RTLlangs = ',he,cn,jp,'; // languages needing right-to-left display $doRTL = (strpos($RTLlangs,$lang) !== false)?true:false; $timeFormat = 'd-M-Y h:i a'; // default to USA format // load the config file #$config = file("./plaintext-parser-data.txt"); // $config = file($scriptFolder."plaintext-parser-data.txt"); // // load and merge the language file (if it exists) #if ($doTranslate and file_exists("./plaintext-parser-lang-$lang.txt") ) { if ($doTranslate and file_exists($scriptFolder."plaintext-parser-lang-$lang.txt") ) { # $lfile = file("./plaintext-parser-lang-$lang.txt"); $lfile = file($scriptFolder."plaintext-parser-lang-$lang.txt"); foreach ($lfile as $val) { array_push($config,$val); } $Status .= "\n"; if (strpos($UTFLang,$lang) > 0) {$useCharSet = 'UTF-8'; $Status .= "\n";} } else { $doTranslate = false; // if($lang <> 'en') { $Status .= "\n"; $lang = 'en'; // } } $showColdVal = preg_match('|C|i',$uomTemp)?$showColdvalC:$showColdvalF; $Status .= "\n"; // Initialize -- read in control file and place in $Conditions and $Precip // for later use $LanguageLookup = array(); $WindLookup = array( // initialized by wind-direction abbreviations for icons // NOTE: don't change these .. use LANGLOOKUP entries in the plaintext-parser-LL.txt // translation control file instead. 'north' => 'N', 'north-northeast' => 'NNE', 'northeast' => 'NE', 'east-northeast' => 'ENE', 'east' => 'E', 'east-southeast' => 'ESE', 'southeast' => 'SE', 'south-southeast' => 'SSE', 'south' => 'S', 'south-southwest' => 'SSW', 'southwest' => 'SW', 'west-southwest' => 'WSW', 'west' => 'W', 'west-northwest' => 'WNW', 'northwest' => 'NW', 'north-northwest' => 'NNW' ); $BeaufortText = array( // NOTE: don't change these .. use LANGLOOKUP entries in the plaintext-parser-LL.txt // translation file instead. 'Calm', 'Light air', 'Light breeze','Gentle breeze', 'Moderate breeze', 'Fresh breeze', 'Strong breeze', 'Near gale', 'Gale', 'Strong gale', 'Storm', 'Violent storm', 'Hurricane' ); // wind speed < values below correspond to force 0 .. 11 . >= last value = force 12 $BeaufortKTS = array( 1,4,7,11,17,22,28,34,41,48,56,64,64 ); $BeaufortMPH = array( 1,4,8,13,19,25,32,39,47,55,64,73,73 ); $BeaufortKPH = array( 1,6,12,20,30,40,51,63,76,88,103,118,118 ); $BeaufortMS = array( 0.2,1.6,3.4,5.5,8.0,10.8,13.9,17.2,20.8,24.5,28.5,32.7,32.7 ); reset($config); // $Status .= "\n"; foreach ($config as $key => $rec) { // load the parser condition strings $recin = trim($rec); if ($recin and substr($recin,0,1) <> '#') { // got a non comment record list($type,$keyword,$dayicon,$nighticon,$condition) = explode('|',$recin . '|||||'); if (isset($type) and strtolower($type) == 'cond' and isset($condition)) { $Conditions["$keyword"] = "$dayicon\t$nighticon\t$condition"; } if (isset($type) and strtolower($type) == 'precip' and isset($nighticon)) { $Precip["$keyword"] = "$dayicon\t$nighticon"; } if (isset($type) and strtolower($type) == 'snow' and isset($nighticon)) { $Snow["$keyword"] = "$dayicon\t$nighticon"; } if (isset($type) and strtolower($type) == 'lang' and isset($dayicon)) { $Language["$keyword"] = "$dayicon"; } if (isset($type) and strtolower($type) == 'langlookup' and isset($dayicon)) { $LanguageLookup["$keyword"] = "$dayicon"; } if (isset($type) and strtolower($type) == 'dateformat' and isset($keyword)) { $timeFormat = trim($keyword); } if (isset($type) and strtolower($type) == 'charset' and isset($keyword)) { $useCharSet = trim($keyword); $Status .= "\n"; } if (isset($type) and strtolower($type) == 'notavail' and isset($keyword)) { $notAvail = trim($keyword); } } // end if not comment or blank } // end loading of $Conditions and $Precip if (count($LanguageLookup) < 1) {$doTranslate = false; } $testFiles = array( // local testing for Ken .. these files aren't part of the distribution 'a' => 'plaintext-bin.txt', 'b' => 'plaintext-test1.txt', 'fr' => 'plaintext-cy.txt', 'nl' => 'plaintext-du.txt', 'it' => 'plaintext-it.txt', 'se' => 'plaintext-se.txt', 'nz' => 'plaintext-nz.txt', 'snow' => 'plaintext-snow.txt', 'rest' => 'plaintext-rest.txt', 'oregon' => 'plaintext-oregon.txt', 'fograin' => 'plaintext-fograin.txt', 'snow2' => 'plaintext-snow2.txt', 'snow3' => 'plaintext-snow3.txt', 'snow4' => 'plaintext-snow4.txt', 'snow5' => 'plaintext-snow5.txt', 'snow6' => 'plaintext-snow6.txt', 'snow7' => 'plaintext-snow7.txt', 'snow8' => 'plaintext-snow8.txt', 'snow9' => 'plaintext-snow9.txt', 'snow10' => 'plaintext-snow10.txt', 'gr' => 'plaintext-gr.txt', 'zulu' => 'plaintext-zulu.txt', 'beaufort' => 'plaintext-beaufort.txt', 'snowlevel' => 'plaintext-snowlevel.txt', 'thunder' => 'plaintext-thunder.txt', 'thunder2' => 'plaintext-thunder2.txt', 'broadstairs' => 'plaintext-broadstairs.txt', 'hdx' => 'plaintext-hdx.txt', 'frost' => 'plaintext-frost.txt', 'hot' => 'plaintext-hot.txt', 'nl-frost' => 'plaintext-nl-frost.txt', 'wc' => 'plaintext-wc.txt', 'wc2' => 'plaintext-wc2.txt', 'nl4' => 'plaintext-nl4.txt', 'nl5' => 'plaintext-nl5.txt', 'sn4' => 'plaintext-sn4.txt', 'sn5' => 'plaintext-sn5.txt', 'wc3' => 'plaintext-wc3.txt', ); $linksList = ''; if (isset($_REQUEST['testlinks'])) { $thisTest = isset($_REQUEST['test'])?$_REQUEST['test']:'notspecified'; foreach ($testFiles as $name => $fname) { $linksList .= ""; if($thisTest == $name) { $linksList .= "$name  "; } else { $linksList .= "$name  "; } } } if (isset($_REQUEST['test']) ) { // for testing only $t = strtolower($_REQUEST['test']); if (isset($testFiles[$t]) ) { $Status .= "\n"; $plaintextFile = $testFiles[$t]; } } if (isset($_REQUEST['minpop'])) { // for testing only $minPoP = $_REQUEST['minpop']; } // Read in the plaintext.txt forecast file for processing if (! file_exists($plaintextFile) ) { $msg = "The WXSIM forecast is not currently available."; if (isset($notAvail)) { $msg = $notAvail; } print "

$msg

\n"; return; } $pt = file($plaintextFile); // fix missing space at start of line if need be foreach ($pt as $i => $line) { if(substr($line,0,1) != ' ') {$pt[$i] = ' ' . $line;} } $plaintext = implode('',$pt); // get the plaintext file. // preprocess.. mark divisions in the forecast days for later parsing $plaintext = preg_replace('![\n][\r|\n]+!s',"\n \n",$plaintext); $plaintext = preg_replace('![\r|\n]+ [\r|\n]+!s',"\t\t",$plaintext); $plaintext .= "\t\t"; // make sure a delimiter is at the end too. $plaintext = preg_replace('|_|is','',$plaintext); // remove dashed line in front // Find city and update date if (preg_match('|WXSIM text forecast for (.*), initialized at\s+(.*)|i',$plaintext,$matches)) { $WXSIMcity = PPget_lang(trim($matches[1])); $wdate = trim($matches[2]); $Status .= "\n"; // there are LOTS of formats of the date stamp in plaintext.txt // 012345678901234567890 // 20:00 Feb 21, 2007 // 15:00 02 Apr, 2007 // 8:00 PM Mar 24, 2007 // 12:00 AM 24 Mar, 2007 // 17:00Z 05 Nov, 2007 $wdateParts = preg_split("/[\s,]+/", $wdate); // $Status .= "\n"; $i=0; if (preg_match('!AM|PM!i',$wdateParts[1]) ) { // got US style date. list($wHrs,$wMins) = explode(':',$wdateParts[0]); if (strtolower($wdateParts[1]) == 'pm' and $wHrs <> 12 ) {$wHrs += 12; } if (strtolower($wdateParts[1]) == 'am' and $wHrs == 12 ) {$wHrs = '00'; } $wTime = "$wHrs:$wMins"; $i=1; } else { $wTime = $wdateParts[0]; } if (preg_match('!\d+!',$wdateParts[$i+1]) ) { // got day in 1, month in 2 (+offset) $wDay = $wdateParts[$i+1]; $wMon = $wdateParts[$i+2]; } else { $wDay = $wdateParts[$i+2]; $wMon = $wdateParts[$i+1]; } $wYear = $wdateParts[$i+3]; // $wdate = preg_replace('|(\S+)\s+(\S+)\s+(\S+),\s+(\S+)|s',"$2-$3-$4 $1:00 ".date('O',time()),$wdate); if(preg_match('|Z|i',$wTime) ) { // Zulu(GMT) time format $wTime = preg_replace('|Z|i','',$wTime); $wdate = "$wDay-$wMon-$wYear $wTime UTC"; $Status .= "\n"; $d = strtotime($wdate); $WXSIMupdated = PPget_lang(date('l',$d)) . ', ' . gmdate($timeFormat,$d) . ' UTC'; } else { $wdate = "$wDay-$wMon-$wYear $wTime " . date('O',time()); $Status .= "\n"; $d = strtotime($wdate); $WXSIMupdated = PPget_lang(date('l',$d)) . ', ' . date($timeFormat,$d); } } // split up the forecast days and texts // good preg_match_all('![\r|\n]+\s+(.*):\s(.*)[\r|\n]+ [\r|\n]+!Us',$plaintext,$matches); preg_match_all('!\t\s(.*):\s(.*)\t!Us',$plaintext,$matches); // split up the forecast // Main loop over each forecast text paragraph. for ($i=0;$i\\1",PPget_lang($WXSIMday[$i])); if (! preg_match('!
!',$WXSIMtitles[$i])) { $WXSIMtitles[$i] .= '
'; // add line break to 'short' day titles } // extract UV index value if (preg_match('|UV index up to (\d+)\.|i',$WXSIMtext[$i],$mtemp) ) { $WXSIMuv[$i] = $mtemp[1]; } // extract Heat Index value if (preg_match('|Heat index up to (\d+)\.|i',$WXSIMtext[$i],$mtemp) ) { $WXSIMheatidx[$i] = $mtemp[1]; } // extract Humidex value if (preg_match('|Humidex up to (\d+)\.|i',$WXSIMtext[$i],$mtemp) ) { $WXSIMhumidex[$i] = $mtemp[1]; } // extract Wind-chill value if (preg_match('/Wind chill (down to|ranging from|as low as|around) (\S+)/i',$WXSIMtext[$i],$mtemp) ) { $WXSIMwindchill[$i] = $mtemp[2]; } // extract Wind direction, values $testwind = str_replace('Wind chill','Wind-chill',$WXSIMtext[$i]); if (preg_match('|Wind (.*)\.|Ui',$testwind,$mtemp) ) { // $Status .= "\n"; $wtemp = preg_replace( '! around| near| in the| morning| evening| afternoon| midnight| tonight| to| after!Uis', '',$mtemp[1]); // $Status .= "\n"; $wtemp = explode(', ',$wtemp); // $Status .= "\n"; // [0] => northwest around 5 mph // or // [0] => northwest near calm // [1] => gusting to 12 mph // [2] => in the morning // [3] => becoming 12 mph in the afternoon // or // [3] => becoming west-northwest around 12 mph in the afternoon // or // [3] => becoming north-northwest in the afternoon $wparts = explode(' ',$wtemp[0]); // break it by spaces. $maxWind = 0; for ($k =0;$k [speed] [units] format $WXSIMwinddir[$i] = $WindLookup[$wparts[0]]; // get abbreviation for direction $WXSIMwinddiricon[$i] = $WXSIMwinddir[$i]; // base name for wind icon $WXSIMwind[$i] = $wparts[1]; // get speed if ($wparts[1] > $maxWind and $wparts[1] <> 'calm') { $maxWind = $wparts[1]; } if ( isset($wparts[2])) { $WXSIMwindunits[$i] = $wparts[2]; // get wind units of measure } } if ($wparts[0] == 'gusting') { $WXSIMwind[$i] .= '-' . $wparts[1]; if ($wparts[1] > $maxWind) { $maxWind = $wparts[1]; } $WXSIMgust[$i] = $wparts[1]; } if ($wparts[0] == 'becoming') { // got 'becoming [dir] [speed] [units] if (isset($WindLookup[$wparts[1]]) ) { $WXSIMwinddir[$i] .= '→' . $WindLookup[$wparts[1]]; } if (preg_match('!(\d+|calm)!',$wtemp[$k],$match)) { $WXSIMwind[$i] .= '→' . $match[1]; if ($match[1] > $maxWind and $match[1] <> 'calm') { $maxWind = $match[1]; } } if (! $WXSIMwindunits[$i] and isset($wparts[2]) ) { $WXSIMwindunits[$i] = $wparts[2]; // get wind units of measure } } } $WXSIMBeaufort[$i] = PPdisplayBeaufort(PPgetBeaufort($maxWind,$WXSIMwindunits[$i])) ; // $Status .= "\n"; } // extract temperature High/Low values $found = strpos ($WXSIMtext[$i], 'High'); if ($found === false) {$found = strpos ($WXSIMtext[$i],'Low');} if ($found === false) {$WXSIMtextSmall[$i] = $WXSIMtext[$i];} else {$WXSIMtextSmall[$i] = substr($WXSIMtext[$i],0,$found);} if (preg_match('!(high|low) ([-|\d]+)[\.|,]!i',$WXSIMtext[$i],$mtemp)) { $WXSIMtemp[$i] = PPget_lang($mtemp[1] .':') . ' ' . $mtemp[2] . $tempDegrees; $WXSIMtempClean[$i] = $mtemp[2]; if ($tempDegrees) { // fix up degrees in the text $WXSIMtext[$i] = preg_replace( '|' . $mtemp[1] . ' ' . $mtemp[2] .'|', $mtemp[1] . ' ' . $mtemp[2] . $tempDegrees, $WXSIMtext[$i]); $WXSIMtext[$i] = preg_replace('/Wind chill down to ([-|\d]+)/i',"Wind chill down to $1$tempDegrees",$WXSIMtext[$i]); $WXSIMtext[$i] = preg_replace('/Heat index up to ([-|\d]+)/i',"Heat index up to $1$tempDegrees",$WXSIMtext[$i]); // $Status .= "\n"; } if(substr($mtemp[1],0,1) == 'H') { $WXSIMtemp[$i] = '' . $WXSIMtemp[$i] . ''; } else { $WXSIMtemp[$i] = '' . $WXSIMtemp[$i] . ''; } } if (preg_match('!temperatures (rising|falling)!i',$WXSIMtext[$i],$mtemp)) { $WXSIMtempdirect[$i] = $mtemp[1]; } // extract PoP if (preg_match('!Chance of precipitation (.*) percent!i',$WXSIMtext[$i],$mtemp)) { // print "
" . print_r($mtemp,true) . "
\n"; $WXSIMpop[$i] = $mtemp[1]; $WXSIMpop[$i] = preg_replace('|less than |i','<',$WXSIMpop[$i]); if ($WXSIMpop[$i] == '<20') {$WXSIMpop[$i] = '10';} if ($WXSIMpop[$i] == 'near 100') { $WXSIMpop[$i] = '100'; } } // extract frost if (preg_match('!with\s+(.*)\s+frost.!is',$WXSIMtext[$i],$mtemp)) { // print "
" . print_r($mtemp,true) . "
\n"; $WXSIMfrost[$i] = ucfirst($mtemp[1]) . ' frost'; if ($doTranslate) { // perform optional translation if $Language has entries reset ($Language); // process in order of the file $text = $WXSIMfrost[$i]; foreach ($Language as $key => $replacement) { $text = str_replace($key,$replacement,$text); } $WXSIMfrost[$i] = $text; } } // now look for harshest conditions first.. (in order in -data file if ($doDebug) { $Status .= "\n"; } reset($Conditions); // Do search in load order foreach ($Conditions as $cond => $condrec) { // look for matching condition if ($doDebug) { $Status .= "\n"; } if(preg_match("!$cond!i",$WXSIMtext[$i],$mtemp)) { list($dayicon,$nighticon,$condition) = explode("\t",$condrec); if (preg_match('!chance!i',$condition) and $WXSIMpop[$i] < $minPoP) { if ($doDebug) { $Status .= "\n"; } continue; // skip this one } if (preg_match("|$cond level|i",$WXSIMtext[$i]) and !preg_match("/(chance of $cond|$cond likely|$cond very likely)/i",$WXSIMtext[$i]) ) { if ($doDebug) { $Status .= "\n"; } continue; // skip 'snow level' and 'freezing level' entries } if ($doDebug) { $Status .= "\n"; } $WXSIMcond[$i] = PPget_lang($condition); if (preg_match('|night|i',$WXSIMday[$i])) { $WXSIMicon[$i] = $nighticon; } else { $WXSIMicon[$i] = $dayicon; } break; } } // end of conditions search // look for precipitation amounts reset($Precip); // Do search in load order foreach ($Precip as $pamt => $prec) { // look for matching precipitation amounts if(preg_match("!$pamt!is",$WXSIMtext[$i],$mtemp)) { list($amount,$units) = explode("\t",$prec); $WXSIMprecip[$i] = $amount . ' ' . $units; break; } } // end of precipitation amount search // look for Snow Accumulation reset($Snow); // Do search in load order foreach ($Snow as $pamt => $prec) { // look for matching precipitation amounts if(preg_match("!$pamt!is",$WXSIMtext[$i],$mtemp)) { list($amount,$units) = explode("\t",$prec); $WXSIMprecip[$i] .= "
" . $amount . ' ' . $units . "\n"; # added $WXSIMsnow[$i] = $amount; break; } } // end of Snow Accumulation amount search // now fix up the full icon name and PoP if available $curicon = $WXSIMicon[$i] . $iconType; if ($WXSIMpop[$i] > 99999) { $testicon = preg_replace('|'.$iconType.'|',$WXSIMpop[$i].$iconType,$curicon); // print "
testicon='$testicon'
\n"; if (file_exists($iconDir . $testicon)) { $WXSIMicon[$i] = $testicon; } else { $WXSIMicon[$i] = $curicon; } } else { $WXSIMicon[$i] = $curicon; } if ($WXSIMtempdirect[$i] <> '') { $tempdirect = 'up.gif'; if (substr($WXSIMtempdirect[$i],0,1) == 'f') { $tempdirect='down.gif'; } $WXSIMtemp[$i] .= "\""; } if ($doTranslate) { // perform optional translation if $Language has entries reset ($Language); // process in order of the file $text = $WXSIMtext[$i]; foreach ($Language as $key => $replacement) { $text = str_replace($key,$replacement,$text); } // put back translated text, fixing capitalization for sentence starts (except the first one). // $WXSIMtext[$i] = preg_replace('!\.\s+([a-z])!es',"'. ' . strtoupper('\\1')",$text); $text = $WXSIMtextSmall[$i]; foreach ($Language as $key => $replacement) { $text = str_replace($key,$replacement,$text); } // put back translated text, fixing capitalization for sentence starts (except the first one). // $WXSIMtextSmall[$i] = preg_replace('!\.\s+([a-z])!es',"'. ' . strtoupper('\\1')",$text); $WXSIMday[$i] = PPget_lang($WXSIMday[$i]); ## $WXSIMday[$i] = $WXSIMday[$i]; if($doRTL and isset($LanguageLookup['NESW-N'])) { // handle RTL language type $Status .= "\n"; $tstr = preg_replace('|→|',"\t",$WXSIMwinddir[$i]); $twdirs = explode("\t",$tstr); foreach ($twdirs as $n => $twdir) { $twdirs[$n] = isset($LanguageLookup['NESW-'.$twdir])?$LanguageLookup['NESW-'.$twdir]:$twdir; } $WXSIMwinddir[$i] = join('←',array_reverse($twdirs)); $Status .= "\n"; if(preg_match('|→|',$WXSIMwind[$i])) { $Status .= "\n"; $tstr = preg_replace('|→|',"\t",$WXSIMwind[$i]); $twspds = explode("\t",$tstr); $WXSIMwind[$i] = join('←',array_reverse($twspds)); $Status .= "\n"; } } else { // handle non-RTL language type $wdirs = PPget_lang('NESW'); // default directions if(strlen($wdirs) == 4) { $WXSIMwinddir[$i] = strtr($WXSIMwinddir[$i],'NESW',$wdirs); // do translation } elseif (preg_match('|,|',$wdirs)) { //multichar translation $wdirsmc = explode(',',$wdirs); $wdirs = array('N','E','S','W'); $wdirlook = array(); foreach ($wdirs as $n => $d) { $wdirlook[$d] = $wdirsmc[$n]; } $tstr = ''; // get ready to pass once through the string for ($n=0;$n $replacement) { $text = str_replace($key,$replacement,$text); } $key = explode("\t",$text); $WXSIMwind[$i] = trim($key[0]); $WXSIMwindunits[$i] = trim($key[1]); } // override icon with hot.jpg if high heat-index or humidex if($WXSIMheatidx[$i] >= $showHotIconF or $WXSIMhumidex[$i] >= $showHotIconC) { // $WXSIMicon[$i] = 'hot.jpg'; $WXSIMcond[$i] .= "
\n" . PPget_lang('Hot!') . ""; } if($WXSIMheatidx[$i] <> '') { // $WXSIMheatidx[$i] = "".PPget_lang('Heat').": $WXSIMheatidx[$i]$tempDegrees\n"; } if($WXSIMhumidex[$i] <> '') { // $WXSIMhumidex[$i] = "".PPget_lang('Hmdx').": $WXSIMhumidex[$i]\n"; } // process Wind-chill if ($WXSIMwindchill[$i] <= $showColdVal and $WXSIMwindchill[$i] <> '') { $WXSIMcond[$i] .= "
" . PPget_lang('Cold!') . ""; // $WXSIMicon[$i] = 'cold.jpg'; } if($WXSIMwindchill[$i] <> '') { // $WXSIMwindchill[$i] = "".PPget_lang('WCh').": $WXSIMwindchill[$i]$tempDegrees\n"; } if ($WXSIMfrost[$i] <> '') { $WXSIMfrost[$i] = "$WXSIMfrost[$i]\n"; } // make HTML for full icon with condition description $WXSIMicons[$i] = "$WXSIMtitles[$i]
\"".strip_tags($WXSIMcond[$i])."\"
$WXSIMcond[$i]"; } // end of main loop ------------------------- # #echo '
snow:';	print_r($WXSIMsnow);
#echo 'humidex: ';		print_r($WXSIMhumidex);
#echo 'chill: ';		print_r($WXSIMwindchill);
#echo 'frost: ';		print_r($WXSIMfrost);
#echo 'precip: ';		print_r($WXSIMprecip);
#echo '
'; #exit; $IncludeMode = false; $PrintMode = true; if (isset($doPrint) && ! $doPrint ) { // print $Status; return; } if (isset($_REQUEST['inc']) && strtolower($_REQUEST['inc']) == 'noprint' ) { print $Status; return; } if (isset($_REQUEST['inc']) && strtolower($_REQUEST['inc']) == 'y') { $IncludeMode = true; } if (isset($doInclude)) { $IncludeMode = $doInclude; } // V1.03 -- set width of for icons based on overall width/num icons preg_match('|(\d+)(.*)|',$maxWidth,$widthparts); //$Status .= "\n"; $nTD = count($WXSIMicon); if ($nTD < 1) { $nTD = 1; } $wTD = round($widthparts[1]/$nTD,0) . $widthparts[2]; $nUseIcons = min(count($WXSIMicons),$maxIcons); $Status .= "\n"; //begin printing of advforecast style printout if(! $IncludeMode) { ?> <?php echo $Version; ?> 1) { print "

"; print "Testing links for "; $thisLink = isset($_REQUEST['test'])?'&test='.$_REQUEST['test']:''; print "lang=$lang "; print "lang=en
\n"; print $linksList; print "\n

\n"; } } // only print above if not include mode print $Status; if ($printHeading or $printIcons) { ?>
>
> ";} echo $WXSIMupdated; if($doRTL) { echo "";} ?>
  $WXSIMicons[$i]\n"; } ?> $WXSIMprecip[$i]\n"; } ?> $WXSIMtemp[$i]\n"; } ?> '') {$flag++; print "\n"; } if ($showHeatIDX and $WXSIMheatidx[$i] <> '') {$flag++; print "\n"; } if ($showWindChill and $WXSIMwindchill[$i] <> '') {$flag++; print "\n"; } if($flag < 1) { // print spacer row print "\n"; } } ?> 1) { ?> '') {$flag++; print "\n"; } else { print "\n"; } } ?> " . $WXSIMwinddir[$i] . "
" . $WXSIMwind[$i] . "
" . $WXSIMwindunits[$i]; if ($showBeaufort) { print "
" . $WXSIMBeaufort[$i] .""; } print "\n"; } ?> " . PPset_UV_string($WXSIMuv[$i]) . "\n"; } ?>
$WXSIMhumidex[$i]$WXSIMheatidx[$i]$WXSIMwindchill[$i] 
$WXSIMfrost[$i] 

 

\n"; print "\n"; print "\n"; print "\n"; } ?>
$WXSIMday[$i]
 
$WXSIMtext[$i]

WXSIM forecast formatting script by Saratoga-Weather.org. '.jpg') { print "
Animated forecast icons courtesy of www.meteotreviglio.com."; } ?>

0) and ($uv < 3)): $uv = "UV: $uv
" . ' ' . PPget_lang("Low") .' '; break; case (($uv >= 3) and ($uv < 6)): $uv = "UV: $uv
" . ' ' . PPget_lang("Medium") .' '; break; case (($uv >=6 ) and ($uv < 8)): $uv = "UV: $uv
" . ' ' . PPget_lang("High") .' '; break; case (($uv >=8 ) and ($uv < 11)): $uv = "UV: $uv
" . ' ' . PPget_lang('Very High') . ' '; break; case (($uv >= 11) ): $uv = "UV: $uv
" . ' ' . PPget_lang("Extreme") .' '; break; } // end switch return $uv; } // end get_UVrange // determine Beaufort number based on wind speed and units function PPgetBeaufort ( $wind, $units) { global $showBeaufort,$BeaufortMPH,$BeaufortKPH,$BeaufortKTS,$BeaufortMS,$doDebug,$Status; switch ($units) { case 'mph': $winds = $BeaufortMPH; break; case 'kph': $winds = $BeaufortKPH; break; case 'km/h': $winds = $BeaufortKPH; break; case 'm/s': $winds = $BeaufortMS; break; case 'mps': $winds = $BeaufortMS; break; case 'kts': $winds = $BeaufortKTS; break; default: $winds = $BeaufortMPH; } // end switch $Bft = 0; for ($i=0;$i<12;$i++) { if ($wind < $winds[$i]) { $Bft = $i; break; } } if ($i > 11 and ! $Bft) { $Bft = 12; }; if($doDebug) { $Status .= "\n"; } return($Bft); }// end PPgetBeaufort // perform Beaufort display if desired by showBeaufort setting function PPdisplayBeaufort ($Bft) { global $showBeaufort, $BeaufortText; if ($Bft < 0 or $Bft > 12 ) { return(""); } if ($showBeaufort == 'T') { return( PPget_lang($BeaufortText[$Bft]) ); } if ($showBeaufort == 'V') { return("$Bft Bft"); } return(""); }// end PPdisplayBeaufort ?>