https://www.icyphoenix.com/viewtopic.php?f=33&t=6976&p=51467#p51467
-----------------------------------
Mighty Gorgon
Fri 11 Feb, 2011 10:56

Re: Test Prevent Image Hotlinking
-----------------------------------
You should act directly on the PHP files using the REFERRERS value...

This is an old piece of code I used to use:

[codeblock]
	$check_referer = explode('?', $_SERVER['HTTP_REFERER']);
	$check_referer = trim($check_referer[0]);

	$good_referers = array();

	if (!empty($config['hotlink_allowed'])
	{
		$good_referers = explode(',', $config['hotlink_allowed']);
	}

	$good_referers[] = $config['server_name'] . $config['script_path'];

	$errored = true;

	for ($i = 0; $i < sizeof($good_referers); $i++)
	{
		$good_referers[$i] = trim($good_referers[$i]);

		if ((strstr($check_referer, $good_referers[$i])) && ($good_referers[$i] != ''))
		{
			$errored = false;
		}
	}

	if ($errored)
	{
		die('NO HOTLINK');
		/*
		header('Content-type: image/jpeg');
		header('Content-Disposition: filename=' . $pic_info['title_reg'] . '.' . $pic_info['filetype']);
		readfile($images['no_thumbnail']);
		exit;
		*/
	}
[/codeblock]


