cakephp - cake php captcha problem -


I am facing a problem with the captcha in KP PHP. When captcha tried to make a last call to the session value display, so the correct answer never gets.

This is my code.

I enter this code for component section

  class extends CaptchaComponent object {var $ controller; Var $ font = 'monofont.ttf'; Function Captcha Component ($ controller) {$ this- & gt; Controller = $ controller; } Generate function ($ character) {/ * All possible characters in the list, similar-looking characters and tones are deleted * / $ possible = '23456789bcdfghjkmnpqrstvwxyz'; $ Code = ''; $ I = 0; While ($ i <$ characters) {$ code. = Substr ($ possible, mt_rand (0, strlen ($ possible) -1,); $ I ++; } return code; } Create the function ($ width = '120', $ height = '40 ', $ character =' 6 ') {$ code = $ this- & gt; GenerationCode ($ character); / * Font size will be 75% of the image height * / $ font_size = $ height * 0.80; $ Image = @imagecreate ($ width, $ height) or die ('Can not start new GD image stream'); / * Set color / $ background_color = imagecolorallocate ($ image, 220, 220, 220); $ Text_color = imagecolorallocate ($ image, 10, 30, 80); $ Noise_color = imagecolorallocate ($ image, 150, 180, 220); / * Random point in background * / ($ i = 0; $ i & lt; ($ width * $ height) / 3; $ i ++) {imagefilledellipse ($ image, mt_rand (0, $ width), mt_rand ( 0, $ height), 1, 1, $ noise_color); } / * Generates random line in the background / ($ i = 0; $ i & lt; ($ width * $ height) / 150; $ i + +) {emailline ($ image, mt_rand (0, $ width) ), MT_Rand (0, $ height), mt_rand (0, $ width), mt_rand (0, $ height), $ noise_color); } / * Create textbox and add text / $ $ textbox = imagettfbbox ($ font_size, 0, $ this- & gt; font, $ code) or die ('error in the imagettfbbox function'); $ X = ($ width - $ text box [4]) / 2; $ Y = ($ height - $ text box [5]) / 2; Imagettftext ($ image, $ font_ size, 0, $ x, $ y, $ text_color, $ this-> font, $ code) or die ('error in fiction'); / * Output Captcha image browser * / header ('content-type: image / JPEG'); Imagejpeg ($ image); Imagedestroy ($ image); $ This- & gt; Controller- & gt; Session-> About ('security_code', $ code); }}  

My code for user control section is

  function captcha () {app :: import ('component', 'captcha'); $ This- & gt; Captcha = new captcha component ($ this); $ This- & gt; Captcha- & gt; Create (); }  

and my option for viewing options is

  echo $ html-> Image ('../user / captcha', array ('style' = & gt; border: 1px #ccc solid ',' vsspace '= & gt; 2)); The latest working version of this captcha component for KPPHP 2.x is available on the author's website  


Comments