I followed the article on: 
http://bakery.cakephp.org/articles/spout/2007/06/09/captcha-component-with-phpcaptcha

...and made some changes to the controller given there:

<?php
App::import('Vendor', 'phpcaptcha/phpcaptcha');

class CaptchaComponent extends Component {
    var $controller;

    function startup( &$controller ) {
        $this->controller = &$controller;
    }

    function image() {
        $imagesPath = APP . 'Vendor' . DS . 'phpcaptcha'.'/fonts/';
        $aFonts = array(
            $imagesPath.'VeraBd.ttf',
            $imagesPath.'VeraIt.ttf',
            $imagesPath.'Vera.ttf'
        );
        $oVisualCaptcha = new PhpCaptcha($aFonts, 200, 60);
        $oVisualCaptcha->UseColour(true);
        //$oVisualCaptcha->SetOwnerText('Source: '.FULL_BASE_URL);
        $oVisualCaptcha->SetNumChars(6);
        $oVisualCaptcha->Create();
    }
    function audio() {
        $oAudioCaptcha = new AudioPhpCaptcha('/usr/bin/flite', '/
tmp/');
        $oAudioCaptcha->Create();
    }
    function check($userCode, $caseInsensitive = true){
        if ($caseInsensitive)
            $userCode = strtoupper($userCode);
        $csi = $this->Session->read(CAPTCHA_SESSION_ID);
        if (($this->Session->check(CAPTCHA_SESSION_ID)) && ($userCode
== $csi)) {
            $this->Session->delete(CAPTCHA_SESSION_ID);
            return true;
        }
        else return false;
    }
}
?>

I added code to my add.ctp view file:

                <img id="captcha" src="<?php echo $this->Html->url('/users/
captcha_image');?>" alt="" />
                <a href="javascript:void(0);"
onclick="javascript:document.images.captcha.src='<?php echo $this-
>Html->url('/users/captcha_image');?>?' +
Math.round(Math.random(0)*1000)+1">Reload image</a>

I didn't change the PhpCaptcha file by Edward Eliot.  I don't get any
errors but the captcha image just shows a red cross.

I also tried some old PHP code (no Cake) that I had for doing captchas
but the webpage just showed a red cross too.

I am wondering if there is a change in the way in which PHP deals with
generated images.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to