Saying that it doesn't work isn't helpful. What part of it doesn't work? What error messages -- if any -- have you seen? What debugging have you already tried?
On Fri, Apr 20, 2012 at 12:53 PM, MSayyaf <[email protected]> wrote: > I have tried to use securimage 3.0.1 (captcha) with cakephp 2.0 > > so, i created the following CaptchaComponent: > > <?php > > /** > * Securimage-Driven Captcha Component > * @author debuggeddesigns.com > * @license MIT > * @version 0.1 > */ > > //cake's version of a require_once() call > App::import('Vendor', 'securimage/securimage'); > > //the local directory of the vendor used to retrieve files > define('CAPTCHA_VENDOR_DIR', APP . 'vendors' . DS . 'securimage/'); > > class CaptchaComponent extends Component > { > var $controller; > > function startup( &$controller ) > { > $this->controller = &$controller; > } > > function image() > { > $img = new Securimage(); > > //Change some settings > $img->image_width = 280; > $img->image_height = 100; > $img->perturbation = 0.9; // high level of distortion > $img->code_length = rand(5,6); // random code length > $img->image_bg_color = new Securimage_Color("#ffffff"); > $img->num_lines = 12; > $img->noise_level = 5; > $img->text_color = new Securimage_Color("#000000"); > $img->noise_color = $img->text_color; > $img->line_color = new Securimage_Color("#cccccc"); > > $img->show(); > } > > function check($userCode, $caseInsensitive = true) > { > if ($caseInsensitive) { > $userCode = strtoupper($userCode); > } > > if (!empty($_SESSION[CAPTCHA_SESSION_ID]) && $userCode == > $_SESSION[CAPTCHA_SESSION_ID]) > { > // clear to prevent re-use > unset($_SESSION[CAPTCHA_SESSION_ID]); > return true; > } > > return false; > } > } > > ?> > > then set function below in my controller: > > function captcha_image() > { > $this->Captcha->image(); > } > > and finally in my views/layouts/contacts, i put the code below: > > BASIC CODE: > > <p> > <img id="siimage" style="border: 1px solid #000; margin-right: > 15px" src="./securimage_show.php?sid=<?php echo md5(uniqid()) ?>" > alt="CAPTCHA Image" align="left"> > <object type="application/x-shockwave-flash" data="./ > securimage_play.swf?audio_file=./ > securimage_play.php&bgColor1=#fff&bgColor2=#fff&iconColor=#777&borderWidth=1&borderColor=#000" > height="32" width="32"> > <param name="movie" value="./securimage_play.swf?audio_file=./ > securimage_play.php&bgColor1=#fff&bgColor2=#fff&iconColor=#777&borderWidth=1&borderColor=#000"> > </object> > > <a tabindex="-1" style="border-style: none;" href="#" > title="Refresh Image" onclick="document.getElementById('siimage').src > = './securimage_show.php?sid=' + Math.random(); this.blur(); return > false"><img src="./images/refresh.png" alt="Reload Image" > onclick="this.blur()" align="bottom" border="0"></a><br /> > <strong>Enter Code*:</strong><br /> > <input type="text" name="ct_captcha" size="12" maxlength="8" /> > </p> > > EDITED CODE: > > <?php $vp= "F:/xampp/htdocs/mysite/vendors/securimage/"; ?> > <p> > > <img id="siimage" style="border: 1px solid #000; margin- > right: 15px" src="<?php echo $this->Html->url('/emails/ > captcha_image');?>?sid=<?php echo md5(uniqid()) ?>" alt="CAPTCHA > Image" align="left"> > > <object > > type="application/x-shockwave-flash" data="<?php echo $vp; ? >>securimage_play.swf?audio_file=<?php echo $vp; ? >>securimage_play.php&bgColor1=#fff&bgColor2=#fff&iconColor=#777&borderWidth=1&borderColor=#000" > height="32" width="32"> > > <param name="movie" value="<?php echo $vp; ? >>securimage_play.swf?audio_file=<?php echo $vp; ? >>securimage_play.php&bgColor1=#fff&bgColor2=#fff&iconColor=#777&borderWidth=1&borderColor=#000"> > > </object> > > > > <a tabindex="-1" style="border-style: none;" href="#" > title="Refresh Image" onclick="document.getElementById('siimage').src > = '<?php echo $this->Html->url('/emails/captcha_image');?>?sid=' + > Math.random(); this.blur(); return false"><img src="<?php echo $vp; ? >>images/refresh.png" alt="Reload Image" onclick="this.blur()" > align="bottom" border="0"></a><br /> > > <strong>Enter Code*:</strong><br /> > > <input type="text" name="ct_captcha" size="12" > maxlength="8" /> > </p> > > the final result is not work, so what should i do? > > thanks > > -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions. > > > To unsubscribe from this group, send email to > [email protected] For more options, visit this group at > http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
