Check Referrer

This checks if the referrer is from the site you expect it to be.

function check_ref($site = 'etogre.com')
{
	if (!array_key_exists('HTTP_REFERER', $_SERVER))
		return false;
	
	$parse = parse_url($_SERVER['HTTP_REFERER']);
	$host = $parse['host'];
	$host = str_replace('www.', '', $host);
	
	return ($host == $site);
}

Usage

if (check_ref('etogre.com')) // they came from etogre.com die('We love you =^_^= !'); else die('We hate you -_- !');


Comments

guest
Posted on 28.08.2009 21:10

Nice!

Add your comment