Go Back   vb.org Archive > vBulletin Modifications > vBulletin 4.x Modifications > vBulletin 4.x Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Complete Hotlink Protection Details »»
Complete Hotlink Protection
Version: 1.00, by naveeid naveeid is offline
Developer Last Online: Apr 2019 Show Printable Version Email this Page

Category: Board Optimization - Version: 4.x.x Rating:
Released: 04-25-2011 Last Update: Never Installs: 20
Re-useable Code Translations  
No support by the author.

Title : Complete Hotlink Protection

Version : 1.1

Coder : naveeid
Purpose : Prevent your forum attachments from being directly linked to - prevent bandwidth abuse.

Why : My dedicated server was down due to too many hotlinked image connections. i was feeling helpless. even after protecting images through .htaccess, images were still hot linked through attachment.php



How : just edit your server .htaccess and modify the code with your domain names



Installation :
edit your .htaccess file.

Code:
RewriteEngine on

RewriteCond %{HTTP_REFERER} !^http://(.+\.)?yourfirstwebsite\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?yoursecondwebsite\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?google\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|bmp|png)$ http://www.yourfirstwebsite/anypic.jpg [L]


RewriteCond %{HTTP_REFERER} !^http://(.+\.)?yourfirstwebsite\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?google\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*attachment\.php*$ http://www.yourfirstwebsite/anypic.jpg [L,R,NC]

1) please change yourfirstwebsite.com and yoursecondwebsite.com to your websites on that cpanel account. if you dont have a second website then you can remove that line

2) i am allowing google to fetch images or attachments for their server. if you dont want to allow google then just remove that line.

3) replace anypic.jpg with your website banner or hotlink warning banner.

it works very fine. its the simplest and easiest available soloution.

Demo:-
i have installed it on my website , you can check my website for hotlink protection.
http://www.nidokidos.org/attachment....3&d=1302073196
now this image will show in my website , this image will be displayed if opened it in a browser. but if it will be opened in any other website , it will be replaced by my website banner.

Supporters / CoAuthors

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.
Благодарность от:
madness85

Comments
  #32  
Old 10-24-2012, 03:39 PM
viper357's Avatar
viper357 viper357 is offline
 
Join Date: Dec 2006
Location: Worthing, UK
Posts: 563
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It's blocking images on tapatalk, any idea how we can allow tapatalk?
Reply With Quote
  #33  
Old 12-16-2012, 02:39 AM
Ary Braga Ary Braga is offline
 
Join Date: Jun 2009
Posts: 28
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

naveeid and Boofo. I'm from Brazil

My .HTACESS stayed that way

Code:
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?MYDOMAIN\.com\.br/.*$ [NC]
RewriteRule \.(mid|wav|mp3|zip|avi|rm|ram|swf|mpg|wmv|pdf|jpeg|jpg|gif|bmp|png|psd|ipa|deb)$ http://www.MYDOMAIN.com.br/images/Xto4B.jpg [NC,R,L]
Until herein perfect.

I have a doubt.

The image that will be replaced in the hotlink, should be the same as the image copies from within my domain ?

The image that will be replaced in the hotlink is warped.

Eg: The original image is 200px x 400px.

My hotlink picture. Should measure 200 x 400 too?
Or should lower?

The problem that my images vary in height and width.

Is there any way to set it somewhere or file?

The hotlink img is here:

The test only is here
Reply With Quote
  #34  
Old 01-08-2013, 06:03 AM
naveeid's Avatar
naveeid naveeid is offline
 
Join Date: Jan 2011
Posts: 104
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Ary Braga View Post
naveeid and Boofo. I'm from Brazil

My .HTACESS stayed that way

Code:
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?MYDOMAIN\.com\.br/.*$ [NC]
RewriteRule \.(mid|wav|mp3|zip|avi|rm|ram|swf|mpg|wmv|pdf|jpeg|jpg|gif|bmp|png|psd|ipa|deb)$ http://www.MYDOMAIN.com.br/images/Xto4B.jpg [NC,R,L]
Until herein perfect.

