Icy Phoenix
Free PHP Scripts - Test Prevent Image Hotlinking
KugeLSichA [ Sat 20 Feb, 2010 14:49 ]
Post subject: Test Prevent Image Hotlinking
icyphoenix.com is in the whitelist... so the image should be displayed...
ok it works...

great

TheSteffen [ Sun 21 Feb, 2010 13:59 ]
Post subject: Re: Test Prevent Image Hotlinking
Is it your own whitelist? A special mod or is it already in IP
KugeLSichA [ Sun 21 Feb, 2010 15:39 ]
Post subject: Re: Test Prevent Image Hotlinking
Is it your own whitelist? A special mod or is it already in IP
its configured in .htaccess (i´ll provite the code later here)
there are 2 ways to prevent hotlinking
1. block all domain who hotlink images, except yours
2. set only the domain which ist not auth to hotlink... <- i prefer this way
f.e. if someone (which domain ist blocked) link to a smilie or pic... it would not show the original pic... the pic which is showed f.e. this one

TheSteffen [ Sun 21 Feb, 2010 16:18 ]
Post subject: Re: Test Prevent Image Hotlinking
Ah, OK... thanks for the information
KasLimon [ Sun 21 Feb, 2010 16:24 ]
Post subject: Re: Test Prevent Image Hotlinking
In any case that person is stealing you bandwith, since that image also consumes resources

KugeLSichA [ Sun 21 Feb, 2010 16:27 ]
Post subject: Re: Test Prevent Image Hotlinking
In any case that person is stealing you bandwith, since that image also consumes resources

yes your right...
but for example... if you have a stealing site which includes many other single pictures from your server.. so it loads only that one image... and then its in the browser cache...
and the second thing is... i have no problem if some ask me if he can include a image... but without ausking, i dont tolerate it...
spydie [ Tue 30 Mar, 2010 20:53 ]
Post subject: Re: Test Prevent Image Hotlinking
could you please post the code here, Kugel
KugeLSichA [ Wed 31 Mar, 2010 00:16 ]
Post subject: Re: Test Prevent Image Hotlinking
could you please post the code here, Kugel
Thanks for remind me...
OPEN
.htaccess
ADD
### S T O P H O T L I N K I N G BEGIN
# Stop Hotlinking Images ONLY for a specific site
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?example.de\.tl/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?example\.com/ [NC]
RewriteRule .*\.(jpe?g|gif|bmp|png)$ /images/nohotlinking.jpe [L]
# Blocks hotlinking for all other page, except your own page
#RewriteCond %{HTTP_REFERER} !^http://(.+\.)?caromonline\.de/ [NC]
#RewriteCond %{HTTP_REFERER} !^$
#RewriteRule .*\.(jpe?g|gif|bmp|png)$ /images/nohotlinking.jpe [L]
### S T O P H O T L I N K I N G END
You need to create an Image something like this:
Name it to nohotlinking.
jpe an upload to folder images... or something else (change the path in htaccess)
greetings
My_PeSePe [ Wed 31 Mar, 2010 00:33 ]
Post subject: Re: Test Prevent Image Hotlinking
My question is this, only with the images uploaded to my FTP or by example with which I have to serve imageshack.us
Informpro [ Wed 31 Mar, 2010 13:04 ]
Post subject: Re: Test Prevent Image Hotlinking
KasLimon, it use the server because off the request ^^".
spydie [ Wed 31 Mar, 2010 13:29 ]
Post subject: Re: Test Prevent Image Hotlinking
How would you do a whitelist for this ???
got my problems, with ht.access. Php/html is fine, but access is a bit more dificult for me
Does´nt work for me . Any chance to do this via php.ini file ??
my server does´nt read the access files.
Mighty Gorgon [ Thu 01 Apr, 2010 13:57 ]
Post subject: Re: Test Prevent Image Hotlinking
I think you can do that only via htaccess.
Otherwise you should create a php file which read images and then black and white list host using PHP code. Like the album does for example.
spydie [ Mon 16 Aug, 2010 12:42 ]
Post subject: Re: Test Prevent Image Hotlinking
anyway there´s one inconvenience.
if you put that in ht.access, it also blocks your forum link image.
that means , you can´t do interchange of link´s with this, since you´ve got to put all pages with links to you´re site in the whitelist, so they´re able to hotlink any image of you´re site
iorio [ Tue 04 Jan, 2011 17:41 ]
Post subject: Re: Test Prevent Image Hotlinking
Holaa
Ghostsearcher [ Wed 09 Feb, 2011 16:04 ]
Post subject: Re: Test Prevent Image Hotlinking
Hi there!
Just a question. I have already edited my htaccess and it works for now.
But now i have a little problem. It's about the dynamic images. They are all "not" hotlink protected.
Like this example: (this is the avatar!)
- http://example.org/download/file.php?avatar=2_1296526796.png
So i googled for it and snap up this code:
- RewriteCond %{HTTP_REFERER} !^http://(www\.)?example.org/download/(.+)php/?avatar/=(.+)?$ [NC]
-
But this code deosn't work....
Can you help me further?
Thank you very much!
Greetings, testi

Mighty Gorgon [ Fri 11 Feb, 2011 10:56 ]
Post subject: Re: Test Prevent Image Hotlinking
You should act directly on the PHP files using the REFERRERS value...
This is an old piece of code I used to use:
$check_referer = explode('?', $_SERVER['HTTP_REFERER']);
$check_referer = trim($check_referer[0]);
$good_referers = array();
if (!empty($config['hotlink_allowed'])
{
$good_referers = explode(',', $config['hotlink_allowed']);
}
$good_referers[] = $config['server_name'] . $config['script_path'];
$errored = true;
for ($i = 0; $i < sizeof($good_referers); $i++)
{
$good_referers[$i] = trim($good_referers[$i]);
if ((strstr($check_referer, $good_referers[$i])) && ($good_referers[$i] != ''))
{
$errored = false;
}
}
if ($errored)
{
die('NO HOTLINK');
/*
header('Content-type: image/jpeg');
header('Content-Disposition: filename=' . $pic_info['title_reg'] . '.' . $pic_info['filetype']);
readfile($images['no_thumbnail']);
exit;
*/
}
Ghostsearcher [ Fri 11 Feb, 2011 11:33 ]
Post subject: Re: Test Prevent Image Hotlinking
Hi there!
Thank you for helping me. It seems to be a hot piece of code you're given me, but i have unfortunely no clue where i have to put it in there.
Can you give me a little hint for that?
Thank you very much!
Greetings, testi
Mighty Gorgon [ Fri 11 Feb, 2011 12:47 ]
Post subject: Re: Test Prevent Image Hotlinking
Hey
testi (I omit the last part to avoid Joshua jumping in and laugh

)!
Just to understand the way I can explain further... How can you rate your PHP knowledge on a scale from 1 to 10?
You mentioned before that you couldn't block your "file.php" to be hotlinked, right? This code should be added almost on top of that file, but of course a bit of edit is needed to configure things properly...
spydie [ Fri 11 Feb, 2011 13:23 ]
Post subject: Re: Test Prevent Image Hotlinking
BTW MG
Testi is using PhpBB3
Mighty Gorgon [ Fri 11 Feb, 2011 15:48 ]
Post subject: Re: Test Prevent Image Hotlinking
Thanks
spydie for clarifying, but I already knew that.
The code I provided is just standard PHP plus a var which has to be defined... but before defining that I wanted to know how detailed I need to explain what he has to do.
Ghostsearcher [ Sat 12 Feb, 2011 14:47 ]
Post subject: Re: Test Prevent Image Hotlinking
Hi there!
Yes, i've updated now my signature for what i use atm. I just forget the main things to say which software i'm using.
And thank you very much Mighty, for answering me. It seems for me the right way.
Well, of course i don't know where i have to setting in the code in the file.php.

I've tried it with just copy and paste in the first line before "<?php" or below of it - But just the avatars will not shown. lol
So i'm curious how it will really work.
And still one question: Why i have to do this with php and why i can't handle this in the htaccess?
Just asking so i can understanding that.
Thank you!
Best Greetings, Testi ^^
spydie [ Sat 12 Feb, 2011 20:41 ]
Post subject: Re: Test Prevent Image Hotlinking
it´s probably, because if you use .htaccess, you´ll block all referers to hotlink, or you need to put the ones you allow , into your whitelist.
with this piece of code, it´s handelt by the script itself, with the ability to allow or disallow them in the ACP i think.
so you don´t need to edit the .htaccess all the times.
BTW htaccess would block all images from hotlinking
Ghostsearcher [ Sun 13 Feb, 2011 15:25 ]
Post subject: Re: Test Prevent Image Hotlinking
it´s probably, because if you use .htaccess, you´ll block all referers to hotlink, or you need to put the ones you allow , into your whitelist.
[...]
BTW htaccess would block all images from hotlinking
Hi there.
I already knew this, what you say and i want this. So if you read my first post in this thread, you will see that just this line doesn't work:
- RewriteCond %{HTTP_REFERER} !^http://(www\.)?example.org/download/(.+)php/?avatar/=(.+)?$ [NC]
And i ask me why, because all the other rules are working good for me!
I think, i have to wait for mighty.
Mighty Gorgon [ Sat 19 Feb, 2011 10:17 ]
Post subject: Re: Test Prevent Image Hotlinking
Unfortunately it is not so easy to include all possible combinations just using regular expressions in HTACCESS because phpBB 3 just use a single php file for serving any file to users (being images or zip files...).
It's tough for me to explain the whole thing, but when you use PHP to serve files, then the content could be easier controlled using PHP code instead of going through HTACCESS, because only PHP code at that stage really knows which kind of file are you serving and which kind of limitations you would like to be in place.
Anyway, back to the point... now that I know what you would like to achieve and that you need to be guided through the process... I just need some time to adjust the right code to suit your needs.
Please be patient until I find the time for doing that... I'll be back with the code sooner or later.

Ghostsearcher [ Sat 19 Feb, 2011 15:39 ]
Post subject: Re: Test Prevent Image Hotlinking
Hello Gorgon!
You are really helpful! Thank you for that!!!

And of course you have so much time you need, because now i understand what you mean "its not so easy". I ever thought, htaccess is the ultimate weapon for this. Seems not to be. ^^
It's much fun to learn with you.
Thank you!
Best wishes, the testi of the testis. ^^
Mighty Gorgon [ Sun 20 Feb, 2011 10:13 ]
Post subject: Re: Test Prevent Image Hotlinking
I ever thought, htaccess is the ultimate weapon for this. Seems not to be. ^^
HTACCESS is actually the best weapon for that, because you just check things on access, avoid charging CPU with other processes. The only point is that HTACCESS is a strange and tough beast, and if you don't know how to code that properly, you can create much more problems than those you will solve.
Can I just ask why are you so worried about avatars hotlinking?
Ghostsearcher [ Sun 20 Feb, 2011 18:26 ]
Post subject: Re: Test Prevent Image Hotlinking
Hi Mighty!
Well, that htaccess is a beast is no wonder for me. If i remind me right, i needed round'bout 4 weeks to solve my general hotlink problem in the past. Because many things didn't worked right for me and the internet - pheeeww - it is sometimes really confusing about this hotlink things. I think, you can follow me.

That one wrote it works but not at me and the other one told me, that cant working, but he told me also not how i could fix that.
But thats not the point today, because my hotlink protection is working so far so good. (except the avatar thingy)
So, it is just a challenge for me to find out, why my htaccess can protect hotlinking, but not by avatars.
Again i found out, i have to put another line to my htaccess:
- RewriteCond %{HTTP_REFERER} !^http://(www\.)?example.org/download/(.+)php/?avatar/=(.+)?$ [NC]
But if i do that: nothing happens. (i told it a couple of posts before ^^)
And as i said, it was found by me in the internet and just guess: well, the user told me it works for him. haha. -.-"
Not for me.

In the other forums of phpbb, mod_rewrite, php and so on, noone can tell me anything about that.
But you, Mighty. ^_^
So and the thing to me is just the fact, why i "just" cant fix to prevent hotlinking of avatars except an eventuelly modified file.php. Because the line of code for the htacess should working - i guess.
And if i modified the line by "experimenting with letters and copy and paste it", the avatars doesnt appears. lol? lol... ^^
As you can see, it is for me more than fun to fix my "problem". I want to find out why it doesnt works and i want to know how it could be works. I have no spammery or hotlinker in my forum.
But, well, i think if i want to prevent hotlink, i have to make it right.
I hope you can understand/follow me.
I have time for that and i'll dont push this thread of course because i heard much about you that you dont have so much time. So i really appreciate it if you help me in any way for my very little problem.
I'm just glad about that, that just anyone want to help me. So i can wait.
Thank you very much!
Best Greetings...
Mighty Gorgon [ Wed 23 Feb, 2011 18:27 ]
Post subject: Re: Test Prevent Image Hotlinking
Ok... so if I understand correctly I just need to play with HTACCESS and see if I can come with an HTACCESS protection.
I will have a try with HTACCESS and get back to you when I have some free time.
Ghostsearcher [ Sat 28 May, 2011 18:14 ]
Post subject: Re: Test Prevent Image Hotlinking
Hi there!
I want to let you know that i'm switching right now to "icy phoenix - board", instead of my old normal phpbb3.0.8!
So it's not sooo important anymore i guess.
If you wish, you don't need anymore make your head broken about the htaccess problem. If yes, so im still curious about that. ^^

Thank you very much! (and to joshua203 to his advise for using icy ^_~)
Best Greetings, testi* ^^
P.s.: I-P looks really cool..!!!! Better than the normal phpbb 3.0.8!
Mighty Gorgon [ Sat 04 Jun, 2011 10:31 ]
Post subject: Re: Test Prevent Image Hotlinking
Hey Testi*, I'm glad to see that you are trying to move to Icy Phoenix, I hope you won't be disappointed.
Did you manage to convert from phpBB 3 yet?
Regarding HTACCESS, I didn't have the time to play with that yet unfortunately...
