code bane ip อย่างง่าย

ตอบกระทู้

รูปแสดงอารมณ์
:icon_plusone: :like: :plusone: :gfb: :-D :) :( :-o 8O :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: :angry: :baa: :biggrin:
รูปแสดงอารมณ์อื่นๆ

BBCode เปิด
[img] เปิด
[url] เปิด
[Smile icon] เปิด

กระทู้แนะนำ
   

มุมมองที่ขยายได้ กระทู้แนะนำ: code bane ip อย่างง่าย

Re: code bane ip อย่างง่าย

โดย konseo » 15/02/2011 2:06 am

imsn เขียน:อย่างง่ายจริงๆ ด้วยครับ แล้วมันใช้งานได้ดีเปล่าน่ะ
ต้องลองดูอะครับ เว็บผมเซ็งพวกฝรั่งมาspamมาก

Re: code bane ip อย่างง่าย

โดย imsn » 15/02/2011 1:15 am

อย่างง่ายจริงๆ ด้วยครับ แล้วมันใช้งานได้ดีเปล่าน่ะ

code bane ip อย่างง่าย

โดย konseo » 14/02/2011 1:25 pm

โค้ด: เลือกทั้งหมด

<?php
if (getenv(REMOTE_ADDR)=="127.0.0.1")
{
    echo "<script>window.location='http://www.sex.com ';</script>";
    exit;
}
?>
หรือแบนทั้งประเทศ
โหลด geoip.inc and geoip.dat
geoip.inc > http://geolite.maxmind.com/download/geoip/api/php/
geoip.dat > MaxMind - GeoLite Country | Open Source IP Address to Country Database
http://www.maxmind.com/app/geoip_country

โค้ด: เลือกทั้งหมด

<?php

include('geoip.inc'); //this file must exist in your directory

$gi = geoip_open('/your/path/to/GeoIP.dat',GEOIP_STANDARD);

// get the ip of the visitor
$addr = getenv('REMOTE_ADDR');
// translate his ip to a country code
$country = geoip_country_code_by_addr($gi, $addr);
// close the geo database
geoip_close($gi);

$badcountry = array('CN','TR');

// redirect them if they suck
if(in_array($country, $badcountry))
header('Location: http://www.SOMEDOMAIN.com '); //enter a url or page on your site

?> 

ข้างบน