I have a doubt.

The image that will be replaced in the hotlink, should be the same as the image copies from within my domain ?

The image that will be replaced in the hotlink is warped.

Eg: The original image is 200px x 400px.

My hotlink picture. Should measure 200 x 400 too?
Or should lower?

The problem that my images vary in height and width.

Is there any way to set it somewhere or file?

The hotlink img is here:

The test only is here

brother you can not control this. because the image we replace with hotlinked image is different sizes. i think its not important , we can ignore this.
Reply With Quote
  #35  
Old 01-08-2013, 06:04 AM
naveeid's Avatar
naveeid naveeid is offline
 
Join Date: Jan 2011
Posts: 104
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by viper357 View Post
Does this work in vb3? I've put this at the bottom of my htaccess file but it doesn't seem to work, can someone check it for me please? My website is in my signature. Thanks.
Code:
RewriteEngine on

RewriteCond %{HTTP_REFERER} !^http://(.+\.)?marineaquariumsa\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?google\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?bing\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|bmp|png)$ http://www.marineaquariumsa.com/hotpic.jpg [L]


RewriteCond %{HTTP_REFERER} !^http://(.+\.)?marineaquariumsa\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?google\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?bing\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*attachment\.php*$ http://www.marineaquariumsa.com/hotpic.jpg [L,R,NC]



i cant say anything about vb3 , if the same attachment.php type of thing is there in vb3 , then i think it will work out.
Reply With Quote
  #36  
Old 01-08-2013, 06:06 AM
naveeid's Avatar
naveeid naveeid is offline
 
Join Date: Jan 2011
Posts: 104
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by viper357 View Post
It's blocking images on tapatalk, any idea how we can allow tapatalk?


to allow any webiste , just add this code below the google line


RewriteCond %{HTTP_REFERER} !^http://(.+\.)?google\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?YESTOTHISWEBSITE\.com/ [NC]

replace YESTOTHISWEBSITE with the name of the website which you want to allow for hotlink.
Reply With Quote
  #37  
Old 06-19-2013, 02:11 PM
MonkYZ MonkYZ is offline
 
Join Date: Jul 2008
Posts: 334
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What if i have vBSEO installed? Seems like it's not working for me (as it's rewriting the url to make it friendly - therefore it doesn't have the attachment.php inside). Let's do a test:

I will use an IMG for this:
Code:
http://www.consolegames.ro/forum/attachments/f7-console-news/198081d1371497600-cum-se-descurca-last-us-la-capitolul-vanzari-the_last_of_us.jpg?cmps=1


See? It's still showing... although i've added the .htaccess lines...
Reply With Quote
  #38  
Old 09-04-2014, 08:03 PM
thetechgenius's Avatar
thetechgenius thetechgenius is offline
 
Join Date: Jun 2014
Posts: 258
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Does anyone have the web.config version of this? I am using iis 7 (windows server 2008R2), and as you know, windows uses web.config, not htaccess.
Reply With Quote
  #39  
Old 09-04-2014, 11:57 PM
ozzy47's Avatar
ozzy47 ozzy47 is offline
 
Join Date: Jul 2009
Location: USA
Posts: 10,929
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have seen you ask numerous times about the windows server, is there a particular reason you don't switch to a Linux server?
Reply With Quote
  #40  
Old 09-05-2014, 03:07 PM
madness85 madness85 is offline
 
Join Date: Jun 2012
Posts: 175
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

works great thank you
Reply With Quote
  #41  
Old 10-16-2014, 11:20 AM
angeljs's Avatar
angeljs angeljs is offline
 
Join Date: Aug 2005
Location: UK
Posts: 384
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks so much for this, just what I needed. I uploaded it to my forum directory as it wouldn't work in the root.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:55 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.14864 seconds
  • Memory Usage 2,338KB
  • Queries Executed 27 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (5)bbcode_code
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (11)post_thanks_box
  • (1)post_thanks_box_bit
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete