function _recaptcha_server_is_up in reCAPTCHA 7
Same name and namespace in other branches
- 6 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.
3 calls to _recaptcha_server_is_up()
- ReCaptchaServerStatusTestCase::testServerStatusCache in tests/
recaptcha_server_status.test - recaptcha_captcha in ./
recaptcha.module - Implements hook_captcha().
- recaptcha_captcha_validation in ./
recaptcha.module - CAPTCHA Callback; Validates the reCAPTCHA code.
File
- ./
recaptcha.module, line 200 - 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.
$status_cache = cache_get('recaptcha_server_status');
if ($status_cache !== FALSE) {
$server_status = (bool) $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;
}