Saratoga Template käyttöönotto ja viritys

Aloittaja nurmiin, lauantai, 22.01.2011, 22:24

« edellinen - seuraava »

0 Jäsenet ja 1 Vieras katselee tätä aihetta.

jamo

Ja korjauspalikkaa löytyy tuon kautta: http://www.weather-watch.com/smf/index.php/topic,49780.0.html
Nyt kiinnitin vasta huomiota tuohon että tuuli tulee km/h, oliko aikaisemmin?
Oma esimerkkisivu: http://www.liminkaweather.info/wxforecast2.php


jamo

simok

Löytyy myös:

http://saratoga-weather.org/scripts-WUforecast.php#WUforecast

Aivan sivun lopussa löytyy 2.2.2011 päivitys. Vanhemmassa versiossa on km/h, settings.php rivillä 168
###########################################################################
$SITE['WDdateMDY'] = false; // for WD date format of month/day/year.  =false for day/month/year
$SITE['uomTemp'] = '°C';
$SITE['uomBaro'] = ' hPa';
$SITE['uomWind'] = ' km/h';
$SITE['uomRain'] = ' mm';
$SITE['uomSnow'] = ' cm';

$SITE['uomDistance'] = ' km';  // or ' miles' -- used for Wind Run display

simok

Iltaa. Minulla on ollu ongelmia nuiden WU ja Hengan Yrno kanssa päivityksien kanssa. Ne ei osaa päivittää sivulleni uusia ennusteita, vaan ne on minun käsin tehtävä, ensin päivitän ne itselleni RAPID PHP'llä ja sitten kopioin ne omille sivuilleni.

http://kotisivu.dnainternet.net/simokarppinen

Johtuuko se dna'sta, eivät salli jotain?  Oon antanu  ko. cache-hakemistoon oikeudet 777 ja myös ko. tiedostoille. Kyllä se homma (Henkan)hakee esim. cacheen Kuusamo.xml koko=0 (nolla) 4.2.2011 22:17:17 oikeudet 0644, Omistaja/Ryhmä 332000, sitten kun yritän antaa oikeudeksi 777, se ei tallenna eli ei anna muuttaa. Sitten siirsin RAPID-PHP'llä ko. tiedoston ensin koneelleni ja sieltä ftp'llä kotisivuilleni, mutta se ei anna siirtää sen päälle, kun oikeudet on 0644. Poistan Kuusamo.xml ja sitten kopioin sen kotihakemistoon ja kaikki näyttää taas ulospäin ok, mutta kun aikaraja täyteen, se ei enää osaa, varmaan osaakin, mutta dna ei anna kopioida sitä uutta taas, vaikka olen muuttanu nyt oikeuksiksi 777. Toivottavasti joku ymmärtää tämän tekstin. Oletan, että DNA ei anna ko. hakemistoon kaikkia tarvittavia oikeuksia.  Neuvoja kiitos.

nurmiin

Pieni vinkki,

Siivotessani sivujani XHTML -kelpoiseksi, pitkällisien tutkimusteni jälkeen löysin pahimman ongelman aiheuttajan:

Linkeissä ja kuvien hakemisessa toiselta palvelimelta ainakin et-merkki "&", pitää korvata ampersandilla "&amp;".  Samoin kaikki tagit pitää myös päättää jollakin tavoin aina esim. linkki  "/></a>". Rivin vaihto "<br>" aiheuttaa virheen, pitää olla "<br />".

Mutta tämä et-merkki aiheutti yhdellä sivullani vaatimattomat 350 virhettä... W3 orgin sivuilla tätä ei selvitetä mitenkään, johdatetaan vain toiseen virheeseen, mutta korjaus on siis kuitenkin "&amp;".

Samoin teksteissä saattaa olla mukana asiaan kuulumattomia näkymättömiä ohjausmerkkejä, jotka aiheuttavat virheen, mutta w3 ei sitä sen tarkemmin ilmoita. Siitä selviää poistamalla ensimmäisen w3 ilmoittaman rivin ja tekemällä sen uudestaan, useasti kaikki loputkin virheet poistuvat sen jälkeen.

Toivottavasti jollekin aukesi tämä.

nurmiin




simok

Päivää. Kiitos neuvosta, mutta se ei auttanut. Lähetin sitten viestin DNA''lle perjantaina ja sai vastauksen jo tänään klo 14:49, vastaus alla:

_____________________________________________________________________________________________________
Hei!

Kiitos viestistäsi.

Otathan huomioon tuossa sen että kun palvelimella kirjoitat php:llä jotakin, tulee silloin tiedoston omistajaksi palvelin? Samalle php skriptille tulisi määritellä että se muuttaisi tiedosto-oikeudet oikeanlaiseksi jolloin päivityksen pitäisi onnistua.

Ystävällisin terveisin


Tatu Mikkonen
DNA Oy, tekninen tuki
puh. 0600 30 5030 (0,37 €/min+pvm+mpm)
ma-pe 8-22, la 9-18 ja su 12-18
apua@dna.fi

_________________________________________________________________________________________

No minun täytyy tunnustaa, etten osaa tehdä tuolle mitään, mutta entä weatherc ja muu porukka, löytyykö teiltä osaamista tuohon?

Kiitos jo etukäteen simok.

nurmiin

Moro,

Onko kukaan muu huomannut, että fiksatun WU ennusteen lämmöt Alin ja Ylin ovat ainakin suomenkielisenä molemmat punaisia, se ja en ovat ennallaan eli  sininen ja punainen.

nurmiin

teutari

Lainaus käyttäjältä: nurmiin - torstai, 10.02.2011, 19:33
Moro,

Onko kukaan muu huomannut, että fiksatun WU ennusteen lämmöt Alin ja Ylin ovat ainakin suomenkielisenä molemmat punaisia, se ja en ovat ennallaan eli  sininen ja punainen.

nurmiin

Tuohon on tullut Keniltä korjaus, toimii ainakin nyt minulla oikein.

<?php 
// WU-forecast.php script by Ken True - webmaster@saratoga-weather.org
//
// Version 1.00 - 02-Sep-2007 - initial release
// Version 1.01 - 09-Sep-2007 - added selective printing and translation for 'Chance of precipitation'
// Version 1.02 - 18-Sep-2007 - fixed typo on line 533 ($PrintMode instead of $printMode)
// Version 1.03 - 31-Jan-2008 - modified to support new Wunderground page layout and icon set
// Version 1.04 - 21-Feb-2008 - modified to support minor WU website change and added support for
//                              Carterlake/AJAX/PHP template integration
// Version 1.05 - 30-Mar-2008 - added units selector C/F/both function for icon legend
// Version 1.06 - 21-Apr-2008 - added $SITE['xlateCOP'] for World-Multi-lingual support
// Version 1.07 - 22-Apr-2008 - added iconv() to convert UTF-8 to targeted character set $SITE['charset']
// Version 1.08 - 01-Oct-2008 - added support for WU display of Tropical data when it appears
// Version 1.09 - 02-Dec-2008 - fixes for WeatherUnderground website changes
// Version 1.10 - 15-Dec-2008 - fixes for F/C temperature for WU website changes
// Version 1.11 - 19-Dec-2008 - fixes for WU website changes
// Version 1.12 - 22-Dec-2008 - fix to remove '\r\n2000\r\n' from WU website returned HTML
// Version 1.13 - 26-Jan-2011 - added support for global $cacheFileDir for cache files
// Version 1.14 - 03-Feb-2011 - fixes for WeatherUnderground major website changes
// Version 1.15 - 07-Feb-2011 - more fixes for multilingual usage
//
$Version "WU-forecast.php (ML) Version 1.15 - 07-Feb-2011";
//
// 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 parses the WeatherUnderground forecast html page and loads icons/text into
//  arrays so you can use them in your weather website.  
//
// NOTE: You must leave an attribution link to weatherunderground.com in the output page.
//
//  The script DOES NOT work for locations in the USA, US territories or Canada. There are
//  other scripts for NOAA and EC forecasts for you to use instead of this script.
//
// output: creates XHTML 1.0-Strict HTML page (or inclusion)
//
// by default, the script uses the WeatherUnderground icons shown at
//    http://www.wunderground.com/graphics/conds/ for the conditions display.
//
// This script may optionally use the NOAA icons instead of linking to the
// WeatherUnderground Icons .. if you use this option, then the NOAA icons need to be placed in the path 
// where the original NOAA icons are located: \forecast\images\
// (so make a folder in your web HTML root called "forecast", then make a folder in it 
// called "images", and place the icons in this folder)
// The icon set is available at http://saratoga-weather.org/carterlake-icons.zip 
// If you have the icon set from:
//   http://members.cox.net/carterlakeweather/forecasticons.zip (380K)
// then please download http://saratoga-weather.org/carterlake-icons-addon.zip and
// upload to your /forecast/images directory.  
//
//
// Options on URL:
//
//   inc=Y            - omit <HTML><HEAD></HEAD><BODY> and </BODY></HTML> 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
//
//    $doIncludeWU = true;
//    include("WU-forecast.php");  for just the text
//  or ------------
//    $doPrintWU = false;
//    include("WU-forecast.php");  for setting up the $WUforecast... variables without printing
//
//  or ------------
//    $doIncludeWU = true;
//    $doPrintHeadingWU = true;
//    $doPrintIconsWU = true;
//    $doPrintTextWU = false
//    include("WU-forecast.php");  include mode, print only heading and icon set
//
// Variables returned (useful for printing an icon or forecast or two...)
//
// $WUforecastcity  - Name of city from WU Forecast header
//
// The following variables exist for $i=0 to $i= number of forecast periods minus 1
//  a loop of for ($i=0;$i<count($WUforecastday);$i++) { ... } will loop over the available 
//  values.
//
// $WUforecastday[$i] - period of forecast
// $WUforecasttext[$i] - text of forecast 
// $WUforecasttemp[$i] - Temperature with text and formatting
// $WUforecastpop[$i] - Number - Probabability of Precipitation ('',10,20, ... ,100)
// $WUforecasticon[$i]   - base name of icon graphic to use
// $WUforecastcond[$i]   - Short legend for forecast icon 
// $WUforecasticons[$i]  - Full icon with Period, <img> and Short legend.
//
// Settings ---------------------------------------------------------------
$iconDir ='./forecast/images/';           // directory for carterlake icons './forecast/images/'
//$iconDir ='';                           // set to '' to use the Wunderground icons instead
//
// view the forecast you want on www.wunderground.com using the language setting you desire,
// then copy the FULL url to the $WU_URL setting below.  Some examples are commented out below
//
// NOTE: don't use locations in the United States, US territories or Canada -- this script won't
//  process the Wunderground versions for those locations.
//
//$WU_URL = 'http://www.wunderground.com/cgi-bin/findweather/getForecast?query=95070'; // doesn't work
//$WU_URL = 'http://www.wunderground.com/cgi-bin/findweather/getForecast?query=Calgary%2C+Canada'; // doesn't work
//$WU_URL = 'http://www.wunderground.com/cgi-bin/findweather/getForecast?query=San+Juan%2C+Puerto+Rico'; // doesn't work
//
//$WU_URL = 'http://www.wunderground.com/global/stations/93119.html'; // Awhitu, Waiuku New Zealand
$WU_URL 'http://www.wunderground.com/global/stations/02984.html';
//$WU_URL = 'http://dutch.wunderground.com/global/stations/06370.html';
//$WU_URL = 'http://dutch.wunderground.com/cgi-bin/findweather/getForecast?query=Amsterdam%2C+Netherlands';
//$WU_URL = 'http://french.wunderground.com/cgi-bin/findweather/getForecast?query=Paris%2C+France';
//$WU_URL = 'http://swedish.wunderground.com/cgi-bin/findweather/getForecast?query=Stockholm%2C+Sweden';
//$WU_URL = 'http://norwegian.wunderground.com/cgi-bin/findweather/getForecast?query=Oslo%2C+Norway';
//$WU_URL = 'http://russian.wunderground.com/cgi-bin/findweather/getForecast?query=Moscow%2C+Russia';
//$WU_URL =  'http://greek.wunderground.com/cgi-bin/findweather/getForecast?query=Athens%2C+Greece';
//$WU_URL = 'http://espanol.wunderground.com/cgi-bin/findweather/getForecast?query=Madrid%2C+Spain';
//$WU_URL = 'http://finnish.wunderground.com/cgi-bin/findweather/getForecast?query=Helsinki%2C+Finland';
//$WU_URL = 'http://deutsch.wunderground.com/global/stations/10389.html';
//$WU_URL = 'http://portuguese.wunderground.com/cgi-bin/findweather/getForecast?query=Lisbon%2C+Portugal';
//$WU_URL = 'http://www.wunderground.com/cgi-bin/findweather/getForecast?query=London%2C+United+Kingdom';
//$WU_URL = 'http://www.wunderground.com/global/stations/03628.html';
//
$maxWidth '640px';                      // max width of tables (could be '100%')
$maxIcons 10;                           // max number of icons to display
$cacheFileDir './';                     // default cache file directory
$cacheName "WU-forecast.txt";           // locally cached page from WU
$refetchSeconds 1800;                    // cache lifetime (1800sec = 30 minutes)
$xlateCOP 'Chance of precipitation';     // change to local language if needed like
//$xlateCOP = 'Kans op neerslag';   //  Dutch example
$showTempsAs  'C';                  // under icons, 'C'=Centigrade only, 'F'=Fahrenheit only, 'B' = both
$charsetOutput 'ISO-8859-1';        // default character encoding of output
$lang 'en'; // default language
// ---- end of settings ---------------------------------------------------
// overrides from Settings.php if available
global $SITE;
if (isset(
$SITE['fcsturlWU']))  {$WU_URL $SITE['fcsturlWU'];}
if (isset(
$SITE['fcsticonsdir']))  {$iconDir $SITE['fcsticonsdir'];}
if (isset(
$SITE['uomTemp'])) {$uomTemp $SITE['uomTemp'];}
if (isset(
$SITE['xlateCOP'])) {$xlateCOP $SITE['xlateCOP'];}
if (isset(
$LANGLOOKUP['Chance of precipitation'])) {
  
$xlateCOP $LANGLOOKUP['Chance of precipitation'];
}
if (isset(
$SITE['charset'])) {$charsetOutput strtoupper($SITE['charset']); }
if (isset(
$SITE['lang'])) {$lang $SITE['lang'];}
if(isset(
$SITE['cacheFileDir']))     {$cacheFileDir $SITE['cacheFileDir']; }
// 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;
}
$Status "<!-- $Version -->\n";
//------------------------------------------------

$NWSiconlist = array(
 
// WU Icon name => NWS icon name // WU meaning
 
'chanceflurries.gif'  => 'sn.jpg'// Chance of Flurries
 
'chancerain.gif'  => 'hi_shwrs.jpg'// Chance of Rain
 
'chancesleet.gif'  => 'ip.jpg'// Chance of Sleet
 
'chancesnow.gif'  => 'sn.jpg'// Chance of Snow
 
'chancetstorms.gif'  => 'hi_tsra.jpg'// Chance of Thunderstorms
 
'clear.gif'  => 'skc.jpg'// Clear
 
'cloudy.gif'  => 'ovc.jpg'// Cloudy
 
'flurries.gif'  => 'sn.jpg'// Flurries
 
'fog.gif'  => 'fg.jpg'// Fog
 
'hazy.gif'  => 'fg.jpg'// Hazy
 
'mostlycloudy.gif'  => 'bkn.jpg'// Mostly Cloudy
 
'mostlysunny.gif'  => 'few.jpg'// Mostly Sunny
 
'partlycloudy.gif'  => 'sct.jpg'// Partly Cloudy
 
'partlysunny.gif'  => 'sct.jpg'// Partly Sunny
 
'rain.gif'  => 'ra.jpg'// Rain 
 
'sleet.gif'  => 'ip.jpg'// Sleet
 
'sleat.gif'  => 'ip.jpg'// Sleet (other spelling)
 
'snow.gif'  => 'sn.jpg'// Snow
 
'sunny.gif'  => 'skc.jpg'// Sunny
 
'tstorms.gif'  => 'tsra.jpg'// Thunderstorms
 
'unknown.gif'  => 'na.jpg'// Unknown
 
'nt_chanceflurries.gif' => 'nsn.jpg'// Chance of Flurries
 
'nt_chancerain.gif'  => 'hi_nshwrs.jpg'// Chance of Rain
 
'nt_chancesleet.gif'  => 'ip.jpg'// Chance of Sleet
 
'nt_chancesnow.gif'  => 'nsn.jpg'// Chance of Snow
 
'nt_chancetstorms.gif' => 'hi_ntsra.jpg'// Chance of Thunderstorms
 
'nt_clear.gif'  => 'nskc.jpg'// Clear
 
'nt_cloudy.gif'  => 'novc.jpg'// Cloudy
 
'nt_flurries.gif'  => 'nsn.jpg'// Flurries
 
'nt_fog.gif'  => 'nfg.jpg'// Fog
 
'nt_hazy.gif'  => 'nfg.jpg'// Hazy
 
'nt_mostlycloudy.gif'  => 'nbkn.jpg'// Mostly Cloudy
 
'nt_mostlysunny.gif'  => 'nfew.jpg'// Mostly Sunny
 
'nt_partlycloudy.gif'  => 'nsct.jpg'// Partly Cloudy
 
'nt_partlysunny.gif'  => 'nsct.jpg'// Partly Sunny
 
'nt_rain.gif'  => 'nra.jpg'// Rain 
 
'nt_sleet.gif'  => 'ip.jpg'// Sleet
 
'nt_sleat.gif' => 'ip.jpg'// sleet (other spelling)
 
'nt_snow.gif'  => 'nsn.jpg'// Snow
 
'nt_sunny.gif'  => 'nskc.jpg'// Sunny
 
'nt_tstorms.gif'  => 'ntsra.jpg'// Thunderstorms
 
'nt_unknown.gif'  => 'na.jpg'// Unknown
) ;
//
$Force false;

