shoaibi Posted August 2, 2006 Share Posted August 2, 2006 Okay look at me, i am a newbie, not quite one, but still one of the beginners, i know about .htacess and all that. I wanna allow one one country people to view my site.You people tell me what's the best and cheapest method to do that.And is there a place from where i can get the ip ranges so that i cna do something like that:allow Tha.tIP.Ra.n.gedeny all??? Quote Link to comment Share on other sites More sharing options...
BillyBoB Posted August 2, 2006 Share Posted August 2, 2006 um i dont really get your question but are u trying to ban ips from ur whole site if so are you using php and mysql (you dont need mysql but php) ? Quote Link to comment Share on other sites More sharing options...
shoaibi Posted August 2, 2006 Author Share Posted August 2, 2006 [quote author=BillyBoB link=topic=102679.msg407857#msg407857 date=1154500746]um i dont really get your question but are u trying to ban ips from ur whole site if so are you using php and mysql (you dont need mysql but php) ?[/quote]I want to ban all ips from my whole site except then a few countries specified.... Quote Link to comment Share on other sites More sharing options...
BillyBoB Posted August 2, 2006 Share Posted August 2, 2006 can i ask why you want to ban all people except for a few countries i dont really know how to ban all except a few tho Quote Link to comment Share on other sites More sharing options...
shoaibi Posted August 2, 2006 Author Share Posted August 2, 2006 [quote author=BillyBoB link=topic=102679.msg407862#msg407862 date=1154500944]can i ask why you want to ban all people except for a few countries i dont really know how to ban all except a few tho[/quote]Well nothing much, except that its a site meant only for those people. and then also i wanna save bandwidth. think of it as a download site which it actually is, but thought the material posted is neither copyrighted nor offensive, but its just meant for the people of those countries, i.e. those who support me, Quote Link to comment Share on other sites More sharing options...
manmadareddy Posted August 2, 2006 Share Posted August 2, 2006 I hope these two sites will be helpful.http://www.maxmind.com orhttp://www.geobytes.com which contains IP to geo lookup Quote Link to comment Share on other sites More sharing options...
Guest ryen Posted August 2, 2006 Share Posted August 2, 2006 HERE:http://www.phptutorial.info/iptocountry/identification_of_specific_countries.html Quote Link to comment Share on other sites More sharing options...
shoaibi Posted August 2, 2006 Author Share Posted August 2, 2006 Thanks manmadareddy and ryen though ryen seemed to be more accurate ;) See you all later when i will have problem regarding these ;) Quote Link to comment Share on other sites More sharing options...
shoaibi Posted August 2, 2006 Author Share Posted August 2, 2006 [quote author=ryen link=topic=102679.msg407869#msg407869 date=1154501246]HERE:http://www.phptutorial.info/iptocountry/identification_of_specific_countries.html[/quote][color=red][size=10pt][size=10pt][size=10pt][size=10pt][size=10pt][size=10pt][u][b]NOTE: Sorry got the answer!!!!!![/b][/u][/size][/size][/size][/size][/size][/size][/color]and that's for to respond in a certain why, suppose that i want to repond to US only and Display a meesage showing that your ip is not allowed to visit then i would have to download the US database as well as others?Or i can downlaod US one and then set a if else check? Quote Link to comment Share on other sites More sharing options...
BillyBoB Posted August 2, 2006 Share Posted August 2, 2006 say u wanted only usa to be allowedthen dl usa database import it and then code a page like [code] <?function iptocountry($ip) { $numbers = preg_split( "/\./", $ip); include("ip_database.php"); $code=($numbers[0] * 16777216) + ($numbers[1] * 65536) + ($numbers[2] * 256) + ($numbers[3]); foreach($ranges as $key => $value){ if($key<=$code){ if($ranges[$key][0]>=$code){$two_letter_country_code=$ranges[$key][1];break;} } } if ($two_letter_country_code==""){$two_letter_country_code="unkown";} return $two_letter_country_code;}$IPaddress=$_SERVER['REMOTE_ADDR'];$two_letter_country_code=iptocountry($IPaddress);if ($two_letter_country_code=="US"){ echo("Access granted"); }else{ echo("Access Denied"); die(); }?>[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.