vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Time (https://vborg.vbsupport.ru/showthread.php?t=38652)

E 05-15-2002 10:07 AM

Time
 
I want to use an if statement like this

if ($action==time) {
eval (blah blah) for 6 hours;
}

i know theres time but ii dunno how to use it...

so if i want an action to do something for a certain amount of time what do i do?

Mark Hensler 05-15-2002 05:21 PM

I'm not quite sure what you want.

Do you want to adjust the timeout setting?

E 05-15-2002 11:43 PM

i want to say like.... if $away=1 then bla blah....

but i want to program that
if ($action=="away") {
$away=1 for 6 hours
}

i just need to be able to have it changed for 6 hours.. then after that time its changed back

Mark Hensler 05-16-2002 05:28 AM

You want a variable to have a value for 6 hours?
Why?
That won't do you any good unless you've got this one script running for that long (like a shell script, or daemon).

If you want to change the configuration of a program globally, try setting a flag in a database with a timestamp for it to revert. Everytime you access the flag in the DB, check the timestamp. If time()==timestamp, then revert the flag.

E 05-18-2002 09:38 AM

umm i dont understand that...
but... hmm
lets say i wanted a user away kind of thing

so if the user clicks this "I'm away button" there account would be inaccessible for like 6 hours

tubedogg 05-18-2002 10:05 AM

You would have to store the time somewhere, e.g. in a database, then check it against the current time.
PHP Code:

$then time() + ($hours*60*60); // figure out what time they're returning
$DB_site->query("INSERT INTO time (time) VALUES ($then)"); // put it in the db

// grab their return time in both timestamp and human-readable
$time $DB_site->query("SELECT time,FROM_UNIXTIME(time) AS returns FROM time");
if (
time() < $time['time']) {
  
// user is away - show when they'll be back
  
echo "User is away and will return at " $time['returns'] .".";
} else {
  
//user is not away
  
"User is present";


or something like that.

See?


All times are GMT. The time now is 12:32 AM.

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.00929 seconds
  • Memory Usage 1,721KB
  • 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
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)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