<?php
// Initial release 070625 (YYMMDD) by SLOweather.com
// This script uses temperature in F and relative Humidity to
// calculate the Chandler Burning index and then select the
// appropriate graphic to display. It also selects the proper
// adjective for the current conditions, but this feature is not
// currently used for anything.
// As written, it requires an image pack of 5 graphics for each of
// the 5 danger levels, in the same directory as the script.
// Based on data from Anole's stickertags.txt file.
// For more information on the Chandler Burning Index:
// http://www.fs.fed.us/psw/topics/fire_science/fire_weather/mfwf/MFWFDesc.shtml
// For the Adjective Fire Danger text for each CBI level
// http://famweb.nwcg.gov/pocketcards/adjective.htm
// DATA FILE: defines the path to the data file.
// The path can be absolute or relative or a URL)!!
$data_file_path = 'http://www.victoriavalley.org/';
// get the data file
$dataraw = file_get_contents($data_file_path);
// we need put the data into an array
$data = explode(",", $dataraw);
// clean up and define the data points
(float)$ftemp = trim($data[2]);
(float)$rh = trim($data[5]);
// Convert F temp to C temp
$ctemp = ($ftemp - 32) * 0.5556;
// Start Index Calcs
// Chandler Index
$cbi = (((110 - 1.373 * $rh) - 0.54 * (10.20 - $ctemp)) * (124 * pow(10,(-0.0142*"$rh"))))/60;
// CBI = (((110 - 1.373*RH) - 0.54 * (10.20 - T)) * (124 * 10**(-0.0142*RH)))/60
//Sort out the Chandler Index
if ($cbi > "97.5") {
$cbitxt = "EXTREME";
$cbiimg= "fdl_extreme.gif";
} elseif ($cbi >="90") {
$cbitxt = "VERY HIGH";
$cbiimg= "fdl_vhigh.gif";
} elseif ($cbi >= "75") {
$cbitxt = "HIGH";
$cbiimg= "fdl_high.gif";
} elseif ($cbi >= "50") {
$cbitxt = "MODERATE";
$cbiimg= "fdl_moderate.gif";
} else
if ($cbi < "50") {
$cbitxt="LOW";
$cbiimg= "fdl_low.gif";
}
$img = imagecreatefromgif($cbiimg);
header("Content-type: image/gif");
imageGIF($img);
imagedestroy($img);
?>
I tried copying and pasting this to my webpage http://www.victoriavalley.org under weather and then detailed weather. The code shows up at the bottom of the page. It is supposed to show a fire danger icon. Also in the script, it asks where is the data file. I am trying to get the current outside temp and humidity from the page that is displayed. All files are in httpdocs. Where am I going wrong?

New Topic/Question
Reply




MultiQuote




|