...

View Full Version : Whats the best way to make a recaptcha



Dan13071992
01-07-2012, 11:54 PM
I want to make a recapture script on my site, that show up every x ammount of clicks, ive already got my website to collect and update the users click ammount, when they are logged in, however Ive looked online for recapture scripts and not found many, and the ones i have found require a new session be implimented into the code inorder for it to show up, whereas I want to set mine to show the recapture box as an included file every x amount of clicks.

If anyone could help me get in the right direction ect that would be great.

Thanks

Dan

mlseim
01-08-2012, 12:07 AM
recapture ?

Do you mean "captcha" or "recaptcha"?

Dan13071992
01-08-2012, 12:17 AM
recapture ?

Do you mean "captcha" or "recaptcha"?

Yes sorry for the spelling mistake

mlseim
01-08-2012, 12:28 AM
First, you need to use PHP SESSION variable to keep track of their clicks.
With SESSION, they have to close the browser to clear the click counts.
Anyone could do that, but they would have to close and come back ...
are you OK with them being able to do that?

So you add 1 to the SESSION variable each time. If it gets to 5, you display
the captcha and reset the SESSION variable to 1. If they close their browser,
or open a different browser, that SESSION will start at 1. I have 4 browsers
on my PC (IE, FF, Safari, Chrome). That means I could jump between them
and do 4 times the number of clicks before the recaptcha appears.

Now, about the "captcha" or "recaptcha" definition ...

You said "recaptcha", which is a proprietary captcha method that you have to
register with and get a key. It's free, but it's called "ReCaptcha". "Captcha" is
the generic term of a captcha ... you can create your own if you wish and make it
as simple or complex as you choose.

Whether it appears or not, is as simple as checking the SESSION value to see if they
have reached the limit. If so, make it show and reset the SESSION value.

Not sure how much PHP experience you have, but everything described in this post is
easily found using Google.

Dan13071992
01-08-2012, 12:33 AM
i get where your coming from, however i was actually going to do it this way:

i have in the users table a number of clicks feild called 'clicks' i was going to have the Captcha come up every x amount of clicks, but in my inc-userfunctions.php page it will update the clicks+1 each time they go to a new page, then if that page reaches the x amount of clicks, the Captcha is displayed and they cannot go to another page till they pass the Captcha, a bit like making someone accept the Terms of Service on your site, it wont let them do anything else until they have accepted. that was my general idea on it instead of using sessions

mlseim
01-08-2012, 12:35 AM
What are you using to keep track of their clicks ... if you're not using SESSION?

Dan13071992
01-08-2012, 12:41 AM
my inc-userfunctions.php page, its included in every single page that a user is logged into, and i was going to do:




$newclicks = $fetch->clicks + 1;

mysql_query(UPDATE users SET clicks='".dbSafe($newclicks)."' WHERE username='".dbSafe($fetch->username)."'");


then in the pages that will need the recaptcha (which wont be all pages, it will be just the main pages) it will be as an include if their click are >= x amount of clicks

mlseim
01-08-2012, 01:05 AM
oh ....
You have a database with the user's clicks ... that's a whole different story.

In your main pages, where you need the captcha, display it if $newlinks is > 10 (or whatever).

<?php if($newclicks > 10){
// display the recaptcha and nothing else.
}


The ONLY thing that can reset the database count to 1 is a successful recaptcha.
You do that right in the recaptcha script. Connect to database and UPDATE 'clicks'.
They will be stuck on the recaptcha and nothing else until it's successful.

Dan13071992
01-08-2012, 01:08 AM
oh ....
You have a database with the user's clicks ... that's a whole different story.

In your main pages, where you need the captcha, display it if $newlinks is > 10 (or whatever).

<?php if($newclicks > 10){
// display the recaptcha and nothing else.
}


The ONLY thing that can reset the database count to 1 is a successful recaptcha.
You do that right in the recaptcha script. Connect to database and UPDATE 'clicks'.
They will be stuck on the recaptcha and nothing else until it's successful.

Yes thats right, however I need to make the captcha, thats what this thread was all about as i dont know how to make a captcha, so i was asking to be point in the right direction to one that doesnt run off sessions, if that makes sense?

mlseim
01-08-2012, 01:12 AM
How sophisticated of a captcha?
If you want to do the whole distorted image thing, that's going to be harder.
If you want to give them a, "What's 2 + 3" and make them enter '5',
that would be easy.

Is the captcha supposed to delay the user (slow them down), or does it have
to totally thwart all captcha recognition software? The more secure, the more
scripting you need to do.

In any event, I would add a new column to the database to store the captcha value.
That would be doing it without SESSION.


.

Dan13071992
01-08-2012, 01:16 AM
i can do it with numbers, but maybe a bit more complex than 2+5, maybe along the lines of 2 + 5 + a then in the box they have to do it without entering the letter of the althabet, if that makes sense?

or even just a box that looks like am image, that infact is just 3 or 4 letters inside it that they have to enter and submit?

Dan13071992
01-10-2012, 01:16 PM
bump - can anyone direct me or help me to make a captcha?

mlseim
01-10-2012, 01:46 PM
I don't know how you'll do it without SESSION or cookie. I suppose AJAX?
Too much scripting for me ... as I don't have any free time now.

Dan13071992
01-10-2012, 02:54 PM
ok thanks for the reply, if you do get a chance or some spare time do you think you could point me in the right direction?

BluePanther
01-10-2012, 03:01 PM
I, personally, have never made a capcha because the recapcha library is so good. I use it all the time - VERY easy to implement and very easy to use. Also helps digitalise books!

But, I do remember seeing some threads in this very forum about someone wanting to make their own capcha (as a learning exercise) - I would give the forum a search.

Dan13071992
01-10-2012, 03:03 PM
ok, ill take a look now, cheers guys :)

mlseim
01-10-2012, 04:04 PM
I agree, recaptcha is the best.
But I do believe it uses PHP SESSION?

BluePanther
01-10-2012, 04:16 PM
I agree, recaptcha is the best.
But I do believe it uses PHP SESSION?

No, I don't think it does. I'm pretty sure it uses it's server and HTTP requests.

What is the issue with using SESSION anyway?

mlseim
01-10-2012, 06:18 PM
I don't know?
He doesn't want to use SESSION (or cookies I assume).
Not sure why.

Dan13071992
01-10-2012, 08:00 PM
im sorry, my understanding of how sessions were used during a captcha were completely wrong, i have now got a recaptcha working :) and up and running, however i need a better background image lol, but there is a question i want to ask:

how can i make the font bigger and bolder on this recaptcha, code is below:



function captcha_text(){
$length = 3;
$options = "abc2def3ghj4kmn5pqr6stu7vwx8yz9";
$option_length = (strlen($options)-1);
$captcha = "";
$i = 0;
while ($i < $length){
$random = mt_rand(0, $option_length);
$captcha .= $options[$random];
$i++;
}
return $captcha;
}
//Creating the captcha text
$captcha = captcha_text();

//Storing the captcha text to a session
session_start();
$_SESSION['captcha'] = $captcha;
//Preparing for the image header
("Content-type: image/gif");
$image=imagecreatefromjpeg("captcha.jpg");
//Making the color white
$white = imagecolorallocate($image, 255,255,255);

//Displaying captcha text
imagestring($image, 12, 15, 15, $captcha, $white);
//Creating the image, then removing it from memory
imagegif($image);
imagedestroy($image);

mlseim
01-11-2012, 12:33 AM
I thought I saw something on customizing re-captcha ...
If I find it, I'll post.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum