You are here

function query_parameters_to_url_protect_redirect_loop in Query Parameters To URL 7

Protects against a redirect loop.

1 call to query_parameters_to_url_protect_redirect_loop()
query_parameters_to_url_init in ./query_parameters_to_url.module
Implements hook_init().

File

./query_parameters_to_url.module, line 679
Query Arguments To URL module.

Code

function query_parameters_to_url_protect_redirect_loop() {
  $exit_early = FALSE;
  if (query_parameters_to_url_redirect_protection_enabled()) {

    // Redirect protection in case something goes horribly wrong. Inspired
    // by redirect module.
    $session_id = session_id();
    if (flood_is_allowed('query_parameters_to_url_init_redirect', 10, 15, $session_id ? $session_id : NULL)) {
      flood_register_event('query_parameters_to_url_init_redirect', 15, $session_id ? $session_id : NULL);
      $exit_early = FALSE;
    }
    else {
      watchdog(QUERY_PARAMETERS_TO_URL_MODULE_NAME, 'Infinite redirect loop stopped.');
      drupal_set_message(t('Oops, looks like this request tried to create an infinite loop.'));
      $exit_early = TRUE;
    }
  }
  return $exit_early;
}