Author Topic: Current Weather Conditions?  (Read 1015 times)

0 Members and 1 Guest are viewing this topic.

Offline Anonymous

  • Newbie
  • *
  • Posts: 164653
  • Karma: +3/-4
    • View Profile
Current Weather Conditions?
« on: April 01, 2004, 04:51:00 PM »
This is probably OT anywhere I post it. On the Fornits homepage, who's weather does the "current weather conditions" reflect?

If I ever get my site up and running I'm thinking that would be a cool feature, the cascading weather (real-time, too, I'm guessing?) over the screen, so Ginger if you could point me toward the codes for that I'd be appreciative.  :nworthy:
« Last Edit: December 31, 1969, 07:00:00 PM by Guest »

Offline Antigen

  • Newbie
  • *
  • Posts: 12992
  • Karma: +3/-0
    • View Profile
    • http://wwf.Fornits.com/
Current Weather Conditions?
« Reply #1 on: April 01, 2004, 05:25:00 PM »
Well, I'd say that's OT in all but this topic
http://fornits.com/wwf/viewtopic.php?to ... m=7&Sort=D

LOL

Anyway, here's the code. As you can see, wunderground.com has changed something in their output format so that the string doesn't parse out the same way it used to. Oh well, it was just for fun anyway.


$show_weather=1;
if ($show_weather==1){
  $fh=fopen("http://www.wunderground.com/US/PA/Pittsburgh/KAGC.html","r");
  while (!feof($fh)){
  $weatherpage .= fread($fh,1024);
  }
  $weatherpage = strip_tags($weatherpage);
  $weatherpage =substr($weatherpage,strpos($weatherpage,"Observed"),strlen($weatherpage));
  $end=(strpos($weatherpage,"Visibility")-strpos($weatherpage,"Conditions"))-11;
  $weatherpage =substr($weatherpage,(strpos($weatherpage,"Conditions")+11),$end);
//  $weatherpage="rain";
  if (preg_match ("/sno/i",$weatherpage) || preg_match ("/flu/i",$weatherpage) || preg_match("/rain/i",$weatherpage)){
    $snow_no = 8; // snow number
    $snow_speed = 7; // smaller number moves the snow faster
    $snow_stx="stx = 0.02 + Math.random()/10";
    $snow_img="/wwf/images/snow2.gif";
    if (preg_match ("/sno/i",$weatherpage)){
      if (preg_match ("/lig/i",$weatherpage)){
        $snow_no = 12; // snow number
        $snow_speed = 7; // smaller number moves the snow faster
      }else if (preg_match ("/heav/i",$weatherpage)){
        $snow_no = 16; // snow number
        $snow_speed = 4; // smaller number moves the snow faster
      }else{
        $snow_no = 10; // snow number
        $snow_speed = 4; // smaller number moves the snow faster
      }
    }else if (preg_match ("/flu/i",$weatherpage)){
      if (preg_match ("/lig/i",$weatherpage)){
        $snow_no = 3; // snow number
        $snow_speed = 7; // smaller number moves the snow faster
      }else{
        $snow_no = 4; // snow number
        $snow_speed = 4; // smaller number moves the snow faster
      }
    }else if(preg_match("/rain/i",$weatherpage)){
      $snow_stx="0;";
      $snow_img="/wwf/images/raindrop.gif";
    }
?>


  }//end check for weather type
}//end check for index
?>

I have never killed a man, but I have read many obituaries with great pleasure.

--Clarence Darrow



_________________
Ginger Warbis ~ Antigen
American drug war P.O.W.
Seed sibling `71 - `80
Straight South (Sarasota, FL)
   10/80 - 10/82
Anonymity Anonymous
« Last Edit: December 31, 1969, 07:00:00 PM by Guest »
"Don\'t let the past remind us of what we are not now."
~ Crosby Stills Nash & Young, Sweet Judy Blue Eyes