Restrict page to open by date????

Discussion in 'ASP General' started by Marce Poulin, Dec 26, 2006.

  1. Marce Poulin

    Marce Poulin Guest

    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
     
    Marce Poulin, Dec 26, 2006
    #1
    1. Advertising

  2. Marce Poulin

    Trevor L. Guest

    Marce Poulin wrote:
    > 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/
    ----------------------------------------
     
    Trevor L., Dec 26, 2006
    #2
    1. Advertising

  3. Marce Poulin

    Mike Brind Guest

    "Trevor L." <Trevor_L.@Canberra> wrote in message
    news:%...
    > Marce Poulin wrote:
    >> 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.


    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.

    --
    Mike Brind
     
    Mike Brind, Dec 26, 2006
    #3
  4. Marce Poulin

    Evertjan. Guest

    Mike Brind wrote on 26 dec 2006 in
    microsoft.public.inetserver.asp.general:

    >> Marce Poulin wrote:
    >>> 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


    > <%
    > 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 < and the > ?

    > 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

    %>



    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Dec 26, 2006
    #4
  5. Marce Poulin

    Mike Brind Guest

    "Evertjan." <> wrote in message
    news:Xns98A5B4F28EA2Beejj99@194.109.133.242...
    > Mike Brind wrote on 26 dec 2006 in
    > microsoft.public.inetserver.asp.general:
    >
    >>> Marce Poulin wrote:
    >>>> 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

    >
    >> <%
    >> 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 < and the > ?
    >
    >> 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.

    --
     
    Mike Brind, Dec 26, 2006
    #5
  6. Marce Poulin

    Evertjan. Guest

    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.

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Dec 26, 2006
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt
    Replies:
    1
    Views:
    609
    Matthew Speed
    Nov 8, 2003
  2. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,279
    Michael Borgwardt
    May 30, 2004
  3. Matt
    Replies:
    2
    Views:
    520
    Pete Becker
    Nov 8, 2003
  4. Matt
    Replies:
    3
    Views:
    724
    Richard Heathfield
    Nov 8, 2003
  5. Tom
    Replies:
    1
    Views:
    515
Loading...

Share This Page