Monday, February 6th, 2012

Weather Script v.2
Root page of JMan's Bedpan
A short little bio of JMan and JMan's Bedpan
Some PHP scripts that JMan has written, for public use. MSN Emoticons, Weather, Webcam, Latest Version, Cache, HotScripts
Other random stuff that doesnt belong on any other page. Family Feud Cheat, I *Heart* James, Stupidest Famous Last Words, Funny Search Engine Queries, Funny Euphemisms
Rants by Blakey
A bunch of useful links
. : : Local Weather Forecast

Use it? Show me.


Version II. This magnificent piece of code leeches weather information off of Environment Canada's weather pages, and displays it in a very flexible format on your own website.

   Major updates from the initial version include:
   · English or French Selection
   · MySQL or Flat-File Caching
   · Object Oriented Style
   · Superior Configuration and Customization Capabilites
   · Ability to Show Longer Text Descriptions, and Current Information (if available)
   · Selectable Display Formats Pre-Programmed in
   · POP% Displayed Graphically on the Weather Icons
   · Better Written Code


Explanations:

#.gif - All the different weather image files.
index.php - A redirecting index page to prevent directory viewing.
cache.class.php - Caches fetched information, for quicker results, and less drag on the source.
gpl.txt - A copy of the General Public License.
readme.txt - A quick readme file.
SQL.sql - The SQL table.
testWeather.php - A working example of the script.
weather.class.php - The script page. Include it in the page you want the weather displayed on, then call its functions.


EXAMPLE: (May not be exactly as shown.)

<?
include_once("weather.class.php");

$weather = new getWeather();
$weather->dbUser="root";
$weather->dbPass="";
$weather->dbName="db_name";
$weather->cityCode="on-82";
echo 
"<table cellspacing=1 cellpadding=1>";
if (
$weather->fetchData()){
    echo 
    
"<tr><td colspan=3 align=center>\n\n".$weather->showWeather().
    
"\n</td></tr>";
}
$weather->cityCode="bc-74";
$weather->dispFormat=1;
if (
$weather->fetchData()){
    echo 
"<tr valign=top><td>\n\n".$weather->showWeather()."\n</td>";
}
$weather->cityCode="nl-24";
$weather->dispFormat=2;
$weather->longText=true;
if (
$weather->fetchData()){
    echo 
"<td>\n\n".$weather->showWeather()."\n</td>";
}
$weather->cityCode="nu-21";
if (
$weather->fetchData()){
    echo 
"<td>\n\n".$weather->showCurrent()."\n</td></tr>\n";
}
echo 
"</table>";
?>

 Kitchener-Waterloo
Wednesday
Wednesday night
Thursday
Friday
Saturday
Sunday
Sunny With Cloudy Periods
Clear
Sunny With Cloudy Periods
Sunny
Sunny
A Mix Of Sun And Cloud
Sunny With Cloudy Periods
Clear
Sunny With Cloudy Periods
Sunny
Sunny
A Mix Of Sun And Cloud
High 25°C
Low 12°C
High 26°C
High 28°C
Low 14°C
High 28°C
Low 16°C
High 26°C
Low 14°C
Last Updated: August 16, 2006 @ 11:00 AM EDT
Vancouver
Wednesday
Sunny With Cloudy Periods
Sunny With Cloudy Periods
High 21°C
Wednesday night
A Few Clouds
A Few Clouds
Low 13°C
Thursday
Sunny
Sunny
High 26°C
Friday
Sunny
Sunny
High 27°C
Low 13°C
Saturday
Sunny
Sunny
High 26°C
Low 13°C
Sunday
Sunny
Sunny
High 25°C
Low 14°C
Last Updated:
August 16, 2006
11:00 AM PDT
St. John's
Wednesday
A Few Showers
A few showers ending late this afternoon then cloudy. Amount 2 to 4 mm. Wind south 30 km/h gusting to 50. High 21. UV index 3 or moderate.
High 21°C
Wednesday night
Chance Of Showers
Cloudy. 40 percent chance of showers this evening. Fog patches developing near midnight. Wind south 30 km/h gusting to 50 becoming southwest 20 this evening. Low 16.
Low 16°C
POP 40%
Thursday
Chance Of Showers
A mix of sun and cloud. 40 percent chance of showers in the evening with the risk of a thundershower. Wind west 20 km/h. High 24.
High 24°C
POP 40%
Friday
Sunny
Sunny. Low 14. High 20.
High 20°C
Low 14°C
Saturday
Sunny
Sunny. Low 14. High 20.
High 20°C
Low 14°C
Sunday
Chance Of Showers
A mix of sun and cloud with 40 percent chance of showers. Low 15. High 21.
High 21°C
Low 15°C
POP 40%
Last Updated:
August 16, 2006 @ 11:00 AM NDT
Current Conditions
Iqaluit Airport
Cloudy
Cloudy
08 /16 /06 1:00 PM EDT
Temperature
6°C
Pressure/ Tendency
99.8 kPa↑
Visibility
13 km
Humidity
97 %
Dewpoint
5°C
Wind
SE 8 km/h
Yesterday
Max Temp.
9.9°C
Min Temp.
3.4°C
Precip Total
2.0 mm
Regional Normals
Max Temp.
10°C
Min Temp.
3°C
Today
Sunrise
4:30
Sunset
20:47
Moonrise
19:43
Moonset
18:10


-- DOWNLOAD: PHP4    PHP5 --
4060 Downloads To Date

HotScripts.com
Rating: Not Yet Rated / 5
Votes: 0
Hits: 0

LASTEST 5 UPDATES: [Show All 19 Updates]
May 24, 2011
Version 2.3.7:
I think this fixes the troubles when they have alerts. Works on my computer right now at least...


October 6, 2010
Version 2.3.6:
Fixed a bug where sunrise/sunset didn't show when using french.
Also added the option to using global a CSS, instead of inline style tags.


March 11, 2009
Version 2.3.5:
There is a new function, array_snip. It does the legwork for the workaround which deals with the extra Tomorrow Night, or X-Day Night long-text Descriptions.
Now the long descriptions should work, and show the right data for the right days again.


April 10, 2008
Version 2.3.4:
Yeah, I had a typo in the name of the cache class file. Fixed.


April 7, 2008
Version 2.3.3:
Added $fontColour so that you can change the font colour of the displayed weather data, from the web page's default colour, to whatever colour you want.

[Show All 59 Comments]

Chris
12/20/2011 11:32 AM
Love the script.

In testWeather.php (shown above), one of the samples is for St. John's, NL. EV Canada has changed the code from nf-24 to nl-24, which means one of your examples does not display.
JMan: Updated, Thanks :)

Bill
05/26/2011 08:33 AM
Thanks for the 2.3.7 update.
It works well for me.


jared
05/21/2011 09:17 PM
lightening banner now :(


<div cla--="gcinits width600">
<div cla--="gcinittop">
<div cla--="banneradrighttop">
<a href="/redirect.php?url=http://www.ec.gc.ca/meteo-weather/default.asp?lang=En&n=BA2EA688-1"><span cla--="fontSize130">Lightning Safety</span></a>
</div>

</div>
</div>
JMan: Resolved?

Bill
05/08/2011 09:13 AM
EV Canada has removed the link to "Emergency Preparedness Week" and the script is now working.

Bill
05/01/2011 09:10 AM
EV Canada has put a link to "Emergency Preparedness Week May 1 -7, 2011" in the same place as the Dec. 2010 problem advertisement and weather.class.php stopped parsing the script again.

[Show All 59 Comments]

Add a Comment (Max: 1 Per Hour)

Please make sure that your comment pertains to this page. If it has nothing to do with this page, I'll just delete it. If you want, you can send me an email here: jman@bedpan.ca.

Name :
Email or URL :
Verification :
All fields are required for submission. Entries with blank fields will not be posted.

disclaimer:
the comments posted throughout my site are submitted by other users.
the things said are not endorsed by me, and do not represent my opinion.