Turing Image Check Before Accessing Site

Turing Check is Required when user tries to access the site

Page 1 of 1

8 Replies - 1932 Views - Last Post: 01 August 2007 - 03:16 PM Rate Topic: -----

#1 mukeshid  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 01-August 07

Turing Image Check Before Accessing Site

Post icon  Posted 01 August 2007 - 01:51 PM

Hello Programmers,
I am also a programmer and knows a good amount of PHP etc.

But now i am in a bit of problem, and unable to understand how can i crack it out.

What i want is a turing number image check for the user if he tries to access any page on home directory of the site.

Suppose the user tries to access www.mydomain.com/test1.php, and if he is accessing the site for the first time ( in that session, or ip check whatever ), it should ask for a turing number image check from the user. and when he got cleared with the turing check, he can access any site on that domain, and need not to enter it again.
the main issue is that if it would have been with a single file, i could have embeded it in that file. but right it's with whole sub-direcoty to be preented. so i can't put the lines in each and every page.

Can you guys tell me any solution or way for this..??

MAJOR PROBLEM :: PAGES ARE ENCODED, I CAN'T EDIT THEM.

** If user has successfully passed turing check once, then he should be able to successfull access req page, with all get & post etc requests successfully.
** There may be case, when i want few pages on site to be excluded from this check, if it's possible, please explain too.

and demo of such work is here: relaxbusiness.biz

This post has been edited by mukeshid: 01 August 2007 - 02:05 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Turing Image Check Before Accessing Site

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1633
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Turing Image Check Before Accessing Site

Posted 01 August 2007 - 02:02 PM

Well for starters I believe you're going to need something in each of the pages, not the turing image code but something to check to see if they've passed the verification yet. You can do this in a couple different ways.

You can do it by checking the HTTP REFERRER, if its not from within your domain then redirect them to a central page where they have to pass the turing image verification. Once they pass the verification set a cookie (with its expiration to 0 so it expires once they leave your site) stating that they've passed the verification and have the right to navigate through the site. But you will have to check for that cookie and the referrer on each page (you can put the check in an includes file then include it on each page).

Thats really the simplest solution I can think of at the moment, maybe someone with expert PHP knowledge may have a PHP solution I wouldn't be able to formulate.

:)
Was This Post Helpful? 0
  • +
  • -

#3 mukeshid  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 01-August 07

Re: Turing Image Check Before Accessing Site

Posted 01 August 2007 - 02:07 PM

View PostPsychoCoder, on 1 Aug, 2007 - 02:02 PM, said:

Well for starters I believe you're going to need something in each of the
..
.
may have a PHP solution I wouldn't be able to formulate.
:)

HTTP Referrer is a good solution.
But i can't EDIT the pages, so anyhow i have to take requests to a central page using mod_rewrites (don't know how to use them, just a guess), then check.
and as per req, if page called, passing all perameters passed to that page.
Was This Post Helpful? 0
  • +
  • -

#4 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1633
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Turing Image Check Before Accessing Site

Posted 01 August 2007 - 02:11 PM

View Postmukeshid, on 1 Aug, 2007 - 02:07 PM, said:

HTTP Referrer is a good solution.
But i can't EDIT the pages, so anyhow i have to take requests to a central page using mod_rewrites (don't know how to use them, just a guess), then check.
and as per req, if page called, passing all perameters passed to that page.


I imagine this site is running on an Apache server (am I right?) if so there is more than likely a server setting that can be used to redirect all page requests to a central page, then from there check the cookie set when they pass the turing validation and redirect them to the page they initially requested. Doing it this way requires no editing of any other page since all requests would be filtered through the one central page.

Sorry I don't know much about Apache, I'm a Windows/IIS man myself, but trust me there are plenty of programmers here who do know :)
Was This Post Helpful? 0
  • +
  • -

#5 mukeshid  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 01-August 07

Re: Turing Image Check Before Accessing Site

Posted 01 August 2007 - 02:13 PM

View PostPsychoCoder, on 1 Aug, 2007 - 02:11 PM, said:

View Postmukeshid, on 1 Aug, 2007 - 02:07 PM, said:

HTTP Referrer is a good solution.
..
.
and as per req, if page called, passing all perameters passed to that page.


I imagine this site is running on an Apache server (am I right?) if so there is ...
..
/IIS man myself, but trust me there are plenty of programmers here who do know :)


Yes server is Apache!!!
Was This Post Helpful? 0
  • +
  • -

#6 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1633
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Turing Image Check Before Accessing Site

Posted 01 August 2007 - 02:23 PM

View Postmukeshid, on 1 Aug, 2007 - 02:13 PM, said:

Yes server is Apache!!!


Here is a great tidbit (for beginners such as yourself) for people just diving into mod_rewrite which will allow you to redirect all incoming requests and redirect them to the page you desire, that way you can have them to the turing image validation, set the cookie when they pass, then each time they request a new page they will come back to that same page, then you just check the cookie and forward them as requested.

While you're reading that I'll see if I can come up with a sample mod_rewrite example for you. :)
Was This Post Helpful? 0
  • +
  • -

#7 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1633
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Turing Image Check Before Accessing Site

Posted 01 August 2007 - 02:46 PM

An example of a mod_rewrite to gather any incoming request to your domain and redirect them where you want them to go

RewriteCond %{HTTP_HOST} ^www.yourdomain.com$ [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/your_request_page.php [R=403,L]



This will grab any incoming request to YourDomain.Com and redirect it to YourDomain.com/your_request_page.php. I am also attaching a mod_rewrite "cheat sheet" I found at ILoveJackDaniels.Com. You need to also do a search on Google for apache mod_rewrite, there are tons of examples for you.

Hope this helps :)

Attached File(s)


Was This Post Helpful? 0
  • +
  • -

#8 mukeshid  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 01-August 07

Re: Turing Image Check Before Accessing Site

Posted 01 August 2007 - 03:00 PM

Thanks Bro!!
now i have grabbed all requests to a single page.
Now, What if the user is already authenticated, then how he will be redirected to his desired page, with all is form feeds (get & posts)

e.g he was going to access abd.html, but due to this he is at testpage right now, and as he cleared the test, how the script will decide that he needs to be sent to abd.html, that too with all form data (get & post data) he had, and posted in same manner, i.e. Get=> Get, Post => Post!!!
Was This Post Helpful? 0
  • +
  • -

#9 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1633
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Turing Image Check Before Accessing Site

Posted 01 August 2007 - 03:16 PM

First thing you need is a way to store the initial request, you can actually do this in the RewriteRule

RewriteCond %{HTTP_HOST} ^www.yourdomain.com$ [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/your_request_page.php [R=403,L]

RewriteCond %{THE_REQUEST} (.+)
RewriteRule  ^your_request_page\.php$ http://www.yourdomain.com/?the_request=%1 [NC,R=301,L] 



This will actually make the URL in the address bar look like

http://www.yourdomai...the_request=GET /the_requested_page.php HTTP/1.1

Then in your central page you grab the page name from between the / and HTTP (you get to do this string manipulation as I'm not going to do all the work for you here, just trying to give you examples to get you on the right track)

Then you have the page they initially requested (stored in a variable on the central page). On this central page you have code to check for the cookie that gets set when they pass the turing image validation, if it doesn't exist you display the turing image and take them through that process, if it does exist and everything is valid then you forward them to their page.

Hope this helps :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1