if (isset(
$_REQUEST['force']) and  $_REQUEST['force']=="1" ) {

  
$Force true;
}

$doDebug false;
if (isset(
$_REQUEST['debug']) and strtolower($_REQUEST['debug'])=='y' ) {
  
$doDebug true;
}

$fileName $WU_URL;
if (
$doDebug) {
  
$Status .= "<!-- WU URL: $fileName -->\n";
}

if (isset(
$uomTemp) and $showTempsAs <> 'B') { // use Settings.php Temp units only
   
$showTempAs preg_match('|C|i',$uomTemp) ? 'C' 'F';
   
$Status .= "<!-- temps in $showTempAs -->\n";
}

$cacheName $cacheFileDir $cacheName;
$cacheName preg_replace('|\.txt|is',"-$lang.txt",$cacheName); // unique cache per language used

// The number 1800 below is the number of seconds the cache will be used instead of pulling a new file
// 1800 = 60s x 30m so it retreives every 30 minutes. 

if (! $Force and file_exists($cacheName) and filemtime($cacheName) + $refetchSeconds time()) {
      
$html implode(''file($cacheName)); 
      
$Status .= "<!-- loading from $cacheName (" strlen($html) . " bytes) -->\n"
  } else { 
      
$Status .= "<!-- loading from $fileName. -->\n"
      
$html fetchUrlWithoutHangingWU($fileName,$cacheName); 
      
$fp fopen($cacheName"w"); 
  if (!$fp) { 
    $Status .= "<!-- unable to open $cacheName for writing. -->\n"
  } else {
        
$write fputs($fp$html); 
        
fclose($fp);  
$Status .= "<!-- saved cache to $cacheName ("strlen($html) . " bytes) -->\n";
  } 



  
preg_match('|charset=([^"]+)"|i',$html,$matches);
  
  if (isset(
$matches[1])) {
    
$charsetInput strtoupper($matches[1]);
  } else {
    
$charsetInput 'ISO-8859-1';
  }
 
$Status .= "<!-- using charsetInput='$charsetInput' charsetOutput='$charsetOutput' -->\n";
 
//  process the file .. select out the 7-day forecast part of the page
  
$UnSupported false;
  
preg_match_all('|<div class="fLeft w275 p10">(.*)</table>\s+</div>|Uis',$html,$matches);
   if(
$doDebug) {
     
$Status .= "<!-- first slice for table matches\n" print_r($matches[1],true) . "  end first slice matches-->\n";
   }
  if(
count($matches[1]) < and strlen($html) > 1000) { // oops... not parsable.. give 'em the news later
//  $Status .= "<!-- matches\n" . print_r($matches,true) . "-->\n";
  
$UnSupported true;   
  }
 
 
$rows $matches[1];
 
/* rows now contains

    [0] => 
<div class="b">Wednesday</div>
<table cellspacing="5" cellpadding="0" class="full">
<tr>
<td class="vaT"><a href="" class="iconSwitchMed"><img src="http://icons-ecast.wxug.com/i/c/k/chancerain.gif" alt="chancerain" class="condIcon" /></a></td>
<td class="vaT">
<div class="fctText">
Chance of Rain.
Partly Cloudy.
High:
6 &deg;C.
Wind
SW
24 - 30 km/h.
30% chance of precipitation
(water equivalent of mm).
Windchill:
-2 &deg;C.
</div>
</td>
</tr>

    [1] => 
<div class="b">Wednesday Night</div>
<table cellspacing="5" cellpadding="0" class="full">
<tr>
<td class="vaT"><a href="" class="iconSwitchMed"><img src="http://icons-ecast.wxug.com/i/c/k/chancerain.gif" alt="chancerain" class="condIcon" /></a></td>
<td class="vaT">
<div class="fctText">
Chance of Rain.
Overcast.
Low:
3 &deg;C.
Wind
SW
22 - 34 km/h.
20% chance of precipitation
(water equivalent of 0.10 mm).
Windchill:
-3 &deg;C.
</div>
</td>
</tr>



*/ 
  
preg_match('|<div id="fct_titlebar">(.*?)</div>|is',$html,$matches); // look for forecast header
   
if($doDebug) {
     
$Status .= "<!-- forecast title matches\n" print_r($matches,true) . "-->\n";
   }
   
$temp explode("\n",trim(strip_tags($matches[1])));
   
$WUtitle trim($temp[1]);
   
$WUtitle iconv($charsetInput,$charsetOutput.'//TRANSLIT',$WUtitle);
   if(
$doDebug) {
     
$Status .= "<!-- WUtitle='$WUtitle' -->\n";
   }
  
   
preg_match_all('|<title>(.*?)</title>|is',$html,$matches); // look for city name in title
   
if($doDebug) {
     
$Status .= "<!-- city title\n" print_r($matches,true) . "-->\n";
   }
   
$temp explode(",",$matches[1][0]); // split after city name
   
$WUforecastcity trim($temp[0]);
   
$WUforecastcity iconv($charsetInput,$charsetOutput.'//TRANSLIT',$WUforecastcity);
   if(
$doDebug) {
     
$Status .= "<!-- WUforecastcity='$WUforecastcity' -->\n";
   }
   
$WUtitle preg_replace("|$WUforecastcity|",'',$WUtitle);
   if(
$doDebug) {
     
$Status .= "<!-- WUtitle='$WUtitle' -->\n";
   }
   

$n 0// counter for arrays to stuff data in




  
for ($i=0;$i<count($rows);$i++) {  // 
 
/* <!-- table rows  this is all different
Array
(
    [0] => 
<div class="b">Wednesday</div>
<table cellspacing="5" cellpadding="0" class="full">
<tr>
<td class="vaT"><a href="" class="iconSwitchMed"><img src="http://icons-ecast.wxug.com/i/c/k/chancerain.gif" alt="chancerain" class="condIcon" /></a></td>
<td class="vaT">
<div class="fctText">
Chance of Rain.
Partly Cloudy.
High:
6 &deg;C.
Wind
SW
24 - 30 km/h.
30% chance of precipitation
(water equivalent of mm).
Windchill:
-2 &deg;C.
</div>
</td>
</tr>

    [1] => 
<div class="b">Wednesday Night</div>
<table cellspacing="5" cellpadding="0" class="full">
<tr>
<td class="vaT"><a href="" class="iconSwitchMed"><img src="http://icons-ecast.wxug.com/i/c/k/chancerain.gif" alt="chancerain" class="condIcon" /></a></td>
<td class="vaT">
<div class="fctText">
Chance of Rain.
Overcast.
Low:
3 &deg;C.
Wind
SW
22 - 34 km/h.
20% chance of precipitation
(water equivalent of 0.10 mm).
Windchill:
-3 &deg;C.
</div>
</td>
</tr>

*/   
// First see if this is a valid (with temperature) forecast, otherwise cut off the scan

   
preg_match('!([^\d-]\s+&deg;)!Uis',$rows[$i],$temp); // look for an empty min/max forecast temperature
if ($doDebug) {
      
$Status .= "<!-- temp test [$i]='" print_r($temp,true) . "' n=$n -->\n";
}
    if(isset(
$temp[1])) { break; } // we're done here

    
$WUforecasticon[$n] = $rows[$i];
preg_match('|src="([^"]+)"|i',$rows[$i],$temp); // extract raw image name
$t parse_url($temp[1]);
$t pathinfo($t['path']);
$WUforecasticon[$n] = $t['basename'];
if ($doDebug) {
      
$Status .= "<!-- WUforecasticon[$n]='" $WUforecasticon[$n] . "' -->\n";
}

    
preg_match('|<div class="b">(.*?)</div>(.*)|is',$rows[$i],$temp); // extract period
//   $Status .= "<!-- temp\n" . print_r($temp,true) . "-->\n";  
$WUforecastday[$n] = trim($temp[1]);
$WUforecastday[$n] = iconv($charsetInput,$charsetOutput.'//TRANSLIT',$WUforecastday[$n]);
$WUforecasttitles[$n] = $WUforecastday[$n];
if ($doDebug) {
      
$Status .= "<!-- WUforecastday[$n]='" $WUforecastday[$n] . "' -->\n";
}
    
preg_match('|<div class="fctText">(.*)</div>|is',$rows[$i],$temp);
$WUforecasttext[$n] = trimpreg_replace("|\n\s+|is",' ',$temp[1]) );
$WUforecasttext[$n] = preg_replace('|Chance of precipitation|s',iconv($charsetOutput,$charsetInput,$xlateCOP),$WUforecasttext[$n]);
$WUforecasttext[$n] = iconv($charsetInput,$charsetOutput.'//TRANSLIT',$WUforecasttext[$n]);
if ($doDebug) {
      
$Status .= "<!-- WUforecasttext[$n]='" $WUforecasttext[$n] . "' -->\n";
}

if (preg_match('|(\d+)\%|',$WUforecasttext[$n],$temp)) {
  $WUforecastpop[$n] = $temp[1]; // got a PoP
   } else {
  $WUforecastpop[$n] = '';
 }
if ($doDebug) {
      
$Status .= "<!-- WUforecastpop[$n]='" $WUforecastpop[$n] . "' -->\n";
}

// fixup temperature
//High: 71&deg; F. / 22&deg; C.
//Min.: 32 &deg;F / 0 &deg;C .
preg_match_all('!(\S+)\s*\:{0,1}\s+([\d-]+\s*\&deg;)!is',$WUforecasttext[$n],$temp);
if ($doDebug) {
      
$Status .= "<!-- temp[$n]='" print_r($temp,true) . "' -->\n";
}

    
$color '#FF0000';

$tday trim($WUforecastday[$n]);
$yday $tday;
if($n 0) {$yday trim(strip_tags($WUforecastday[$n-1])); }
$tdayblanks count(explode(" ",$tday)) -1// counts the number of blanks in todays name
if($doDebug) {
  $Status .= "<!-- DayNight tday'$tday' yday='$yday' tdayblanks=$tdayblanks -->\n";
}

if ( ($tdayblanks 0) or 
     (strlen($tday) > strlen($yday) and stripos($tday,$yday) !== false)
  ) {
  // the above IF checks to see if the todays name is longer than yesterdays name, and
  // that yesterdays day name is present in todays name .. this probably means it's a
  // night time forecast, so treat it as a 'low' temp, and change the icon to night-time
  // if needed.
  if($doDebug) {
$Status .= "<!-- night time icon selected -->\n";
  }
  if(substr($WUforecasticon[$n],0,3) <> 'nt_') {
  
    $WUforecasticon[$n] = 'nt_'.$WUforecasticon[$n]; // funny.. they stopped using day/night icons
  }
  $color '#0000FF';
}
$WUforecasttemp[$n] = "<span style=\"color: $color;\">";
$thilo iconv($charsetInput,$charsetOutput.'//TRANSLIT',$temp[1][0]);
if ($doDebug) {
      
$Status .= "<!-- temp[1][0]='" $temp[1][0] . "' thilo='$thilo' -->\n";
}
if(strlen($thilo) < 2) {$thilo trim($temp[1][0]); } // in case the iconv fails
    
$WUforecasttemp[$n] .= $thilo ' 'preg_replace('| &deg;|','&deg;',$temp[2][0]);
$WUforecasttemp[$n] .= '</span>';  // assemble the temperature

if ($doDebug) {
      
$Status .= "<!-- forecasttemp[$n]='" $WUforecasttemp[$n] . "' -->\n";
}

$temp explode('.',$WUforecasttext[$n]); // split as sentences (sort of).

$WUforecastcond[$n] = trim($temp[0]); // take first one as summary.
if ($doDebug) {
      
$Status .= "<!-- forecastcond[$n]='" $WUforecastcond[$n] . "' -->\n";
}

if(preg_match('| |',$WUforecastday[$n]) ) {
  $WUforecastday[$n] = preg_replace('| |','<br/>',$WUforecastday[$n],1);
} else {
  $WUforecastday[$n] .= "<br/>";
}

$WUforecasticons[$n] = $WUforecastday[$n] . "<br/>" .
     img_replace($WUforecasticon[$n],$WUforecastcond[$n],$WUforecastpop[$n]) . "<br/>" .
 $WUforecastcond[$n];

if ($doDebug) {
  $Status .= "\n";
}
$n++;
}

