| | |
Help with CAPTCHA
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Nov 2006
Posts: 1
Reputation:
Solved Threads: 0
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
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
•
•
•
•
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!
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
•
•
Join Date: Apr 2007
Posts: 1
Reputation:
Solved Threads: 0
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
Captcha ZDR anti spamm protection
Best regards
zdrsoft
![]() |
Similar Threads
Other Threads in the PHP Forum
- Previous Thread: fwrite every other time
- Next Thread: anybody give me suggestion for my final year project??
| Thread Tools | Search this Thread |
# 5.2.10 alexa apache api array beginner binary broken cakephp checkbox class clean clients cms code cron curl database date directory display dissertation dropdown dynamic echo echo$_get[x]changingitintovariable... email encode error fairness file files folder form forms function functions google href htaccess html image images include indentedsubcategory insert ip javascript joomla legislation limit link local login mail memberships menu mlm multiple multipletables mysql mysqlquery newsletters oop open paypal pdf persist php problem provider query radio random recursion remote rss script search server sessions sms sockets source space spam sql syntax system table tutorial update upload url validator variable video web youtube






