Welcome and have a nice stay !       login   register   need help?  

 Page Info

Page Title: Forbidden Direct Downloads
Description: How to prevent direct-downloads?
Author: Bonfire
Submission Date: 11-09-2005 08:59

 Rating & Comments

View or add comments: (0)
Average members rating: 8.00



I made easy script for prevent direct-downloads from other pages. (PHP script)
If you have file "http://www.mysite.com/myfiles/downloads/my_file.zip" and you want give link to some forum or page etc., you can do this:
make file "download.php" and write this into file:

Code :
// hide source code
// hide line numbers

 1  <?
 2  
if (SubStr ($_SERVER[HTTP_REFERER], 210) == "http://www.mysite.com"){
 3  
 4  
$file $_GET[f];
 5  
header("Content-Description: File Transfer");
 6  
header("Content-Type: application/force-download");
 7  
header("Content-Disposition: attachment; filename="myfiles/downloads/$file"");
 8  
readfile ($file);
 9  }
10  else {
11  
header ("Location: http://www.mysite.com/mydownloads.php");
12  }
13  
?> 



In first line, the number 21 presents long of the string "http://www.mysite.com"
now the link on your page "http://www.mysite.com/download.php?f=my_file.zip" downloads file "http://www.mysite.com/myfiles/downloads/my_file.zip", but in download link will be written "http://www.mysite.com/download.php?f=my_file.zip".

When you click on this link from other page, or when you directly write this link into explorer, you not start downloading, but explorer open page "www.mysite.com/mydownloads.php" where SAME link what were written on this page starts downloads this file.

Donation:

If you like our free quality work, make a donation by using Paypal and tell us what you would like to see improved on our site for the next few months.

Comments


No comments yet

 Site Activity
Currently online: 0 member(s), 40 guest(s) : All members offline.


 Quick Menu
sitemap
search
galleries
main
forums


 Our Services

Main Projects
Designers For Hire
Unique LDU Skins
LDU Skins For Sale
Seditio Skins For Sale
Templates For Sale


 Statistics
18582 registered members,
1870 topics in forums,
21587 posts in forums,
13589738 pages served since 2004-05-09.
more


 7th Version Design

+++
top