Important alert: (current site time 7/16/2013 6:45:33 AM EDT)
 

VB icon

Anti-Leech for CF

Email
Submitted on: 1/29/2002 5:49:21 PM
By: Steve Oliver 
Level: Intermediate
User Rating: Unrated
Compatibility: Cold Fusion 4.5, Pre Cold Fusion 4.5
Views: 12096
(About the author)
 
     Perfect for those with limited bandwidth. Stop others from leeching your files. Put files in a folder that isn't in your web root, and use this script to serve the files.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
//**************************************
// Name: Anti-Leech for CF
// Description:Perfect for those with limited bandwidth. Stop others from leeching your files. Put files in a folder that isn't in your web root, and use this script to serve the files.
// By: Steve Oliver
//
// Inputs:file=filename
//
// Returns:the file
//
//This code is copyrighted and has// limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=43&lngWId=9//for details.//**************************************

<!---Save this source to download.cfm, remove all of the dots of course :)
.
To download a file, simply put yourserver.com/download.cfm?file=filename
.
This file checks for http_referer, it could be modified to check for session
variables or cookies as well, for maximum security.--->
.
.
.
<!---set the directory here--->
<cfset directory = "c:\path\to\files\">
.
.
<!---if the referer doesn't have your domain name in it, it rejects the download--->
<cfif CGI.HTTP_REFERER DOES NOT CONTAIN "http://your server/">
.
<H2>UNAUTHORIZED ACCESS</H2>
Remote IP: 
<cfoutput> #CGI.REMOTE_ADDR# </cfoutput>
<br>
<br>
You are not authorized to download this file.
<br>
<br>
.
<cfelse>
.
<!---all is good, serve them the file--->
<cfheader name="Content-Disposition" value="inline; filename=#URLDecode(URL.file)#">
<cfcontent file="#Directory##URLDecode(URL.file)#" type="application/ms-download">
</cfif>


Other 3 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

2/12/2007 6:25:37 PMMatt Foley

This is very cool forCF on Apache.... What about for IIS webservers? I googled and found this free one -- http://www.michaelbrumm.com/leechblocker.html --and what seemed to a good commericial one -- http://www.linkdeny.com. Anyone ever tried these out?

Thanks,
Matt
(If this comment was disrespectful, please report it.)

 

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.