Back to vBulletin 3.0 Add-Ons

VB World Weather
Mod Version: 1.00, by why-not

This modification is in the archives.
vB Version: 3.0.3 Rating: (1 vote - 5.00 average) Installs: 82
Released: 12 Jul 2004 Last Update: Never Downloads: 363
Not Supported  

This is VB World Weather...

It allow your users to look up and display local weather for 39,722 locations around the world! It is template based with multi language support built in!

The zip file contains...

1. Step by step install files
2. All images, language files, templates, weather database file and scripts

Demo

http://forum.ya-right.com/

user: test
pass: test

when you login go to the usercp to try the demo, also look at the bottom of the forum home for the other display...

The one on the forum home can be placed where ever you want to place it!

If you have any questions or need install help post your questions here...

UPDATES (7/15/2004 9:47 PM EDT)

Go here for the FORUMHOME template update install info

Spoiler (click to open)


Update to display forum home view (Jul 15, 9:47 PM EDT)

This is the update for the forum home weather view....

This can be done many ways but I think I will only do it one way, so that this final update that will support the AdminCP addon that I will release to control the weather system....

Lets begin.....

(1)

Go to Languages & Phrases >> Phrase Manager

In the Phrase Type selectbox, select 'Posting'

When it changes, select pages '9/10'

in the list below you should see 'weather_none'

Delete it!!!!

When the page reloads, click the button 'Add New Phrase'

Make sure you are still in 'Posting'

Then add the new phrase below...

Code:
Phrase Type: Posting
Varname: weather_none_one
value....
copy below this line....
<span align="center">--<font color="ff0000"> NO FORECAST SELECTED </font>--
<br />
<br />
Use the Forecast Options below to configure your weather display
<br />
<br />
--<font color="ff0000"> NO FORECAST SELECTED </font>--</span>
copy above this line....
Click 'Save'

When the page reloads, , click the button 'Add New Phrase'

When that page loads, change the Phrase Type to 'GLOBAL' in the selectbox

Then add the new phrase below...

Code:
Phrase Type: GLOBAL
Varname: weather_none_two
value....
copy below this line....
<span class="smallfont"><font color="ff0000">--</font> no forecast location has been configured, click the weather icon to the left to select one <font color="ff0000">--</font></span>
copy above this line....
No go to 'Styles & Templates' >> Search in templates >> search for 'FORUMHOME'

open 'FORUMHOME'

Then find the following....

Code:
<head>
right below that add....

// change the url to the url you are using

Code:
  <if condition="$show['forecast']"><if condition="$forecast_home['location']!='0'">
<link rel="stylesheet" type="text/css" href="/forecast/css/main.css" />
</if></if>

Now go almost to the bottom of 'FORUMHOME'

Find what is below....

Code:
</table>
<br />
<!-- end what's going on box -->

Right above the '</table>' add what is below...

Code:
<!-- the weather condition -->
  <if condition="$show['forecast']"><if condition="$forecast_home['location']!='0'">$forecast_home[data]<else /><tbody>
   <tr>
    <td class="thead" colspan="2"><a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('forumhome_weather')"><img id="collapseimg_forumhome_weather" src="$stylevar[imgdir_button]/collapse_thead$vbcollapse[collapseimg_forumhome_weather].gif" alt="" border="0" /></a>$vbphrase[local_weather]</td>
   </tr>
  </tbody>
  <tbody id="collapseobj_forumhome_weather" style="$vbcollapse[collapseobj_forumhome_weather]">
   <tr>
    <td class="alt2"><a href="profile.php?$session[sessionurl]do=weather"><img border='0' src='$stylevar[imgdir_misc]/weather.gif' alt='$vbphrase[local_weather]' /></a></td>
    <td class="alt1" width="100%" align="center"><div class="smallfont" align="center">$forecast_home[data]</div></td>
   </tr>
  </tbody></if></if>
<!-- / the weather condition -->

Save...

Now go back to Styles & Templates >> Styles Manager

Use the selectbox, for the style you are adding the weather system to....

Scroll UP >> select >> Add New Template

Then add the following template....

Code:
Title = current_weather_two
template value.....
copy what is below this line...
<tbody>
 <tr>
  <td class="thead" colspan="2"><a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('forumhome_weather')"><img id="collapseimg_forumhome_weather" src="$stylevar[imgdir_button]/collapse_thead$vbcollapse[collapseimg_forumhome_weather].gif" alt="" border="0" /></a>$tpl[location_header]$tpl[location]</td>
