equal
deleted
inserted
replaced
13 * to license@zend.com so we can send you a copy immediately. |
13 * to license@zend.com so we can send you a copy immediately. |
14 * |
14 * |
15 * @category Zend |
15 * @category Zend |
16 * @package Zend_Captcha |
16 * @package Zend_Captcha |
17 * @subpackage Adapter |
17 * @subpackage Adapter |
18 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
18 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) |
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
20 * @version $Id: Image.php 24821 2012-05-29 14:54:50Z adamlundrigan $ |
20 * @version $Id$ |
21 */ |
21 */ |
22 |
22 |
23 /** @see Zend_Captcha_Word */ |
23 /** @see Zend_Captcha_Word */ |
24 require_once 'Zend/Captcha/Word.php'; |
24 require_once 'Zend/Captcha/Word.php'; |
25 |
25 |
29 * Generates image displaying random word |
29 * Generates image displaying random word |
30 * |
30 * |
31 * @category Zend |
31 * @category Zend |
32 * @package Zend_Captcha |
32 * @package Zend_Captcha |
33 * @subpackage Adapter |
33 * @subpackage Adapter |
34 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
34 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) |
35 * @license http://framework.zend.com/license/new-bsd New BSD License |
35 * @license http://framework.zend.com/license/new-bsd New BSD License |
36 */ |
36 */ |
37 class Zend_Captcha_Image extends Zend_Captcha_Word |
37 class Zend_Captcha_Image extends Zend_Captcha_Word |
38 { |
38 { |
39 /** |
39 /** |
238 */ |
238 */ |
239 public function getWidth() |
239 public function getWidth() |
240 { |
240 { |
241 return $this->_width; |
241 return $this->_width; |
242 } |
242 } |
243 /** |
243 |
|
244 /** |
|
245 * Set start image |
|
246 * |
244 * @param string $startImage |
247 * @param string $startImage |
|
248 * @return Zend_Captcha_Image |
245 */ |
249 */ |
246 public function setStartImage ($startImage) |
250 public function setStartImage ($startImage) |
247 { |
251 { |
248 $this->_startImage = $startImage; |
252 $this->_startImage = $startImage; |
249 return $this; |
253 return $this; |
250 } |
254 } |
251 /** |
255 |
|
256 /** |
|
257 * Set dot noise level |
|
258 * |
252 * @param int $dotNoiseLevel |
259 * @param int $dotNoiseLevel |
|
260 * @return Zend_Captcha_Image |
253 */ |
261 */ |
254 public function setDotNoiseLevel ($dotNoiseLevel) |
262 public function setDotNoiseLevel ($dotNoiseLevel) |
255 { |
263 { |
256 $this->_dotNoiseLevel = $dotNoiseLevel; |
264 $this->_dotNoiseLevel = $dotNoiseLevel; |
257 return $this; |
265 return $this; |
258 } |
266 } |
259 /** |
267 |
|
268 /** |
|
269 * Set line noise level |
|
270 * |
260 * @param int $lineNoiseLevel |
271 * @param int $lineNoiseLevel |
|
272 * @return Zend_Captcha_Image |
261 */ |
273 */ |
262 public function setLineNoiseLevel ($lineNoiseLevel) |
274 public function setLineNoiseLevel ($lineNoiseLevel) |
263 { |
275 { |
264 $this->_lineNoiseLevel = $lineNoiseLevel; |
276 $this->_lineNoiseLevel = $lineNoiseLevel; |
265 return $this; |
277 return $this; |
346 public function setImgUrl($imgUrl) |
358 public function setImgUrl($imgUrl) |
347 { |
359 { |
348 $this->_imgUrl = rtrim($imgUrl, "/\\") . '/'; |
360 $this->_imgUrl = rtrim($imgUrl, "/\\") . '/'; |
349 return $this; |
361 return $this; |
350 } |
362 } |
351 /** |
363 |
|
364 /** |
|
365 * Set image alternative text |
|
366 * |
352 * @param string $imgAlt |
367 * @param string $imgAlt |
|
368 * @return Zend_Captcha_Image |
353 */ |
369 */ |
354 public function setImgAlt ($imgAlt) |
370 public function setImgAlt ($imgAlt) |
355 { |
371 { |
356 $this->_imgAlt = $imgAlt; |
372 $this->_imgAlt = $imgAlt; |
357 return $this; |
373 return $this; |
438 * Generate image captcha |
454 * Generate image captcha |
439 * |
455 * |
440 * Override this function if you want different image generator |
456 * Override this function if you want different image generator |
441 * Wave transform from http://www.captcha.ru/captchas/multiwave/ |
457 * Wave transform from http://www.captcha.ru/captchas/multiwave/ |
442 * |
458 * |
443 * @param string $id Captcha ID |
459 * @param string $id Captcha ID |
444 * @param string $word Captcha word |
460 * @param string $word Captcha word |
|
461 * @throws Zend_Captcha_Exception |
445 */ |
462 */ |
446 protected function _generateImage($id, $word) |
463 protected function _generateImage($id, $word) |
447 { |
464 { |
448 if (!extension_loaded("gd")) { |
465 if (!extension_loaded("gd")) { |
449 require_once 'Zend/Captcha/Exception.php'; |
466 require_once 'Zend/Captcha/Exception.php'; |
565 imagedestroy($img2); |
582 imagedestroy($img2); |
566 } |
583 } |
567 |
584 |
568 /** |
585 /** |
569 * Remove old files from image directory |
586 * Remove old files from image directory |
570 * |
|
571 */ |
587 */ |
572 protected function _gc() |
588 protected function _gc() |
573 { |
589 { |
574 $expire = time() - $this->getExpiration(); |
590 $expire = time() - $this->getExpiration(); |
575 $imgdir = $this->getImgDir(); |
591 $imgdir = $this->getImgDir(); |