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

    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


                  #9
                  I'm not to sure what the question/problem is but at a guess I would say either you are hitting your allowed upload limit on your server, which can be changed via:
                  .htaccess
                  Code:
                  php_value memory_limit 30M
                  php_value upload_max_filesize 30M
                  php_value post_max_size 100M
                  or
                  php.ini
                  Code:
                  memory_limit  = 30M
                  upload_max_filesize = 30M
                  post_max_size = 100M
                  However I think that you may also be using GD Library in your class.upload file?
                  In which case you are probably running out of memory (See above how to increase memory imit)

                  However that being said some hosts don't allow the above to be altered.

                  If you find that you can't adjust the above and you are working with GD Library then you may want to look at imageMagick as an alternative as this does not count against your memory limit.

                  To view your limits make a script with the following code in:
                  randomName.php
                  PHP Code:
                  <?php
                  phpinfo
                  ();
                  ?>
                  (Note: keep this file hidden/deleted after use as it is useful to hackers)
                  Last edited by something else; 10.07.18, 22:57.

                  Comment

                  Working...
                  X