vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 2.x Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=4)
-   -   Let users choose their own date and time format (https://vborg.vbsupport.ru/showthread.php?t=28193)

Admin 09-15-2001 10:00 PM

This hack adds an option for the user to select the date format and time format he wants to use in the forum.
Good for people from different countries, that use different formats.
Requested by markrt.

Demo:
http://www.vbulletin.com/forum/attac...&postid=172339

Run this query:
Code:

ALTER TABLE user ADD dateformat VARCHAR(4) DEFAULT '-1' not null AFTER timezoneoffset, ADD timeformat VARCHAR(4) DEFAULT '-1' not null AFTER dateformat;
(for more information on running queries visit the Troubleshooting and Problems forum)

In your modifyoptions template add this code:
Code:

<tr>
        <td bgcolor="{secondaltcolor}"><normalfont><b>Date format</b></normalfont><br>
        <smallfont>Select what format you would like to use for dates.</smallfont></td>
        <td bgcolor="{secondaltcolor}"><smallfont>
        <select name="newdateformat">
                <option value="-1" $datedefselected>Use forum default</option>
                <option value="0" $date0selected>04-25-1998</option>
                <option value="1" $date1selected>04-25-98</option>
                <option value="2" $date2selected>04.25.1998</option>
                <option value="3" $date3selected>04.25.98</option>
                <option value="4" $date4selected>25-04-1998</option>
                <option value="5" $date5selected>25-04-98</option>
                <option value="6" $date6selected>25.04.1998</option>
                <option value="7" $date7selected>25.04.98</option>
                <option value="8" $date8selected>April 25th, 1998</option>
                <option value="9" $date9selected>Saturday, April 25th, 1998</option>
                <option value="10" $date10selected>25th April 1998</option>
                <option value="11" $date11selected>Saturday, 25th April 1998</option>
        </select></smallfont></td>
</tr>
<tr>
        <td bgcolor="{firstaltcolor}"><normalfont><b>Time format</b></normalfont><br>
        <smallfont>Select what format you would like to use for times.</smallfont></td>
        <td bgcolor="{firstaltcolor}"><smallfont>
        <select name="newtimeformat">
                <option value="-1" $timedefselected>Use forum default</option>
                <option value="0" $time0selected>08:15 pm</option>
                <option value="1" $time1selected>08:15:48 pm</option>
                <option value="2" $time2selected>08:15 PM</option>
                <option value="3" $time3selected>08:15:48 PM</option>
                <option value="4" $time4selected>20:15</option>
                <option value="5" $time5selected>20:15:48</option>
        </select></smallfont></td>
</tr>

right after
Code:

                <option value="+12" $timezonesel[120]>(GMT +12:00 hours) Auckland, Wellington, Fiji, Kamchatka, Marshall Island</option>
        </select></smallfont></td>
</tr>

In member.php add this code:
PHP Code:

  if ($bbuserinfo[dateformat]!=-1) {
    
$dateformat="date".$bbuserinfo[dateformat]."selected";
    $
$dateformat "selected";
  } else {
    
$datedefselected "selected";
  }

  if (
$bbuserinfo[timeformat]!=-1) {
    
$timeformatsel="time".$bbuserinfo[timeformat]."selected";
    $
$timeformatsel "selected";
  } else {
    
$timedefselected "selected";
  } 

right after
PHP Code:

  if ($bbuserinfo[timezoneoffset]<0) {
    
$timezonesel["n".(-$bbuserinfo[timezoneoffset]*10)]="selected";
  } else {
    
$timezonesel[$bbuserinfo[timezoneoffset]*10]="selected";
  } 

Still in member.php, replace this code:
Code:

  $DB_site->query("UPDATE user
                  SET ".$updatestyles."adminemail='$adminemail',
                      showemail='$showemail',invisible='$invisible',cookieuser='$cookieuser',
                      maxposts='".addslashes($umaxposts)."',daysprune='".addslashes($prunedays)."',
                      timezoneoffset='".addslashes($timezoneoffset)."',emailnotification='$emailnotification',
                      startofweek='".addslashes($startofweek)."',options='$options',receivepm='$receivepm',
                      emailonpm='$emailonpm',pmpopup='$pmpopup',usergroupid='$bbuserinfo[usergroupid]',
                      nosessionhash='$nosessionhash'
                  WHERE userid='$bbuserinfo[userid]'");

with this code:
Code:

  $DB_site->query("UPDATE user
                  SET ".$updatestyles."adminemail='$adminemail',
                      showemail='$showemail',invisible='$invisible',cookieuser='$cookieuser',
                      maxposts='".addslashes($umaxposts)."',daysprune='".addslashes($prunedays)."',
                      dateformat='".addslashes($newdateformat)."',timeformat='".addslashes($newtimeformat)."',
                      timezoneoffset='".addslashes($timezoneoffset)."',emailnotification='$emailnotification',
                      startofweek='".addslashes($startofweek)."',options='$options',receivepm='$receivepm',
                      emailonpm='$emailonpm',pmpopup='$pmpopup',usergroupid='$bbuserinfo[usergroupid]',
                      nosessionhash='$nosessionhash'
                  WHERE userid='$bbuserinfo[userid]'");

(note: this code might be changed in your file due to another hack. If so, just add the code that is in red)

In global.php (main directory) add this code:
PHP Code:

// change to right date format
if ($bbuserinfo[dateformat]!="-1") {
  if (
$bbuserinfo[dateformat]=="0") {
    
$dateformat "m-d-Y";
  } elseif (
$bbuserinfo[dateformat]=="1") {
    
$dateformat "m-d-y";
  } elseif (
$bbuserinfo[dateformat]=="2") {
    
$dateformat "m.d.Y";
  } elseif (
$bbuserinfo[dateformat]=="3") {
    
$dateformat "m.d.y";
  } elseif (
$bbuserinfo[dateformat]=="4") {
    
$dateformat "d-m-Y";
  } elseif (
$bbuserinfo[dateformat]=="5") {
    
$dateformat "d.m.y";
  } elseif (
$bbuserinfo[dateformat]=="6") {
    
$dateformat "d.m.y";
  } elseif (
$bbuserinfo[dateformat]=="7") {
    
$dateformat "d.m.y";
  } elseif (
$bbuserinfo[dateformat]=="8") {
    
$dateformat "F jS, Y";
  } elseif (
$bbuserinfo[dateformat]=="9") {
    
$dateformat "l, F jS, Y";
  } elseif (
$bbuserinfo[dateformat]=="10") {
    
$dateformat "jS F Y";
  } elseif (
$bbuserinfo[dateformat]=="11") {
    
$dateformat "l, jS F Y";
  } else {
    
$dateformat "$dateformat";
  }
}

// change to right time format
if ($bbuserinfo[timeformat]!="-1") {
  if (
$bbuserinfo[timeformat]=="0") {
    
$timeformat "h:i a";
  } elseif (
$bbuserinfo[timeformat]=="1") {
    
$timeformat "h:i:s a";
  } elseif (
$bbuserinfo[timeformat]=="2") {
    
$timeformat "h:i A";
  } elseif (
$bbuserinfo[timeformat]=="3") {
    
$timeformat "h:i:s A";
  } elseif (
$bbuserinfo[timeformat]=="4") {
    
$timeformat "H:i";
  } elseif (
$bbuserinfo[timeformat]=="5") {
    
$timeformat "H:i:s";
  } else {
    
$timeformat "$timeformat";
  }


right after
PHP Code:

// ###################### Referrer Stuff ######################### 

That's it. :D
I know it might look long, but it's really very very easy to install.
If you have any troubles with that block I told you about, ask for help here.

Feedback please! :)

squawell 09-16-2001 11:53 AM

one question??

Can this hack work in version2.0.3??

where can find this code:

--------------------------------------------------------------------------------ALTER TABLE user ADD dateformat VARCHAR(4) DEFAULT '-1' not null AFTER timezoneoffset, ADD timeformat VARCHAR(4) DEFAULT '-1' not null AFTER dateformat;

Admin 09-16-2001 12:00 PM

squawell:
This was done on v2.0.3, but should work on all.

What you pasted is not in the files, it's a query you need to run.
Learn more about it here:
http://www.vbulletin.com/forum/showt...threadid=18558

Here's a demo guys. :)

squawell 09-16-2001 12:13 PM

thanks FireFly~~~

i got it!!

i just see you give the link~~~

is phpmyadmin necessary??

but i do not have it yet!!

should i install ??

Admin 09-16-2001 12:23 PM

If you have Telnet access, then it's not necessary for this praticular hack.
But it's good to have it, so I suggest you install it.

How did you run the query by the way?

squawell 09-16-2001 01:30 PM

i look the link find it's need phpmyadmin but i do not have it!!

How did you run the query by the way?-no i don't run the query!!

one question--my forum made in this space[multimania]!!

but i think this space shouldn't support Telnet access,am i ??

have another way to make this hack??

Admin 09-16-2001 01:34 PM

Nope.

Install phpMyAdmin, it's very easy to install and you'll find it very useful.

Gramphos 09-16-2001 05:22 PM

Can you allow the user to write in the dateformat itself?

Maybe in normal ways, and not in PHP format (using replace)

MarkB 09-16-2001 10:34 PM

An excellent enhancement to my board! Thanks!! :D

Freddie Bingham 09-16-2001 10:42 PM

Squawel and Gramphos please enter your license information in your profile.


All times are GMT. The time now is 01:35 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01398 seconds
  • Memory Usage 1,784KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_code_printable
  • (4)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete