You are here

function visitors_get_referer in Visitors 7.2

Same name and namespace in other branches
  1. 8 visitors.exit.inc \visitors_get_referer()
  2. 7 visitors.exit.inc \visitors_get_referer()
  3. 7.0 visitors.exit.inc \visitors_get_referer()

Get the address of the page (if any) which referred the user agent to the current page.

Return value

string referer, or empty string if referer does not exist

1 call to visitors_get_referer()
visitors_exit in ./visitors.exit.inc
Implements hook_exit().

File

./visitors.exit.inc, line 93
Implements hook_exit().

Code

function visitors_get_referer() {
  $referer = '';
  if (isset($_SERVER['HTTP_REFERER'])) {
    if (preg_match('/^(?:[;\\/?:@&=+$,]|(?:[^\\W_]|[-_.!~*\\()\\[\\] ])|(?:%[\\da-fA-F]{2}))*$/', $_SERVER['HTTP_REFERER'])) {
      $referer = rawurldecode($_SERVER['HTTP_REFERER']);
    }
  }
  return $referer;
}