diff -u weather/functions.php weather-new/functions.php --- weather/functions.php 2005-03-14 21:24:23.000000000 +0100 +++ weather-new/functions.php 2006-06-21 16:01:19.000000000 +0200 @@ -22,6 +22,21 @@ class dcWeather { + /* fonction de récupération d'URL basé sur CURL*/ + function urlopen($url) + { + $ch = curl_init(); + + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_HEADER, 0); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + + $page=curl_exec($ch); + curl_close($ch); + + return $page; + } + /* fonction d'admin : copie les fichiers necessaires dans share */ function installToShare($plugin_name,$dir) { @@ -62,9 +77,9 @@ /* fonction d'admin : retourne le resultat de la recherche dans un tableau */ function search2array ($city='Paris') { - $file = 'http://xoap.weather.com/search/search?where='.rawurlencode($city); + $url = 'http://xoap.weather.com/search/search?where='.rawurlencode($city); - $data = @implode('',@file($file)); + $data = dcWeather::urlopen($url); preg_match_all("|(.*)|U",$data,$cities); $_cities = array(); @@ -182,9 +197,9 @@ /* fonction download et ecrit le fichier xml météo */ function writeData($code) { - $file = 'http://xoap.weather.com/weather/local/'.$code.'?cc=*&unit=m'; + $url = 'http://xoap.weather.com/weather/local/'.$code.'?cc=*&unit=m'; - if ( $data = @implode('',@file($file)) ) + if ( $data = dcWeather::urlopen($url) ) { if ($out = @fopen (DC_SHARE_DIR.'/weather/codes/'.$code.'.xml','w')) {