Php İle Ülkeye Göre Girişleri Kontrol Etmek

Php ile gelen kullanıcıların hangi ülkeden geldiğini öğrenebiliriz ve onları istediğimiz sayfaya yönlendirebiliriz. Örneğin tr,eng gibi dillerde olan sayfalarımız da varsa onlara da yönlendirebiliriz.

<?php
$IPaddress=$_SERVER['REMOTE_ADDR'];
$two_letter_country_code=iptocountry($IPaddress);
 
if ($two_letter_country_code=="TR"){
     include("bu-sayfa-turkler-icin.html");
      die();
    }else{
     include("bu-sayfa-diger-ulkelerden-insanlar-icin.html");
      die();
    }
 
function iptocountry($ip) {   
    $numbers = preg_split( "/\./", $ip);   
    include("ipadresleri.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;
}
?>

include edilen ipadresleri.php dosyamız.

<?php
$ranges=Array(
"1042087936" => array("1042120703","TR"),
"1044692992" => array("1044701183","TR"),
"1045790720" => array("1045798911","TR"),
"1047281664" => array("1047289855","TR"),
"1047592960" => array("1047601151","TR"),
"1052260864" => array("1052260895","TR"),
"1052291680" => array("1052291687","TR"),
"1052354112" => array("1052354175","TR"),
"1052396800" => array("1052396863","TR"),
"1053409280" => array("1053425663","TR"),
"1055227904" => array("1055231999","TR"),
"1056227328" => array("1056243711","TR"),
"1056440320" => array("1056473087","TR"),
"1074956800" => array("1074957055","TR"),
"1076192832" => array("1076192895","TR"),
"1076193152" => array("1076193183","TR"),
"1076194432" => array("1076194463","TR"),
"1077004336" => array("1077004343","TR"),
"1077005944" => array("1077005951","TR"),
"1077011320" => array("1077011327","TR"),
"1089155012" => array("1089155031","TR"),
"1093052480" => array("1093052511","TR"),
"1097737060" => array("1097737069","TR"),
"1097737286" => array("1097737295","TR"),
"1097737532" => array("1097737541","TR"),
"1097738250" => array("1097738259","TR"),
"1097738300" => array("1097738309","TR"),
"1097738666" => array("1097738675","TR"),
"1097739138" => array("1097739147","TR"),
"1097739570" => array("1097739579","TR"),
"1097743254" => array("1097743263","TR"),
"1097744138" => array("1097744147","TR"),
"1110891151" => array("1110891158","TR"),
"1112519136" => array("1112519167","TR"),
"1113642721" => array("1113642730","TR"),
"1113643996" => array("1113644015","TR"),
"1114579290" => array("1114579299","TR"),
"1114579424" => array("1114579439","TR"),
"1114579646" => array("1114579655","TR"),
"1114581082" => array("1114581091","TR"),
"1114581212" => array("1114581231","TR"),
"1114582066" => array("1114582075","TR"),
"1114586458" => array("1114586467","TR"),
"1115071242" => array("1115071251","TR"),
"1118962944" => array("1118963199","TR"),
"1121478632" => array("1121478639","TR"),
"1122180041" => array("1122180048","TR"),
"1125106208" => array("1125106223","TR"),
"1125110784" => array("1125110911","TR"),
"1125116192" => array("1125116223","TR"),
"1125118560" => array("1125118591","TR"),
"1125119200" => array("1125119231","TR"),
"1158945736" => array("1158945743","TR"),
"1158947832" => array("1158947839","TR"),
"1159643440" => array("1159643455","TR"),
"1208210752" => array("1208210759","TR"),
"1346863104" => array("1346867199","TR"),
"1347891200" => array("1347895295","TR"),
"1347980000" => array("1347980031","TR"),
"1347980736" => array("1347980799","TR"),
"1348325376" => array("1348329471","TR"),
"1358254080" => array("1358254335","TR"),
"1358626816" => array("1358630911","TR"),
"1358635008" => array("1358639103","TR"),
"1359364096" => array("1359380479","TR"),
"1359478784" => array("1359511551","TR"),
"1360371712" => array("1360375807","TR"),
"1360421120" => array("1360424959","TR"),
"1361035744" => array("1361035751","TR"),
"1361036144" => array("1361036151","TR"),
"1361036168" => array("1361036175","TR"),
"1361036460" => array("1361036463","TR"),
"1361036560" => array("1361036567","TR"),
"1361036608" => array("1361036611","TR"),
"1361036672" => array("1361036675","TR"),
"1361036952" => array("1361036959","TR"),
"1361037016" => array("1361037023","TR"),
"1361037128" => array("1361037135","TR"),
"1361037216" => array("1361037223","TR"),
"1361037376" => array("1361037383","TR"),
"1361037388" => array("1361037391","TR"),
"1361037840" => array("1361037847","TR"),
"1361037912" => array("1361037919","TR"),
"1361037968" => array("1361037975","TR"),
"1364946944" => array("1364951039","TR"),
"1372848128" => array("1373110271","TR"),
"1385291776" => array("1385299967","TR"),
"1385660416" => array("1385668607","TR"),
"1390280704" => array("1390346239","TR"),
"1396834304" => array("1396899839","TR"),
"1403400192" => array("1403400207","TR"),
"1403660672" => array("1403660735","TR"),
"1410013696" => array("1410013727","TR"),
"1410027520" => array("1410027647","TR"),
"1410399488" => array("1410399743","TR"),
"1410416640" => array("1410424831","TR"),
"1412169728" => array("1412202495","TR"),
"1412628480" => array("1412641791","TR"),
"1412642816" => array("1412644863","TR"),
"1425967105" => array("1425967120","TR"),
"1426780632" => array("1426780639","TR"),
"1427963904" => array("1427980287","TR"),
"1432353792" => array("1433403391","TR"),
"1433870336" => array("1433872383","TR"),
"1433878528" => array("1433880575","TR"),
"1436090368" => array("1436155903","TR"),
"1436442624" => array("1436444671","TR"),
"1436499968" => array("1436504063","TR"),
"1441480704" => array("1441488895","TR"),
"1449951232" => array("1449983999","TR"),
"1475108864" => array("1475110911","TR"),
"1476067328" => array("1476075519","TR"),
"1486350336" => array("1486352383","TR"),
"1491075072" => array("1493172223","TR"),
"1500119040" => array("1500127231","TR"),
"2343763968" => array("2343829503","TR"),
"2423914496" => array("2423980031","TR"),
"2615083008" => array("2615148543","TR"),
"2689269760" => array("2689335295","TR"),
"2701721600" => array("2701787135","TR"),
"2827681792" => array("2827747327","TR"),
"3225847040" => array("3225847551","TR"),
"3229701888" => array("3229702143","TR"),
"3231716608" => array("3231716863","TR"),
"3238018304" => array("3238018559","TR"),
"3239549952" => array("3239550207","TR"),
"3239672832" => array("3239673343","TR"),
"3240690176" => array("3240690687","TR"),
"3240810496" => array("3240810751","TR"),
"3241864192" => array("3241864447","TR"),
"3245135104" => array("3245135359","TR"),
"3245180416" => array("3245180927","TR"),
"3245255168" => array("3245255679","TR"),
"3245264896" => array("3245266943","TR"),
"3247054336" => array("3247054591","TR"),
"3247177728" => array("3247243263","TR"),
"3247875328" => array("3247875583","TR"),
"3248752896" => array("3248753151","TR"),
"3249723904" => array("3249724159","TR"),
"3250374144" => array("3250374655","TR"),
"3250425344" => array("3250425599","TR"),
"3250610176" => array("3250618367","TR"),
"3251213760" => array("3251213823","TR"),
"3251215616" => array("3251215743","TR"),
"3251245568" => array("3251245823","TR"),
"3251271680" => array("3251271935","TR"),
"3252318464" => array("3252318719","TR"),
"3252340736" => array("3252340991","TR"),
"3252408320" => array("3252408339","TR"),
"3252438016" => array("3252438271","TR"),
"3252636672" => array("3252636927","TR"),
"3253977088" => array("3253985279","TR"),
"3254707200" => array("3254707711","TR"),
"3254713344" => array("3254713855","TR"),
"3254714368" => array("3254779903","TR"),
"3255414272" => array("3255414527","TR"),
"3256410112" => array("3256410623","TR"),
"3256549376" => array("3256614911","TR"),
"3256733696" => array("3256735743","TR"),
"3258078208" => array("3258078463","TR"),
"3258102528" => array("3258102783","TR"),
"3258327040" => array("3258335231","TR"),
"3259354624" => array("3259354879","TR"),
"3262472620" => array("3262472623","TR"),
"3262475856" => array("3262475871","TR"),
"3262476616" => array("3262476619","TR"),
"3262476804" => array("3262476807","TR"),
"3262477864" => array("3262477867","TR"),
"3262478084" => array("3262478084","TR"),
"3262478098" => array("3262478098","TR"),
"3262478100" => array("3262478100","TR"),
"3262478102" => array("3262478102","TR"),
"3262478104" => array("3262478104","TR"),
"3262478107" => array("3262478107","TR"),
"3262478114" => array("3262478114","TR"),
"3262478133" => array("3262478133","TR"),
"3262478135" => array("3262478135","TR"),
"3262478138" => array("3262478138","TR"),
"3262478141" => array("3262478143","TR"),
"3262478153" => array("3262478153","TR"),
"3262478156" => array("3262478156","TR"),
"3262478160" => array("3262478160","TR"),
"3262478166" => array("3262478166","TR"),
"3262478173" => array("3262478174","TR"),
"3262478176" => array("3262478176","TR"),
"3262478179" => array("3262478180","TR"),
"3262478188" => array("3262478188","TR"),
"3262478351" => array("3262478351","TR"),
"3262478450" => array("3262478450","TR"),
"3262478569" => array("3262478569","TR"),
"3262478622" => array("3262478622","TR"),
"3262478662" => array("3262478662","TR"),
"3262478688" => array("3262478688","TR"),
"3262478693" => array("3262478693","TR"),
"3262478760" => array("3262478760","TR"),
"3262478784" => array("3262478785","TR"),
"3262478809" => array("3262478809","TR"),
"3263031296" => array("3263032319","TR"),
"3263096320" => array("3263096575","TR"),
"3263512832" => array("3263513087","TR"),
"3263537152" => array("3263540479","TR"),
"3263540736" => array("3263541247","TR"),
"3263557632" => array("3263558911","TR"),
"3263559680" => array("3263561727","TR"),
"3270647808" => array("3270648063","TR"),
"3272109312" => array("3272109567","TR"),
"3272479488" => array("3272479743","TR"),
"3273768960" => array("3273785343","TR"),
"3274170368" => array("3274170879","TR"),
"3274604544" => array("3274612735","TR"),
"3274823680" => array("3274825727","TR"),
"3275784192" => array("3275792383","TR"),
"3276132352" => array("3276133375","TR"),
"3276414976" => array("3276423167","TR"),
"3276524032" => array("3276524047","TR"),
"3276524064" => array("3276524095","TR"),
"3276524192" => array("3276524279","TR"),
"3276529152" => array("3276529167","TR"),
"3276529176" => array("3276529295","TR"),
"3276529312" => array("3276529407","TR"),
"3276532736" => array("3276532767","TR"),
"3276532776" => array("3276532815","TR"),
"3276532832" => array("3276532839","TR"),
"3276532848" => array("3276532991","TR"),
"3276533248" => array("3276533391","TR"),
"3276785600" => array("3276785607","TR"),
"3276786880" => array("3276786911","TR"),
"3277189632" => array("3277189887","TR"),
"3277192960" => array("3277193215","TR"),
"3277258752" => array("3277324287","TR"),
"3278929920" => array("3278938111","TR"),
"3278938128" => array("3278938131","TR"),
"3278939660" => array("3278939663","TR"),
"3278939700" => array("3278939703","TR"),
"3278939708" => array("3278939711","TR"),
"3278939716" => array("3278939723","TR"),
"3278939728" => array("3278939731","TR"),
"3279055872" => array("3279056383","TR"),
"3279953920" => array("3279955967","TR"),
"3280010752" => array("3280011263","TR"),
"3280592384" => array("3280592895","TR"),
"3280782336" => array("3280783359","TR"),
"3280863232" => array("3280928767","TR"),
"3281343744" => array("3281343999","TR"),
"3281351680" => array("3281351935","TR"),
"3281715200" => array("3281780735","TR"),
"3282960384" => array("3283091455","TR"),
"3283209728" => array("3283210239","TR"),
"3283215872" => array("3283216383","TR"),
"3283491072" => array("3283491327","TR"),
"3283610816" => array("3283610879","TR"),
"3285509632" => array("3285509887","TR"),
"3285513224" => array("3285513231","TR"),
"3285534096" => array("3285534111","TR"),
"3285614592" => array("3285630975","TR"),
"3286905856" => array("3286906111","TR"),
"3286934784" => array("3286935039","TR"),
"3287448064" => array("3287448575","TR"),
"3287556096" => array("3287564287","TR"),
"3287671552" => array("3287671807","TR"),
"3344552448" => array("3344552703","TR"),
"3423532544" => array("3423532799","TR"),
"3454718960" => array("3454718967","TR"),
"3482755508" => array("3482755517","TR"),
"3482755940" => array("3482755949","TR"),
"3482756176" => array("3482756185","TR"),
"3482756758" => array("3482756767","TR"),
"3482757556" => array("3482757565","TR"),
"3482761328" => array("3482761343","TR"),
"3482762361" => array("3482762368","TR"),
"3482762382" => array("3482762445","TR"),
"3486601472" => array("3486601535","TR"),
"3510473088" => array("3510473095","TR"),
"3514335681" => array("3514335688","TR"),
"3516351056" => array("3516351087","TR"),
"3517181096" => array("3517181103","TR"),
"3522121024" => array("3522121039","TR"),
"3556950016" => array("3556958207","TR"),
"3557588992" => array("3557597183","TR"),
"3557752832" => array("3557761023","TR"),
"3558686720" => array("3558703103","TR"),
"3558801408" => array("3558809599","TR"),
"3559735296" => array("3559743487","TR"),
"3559972864" => array("3559981055","TR"),
"3560054784" => array("3560062975","TR"),
"3560505344" => array("3560513535","TR"),
"3560570880" => array("3560579071","TR"),
"3560942248" => array("3560942251","TR"),
"3560942804" => array("3560942807","TR"),
"3560942816" => array("3560942819","TR"),
"3560944640" => array("3560944643","TR"),
"3560944648" => array("3560944651","TR"),
"3560944656" => array("3560944659","TR"),
"3560944668" => array("3560944671","TR"),
"3560944680" => array("3560944687","TR"),
"3560944696" => array("3560944699","TR"),
"3560944708" => array("3560944711","TR"),
"3560944724" => array("3560944727","TR"),
"3560944732" => array("3560944735","TR"),
"3560944748" => array("3560944755","TR"),
"3560944760" => array("3560944767","TR"),
"3560944840" => array("3560944843","TR"),
"3561013248" => array("3561021439","TR"),
"3561062400" => array("3561070591","TR"),
"3561971712" => array("3561976831","TR"),
"3561978368" => array("3561979903","TR"),
"3563192320" => array("3563200511","TR"),
"3563241472" => array("3563257855","TR"),
"3563413504" => array("3563421695","TR"),
"3563880448" => array("3563888639","TR"),
"3563937792" => array("3563945983","TR"),
"3563970560" => array("3563978751","TR"),
"3564306432" => array("3564314623","TR"),
"3564961792" => array("3564969983","TR"),
"3565117440" => array("3565125631","TR"),
"3565518848" => array("3565551615","TR"),
"3566370816" => array("3566403583","TR"),
"3566862336" => array("3566895103","TR"),
"3566993408" => array("3567058943","TR"),
"3568173056" => array("3568304127","TR"),
"3573284864" => array("3573415935","TR"),
"3574464512" => array("3574530047","TR"),
"3575635856" => array("3575635871","TR"),
"3575640064" => array("3575644159","TR"),
"3576365056" => array("3576430591","TR"),
"3577613888" => array("3577613951","TR"),
"3577620672" => array("3577620735","TR"),
"3578396672" => array("3578462207","TR"),
"3582590976" => array("3582599167","TR"),
"3582705664" => array("3582722047","TR"),
"3582976000" => array("3582984191","TR"),
"3583008768" => array("3583016959","TR"),
"3583262720" => array("3583270911","TR"),
"3583606784" => array("3583639551","TR"),
"3583729664" => array("3583737855","TR"),
"3583975424" => array("3583983615","TR"),
"3584131072" => array("3584139263","TR"),
"3585418944" => array("3585419007","TR"),
"3585769472" => array("3585777663","TR"),
"3586277376" => array("3586286591","TR"),
"3586286608" => array("3586293759","TR"),
"3586785280" => array("3586793471","TR"),
"3586932736" => array("3586949119","TR"),
"3587179456" => array("3587179463","TR"),
"3587287440" => array("3587287447","TR"),
"3588751360" => array("3588767743","TR"),
"3589021696" => array("3589029887","TR"),
"3589177344" => array("3589193727","TR"),
"3589472256" => array("3589488639","TR"),
"3589832704" => array("3589849087","TR"),
"3590225920" => array("3590234111","TR"),
"3625376192" => array("3625376223","TR"),
"3632482040" => array("3632482047","TR"),
"3640315392" => array("3640315647","TR"),
"3641806848" => array("3641809663","TR"),
"3641809920" => array("3641810943","TR"),
"3642191456" => array("3642191487","TR"),
"3642744832" => array("3642753023","TR"),
"3644887040" => array("3644891135","TR"),
"3644903424" => array("3644907519","TR"),
"3645113632" => array("3645113639","TR"),
"3645165568" => array("3645169663","TR"),
"3645763953" => array("3645763953","TR"),
"3645764058" => array("3645764058","TR"),
"3645764265" => array("3645764265","TR"),
"3645765312" => array("3645765315","TR"),
"3649241088" => array("3649306623","TR"),
"3651780608" => array("3651784703","TR"),
"3652033920" => array("3652033935","TR"),
"3652033984" => array("3652034015","TR"),
"3652034112" => array("3652034143","TR"),
"3652067328" => array("3652071423","TR"),
"3653404576" => array("3653404591","TR"),
"3653405104" => array("3653405119","TR"),
"3653484544" => array("3653488639","TR"),
);
?>

Hasan Huseyin İŞLER hakkında

Lise yıllarında programlama ile tanışan ve Q-Basic, Pascal, C başlangıç seviyesinde öğrenenir. Üniversite de TEF-BSÖ okurken diğer dillerin yanı sıra PHP'de kendini geliştirmeye devam ederek bunların yanında CSS, JS ve Wordpress sistemiyle ilgilenir. www.phpsorunu.com'un da yöneticisi ve yazarlarındandır.
Bu yazı Php kategorisine gönderilmiş. Kalıcı bağlantıyı yer imlerinize ekleyin.

Bir Cevap Yazın

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir

Şu HTML etiketlerini ve özelliklerini kullanabilirsiniz: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>