Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Contribution help


olliel

Recommended Posts

Posted

Hi there, I'm working on editing the contribution 2641 which is a Weather Box, by JeanLuc Friez. I've worked out how to add the extra areas with the codes, but I am struggling to change to target to Uk yahoo rather than fr.yahoo.com. I'll paste the code and see if anyone can help me, it's rather long.

 

// 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 (Washington, DC below) - 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 //-->

Posted

i've tried changing this :

$filename="http://fr.weather.yahoo.com/".$choix_ville."/index_f.html"; 
	$fp=@file_get_contents($filename,"r"); 
	$chaine = $fp;

to this

$filename="http://uk.weather.yahoo.com/".$choix_ville."/index_c.html"; 
	$fp=@file_get_contents($filename,"r"); 
	$chaine = $fp;

 

But this doesn''t work.

Posted

its not going to work like this. You have to change the entire array to reference the UK.

 

for example you should have

 

$british_towns_array = array("Abbey"=>"UKXX1294, "Abbey Hey" => "UKXX1690"......................etc.,

 

then for the $filename use

 

$filename="http://uk.weather.yahoo.com/UKXX/".$choix_ville."/index_c.html";

 

should be easier to modify the french version I think.

Posted
its not going to work like this. You have to change the entire array to reference the UK.

 

for example you should have

 

$british_towns_array = array("Abbey"=>"UKXX1294, "Abbey Hey" => "UKXX1690"......................etc.,

 

then for the $filename use

 

$filename="http://uk.weather.yahoo.com/UKXX/".$choix_ville."/index_c.html";

 

should be easier to modify the french version I think.

 

Should I bother changing the $climat = array ? I think i should be able to do this, and if it works, will I able to offer it as a contribution? Thankyou

Posted

the $climat is used for some icons and stuff. I think the US version uses exactly the same array. So deal with it last if you see any other problems. One other thing is the default town you may want to also change

 

if(!isset($choix_ville) && !tep_session_is_registered('weather_session')) $choix_ville = 'FRXX0068';

 

Just put one from the UK. This is loaded when no town is specified I think.

Posted

I am now getting a blank dropdown in my infobox. Below is the code.

 

// A modifier pour avoir des villes diff?rentes (voir le code correspondant sur http://fr.weather.yahoo.com/meteo/)
$british_towns_array = array("Abbey"=>"UKXX1294","Abbey Hey"=>"UKXX1690","Leeds"=>"UKXX0078","Vichy"=>"FRXX0177","Vienne"=>"FRXX0107","Vierzon"=>"FRXX0108","Villeurbanne"=>"FRXX0110" );

// Le tableau des villes mis en forme pour le formulaire avec le menu de choix des villes
$british_towns = array();
foreach ($british_towns_array as $key => $value) {
	$british_towns[] = array('id' => $value, 'text' => $key );
}

// On r?cup?re les param?tres d'URL de la page dans laquelle on se trouve...
$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);
}
}

// on teste si une ville a ?t? choisie et si la session 'weather_session' existe sinon on prend Montpellier par d?faut (changez le code ? votre convenance)  
if(!isset($choix_ville) && !tep_session_is_registered('weather_session')) $choix_ville = 'FRXX0068';
// au cas o? on a lanc? un autre formulaire que celui de la weather_box
if(!isset($choix_ville) && tep_session_is_registered('weather_session')) $choix_ville = $weather_session['choix_ville_session'];

