Register Members List Search Today's Posts Mark Forums Read

Reply
 
Mod Options
vB Weather: Give your members current weather and forecasts! Details »
vB Weather: Give your members current weather and forecasts!
Mod Version: 1.00, by JJR512 (Member) JJR512 is offline
Developer Last Online: Jun 2006 I like it Show Printable Version Email this Page

This modification is in the archives.
vB Version: 2.2.x Rating: (0 vote - 0 average) Installs: 25
Released: 26 Feb 2002 Last Update: Never Downloads: 20
Not Supported  

After seeing a weather feature at the vbPortal website, and finding out that I couldn't get it for free, I determined to create it for myself, and give it away to everyone for FREE.

So here it is. It's based in part upon the original MyWeather add-on module for PHP-Nuke, which as I understand was also the basis for the add-on module for vbPortal. Anyway, I basically used the part of the PHP-Nuke module that gets the raw data and parses it into a usable format, although I reworked it some and corrected a few bugs. I wrote on my own the rest of the code which handles and displays the data, along with letting the user select his/her location (to localize the weather), number formats (like F or C, winds in mph or kmph, etc.), and various other little bits.

I've done as much testing on it as I can on my own, and have had it running on my own production forums for about a day now. Several people have commented that they really love the feature, that it's almost getting to the point where they don't have to go anywhere else on the Internet. I haven't heard of any complaints or problems yet, though, so I'm reasonably certain it's fit for a full release.

You can demo the hack on my message board: JJR512.com. The first part you should look at is the box that appears in the column of boxes on the left side of the home page. This box displays basic current weather info. There are two links in that box, one to see the forecast, and the other to change settings. I forget if you need to be logged in to see the forecast--it may just show you a forecast for the default location, which is Central Park, New York City, NY, USA--but you definitely need to be logged in to change settings. For the purpose of seeing this hack in action, you can login as Test User using the password testuser. Feel free to change the settings and save them, do whatever.

Installing this hack is in some ways easy, in other ways not so easy. There will only be one file modification. However, there are no specific instructions as to which file to edit or how to edit it. If you want the small weather box to show up on your forums home page, you need to edit the associated file (index.php). If you want it to show up somewhere else, then you need to edit whatever file generates the page where you want it. There is a text file in the ZIP that contains all the code, and only the code, that you need to insert into whatever file. If you prefer, you can turn that text file into a .php file (by adding <?php at the beginning and ?> at the end and renaming it to .php) and simply including it in whatever file you need it in.

You will also most likely need to edit the template that makes the weather box. It's formatted to basically make a box as it appears on my site, which is in the middle of some other boxes in a column. If you want to reformat it to appear as a long thing across the top of the page, like the various stuff at the top of the forums home page here at vbulletin.org, that's up to you. You edit the templates to match your own site.

BTW, I would appreciate it if someone better at PHP coding than myself would take a look over this and tell me if I've done everything right or not. I believe the code works and does what I want it to do, but it seems like it might be a little more complex than it needs to or should be. I guess I'm just wondering if there may have been a more efficient way to do some of the things I did. If you have any tips or advice for me, or even want to rewrite the code to show me, I'd really appreciate it.

OK, so without further ado, here's the hack in the attachment. Whatever problems you have, please post them here, and I'll try to help as best I can, but make no guarantees that I can help at all. Please remember that I write my hacks for my own site first and foremost, so they do what I need them to do, not what I think somebody else might want. I choose to release them here in case anybody else can benefit from them, but you may need some part of it to work slightly differently. If I know how to do it I will try to tell you how to do it, but I won't update the hack with every little feature variation that people ask for. In general, I only update my hacks to fix bugs and to add new features that I want or need for my site.

// Change Log]
03b: Includes necessary database change instructions.
03a: Forgot to update 03 ZIP with new templates; fixed.
03: Changed code for new icon system, added code for forecasted weather type (new part of raw data)
02: Adjusted code for new format of weather forecast raw data
01b: Fixed two missing lines from weather_include.txt
01a: Added missing template; updated instructions regarding missing template; fixed $templatesused variable in weather.php; added text file explaining how to add more cities; updated instructions regarding where to get the icons used for this hack
01: Original release

