From d33ea353eba6f5df67ecfd52ccf54688efc61ed9 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Sun, 19 Oct 2014 01:22:26 +0400 Subject: [PATCH] Fixes #5598: added ImageMagick with PNG and GD with FreeType checks to requirements of basic and advanced applications, used better Captcha exception message --- requirements.php | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/requirements.php b/requirements.php index a38b936..4da0631 100644 --- a/requirements.php +++ b/requirements.php @@ -23,6 +23,28 @@ if (!is_dir($frameworkPath)) { require_once($frameworkPath . '/requirements/YiiRequirementChecker.php'); $requirementsChecker = new YiiRequirementChecker(); +$gdMemo = $imagickMemo = 'Either GD PHP extension with FreeType support or ImageMagick PHP extension with PNG support is required for image CAPTCHA.'; +$gdOK = $imagickOK = false; + +if (extension_loaded('imagick')) { + $imagick = new Imagick(); + $imagickFormats = $imagick->queryFormats('PNG'); + if (in_array('PNG', $imagickFormats)) { + $imagickOK = true; + } else { + $imagickMemo = 'Imagick extension should be installed with PNG support in order to be used for image CAPTCHA.'; + } +} + +if (extension_loaded('gd')) { + $gdInfo = gd_info(); + if (!empty($gdInfo['FreeType Support'])) { + $gdOK = true; + } else { + $gdMemo = 'GD extension should be installed with FreeType support in order to be used for image CAPTCHA.'; + } +} + /** * Adjust requirements according to your application specifics. */ @@ -69,6 +91,21 @@ $requirements = array( 'condition' => extension_loaded('apc'), 'by' => 'ApcCache', ), + // CAPTCHA: + array( + 'name' => 'GD PHP extension with FreeType support', + 'mandatory' => false, + 'condition' => $gdOK, + 'by' => 'Captcha', + 'memo' => $gdMemo, + ), + array( + 'name' => 'ImageMagick PHP extension with PNG support', + 'mandatory' => false, + 'condition' => $imagickOK, + 'by' => 'Captcha', + 'memo' => $imagickMemo, + ), // PHP ini : 'phpSafeMode' => array( 'name' => 'PHP safe mode',