if ( tep_session_is_registered('weather_session') && $choix_ville == $weather_session['choix_ville_session'] ) {
// Si pas de modification dans weather_box, on prend les donn?es stock?es dans la session (donc requ?te ? Yahoo 1 seule fois par session si on ne change pas de ville dans la boxe)
$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) { //on teste pour savoir quelle ic?ne on prend (nuit ou jour)
		$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', $french_towns, '', 'onchange="this.form.submit();"') . $hidden_get_variables . tep_hide_session_id());

new infoBox($info_box_contents);


}else{	//Pas encore de session OU choix d'une nouvelle ville dans la weather_box

	$filename="http://uk.weather.yahoo.com/UKXX/".$choix_ville."/index_c.html"; 
	$fp=@file_get_contents($filename,"r"); 
	$chaine = $fp; 
	# -------------------- Ville --------------------#  
	$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) . ' Celsius';  
	}
	# -------------------- LE MOMENT DE PRELEVEMENT DES TEMPERATURES --------------------# 
	$left = "<tr><td align=center><font size=-2 face=Arial>"; 
	$right = "CET<br>"; 
	if (strstr($chaine, $left)){
		$chaine = strstr($chaine, $left); 
		$moment = good_char($chaine, $left, $right);
	}
	# -------------------- ETAT DU CIEL --------------------# 
	$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); 
	}
	# -------------------- NUIT/JOUR --------------------# 
	$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);
	}
	// On d?termine si c'?tait la nuit ou le jour au moment du pr?l?vement de la temp?rature
	if ( (array_key_exists($etat, $climat) ) && ( $leverSoleil != '' || $coucherSoleil != '' ) ) {
			$leverSoleilNumeric = 0 + str_replace(":", ".", $leverSoleil);
			$coucherSoleilNumeric = 0 + str_replace(":", ".", $coucherSoleil);
			$momentNumeric = 0 + str_replace(":", ".", $moment);
			// Selon le cas, on prend les ic?nes de nuit ou de jour.		
			if ( ($momentNumeric > $leverSoleilNumeric) && ($momentNumeric < $coucherSoleilNumeric) ) {
					$icone = $climat[$etat]['icone'];
					$night = false;
			} else {
					$icone = $climat[$etat]['iconeNight'];
					$night = true;
			}	
	}
	if ( $leverSoleil=='' || $coucherSoleil=='' ) {	// Parfois les heures de lever et de coucher du soleil ne sont pas donn?es... 
			$icone = $climat[$etat]['icone'];	// donc icone de jour par d?faut...
			$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', $french_towns, '', 'onchange="this.form.submit();"') . $hidden_get_variables . tep_hide_session_id());

new infoBox($info_box_contents);}
?>
		</td>
	  </tr>
<!-- weather_eof //-->

 

I have a feeling that the language barrier is causing an error. Should I change the $climat=array ?

 

thankyou

Posted

you need the starting code for the info box like in the US/French boxes where is it? For the $climat array I meant leave it as is till you've done everything else.

Posted
you need the starting code for the info box like in the US/French boxes where is it? For the $climat array I meant leave it as is till you've done everything else.

 

i'm almost there. I've got it linking with yahoo, but the images aren't working. My images are held in catalog/images/weather, but the code says;

 

DIR_WS_IMAGES . 'weather/

Should this be

DIR_WS_IMAGES . '/images/weather/

?

 

Thankyou

Posted

no because the DIR_WS_IMAGES should already be defined in your configure.php like this:

define('DIR_WS_IMAGES', 'images/');

Posted
no because the DIR_WS_IMAGES should already be defined in your configure.php like this:

define('DIR_WS_IMAGES', 'images/');

 

I think I'm going to have to change the $climat array, because it is not understanding the different variables, i.e. windy and misty. Instead it is looking for the french for these, shall I translate these, for example;

 

"Vent"=>array( "french"=>"Vent",
																"english"=>"Windy",
																 "german"=>"Windy",
																"espanol"=>"Windy",
																  "icone"=>"windy.gif",
																	 "iconeNight"=>"windy.gif") ,

 

Would go to;

 

"Windy"=>array( "english"=>"Windy",
																"french"=>"Vent",
																 "german"=>"Windy",
																"espanol"=>"Windy",
																  "icone"=>"windy.gif",
																	 "iconeNight"=>"windy.gif") ,

?

Posted

you need to change the first part but you shouldn't need to rearrange the order

 

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

 

to

 

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

 

that should take care of the strings, and then for the icons the individual vent.gif for instance make sure its valid ( I believe it should)

Posted
you need to change the first part but you shouldn't need to rearrange the order

 

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

 

to

 

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

 

that should take care of the strings, and then for the icons the individual vent.gif for instance make sure its valid ( I believe it should)

 

That's solved it all, although it still does come up with a white box and rec cross image now and then! Nevermind, its almost there. Thankyou.

Posted

ok replace the strings and when it comes with a white box see if you can add some debug code to see what's happening. Is it possible that it cannot connect to the server to get the datat?

Posted
ok replace the strings and when it comes with a white box see if you can add some debug code to see what's happening. Is it possible that it cannot connect to the server to get the datat?

 

I've put it down to a connection problem, because if you try it later, it works. Thankyou,.

Archived

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

×
×
  • Create New...