in your template to insert the weather information. Please visit the wiki page mentioned above for detailed information. There is also a link to a forum for support. */ class NP_Weatherreport extends NucleusPlugin { function getName() { return 'Weatherreport'; } function getAuthor() { return 'Edelpils (edelpils@gmail.com), mod by fishy'; } function getURL() { return 'http://wakka.xiffy.nl/weatherreport/'; } function getVersion() { return 'V3.02'; } function getDescription() { return 'This plugin show the weather information of most major cities in the world. Use <%Weatherreport%> in your template to insert the weahter information. This version ('.$this->getVersion().') is only compatible with PHP 5 or higher! If you are using an older PHP version download the v2.8 of this plugin.'; } function install() { $this->createBlogOption('city_name','Name of the city','text','Rotterdam'); $this->createBlogOption('city_id','City ID number (search at http://xoap.weather.com/search/search?where=XXX)','text','NLXX0015'); $this->createBlogOption('unit','Measure format','select','m' , 'Metric (Celcius)|m|Imperial (Fahrenheid)|c'); $this->createOption('icons_url','Root location or relative path of the icons (end with /)','text','http://www.ditnetwel.nl/weathericons/'); $this->createOption('icon_size','Icon size','select','128x128' , '128x128|128x128|64x64|64x64|32x32|32x32'); $this->createOption('extension','Icon extension','select','png' , 'PNG|png|GIF|gif'); $this->createOption('time_out','Time out setting in seconds','text','5','datatype=numerical'); $this->createOption('cache_timer','Cache timer (retreive weather data every xx seconds)','text','300','datatype=numerical'); $this->createOption('error_text','Text when error occurs','text','Weather server temp. offline'); $this->createOption('tmp_text','Translation for temperature','text','Temp.'); $this->createOption('feelslike_text','Translation for feelslike temperature','text','Feels like'); $this->createOption('humidity_text','Translation for humidity','text','Relative Humidity'); $this->createOption('windspeed_text','Translation for windspeed','text','Wind.'); $this->createOption('winddir_text','Translation for winddirection','text','Direction'); $this->createOption('airpressure_text','Translation for Barometric Pressure','text','Barometric Pressure'); $this->createOption('uv_text','Translation for UV Index','text','UV Index'); $this->createOption('dewp_text','Translation for Dewpoint','text','Dewpoint'); $this->createOption('vis_text','Translation for Visibility','text','Visibility'); $this->createOption('na_text','Translation for N/A (sometimes happends when conditions cannot be retreived)','text','Not available'); $this->createOption('unlimited_text','Translation for Unlimited (Sight)','text','Unlimited'); $this->createOption('calm_text','Translation for Calm (No wind)','text','Calm'); $this->createOption('show_icon','Show icon','yesno','yes'); $this->createOption('show_cityname','Show name of the city','yesno','yes'); $this->createOption('show_cond','Show weather conditions (only in english)','yesno','yes'); $this->createOption('show_temp','Show temperature','yesno','yes'); $this->createOption('show_feelslike','Show feels like temperature','yesno','yes'); $this->createOption('show_humidity','Show humidity','yesno','yes'); $this->createOption('show_windspeed','Show windspeed','yesno','yes'); $this->createOption('show_winddir','Show winddirection','yesno','yes'); $this->createOption('show_airpressure','Show air-pressure','yesno','yes'); $this->createOption('show_arrow','Show air-pressure arrows','yesno','yes'); $this->createOption('show_uv','Show Erythemal UV index','yesno','yes'); $this->createOption('show_dewp','Show Dew point temperature','yesno','yes'); $this->createOption('show_vis','Show Visability','yesno','yes'); //Create neccesary tables and default values for caching $query="create table if not exists ".sql_table('plugin_weatherreport')." ( id int(10) primary key default 0, value longtext default '')"; sql_query($query); $query="insert into ".sql_table('plugin_weatherreport')." (id,value) values ('1','1000')"; sql_query($query); $query="insert into ".sql_table('plugin_weatherreport')." (id,value) values ('2','')"; sql_query($query); } // SqlTablePrefix support function supportsFeature($what) { switch($what) { case 'SqlTablePrefix': return 1; default: return 0; } } //Uninstall function function unInstall() { $query="DROP TABLE IF EXISTS ".sql_table('plugin_weatherreport'); sql_query($query); } function doSkinVar($skinType) { global $blogid; //Get the weather conditions echo "\n\n"; $path = "http://xoap.weather.com/weather/local/".$this->getBlogOption($blogid,'city_id')."?cc=*&unit=".$this->getBlogOption($blogid, 'unit'); $timeout = $this-> getOption('time_out'); ini_set (default_socket_timeout, $timeout); // Read from cache? $query="select value from ".sql_table('plugin_weatherreport')." where id=1"; $result= sql_query($query); $row=mysql_fetch_object($result); $cache_timer = intval($row->value)+intval(($this->getOption('cache_timer'))); if ($cache_timer < time()) { echo "\n\n"; //Don't crash if its not XML. Generate error! $data = file_get_contents($path); if ($xml = @simplexml_load_string($data)) {} else {echo $this->getOption('error_text');} //Restore timeout settings ini_restore(default_socket_timeout); //Update cache-table $query="update ".sql_table('plugin_weatherreport')." set value='".$data."' where id=2"; sql_query($query); $query="update ".sql_table('plugin_weatherreport')." set value='".time()."' where id=1"; sql_query($query); } else { echo "\n\n"; $query="select value from ".sql_table('plugin_weatherreport')." where id=2"; $result= sql_query($query); $row=mysql_fetch_object($result); $xml=@simplexml_load_string($row->value); } //When visibility is unlimited , clear the visibility Unit if ($xml->cc->vis=="Unlimited") { $xml->cc->vis=$this->getOption('unlimited_text'); $xml->head->ud=""; } //When wind is calm, clear the wind Unit if ($xml->cc->wind->s=="Calm") { $xml->cc->wind->s=$this->getOption('calm_text'); $xml->head->us="";} // From here you can edit the layout yourself.. Make a backup first! // Icon if ($this->getOption('show_icon') == "yes") { //Show not available icon when weather information is not available. if ($xml->cc->icon == "-") { $xml->cc->icon="na"; } echo "getOption('icon_size')."/".$this->getOption('extension')."/".$xml->cc->icon.".".$this-> getOption('extension')."' alt='".$xml->cc->t."' title='".$xml->cc->t."' />
\n"; } //City Name if ($this->getOption('show_cityname') == "yes") { if ($this->getBlogOption($blogid,'city_name') <> '') { echo $this->getBlogOption($blogid,'city_name')."
\n"; } else { echo $xml->loc->dnam."
\n"; } } //var_dump($xml); //Weather conditions if ($this->getOption('show_cond') == "yes") { if ($xml->cc->t == "N/A") { $xml->cc->t=$this->getOption('na_text'); } echo $xml->cc->t."
\n"; } //Temperature if ($this->getOption('show_temp') == "yes") { echo $this->getOption('tmp_text')." ".$xml->cc->tmp." °".$xml->head->ut."
\n";} //Feels link if ($this->getOption('show_feelslike') == "yes") { echo $this->getOption('feelslike_text')." ".$xml->cc->flik." °".$xml->head->ut."
\n";} // Relative Humidity if ($this->getOption('show_humidity') == "yes") { echo $this->getOption('humidity_text')." ".$xml->cc->hmid."%
\n"; } //Windspeed if ($this->getOption('show_windspeed') == "yes") { echo $this->getOption('windspeed_text')." ".$xml->cc->wind->s." ".$xml->head->us."
\n"; } //Windspeed Direction if ($this->getOption('show_winddir') == "yes") { echo $this->getOption('winddir_text')." ".$xml->cc->wind->t."
\n"; } //Air pressure if ($this->getOption('show_airpressure') == "yes") { echo $this->getOption('airpressure_text')." ".$xml->cc->bar->r." ".$xml->head->up." "; //Show little arrows for raising and falling. if ($this->getOption('show_arrow') == "yes") {echo "cc->bar->d.".gif' title='".$xml->cc->bar->d."' alt='".$xml->cc->bar->d."' />";} echo "
\n"; } //Show UV Index if ($this->getOption('show_uv') == "yes") { echo $this->getOption('uv_text')." ".$xml->cc->uv->i."
\n";} // Show Dewpoint Temp if ($this->getOption('show_dewp') == "yes") { echo $this->getOption('dewp_text')." ".$xml->cc->dewp." ".$xml->head->ut." °
\n"; } // Visability if ($this->getOption('show_vis') == "yes") { echo $this->getOption('vis_text')." ".$xml->cc->vis." ".$xml->head->ud."
\n"; } echo "\n\n"; } } ?>