Page 1 of 3

Prevent Hotlinking and Bandwidth Theft

Posted: 03 Aug 2011, 08:12
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 944 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.

Prevent Hotlinking and Bandwidth Theft

Posted: 24 Aug 2011, 22:33
by martin123456
Top tool ty stoker

Prevent Hotlinking and Bandwidth Theft

Posted: 24 Aug 2011, 22:38
by Terr0r
what happens if I do this? ?

Prevent Hotlinking and Bandwidth Theft

Posted: 24 Aug 2011, 22:50
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

Prevent Hotlinking and Bandwidth Theft

Posted: 25 Aug 2011, 00:26
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

Prevent Hotlinking and Bandwidth Theft

Posted: 25 Aug 2011, 06:56
by Stoker
There is no htaccess file in the download folder.

Prevent Hotlinking and Bandwidth Theft

Posted: 25 Aug 2011, 13:12
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:

Prevent Hotlinking and Bandwidth Theft

Posted: 25 Aug 2011, 15:20
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

Prevent Hotlinking and Bandwidth Theft

Posted: 25 Aug 2011, 15:23
by Stoker
i see no problems?

Prevent Hotlinking and Bandwidth Theft

Posted: 25 Aug 2011, 15:24
by Terr0r
I have set it now on my forum take a look now