setEventMessage($langs->trans("Error"), 'errors');
        }
    }
}
/*
 * View
 */
$form = new Form($db);
llxHeader();
$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">' . $langs->trans("BackToModuleList") . '</a>';
print_fiche_titre($langs->trans("GeoIPMaxmindSetup"), $linkback, 'setup');
print '<br>';
$version = '';
$geoip = '';
if (!empty($conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE)) {
    $geoip = new DolGeoIP('country', $conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE);
    //if ($geoip->error) print dol_htmloutput_errors($geoip->errorlabel,'',1);
    if ($geoip->gi == 'NOGI') {
        $geointernal = true;
    } else {
        $geointernal = false;
    }
} else {
    if (function_exists('geoip_country_code_by_name')) {
        $geointernal = true;
    }
}
// Mode
$var = true;
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
Example #2
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;
}