自动检测货币PHP / Javascript [关闭]

I have a payment form, and I would like to add a library or something that will detect the region of the user through their IP most likely and automatically choose their respective currency and echo it.

I have tried to find a library like that, but most modules where for platforms like opencart etc, I want something to add it to my custom coded website.

Thanks in advance.

You can done it with the help of geoplugin. An example here

function getIP()
{
    if (isset($_SERVER["HTTP_CLIENT_IP"])){return $_SERVER["HTTP_CLIENT_IP"];}
    elseif (isset($_SERVER["HTTP_X_FORWARDED_FOR"])){return $_SERVER["HTTP_X_FORWARDED_FOR"];}
    elseif (isset($_SERVER["HTTP_X_FORWARDED"])){return $_SERVER["HTTP_X_FORWARDED"];}
    elseif (isset($_SERVER["HTTP_FORWARDED_FOR"])){return $_SERVER["HTTP_FORWARDED_FOR"];}
    elseif (isset($_SERVER["HTTP_FORWARDED"])){return $_SERVER["HTTP_FORWARDED"];}
    else{return $_SERVER["REMOTE_ADDR"];}
}

$ip_addr = getIP();
$geoplugin = unserialize( file_get_contents('http://www.geoplugin.net/php.gp?ip='.$ip_addr) );
if ( is_array($geoplugin) and isset($geoplugin['geoplugin_currencySymbol'])) {
    echo $geoplugin['geoplugin_currencySymbol'];
}