Download Now

Only licensed members can download files, Click Here for more information.

Show Your Support

  • To receive notifications regarding updates -> Click to Mark as Installed.
  • This modification may not be copied, reproduced or published elsewhere without author's permission.
Similar Mod
Mod Developer Type Replies Last Post
Miscellaneous Hacks Weather: Current Conditions calorie vBulletin 3.6 Add-ons 33 14 Jul 2009 13:27
Current Weather [VBIndex and Standalone] - 1.0 Reeve of shinra vBulletin 3.0 Full Releases 3 30 May 2004 00:10

Comments
  #2  
Old 26 Feb 2002, 10:28
Mark Hewitt Mark Hewitt is offline
 
Join Date: Nov 2001
Looks great.

The list of cities which are included with the hack. Are they the only ones which are available, or can more be added?

Newcastle (where I live) is a major city and it's not on the list. Neither are Edinburgh or Cardiff, captials of Scotland and Wales respectively, Glasgow is there though, strange.

ps Love the way you've organised your front page
Reply With Quote
  #3  
Old 26 Feb 2002, 11:15
DjSap DjSap is offline
 
Join Date: Nov 2001
heh i was about to start coding a weather thingy today, but now i dont have to, thanks for the hack.
Reply With Quote
  #4  
Old 26 Feb 2002, 12:14
DjSap DjSap is offline
 
Join Date: Nov 2001
and you can add more cities if you like to, i dont know exactly how to do it but it shouldnt be that hard since all the weather info is taken from msnbc
Reply With Quote
  #5  
Old 26 Feb 2002, 12:22
Mark Hewitt Mark Hewitt is offline
 
Join Date: Nov 2001
Just looked at the msnbc site (popup hell!!). And it does have the majority of places in

Does this hack mean your server has to connect to msnbc every time the front page loads?
Reply With Quote
  #6  
Old 26 Feb 2002, 14:22
TheComputerGuy's Avatar
TheComputerGuy TheComputerGuy is offline
 
Join Date: Oct 2001
Real name: Joe
I like it, I will try to install it sometime tonight
__________________
I'll buy your forum!
Reply With Quote
  #7  
Old 26 Feb 2002, 15:21
qwaz qwaz is offline
 
Join Date: Nov 2001
JJ, I have "boxes" down the side of my forums to, and they are there all througout the forums, on every page. They are produced by the header template.

Should the code go into index.php? Because I can't get it to show when I put $weather in the header template.
Reply With Quote
  #8  
Old 26 Feb 2002, 15:27
DjSap DjSap is offline
 
Join Date: Nov 2001
if you are gonna show it on every page then i think yo uhave to put it in global
Reply With Quote
  #9  
Old 26 Feb 2002, 15:34
qwaz qwaz is offline
 
Join Date: Nov 2001
Just tried that.

No dice.
Reply With Quote
  #10  
Old 26 Feb 2002, 16:05
Gamingforce's Avatar
Gamingforce Gamingforce is offline
 
Join Date: Nov 2001
Awesome hack JJR512, but where can we get the iconsets for /images/weather ?
Reply With Quote
  #11  
Old 26 Feb 2002, 16:53
JJR512's Avatar
JJR512 JJR512 is offline
 
Join Date: Oct 2001
Real name: Justin J. Rebbert
If you want it on every page, I believe the easiest way to do that is to make the weather_include.txt file into a PHP file, by adding <?php at the beginning and ?> at the end, renaming the extension, then include that file in the phpinclude template, then you should be able to use $weather anywhere. (This is in theory, not tested by me.)

You can easily add more cities. This hack comes with over 1500 cities that are made available, but there are a lot, lot more. Probably just about any town that is covered by an ISP would be available, or if not then the town next to it. I have attached a text file to this post that explains how to add more cities. I have also put this file into the weather01.zip and updated the attachment in the first post; note that if you have already downloaded it, it is NOT necessary to download it again. Just download the file from the attachment in this post, because nothing else in the ZIP has changed at all.

