From f181b662c6852bc7bc28df6d456dd40bab46b9c5 Mon Sep 17 00:00:00 2001 From: xue <> Date: Sat, 29 Sep 2007 14:33:13 +0000 Subject: Modified how requirement is being checked for TCaptcha. --- framework/Web/UI/WebControls/TCaptcha.php | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'framework/Web/UI/WebControls') diff --git a/framework/Web/UI/WebControls/TCaptcha.php b/framework/Web/UI/WebControls/TCaptcha.php index 55cbc940..65168a1d 100644 --- a/framework/Web/UI/WebControls/TCaptcha.php +++ b/framework/Web/UI/WebControls/TCaptcha.php @@ -64,15 +64,6 @@ class TCaptcha extends TImage private $_privateKey; private $_validated=false; - /** - * Checks the requirements needed for using TCaptcha. - */ - public function onInit($param) - { - parent::onInit($param); - $this->checkRequirements(); - } - /** * @return integer the theme of the token image. Defaults to 0. */ @@ -368,6 +359,8 @@ class TCaptcha extends TImage public function onPreRender($param) { parent::onPreRender($param); + if(!self::checkRequirements()) + throw new TConfigurationException('captcha_imagettftext_required'); if(!$this->getViewState('TokenGenerated',0)) { $manager=$this->getApplication()->getAssetManager(); @@ -487,15 +480,12 @@ class TCaptcha extends TImage /** * Checks the requirements needed for generating CAPTCHA images. + * TCaptach requires GD2 with TrueType font support and PNG image support. + * @return boolean whether the requirements are satisfied. */ - protected function checkRequirements() + public static function checkRequirements() { - if(!extension_loaded('gd')) - throw new TConfigurationException('captcha_gd2_required'); - if(!function_exists('imagettftext')) - throw new TConfigurationException('captcha_imagettftext_required'); - if(!function_exists('imagepng')) - throw new TConfigurationException('captcha_imagepng_required'); + return extension_loaded('gd') && function_exists('imagettftext') && function_exists('imagepng'); } } -- cgit v1.2.3