Home

The IP Geolocation Tool

Contents

1. What's it for?

2. PHP sample integration

3. Possible errors

4. Privacy notes

5. License notes

 

1. What's it for?

Currently, we only offer the Country Geolocation of the given IP Address.To do so, you can just try opening the following link: https://mys.onl/iplocate/cclocator.php. You will see the two letter code of the country you are visiting this website from.

You now may want to locate not yourself, but a specific IP Address, so just do this:

https://mys.onl/iplocate/cclocator.php?ip=xxx.xxx.xxx

Note: You must replace the x'es with the IP address that you want to look up.

 

2. PHP sample integration

Now you learned the basics on the country location tool, but may want to implement this into your PHP sites. So we have prepared the following example with a country-based redirect in PHP:

<?php

$countryCode = (serialize(file_get_contents('https://www.mys.onl/iplocate/cclocator.php?ip='.$_SERVER['REMOTE_ADDR'])));

if (strpos($countryCode, 'US') !== false) {
    /* redirects to the given extension ( domain.com/dir -> domain.com/dir/extension ) */
    $host  = $_SERVER['HTTP_HOST'];
    $uri   = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
    $extension = 'en_US';

    header("Refresh: 0; url = http://$host$uri/$extension");
    exit;
}

elseif (strpos($countryCode, 'GB') !== false) {
    $host  = $_SERVER['HTTP_HOST'];
    $uri   = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
    $extension = 'en_UK';
    header("Refresh: 0; url = http://$host$uri/$extension");
    exit;
}

elseif (strpos($countryCode, 'DE') !== false) {
    $host  = $_SERVER['HTTP_HOST'];
    $uri   = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
    $extension = 'de';
    header("Refresh: 0; url = http://$host$uri/$extension");
    exit;
}

else {
    $host  = $_SERVER['HTTP_HOST'];
    $uri   = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
    $extension = 'en';
    header("Refresh: 0; url = http://$host$uri/$extension");
    exit;
}

?>

Note: It actually makes more sense doing the following way, but some webservers seem to have troubles with it.

$countryCode = (unserialize(file_get_contents('http://www.mys.onl/iplocate/cclocator.php?ip='.$_SERVER['REMOTE_ADDR'])));
if ($countryCode == 'US') { ... }

 

3. Possible errors

Depending on the PHP version you use, some functions may vary. However, if the sample does not work properly, you may try editing the code as shown in the note above. At worst, you can try using the insecure HTTP-connection instead of the TLS-encrypted HTTPS-connection.

If the user (site visitor) is using a VPN or Proxy, you may not be able to retrieve the correct location when using the sample code.

Please note that all services come without any warranties and support, but any feedbacks and improvement requests will be welcome, especially if you have encountered a problem and found a solution to that. Please check the terms specified in the main page.

 

4. Privacy notes

Of course the privacy of our users is an important matter to us as well. Unless specified otherwise, we try to not use any third party tools and applications if possible. But in this case, we are retrieving the data on the IP using the geoPlugin for IP Geolocation. Still, your own IP address or server address will not be sent to geoPlugin, but only the IP address that you asked to locate for.

We offer ourselves as some kind of a proxy and ask for the required query in your stead and deliver the results to you. We may log your IP address as well as the connections you established on our network, but those logs will never be shared to any third party and thus stay within our own servers.

We are not keeping logs or collecting any data for targeting our users with customized advertisements or such, nor do we analyze any logs to retrieve personal information on our users. The logs may be used to keep a spam control and IP blocking system to prevent excessive usage and abuse. If you encounter any troubles regarding your privacy using our services or any troubles with our IP blacklisting, please contact us.

 

5. License notes

The service offered here is based on the geoPlugin for IP Geolocation to ensure providing the best IP Geolocation offers possible. So please refer to their license agreements and terms when using this service. Any other content such as the samples above may be used, copied, edited and shared under the license agreement specified in our terms.

 

check our terms and notices. We use cookies on our site.

Powered by the MySnet network