function _image_captcha_check_setup in CAPTCHA 7
Same name and namespace in other branches
- 8 image_captcha/image_captcha.module \_image_captcha_check_setup()
- 6.2 image_captcha/image_captcha.module \_image_captcha_check_setup()
Helper function for checking the setup of the Image CAPTCHA.
The image CAPTCHA requires at least the GD PHP library. Support for TTF is recommended and the enabled font files should be readable. This functions checks these things.
Parameters
bool $check_fonts: whether or not the enabled fonts should be checked.
Return value
int status code: bitwise 'OR' of status flags like IMAGE_CAPTCHA_ERROR_NO_GDLIB, IMAGE_CAPTCHA_ERROR_NO_TTF_SUPPORT, IMAGE_CAPTCHA_ERROR_TTF_FILE_READ_PROBLEM.
5 calls to _image_captcha_check_setup()
- image_captcha_captcha in image_captcha/
image_captcha.module - Implements hook_captcha().
- image_captcha_requirements in image_captcha/
image_captcha.install - Implements hook_requirements().
- image_captcha_settings_form in image_captcha/
image_captcha.admin.inc - Configuration form for image_captcha.
- _image_captcha_get_enabled_fonts in image_captcha/
image_captcha.module - Helper function for getting the fonts to use in the image CAPTCHA.
- _image_captcha_settings_form_font_section in image_captcha/
image_captcha.admin.inc - Form elements for the font specific setting.
File
- image_captcha/
image_captcha.module, line 159 - Implements image CAPTCHA for use with the CAPTCHA module
Code
function _image_captcha_check_setup($check_fonts = TRUE) {
// Start clean.
$status = 0;
// Check if we can use the GD library.
// We need at least the imagepng function (for font previews on the settings page).
// Note that the imagejpg function is optionally also used, but not required.
if (!function_exists('imagepng')) {
$status = $status | IMAGE_CAPTCHA_ERROR_NO_GDLIB;
}
if (!function_exists('imagettftext')) {
$status = $status | IMAGE_CAPTCHA_ERROR_NO_TTF_SUPPORT;
}
if ($check_fonts) {
// Check availability of enabled fonts.
$fonts = _image_captcha_get_enabled_fonts();
list($readable_fonts, $problem_fonts) = _image_captcha_check_fonts($fonts);
if (count($problem_fonts) != 0) {
$status = $status | IMAGE_CAPTCHA_ERROR_TTF_FILE_READ_PROBLEM;
}
}
return $status;
}