View Single Post
  #5 (permalink)  
Old 01-24-2008, 09:22 AM
xorsyst xorsyst is offline
New Pligger
 
Join Date: Dec 2007
Posts: 12
Thanks: 0
Thanked 1 Time in 1 Post
Stumbled upon this script just now. A generic script that redirects to Coral Cache. Figured it would help if anyone is still interested in this useful script.

mpwebwizard » Blog Archive » Using a mirror automatically for hits from popular websites

Quote:
To use this code, simply include it above all the PHP code in your website. You must make sure there is no output (including whitespace) otherwise the script will fail when it comes to redirection.
Code:
<?php

/** ************************** **/
/** COPYRIGHT MARTIN PORCHERON **/
/** ************************** **/

$sites	= Array(
		'digg.com',
		'slashdot.org',
		'reddit.com',
		'fark.com',
		'somethingawful.com',
		'kuro5hin.org',
		'engadget.com',
		'boingboing.net',
		'del.icio.us',
		'netscape.com'
		);
 
if (isset ($_SERVER['HTTP_REFERER']) && !strstr ($_SERVER['HTTP_USER_AGENT'], 'CoralWebPrx'))
{
	$referer = parse_url ($_SERVER['HTTP_REFERER']);
	$referer = $referer['host'];
	foreach ($sites as $site)
	{
		if (stristr ($referer['host'], $site))  
		{
			header ('Location: http://'. $_SERVER['HTTP_HOST'] .'.nyud.net:8080'. $_SERVER['REQUEST_URI']);
			exit;
		}
	}
	unset ($sites);
	unset ($referer);
	unset ($site);
}
?>

Last edited by xorsyst; 01-24-2008 at 09:27 AM..
Reply With Quote