// All finished with parsing, now prepare to print

   $wdth intval(100/count($WUforecasticons));
   $ndays intval(count($WUforecasticon)/2);
   
   $WUtitle preg_replace('|5|i',$ndays,$WUtitle,1);

       
$doNumIcons $maxIcons;
   if(count($WUforecasticons) < $maxIcons) { $doNumIcons count($WUforecasticons); }

  
$IncludeMode false;
  
$PrintMode true;

  if (isset(
$doPrintWU) && ! $doPrintWU ) {
      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(
$doIncludeWU)) {
  
$IncludeMode $doIncludeWU;
}

$printHeading true;
$printIcons true;
$printText true;

if (isset(
$doPrintHeadingWU)) {
  
$printHeading $doPrintHeadingWU;
}
if (isset(
$_REQUEST['heading']) ) {
  
$printHeading substr(strtolower($_REQUEST['heading']),0,1) == 'y';
}

if (isset(
$doPrintIconsWU)) {
  
$printIcons $doPrintIconsWU;
}
if (isset(
$_REQUEST['icons']) ) {
  
$printIcons substr(strtolower($_REQUEST['icons']),0,1) == 'y';
}
if (isset(
$doPrintTextWU)) {
  
$printText $doPrintTextWU;
}
if (isset(
$_REQUEST['text']) ) {
  
$printText substr(strtolower($_REQUEST['text']),0,1) == 'y';
}


