Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 132,665 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,157 people online right now. Registration is fast and FREE... Join Now!




Turing Image Check Before Accessing Site

 
Reply to this topicStart new topic

Turing Image Check Before Accessing Site, Turing Check is Required when user tries to access the site

mukeshid
post 1 Aug, 2007 - 12:51 PM
Post #1


New D.I.C Head

*
Joined: 1 Aug, 2007
Posts: 17


My Contributions


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: 1 Aug, 2007 - 01:05 PM
User is offlineProfile CardPM

Go to the top of the page

PsychoCoder
post 1 Aug, 2007 - 01:02 PM
Post #2


using DIC.Core;

Group Icon
Joined: 26 Jul, 2007
Posts: 8,933



Thanked 118 times

Dream Kudos: 8525

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions


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.

smile.gif
User is offlineProfile CardPM

Go to the top of the page

mukeshid
post 1 Aug, 2007 - 01:07 PM
Post #3


New D.I.C Head

*
Joined: 1 Aug, 2007
Posts: 17


My Contributions


QUOTE(PsychoCoder @ 1 Aug, 2007 - 02:02 PM) *

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.
smile.gif

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.
User is offlineProfile CardPM

Go to the top of the page

PsychoCoder
post 1 Aug, 2007 - 01:11 PM
Post #4


using DIC.Core;

Group Icon
Joined: 26 Jul, 2007
Posts: 8,933



Thanked 118 times

Dream Kudos: 8525

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions


QUOTE(mukeshid @ 1 Aug, 2007 - 02:07 PM) *

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 smile.gif
User is offlineProfile CardPM

Go to the top of the page

mukeshid
post 1 Aug, 2007 - 01:13 PM
Post #5


New D.I.C Head

*
Joined: 1 Aug, 2007
Posts: 17


My Contributions


QUOTE(PsychoCoder @ 1 Aug, 2007 - 02:11 PM) *

QUOTE(mukeshid @ 1 Aug, 2007 - 02:07 PM) *

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 smile.gif


Yes server is Apache!!!
User is offlineProfile CardPM

Go to the top of the page

PsychoCoder
post 1 Aug, 2007 - 01:23 PM
Post #6


using DIC.Core;

Group Icon
Joined: 26 Jul, 2007
Posts: 8,933



Thanked 118 times

Dream Kudos: 8525

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions


QUOTE(mukeshid @ 1 Aug, 2007 - 02:13 PM) *

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. smile.gif
User is offlineProfile CardPM

Go to the top of the page

PsychoCoder
post 1 Aug, 2007 - 01:46 PM
Post #7


using DIC.Core;

Group Icon
Joined: 26 Jul, 2007
Posts: 8,933



Thanked 118 times

Dream Kudos: 8525

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions


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

CODE

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 smile.gif


Attached File(s)
Attached File  mod_rewrite_cheat_sheet.pdf ( 324.35k ) Number of downloads: 32
User is offlineProfile CardPM

Go to the top of the page

mukeshid
post 1 Aug, 2007 - 02:00 PM
Post #8


New D.I.C Head

*
Joined: 1 Aug, 2007
Posts: 17


My Contributions


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!!!
User is offlineProfile CardPM

Go to the top of the page

PsychoCoder
post 1 Aug, 2007 - 02:16 PM
Post #9


using DIC.Core;

Group Icon
Joined: 26 Jul, 2007
Posts: 8,933



Thanked 118 times

Dream Kudos: 8525

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions


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

CODE

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.yourdomain.com/?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 smile.gif
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 05:49AM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month