Go to the documentation of this file.
25 require
'../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
27 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeoip.class.php';
36 $langs->loadLangs(array(
"admin",
"errors"));
38 $action =
GETPOST(
'action',
'aZ09');
45 if ($action ==
'set') {
48 $gimcdf =
GETPOST(
"GEOIPMAXMIND_COUNTRY_DATAFILE");
50 if (!$error && $gimcdf && !preg_match(
'/\.(dat|mmdb)$/', $gimcdf)) {
51 setEventMessages($langs->trans(
"ErrorFileMustHaveFormat",
'.dat|.mmdb'),
null,
'errors');
55 if (!$error && $gimcdf && !file_exists($gimcdf)) {
56 setEventMessages($langs->trans(
"ErrorFileNotFound", $gimcdf),
null,
'errors');
66 $res2 =
dolibarr_set_const($db,
"GEOIPMAXMIND_COUNTRY_DATAFILE", $gimcdf,
'chaine', 0,
'', $conf->entity);
79 if (!isset($conf->global->GEOIP_VERSION)) {
80 $conf->global->GEOIP_VERSION =
'2';
92 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
93 print
load_fiche_titre($langs->trans(
"GeoIPMaxmindSetup"), $linkback,
'title_setup');
98 if (!empty($conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE)) {
99 $geoip =
new DolGeoIP(
'country', $conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE);
103 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
104 print
'<input type="hidden" name="token" value="'.newToken().
'">';
105 print
'<input type="hidden" name="action" value="set">';
107 print
'<table class="noborder centpercent">';
108 print
'<tr class="liste_titre">';
109 print
'<td>'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td>';
110 print
'<td class="right"><input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'"></td>';
114 print
'<tr class="oddeven"><td width="50%">'.$langs->trans(
"GeoIPLibVersion").
'</td>';
115 print
'<td colspan="2">';
116 $arrayofvalues = array(
'php' =>
'Native PHP functions',
'1' =>
'Embedded GeoIP v1',
'2' =>
'Embedded GeoIP v2');
117 print
$form->selectarray(
'geoipversion', $arrayofvalues, (isset($conf->global->GEOIP_VERSION) ? $conf->global->GEOIP_VERSION :
'2'));
118 if ($conf->global->GEOIP_VERSION ==
'php') {
120 $version = $geoip->getVersion();
123 print
'<br>'.$langs->trans(
"Version").
': '.$version;
129 print
'<tr class="oddeven"><td>'.$langs->trans(
"PathToGeoIPMaxmindCountryDataFile").
'</td>';
130 print
'<td colspan="2">';
132 if ($conf->global->GEOIP_VERSION ==
'php') {
133 print
'Using geoip PHP internal functions. Value must be '.geoip_db_filename(GEOIP_COUNTRY_EDITION).
' or '.geoip_db_filename(GEOIP_CITY_EDITION_REV1).
' or /pathtodatafile/GeoLite2-Country.mmdb<br>';
135 print
'<input type="text" class="minwidth200" name="GEOIPMAXMIND_COUNTRY_DATAFILE" value="'.dol_escape_htmltag($conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE).
'">';
144 print $langs->trans(
"NoteOnPathLocation").
'<br>';
146 $url1 =
'http://www.maxmind.com/en/city?rId=awstats';
147 print $langs->trans(
"YouCanDownloadFreeDatFileTo",
'<a href="'.$url1.
'" target="_blank" rel="noopener noreferrer external">'.$url1.
'</a>');
151 $url2 =
'http://www.maxmind.com/en/city?rId=awstats';
152 print $langs->trans(
"YouCanDownloadAdvancedDatFileTo",
'<a href="'.$url2.
'" target="_blank" rel="noopener noreferrer external">'.$url2.
'</a>');
156 print
'<br><span class="opacitymedium">'.$langs->trans(
"TestGeoIPResult", $ip).
':</span>';
159 print
'<br>'.$ip.
' -> ';
164 print $langs->trans(
"Error");
167 $ip =
'2a01:e0a:7e:4a60:429a:23ff:f7b8:dc8a';
168 print
'<br>'.$ip.
' -> ';
173 print $langs->trans(
"Error");
189 print
'<br>'.$ip.
' -> ';
194 print $langs->trans(
"Error");
197 print
'<br>'.$ip.
' -> ';
202 print $langs->trans(
"NotAPublicIp");
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Classe to manage GeoIP Usage: $geoip=new GeoIP('country',$datfile); $geoip->getCountryCodeFromIP($ip)...
dol_print_ip($ip, $mode=0)
Return an IP formated to be shown on screen.
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
is_ip($ip)
This function evaluates a string that should be a valid IPv4 Note: For ip 169.254....
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
getUserRemoteIP()
Return the IP of remote user.