Forums / All Other Contributions/Addons / Captcha using TTF & GD

Captcha using TTF & GD

Views: 147,342

Results 41 to 60 of 593
21 Mar 2007, 5:08 PM
#41
a_berezin avatar

a_berezin

Deceased

Join Date:
Aug 2004
Location:
Saint Petersburg, Russia
Posts:
1,782
Plugin Contributions:
5

Captcha using TTF & GD

babygekko:

My feedback: maybe you can find better color for the fonts?
You have enough of knowledge to self-make it. See

	var $backgroundColor = array(array(220, 220, 220), array(255, 255, 255));
	var $linesColor = array(array(150, 150, 150), array(185, 185, 185));
	var $textColor = array(array(30, 30, 30), array(199, 199, 199));

NOTE: We are sorry that Andrew is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

21 Mar 2007, 9:13 PM
#42
woodymon avatar

woodymon

Totally Zenned

Join Date:
Sep 2004
Posts:
2,309
Plugin Contributions:
1

Re: Captcha using TTF & GD

Nevermind nevermind

21 Mar 2007, 9:34 PM
#43
woodymon avatar

woodymon

Totally Zenned

Join Date:
Sep 2004
Posts:
2,309
Plugin Contributions:
1

Re: Captcha using TTF & GD

Yes! The changes above to /includes/classes/captcha.php
solved my problem of the characters displaying.
Looks good!
So issues on PHP 4.44. shop are solved.

But still no image displays on PHP 5.1.6 shop.

My host says problems are with the script not their service (of course they would say that). If I can point them in the right direction they will help but I'm clueless.

Woody

21 Mar 2007, 9:44 PM
#44
woodymon avatar

woodymon

Totally Zenned

Join Date:
Sep 2004
Posts:
2,309
Plugin Contributions:
1

Re: Captcha using TTF & GD

Woodymon:

But still no image displays on PHP 5.1.6 shop.

My host says problems are with the script not their service (of course they would say that). If I can point them in the right direction they will help but I'm clueless.
I forgot to include error log entry:

File does not exist: /home/account/public_html/403.shtml
client denied by server configuration: /home/account/public_html/shop/includes/templates/my_template/images/index.php

Does this indicate a server security setting amiss or any other ideas?

I asked host to look in their mod_security rules but that came back negative.

Woody

21 Mar 2007, 10:02 PM
#45
woodymon avatar

woodymon

Totally Zenned

Join Date:
Sep 2004
Posts:
2,309
Plugin Contributions:
1

Re: Captcha using TTF & GD

Anyone else have issues with this script on PHP 5.1x ??

Just checking before I fire my web host :wink2:

Woody

22 Mar 2007, 4:36 AM
#46
woodymon avatar

woodymon

Totally Zenned

Join Date:
Sep 2004
Posts:
2,309
Plugin Contributions:
1

Re: Captcha using TTF & GD

Woodymon:

I forgot to include error log entry:

File does not exist: /home/account/public_html/403.shtml
client denied by server configuration: /home/account/public_html/shop/includes/templates/my_template/images/index.php

> 
> Does this indicate a server security setting amiss or any other ideas?
> 
> I asked host to look in their mod_security rules but that came back negative.

Host says they observe no file index.php created 
in /home/account/public_html/shop/includes/templates/my_template/images/

Is this index.php suppose to be created (and destroyed) on the fly each time the captcha image  is generate?. Or is index.php only created in memory, not ever written to disk?

My web host says that file needs loaded into the images directory, so that is my problem. But the mod does not come with index.php file.

Is there an ez method availabe to adapt the mod to write the file to disk (as a png, gif or jpg) just to ensure the image is created. 

My host asked if there was a "debug" version of the script available.

Woody
22 Mar 2007, 8:38 AM
#47
a_berezin avatar

a_berezin

Deceased

Join Date:
Aug 2004
Location:
Saint Petersburg, Russia
Posts:
1,782
Plugin Contributions:
5

Re: Captcha using TTF & GD

Woodymon:

Host says they observe no file index.php created
in /home/account/public_html/shop/includes/templates/my_template/images/

Is this index.php suppose to be created (and destroyed) on the fly each time the captcha image is generate?. Or is index.php only created in memory, not ever written to disk?
CAPTCHA don't create, use, need and etc index.php in any directory. And also CAPTCHA don't use/read/wrtite/touch any /images/ directory at all.
Woodymon:

Is there an ez method availabe to adapt the mod to write the file to disk (as a png, gif or jpg) just to ensure the image is created.
It is possible, but I it shall not do it.

NOTE: We are sorry that Andrew is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

22 Mar 2007, 12:31 PM
#48
woodymon avatar

woodymon

Totally Zenned

Join Date:
Sep 2004
Posts:
2,309
Plugin Contributions:
1

Re: Captcha using TTF & GD

Woodymon:

Yes! The changes above to /includes/classes/captcha.php
solved my problem of the characters displaying.
Looks good! So issues on PHP 4.44. shop are solved.
I jumped to conclusions. After making the edits recommended the CAPTCHA module is working. But seven new errors showing up in error log each time.

error PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/account/public_html/shop/includes/classes/captcha.php:276) 
in /home/account/public_html/shop/includes/classes/captcha.php on line 152
in /home/account/public_html/shop/includes/classes/captcha.php on line 151
in /home/account/public_html/shop/includes/classes/captcha.php on line 150
in /home/account/public_html/shop/includes/classes/captcha.php on line 149
in /home/account/public_html/shop/includes/classes/captcha.php on line 148
in /home/account/public_html/shop/includes/classes/captcha.php on line 147
in /home/account/public_html/shop/includes/classes/captcha.php on line 146

The line numbers above refer to the following header code in function showCaptchaImg() within /includes/classes/captcha.php ```
header('HTTP/1.0 200 OK');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Expires: Thu, 19 Nov 1981 08:52:00 GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Pragma: no-cache');
header('Content-Type: image/' . $this->img_type);
header('Content-Length: ' . strlen($this->img));


This is for the shop on PHP 4.4.4.

I'm suspecting this is related to error I reported in shop running PHP 5.16

Recommends anyone? Thanks.

Woody
22 Mar 2007, 3:13 PM
#49
a_berezin avatar

a_berezin

Deceased

Join Date:
Aug 2004
Location:
Saint Petersburg, Russia
Posts:
1,782
Plugin Contributions:
5

Re: Captcha using TTF & GD

Woodymon:

I jumped to conclusions. After making the edits recommended the CAPTCHA module is working. But seven new errors showing up in error log each time.
It's normal for this recommendations.

NOTE: We are sorry that Andrew is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

22 Mar 2007, 4:21 PM
#50
woodymon avatar

woodymon

Totally Zenned

Join Date:
Sep 2004
Posts:
2,309
Plugin Contributions:
1

Re: Captcha using TTF & GD

a_berezin:

It's normal for this recommendations.

OK. So you're stating that by implementing the edits as I did, that is the casue of the error log entries.

OK. But if I did not make the recommended edits the mod does not work for me.

So it is a Catch-22.

As babygekko recommended I commented out in /classes/captcha_img.php

  1. the if (function_exists('glob') structure
  2. ob_start() and ob_end_clean()

Is there a suggested method to make the mod work WITHOUT the error log entries?

I will provide access credentials to view if you wish to check out.

Woody

22 Mar 2007, 5:06 PM
#51
a_berezin avatar

a_berezin

Deceased

Join Date:
Aug 2004
Location:
Saint Petersburg, Russia
Posts:
1,782
Plugin Contributions:
5

Re: Captcha using TTF & GD

  1. Use of function glob can be really problematic. It's possible to refuse it.
  2. Other question, IMHO it's a question to babygekko.

NOTE: We are sorry that Andrew is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

22 Mar 2007, 5:09 PM
#52
woodymon avatar

woodymon

Totally Zenned

Join Date:
Sep 2004
Posts:
2,309
Plugin Contributions:
1

Re: Captcha using TTF & GD

Looking at http://www.php.net/ob_start

Note the statements:
" Some web servers (e.g. Apache) change the working directory of a script when calling the callback function."

  • and -
    "the solution provided by PHP, does not function as intended when running PHP as a CGI (on CGI mode (CGI-BUILD (--enable-cgi) and/or CLI)"

And then later, code recommends that "works on both the non-CGI and the CGI PHP processor types".

Is this possibly relevant to the issues I have reported?

Woody

23 Mar 2007, 1:46 AM
#53
ktnaturals avatar

ktnaturals

Zen Follower

Join Date:
Dec 2006
Location:
Ohio
Posts:
196
Plugin Contributions:
0

Re: Captcha using TTF & GD

Hi. I just installed this on 1.3.7 (upgraded from 1.3.6). When I went to my Log In page, I got:

Fatal error: Cannot redeclare class captcha in /home/nakayama/public_html/includes/classes/captcha.php on line 12

I used to have the "other" mod installed, and I uninstalled it to the best of my knowledge (wasn't sure how to do it in MySQL, so I deleted the table and something else related to the mod...)

Thanks,
Katie

23 Mar 2007, 2:02 AM
#54
ktnaturals avatar

ktnaturals

Zen Follower

Join Date:
Dec 2006
Location:
Ohio
Posts:
196
Plugin Contributions:
0

Re: Captcha using TTF & GD

I should mention that I'm using a split login page for Paypal Express Checkout.

23 Mar 2007, 2:30 AM
#55
woodymon avatar

woodymon

Totally Zenned

Join Date:
Sep 2004
Posts:
2,309
Plugin Contributions:
1

Re: Captcha using TTF & GD

a_berezin:

  1. Use of function glob can be really problematic. It's possible to refuse it.
  2. Other question, IMHO it's a question to babygekko.

I followed your suggestions and kept the glob function commented out, and then uncommented:
ob_start();
ob_end_clean();

And everything is cool on the PHP 4.4.4 shop :thumbsup:

So now on to solving my issue on the PHP 5.1.6 shop, which will become the new home for the 4.4.4 shop, that is whenver I can get this captcha issue resolved. :wink2:

Thanks again for the assist!

Woody

23 Mar 2007, 11:11 AM
#56
a_berezin avatar

a_berezin

Deceased

Join Date:
Aug 2004
Location:
Saint Petersburg, Russia
Posts:
1,782
Plugin Contributions:
5

Re: Captcha using TTF & GD

KTNaturals!
I could not reproduce this error. Check once more uninstalling "other" mod.

NOTE: We are sorry that Andrew is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

23 Mar 2007, 11:13 AM
#57
a_berezin avatar

a_berezin

Deceased

Join Date:
Aug 2004
Location:
Saint Petersburg, Russia
Posts:
1,782
Plugin Contributions:
5

Re: Captcha using TTF & GD

v 2.5 23.03.2007 13:11

  1. Remove "glob" function;
  2. Add error messages constants;
  3. Add session id to captcha_img.php href link;
  4. Use direct output (no output buffer used);
  5. The functions generateCaptcha(), createCaptchaImg() and showCaptchaImg() are incorporated in one function generateCaptcha();

NOTE: We are sorry that Andrew is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

23 Mar 2007, 6:27 PM
#58
woodymon avatar

woodymon

Totally Zenned

Join Date:
Sep 2004
Posts:
2,309
Plugin Contributions:
1

Re: Captcha using TTF & GD

Woodymon:

Ierror log entry:

File does not exist: /home/account/public_html/403.shtml
client denied by server configuration: /home/account/public_html/shop/includes/templates/my_template/images/index.php


I discovered the above error was unrelated to CAPTCHA mod install (I was inadvertently calling an image in tpl_header). So no more errors in the error log.

As a refresher on my issue, the captcha imaged won't display on my 5.1.6 shop but displays on shop running PHP 4.4.4.

The same goes for displaying captcha image via _test_captcha.php or on the create-account or the contact_us pages.

In IE I see the broken image icon and ALT tag "Enable this picture" and the outline of where the captcha image should display. Firefox shows the same for a split second when clicking the redraw button.

The below access log entry created when accessing the shop's contact_us page looks normal...

[23/Mar/2007:11:59:49] "GET /shop/index.php?main_page=contact_us HTTP/1.1" 200 4755 "http://www.domain.com/shop/index.php?main_page=index" 

When I click the captcha redraw button on the contact_us page I observe the following entries in the access log:

[23/Mar/2007:11:59:52] "GET /shop/captcha_img.php?0.836195001174669189 HTTP/1.1" 200 7682 "-" 

And when I click the redraw button again:

[23/Mar/2007:12:00:02] "GET /shop/captcha_img.php?0.4578382568536792 HTTP/1.1" 200 9592 "-" \[/quote]

So it appears the mod is functioning fine, other than displaying the captcha image.

If it is relevant below are gd related entries in phpinfo():
> gd
> GD Support 	enabled
> GD Version 	bundled (2.0.28 compatible)
> FreeType Support 	enabled
> FreeType Linkage 	with freetype
> FreeType Version 	2.1.9
> GIF Read Support 	enabled
> GIF Create Support 	enabled
> JPG Support 	enabled
> PNG Support 	enabled
> WBMP Support 	enabled
> XPM Support 	enabled
> XBM Support 	enabled

The above is same on the server running PHP 4.4.4. where the captcha image correctly displays.

I'm looking for a needle in a haystack here. Could it be something in the Apache config/environment which might be the issue? Any other ideas why the CAPTCHA image will not display on the PHP 5.1.6 shop? If there is any other info I can provide let me know. And thanks for your recommends.

NOTE: The above was with Andrew's v.3.4 mod. I will install 3.5 and report back.

Woody
23 Mar 2007, 7:12 PM
#59
woodymon avatar

woodymon

Totally Zenned

Join Date:
Sep 2004
Posts:
2,309
Plugin Contributions:
1

Re: Captcha using TTF & GD

v.3.5 works fine on php 4.4.4 shop. But PHP 5.1.6 shop did get any better :sad:
Woody

23 Mar 2007, 7:17 PM
#60
ktnaturals avatar

ktnaturals

Zen Follower

Join Date:
Dec 2006
Location:
Ohio
Posts:
196
Plugin Contributions:
0

Re: Captcha using TTF & GD

a_berezin:

KTNaturals!
I could not reproduce this error. Check once more uninstalling "other" mod.
Hi, Andrew.

I verified that the other mod is uninstalled. As for SQL, I'm not really sure since I don't know it at all. What I did was do "DROP TABLE IF EXISTS anti_robotreg;", and went into the DB and deleted the CAPTCHA Validation from configuration_group (or something like that). I attached the install SQL file for reference. Could you tell me what else I need to do?

I'm also having a display problem on both my live site and my test site on the Contact Us page. The center column extends all the way to the right.
http://www.ktnaturals.com/catalog2/index.php?main_page=contact_us

Any help would be appreciated. Thanks!