Help with CAPTCHA

Reply

Join Date: Nov 2006
Posts: 1
Reputation: blah23 is an unknown quantity at this point 
Solved Threads: 0
blah23 blah23 is offline Offline
Newbie Poster

Help with CAPTCHA

 
0
  #1
Nov 13th, 2006
Hello, I recently downloaded and uploadee Secuimage CAPTCHA Class Version 0.3 PHP4 from http://www.neoprogrammers.com/ and Im having some problems.

1) It always says that the code entered is wrong, even in the example forms. I tried it with my altered code and without and it still never says it is correct

2) Sometimes the image doesnt load and the page needs to be refreshed before it does load, is there a way to fix this?

Thanks for your help
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 1,073
Reputation: digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice 
Solved Threads: 66
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Veteran Poster

Re: Help with CAPTCHA

 
0
  #2
Nov 13th, 2006
Originally Posted by blah23 View Post
Hello, I recently downloaded and uploadee Secuimage CAPTCHA Class Version 0.3 PHP4 from http://www.neoprogrammers.com/ and Im having some problems.

1) It always says that the code entered is wrong, even in the example forms. I tried it with my altered code and without and it still never says it is correct

2) Sometimes the image doesnt load and the page needs to be refreshed before it does load, is there a way to fix this?

Thanks for your help

Hi,

I looked through the captcha class briefly.

Normally a captcha class would use the built in session functions for PHP but this particular one just writes the results of each captcha to a file. By default it is:

[PHP]var $data_directory = "./image_data";
//path of directory to store code data in. make sure this is either outside of the webroot or unreadable[/PHP]

See the code:

[PHP]function saveData()
{
$filename = md5($this->hash_salt . $_SERVER['REMOTE_ADDR']);
$fp = fopen($this->data_directory . "/" . $filename, "w+");
fwrite($fp, md5( $this->hash_salt . strtolower($this->code) ) );
fclose($fp);
}

function validate()
{
$filename = md5($this->hash_salt . $_SERVER['REMOTE_ADDR']);

$enced_code = trim(@file_get_contents($this->data_directory . "/" . $filename));

$check = md5($this->hash_salt . strtolower($this->code_entered));

if($check == $enced_code) {
$this->correct_code = TRUE;
@unlink($this->data_directory . "/" . $filename);
} else {
$this->correct_code = FALSE;
}
}

function checkCode()
{
return $this->correct_code;
}

function pruneOld()
{
if ($handle = @opendir($this->data_directory)) {
while (($filename = readdir($handle)) !== false) {
if(time() - filemtime($this->data_directory . "/" . $filename) > $this->prune_minimum_age * 60) {
@unlink($this->data_directory . "/" . $filename);
}
}
closedir($handle);
}
}[/PHP]

It may be that the script cannot write to the folder specified by:

var $data_directory

You may have to chmod it to 755, either via ftp or modify the PHP to do that automatically.

Since the captcha only outputs an image, it would be a bit hard to debug, but you could probably change the output temporarily so you can debug.

[PHP]function output()
{
header("Expires: Sun, 1 Jan 2000 12:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Content-Type: image/jpeg");
imagejpeg($this->im);
imagedestroy($this->im);
}[/PHP]

to
[PHP]
function output()
{

return; // add a return so we dont send image headers, but output the default Content-Type of text/html so we can see errors

header("Expires: Sun, 1 Jan 2000 12:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Content-Type: image/jpeg");
imagejpeg($this->im);
imagedestroy($this->im);
}[/PHP]

I believe the use of custom disk writing functions instead of the regular PHP session functions is to not interfere with the larger php app that would be using the captch class, but it would probably be easier if you just used the Session Functions if you already have a session going on your site...

Hope that helps abit.
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 1
Reputation: zdrsoft is an unknown quantity at this point 
Solved Threads: 0
zdrsoft zdrsoft is offline Offline
Newbie Poster

Re: Help with CAPTCHA

 
0
  #3
Apr 23rd, 2007
You can use "Captcha ZDR". Please review and leave your comment about that new captcha class writen in PHP.

Captcha ZDR anti spamm protection

Best regards
zdrsoft
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC