PHPBuilder - Script

RSS Twitter
Snippets Script

by: Steven Chalker
February 15, 2003

Version: 5.1

Type: Sample Code (HOWTO)

Category: HTTP

License: GNU General Public License

Description: this little script in a class will show you everything on the weather including Barometer and text forecasts splitting \n so you can replace \n with <BR>. borrowed some of the code from a site and really changed to make it so it was from scratch

// VERSION: 5.1
// BY: lentin64
// CHANGES: Gets from wunderground,
//, and yahoo! weather
// Changed: Dec 19, 2002
// DESCRIPTION: Read changes.
// Now doesn't get from anymore
// City, State coming soon, stick with
// the ZIP CODE thingy for now
if($idalert != "") {
$rr=join('',file("".$idalert)) or die("Could not open file!");
if(eregi('<TD CLASS="blkVerdanaText11">(.*)</TD>',$rr,$m)) {
$m[1]=str_replace("Close this window","",$m[1]);
echo "<A HREF='javascript:history.back()'>Back</A><BR>".$m[1]."<BR><A HREF='javascript:history.back(1)'>Back</A>"; exit;
} else {
echo "Could not get Advisory #".$idalert."!"; exit;
if($zip != "") {
    echo "<FORM ACTION='$PHP_SELF' ACTION=get>";
    echo "Zip Code: <INPUT TYPE=text NAME=zip MAXLENGTH=5><BR>";
    echo "<INPUT TYPE=submit VALUE='Get Weather'>"; exit;
echo "<font size=5>Current Conditions for ".$data[18].", ".$data[19].":</font><BR>";
echo "<table><tr><td>Currently ".$data[8]."</td><td width=37%>The Temperature is now ".$data[1]." F</td></tr></table><BR>";
if(eregi("var marqueecontents=\"(.*)</font>\"",$weathercom,$m)) {
$m[1]=str_replace(" [More Details]","",$m[1]);
echo "Advisory(s):<BR>";
echo "<SCRIPT> document.write(\"".$m[1]."\"); </SCRIPT>";
echo "<TABLE>\n";
if($data[2] != "N/A") {
echo "<TR><TD>Wind Chill</TD><TD width=50%>".$data[2]."F</TD></TR>\n";
if($data[3] != "N/A") {
echo "<TR><TD>Heat Index</TD><TD width=50%>".$data[3]."F</TD></TR>\n";
echo "<TR><TD>Humidity</TD><TD width=50%>".$data[4]."</TD></TR>\n";
echo "<TR><TD>Dew Point</TD><TD width=50%>".$data[5]."</TD></TR>\n";
echo "<TR><TD>Wind</TD><TD width=50%>From the ".$data[6]." MPH</TD></TR>\n";
echo "<TR><TD>Barometer</TD><TD width=50%>".$data[7]."</TD></TR>\n";
echo "<TR><TD>Visibility</TD><TD width=50%>".$data[9]." Miles (1=bad, 10=good)</TD></TR>\n";
echo "<TR><TD>Sunrise</TD><TD width=50%>".$data[10]."</td></tr>\n";
echo "<TR><TD>Sun Set</TD><TD width=50%>".$data[11]."</td></tr>\n";
echo "</table><BR><BR>";
echo "<FONT size=5>Radar</FONT><BR>";
if($po == "animate") {
echo "<TABLE><TR><TD><IMG SRC='";
echo "";
echo "=".$zip."&height=270&width=360' width=360 height=270>";
echo "</TD><TD width=50%><A HREF='?zip=".$zip."&po=static'>Static Radar</A></td></tr></table>";
} else {
echo "<TABLE><TR><TD><IMG SRC='";
echo "";
echo "bin/interradzipstaticrain?zipcode=".$zip;
echo "&height=270&width=360' WIDTH=360 height=270></TD>";
echo "<TD width=50%><A HREF='?zip=".$zip."&po=animate'>Animated Radar</A></td></tr></table>";
echo "<BR><BR>";
echo "<font size=5>Forecast</font><BR>";
if(eregi("<!----------------------- FORECAST ------------------------->(.*)<!--ENDFC-->",$ch,$mm)) {
$detailed=str_replace('<td width="17%" align=center><font face=Arial size=2><b>6-10 Day</b></font></td>','',$detailed);
$detailed=str_replace('<a href="*">Extended Forecast at</a>','',$detailed);
echo $detailed."<BR><BR>";
if(eregi("<!--TEXT FORECAST-->(.*)<!--ENDTEXT FORECAST-->",$ch,$mm)){
echo $mm[1];
} ?>

Comment and Contribute

Your comment has been submitted and is pending approval.

Steven Chalker



(Maximum characters: 1200). You have characters left.