> Might I suggest a set of x pre-generated images that are refreshed
> periodically, adding considerable overhead to a single request (or run
> on a cron job or equivalent), but overall reducing overhead considerably?
>
> Just a thought.
> G
can I suggest to extend as suggested in the docs ?
IMHO the funciotn _generateImage() is Too long and a method like
$this->_outputImage($img, $file = null) could be used (and overwritten)
to change the output type
class Your_Captcha_Image extends Zend_Captcha_Image
{
protected $_imageBinary;
/**
* Generate image captcha
*
* Override this function if you want different image generator
* Wave transform from http://www.captcha.ru/captchas/multiwave/
*
* @param string $id Captcha ID
* @param string $word Captcha word
*/
protected function _generateImage($id, $word)
{
// .... same code here except for the the output ... html
embedded instead of write a file
ob_start();
imagepng($img2);
$this->_imageBinary = ob_get_contents();
ob_end_clean();
imagedestroy($img);
imagedestroy($img2);
}
/**
* Display the captcha
*
* @param Zend_View_Interface $view
* @param mixed $element
* @return string
*/
public function render(Zend_View_Interface $view = null, $element =
null)
{
// return '<img width="'.$this->getWidth().'"
height="'.$this->getHeight().'" alt="'.$this->getImgAlt().'" src="' .
$this->getImgUrl() . $this->getId() . $this->getSuffix() . '"/><br/>';
return '<img src="data:image/png;base64,' .
base64_encode($this->_imageBinary) . '" /><br />';
}
}
--
________________________________________
Simone Cosci - NextIdea
Software engineering
Planet S.r.l. Sistemi informatici
Via Giorgio Ambrosoli, 39
50018, Scandicci, Firenze, Italy
WEB http://www.planetweb.it
E-Mail s.cosci@nextidea.it
Tel. +39 055 7350271 / 4630416
Fax. +39 055 7351109
Cell. +39 339 8672146
Voip. +39 055 5357896
________________________________________
没有评论:
发表评论