开发者

codeigniter/captcha helper/image sometimes pads too much on left

using the "out-of-the-box" captcha helper with Codeigniter with no trouble except, I am making the "word" a two 5-letter long random strings (ex. WDRTH IFTBG)

occasionally, the image is drawing a lot of "padding" to the left of the first string, resulting in the second string running off the image. It may cut the last character in half, or it may cut it off completely, resulting in a 5-letter/4-letter image although the db value is correctly 5 and 5.

i have a "refresh va开发者_开发问答lue" option, but when it cuts it down to 5 and 4 it looks normal to the user and they won't understand why the value won't validate.

Is there anyway to control this extra padding when the image is drawn?

TIA!


I have not used the Codeigniter CAPTCHA in quite some time, but the "padding" you sometimes see is desirable for CAPTCHA because we want the image to appear random.

You should change the settings in your configuration to allow more room for the digits, or use less digits, or try a different font.

Taken from the CI 1.7.1 source:

// Once loaded you can generate a captcha like this:

$vals = array(
    'word'       => 'Random word',
    'img_path'   => './captcha/',
    'img_url'    => 'http://example.com/captcha/',
    'font_path'  => './system/fonts/texb.ttf',

     // Increase this value to allow more room for the digits
    'img_width'  => '150',

    'img_height' => 30,
    'expiration' => 7200
);

Honestly it's been so long since I've used this, you really should check out the latest version one of these days (We're on 2.0.2).

  • Latest: https://bitbucket.org/ellislab/codeigniter-reactor/overview
  • Stable: http://codeigniter.com/

Some other interesting reads:

  • When the bots attack!
  • Blocking comment spam without using captcha
  • https://stackoverflow.com/questions/4683117/alternative-to-annoying-captcha-in-forms-how-to-smell-the-difference-between-a-h
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