Skip to content
Snippets Groups Projects
Commit aaef0f97 authored by Jeff Geerling's avatar Jeff Geerling
Browse files

Issue #1450536 by Dmitriy.trt, geerlingguy: Disable cache for pages with time...

Issue #1450536 by Dmitriy.trt, geerlingguy: Disable cache for pages with time restriction protected forms.
parent 1ba83df5
No related branches found
No related tags found
No related merge requests found
......@@ -42,7 +42,7 @@ function honeypot_admin_form($form) {
$form['configuration']['honeypot_time_limit'] = array(
'#type' => 'textfield',
'#title' => t('Honeypot time limit'),
'#description' => t('Minimum time required before form should be considered entered by a human instead of a bot. Set to 0 to disable.'),
'#description' => t('Minimum time required before form should be considered entered by a human instead of a bot. Set to 0 to disable. <strong>Page caching will be disabled if there is a form protected by time limit on the page.</strong>'),
'#default_value' => variable_get('honeypot_time_limit', 5),
'#required' => TRUE,
'#size' => 5,
......
......@@ -147,6 +147,17 @@ function honeypot_add_form_protection(&$form, &$form_state, $options = array())
'#default_value' => time(),
'#element_validate' => array('_honeypot_time_restriction_validate'),
);
// Disable page caching to make sure timestamp isn't cached.
if (user_is_anonymous()) {
$GLOBALS['conf']['cache'] = CACHE_DISABLED;
// Pressflow in CACHE_EXTERNAL caching mode additionally requires marking
// this request as non-cacheable to bypass external caches (e.g., Varnish).
if (function_exists('drupal_page_is_cacheable')) {
drupal_set_header('Cache-Control', 'no-cache, must-revalidate, post-check=0, pre-check=0', FALSE);
}
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment