Пример #1
0
/**
 *  Return country code for current user.
 *  If software is used inside a local network, detection may fails (we need a public ip)
 *  @return     string      country code (fr, es, it, us, ...)
 */
function dol_user_country()
{
    global $conf, $langs, $user;
    //$ret=$user->xxx;
    $ret = '';
    if (!empty($conf->geoipmaxmind->enabled)) {
        $ip = $_SERVER["REMOTE_ADDR"];
        $datafile = $conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE;
        //$ip='24.24.24.24';
        //$datafile='E:\Mes Sites\Web\Admin1\awstats\maxmind\GeoIP.dat';
        include_once DOL_DOCUMENT_ROOT . '/lib/dolgeoip.class.php';
        $geoip = new DolGeoIP('country', $datafile);
        $countrycode = $geoip->getCountryCodeFromIP($ip);
        $ret = $countrycode;
    }
    return $ret;
}