Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.6 > vBulletin 3.6 Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Fix vbShout Timezone problem Details »»
Fix vbShout Timezone problem
Version: 1.00, by newhere newhere is offline
Developer Last Online: Dec 2009 Show Printable Version Email this Page

Category: Chat Modifications - Version: 3.6.5 Rating:
Released: 04-09-2007 Last Update: Never Installs: 13
 
No support by the author.

This vbShout plugin: http://www.vbhackers.com/f76/ajax-fl...ut-2-1-a-4536/

Has a serious bug with Time Zone changing to that of the last person to post in the shout box.

Here is a fix so that each user will see the time in their local timezone correctly.

1. Open template forumhome_vbshout_shout
Find this (should be at the very beginning):
Code:
<tr>
After it add:
Code:
                                <td nowrap align="left" valign="top">
                                <font size="1">
                                    <date>{$Shout['time']}</date>
                                    
                                </font>
                                </td>
Make sure that the "date" and "/date" tags are on the same line, and with no spaces between them and the $Shout variable, just as above. These are not valid html tags, and we are going to write code to replace them ourselves.



2. Open template forumhome_vbshout
Find:
Code:
Shouts.innerHTML = '<table cellpadding="1" cellspacing="3" border="0" width="95%" align="left">' + ShoutRequest.handler.responseText + '</table>'
Replace it with:
Code:
                        var formatMe = ShoutRequest.handler.responseText
			formatMe = replaceDates(formatMe);
                        Shouts.innerHTML = '<table cellpadding="1" cellspacing="0" border="0" width="100%" align="left">' + formatMe + '</table>'
In the same template
Find this:
Code:
function sb_CollectHV(sbForm)
Before it add:
Code:
// replaces <date> tags
function replaceDates(s) {
            var ret = "";
            var matches = s.match(/<date>\d+<\/date>/g);
            for(var i = 0; matches != null && i < matches.length; i++) {
                var utc = matches[i].match(/\d+/);
                var date = new Date(utc * 1000);
                ret = ret + s.substr(0, s.indexOf(matches[i]));
                ret = ret + (date.getMonth()+1) + "/" +
                            date.getDate() + "/" +
                            date.getFullYear() + " " +
                            date.getHours() + ":" +
                            ((date.getMinutes() < 10) ? "0" : "") +
                            date.getMinutes() + ":" +
                            ((date.getSeconds() < 10) ? "0" : "") +
                            date.getSeconds() + " ";


                s = s.substr(s.indexOf(matches[i]) + matches[i].length);
            }
            ret = ret + s;
            return ret;
}



3. Open file vbshout.php
FInd this (There are similar code blocks, this should be in the function rewrite_shoutbox_flatfile() around line 226):
Code:
        $Shout['time']     = buildTime($Shout['s_time']);
        $Shout['s_shout']  = bbcodeparser($Shout['s_shout']);
        $Shout['style']    = '';
        $Shout['data']     = unserialize($Shout['s_data']);
        $Shout['username'] = fetch_musername($Shout, 'usergroupid');

        if (preg_match("#(\#)?0099FF#i", $Shout['data']['color']) && $Shout['s_by'] != 1)
        {
            $Shout['data']['color'] = '';
        }
Replace it with:
Code:
        // $Shout['time']     = buildTime($Shout['s_time']);
        $Shout['time']     = $Shout['s_time'];
        $Shout['s_shout']  = bbcodeparser($Shout['s_shout']);
        $Shout['style']    = '';
        $Shout['data']     = unserialize($Shout['s_data']);
        $Shout['username'] = fetch_musername($Shout, 'usergroupid');
        
        if (preg_match("#(\#)?0099FF#i", $Shout['data']['color']) && $Shout['s_by'] != 1)
        {
            $Shout['data']['color'] = '';
        }

This should now pass the date as UTC and JavaScript will convert it on the client side to the appropriate date.

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #52  
Old 05-03-2007, 09:08 AM
parabat parabat is offline
 
Join Date: Apr 2006
Location: South Africa
Posts: 111
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by newhere View Post
Either way (with your code or with mine), I get a horizontal scroll bar when someone posts a shout which is too long.
Just as a side.. the scrollbar appears in IE6 & IE7 (without a long posting), but not in Firefox.

-PB
Reply With Quote
  #53  
Old 06-01-2007, 06:13 AM
jessej jessej is offline
 
Join Date: Jun 2006
Posts: 33
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Terminatoronly View Post
when i installed it i didnt get any time with the shout how can i add the time ???
same here.

i hope someone will answer cause i had it on v2.0, and i really want it on v2.1.

thanks- and this is a GREAT hack.
Reply With Quote
  #54  
Old 11-03-2007, 10:32 PM
CMGU CMGU is offline
 
Join Date: Mar 2007
Location: Central America
Posts: 213
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i can´t change somebody help me
Reply With Quote
  #55  
Old 06-04-2008, 12:14 AM
oz_moses oz_moses is offline
 
Join Date: Oct 2004
Location: Sydney
Posts: 115
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Cheers for the mods, much appreciated

CMGU, perhaps if you ask a question you might find help more forthcoming.
Reply With Quote
  #56  
Old 06-04-2008, 12:38 AM
oz_moses oz_moses is offline
 
Join Date: Oct 2004
Location: Sydney
Posts: 115
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok, here's my customisations for anyone who's interested. These changes to the replaceDates function do the following
  • Droped the seconds - the shouts are displayed in order anyway, my users don't care if a shout was 3 or 49 seconds ago
  • Changed the date format to dd-mon , easier to read, all months are 3 letters helps keep it aligned at the month turnover.

Code:
// replaces <date> tags
function replaceDates(s) {
	var ret = "";
	var matches = s.match(/<date>\d+<\/date>/g);
	var months=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug', 'Sep','Oct','Nov','Dec'];

	for(var i = 0; matches != null && i < matches.length; i++) {

	var utc = matches[i].match(/\d+/);
	var date = new Date(utc * 1000);
        
        ret = ret + s.substr(0, s.indexOf(matches[i]));
	ret = ret + (
                        date.getDate() + "-" +
			months[date.getMonth()]) + " " +
                        ((date.getHours() < 10) ? " " : "") + 
				date.getHours() + ":" +
                        ((date.getMinutes() < 10) ? "0" : "") +
				date.getMinutes() + " ";

                s = s.substr(s.indexOf(matches[i]) + matches[i].length);
            }
            ret = ret + s;
            return ret;
}
Reply With Quote
  #57  
Old 06-04-2008, 12:41 AM
oz_moses oz_moses is offline
 
Join Date: Oct 2004
Location: Sydney
Posts: 115
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by jessej View Post
same here.

i hope someone will answer cause i had it on v2.0, and i really want it on v2.1.

thanks- and this is a GREAT hack.
I found that changes aren't rendered until you make a new shout... so just shout!
Reply With Quote
  #58  
Old 06-04-2008, 12:46 AM
oz_moses oz_moses is offline
 
Join Date: Oct 2004
Location: Sydney
Posts: 115
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by parabat View Post
Just as a side.. the scrollbar appears in IE6 & IE7 (without a long posting), but not in Firefox.

-PB
I noticed the horizontal scroll initially in IE6, it was on all the time.

I made an edit in forumhome_vbshout template to chang the table width to 95% as per the original hack which seems to have fixed it.
Code:
Shouts.innerHTML = '<table cellpadding="1" cellspacing="0" border="0" width="95%" align="left">' + formatMe + '</table>'
seems to be working in IE6 and IE7. Haven't tested Firefox yet...
Reply With Quote
Reply


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

Forum Jump


All times are GMT. The time now is 06:39 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06444 seconds
  • Memory Usage 2,290KB
  • Queries Executed 22 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (10)bbcode_code
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (7)postbit
  • (8)postbit_onlinestatus
  • (8)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete