ip to country

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • ip to country

    Is there any way to update a wap site's ip to country flag to capture most if not all ips to suit the mini country flags? like the most recent files to capture them

  • #2
    http://php.net/manual/en/geoip.setup.php
    PHP Code:
    <?
    $countryName 
    geoip_country_name_by_name($ip);
    $countryCode geoip_country_code_by_name($ip);
    print 
    '<img src="flags/'.$countryCode.'.png" alt="'.$countryName.'"/>';
    ?>
    Last edited by something else; 04.07.18, 11:18.

    Comment


    • #3
      I'm a bit confused bro. Is that code all i need to add? if so where? and what about the linked you provided where i can do the download?

      Comment


      • #4
        I have a code already, but the problem is it does not identify a flag for certain IPs. This is my code

        function iptocountry($ip) {

        $numbers = preg_split( "/\./", $ip);

        include("ip_files/".$numbers[0].".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="unknown";}

        return $two_letter_country_code;

        }

        Comment


        • #5
          Easier way:
          PHP Code:
          <?php
              $ip 
          $_SERVER['REMOTE_ADDR'];
              
          $geo unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip='.$ip));
              
          $city $geo['geoplugin_city'];
              
          $region $geo['geoplugin_region'];
              
          $country $geo['geoplugin_countryName'];
              echo 
          'City: '.$city.', Region: '.$region.', Country: '.$country.'<br/>';
              
          /*
                  geoplugin_request
                  geoplugin_status
                  geoplugin_credit
                  geoplugin_city
                  geoplugin_region
                  geoplugin_areaCode
                  geoplugin_dmaCode
                  geoplugin_countryCode
                  geoplugin_countryName
                  geoplugin_continentCode
                  geoplugin_latitude
                  geoplugin_longitude
                  geoplugin_regionName
                  geoplugin_currencyCode
                  geoplugin_currencySymbol
                  geoplugin_currencySymbol_UTF8
                  geoplugin_currencyConverter

              */
          ?>
          Last edited by something else; 06.07.18, 11:26.

          Comment


          • #6
            ok something else, thank you. So is that all i need the add? just replace my code with this one and it should work perfect, right?

            Comment


            • #7
              With your function it would be:
              PHP Code:
              function iptocountry($ip)
              {
                  
              $geo unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip='.$ip));
                  return 
              $geo['geoplugin_countryCode'];

              Last edited by something else; 08.07.18, 10:56.

              Comment


              • #8
                Ok, thanks alot bro! Is there anyway to increase the regular 512 or 1024 kb upload limit in class.upload file? I've tried everything, I've even tried to change it to 2000kb or 2048 kb at it still doesn't show images uploaded that's larger than 1024 kb. something else
                Last edited by tupac; 19.07.18, 02:43.

                Comment

                Working...
                X