what i want to do is: IF HTTP_REFERER = specific ip-address (coming from a specific website/server) do something else do something else. what's the php code for this please help ^^.
could you use somthing like - <?php $url = $_SERVER['REQUEST_URI']; if($url=="IP?") { do this } ?> HTML: Untested, but you can play with it.
Funk-woo10, I think your example is not what the author told about inaga, You can try to do the follow: if ( $_SERVER['HTTP_REFERER'] == '127.0.0.1 or url here' ) { do smth; } else { do smth else; } PHP: I hope it will help you.
@above Small correction : if ( $_SERVER['REMOTE_ADDR'] == '127.0.0.1' ) { do smth; } else { do smth else; } PHP:
techcone Hm.. maybe Maybe inaga meant by this: "specific ip-address (coming from a specific website/server)" an url which presented as an ip-address..?
INAGA: clear the topic up, some think you want to block specific users with IP adress some think you want to block specific sites linking into your site i believe you want to achieve the latter, since REFERER is REFERER and not REMOTE_ADDR so go with this code, if you want to block a specific site linking to you if(eregi("domain/ip/url-pattern-you-dont-want-to-link.to.you-here",$_SERVER[HTTP_REFERER])) { do-what-you-need-here; die; } Code (markup):
If you want to extend it out perhaps this might work? $last_url = trim($_SERVER['HTTP_REFERER']); $parse_url = parse_url($last_url); $last_domain = $parse_url['host']; switch($last_domain) { case default: //If no match do this; break; case 'www.zomganime.com': //do something; break; } PHP:
Sillysoft Why do you do "trim" to the "HTTP_REFERER"? I think the right way of that line is: $last_url = $_SERVER['HTTP_REFERER'];
Well normally I have functions that would clean the variable, I just used trim to show that I try to clean it up first. But my normal function would trim it, strip any html etc etc. Never trust your data no matter what! Security should always be apart of any web application.