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

Reply
 
Thread Tools Display Modes
  #1  
Old 05-02-2003, 05: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, 06: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, 06: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, 08: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, 08: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, 08: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, 05: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, 10: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 07:16 AM.


Powered by vBulletin® Version 3.9.0
Copyright ©2000 - 2017, vBulletin Solutions Inc.