Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

weather box


Guest

Recommended Posts

Hello, I added the US weather box but I can't get it to default to Honolulu Hawaii.

I change it where I assume it is to be changed but still not defaulting to Honolulu. Please take a look to see where I may have not done it right.

Thanks for the support.

 

<?php

/*

weather.php,v 1.4 2005/01/10 JeanLuc Friez

Released under the GNU General Public License

*/

function good_char($string, $left, $right){

$debut = strpos($string, $left) + strlen($left);

$longueur = strpos($string, $right) - strlen($left);

$new_string = trim( substr($string, $debut, $longueur) );

return $new_string;

}

?>

<!-- weather //-->

<tr>

<td>

<?php

// array for texts and icones

$climat = array ( "Partiellement nuageux/Vent"=>array( "french"=>"Partiellement nuageux/Vent",

"english"=>"Clouds and Wind",

"german"=>"Clouds and Wind",

"espanol"=>"Clouds and Wind",

"icone"=>"vent.gif",

"iconeNight"=>"vent.gif") ,

"Soleil/Vent"=>array( "french"=>"Soleil/Vent",

"english"=>"Sun and Wind",

"german"=>"Sun and Wind",

"espanol"=>"Sun and Wind",

"icone"=>"vent.gif",

"iconeNight"=>"vent.gif") ,

"Faibles pluies"=>array( "french"=>"Faibles pluies",

"english"=>"Light Rain",

"german"=>"Light Rain",

"espanol"=>"Light Rain",

"icone"=>"lightRainShower.gif",

"iconeNight"=>"showersNight.gif") ,

"Averses de pluie"=>array( "french"=>"Averses de pluie",

"english"=>"Showers",

"german"=>"Showers",

"espanol"=>"Showers",

"icone"=>"lightRainShower.gif",

"iconeNight"=>"showersNight.gif") ,

"Thundershowers/Wind"=>array( "french"=>"Orages/Vent",

"english"=>"Thundershowers/Wind",

"german"=>"Thundershowers/Wind",

"espanol"=>"Thundershowers/Wind",

"icone"=>"lightRainShower.gif",

"iconeNight"=>"showersNight.gif") ,

"Pluies d'orage"=>array( "french"=>"Pluies d'orage",

"english"=>"Rain and Thunderstorms",

"german"=>"Rain and Thunderstorms",

"espanol"=>"Rain and Thunderstorms",

"icone"=>"lightRainShower.gif",

"iconeNight"=>"showersNight.gif") ,

"Pluie/Tonnerre"=>array( "french"=>"Pluie/Tonnerre",

"english"=>"Rain and Thunderstorms",

"german"=>"Rain and Thunderstorms",

"espanol"=>"Rain and Thunderstorms",

"icone"=>"rain.gif",

"iconeNight"=>"showersNight.gif") ,

"Averses"=>array( "french"=>"Averses",

"english"=>"Showers",

"german"=>"Showers",

"espanol"=>"Showers",

"icone"=>"showers.gif",

"iconeNight"=>"showersNight.gif") ,

"Averses/Vent"=>array( "french"=>"Averses/Vent",

"english"=>"Showers and Wind",

"german"=>"Showers and Wind",

"espanol"=>"Showers and Wind",

"icone"=>"windShowers.gif",

"iconeNight"=>"showersNight.gif") ,

"Quelques averses"=>array( "french"=>"Quelques averses",

"english"=>"Scattered Showers",

"german"=>"Scattered Showers",

"espanol"=>"Scattered Showers",

"icone"=>"showers.gif",

"iconeNight"=>"showersNight.gif") ,

"Showers in the Vicinity"=>array( "french"=>"Averses passag?res",

"english"=>"Showers in the Vicinity",

"german"=>"Showers in the Vicinity",

"espanol"=>"Showers in the Vicinity",

"icone"=>"scatteredShowers.gif",

"iconeNight"=>"showersNight.gif") ,

"Averses passag?res"=>array( "french"=>"Averses passag?res",

"english"=>"Scattered Showers",

"german"=>"Scattered Showers",

"espanol"=>"Scattered Showers",

"icone"=>"scatteredShowers.gif",

"iconeNight"=>"showersNight.gif") ,

"Scattered Showers"=>array( "french"=>"Averses passag?res",

"english"=>"Scattered Showers",

"german"=>"Scattered Showers",

"espanol"=>"Scattered Showers",

"icone"=>"showers.gif",

"iconeNight"=>"showersNight.gif") ,

"Averses orageuses passag?res"=>array( "french"=>"Averses orageuses passag?res",

"english"=>"Scattered Thundershowers",

"german"=>"Scattered Thundershowers",

"espanol"=>"Scattered Thundershowers",

"icone"=>"scatteredThundershowers.gif",

"iconeNight"=>"thunderstormsNight.gif") ,

"L?g?res averses de neige"=>array( "french"=>"L?g?res averses de neige",

"english"=>"Light Snow Showers",

"german"=>"Light Snow Showers",

"espanol"=>"Light Snow Showers",

"icone"=>"lightSnowShowers.gif",

"iconeNight"=>"snowNight.gif") ,

"Faible neige"=>array( "french"=>"Faible neige",

"english"=>"Light Snow Showers",

"german"=>"Light Snow Showers",

"espanol"=>"Light Snow Showers",

"icone"=>"SnowShowers.gif",

"iconeNight"=>"snowNight.gif") ,

"Averses de gr?le"=>array( "french"=>"Averses de gr?le",

"english"=>"Hail",

"german"=>"Hail",

"espanol"=>"Hail",

"icone"=>"hail.gif",

"iconeNight"=>"hail.gif") ,

"Averses de neige"=>array( "french"=>"Averses de neige",

"english"=>"Snow Showers",

"german"=>"Snow Showers",

"espanol"=>"Snow Showers",

"icone"=>"snowShowers.gif",

"iconeNight"=>"snowNight.gif") ,

"Averses de neige intermittentes"=>array( "french"=>"Averses de neige intermittentes",

"english"=>"Snow Showers",

"german"=>"Snow Showers",

"espanol"=>"Snow Showers",

"icone"=>"snowShowers.gif",

"iconeNight"=>"snowNight.gif") ,

"Averses neigeuses"=>array( "french"=>"Averses neigeuses",

"english"=>"Snow Showers",

"german"=>"Snow Showers",

"espanol"=>"Snow Showers",

"icone"=>"mixedRainAndSnow.gif",

"iconeNight"=>"snowNight.gif") ,

"Snow Showers/Wind"=>array( "french"=>"Averses de Neige/Vent",

"english"=>"Snow Showers/Wind",

"german"=>"Snow Showers/Wind",

"espanol"=>"Snow Showers/Wind",

"icone"=>"windSnow.gif",

"iconeNight"=>"windSnow.gif") ,

"Pluie/Chutes de neige"=>array( "french"=>"Pluie/Chutes de neige",

"english"=>"Mixed Rain and Snow",

"german"=>"Mixed Rain and Snow",

"espanol"=>"Mixed Rain and Snow",

"icone"=>"mixedRainAndSnow.gif",

"iconeNight"=>"mixedRainAndSnow.gif") ,

"Pluie/Neige/Vent"=>array( "french"=>"Pluie/Neige/Vent",

"english"=>"Wind, Rain and Snow",

"german"=>"Wind, Rain and Snow",

"espanol"=>"Wind, Rain and Snow",

"icone"=>"windSnow.gif",

"iconeNight"=>"windSnow.gif") ,

"Pluie/Neige"=>array( "french"=>"Pluie/Neige",

"english"=>"Mixed Rain and Snow",

"german"=>"Mixed Rain and Snow",

"espanol"=>"Mixed Rain and Snow",

"icone"=>"mixedRainAndSnow.gif",

"iconeNight"=>"mixedRainAndSnow.gif") ,

"Neige"=>array( "french"=>"Neige",

"english"=>"Snow",

"german"=>"Snow",

"espanol"=>"Snow",

"icone"=>"snow.gif",

"iconeNight"=>"snowNight.gif") ,

"Pluie vergla?ante"=>array( "french"=>"Pluie vergla?ante",

"english"=>"Showers Ice",

"german"=>"Showers Ice",

"espanol"=>"Showers Ice",

"icone"=>"showersIce.gif",

"iconeNight"=>"showersIce.gif") ,

"Orages isol?s"=>array( "french"=>"Orages isol?s",

"english"=>"Isolated Thunderstorms",

"german"=>"Isolated Thunderstorms",

"espanol"=>"Isolated Thunderstorms",

"icone"=>"isolatedThunderstorms.gif",

"iconeNight"=>"thunderstormsNight.gif") ,

"Tonnerre"=>array( "french"=>"Tonnerre",

"english"=>"Isolated Thunderstorms",

"german"=>"Isolated Thunderstorms",

"espanol"=>"Isolated Thunderstorms",

"icone"=>"isolatedThunderstorms.gif",

"iconeNight"=>"thunderstormsNight.gif") ,

"Orages"=>array( "french"=>"Orages",

"english"=>"Thunderstorms",

"german"=>"Thunderstorms",

"espanol"=>"Thunderstorms",

"icone"=>"thunderstorms.gif",

"iconeNight"=>"thunderstormsNight.gif") ,

"Orages intermittents"=>array( "french"=>"Orages intermittents",

"english"=>"Thunderstorms",

"german"=>"Thunderstorms",

"espanol"=>"Thunderstorms",

"icone"=>"thunderstorms.gif",

"iconeNight"=>"thunderstormsNight.gif") ,

"L?g?re bruine"=>array( "french"=>"L?g?re bruine",

"english"=>"Light Drizzle",

"german"=>"Light Drizzle",

"espanol"=>"Light Drizzle",

"icone"=>"lightDrizzle.gif",

"iconeNight"=>"lightDrizzle.gif") ,

"Nuages ?pars"=>array( "french"=>"Nuages ?pars",

"english"=>"Partly Cloudy",

"german"=>"Partly Cloudy",

"espanol"=>"Partly Cloudy",

"icone"=>"partlyCloudy.gif",

"iconeNight"=>"partlyCloudyNight.gif"),

"Assez nuageux"=>array( "french"=>"Assez nuageux",

"english"=>"Mostly Cloudy",

"german"=>"Mostly Cloudy",

"espanol"=>"Mostly Cloudy",

"icone"=>"mostlyCloudy.gif",

"iconeNight"=>"mostlyCloudyNight.gif") ,

"Nuageux"=>array( "french"=>"Nuageux",

"english"=>"Cloudy",

"german"=>"Cloudy",

"espanol"=>"Cloudy",

"icone"=>"cloudy.gif",

"iconeNight"=>"mostlyCloudyNight.gif") ,

"Nuages et vent"=>array( "french"=>"Nuages et vent",

"english"=>"Mostly Cloudy",

"german"=>"Mostly Cloudy",

"espanol"=>"Mostly Cloudy",

"icone"=>"mostlyCloudy.gif",

"iconeNight"=>"mostlyCloudyNight.gif") ,

"Ensoleill?"=>array( "french"=>"Ensoleill?",

"english"=>"Sunny",

"german"=>"Sunny",

"espanol"=>"Sunny",

"icone"=>"sunny.gif",

"iconeNight"=>"clearNight.gif") ,

"Beau temps"=>array( "french"=>"Beau temps",

"english"=>"Mostly Sunny",

"german"=>"Mostly Sunny",

"espanol"=>"Mostly Sunny",

"icone"=>"mostlySunny.gif",

"iconeNight"=>"clearSkyNight.gif"),

"Beau temps avec du vent"=>array( "french"=>"Beau temps",

"english"=>"Mostly Sunny",

"german"=>"Mostly Sunny",

"espanol"=>"Mostly Sunny",

"icone"=>"mostlySunny.gif",

"iconeNight"=>"clearSkyNight.gif"),

"Pluie"=>array( "french"=>"Pluie",

"english"=>"Rain",

"german"=>"Rain",

"espanol"=>"Rain",

"icone"=>"rain.gif",

"iconeNight"=>"showersNight.gif") ,

"Fortes pluies"=>array( "french"=>"Fortes pluies",

"english"=>"Rain",

"german"=>"Rain",

"espanol"=>"Rain",

"icone"=>"rain.gif",

"iconeNight"=>"showersNight.gif") ,

"Pluie/Vent"=>array( "french"=>"Pluie/Vent",

"english"=>"Rain and Wind",

"german"=>"Rain and Wind",

"espanol"=>"Rain and Wind",

"icone"=>"rain.gif",

"iconeNight"=>"showersNight.gif") ,

"Brouillard"=>array( "french"=>"Brouillard",

"english"=>"Fog",

"german"=>"Fog",

"espanol"=>"Fog",

"icone"=>"fog.gif",

"iconeNight"=>"fog.gif") ,

"Brume"=>array( "french"=>"Brume",

"english"=>"Misty",

"german"=>"Misty",

"espanol"=>"Misty",

"icone"=>"fog.gif",

"iconeNight"=>"fog.gif") ,

"Brume s?che"=>array( "french"=>"Brume s?che",

"english"=>"Misty",

"german"=>"Misty",

"espanol"=>"Misty",

"icone"=>"misty.gif",

"iconeNight"=>"misty.gif") ,

"Vent"=>array( "french"=>"Vent",

"english"=>"Windy",

"german"=>"Windy",

"espanol"=>"Windy",

"icone"=>"windy.gif",

"iconeNight"=>"windy.gif") ,

"Showers Early"=>array( "french"=>"Averses matinales",

"english"=>"Showers Early",

"german"=>"Showers Early",

"espanol"=>"Showers Early",

"icone"=>"showers.gif",

"iconeNight"=>"showersNight.gif") ,

"Showers Late"=>array( "french"=>"Averses en soir?e",

"english"=>"Showers Late",

"german"=>"Showers Late",

"espanol"=>"Showers Late",

"icone"=>"showers.gif",

"iconeNight"=>"showersNight.gif") ,

"Ciel d?gag?"=>array( "french"=>"Ciel d?gag?",

"english"=>"Clear Sky",

"german"=>"Clear Sky",

"espanol"=>"Clear Sky",

"icone"=>"sunny.gif",

"iconeNight"=>"clearSkyNight.gif") ,

"D?gag?"=>array( "french"=>"D?gag?",

"english"=>"Clear Night",

"german"=>"Clear Night",

"espanol"=>"Clear Night",

"icone"=>"sunny.gif",

"iconeNight"=>"clearNight.gif") ,

"Widespread Dust"=>array( "french"=>"Poussi?re",

"english"=>"Widespread Dust",

"german"=>"Widespread Dust",

"espanol"=>"Widespread Dust",

"icone"=>"widespreadDust.gif",

"iconeNight"=>"widespreadDust.gif") ,

);

 

// array of the US towns and their "YAHOO-M?t?o" code

// Modify to have others towns (see the code in http://fr.weather.yahoo.com/meteo/)

$US_towns_array = array("Abilene"=>array("url"=>"USTX/USTX0003","hour"=>"CST"),

"Akron"=>array("url"=>"USOH/USOH0008","hour"=>"EST"),"Albuquerque"=>array("url"=>"USNM/USNM0004","hour"=>"MST"),"Allentown"=>array("url"=>"USPA/USPA0025","hour"=>"EST"),

"Amarillo"=>array("url"=>"USTX/USTX0029","hour"=>"CST"),"Anaheim"=>array("url"=>"USCA/USCA0027","hour"=>"PST"),"Anchorage"=>array("url"=>"USAK/USAK0012","hour"=>"AKT"),

"Ann Arbor"=>array("url"=>"USMI/USMI0028","hour"=>"EST"),"Aspen"=>array("url"=>"USCO/USCO0016","hour"=>"MST"),"Atlanta"=>array("url"=>"USGA/USGA0028","hour"=>"EST"),

"Atlantic City"=>array("url"=>"USNJ/USNJ0015","hour"=>"EST"),"Aurora"=>array("url"=>"USCO/USCO0019","hour"=>"MST"),"Bakersfield"=>array("url"=>"USCA/USCA0062","hour"=>"PST"),

"Baltimore"=>array("url"=>"USMD/USMD0018","hour"=>"EST"),"Baton Rouge"=>array("url"=>"USLA/USLA0033","hour"=>"CST"),"Berkeley"=>array("url"=>"USCA/USCA0087","hour"=>"PST"),

"Beverly Hills"=>array("url"=>"USCA/USCA0090","hour"=>"PST"),"Birmingham"=>array("url"=>"USAL/USAL0054","hour"=>"CST"),"Bismarck"=>array("url"=>"USND/USND0037","hour"=>"CST"),

"Boca Raton"=>array("url"=>"USFL/USFL0040","hour"=>"EST"),"Boise"=>array("url"=>"USID/USID0025","hour"=>"MST"),"Boston"=>array("url"=>"USMA/USMA0046","hour"=>"EST"),

"Boulder"=>array("url"=>"USCO/USCO0038","hour"=>"MST"),"Bridgeport"=>array("url"=>"USCT/USCT0019","hour"=>"EST"),"Brownsville"=>array("url"=>"USTX/USTX0166","hour"=>"CST"),

"Cambridge"=>array("url"=>"USMA/USMA0066","hour"=>"EST"),"Casper"=>array("url"=>"USWY/USWY0030","hour"=>"MST"),"Cedar Rapids"=>array("url"=>"USIA/USIA0138","hour"=>"CST"),

"Charleston"=>array("url"=>"USSC/USSC0051","hour"=>"EST"),"Charlotte"=>array("url"=>"USNC/USNC0121","hour"=>"EST"),"Cattanooga"=>array("url"=>"USTN/USTN0084","hour"=>"EST"),

"Chesapeake"=>array("url"=>"USVA/USVA0148","hour"=>"EST"),"Cheyenne"=>array("url"=>"USWY/USWY0032","hour"=>"MST"),"Chicago"=>array("url"=>"USIL/USIL0225","hour"=>"CST"),

"Chula Vista"=>array("url"=>"USCA/USCA0219","hour"=>"PST"),"Cincinnati"=>array("url"=>"USOH/USOH0188","hour"=>"EST"),"Clearwater"=>array("url"=>"USFL/USFL0084","hour"=>"EST"),

"Cleveland"=>array("url"=>"USOH/USOH0195","hour"=>"EST"),"Colorado Springs"=>array("url"=>"USCO/USCO0078","hour"=>"MST"),"Columbia"=>array("url"=>"USSC/USSC0065","hour"=>"EST"),

"Corpus Christi"=>array("url"=>"USTX/USTX0294","hour"=>"CST"),"Dallas"=>array("url"=>"USTX/USTX0327","hour"=>"CST"),"Dayton"=>array("url"=>"USOH/USOH0245","hour"=>"EST"),

"Daytona Beach"=>array("url"=>"USFL/USFL0106","hour"=>"EST"),"Denver"=>array("url"=>"USCO/USCO0105","hour"=>"MST"),"Des Moines"=>array("url"=>"USIA/USIA0231","hour"=>"CST"),

"Detroit"=>array("url"=>"USMI/USMI0229","hour"=>"EST"),"Dothan"=>array("url"=>"USAL/USAL0162","hour"=>"CST"),"Durham"=>array("url"=>"USNC/USNC0192","hour"=>"EST"),

"El Monte"=>array("url"=>"USCA/USCA0338","hour"=>"PST"),"El Paso"=>array("url"=>"USTX/USTX0413","hour"=>"MST"),"Elisabeth"=>array("url"=>"USNJ/USNJ0134","hour"=>"EST"),

"Erie"=>array("url"=>"USPA/USPA0509","hour"=>"EST"),"Escondido"=>array("url"=>"USCA/USCA0356","hour"=>"PST"),"Eugene"=>array("url"=>"USOR/USOR0118","hour"=>"PST"),

"Evansville"=>array("url"=>"USIN/USIN0190","hour"=>"CST"),"Fairbanks"=>array("url"=>"USAK/USAK0083","hour"=>"AKT"),"Flagstaff"=>array("url"=>"USAZ/USAZ0068","hour"=>"MST"),

"Flint"=>array("url"=>"USMI/USMI0295","hour"=>"EST"),"Fort Lauderdale"=>array("url"=>"USFL/USFL0149","hour"=>"EST"),"Fort Smith"=>array("url"=>"USAR/USAR0197","hour"=>"CST"),

"Fort Wayne"=>array("url"=>"USIN/USIN0211","hour"=>"EST"),"Fort Worth"=>array("url"=>"USTX/USTX0474","hour"=>"CST"),"Fremont"=>array("url"=>"USCA/USCA0403","hour"=>"PST"),

"Freno"=>array("url"=>"USCA/USCA0406","hour"=>"PST"),"Fullerton"=>array("url"=>"USCA/USCA0408","hour"=>"PST"),"Garden Grove"=>array("url"=>"USCA/USCA0412","hour"=>"PST"),

"Gary"=>array("url"=>"USIN/USIN0233","hour"=>"CST"),"Glendale"=>array("url"=>"USAZ/USAZ0083","hour"=>"MST"),"Grand Prairie"=>array("url"=>"USTX/USTX0542","hour"=>"CST"),

"Grand Rapids"=>array("url"=>"USMI/USMI0344","hour"=>"EST"),"Greensboro"=>array("url"=>"USNC/USNC0280","hour"=>"EST"),"Hampton"=>array("url"=>"USVA/USVA0345","hour"=>"EST"),

"Hartford"=>array("url"=>"USCT/USCT0094","hour"=>"EST"),"Hayward"=>array("url"=>"USCA/USCA0470","hour"=>"PST"),"Hialeah"=>array("url"=>"USFL/USFL0196","hour"=>"EST"),

"Hollywood"=>array("url"=>"USFL/USFL0204","hour"=>"EST"),"Honolulu"=>array("url"=>"USHI/USHI0026","hour"=>"HST"),"Houston"=>array("url"=>"USTX/USTX0617","hour"=>"CST"),

"Huntington Beach"=>array("url"=>"USCA/USCA0500","hour"=>"PST"),"Huntsville"=>array("url"=>"USAL/USAL0287","hour"=>"CST"),"Independence"=>array("url"=>"USMO/USMO0441","hour"=>"CST"),

"Indianapolis"=>array("url"=>"USIN/USIN0305","hour"=>"EST"),"Inglewood"=>array("url"=>"USCA/USCA0513","hour"=>"PST"),"Irvine"=>array("url"=>"USCA/USCA0517","hour"=>"PST"),

"Irving"=>array("url"=>"USTX/USTX0646","hour"=>"CST"),"Jersey City"=>array("url"=>"USNJ/USNJ0234","hour"=>"EST"),"Jonesboro"=>array("url"=>"USAR/USAR0304","hour"=>"CST"),

"Kansas City"=>array("url"=>"USKS/USKS0298","hour"=>"CST"),"Key West"=>array("url"=>"USFL/USFL0244","hour"=>"EST"),"Killington"=>array("url"=>"USVT/USVT0125","hour"=>"EST"),

"Lansing"=>array("url"=>"USMI/USMI0477","hour"=>"EST"),"Laredo"=>array("url"=>"/USTX/USTX0737","hour"=>"CST"),"Las Vegas"=>array("url"=>"USNV/USNV0049","hour"=>"PST"),

"Lexington"=>array("url"=>"USKY/USKY1079","hour"=>"EST"),"Lincoln"=>array("url"=>"USNE/USNE0283","hour"=>"CST"),"Little Rock"=>array("url"=>"USAR/USAR0336","hour"=>"CST"),

"Livonia"=>array("url"=>"USMI/USMI0496","hour"=>"EST"),"Long Beach"=>array("url"=>"USCA/USCA0632","hour"=>"PST"),"Los Angeles"=>array("url"=>"USCA/USCA0638","hour"=>"PST"),

"Louisville"=>array("url"=>"USKY/USKY1096","hour"=>"EST"),"Lowell"=>array("url"=>"USMA/USMA0223","hour"=>"EST"),"Lubbock"=>array("url"=>"USTX/USTX0808","hour"=>"CST"),

"Macon"=>array("url"=>"USGA/USGA0346","hour"=>"EST"),"Madison"=>array("url"=>"USWI/USWI0411","hour"=>"CST"),"Manchester"=>array("url"=>"USNH/USNH0136","hour"=>"EST"),

"Memphis"=>array("url"=>"USTN/USTN0325","hour"=>"CST"),"Mesa"=>array("url"=>"USAZ/USAZ0136","hour"=>"MST"),"Mesquite"=>array("url"=>"USTX/USTX0881","hour"=>"CST"),

"Miami"=>array("url"=>"USFL/USFL0316","hour"=>"EST"),"Milwaukee"=>array("url"=>"USWI/USWI0455","hour"=>"CST"),"Minneapolis"=>array("url"=>"USMN/USMN0503","hour"=>"CST"),

"Mobile"=>array("url"=>"USAL/USAL0371","hour"=>"CST"),"Modesto"=>array("url"=>"USCA/USCA0714","hour"=>"PST"),"Montgomery"=>array("url"=>"USAL/USAL0375","hour"=>"CST"),

"Montpelier"=>array("url"=>"USVT/USVT0147","hour"=>"EST"),"Moreno Valley"=>array("url"=>"USCA/USCA0730","hour"=>"PST"),"Mountain View"=>array("url"=>"USCA/USCA0746","hour"=>"PST"),

"Napa"=>array("url"=>"USCA/USCA0750","hour"=>"PST"),"Naples"=>array("url"=>"USFL/USFL0338","hour"=>"EST"),"Nashville"=>array("url"=>"USTN/USTN0357","hour"=>"CST"),

"New Bedford"=>array("url"=>"USMA/USMA0275","hour"=>"EST"),"New Haven"=>array("url"=>"USCT/USCT0135","hour"=>"EST"),"Nouvelle Orleans"=>array("url"=>"USLA/USLA0338","hour"=>"CST"),

"New York City"=>array("url"=>"USNY/USNY0996","hour"=>"EST"),"Newport News"=>array("url"=>"USVA/USVA0550","hour"=>"EST"),"Oakland"=>array("url"=>"USCA/USCA0791","hour"=>"PST"),

"Oceanside"=>array("url"=>"USCA/USCA0797","hour"=>"PST"),"Oklahoma City"=>array("url"=>"USOK/USOK0400","hour"=>"CST"),"Omaha"=>array("url"=>"USNE/USNE0363","hour"=>"CST"),

"Ontario"=>array("url"=>"USCA/USCA0806","hour"=>"PST"),"Orange"=>array("url"=>"USCA/USCA0808","hour"=>"PST"),"Orlando"=>array("url"=>"USFL/USFL0372","hour"=>"EST"),

"Overland Park"=>array("url"=>"USKS/USKS0450","hour"=>"CST"),"Oxnard"=>array("url"=>"USCA/USCA0819","hour"=>"PST"),"Palo Alto"=>array("url"=>"USCA/USCA0830","hour"=>"PST"),

"Pasadena"=>array("url"=>"USCA/USCA0840","hour"=>"PST"),"Paterson"=>array("url"=>"USNJ/USNJ0393","hour"=>"EST"),"Philadelphia"=>array("url"=>"USPA/USPA1276","hour"=>"EST"),

"Phoenix"=>array("url"=>"USAZ/USAZ0166","hour"=>"MST"),"Pittsburgh"=>array("url"=>"USPA/USPA1290","hour"=>"EST"),"Plano"=>array("url"=>"USTX/USTX1060","hour"=>"CST"),

"Pomona"=>array("url"=>"USCA/USCA0889","hour"=>"PST"),"Portland"=>array("url"=>"USME/USME0328","hour"=>"EST"),"Portsmouth"=>array("url"=>"USNH/USNH0191","hour"=>"EST"),

"Providence"=>array("url"=>"USRI/USRI0050","hour"=>"EST"),"Pueblo"=>array("url"=>"USCO/USCO0323","hour"=>"MST"),"Raleigh"=>array("url"=>"USNC/USNC0558","hour"=>"EST"),

"Rancho Cucamunga"=>array("url"=>"USCA/USCA0911","hour"=>"PST"),"Reno"=>array("url"=>"USNV/USNV0076","hour"=>"PST"),"Riverside"=>array("url"=>"USCA/USCA0949","hour"=>"PST"),

"Rockford"=>array("url"=>"USIL/USIL1013","hour"=>"CST"),"Sacramento"=>array("url"=>"USCA/USCA0967","hour"=>"PST"),"Saint Louis"=>array("url"=>"USMO/USMO0787","hour"=>"CST"),

"Saint Paul"=>array("url"=>"USMN/USMN0664","hour"=>"CST"),"Saint Petersburg"=>array("url"=>"USFL/USFL0438","hour"=>"EST"),"Salinas"=>array("url"=>"USCA/USCA0971","hour"=>"PST"),

"Salt Lake City"=>array("url"=>"USUT/USUT0225","hour"=>"MST"),"San Antonio"=>array("url"=>"USTX/USTX1200","hour"=>"CST"),"San Bernadino"=>array("url"=>"USCA/USCA0978","hour"=>"PST"),

"San Diego"=>array("url"=>"USCA/USCA0982","hour"=>"PST"),"san Francisco"=>array("url"=>"USCA/USCA0987","hour"=>"PST"),"San Jose"=>array("url"=>"USCA/USCA0993","hour"=>"PST"),

"Santa Ana"=>array("url"=>"USCA/USCA1016","hour"=>"PST"),"Santa Barbara"=>array("url"=>"USCA/USCA1017","hour"=>"PST"),"Santa Clarita"=>array("url"=>"USCA/USCA1019","hour"=>"PST"),

"Santa Fe"=>array("url"=>"USNM/USNM0292","hour"=>"MST"),"Santa Monica"=>array("url"=>"USCA/USCA1024","hour"=>"PST"),"Santa Rosa"=>array("url"=>"USCA/USCA1027","hour"=>"PST"),

"Savannah"=>array("url"=>"USGA/USGA0506","hour"=>"EST"),"Scottsdale"=>array("url"=>"USAZ/USAZ0207","hour"=>"MST"),"Seattle"=>array("url"=>"USWA/USWA0395","hour"=>"PST"),

"Shreveport"=>array("url"=>"USLA/USLA0426","hour"=>"CST"),"Simi Valley"=>array("url"=>"USCA/USCA1060","hour"=>"PST"),"Sioux Falls"=>array("url"=>"USSD/USSD0315","hour"=>"CST"),

"South Bend"=>array("url"=>"USIN/USIN0624","hour"=>"EST"),"Spokane"=>array("url"=>"USWA/USWA0422","hour"=>"PST"),"Stamford"=>array("url"=>"USCT/USCT0218","hour"=>"EST"),

"Sterling Heights"=>array("url"=>"USMI/USMI0808","hour"=>"EST"),"Stockton"=>array("url"=>"USCA/USCA1100","hour"=>"PST"),"Sunnyvale"=>array("url"=>"USCA/USCA1116","hour"=>"PST"),

"Syracuse"=>array("url"=>"USNY/USNY1434","hour"=>"EST"),"Tacoma"=>array("url"=>"USWA/USWA0441","hour"=>"PST"),"Tallahassee"=>array("url"=>"USFL/USFL0479","hour"=>"EST"),

"Tampa"=>array("url"=>"USFL/USFL0481","hour"=>"EST"),"Tempe"=>array("url"=>"USAZ/USAZ0233","hour"=>"MST"),"Thousand Oaks"=>array("url"=>"USCA/USCA1144","hour"=>"PST"),

"Toledo"=>array("url"=>"USOH/USOH0953","hour"=>"EST"),"Topeka"=>array("url"=>"USKS/USKS0571","hour"=>"CST"),"Torrance"=>array("url"=>"USCA/USCA1153","hour"=>"PST"),

"Tucson"=>array("url"=>"USAZ/USAZ0247","hour"=>"MST"),"Tulsa"=>array("url"=>"USOK/USOK0537","hour"=>"CST"),"Tuscaloosa"=>array("url"=>"USAL/USAL0542","hour"=>"CST"),

"Vail"=>array("url"=>"USCO/USCO0388","hour"=>"MST"),"Vallejo"=>array("url"=>"USCA/USCA1184","hour"=>"PST"),"Virginia Beach"=>array("url"=>"USVA/USVA0797","hour"=>"EST"),

"Waco"=>array("url"=>"USTX/USTX1413","hour"=>"CST"),"Washington, DC"=>array("url"=>"USDC/USDC0001","hour"=>"EST"),"Waterbury"=>array("url"=>"USCT/USCT0242","hour"=>"EST"),

"Wichita"=>array("url"=>"USKS/USKS0620","hour"=>"CST"),"Winston-Salem"=>array("url"=>"USNC/USNC0767","hour"=>"EST"),"Worcester"=>array("url"=>"USMA/USMA0502","hour"=>"EST"),

"Yonkers"=>array("url"=>"USNY/USNY1629","hour"=>"EST"),"Yuma"=>array("url"=>"USAZ/USAZ0275","hour"=>"MST")

);

 

// The array of the US towns re-arrange for the dropdown menu

$US_towns = array();

foreach ($US_towns_array as $key => $value) {

$US_towns[] = array('id' => $value['url'], 'text' => $key );

}

 

// We get the parameters of URLs of the page we are

$hidden_get_variables = '';

reset($HTTP_GET_VARS);

while (list($key, $value) = each($HTTP_GET_VARS)) {

if ( ($key != tep_session_name()) && ($key != 'x') && ($key != 'y') && ($key != 'choix_ville') ) {

$hidden_get_variables .= tep_draw_hidden_field($key, $value);

}

}

 

// Check if a town has been choose and if the 'weather_session' exists else we choose the default town (Honolulu) - Change it if you want other

if(!isset($choix_ville) && !tep_session_is_registered('weather_session')) $choix_ville = 'USDC/USDC0001';

// if there is an other form working than 'weather'

if(!isset($choix_ville) && tep_session_is_registered('weather_session')) $choix_ville = $weather_session['choix_ville_session'];

// get the hour code of the choosen town (EST, PST, AKT, MST...)

foreach ($US_towns_array as $key => $value) {

if ( $value['url'] == $choix_ville) {

$hour_code = $value['hour'];

}

}

if ( tep_session_is_registered('weather_session') && $choix_ville == $weather_session['choix_ville_session'] ) {

// If no changes in the weather_box, we take the data in the session (So just 1 query by session in the Yahoo site if the visitor doesn't choose another town in the box)

$info_box_contents = array();

$info_box_contents[] = array('text' => BOX_HEADING_WEATHER_BOX . $weather_session['ville']);

 

new infoBoxHeading($info_box_contents, false, false);

 

$weather_string = $weather_session['ville'] . '<br>';

$weather_string .= $weather_session['etat'][$language] . '<br>';

if ($weather_session['night'] == false) { //Test to know which icone we must take (day or night)

$weather_string .= tep_image(DIR_WS_IMAGES . 'weather/' . $weather_session['etat']['icone'], $weather_session['etat'][$language]) . '<br>';

} else {

$weather_string .= tep_image(DIR_WS_IMAGES . 'weather/' . $weather_session['etat']['iconeNight'], $weather_session['etat'][$language]) . '<br>';

}

$weather_string .= $weather_session['temperature'] . '<br><br>';

 

$info_box_contents = array();

$info_box_contents[] = array('form' => tep_draw_form('weather', tep_href_link(basename($PHP_SELF), '', $request_type, false), 'get'),

'align' => 'center',

'text' => $weather_string.tep_draw_pull_down_menu('choix_ville', $US_towns, '', 'onchange="this.form.submit();"') . $hidden_get_variables . tep_hide_session_id());

 

new infoBox($info_box_contents);

 

 

}else{ //Not yet a session OR choice of a new town in the weatherbox

 

$filename="http://fr.weather.yahoo.com/".$choix_ville."/index_f.html";

$fp=@file_get_contents($filename,"r") ;

$chaine = $fp;

# -------------------- Town --------------------#

$left = "<font face=Arial><big><b>Yahoo! M?t?o - ";

$right = '</b></big></font></td><td align=right';

if (strstr($chaine, $left) && strstr($chaine, $right)){

$chaine = strstr($chaine, $left);

$ville = good_char($chaine, $left, $right);

}

# -------------------- TEMPERATURE --------------------#

$left = '<tr><td align=center nowrap><font size=+2 face=Arial><b>';

$right = "</b></font></td></tr>";

if (strstr($chaine, $left)){

$chaine = strstr($chaine, $left);

$temperature = good_char($chaine, $left, $right) . ' Farenheit';

}

# -------------------- THE MOMENT THE TEMPERATURES ARE MESURED--------------------#

$left = "<tr><td align=center><font size=-2 face=Arial>";

$right = $hour_code."<br>";

if (strstr($chaine, $left)){

$chaine = strstr($chaine, $left);

$moment = good_char($chaine, $left, $right);

}

# -------------------- THE SKY --------------------#

$left = '<font size=-2 face="Arial,Helvetica">';

$right = "</font></td> <td align=center";

if (strstr($chaine, $left)){

$chaine = strstr($chaine, $left);

$etat = good_char($chaine, $left, $right);

}

# -------------------- NIGHT/JDAY --------------------#

$left = "Lever?du?soleil?:</font></td><td><font size=-1>";

$right = "</font></td></tr>";

if (strstr($chaine, $left)) {

$chaine = strstr($chaine, $left);

$leverSoleil = good_char($chaine, $left, $right);

}

$left = "Coucher?du?soleil?</font></td><td><font size=-1>";

$right = "</font></td></tr>";

if ( strstr($chaine, $left) ) {

$chaine = strstr($chaine, $left);

$coucherSoleil = good_char($chaine, $left, $right);

}

// Was there night or day when the temperatures were mesured

if ( (array_key_exists($etat, $climat) ) && ( $leverSoleil != '' || $coucherSoleil != '' ) ) {

$leverSoleilNumeric = 0 + str_replace(":", ".", $leverSoleil);

$coucherSoleilNumeric = 0 + str_replace(":", ".", $coucherSoleil);

$momentNumeric = 0 + str_replace(":", ".", $moment);

// Depending the moment, we choose the night or day icone.

if ( ($momentNumeric > $leverSoleilNumeric) && ($momentNumeric < $coucherSoleilNumeric) ) {

$icone = $climat[$etat]['icone'];

$night = false ;

} else {

$icone = $climat[$etat]['iconeNight'];

$night = true ;

}

}

if ( $leverSoleil=='' || $coucherSoleil=='' ) { // Sometimes, the hours are not given...

$icone = $climat[$etat]['icone']; // so default day icone...

$night = false ;

}

 

tep_session_register('weather_session');

$weather_session = array();

$weather_session = array ("choix_ville_session"=>$choix_ville,

"ville"=>$ville,

"temperature"=>$temperature,

"etat"=>$climat[$etat],

"night"=>$night);

 

$info_box_contents = array();

$info_box_contents[] = array('text' => BOX_HEADING_WEATHER_BOX . $ville);

 

new infoBoxHeading($info_box_contents, false, false);

 

$weather_string = $ville . '<br>';

$weather_string .= $climat[$etat][$language] . '<br>';

$weather_string .= tep_image(DIR_WS_IMAGES . 'weather/' . $icone, $climat[$etat][$language]) . '<br>';

$weather_string .= $temperature . '<br><br>';

 

$info_box_contents = array();

$info_box_contents[] = array('form' => tep_draw_form('weather', tep_href_link(basename($PHP_SELF), '', $request_type, false), 'get'),

'align' => 'center',

'text' => $weather_string.tep_draw_pull_down_menu('choix_ville', $US_towns, '', 'onchange="this.form.submit();"') . $hidden_get_variables . tep_hide_session_id());

 

new infoBox($info_box_contents);

}

?>

</td>

</tr>

<!-- weather_eof //-->

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...