26require
'../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeoip.class.php';
37$langs->loadLangs(array(
"admin",
"errors"));
39$action =
GETPOST(
'action',
'aZ09');
46if ($action ==
'set') {
49 $gimcdf =
GETPOST(
"GEOIPMAXMIND_COUNTRY_DATAFILE");
51 if (!$error && $gimcdf && !preg_match(
'/\.(dat|mmdb)$/', $gimcdf)) {
52 setEventMessages($langs->trans(
"ErrorFileMustHaveFormat",
'.dat|.mmdb'),
null,
'errors');
61 $res2 =
dolibarr_set_const($db,
"GEOIPMAXMIND_COUNTRY_DATAFILE", $gimcdf,
'chaine', 0,
'', $conf->entity);
73if (!isset($conf->global->GEOIP_VERSION)) {
74 $conf->global->GEOIP_VERSION =
'2';
84llxHeader(
'',
'',
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-geoipmaxmind');
86$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
87print
load_fiche_titre($langs->trans(
"GeoIPMaxmindSetup"), $linkback,
'title_setup');
93 $geoip =
new DolGeoIP(
'country', $conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE);
97print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
98print
'<input type="hidden" name="token" value="'.newToken().
'">';
99print
'<input type="hidden" name="action" value="set">';
101print
'<table class="noborder centpercent">';
102print
'<tr class="liste_titre">';
103print
'<td>'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td>';
104print
'<td class="right"><input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'"></td>';
108print
'<tr class="oddeven"><td>'.$langs->trans(
"GeoIPLibVersion").
'</td>';
110$arrayofvalues = array(
'php' =>
'Native PHP functions',
'1' =>
'Embedded GeoIP v1',
'2' =>
'Embedded GeoIP v2');
111print $form->selectarray(
'geoipversion', $arrayofvalues, (isset($conf->global->GEOIP_VERSION) ? $conf->global->GEOIP_VERSION :
'2'));
114 $version = $geoip->getVersion();
117 print
'<br>'.$langs->trans(
"Version").
': '.$version;
127print
'<tr class="oddeven"><td>'.$langs->trans(
"PathToGeoIPMaxmindCountryDataFile").
'</td>';
130 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>';
132print
'<input type="text" class="minwidth200" name="GEOIPMAXMIND_COUNTRY_DATAFILE" value="'.dol_escape_htmltag(
getDolGlobalString(
'GEOIPMAXMIND_COUNTRY_DATAFILE')).
'">';
133if (!file_exists($gimcdf)) {
134 print
'<div class="error">'.$langs->trans(
"ErrorFileNotFound", $gimcdf).
'</div>';
137print
'<span class="opacitymedium">';
138print $langs->trans(
"Example").
'<br>';
139print
'/usr/local/share/GeoIP/GeoIP.dat<br>
140/usr/share/GeoIP/GeoIP.dat<br>
141/usr/share/GeoIP/GeoLite2-Country.mmdb';
151print $langs->trans(
"NoteOnPathLocation").
'<br>';
153$url1 =
'http://www.maxmind.com/en/city?rId=awstats';
154$textoshow = $langs->trans(
"YouCanDownloadFreeDatFileTo",
'{s1}');
155$textoshow = str_replace(
'{s1}',
'<a href="'.$url1.
'" target="_blank" rel="noopener noreferrer external">'.$url1.
'</a>', $textoshow);
160$url2 =
'http://www.maxmind.com/en/city?rId=awstats';
161$textoshow = $langs->trans(
"YouCanDownloadAdvancedDatFileTo",
'{s1}');
162$textoshow = str_replace(
'{s1}',
'<a href="'.$url2.
'" target="_blank" rel="noopener noreferrer external">'.$url2.
'</a>', $textoshow);
166 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
167 print
'<input type="hidden" name="token" value="'.newToken().
'">';
170 print
'<br><span class="opacitymedium">'.$langs->trans(
"TestGeoIPResult", $ip).
':</span>';
173 print
'<br>'.$ip.
' -> ';
178 print $langs->trans(
"Error");
181 $ip =
'2a01:e0a:7e:4a60:429a:23ff:f7b8:dc8a';
182 print
'<br>'.$ip.
' -> ';
187 print $langs->trans(
"Error");
203 print
'<br>'.$ip.
' -> ';
208 print $langs->trans(
"Error");
211 print
'<br>'.$ip.
' -> ';
216 print $langs->trans(
"NotAPublicIp");
221 print
'<br><input type="text class="width100" name="iptotest" id="iptotest" placeholder="'.dol_escape_htmltag($langs->trans(
"EnterAnIP")).
'" value="'.$ip.
'">';
222 print
'<input type="submit" class="width40 button small smallpaddingimp" value=" -> ">';
228 print $langs->trans(
"Error");
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).
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage GeoIP conversion Usage: $geoip=new GeoIP('country',$datfile); $geoip->getCountryCodeF...
is_ip($ip)
This function evaluates a string that should be a valid IPv4 Note: For ip 169.254....
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_print_ip($ip, $mode=0)
Return an IP formatted to be shown on screen.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
getUserRemoteIP()
Return the IP of remote user.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.