I was looking for a download protector so that I could utilize adsense and distribute downloads while displaying the the ads without allowing direct linking.
This is the script I was looking at:
CODE
<?php
///////////////////////////////////////////////
// //
// Download Protector v 1.1 //
// ----------------------------------------- //
// by Graeme (webmaster@phpscriptcenter.com) //
// http://www.phpscriptcenter.com //
// //////////////////////////////
// PHP Script CENTER offers no warranties on this script. //
// The owner/licensee of the script is solely responsible for any //
// problems caused by installation of the script or use of the script //
// //
// All copyright notices regarding Download Protector, must remain //
// intact on the scripts and in the HTML for the scripts. //
// //
// (c) Copyright 2001 PHP Script CENTER //
// //
// For more info on Download Protector, //
// see http://www.phpscriptcenter.com/downloadprotector.php //
// //
///////////////////////////////////////////////////////////////////////////
$ADMIN[defaulturl] = "http://phpscriptcenter.com";
$okaysites = array("http://phpscriptcenter.com","http://www.phpscriptcenter.com");
$ADMIN[url_1] = "http://www.phpscriptcenter.com/download.php3?product=";
$ADMIN[url_2] = "http://downloads.com";
$ADMIN[url_3] = "http://downloads.com/new";
//////////////////////////////////////////////////////
$reffer = $HTTP_REFERER;
if($reffer) {
$yes = 0;
while(list($domain, $subarray) = each($okaysites)) {
if (ereg("$reffer",$subarray)) {
$yes = 1;
}
}
$theu = "url"."_"."$site";
if ($ADMIN[$theu] AND $yes == 1) {
header("Location: $ADMIN[$theu]/$file");
} else {
header("Location: $ADMIN[defaulturl]");
}
} else {
header("Location: $ADMIN[defaulturl]");
}
?>
///////////////////////////////////////////////
// //
// Download Protector v 1.1 //
// ----------------------------------------- //
// by Graeme (webmaster@phpscriptcenter.com) //
// http://www.phpscriptcenter.com //
// //////////////////////////////
// PHP Script CENTER offers no warranties on this script. //
// The owner/licensee of the script is solely responsible for any //
// problems caused by installation of the script or use of the script //
// //
// All copyright notices regarding Download Protector, must remain //
// intact on the scripts and in the HTML for the scripts. //
// //
// (c) Copyright 2001 PHP Script CENTER //
// //
// For more info on Download Protector, //
// see http://www.phpscriptcenter.com/downloadprotector.php //
// //
///////////////////////////////////////////////////////////////////////////
$ADMIN[defaulturl] = "http://phpscriptcenter.com";
$okaysites = array("http://phpscriptcenter.com","http://www.phpscriptcenter.com");
$ADMIN[url_1] = "http://www.phpscriptcenter.com/download.php3?product=";
$ADMIN[url_2] = "http://downloads.com";
$ADMIN[url_3] = "http://downloads.com/new";
//////////////////////////////////////////////////////
$reffer = $HTTP_REFERER;
if($reffer) {
$yes = 0;
while(list($domain, $subarray) = each($okaysites)) {
if (ereg("$reffer",$subarray)) {
$yes = 1;
}
}
$theu = "url"."_"."$site";
if ($ADMIN[$theu] AND $yes == 1) {
header("Location: $ADMIN[$theu]/$file");
} else {
header("Location: $ADMIN[defaulturl]");
}
} else {
header("Location: $ADMIN[defaulturl]");
}
?>
Only problem with this script is that it looks at the entire referring link. Is it possible to just have it look at the domain. I ask this because I wish to parse my download page with the download's name in the URL.
i.e.:
download.php?download=whatever.exe shows a page with the adsense and a link to the download (possibly download begins in x seconds). The link is getdownload.php?site=1&file=whatever.exe which goes to the above script.
Thanks!