PDA

View Full Version : Time-Dependant Page



MuMu
10-19-2007, 01:35 PM
Hi,
I'm hoping someone can help me with this.

I have a URL for which I'd like to limit access to by time. I have a URL that I don't want accessible on between 11:00 and 23:00 (server time)- so when someone clicks on the URL during this period, a message pops up saying somthing like "sorry we're closed now etc" ...

Is this possible? if yes, how... !?

boogyman
10-19-2007, 01:43 PM
read the Posting Policy (http://www.dynamicdrive.com/forums/showthread.php?t=24866) especially #1

http://www.dynamicdrive.com/forums/showpost.php?p=111938&postcount=5

MuMu
10-19-2007, 02:10 PM
<script language="text/javascript">
Stamp = new Date();
var hour;
hour = Stamp.getHours();
if (!(hour>=7&&hour<=21)) { document.location = 'locked.htm'; }
</script>

I understand this is the code to be used - but I DON'T UNDERSTAND HOW ... can someone explain!

MuMu
10-19-2007, 02:21 PM
I've tried using the above script - without any luck... it seems I don't know how (not that it doesn't work) :mad:

P.S. I've tried doing what this script does with the help of .htaccess files (like this):


Order deny,allow
RewriteEngine on
RewriteCond %{TIME_HOUR}%{TIME_MIN} >1100
RewriteCond %{TIME_HOUR}%{TIME_MIN} <2300
RewriteRule ^produse\.html$ produse_disponibile.html
RewriteRule ^produse\.html$ produse_indisponibile.html
RewriteCond %{HTTP_USER_AGENT} Wget [OR]
RewriteCond %{HTTP_USER_AGENT} CherryPickerSE [OR]
RewriteCond %{HTTP_USER_AGENT} CherryPickerElite [OR]
RewriteCond %{HTTP_USER_AGENT} EmailCollector [OR]
RewriteCond %{HTTP_USER_AGENT} EmailSiphon [OR]
RewriteCond %{HTTP_USER_AGENT} EmailWolf [OR]
RewriteCond %{HTTP_USER_AGENT} ExtractorPro
RewriteRule ^.*$ deny.html [L]
ErrorDocument 400 eroare.html
DirectoryIndex index.html

BUT, this doesn't work... don't know why!
CAN ANYONE HELP!?

boogyman
10-19-2007, 02:22 PM
Stamp = new Date();
initiates the date javascript function

var hour;
hour = Stamp.getHours();

gets the current hour



if (!(hour>=7&&hour<=21)) { document.location = 'locked.htm'; }

evaluates what hour it is.. if hour isn't between 0700 (7am) and 2100 (9pm) send send page to some url.

djr33
10-19-2007, 02:22 PM
It is a script that will redirect if it is between that time.

you place it inside the <head> tags on your page.

You can also change the page-- locked.htm-- and the hours-- 7 and 21.

That's Javascript, not PHP.

However, a recent thread asked the same question; it has been answered several times. Search a bit and your answer will be there.

MuMu
10-19-2007, 02:27 PM
boogyman, the problem is... I don't know WHERE (in what SECTION of the HTML page) to insert this script.

P.S. THIS DOES IN THE PAGE I'M TRYING TO LIMIT ACCESS TO, RIGHT!? :confused:

boogyman
10-19-2007, 02:33 PM
put it in the<head> tags

you can read the full thread that post was from @ http://www.dynamicdrive.com/forums/showthread.php?p=111938

MuMu
10-19-2007, 02:47 PM
IT'S NOT WORKING :(
DON'T KNOW WHY...

P.S. HERE IS MY TEST LINK ... http://www.slickdeals.ro/pizza/

THE LINK THAT SHOULD BE DISABLED NOW IS PRODUSE.

boogyman
10-22-2007, 03:19 PM
that page is not found giving me the 404 error page