Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Prevent People From Linking To Your Downloads
s2city
post Nov 13 2006, 10:34 PM
Post #1


Premium Member
********

Group: Members
Posts: 155
Joined: 9-October 04
Member No.: 1,586



Ever find that found some people are listing items, images and tuts and linking directly to the download url (those that are like image.php?id=0). To prevent this, you can add a piece of code to the download pages that checks which page referred them to the download page: if it's your domain, it downloads the file normally, if it's not, it will redirect to your home page instead.

Important: Not all browsers log referrers, so this won't work depending on the browser the visitor uses and this method can be also bypassed, but it will work for for the major part of visitors.

CODE
<?php
$yoursite = "yoursite.com"; //Your site url without http://
$yoursite2 = "www.yoursite.com"; //Type your domain with www. this time

$referer = $_SERVER['HTTP_REFERER'];

//Check if browser sends referrer url or not
if ($referer == "") { //If not, set referrer as your domain
$domain = $yoursite;
} else {
$domain = parse_url($referer); //If yes, parse referrer
}

if($domain['host'] == $yoursite || $domain['host'] == $yoursite2) {

//Run your dowloading code here normally

} else {

//The referrer is not your site, we redirect to your home page
header("Location: http://yoursite.com");
exit(); //Stop running the script

}

?>
Go to the top of the page
 
+Quote Post
Saint_Michael
post Nov 14 2006, 12:11 AM
Post #2


$p4m 0n j00 $h4m3 m3 0nc3 $p4m 0n m3 $h4m3 m3 7\/\/1c3
*********************

Group: [HOSTED]
Posts: 6,315
Joined: 21-September 04
From: 9r33|\| 399$ 4|\|D 5P4/\/\
Member No.: 1,218
T17 GFX Crew



Interesting script it's a smart idea to do something like that. When I check around I saw some other one's smaller in script size and yet do the same thing.

Although this could be effective for those who have many downloads that need a password. But sites like filefront and megaupload make this script somewhat useless since people are saving their bw by uploading somewhere else.

But either way interesting script.
Go to the top of the page
 
+Quote Post
biscuitrat
post Nov 14 2006, 04:26 AM
Post #3


Kween of Everything :)
***********

Group: Members
Posts: 1,052
Joined: 16-October 04
From: Houston, Tejas :D
Member No.: 1,774



Oooh, very nice! No one ever seems to mention mass-hotlinking downloads, but thank you for this! In some distant future, when I offer templates or assorted goodies again, I'll check back to this...not that I don't have loads more bandwidth than I need currently, but why not smile.gif
Go to the top of the page
 
+Quote Post
delivi
post Nov 17 2006, 07:18 AM
Post #4


Trap Grand Marshal Member
***********

Group: [HOSTED]
Posts: 1,300
Joined: 11-January 06
From: Chennai, India
Member No.: 16,932



wow thats a great piece of code. i had code for preventing others from hotlinking pictures in my site and this will now make my downloads too unvulnerable.

This will save a lot of bandwidth. Thanx friend
Go to the top of the page
 
+Quote Post
FaLgoR
post Nov 18 2006, 03:07 AM
Post #5


Super Member
*********

Group: Members
Posts: 217
Joined: 2-January 05
Member No.: 3,084



That looks just good, could be useful to me as I like to use these kind of downloading codes. Just a simple question here: what exactly does the parse_url() function does? It sounds obvious if you see the code but I'm still a little confuse biggrin.gif could you give me that little tip? thanks smile.gif
Go to the top of the page
 
+Quote Post
sportytalk
post Nov 18 2006, 09:57 PM
Post #6


Super Member
*********

Group: Members
Posts: 326
Joined: 7-October 05
Member No.: 12,650



I agree with the other replies on this thread. That code there is an interesting one, is quite long, but it's very easy to understand and sounds like it does its job.

I don't have a use for a download protection code as I don't have anything on my site which users can download, however, if I ever did have things which were up for download, there's a high chance I'd include a code similar to this one.
(I wouldn't want users from other people's websites coming to my website via a hyperlink to download something. They'd coming onto the website when they aren't actually browsing it or using it like a normal website, they'd be coming only to download, hence they would be using my bandwidth. Additionally, most of the users wouldn't realise they'd been referred to a different site that this other webmaster doesn't own and the users would still think they're on this other website).

As for the parse url, i've just researched it for you on the php manual section of the official php website.

QUOTE
Quote from http://uk2.php.net/manual/en/function.parse-url.php

This function parses a URL and returns an associative array containing any of the various components of the URL that are present.

This function is not meant to validate the given URL, it only breaks it up into the above listed parts. Partial URLs are also accepted, parse_url() tries its best to parse them correctly.


Basically, i haven't ever used the parse_url function but from what I understand it separates the address into each various sections, such as host and port.

Here is another quotation from the php manual. This is the section of the manual which states the various section which can be retrieved by using this parse_url function which s2city used in his code.

QUOTE

Return Values
On seriously malformed URLs, parse_url() may return FALSE and emit a E_WARNING. Otherwise an associative array is returned, whose components may be (at least one):


scheme - e.g. http
host
port
user
pass
path
query - after the question mark ?
fragment - after the hashmark #

If the component parameter is specified a string is returned instead of an array.


Hopefully you will find this post easy to understand.

Thanks for sharing your download protection with us s2city. Even though I most likely won't have a need to use the code, there's bound to be a lot of users that do need to use it and I feel quite confident in saying quite a few users will use your code, even if they don't give you feedback on their views smile.gif

This post has been edited by sportytalk: Nov 18 2006, 10:11 PM
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. wanna know the gender of people on ere!!(20)
  2. Beside novel or friction, what do you read?(5)
  3. People Who Put You Down And Think They Are The Best....(10)
  4. Rove Live(9)
  5. Arrogant People! Arg(9)
  6. Advice For Guyz By Girls And Visa Versa(15)
  7. The Next Best Generation Download Manager!(43)
  8. What Is The Human Tail? (graphical Content)(35)
  9. What Do You Do When You Love Two People?(46)
  10. The Reason Why People Get Drunk?(33)
  11. Check Referrer To Prevent Linking Yours From Other Sites(8)
  12. Which Domain Of These Ones Would People Recommend?(23)
  13. Animal Cruelty(18)
  14. Php Linking(4)
  15. 14 Downloads For Your Digital Photography Tool Kit (mostly Free)(13)
  1. Why Do People Hate Australias Because Of Spiders?(5)
  2. How To Make A Website(18)
  3. Advice Plz...ِِِ(7)
  4. Why Do People Smoke?(21)
  5. Ways To Destress And Prevent Yourself From Bingeing(5)
  6. People Can Ask For Site Reviews? How Bout Mine?(7)
  7. Hello People(4)
  8. Team Fortress 2 Professional Spy Guide(1)
  9. 95% Of People Are Like Zombies.(9)
  10. Think Wii Fit Is Going To Help People?(10)
  11. I Hate It When People Come To Look At Our House.(2)
  12. Lazy People Can Make Money Too(6)
  13. Vb 2008 Linking To Another Form..(0)


 



- Lo-Fi Version Time is now: 27th July 2008 - 02:32 AM