Restrict page to open by date????

M

Marce Poulin

I'm trying to find out how I can make a page to be restricted to open
between Saturdays 12:05 pm until Sundays10: pm... and that.. EVERY WEEK...
is there any way at all to do this or is it just simply impossible.???
thanks
 
T

Trevor L.

Marce said:
I'm trying to find out how I can make a page to be restricted to open
between Saturdays 12:05 pm until Sundays10: pm... and that.. EVERY
WEEK... is there any way at all to do this or is it just simply
impossible.??? thanks

I'd have to think know about doing it using ASP.

But with client side Javascript, one could extract the current date and time
and then check it against that time window.

If it is within that time window, then reveal a hidden <div>. If not, reveal
an hidden error <div>.

A side issue is what time?
The time on the visitor's server?
This could differ widely.

--
Cheers,
Trevor L.
[ Microsoft MVP - FrontPage ]
MVPS Website: http://trevorl.mvps.org/
----------------------------------------
 
M

Mike Brind

Trevor L. said:
I'd have to think know about doing it using ASP.

The following will set a boolean value to True if the time on the server
falls between the limits set in the OP. If False, it redirects the browser
to another page.

<%
Dim opened
opened = False
If WeekDay(Now()) >= 7 And Hour(Now()) >= 12 And Minute(Now()) >= 5 Then
opened = True
If WeekDay(Now()) <= 1 And Hour(Now()) <= 22 And Minute(Now()) <> 0 Then
opened = True
If opened = False Then Response.Redirect "otherpage"
%>
But with client side Javascript, one could extract the current date and
time and then check it against that time window.

Not a good idea. If the purpose is to prevent access to the content of a
page then client-side javascript can easily be disabled, rendering it
useless.
If it is within that time window, then reveal a hidden <div>. If not,
reveal an hidden error <div>.

A side issue is what time?
The time on the visitor's server?

Another good reason not to use client-side code. ASP acts on the hosting
server, where the time zone is predictable. Additionally, placing the
restricted content in a div with it's "visible" set to none does not prevent
the content being readable in the source code of the page. That is no more
secure than using hidden form fields for sensitive information, for example.
 
E

Evertjan.

Mike Brind wrote on 26 dec 2006 in
microsoft.public.inetserver.asp.general:
<%
Dim opened
opened = False
If WeekDay(Now()) >= 7 And Hour(Now()) >= 12 And Minute(Now()) >= 5

What about:
13:04
14:04
..... ?
Then opened = True
If WeekDay(Now()) <= 1 And Hour(Now()) <= 22 And Minute(Now()) <> 0

what about 17:00 exactly ?

WeekDay(Now()) >= 7
WeekDay(Now()) <= 1

why the said:
Then opened = True
If opened = False Then Response.Redirect "otherpage"
%>

Try:

<%
If NOT _
( WeekDay(Now())=7 _
AND _
( ( Hour(Now())=12 AND Minute(Now())>4 ) OR Hour(Now())>12 ) )_
AND NOT _
( WeekDay(Now())=1 AND Hour(Now())<22 ) _
Then
Response.Redirect "otherpage"
End If
%>

or [I like this one better]:

<%

mn = Hour(Now())*60 + Minute(Now())
wd = WeekDay(Now())

If NOT ( wd=7 AND mn>12*60+4 ) _
AND NOT ( wd=1 AND mn<22*60 ) Then
Response.Redirect "otherpage"
End If

%>
 
M

Mike Brind

Evertjan. said:
Mike Brind wrote on 26 dec 2006 in
microsoft.public.inetserver.asp.general:
<%
Dim opened
opened = False
If WeekDay(Now()) >= 7 And Hour(Now()) >= 12 And Minute(Now()) >= 5

What about:
13:04
14:04
.... ?
Then opened = True
If WeekDay(Now()) <= 1 And Hour(Now()) <= 22 And Minute(Now()) <> 0

what about 17:00 exactly ?

WeekDay(Now()) >= 7
WeekDay(Now()) <= 1

why the said:
Then opened = True
If opened = False Then Response.Redirect "otherpage"
%>

Try:

<%
If NOT _
( WeekDay(Now())=7 _
AND _
( ( Hour(Now())=12 AND Minute(Now())>4 ) OR Hour(Now())>12 ) )_
AND NOT _
( WeekDay(Now())=1 AND Hour(Now())<22 ) _
Then
Response.Redirect "otherpage"
End If
%>

or [I like this one better]:

<%

mn = Hour(Now())*60 + Minute(Now())
wd = WeekDay(Now())

If NOT ( wd=7 AND mn>12*60+4 ) _
AND NOT ( wd=1 AND mn<22*60 ) Then
Response.Redirect "otherpage"
End If

%>

I think the most suitable expression I can come up with is Doh!

I prefer your second one too.

--
 
E

Evertjan.

Mike Brind wrote on 26 dec 2006 in microsoft.public.inetserver.asp.general:
I prefer your second one too.

At my third xmass meal my wandering mind came up with this:

<%

n = DateAdd("h", 6, Now)
'' Time zone correction in my case, server to main user group.
'' Calling now() only once prevents the minute possiblility of a
'' in row date switch.

minutes = (WeekDay(n)-1)*60*24 + Hour(n)*60 + Minute(n)
'' total of minutes since last Sunday 00:00

If ( minutes > 0*60*24+22*60-1 ) OR ( minutes < 6*60*24+12*60+5 ) Then
Response.Redirect "otherpage"
End If

%>

So we skip all those error prone NOTs.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top