28require
'../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeoip.class.php';
47$langs->loadLangs(array(
"admin",
"errors"));
49$action =
GETPOST(
'action',
'aZ09');
56if ($action ==
'set') {
59 $gimcdf =
GETPOST(
"GEOIPMAXMIND_COUNTRY_DATAFILE");
61 if (!$error && $gimcdf && !preg_match(
'/\.(dat|mmdb)$/', $gimcdf)) {
62 setEventMessages($langs->trans(
"ErrorFileMustHaveFormat",
'.dat|.mmdb'),
null,
'errors');
83if (!isset(
$conf->global->GEOIP_VERSION)) {
84 $conf->global->GEOIP_VERSION =
'2';
94llxHeader(
'',
'',
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-geoipmaxmind');
96$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
97print
load_fiche_titre($langs->trans(
"GeoIPMaxmindSetup"), $linkback,
'title_setup');
103 $geoip =
new DolGeoIP(
'country',
$conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE);
107print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
108print
'<input type="hidden" name="token" value="'.newToken().
'">';
109print
'<input type="hidden" name="action" value="set">';
111print
'<table class="noborder centpercent">';
112print
'<tr class="liste_titre">';
113print
'<td>'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td>';
114print
'<td class="right"><input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'"></td>';
118print
'<tr class="oddeven"><td>'.$langs->trans(
"GeoIPLibVersion").
'</td>';
120$arrayofvalues = array(
'php' =>
'Native PHP functions',
'1' =>
'Embedded GeoIP v1',
'2' =>
'Embedded GeoIP v2');
121print $form->selectarray(
'geoipversion', $arrayofvalues, (isset(
$conf->global->GEOIP_VERSION) ?
$conf->global->GEOIP_VERSION :
'2'));
124 $version = $geoip->getVersion();
127 print
'<br>'.$langs->trans(
"Version").
': '.$version;
137print
'<tr class="oddeven"><td>'.$langs->trans(
"PathToGeoIPMaxmindCountryDataFile").
'</td>';
140 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>';
142print
'<input type="text" class="minwidth200" name="GEOIPMAXMIND_COUNTRY_DATAFILE" value="'.dol_escape_htmltag(
getDolGlobalString(
'GEOIPMAXMIND_COUNTRY_DATAFILE')).
'">';
143if (!file_exists($gimcdf)) {
144 print
'<div class="error">'.$langs->trans(
"ErrorFileNotFound", $gimcdf).
'</div>';
147print
'<span class="opacitymedium">';
148print $langs->trans(
"Example").
'<br>';
149print
'/usr/local/share/GeoIP/GeoIP.dat<br>
150/usr/share/GeoIP/GeoIP.dat<br>
151/usr/share/GeoIP/GeoLite2-Country.mmdb';
161print $langs->trans(
"NoteOnPathLocation").
'<br>';
163$url1 =
'http://www.maxmind.com/en/city?rId=awstats';
164$textoshow = $langs->trans(
"YouCanDownloadFreeDatFileTo",
'{s1}');
165$textoshow = str_replace(
'{s1}',
'<a href="'.$url1.
'" target="_blank" rel="noopener noreferrer external">'.$url1.
'</a>', $textoshow);
170$url2 =
'http://www.maxmind.com/en/city?rId=awstats';
171$textoshow = $langs->trans(
"YouCanDownloadAdvancedDatFileTo",
'{s1}');
172$textoshow = str_replace(
'{s1}',
'<a href="'.$url2.
'" target="_blank" rel="noopener noreferrer external">'.$url2.
'</a>', $textoshow);
176 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
177 print
'<input type="hidden" name="token" value="'.newToken().
'">';
182 print
'<br><span class="opacitymedium">'.$langs->trans(
"TestGeoIPResult", $ip).
':</span>';
184 print
'<br>'.$ip.
' -> ';
189 print $langs->trans(
"Error");
192 $ip =
'2a01:e0a:7e:4a60:429a:23ff:f7b8:dc8a';
193 print
'<br>'.$ip.
' -> ';
198 print $langs->trans(
"Error");
214 print
'<br>'.$ip.
' -> ';
219 print $langs->trans(
"Error");
222 print
'<br>'.$ip.
' -> ';
227 print $langs->trans(
"NotAPublicIp");
232 print
'<br><input type="text class="width100" name="iptotest" id="iptotest" placeholder="'.dol_escape_htmltag($langs->trans(
"EnterAnIP")).
'" value="'.$ip.
'">';
233 print
'<input type="submit" class="width40 button small smallpaddingimp" value=" -> ">';
239 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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.