</tr>
</tbody>
<tbody id="collapseobj_forumhome_weather" style="$vbcollapse[collapseobj_forumhome_weather]">
 <tr>
  <td class="wic"><div><a href="profile.php?$session[sessionurl]do=weather"><img border='0' src='$tpl[current_icon]' title="$tpl[current_text]" alt='' /></a></div><div class='smallfont'>$tpl[current_temp]</div></td>
  <td class="wic">
   <table border="0" cellpadding="1" width="100%">
    <tr>
     <td class="ihs">$tpl[time_text]</td><td width='4'></td>
     <td class="ihs">$tpl[humd_header]</td><td width='4'></td>
     <td class='ihs'>$tpl[vis_header]</td><td width='4'></td>
     <td class='ihs'>$tpl[ultra_header]</td><td width='4'></td>
     <td class='ihs'>$tpl[baro_header]</td><td width='4'></td>
     <td class='ihs'>$tpl[direct_header] ($tpl[direct_type])</td>
    </tr>
    <tr>
     <td class="smallfont">$tpl[local_time]</td><td width='4'></td>
     <td class="smallfont">$tpl[current_humd]</td><td width='4'></td>
     <td class='smallfont'>$tpl[current_vis]</td><td width='4'></td>
     <td class='smallfont'>$tpl[current_ultra]</td><td width='4'></td>
     <td class='smallfont'>$tpl[current_baro] <span><img border='0' src='$tpl[icon_baro]' alt='' /></span></td><td width='4'></td>
     <td class='smallfont'>$tpl[current_direct]</td>
    </tr>
   </table>
  </td>
 </tr>
</tbody>
copy what is above this line...

Before you do the next thing....

Find out the following.....

Code:
(1) What is the starting 'field#' for the weather system
(2) What is the ending 'field#' for the weather system
If you fields are....
field11, field12, field13, field14, field15
Then your starting field# is -> 11
And your ending field# is -> 15
(3) find out what option (#) is option : weather in profilefield.php
To do this >> Go To >> left nav >> User Profile Fields >> 'add new profile field'
just click 'continue'........
When the page loads..... >> 'View Page Source'
Look for......
<select name="profilefield[form]" id="sel_profilefield[form]" tabindex="1" class="bginput">
Below the above select name  you will see 'Options : Weather'
<option value="?">Options: weather</option>
You want the value where the '?' is....
After you have these values copy them to notepad or whatever your system has

// field_start = 11 <- this an example, yours may be different!
// field _end = 15 <- this an example, yours may be different!
// option_id = 6 <- this an example, yours may be different!

Now open ./profile.php

find this....

PHP Code:
    'places' => array(
        
'weather_new',
    ), 

replace with....

PHP Code:
    'places' => array(
        
'places_display',
    ), 

find this... (the old weather block)

PHP Code:
if (!($permissions['genericpermissions'] & CANMODIFYPROFILE))
{
    
print_no_permission();
}

// ####### weather forecast and the forecast options ######

if ( $_REQUEST['do'] == 'weather' || $_REQUEST['do'] == 'places' )
{
    
define 'DO_WEATHER');
    
construct_usercp_nav $_REQUEST['do'] );
    
$templatename $_REQUEST['do'] . '_display';
    
$shelltemplatename 'USERCP_SHELL';
    include_once ( 
'./includes/functions_weather.php' );
}

if ( 
$_REQUEST['do'] == 'weather' )
{
    
$new_forecast forecast_valid $bbuserinfo[field5], $bbuserinfo[field6], $bbuserinfo[field7], $bbuserinfo[field8], $bbuserinfo[field9] );
    
$new_forecast fetch_forecast $new_forecast);
    
$customfields = array ();
    
fetch_profilefields(1);
    
$navbits[''] = $vbphrase['weather_title'];
}

if ( 
$_REQUEST['do'] == 'places' )
{
    if ( !empty ( 
$_POST['location'] ) )
    {
        
$DB_site->query "UPDATE " TABLE_PREFIX "userfield SET field9=" addslashes$_POST['location'] ) . " WHERE userid=$bbuserinfo[userid]);
        
$GLOBALS['url'] = 'profile.php?do=weather';
        eval ( 
print_standard_redirect 'redirect_updatethanks' ) );
    }
    else
    {
        
$tpl places_validate ();
        
$navbits[''] = $tpl['page_title'];
    }
}

