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);
}
?>