Cara Mudah Deteksi IP Sebuah Negara Dengan PHP

06.41


Cara Mudah Deteksi IP Sebuah Negara Dengan PHP


lifewire.com



TulisOne - Bagi kalian yang sedang cari tutorial mendeteksi ip sebuah negara lebih tepatnya mendeteksi negara dengan menggunakan sebuah ip.


Pada tutorial yang akan saya bawakan ini, saya menggunakan JSON API dari FREEGEOIP.NET. Baiklah, tanpa basa-basi lagi silahkan kalian ikuti step by step tutorialnya.



  1. Pertama, buatlah file dengan ekstensi .php misalnya detect_ip.php

  2. Kemudian, salin source code berikut kedalam file php yang telah kalian buat





    <?php

    /**

    * Name : ITTF ( Ip Tracking Tools Free )

    * Author : Afid Arifin

    * Version : v1.0

    * Created On : 15 June 2017

    */



    //About This Script



    /*

    This a free script for tracking a ip. Example you know a ip 212.33.76.158 will be display country of Poland. This script usage json of freegeoip.net.

    So, it’s so beautifull for you tools and this free script.

    You freedom to modify and redistributed this script for more people.

    Attention! you dont have sell this script cause this script giving you as for free so, support me !.

    Happy day!

    */







    //HTML Code

    echo '<?xml version="1.0" encoding="UTF-8" ?>';

    echo '<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN"

    "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">';

    echo '<html xmlns="http://www.w3.org/1999/xhtml">';

    echo '<head>

    <title>IP Tracking Tools Free</title>';



    //Meta Name

    echo '<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>

    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>

    <meta content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0" name="viewport"/>';

    echo '</head>';

    echo '<html>';

    echo '<body>';



    //If No Submit Value

    if(empty($_POST['ip'])) {

    echo '<center style="color:red">A Value Is Required!</center>';

    }



    //Start Of Html Page



    echo '<div style="text-align:center;background:#fff;padding:2px;margin:0px;color:maroon;"><form method="POST" action="index.php">

    <b style="font-family:serif;">Insert Valid IP (Ex. '.$_SERVER['REMOTE_ADDR'].')

    </b>

    <br/>

    <input style="border-radius:6px;background:#D8CACA;color:#fff;text-align:center;padding:2px;margin:2px;font-family:serif;" name="ip" type="text" value="" placeholder="'.$_POST['ip'].'"/>

    <input style="border-radius:6px;background:#753C3C;color:#fff;font-family:serif;padding:2px;margin:2px;" name="submit" type="submit" value="Track!"/>

    </form>

    </div>

    <span style="padding:2px;margin:0px;color:maroon;font-family:serif;"><marquee scrollamount="2" scrolldelay="2" direct="left">This tools for tracking a ip. If no insert a ip now, This tools will display your ip now!</marquee></span>

    <br/>';



    //End Of Html Page



    if(isset($_POST['submit'])) {

    if(isset($_POST['ip'])) {

    $fgi = 'http://freegeoip.net/json/'.$_POST['ip'].'';

    $load_ip = file_get_contents($fgi);

    $result = json_decode($load_ip);



    //For Result

    $ip = $result->ip; //ip

    $country_name = $result->country_name; //name of country

    $country_code = $result->country_code; //code of country

    $city = $result->city; //city

    $region_name = $result->region_name; //name of region

    $region_code = $result->region_code; //code of region

    $zipCode = $result->zip_code; //code of zip postal

    $lt = $result->latitude; //latitude

    $_lt = $result->longitude; //longitude

    $mtc = $result->metro_code; //code of metro

    $arc = $result->area_code; //code of area



    //Start Of Table Info

    echo '<center>

    <table border="1">

    <tr>

    <td colspan="3" align="center" style="background:#bbb;color:000;"><b>Statistic</b></td>

    </tr>

    <tr>

    <td width="30%" align="left"><b>IP</b></td>

    <td align="center">:</td>

    <td width="30%" align="left">'.$ip.'</td>

    </tr>

    <tr>

    <td width="30%" align="left"><b>Country</b></td>

    <td align="center">:</td>

    <td width="30%" align="left">'.$country_name.'</td>

    </tr>

    <tr>

    <td width="30%" align="left"><b>Country Code</b></td>

    <td align="center">:</td>

    <td width="30%" align="left">'.$country_code.'</td>

    </tr>

    <tr>

    <td width="30%" align="left"><b>Official Flag</b></td>

    <td align="center">:</td>

    <td width="30%" align="left"><img src="images/'.strtolower($result->country_code).'.png"/></td>

    </tr>

    <tr>

    <td width="30%" align="left"><b>Region</b></td>

    <td align="center">:</td>

    <td width="30%" align="left">'.$region_name.'</td>

    </tr>

    <tr>

    <td width="30%" align="left"><b>Region Code</b></td>

    <td align="center">:</td>

    <td width="30%" align="left">'.$region_code.'</td>

    </tr>

    <tr>

    <td width="30%" align="left"><b>City</b></td>

    <td align="center">:</td>

    <td width="30%" align="left">'.$city.'</td>

    </tr>

    <tr>

    <td width="30%" align="left"><b>Postal Code</b></td>

    <td align="center">:</td>

    <td width="30%" align="left">'.$zipCode.'</td>

    </tr>

    <tr>

    <td width="30%" align="left"><b>Latitude</b></td>

    <td align="center">:</td>

    <td width="30%" align="left">'.$lt.'</td>

    </tr>

    <tr>

    <td width="30%" align="left"><b>Longitude</b></td>

    <td align="center">:</td>

    <td width="30%" align="left">'.$_lt.'</td>

    </tr>

    <tr>

    <td width="30%" align="left"><b>Metro Code</b></td>

    <td align="center">:</td>

    <td width="30%" align="left">'.$mtc.'</td>

    </tr>

    <tr>

    <td width="30%" align="left"><b>Area Code</b></td>

    <td align="center">:</td>

    <td width="30%" align="left">'.$arc.'</td>

    </tr>

    </table>

    </center>';



    //End Of Table Info

    }

    }



    echo '</body>';

    echo '</html>';

    ?>




  3. Lalu, kemudian jalan file detect_ip.php yang telah kalian buat.




Bagaimana sob, mudahkan? untuk demonya bisa kalian b

Aplikasi Untuk Download Film , Video, Music, Anime, Game, Apps, Terlengkap

Cara Mudah Deteksi IP Sebuah Negara Dengan PHP | Siswa Master | 5

Artikel Lainnya

Previous
Next Post »
Blogger
Pilih Sistem Komentar Yang Anda Sukai

Posting Komentar

Ayo budayakan komentar setelah membaca artikel ! (Jangan SPAM ya)