Search code examples
zend-frameworkzend-formcaptchazend-form-element

Need help with Zend_Form_Element_Captcha in localhost and web hosting environment


Currently I'm develping a web application using Zend framework.

My problem is that I have to write 2 set of codes for the captcha element for my localhost (window environment running XAMPP ) and web hosting (linux environment).

My question is that is there a better way to code it, so that it works both my localhost and web hosting environment? At the moment is just so annoying to keep changing the codes when I upload to the web host enviroment.

Thanks so much in advance. :)

Here is my code for my web hosting environment

array('captcha' => array(
                 'captcha' => 'Image',
             'wordLen' => 3,
             'timeout' => 600,
                 'font' => '../font/arial.ttf',
                 'imgurl' => '../images/captcha/',
                 'fontsize' =>20,
             'expiration' =>20,
                         'lineNoiseLevel' =>0,
                         'DotNoiseLevel' =>10,
             )
                )
           );

It work perfectly on the web host but if i run it in my localhost window environment i get blank captcha the text doesn't get generated.

This is what i currently have for my localhost and its work fine.

array('captcha' => array(
                 'captcha' => 'Image',
                 'wordLen' => 3,
                 'timeout' => 600,
                 'font' => 'C:\WINDOWS\Fonts\arial.ttf',
                 'imgurl' => 'http://localhost/images/captcha',
                 'fontsize' =>20,
                 'expiration' =>20,
                         'lineNoiseLevel' =>0,
                         'DotNoiseLevel' =>10,
             )
                )
           );

Solution

  • Use APPLICATION_PATH for the font . From http://framework.zend.com/manual/en/zend.captcha.adapters.html the default is "./images/captcha/" . So not needed. Hope it helps you.