if ( 
$_POST['do'] == 'forecast' )

    
$forecast_fields verify_profilefields );

    if ( !empty ( 
$forecast_fields ) )
    {
        
$DB_site->query "UPDATE " TABLE_PREFIX "userfield SET userid=$bbuserinfo[userid]$forecast_fields WHERE userid=$bbuserinfo[userid]);
    }

    eval ( 
print_standard_redirect 'redirect_updatethanks' ) );


replace with....

PHP Code:
if (!($permissions['genericpermissions'] & CANMODIFYPROFILE))
{
    
print_no_permission();
}

// ####### weather forecast and the forecast options ######

if ( $_REQUEST['do'] == 'weather' || $_REQUEST['do'] == 'places' )
{
    
define 'DO_WEATHER');
    
// special tags you need to change ( 2 -> field_start, field_end )
    
$w_fields = array ( 'field_start''field_end' );
    
construct_usercp_nav $_REQUEST['do'] );
    
$templatename $_REQUEST['do'] . '_display';
    
$shelltemplatename 'USERCP_SHELL';
    include_once ( 
'./includes/functions_weather.php' );
}

if ( 
$_REQUEST['do'] == 'weather' )
{
    
$new_forecast forecast_valid $w_fields );
    
$new_forecast fetch_forecast $new_forecast);
    
$customfields = array ();
    
// special tag you need to change ( 1 -> option_id )
    
fetch_profilefields option_id );
    
$navbits[''] = $vbphrase['weather_title'];
}

if ( 
$_REQUEST['do'] == 'places' )
{
    if ( !empty ( 
$_POST['location'] ) )
    {
        
$DB_site->query "UPDATE " TABLE_PREFIX "userfield SET field" $w_fields[1] . " = '" addslashes$_POST['location'] ) . "' WHERE userid = '" $bbuserinfo['userid'] . "'" );
        
$GLOBALS['url'] = WEATHER_URL 'profile.php?' $session['sessionurl'] . 'do=weather';
        eval ( 
print_standard_redirect 'redirect_updatethanks' ) );
    }
    else
    {
        
$tpl places_validate ();
        
$navbits[''] = $tpl['page_title'];
    }
}

if ( 
$_POST['do'] == 'forecast' )
{
    
// special tag you need to change ( 1 -> option_id )
    
$forecast_fields verify_profilefields option_id );

    if ( !empty ( 
$forecast_fields ) )
    {
        
$DB_site->query "UPDATE " TABLE_PREFIX "userfield SET userid=" $bbuserinfo['userid'] . $forecast_fields " WHERE userid = '" $bbuserinfo['userid'] . "'" );
    }

    eval ( 
print_standard_redirect 'redirect_updatethanks' ) );


Now in the code you just replaced, find the following special tags and replace them with the values I told you to save right before you opened'profile.php'!

Code:
(1)  field_start, occurs (1) time
change 'field_start', to the (#) that is the value for field_start!
(2) field_end, occurs (1) time
change 'field_end', to the (#) that is the value for field_end!
(3) option_id, occurs (2) time
change 'option_id, to the (#) that is the value for option_id!
Using my example values I would change the following lines in the replaced code above!

PHP Code:

// my example values....

// field_start = 11 <- this an example, yours may be different!
// field _end = 15 <- this an example, yours may be different!
// option_id = 6 <- this an example, yours may be different!


    // special tags you need to change ( 2 -> field_start, field_end )
    
$w_fields = array ( 'field_start''field_end' );

    
// after changing the above (occurs 1 time in the replace code)
    
$w_fields = array ( '11''15' );

    
// special tag you need to change ( 1 -> option_id )
    
$forecast_fields verify_profilefields option_id );

    
// after changing the above (occurs 2 time in the replace code)
    
$forecast_fields verify_profilefields ); 
after save and close profile.php!

open ./index.php

find the following.....

