ip to country

Started on the old forum in July 2018 · view the original in the archive · old links redirect here

8 replies · 201 views · started 8 years ago · 1 min read

2 participants
tupac Developer · 95 posts #1

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

tupac Developer · 95 posts #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?

tupac Developer · 95 posts #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;

}

something else Fellow · 2,296 posts #5

Easier way:

<?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

    */
?>
tupac Developer · 95 posts #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?

something else Fellow · 2,296 posts #7

With your function it would be:

function iptocountry($ip)
{
    $geo = unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip='.$ip));
    return $geo['geoplugin_countryCode'];
}
tupac Developer · 95 posts #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

something else Fellow · 2,296 posts #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

php_value memory_limit 30M
php_value upload_max_filesize 30M
php_value post_max_size 100M

or php.ini

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
phpinfo();
?>

(Note: keep this file hidden/deleted after use as it is useful to hackers)

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close