BTW, the cities Newcastle, Newcastle On Clun, Newcastle Wea Cntr, and Newcastle Wx Centre are all available, as are Cardiff and Edinburgh.

Mark Hewitt, no, it the front page won't try to connect to MSNBC every time someone loads it. A user's weather data is stored in the database and is usable for up to two hours after it was put there; after it is more than two hours old, the hack will connect to get new data. This should minimize the amount your site has to connect to MSNBC, plus the hack itself will not have to go through the steps of parsing the raw data, etc. I have personally observed on my home computer a difference of a few seconds between when the front page uses cached data and when I force it to get new data. If you want to change how long the cached data is considered "fresh", look for this line in weather.php:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Change the number 7200 to some other number, where it is the number of seconds. (There are 3600 seconds in one hour, thus for two hours, it is 7200.) Now this hack will display, on either the box on the forums home page or on the weather forecast page, the time the data was last updated by AccuWeather. This is the time the original raw data was updated, NOT when the data was stored in your database. You can try to pay attention to that time to see how often the actual raw data is updated (I have not had time to do that yet, and I just picked two hours as a seemingly good amount of time), and adjust the number accordingly. Meaning, if the raw data is only updated every three hours, make the cached data fresh for three hours; however, you run the risk that someone will cache some data just before an update, then the raw data changes, meanwhile the user is sees old data for the next three hours.
Attached Files
File Type: txt more_cities.txt (2.7 KB, 102 views)
__________________
-Justin J. "JJR512" Rebbert
www.JJR512.com: Chat about anything!

Last edited by JJR512; 26 Feb 2002 at 22:17.
Reply With Quote
  #12  
Old 26 Feb 2002, 17:07
JJR512's Avatar
JJR512 JJR512 is offline
 
Join Date: Oct 2001
Real name: Justin J. Rebbert
Gamingforce: D'oh! I forgot to include those. The ZIP with all the graphics is too big to attach, at 273kB, so I uploaded it to my own webserver where you can download it: <link removed by JJR512; the ZIP is now attached to Post #55 in this thread>. There will be four folders in the ZIP: iconset1, iconset2, etc. Please create a folder in your forums/images folder called "weather", and upload the four folders (including each folder's contents) there. (If you really want to put them somewhere else, you will need to edit the paths in the templates.)

I have updated the instructions.txt file for this hack to include the URL to download the images ZIP file. That is the only change; if you have already downloaded the weather01.zip, you do NOT need to download it again, because I just told you how to get the ZIP.

Note that each iconset has two additional graphics, forecast.gif and current_cond.gif, which are just graphics that say "Forecast" and "Current Conditions". I did not use these on my website, so they are not used in the templates, but they are there for you to use if you want to.
__________________
-Justin J. "JJR512" Rebbert
www.JJR512.com: Chat about anything!

Last edited by JJR512; 11 Jul 2002 at 18:33.
Reply With Quote
  #13  
Old 26 Feb 2002, 17:15
Lesane's Avatar
Lesane Lesane is offline
 
Join Date: Oct 2001
Real name: Maurice
Fantastic Hack JJR512. Install this one later. Well done, thanks.
Reply With Quote
  #14  
Old 26 Feb 2002, 18:56
Martz's Avatar
Martz Martz is offline
 
Join Date: Oct 2001
looks good, nice work
__________________
utassault.net forums
Free hosting for
28 co-branded Unreal Tournament clans/projects
Reply With Quote
  #15  
Old 26 Feb 2002, 19:18
JJR512's Avatar
JJR512 JJR512 is offline
 
Join Date: Oct 2001
Real name: Justin J. Rebbert
I have updated the ZIP file to include another text file, redirect_weather_updatethanks.txt, which is used for another template. I forgot about it originally. I updated the instructions to include a reference to that file. I updated the weather.php file to fill in the template names for the $templatesused variable at the top.

If you have already downloaded this hack, please download the new ZIP, upload the new weather.php file, and add a new template for redirect_weather_updatethanks. Sorry!
__________________
-Justin J. "JJR512" Rebbert
www.JJR512.com: Chat about anything!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Mod Options

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 15:56.

Layout Options | Width: Wide Color: