Prevent Hotlinking and Bandwidth Theft

Mixed forum with code snippets, guides and styles
Forum rules
Everything in this forum is for everybody
But support only for Donators!
User avatar
Stoker
Site Admin
Site Admin
Posts: 3536
Joined: 12 May 2008, 23:26
BBCodes: 239
Favourite BBCode: Anipro
Favourite MOD: PrettyPhoto
Location: Denmark
Contact:

Prevent Hotlinking and Bandwidth Theft

Post by Stoker »

Prevent Hotlinking and Bandwidth Theft

Author: Stoker
Description: Here is a little addon for Your phpBB3 board that prevents hotlinking.
It only affects files that are uploaded with the "Upload attachment" function.
Uploaded Avatars, files and images are included.
This way it only causes very little server load because it only checks files placed in the download folder.
Note! Only works on servers running Apache!

Attached file:
prevent hotlinking.zip
(7.14 KiB) Downloaded 943 times
Demo: Copy and post this links at Your own site:

Code: Select all

http://www.phpbb3bbcodes.com/download/file.php?id=213
http://www.phpbb3bbcodes.com/download/file.php?id=162&mode=view/stats.png
Intructions:
Download the zip file, unzip it and open root/download/.htaccess file
It looks like this:

Code: Select all

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+.)?yourdomain.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*.(php)$ ../stop.gif [L]
Change yourdomain.com to Your domain name.
Example:

Code: Select all

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+.)?phpbb3bbcodes.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*.(php)$ ../stop.gif [L]
Upload root/download/.htaccess to root/download
Upload root/stop.gif to root
Offcourse You can use any other pic at Your own choice.

FAQ:
Q - What if I want to allow more domains to hotlink?
A - It is easily done. Lets say that phpbb.com should be allowed to hotlink, just use this:

Code: Select all

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+.)?phpbb3bbcodes.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.+.)?phpbb.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*.(php)$ ../stop.gif [L]
You can add several domains if needed. Just add an extra line as the example above.
Board rules! No PM support
User avatar
martin123456
BBCoder VI
BBCoder VI
Posts: 765
Joined: 25 Jul 2011, 13:29
BBCodes: 34
Favourite MOD: Ban button
Location: Down south!
Contact:

Prevent Hotlinking and Bandwidth Theft

Post by martin123456 »

Top tool ty stoker
User avatar
Terr0r
BBCoder V
BBCoder V
Posts: 339
Joined: 04 May 2011, 00:47
BBCodes: 100
Location: The Netherlands
Contact:

Prevent Hotlinking and Bandwidth Theft

Post by Terr0r »

what happens if I do this? ?
If you can't fix it with ducktape you ain't using enough
For my MODS and BBCodes or other things that I have made take a look here
User avatar
martin123456
BBCoder VI
BBCoder VI
Posts: 765
Joined: 25 Jul 2011, 13:29
BBCodes: 34
Favourite MOD: Ban button
Location: Down south!
Contact:

Prevent Hotlinking and Bandwidth Theft

Post by martin123456 »

You save bandwidth i could come to your site and get the links of an image or a file and place it on my site but you pay for the bandwidth and i get it free as you have paid for it.

Place these on your site in a forum post and click them

Code: Select all

    http://www.phpbb3bbcodes.com/download/file.php?id=213
    http://www.phpbb3bbcodes.com/download/file.php?id=162&mode=view/stats.png
User avatar
Terr0r
BBCoder V
BBCoder V
Posts: 339
Joined: 04 May 2011, 00:47
BBCodes: 100
Location: The Netherlands
Contact:

Prevent Hotlinking and Bandwidth Theft

Post by Terr0r »

this is very nice and a must have

a few questions about this snippet

if Will upload the file then I get the message on my FTP there is already a file white the same name

and now what must I do now ?

the file what already state on my FTP I must let it state there because that is for my forum
If you can't fix it with ducktape you ain't using enough
For my MODS and BBCodes or other things that I have made take a look here
User avatar
Stoker
Site Admin
Site Admin
Posts: 3536
Joined: 12 May 2008, 23:26
BBCodes: 239
Favourite BBCode: Anipro
Favourite MOD: PrettyPhoto
Location: Denmark
Contact:

Prevent Hotlinking and Bandwidth Theft

Post by Stoker »

There is no htaccess file in the download folder.
Board rules! No PM support
User avatar
Terr0r
BBCoder V
BBCoder V
Posts: 339
Joined: 04 May 2011, 00:47
BBCodes: 100
Location: The Netherlands
Contact:

Prevent Hotlinking and Bandwidth Theft

Post by Terr0r »

When I made ​​my post I read that part pass good

and it was very late tonight and I had no sence to change it because I was very tired :lol:
If you can't fix it with ducktape you ain't using enough
For my MODS and BBCodes or other things that I have made take a look here
User avatar
Terr0r
BBCoder V
BBCoder V
Posts: 339
Joined: 04 May 2011, 00:47
BBCodes: 100
Location: The Netherlands
Contact:

Prevent Hotlinking and Bandwidth Theft

Post by Terr0r »

if I do this then get I by images that state on my forum to see this and that is not good I think

Image

how is that possible and how can I fix that

take a look here

I see it also by my avatars and by all images what state on my forum that is not good

this is a good thing but I have get it from my server every image looks like this
Image
and that is not good
Last edited by Terr0r on 25 Aug 2011, 15:24, edited 2 times in total.
If you can't fix it with ducktape you ain't using enough
For my MODS and BBCodes or other things that I have made take a look here
User avatar
Stoker
Site Admin
Site Admin
Posts: 3536
Joined: 12 May 2008, 23:26
BBCodes: 239
Favourite BBCode: Anipro
Favourite MOD: PrettyPhoto
Location: Denmark
Contact:

Prevent Hotlinking and Bandwidth Theft

Post by Stoker »

i see no problems?
Board rules! No PM support
User avatar
Terr0r
BBCoder V
BBCoder V
Posts: 339
Joined: 04 May 2011, 00:47
BBCodes: 100
Location: The Netherlands
Contact:

Prevent Hotlinking and Bandwidth Theft

Post by Terr0r »

I have set it now on my forum take a look now
If you can't fix it with ducktape you ain't using enough
For my MODS and BBCodes or other things that I have made take a look here
Post Reply