Hi,

I have ran into a problem with a script I am using that shows content to a visitor based upon their browser referer. Here is the relevant portion of the script:

<?php
$allowed_referers[0] = "allowedwebsite.com";
$ok_mode = 0;

if((in_array(parse_url($_SERVER['HTTP_REFERER'],PHP_URL_HOST), $allowed_referers) && $_SERVER['HTTP_REFERER'] != "") || $ok_mode)
{
}
?>

It works fine until I want to add additional allowed referers and that is where I encounter a problem. I would like to either add the list (which includes about 15 allowed referers) into the script or add a function that will retrieve the allowed referers from a text document.

Any help would be greatly appreciated.

$allowed_referers = array();
$allowed_referers[] = "allowedwebsite.com";
$allowed_referers[] = "example.com";

or

$allowed_referers = file('my-allowed-file.txt'); # one url per line
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.