For the impatient between you hereĀ“s a whole example first. It checks whether the HTTP_REFERER is valid and converts it into an truly URI before using it on our page.
Code:
$cleaned = array();
$error = 0;
if (is_url($_SERVER['HTTP_REFERER'], PATH, $error, $cleaned)) {
if ($error & (SCHEME + AUTHORITY)) {
$_SERVER['HTTP_REFERER'] = make_abs($_SERVER['HTTP_REFERER'],
$_SERVER['SCRIPT_URI']);
} elseif ($cleaned['authority']!= $_SERVER['SERVER_NAME']) {
echo "Referer is from other domain. We do not include it.";
} else {
$_SERVER['HTTP_REFERER'] = make_uri($cleaned);
echo "<br>$_SERVER[HTTP_REFERER]";
}
} else {
echo "errors: $error<br>";
}
Bookmarks