VB icon

Very Good Anti-Leech Script

Email
Submitted on: 1/1/2015 4:46:00 AM
By: Steve Oliver (from psc cd)  
Level: Intermediate
User Rating: By 7 Users
Compatibility: PHP 3.0, PHP 4.0
Views: 2255
 
     This is the best anti-leech script out there. There is now way at all to tell where a file is coming from. What it does is open the file, and streams it through the script. This example demonstrates various functions of PHP.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
//**************************************
// Name: Very Good Anti-Leech Script
// Description:This is the best anti-leech script out there. There is now way at all to tell where a file is coming from. What it does is open the file, and streams it through the script. This example demonstrates various functions of PHP.
// By: Steve Oliver (from psc cd)
//
// Inputs:$domain - your domain name.
$folder - folder that your files are in.
//**************************************

<?php
/*Anti-Leech script by Steve Oliver
 This is the best anti-leech out there.
 No way of telling where the file is coming from.
 Set the 2 variables below, $domain and $folder.
 You can replace the errors below where commented with html files if wanted.*/
//your domain
$domain="www.yourdomain.com";
//folder that the files are in, no lead or trailing slashes
$folder="filefolder";
$filename=stripslashes(urldecode($QUERY_STRING));
//this can be replaced with
//if ($filename==""){readfile("http://www.yourdomain.com/invalidfile.html");exit;}
if ($filename==""){die("<h1>Invalid File Request...</h1>");}
$refr=getenv("HTTP_REFERER");
list($remove,$stuff)=split('//',$refr,2);
list($home,$stuff)=split('/',$stuff,2);
//this can be replaced with
//if ($home!=$domain){readfile("http://www.yourdomain.com/leecher.html");exit;
if($home!=$domain){die("<h1>Leecher!</h1>This file is from $domain");
}else{
$fp=@fopen("http://".$domain."/".$folder."/".$filename,"r");
if($fp){
if (ereg(".mp3",$filename)){$xtype="audio/mpeg";}
elseif(ereg(".zip",$filename)){$xtype="application/x-zip-compressed";}
elseif(ereg(".exe",$filename)){$xtype="application/x-msdownload";}
else{$xtype="application/octet-stream";}
Header("Content-Type: $xtype");
Header("Accept-Ranges: bytes");
Header("Content-Disposition: ; Filename=$filename");
readfile("http://".$domain."/".$folder."/".$filename);
}else{
//this can be replaced with
//readfile("http://www.yourdomain.com/filenotfound.html");exit;
die("file not found");
}}
?>


Other 4 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.