if (! 
$IncludeMode and $PrintMode) { ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>WeatherUnderground <?php echo $WUtitle ' - ' $WUforecastcity?></title>
    <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charsetOutput?>" />
</head>
<body style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; background-color:#FFFFFF">

<?php
// end printmode and not includemode
print $Status;
// if the forecast text is blank, prompt the visitor to force an update

if($UnSupported) {

  print <<< EONAG
<h1>Sorry.. this country <a href="$WU_URL">forecast</a> can not be processed by this script.</h1>
<p>Locations in the United States and territories should use the <a href="http://saratoga-weather.org/scripts-carterlake.php#advforecast">carterlake NOAA script</a>.</p>
<p>Locations in Canada should use the <a href="http://saratoga-weather.org/scripts-ECforecast.php#ECforecast">Environment Canada forecast script</a>.</p>

EONAG
;
}

if (
strlen($WUforecasttext[0])<and $PrintMode and ! $UnSupported ) {

  echo 
'<br/><br/>Forecast blank? <a href="' $PHP_SELF '?force=1">Force Update</a><br/><br/>';


if (
$PrintMode and ($printHeading or $printIcons)) {  ?>

  <table width="<?php print $maxWidth?>" style="border: none;" class="WUforecast">
    <?php if($printHeading) { ?>
    <tr align="center" style="background-color: #FFFFFF;">
      <td><b>WeatherUnderground <?php echo $WUtitle?>: </b><span style="color: green;">
   <?php echo $WUforecastcity?></span>
      </td>
    </tr>
<?php // end print heading

if ($printIcons) {
?>

    <tr>
      <td align="center">
    <table width="100%" border="0" cellpadding="0" cellspacing="0"> 
      <tr valign ="top" align="center">
<?php
  for (
$i=0;$i<$doNumIcons;$i++) {
    print "<td style=\"width: $wdth%;\"><span style=\"font-size: 8pt;\">$WUforecasttitles[$i]</span></td>\n";
  }
?>

          </tr>
      <tr valign ="top" align="center">
<?php
  for (
$i=0;$i<$doNumIcons;$i++) {
    print "<td style=\"width: $wdth%;\">" img_replace($WUforecasticon[$i],$WUforecastcond[$i],$WUforecastpop[$i]) . "</td>\n";
  }
?>

          </tr>
      <tr valign ="top" align="center">
<?php
  for (
$i=0;$i<$doNumIcons;$i++) {
    print "<td style=\"width: $wdth%;\"><span style=\"font-size: 8pt;\">$WUforecastcond[$i]</span></td>\n";
  }
?>

          </tr>
          <tr valign ="top" align="center">
  <?php
  for (
$i=0;$i<$doNumIcons;$i++) {
    print "<td style=\"width: $wdth%;\">$WUforecasttemp[$i]</td>\n";
  }
  ?>

          </tr>
<?php if(! $iconDir) { // print a PoP row since they aren't using icons ?>
      <tr valign ="top" align="center">
<?php
  for (
$i=0;$i<$doNumIcons;$i++) {
    print "<td style=\"width: $wdth%;\">";
    if($WUforecastpop[$i] > 0) {
  
  print "<span style=\"font-size: 8pt; color: #009900;\">PoP: $WUforecastpop[$i]%</span>";
} else {
  print "&nbsp;";
}
print "</td>\n";

  }
?>

          </tr>
  <?php // end if iconDir ?>
        </table><!-- end icon table -->
     </td>
   </tr><!-- end print icons -->
    <?php // end print icons ?>
</table>
  <p>&nbsp;</p>
<?php // end print header or icons

if ($PrintMode and $printText) { ?>


<table style="border: 0" width="<?php print $maxWidth?>" class="WUforecast">
<?php
  for (
$i=0;$i<count($WUforecasttitles);$i++) {
        print 
"<tr valign =\"top\" align=\"left\">\n";
    print "<td style=\"width: 20%;\"><b>$WUforecasttitles[$i]</b><br />&nbsp;<br /></td>\n";
    print "<td style=\"width: 80%;\">$WUforecasttext[$i]</td>\n";
print "</tr>\n";
  }
?>

   </table>
<?php // end print text ?>
<?php if ($PrintMode) { ?>
<p>&nbsp;</p>
<p>Forecast from <a href="<?php echo htmlspecialchars($fileName); ?>">WeatherUnderground</a>
for <?php echo $WUforecastcity?>.</p>
<?php
// end printmode

 
if (! $IncludeMode and $PrintMode ) { ?>

</body>
</html>
<?php 
}  

 
// Functions --------------------------------------------------------------------------------

function fetchUrlWithoutHangingWU($url,$cacheurl)
   {
   global 
$Status;
   
// Set maximum number of seconds (can have floating-point) to wait for feed before displaying page without feed
   
$numberOfSeconds=4;    

   
// Suppress error reporting so Web site visitors are unaware if the feed fails
   
error_reporting(0);

   
// Extract resource path and domain from URL ready for fsockopen

   
$url str_replace("http://","",$url);
   
$urlComponents explode("/",$url);
   
$domain $urlComponents[0];
   
$resourcePath str_replace($domain,"",$url);
   
$xml '';

   
// Establish a connection
   
$socketConnection fsockopen($domain80$errno$errstr$numberOfSeconds);

   if (!
$socketConnection)
       {

       
// You may wish to remove the following debugging line on a live Web site

       
$Status .= "<!-- Network error: $errstr ($errno) -->\n";
       }    
// end if
   
else    {
       
$xml '';
       
fputs($socketConnection"GET $resourcePath HTTP/1.1\r\nHost: $domain\r\nConnection: Close\r\nCookie: Units=metric;\r\n\r\n");
   
       
// Loop until end of file
       
while (!feof($socketConnection))
           {
           
$xml .= fgets($socketConnection4096);
           }    
// end while

       
fclose ($socketConnection);

       }    
// end else

   
$xml preg_replace('|\r\n2000\r\n|is','',$xml);  // this funky string started appearing in WU website

   
return($xml);

   }    
// end function

// -------------------------------------------------------------------------------------------
   
 
function img_replace $WUimage$WUcondtext,$WUpop) {
//
// optionally replace the WeatherUnderground icon with an NWS icon instead.
// 
 
global $NWSiconlist,$iconDir;
// $WU_URL = 'http://icons-aa.wxug.com/graphics/conds/';
// $WU_URL = 'http://icons.wunderground.com/graphics/conds/2005/';
 
$WU_URL 'http://icons-pe.wxug.com/i/c/50/';
 
 
$curicon $NWSiconlist[$WUimage]; // translated icon (if any)

 
if (!$iconDir or !$curicon) { // no change.. use WU icon
   
return("<img src=\"$WU_URL$WUimage\" width=\"50\" height=\"50\" 
  alt=\"
$WUcondtext\" title=\"$WUcondtext\"/>"); 
 }
   
  if (
$WUpop 0) {
$testicon preg_replace("|.jpg|","$WUpop.jpg",$curicon);
if (file_exists("$iconDir$testicon")) {
  $newicon $testicon;
} else {
  $newicon $curicon;
}
  } else {
$newicon $curicon;
  }

  return(
"<img src=\"$iconDir$newicon\" width=\"55\" height=\"58\" 
  alt=\"
$WUcondtext\" title=\"$WUcondtext\"/>"); 
 
 
 }
// End of functions --------------------------------------------------------------------------

?>

nurmiin

Kiitos teutari,

Nythän tuo WU-ennuste onkin taas aivan kohdallaan.

finilves

Olisiko kellään neuvoa ongelmaan. CUtags.txt ajaa Cumulus 1.9.0 ilmoittaa päivityksen 2.05, mutta kun Cumuksen 1.9.1
ilmoitta seuraavan päivitys ajan ja pelaa muuten hyvin tiputtaa lämpötilastaä desimaalit pois.
CUtags.php en löydä muuta eroa kuin osa tulee siuomenkielisinä.


Argonex

Moro!

Jaahas jospas minäkin muutaman päivän ihmettelyn ja taistelun jälkeen uskaltautuisin tänne aiheuttamaan pahennusta.

Elikkä tässä muutaman päivän olen nyt tapellut tuon Saratogan kanssa, nuo päivitykset jo toimivat, mutta muutamia ongelmia on tullut vastaan mille en osaa tehdä mitään, josko joku osaisi antaa vinkkiä.

Ensinnäkin tuohon sivun ylä ja alareunaan tulee muutama herja käyttäessä mozillaa:

Warning: session_start() [function.session-start]: open(/mbnet/phpsessions/sess_5b6d716d8cb61d75c2444f7ad9083a4f, O_RDWR) failed: Permission denied (13) in /mbnet/m/mturkki/saa/Settings.php on line 299

Warning: Unknown: open(/mbnet/phpsessions/sess_5b6d716d8cb61d75c2444f7ad9083a4f, O_RDWR) failed: Permission denied (13) in Unknown on line 0

Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/mbnet/phpsessions) in Unknown on line 0

(juu perseestä tuo mbnet, tiedetään), millähän noista voisi päästä eroon?

Sitten ongelma numero 2:

thermometer.php ei toimi: Kuvaa http://koti.mbnet.fi/mturkki/saa/thermometer.php?t=3.0 ei voida näyttää, koska se sisältää virheitä.

Nuo molemmat näyttävät toimivan ie:n kanssa ongelmitta, joten mistään monimutkaisesta jutusta ei kait ole kyse?

Sitten tuon yläreunan bannerin kanssa olen kanssa suorittanut pienimuotoista maaottelua, saan sen bannerin sinne kyllä asennettua mutta se häviää sellaisen vaalean sinisen värityksen taakse. klikkaamalla värityksen päältä näytä kuva, sen saa näkyviin uudella sivulla, tämän korjaamiseen kanssa vinkkejä ottaisin vastaan.

Niin ja sivujen osoitehan siis http://koti.mbnet.fi/mturkki/saa

- Mikko
Kun kiekuu uljas kukko laella tunkion, niin tietää joka ukko, sään muutos tulos on. Voi tulla poutaa sadetta, voi tulla pakkas sää, voi myöskin käydä niin että entiselleen jää