27require
'../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeoip.class.php';
38$langs->loadLangs(array(
"admin",
"errors"));
40$action =
GETPOST(
'action',
'aZ09');
47if ($action ==
'set') {
50 $gimcdf =
GETPOST(
"GEOIPMAXMIND_COUNTRY_DATAFILE");
52 if (!$error && $gimcdf && !preg_match(
'/\.(dat|mmdb)$/', $gimcdf)) {
53 setEventMessages($langs->trans(
"ErrorFileMustHaveFormat",
'.dat|.mmdb'),
null,
'errors');
62 $res2 =
dolibarr_set_const($db,
"GEOIPMAXMIND_COUNTRY_DATAFILE", $gimcdf,
'chaine', 0,
'', $conf->entity);
74if (!isset($conf->global->GEOIP_VERSION)) {
75 $conf->global->GEOIP_VERSION =
'2';
85llxHeader(
'',
'',
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-geoipmaxmind');
87$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
88print
load_fiche_titre($langs->trans(
"GeoIPMaxmindSetup"), $linkback,
'title_setup');
94 $geoip =
new DolGeoIP(
'country', $conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE);
98print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
99print
'<input type="hidden" name="token" value="'.newToken().
'">';
100print
'<input type="hidden" name="action" value="set">';
102print
'<table class="noborder centpercent">';
103print
'<tr class="liste_titre">';
104print
'<td>'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td>';
105print
'<td class="right"><input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'"></td>';
109print
'<tr class="oddeven"><td>'.$langs->trans(
"GeoIPLibVersion").
'</td>';
111$arrayofvalues = array(
'php' =>
'Native PHP functions',
'1' =>
'Embedded GeoIP v1',
'2' =>
'Embedded GeoIP v2');
112print $form->selectarray(
'geoipversion', $arrayofvalues, (isset($conf->global->GEOIP_VERSION) ? $conf->global->GEOIP_VERSION :
'2'));
115 $version = $geoip->getVersion();
118 print
'<br>'.$langs->trans(
"Version").
': '.$version;
128print
'<tr class="oddeven"><td>'.$langs->trans(
"PathToGeoIPMaxmindCountryDataFile").
'</td>';
131 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>';
133print
'<input type="text" class="minwidth200" name="GEOIPMAXMIND_COUNTRY_DATAFILE" value="'.dol_escape_htmltag(
getDolGlobalString(
'GEOIPMAXMIND_COUNTRY_DATAFILE')).
'">';
134if (!file_exists($gimcdf)) {
135 print
'<div class="error">'.$langs->trans(
"ErrorFileNotFound", $gimcdf).
'</div>';
138print
'<span class="opacitymedium">';
139print $langs->trans(
"Example").
'<br>';
140print
'/usr/local/share/GeoIP/GeoIP.dat<br>
141/usr/share/GeoIP/GeoIP.dat<br>
142/usr/share/GeoIP/GeoLite2-Country.mmdb';
152print $langs->trans(
"NoteOnPathLocation").
'<br>';
154$url1 =
'http://www.maxmind.com/en/city?rId=awstats';
155$textoshow = $langs->trans(
"YouCanDownloadFreeDatFileTo",
'{s1}');
156$textoshow = str_replace(
'{s1}',
'<a href="'.$url1.
'" target="_blank" rel="noopener noreferrer external">'.$url1.
'</a>', $textoshow);
161$url2 =
'http://www.maxmind.com/en/city?rId=awstats';
162$textoshow = $langs->trans(
"YouCanDownloadAdvancedDatFileTo",
'{s1}');
163$textoshow = str_replace(
'{s1}',
'<a href="'.$url2.
'" target="_blank" rel="noopener noreferrer external">'.$url2.
'</a>', $textoshow);
167 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
168 print
'<input type="hidden" name="token" value="'.newToken().
'">';
173 print
'<br><span class="opacitymedium">'.$langs->trans(
"TestGeoIPResult", $ip).
':</span>';
175 print
'<br>'.$ip.
' -> ';
180 print $langs->trans(
"Error");
183 $ip =
'2a01:e0a:7e:4a60:429a:23ff:f7b8:dc8a';
184 print
'<br>'.$ip.
' -> ';
189 print $langs->trans(
"Error");
205 print
'<br>'.$ip.
' -> ';
210 print $langs->trans(
"Error");
213 print
'<br>'.$ip.
' -> ';
218 print $langs->trans(
"NotAPublicIp");
223 print
'<br><input type="text class="width100" name="iptotest" id="iptotest" placeholder="'.dol_escape_htmltag($langs->trans(
"EnterAnIP")).
'" value="'.$ip.
'">';
224 print
'<input type="submit" class="width40 button small smallpaddingimp" value=" -> ">';
230 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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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.
getDolGlobalString($key, $default='')
Return a 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.