function _recaptcha_server_is_up in reCAPTCHA 6
Same name and namespace in other branches
- 7 recaptcha.module \_recaptcha_server_is_up()
Return the cached output of _recaptcha_test_recaptcha_server().
Return value
bool TRUE if the reCAPTCHA server was up last time it was checked, FALSE otherwise.
2 calls to _recaptcha_server_is_up()
- recaptcha_captcha in ./
recaptcha.module - Implements hook_captcha().
- recaptcha_captcha_validation in ./
recaptcha.module - CAPTCHA Callback; Validates the reCAPTCHA code.
File
- ./
recaptcha.module, line 194 - Uses the reCAPTCHA web service to improve the CAPTCHA system.
Code
function _recaptcha_server_is_up() {
static $server_status;
// Use static cache value, if available.
if (isset($server_status)) {
return $server_status;
}
// Check if the status is cached already.
// D6 cache_get() may return 0 what makes the condition failing
$status_cache = (bool) cache_get('recaptcha_server_status');
if ($status_cache !== FALSE) {
$server_status = $status_cache;
return $server_status;
}
// Status is not cached. Check if server is up.
$server_status = _recaptcha_test_recaptcha_server();
// Set to 5 minutes, if interval is not set.
$cache_period = variable_get('recaptcha_server_status_check_interval', 5);
// Save it as integer as cache_get returns FALSE, if not found.
cache_set('recaptcha_server_status', (int) $server_status, 'cache', time() + $cache_period * 60);
return $server_status;
}