You are here

function customerror_check_redirect in Customerror 5

Same name and namespace in other branches
  1. 6 customerror.module \customerror_check_redirect()
  2. 7 customerror.module \customerror_check_redirect()
1 call to customerror_check_redirect()
customerror_page in ./customerror.module

File

./customerror.module, line 206
Enables custom 404 (not found) and 403 (access denied) pages in Drupal with no need for creating real nodes under taxonomies

Code

function customerror_check_redirect() {
  $destination = $_REQUEST['destination'];
  if (empty($destination)) {
    return;
  }
  $list = explode("\n", variable_get('customerror_redirect', ''));
  if (count($list) <= 1) {
    return;
  }
  foreach ($list as $item) {
    list($src, $dst) = explode(' ', $item);
    if (isset($src) && isset($dst)) {
      $src = str_replace("/", "\\/", $src);
      $dst = str_replace("\r", "", $dst);
      if (preg_match('/' . $src . '/', $destination)) {
        $_REQUEST['destination'] = $dst;
        drupal_goto($dst);
      }
    }
  }
}