IPB

Welcome Guest ( Log In | Register )



Tags
This content has not been tagged yet
 
Reply to this topicStart new topic

Check Referrer To Prevent Linking Yours From Other Sites

, Check referrer with Php and Mysql


P0T33n
no avatar
Newbie [Level 1]
*
Group: Members
Posts: 17
Joined: 15-July 06
Member No.: 26,645



Post #1 post Aug 19 2006, 04:56 PM
Check Referrer Using Php To Prevent People Linking To Your Downloads From Other Sites

Ever find that found some people are listing items, images and tuts and linking directly to the download url (those that are like my photoshop tutorial.php?id=0), which is a .php to count the number of downloads. 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 my domain, it downloads the file normally, if it's not, it will redirect to my 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

}

?>


Hope some one finds this usefull!! smile.gif

[note=electriic ink] P0T33n, in the future please ensure that your topic titles and descriptions are as descriptive as possible and that you put all your code in [-CODE-] tags. Thank you. [/note]

This post has been edited by BuffaloHELP: Aug 21 2006, 05:05 AM
Go to the top of the page
+Quote Post
Plenoptic
no avatar
Trap Double Mocha Member
***************
Group: [HOSTED]
Posts: 2,310
Joined: 5-November 05
From: That one place over there...
Member No.: 13,830
myCENT:24.66



Post #2 post Aug 19 2006, 06:06 PM
That is pretty useful I might have to try it sometime. Hopefully I can adjust it to work on all browsers and make it more secure. I would post a comment on the page saying that those who have reached the page from the wrong area can visit the site that way people know the link they got wasn't from the creator of the download or whatever. I can use this for my download system. Nice tutorial.
Go to the top of the page
+Quote Post
Dooga
no avatar
Moderator
***********
Group: Members
Posts: 1,346
Joined: 26-December 04
From: Canada
Member No.: 2,940
myCENT:66.95



Post #3 post Aug 20 2006, 07:41 AM
Referals can be changed, which means that this sometimes doesn't work.
Go to the top of the page
+Quote Post
Florisjuh
no avatar
Proud to be hosted
*********
Group: Members
Posts: 992
Joined: 11-July 04
From: NL
Member No.: 75



Post #4 post Aug 20 2006, 01:54 PM
This is a nice and usefull script, thanks for sharing it. Leeching is a pretty big problem nowadays seeing every website 'hotlinks like hell' while traffic is very important seeing content can be found everywhere nowadays.
Go to the top of the page
+Quote Post
Sprnknwn
no avatar
Privileged Member
*********
Group: Members
Posts: 821
Joined: 6-March 05
Member No.: 4,202



Post #5 post Aug 21 2006, 09:33 AM
Nice tutorial. Iīll definitely bookmark it, maybe itīll be useful in the near future. Thanks.
Go to the top of the page
+Quote Post
delivi
no avatar
Trap Grand Marshal Member
***********
Group: [HOSTED]
Posts: 1,320
Joined: 11-January 06
Member No.: 16,932
myCENT:NEGATIVE[-455.29]



Post #6 post Aug 20 2007, 05:49 PM
great script, will help a lot in saving the precious bandwidth.
Go to the top of the page
+Quote Post
Soby
no avatar
Member [Level 1]
****
Group: Members
Posts: 52
Joined: 25-August 07
Member No.: 48,808



Post #7 post Sep 10 2007, 06:27 AM
What is the file that I want to put on the server is hosted on a different webserver. Can it check referers for that too?
Go to the top of the page
+Quote Post
iGuest
no avatar
Hail Caesar!
*********************
Group: Members
Posts: 5,876
Joined: 21-September 07
Member No.: 50,369



Post #8 post May 3 2008, 02:21 PM
Bad script,very bad. If I put in my reffer : "> ,then this site with this script is vulnerable to XSS

-reply by Number.49
Go to the top of the page
+Quote Post
hitmanblood
no avatar
Privileged Member
*********
Group: [HOSTED]
Posts: 786
Joined: 13-April 07
From: mreža
Member No.: 41,558



Post #9 post Jun 13 2008, 08:37 PM
Well, this is useful script for web statistics but not for the prevention of unwanted download. So you should check it it may be as starting point for some other more secure scripts.

But as this script is very easily defeated it is not very secure. So be careful when imposing this script to your site. And another thing I personally never use open source scripts that are widely available for important security parts of my sites.

***--this is after edition--***

there is also one thing is referral is entered as blank that is as you can make custom user agents then you may be able to enter the site and make it work in unwanted way.
This is important fact.

This post has been edited by hitmanblood: Jun 13 2008, 08:40 PM
Go to the top of the page
+Quote Post
iGuest
no avatar
Hail Caesar!
*********************
Group: Members
Posts: 5,876
Joined: 21-September 07
Member No.: 50,369



Post #10 post Jul 10 2009, 09:21 AM
PHP Referer check/redirect mostly useful.
Check Referrer To Prevent Linking Yours From Other Sites

While not foolproof, this script is now being used in my wife's website, www.Tiffany.Pro. What this script helps us do is prevent the average and most advanced folks from copying the pages that contain copyright work. We deployed the use of the jQuery thickbox plugin and a bit of javascript highlighting disabling functions. There are 2 ways to overcome this to copy the text, but the chances of people doing this are unlikely. The steps only took a half hour or so to take, and now she can self publish her work without worry that search engines and others will go out of their way to copy the text, where it might find it's way around the rest of the web.

I think the author of this script, as it saved me the trouble of writing a custom script.

-reply by Nicholas Maietta

Go to the top of the page
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

    Topic Title Replies Topic Starter Views Last Action
No New Posts   1 Etherion 4,445 3rd August 2004 - 01:15 PM
Last post by: tomko
No New Posts   7 Shibbeh 4,672 7th August 2004 - 02:03 AM
Last post by: Critical_Impact
No new   39 Bash 39,925 28th May 2009 - 01:47 AM
Last post by: nol
No New Posts 8 hatebreed 3,916 25th August 2004 - 02:21 AM
Last post by: Zenchi
No new   36 Bash 12,338 10th November 2004 - 10:07 AM
Last post by: finaldesign
No New Posts   1 Bash 8,892 8th August 2004 - 09:03 PM
Last post by: Torch89
No new   21 odomike 9,426 24th August 2004 - 06:00 PM
Last post by: odomike
No New Posts 10 holyium 9,966 25th September 2004 - 12:33 AM
Last post by: spyshow
No New Posts   3 jailbox 9,169 11th August 2006 - 06:34 PM
Last post by: juice
No New Posts 5 football123213 2,753 2nd September 2004 - 01:47 AM
Last post by: football123213
No new   40 Too_Hot 9,249 19th September 2004 - 09:19 AM
Last post by: Too_Hot
No New Posts 6 dozen 4,673 9th September 2004 - 11:58 PM
Last post by: Triple X
No New Posts 6 spyshow 6,332 24th June 2009 - 09:06 PM
Last post by: iworld200
No New Posts   3 ZPGames 962 8th August 2007 - 05:51 PM
Last post by: ZPGames
No New Posts   11 downpour 6,566 2nd October 2004 - 11:06 AM
Last post by: hulunes


 



RSS Open Discussion Time is now: 22nd November 2009 - 08:40 AM

Web Hosting Powered by ComputingHost.com.