Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 05-02-2003, 06:09 PM
webhost's Avatar
webhost webhost is offline
 
Join Date: Oct 2001
Location: St. Louis
Posts: 577
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Time Based Page Redirection

We have a contact us page with online/open times and other information.

We would like to also have a page that is somewhat different from the online page lets call it offline page.

How would one use a php statement based on server time to have it automatically switch between pages?
Reply With Quote
  #2  
Old 05-02-2003, 07:43 PM
Black Vivi's Avatar
Black Vivi Black Vivi is offline
 
Join Date: Dec 2002
Location: United Kingdom
Posts: 120
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

try this:

PHP Code:
$hour date("G");

if (
$hour /* OFFLINE PAGE HOUR */) {
    
/* OFFLINE PAGE */
} else {
    
/* ONLINE PAGE */

replace what's in the block quotes with whatever you want.
so, an example of a page would be:

PHP Code:
$hour date("G");

if (
$hour 18 || $hour 6) {
    echo(
"We are currently offline!");
} else {
    echo(
"We are currently online!");

Reply With Quote
  #3  
Old 05-02-2003, 07:55 PM
webhost's Avatar
webhost webhost is offline
 
Join Date: Oct 2001
Location: St. Louis
Posts: 577
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

We want the time to switch between say contacton.html and contactoff.html
Reply With Quote
  #4  
Old 05-02-2003, 09:18 PM
Black Vivi's Avatar
Black Vivi Black Vivi is offline
 
Join Date: Dec 2002
Location: United Kingdom
Posts: 120
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

what times do you want it to display "contactoff.html"?

then ill just give u the code.
Reply With Quote
  #5  
Old 05-02-2003, 09:36 PM
webhost's Avatar
webhost webhost is offline
 
Join Date: Oct 2001
Location: St. Louis
Posts: 577
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

http://www.realwebhost.net.contact.php = online
12:00 pm to 6:00 pm
http://www.realwebhost.net/contact1.php = offline
6:00pm to 12:00 pm

has to be hours and minutes not just hours are there will a hour delay
Reply With Quote
  #6  
Old 05-02-2003, 09:53 PM
webhost's Avatar
webhost webhost is offline
 
Join Date: Oct 2001
Location: St. Louis
Posts: 577
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is what we have in contact.php
PHP Code:
<?php 

// the online time will be from 14 to 16:59 
// taking minutes into consideration was 
// more trouble 
/// so $onlineuntil should be realend - 1 
$onlinefrom 12// in hours 
$onlineuntil 18// in hours 

// $date holds the current HH 
$date date('H'time()); 

if ( ! (
$onlinefrom <= $date && $date <= $onlineuntil) ) {
    
header("Location: [url]http://www.realwebhost.net/contact1.php[/url]");
}
?>
This what we have in contact1.php

PHP Code:
<?php 

// the online time will be from 14 to 16:59 
// taking minutes into consideration was 
// more trouble 
/// so $onlineuntil should be realend - 1 
$onlinefrom 18// in hours 
$onlineuntil 12// in hours 

// $date holds the current HH 
$date date('H'time()); 

if (
$onlinefrom <= $date && $date <= $onlineuntil) {
    
header("Location: [url]http://www.realwebhost.net/contact.php[/url]");
}

?>

But it does not work.
Reply With Quote
  #7  
Old 05-03-2003, 06:29 AM
Black Vivi's Avatar
Black Vivi Black Vivi is offline
 
Join Date: Dec 2002
Location: United Kingdom
Posts: 120
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

try this:

contact.php
PHP Code:
<?php 

// the online time will be from 14 to 16:59 
// taking minutes into consideration was 
// more trouble 
/// so $onlineuntil should be realend - 1 
$onlinefrom "14:00"// in hours 
$onlineuntil "16:59"// in hours 

// $date holds the current HH 
$date date("G:i"); 

if (
$onlinefrom >= $date || $date >= $onlineuntil) {
    
header("Location: contact1.php");
}

?>
and this for contact1.php
PHP Code:
<?php 

// the online time will be from 14 to 16:59 
// taking minutes into consideration was 
// more trouble 
/// so $onlineuntil should be realend - 1 
$onlinefrom "14:00"// in hours 
$onlineuntil "11:59"// in hours 

// $date holds the current HH 
$date date("G:i"); 

if (
$onlinefrom <= $date || $date >= $onlineuntil) {
    
header("Location: contact.php");
}

?>
Reply With Quote
  #8  
Old 05-03-2003, 11:32 AM
webhost's Avatar
webhost webhost is offline
 
Join Date: Oct 2001
Location: St. Louis
Posts: 577
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you very much, we will try it. We last nite when what we had did not work went with 2 files and 2 perl scripts and run them from cron.But we will try this.

Thank You for your effort.
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 11:06 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.04341 seconds
  • Memory Usage 2,247KB
  • Queries Executed 11 (?)
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
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (6)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete