vb.org Archive

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

webhost 05-02-2003 06:09 PM

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?

Black Vivi 05-02-2003 07:43 PM

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!");



webhost 05-02-2003 07:55 PM

We want the time to switch between say contacton.html and contactoff.html

Black Vivi 05-02-2003 09:18 PM

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

then ill just give u the code.

webhost 05-02-2003 09:36 PM

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

webhost 05-02-2003 09:53 PM

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.

Black Vivi 05-03-2003 06:29 AM

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");
}

?>


webhost 05-03-2003 11:32 AM

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.


All times are GMT. The time now is 07:05 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.01327 seconds
  • Memory Usage 1,746KB
  • 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
  • (6)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)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