vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   Time Since Forum Leaders Offline (https://vborg.vbsupport.ru/showthread.php?t=35764)

Sinecure 03-06-2002 04:01 AM

Time Since Forum Leaders Offline
 
Would it be possible to have a hack where it displays how long its been since the forum leaders have been offline? And if they are online, it would say online! For example, if the administrator had been offline for 120 minutes. It would display it as 2 hours, but if the admin had been offline for 45 minutes, it would display it for simply 45 minutes. Same thing for days, if the minutes were however there is in a day, it would say 1 day.. So lets just go into detail here.

Lets say the admin had been offline for 31234 minutes.. For arguments sake, lets say thats equivelent to 2days, 3 hours, 12 minutes. Is this implementable? Or would it involve major hacking??

Neo 03-06-2002 05:27 AM

Not really. It could be done fairly easy. If I add a new row and use some timestamp.... so

they go offline
timestamp starts

middle
using time stamp, you calculate how long they have been offline, from time the first timestamp logged

they come online
timestamp ends

.... something like that....

Sinecure 03-06-2002 07:42 AM

sooo.. Does this mean someones working on it :)

Neo 03-06-2002 07:53 AM

Sure does. Give me a few though.

Robert9 03-06-2002 08:23 AM

kewl, but if a leader quit the forum, he had to "Log Out", or it enough, only to quit thewindow of the explorer?

Neo 03-06-2002 09:43 AM

it works either way.

Robert9 03-06-2002 09:46 AM

thats great, do you know, when you finished this hack?

Neo 03-06-2002 10:16 AM

Give me a day or so to get something together.. I have other projects aswell.

Admin 03-06-2002 10:35 AM

Why would you use a new field for cyring out loud?!

Neo 03-06-2002 10:38 AM

I have no clue... I have to look at the db first and see what I can go Mr.ProMan :p

Robert9 03-06-2002 11:18 AM

yeah, one day iss great, havephun :)

Freddie Bingham 03-06-2002 04:10 PM

/me is confused about adding new fields since you can simply reference lastvisit to figure how long it has been since someone has been online. It will be exact if the person logged out and it will be TIMENOW - lastvisit - cookietimeout if they used cookies.

Neo 03-06-2002 05:10 PM

Thats true, but I wasnt thinking about that...I was just thinking about how it would look in my head if I was coding it without the use of vb.

Neo 03-14-2002 03:52 AM

OK... I will have something soon.

Boofo 12-08-2002 12:21 AM

How soon? :)

Logik 01-02-2003 02:21 AM

I wouldn't mind this hack either. ;)

Mystis 01-02-2003 06:55 AM

Deviantart inspired? :) This should be a piece of cake, I believe I've got a function sitting around to return a formatted difference between 2 times. I'll see if I can dig it up. Sorry if I'm stepping on your toes, Neo :)

Edit: just realized how old this thread is, but I'll still finish the hack anyway, could be useful to someone :)

Mystis 01-02-2003 07:24 AM

PHP Code:

function pluralize($word,$var){
    if(
$var!=1){
        
$word $word."s";
    }
    if(
$var>0){
        
$word $var." ".$word." ";
    }else{
        
$word "";
    }
    return 
$word;
}
function 
timediff($earlier,$later){
    
$secs $earlier $later
    
$string="";
    if(
$secs>=604800){
        
$weeks 0;
        while(
$secs>=604800){
            
$secs -= 604800;
            
$weeks++;
        }
        
$string .= pluralize("week",$weeks);
    }
    if(
$secs>=86400){
        
$days 0;
        while(
$secs>=86400){
            
$secs -= 86400;
            
$days++;
        }
        
$string .= pluralize("day",$days);
    }
    if(
$secs>=3600){
        
$hours 0;
        while(
$secs>=3600){
            
$secs -= 3600;
            
$hours++;
        }
        
$string .= pluralize("hour",$hours);
    }
    if(
$secs>=60){
        
$minutes 0;
        while(
$secs>=60){
            
$secs -= 60;
            
$minutes++;
        }
        
$string .= pluralize("minute",$minutes);
    }
    return 
$string;


There are the functions anyway, you would use like this:
PHP Code:

$variable timediff(time(),$userlastvisit); 

with $userlastvisit being the field 'lastvisit' pulled from the user table from the row of the corresponding member. Then, just add $variable in any of your templates and it will return a string something like "1 day 3 hours 12 minutes", or "2 weeks 8 hours 1 minute". Let me know where you would want this information displayed, and I'll write and release a full fledged hack for it.


All times are GMT. The time now is 12:57 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.01106 seconds
  • Memory Usage 1,757KB
  • 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
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (18)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete