Image Verification *captach* not working

Status
Not open for further replies.

sgrpdl

New Member
Messages
63
Reaction score
0
Points
0
Few days ago GdLibrary error - which is now is fixed.
But Image verification problem is stil same, is this due to same basic php v.?
My image verification does not show the image....
Tech team when this php issue gona be fixed..
 

garrettroyce

Community Support
Community Support
Messages
5,611
Reaction score
249
Points
63
What software are you using? My forum has a CAPTCHA and it doesn't use GD.
 

sgrpdl

New Member
Messages
63
Reaction score
0
Points
0
Well my image verification require require GD Library.
Isn't Gd Library is installed???
 

garrettroyce

Community Support
Community Support
Messages
5,611
Reaction score
249
Points
63
GD is installed on all servers, to my knowledge. You can test this using the phpinfo() function:

Code:
<?
phpinfo();
?>

Create this file and open it in your browser. It should display all the modules compiled into php, including GD. Make sure you delete it after you use it.
 

xav0989

Community Public Relation
Community Support
Messages
4,467
Reaction score
95
Points
0
add
PHP:
error_reporting(E_ALL);
just after the
PHP:
<?
, browse to the image script, post any error message and delete the line you added.
 

sgrpdl

New Member
Messages
63
Reaction score
0
Points
0
Ya it says gd is installed but why my image verification not working, code is correct coz past it use to work w/o any problem. I checked in another server too and it works w/o problem.


i found this error when i tried to open the captcha image by its link. Plz tell me what is wrong here...


---
Warning: fclose() [function.fclose]: 2 is not a valid stream resource in /home/edited/public_html/contact/contact.php on line 83

Warning: fclose() [function.fclose]: 2 is not a valid stream resource in /home/edited/public_html/contact/contact.php on line 86

Warning: Cannot modify header information - headers already sent by (output started at /home/edited/public_html/contact/contact.php:83) in /home/edited/public_html/contact/contact.php on line 89

-------

But same code works in my other server w/o any error :(


73 $Handle = opendir('code');
74
75 while ( $CaptchaFile = readdir($Handle) ) {
76 if ( substr($CaptchaFile, 0, 1) != '.' ) {
77 if ( ( filemtime('code' . '/' . $CaptchaFile) + 900 * 60 ) < time() ) {
78 unlink('code' . '/' . $CaptchaFile);
79 }
80 }
81 }
82
83 fclose($Handle);
84
85 $handle = fopen('code' . '/' . $FileName, 'w');
86 fclose($Handle);
87
88 if (imagetypes() & IMG_JPG) {
89 header("Content-type: image/jpeg");
90 imagejpeg($im);
91 } elseif (imagetypes() & IMG_PNG) {
92 header("Content-type: image/png");
93 imagepng($im);
94 }
95 exit;
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
Use closedir on a directory resource, not fclose.

Also, what's up with lines 85 & 86? If you want to close the file handle you just opened, line 85 should be
Code:
[FONT="Courier New"]$[COLOR="Red"]H[/COLOR]andle = fopen('code' . '/' . $FileName, 'w');[/FONT]
(note the capital H; variable names are case sensitive) so that the fclose on line 86 will close the correct file resource.

Regarding the "Cannot modify header" warning: setting the Content-type header after performing other processing is good, but the script should skip setting the content type to jpg/png & print an error if the earlier processing failed.

If you're asking about code, you should always post a minimal test case and any errors it generates. That way you won't have to wait a few days to get your answer.
 
Last edited:

sgrpdl

New Member
Messages
63
Reaction score
0
Points
0
Sir,

Seems like problem is fixed..i'm testing it.
Thank you

Image verification is ok now but why i'm NOT RECEIVING MAIL from it?????
 
Last edited:
Status
Not open for further replies.
Top