• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
an enhanced captcha as helper

#11
[eluser]JP X3M[/eluser]
[quote author="krz" date="1211289719"]I followed the example above with the following code. It doesnt seem to work for me. I dont even get a print_r() !

My directory structure is as follows:

img_path = http://localhost/Paradise Calling/common/captcha/
img_url = http://localhost/Paradise Calling/common/captcha/
font_path = http://localhost/Paradise Calling/application/fonts/

Am I supposed to add place an image in one of those dirs or something?

The captcha helper is located at: http://localhost/Paradise Calling/application/helpers/

[/quote]
if it may help to know that i am using YATS and here is my configuration

Code:
$aCaptchaCfg = array(
          //'word'          => 'myrandomword',                        //default: random()
          'length'        => 6,                                       //default: 5
          'img_path'   => './assets/captcha/files/',                  //no default !
          'img_url'       => site_url().'assets/captcha/files/',      // no default!
          'font_path'  => './assets/captcha/fonts/',                  // default: ./system/fonts/
          'fonts'         => array('corsiva.ttf', 'TSCu_Comic.ttf'),  // default: texb.ttf
          'font_size'     => 13,                                      // default: 18
          'img_width'  => '150',                                      // default: 170
          'img_height' => '50',                                       // default: 60
          'expiration' => 360                                         // default: 7200
        );

i forgot what i did to make it work when i had the same problem...

try to make a folder to hold the generated captchas (in my case a folder named files) and chmod it to 777

and check for the height spelling in your helper (though having the spelling wrong only ignores your height in the config array).

#12
[eluser]JOKERz[/eluser]
heres my config. hope it can help you as reference.

Code:
$aCaptchaCfg = array(
          'length'        => 6,
          'img_path'   => 'captcha/',
          'img_url'       => base_url().'captcha/',
          'font_path'  => './system/fonts/',
          'fonts'         => array('Bryant-Bold.ttf','LTe50537.ttf'),
          'font_size'     => '22',
          'img_width'  => '180',
          'img_height' => '60',
          'expiration' => 7200
        );

#13
[eluser]Sceneshift[/eluser]
I'm having some difficulty figuring out how to validate a captcha once it's in place. I mean I could put the word in a hidden input field, but doesn't that defeat the point of a captcha?

#14
[eluser]mr_coffee[/eluser]
I did this for the validation:

Code:
$this->session->set_userdata(array('security_code' => strtolower($data['captcha']['word'])));

Thereby storing the security code (in lower case) into a session variable for the user. Makes sense... since that code will be no good once the session expires. You'll want the above line to run on the page load.

Later on -- during form processing -- assuming the form also passes validation -- the user should have filled in a field (I used security_code for the name to keep it simple):

Code:
if (($this->validation->run() == FALSE) || ($this->session->userdata['security_code'] != strtolower($_POST['security_code']))) {
  this->_captchaerror();
} else {
  // code to send e-mail here.
}

#15
[eluser]novarli[/eluser]
[quote author="Christian Rößler" date="1193671661"]Hy 'JP X3M',
....

If you use apache's mod rewrite to hide index.php from your url, edit .htaccess to allow clients access to the captcha directory!
....
[/quote]
My .htacces file
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ /firstlaborv2/index.php/$1 [L]

How can i change to allow clients access to the captcha directory!

Captcha doesn't appear. When i change print_r($aCaptcha) printed only '1'. Why? I followed your configuration.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.