Reply to topic
Restiricting Website Access
dgalfano


Joined: 11 Oct 2004
Posts: 55
Location: West Chester, PA - USA
Reply with quote
One of my clients wants to randomly restrict access to his website. So, for the % that get through, they'll get to see the page how it's intended. The blocked visitors will get to a page that says something like, the government has stopped you from viewing the material on this website, please come back later...

Is this possible (or anything close)?

Thanks,

Dan
loftboy
Forum Regular

Joined: 24 Jun 2004
Posts: 1129
Location: Colorado
Reply with quote
come to the good side (coldfusion) and i'll show u!

if not look up http cgi variables and how to extract them in .net
Josh
Forum Regular

Joined: 01 Apr 2004
Posts: 1031
Location: Felton, Delaware
Reply with quote
pfft coldfusion... if he wanted some slow and klunky java rewriter he'd have posted it in that forum Wink j/k lofty

why in the WORLD would you randomly restrict access? lol...

sure this is possible... it'd be pretty easy also. No CGI necessary. Just a subroutine run on the main page. what chance of being redirected does he want? 1 in 4, 1 in 100?
loftboy
Forum Regular

Joined: 24 Jun 2004
Posts: 1129
Location: Colorado
Reply with quote
shhhhtttttttt
ua nd your glorified fp coder lol
bobum
Elvis Fanatic
Elvis Fanatic

Joined: 16 Nov 2004
Posts: 746
Location: Montgomery, AL
Reply with quote
You could do this really easily if he knows a little coding

For example...

User hits page1 and it generates a random number (or just culls it from the session ID - my preferable method)
That number is compared to a set % of allowable visits
If it's within that % then direct them to the site and set something like a session variable to "ok for viewing"
If not direct them away and flag them "not ok for viewing" for that session

something like that...not too difficult to accomplish in any language, ASP, PHP, PERL what have you...
loftboy
Forum Regular

Joined: 24 Jun 2004
Posts: 1129
Location: Colorado
Reply with quote
ask m$ they dont let me into their cruddy site lol
um
dgalfano


Joined: 11 Oct 2004
Posts: 55
Location: West Chester, PA - USA
Reply with quote
Well, custom coding, no, I'm not so good, that's why I asked for help.

Josh, I'm not sure what percentage he'd want denied. Please tell me about this subroutine on the main page.

Bobum, not too in to custom coding, can you elaborate on your post some? I'd be working in ASP.

Thanks,

Dan
Josh
Forum Regular

Joined: 01 Apr 2004
Posts: 1031
Location: Felton, Delaware
Reply with quote
basically what I could do is exactly what Bobum said... it doesn't get any simpler than that.
loftboy
Forum Regular

Joined: 24 Jun 2004
Posts: 1129
Location: Colorado
Reply with quote
unless u use coldfusion Wink haha
bobum
Elvis Fanatic
Elvis Fanatic

Joined: 16 Nov 2004
Posts: 746
Location: Montgomery, AL
Reply with quote
Alright...here is an example for you...
It's pretty verbose, but that's to help you understand the logic...
You will put this script ina file of it's own and include it at the beginning of each of your pages...it will check to see if the user is allowed in and if they are not redirect them away. If you decide to mark them as rejected by setting the session variable "pass" as false, then they will have to start a new session by clearing out their cookies, or shutting down their browser and waiting for their session to time out on the server. If you do not set them to rejected, then they can just sit there and hit refresh till they get in.

I've commented out the actual redirects so that you can play with the script, without getting redirected all over the place everytime. Before you get ready to use the script, be sure to remove all the Respon.Writes I have in there and uncomment the redirects.

Code:
<%
If Session("pass") <> "true" Then         
                           'Check to see if they are allowed in
                           'If they are not marked as ok
                           'Determine if they have been denied
                           'Or if we need to check them
   Response.Write("You have not been passed<br>")

   If Session("pass") <> "false" Then      
                           'If they have not been checked
                           'Randomize a number
                           'Make it between 1 & 100

      Response.Write("You have not been checked either<br>")
      Response.Write("...checking you<br>")
      Randomize            
      Roll = Int(100*Rnd+1)
   
      If Roll < 10 Then         
                        'If the number is less than 10 (10%)
                        'Mark their session as ok to come in

         Response.Write("your number was " & Roll)
         Response.Write("<br>")
         Response.Write("you are ok come on in<br>")
         Session("pass") = "true"

      Else                     
                           'If their number was too high
                           'Send them on their way

         Response.Write("your number was " & Roll & ", go away<br>")
         Session("pass") = "false"
         'Response.Redirect("goaway.asp")
      End If
   Else
                     'If you decided to mark them as rejected
                     'just send them on their way
 
      'Response.Redirect("goaway.asp")
      Response.Write("You were already rejected - get outta here<br>")
   End If
End If
%>
Thanks!
dgalfano


Joined: 11 Oct 2004
Posts: 55
Location: West Chester, PA - USA
Reply with quote
for the example! I tried to test it, this is what I got:
Code:
Microsoft JScript compilation error '800a03ec'

Expected ';'

/denied/admit.asp, line 2

If Session("pass") <> "true" Then
---^


I have an index.asp w/ info + include to this script (admit.asp) and goaway.asp.
Josh
Forum Regular

Joined: 01 Apr 2004
Posts: 1031
Location: Felton, Delaware
Reply with quote
hm... the problem is that what Bobum provided for you is VBScript... you're using JScript on your site. BTW, is this Classic ASP or ASP.NET that you're using on your site?
Oops
dgalfano


Joined: 11 Oct 2004
Posts: 55
Location: West Chester, PA - USA
Reply with quote
I don't know why I did that. I guess I was hastily making test pages. I changed it to VBSCRIPT and it worked.

Thanks Bobum and Josh!

Dan
Restiricting Website Access
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT  
Page 1 of 1  

  
  
 Reply to topic