PHP Code:
// ### WELCOME MESSAGE #################################################
if ($bbuserinfo['userid'])
{    
// registered user
    
$showmemberwelcome true;
}
else
{    
// guest
    
$showmemberwelcome false;


replace with.....

PHP Code:
// ### WELCOME MESSAGE #################################################
if ($bbuserinfo['userid'])
{
    
$showmemberwelcome true;
    
// special tags you need to change ( 2 -> field_start, field_end )
    
$w_fields = array ( 'field_start''field_end' );
    
$w_m 'field' . ( $w_fields[1] - );

    if ( 
strpos $bbuserinfo[$w_m], 'always' ) )
    {
        
$show['forecast'] = true;

        
define 'DO_WEATHER');

        include_once ( 
'./includes/functions_weather.php' );

        
$forecast_home forecast_valid $w_fields );

        if ( !empty ( 
$forecast_home )  )
        {
            
$forecast_home fetch_forecast $forecast_home);
        }
    }
}
else
{
    
$showmemberwelcome false;
    
$show['forecast'] = false;


There are (2) special tags in the replace code above, be sure to change them just like you did before!

These are the tags you need to replace in the replace code above.....

PHP Code:
    // special tags you need to change ( 2 -> field_start, field_end )
    
$w_fields = array ( 'field_start''field_end' );

    
// after changing the above (occurs 1 time in the replace code)
    
$w_fields = array ( '11''15' ); 
After save changes to ./index.php and close it!

Open....

./includes/functions_user.php

find the following code!

PHP Code:
function fetch_profilefields($formtype 0// 0 indicates a profile field, 1 indicates an option field
{

    global 
$DB_site$vboptions$stylevar$customfields$bgclass;
    global 
$vbphrase$altbgclass$bgclass1$tempclass$bbuserinfo;

    
// get extra profile fields
    
$profilefields $DB_site->query("
        SELECT * FROM " 
TABLE_PREFIX "profilefield
        WHERE editable = 1
            AND form " 
iif($formtype'>= 1''= 0'). "
        ORDER BY displayorder
    "
); 
replace with.....

PHP Code:
function fetch_profilefields($formtype 0// 0 indicates a profile field, 1 indicates an option field
{

    global 
$DB_site$vboptions$stylevar$customfields$bgclass;
    global 
$vbphrase$altbgclass$bgclass1$tempclass$bbuserinfo$new_forecast;

    
// get extra profile fields
    
$profilefields $DB_site->query "SELECT * FROM " TABLE_PREFIX "profilefield WHERE editable = '1' AND form " . ( $formtype == option_id "= '" $formtype "'" : ( $formtype ">= '" $formtype "'" "= '0'" ) ) . " ORDER BY displayorder" ); 
There is (1) special tag in the replace code above! You need to change it to the value of 'option_id'

using my example.....

PHP Code:
    // special tag you need to change ( 1 -> option_id )
    
$profilefields $DB_site->query "SELECT * FROM " TABLE_PREFIX "profilefield WHERE editable = '1' AND form " . ( $formtype == option_id "= '" $formtype "'" : ( $formtype ">= '" $formtype "'" "= '0'" ) ) . " ORDER BY displayorder" );

    
// after changing the above (occurs 1 time in the replace code)
    
$profilefields $DB_site->query "SELECT * FROM " TABLE_PREFIX "profilefield WHERE editable = '1' AND form " . ( $formtype == "= '" $formtype "'" : ( $formtype ">= '" $formtype "'" "= '0'" ) ) . " ORDER BY displayorder" ); 
Save changes and close ./includes/functions_user.php

Download the file new_weather.zip

Move the folder 'si' in the zip file to, ./forecast/img/

over write the current ./forecast/css/main.css, with the new one in the zip file...

copy 'weather.gif' to the ./images/misc/ directory of the style you are using!

overwrite ./forecast.php with the new one in the zip file
overwrite ./includes/functions_weather, with the one included in the zip file!

All done...

1. Adds forum display
2. 20% speed gain...
3. fixes sort order in location select boxes
4. setups the weather system to plugin to the new Admin CP 'Weather Manager', which will be released on the 23 of July!

Need help just post!

Sonia
Attached Files
File Type: zip new_weather.zip (41.0 KB, 175 views)

Close


UPDATES (7/18/2004 9:04 AM EDT)

Add a database install table script, for people who can not run
the single sql file (FOUND IN STEP 7). It is very easy to use!

Have a great day....

Sonia

_______________________________
Next mod -> translate this topic or post!

Download

This modification is archived and cannot be downloaded.

Screenshots

   

Similar Mods

vB Weather: Give your members current weather and forecasts! vBulletin 2.x Full Releases

vblts.ru supports vBulletin®, 2022-2024