diff --git a/htdocs/admin/geoipmaxmind.php b/htdocs/admin/geoipmaxmind.php index c7373fd02db..8f76f9a7b2b 100644 --- a/htdocs/admin/geoipmaxmind.php +++ b/htdocs/admin/geoipmaxmind.php @@ -53,27 +53,20 @@ if ($action == 'set') { $error++; } - if (!$error && $gimcdf && !file_exists($gimcdf)) { - setEventMessages($langs->trans("ErrorFileNotFound", $gimcdf), null, 'errors'); + $res1 = dolibarr_set_const($db, "GEOIP_VERSION", GETPOST('geoipversion', 'aZ09'), 'chaine', 0, '', $conf->entity); + if (!($res1 > 0)) { + $error++; + } + + $res2 = dolibarr_set_const($db, "GEOIPMAXMIND_COUNTRY_DATAFILE", $gimcdf, 'chaine', 0, '', $conf->entity); + if (!($res2 > 0)) { $error++; } if (!$error) { - $res1 = dolibarr_set_const($db, "GEOIP_VERSION", GETPOST('geoipversion', 'aZ09'), 'chaine', 0, '', $conf->entity); - if (!($res1 > 0)) { - $error++; - } - - $res2 = dolibarr_set_const($db, "GEOIPMAXMIND_COUNTRY_DATAFILE", $gimcdf, 'chaine', 0, '', $conf->entity); - if (!($res2 > 0)) { - $error++; - } - - if (!$error) { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + //setEventMessages($langs->trans("Error"), null, 'errors'); } } @@ -112,8 +105,8 @@ print '\n"; // Lib version -print ''.$langs->trans("GeoIPLibVersion").''; -print ''; +print ''.$langs->trans("GeoIPLibVersion").''; +print ''; $arrayofvalues = array('php' => 'Native PHP functions', '1' => 'Embedded GeoIP v1', '2' => 'Embedded GeoIP v2'); print $form->selectarray('geoipversion', $arrayofvalues, (isset($conf->global->GEOIP_VERSION) ? $conf->global->GEOIP_VERSION : '2')); if ($conf->global->GEOIP_VERSION == 'php') { @@ -124,16 +117,29 @@ if ($conf->global->GEOIP_VERSION == 'php') { print '
'.$langs->trans("Version").': '.$version; } } +print ''; +print ''; print ''; +$gimcdf = getDolGlobalString('GEOIPMAXMIND_COUNTRY_DATAFILE'); + // Path to database file print ''.$langs->trans("PathToGeoIPMaxmindCountryDataFile").''; -print ''; - +print ''; if ($conf->global->GEOIP_VERSION == 'php') { 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
'; } -print ''; +print ''; +if (!file_exists($gimcdf)) { + print '
'.$langs->trans("ErrorFileNotFound", $gimcdf).'
'; +} +print ''; +print ''; +print $langs->trans("Example").'
'; +print '/usr/local/share/GeoIP/GeoIP.dat
+/usr/share/GeoIP/GeoIP.dat
+/usr/share/GeoIP/GeoLite2-Country.mmdb'; +print '
'; print ''; print ''; @@ -145,12 +151,16 @@ print '
'; print $langs->trans("NoteOnPathLocation").'
'; $url1 = 'http://www.maxmind.com/en/city?rId=awstats'; -print $langs->trans("YouCanDownloadFreeDatFileTo", ''.$url1.''); +$textoshow = $langs->trans("YouCanDownloadFreeDatFileTo", '{s1}'); +$textoshow = str_replace('{s1}', ''.$url1.'', $textoshow); +print $textoshow; print '
'; $url2 = 'http://www.maxmind.com/en/city?rId=awstats'; -print $langs->trans("YouCanDownloadAdvancedDatFileTo", ''.$url2.''); +$textoshow = $langs->trans("YouCanDownloadAdvancedDatFileTo", '{s1}'); +$textoshow = str_replace('{s1}', ''.$url2.'', $textoshow); +print $textoshow; if ($geoip) { print '

'; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 2cd9d55aefb..3f12a36283f 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1881,7 +1881,7 @@ SuppliersInvoiceNumberingModel=Vendor invoices numbering models IfSetToYesDontForgetPermission=If set to a non null value, don't forget to provide permissions to groups or users allowed for the second approval ##### GeoIPMaxmind ##### GeoIPMaxmindSetup=GeoIP Maxmind module setup -PathToGeoIPMaxmindCountryDataFile=Path to file containing Maxmind ip to country translation.
Examples:
/usr/local/share/GeoIP/GeoIP.dat
/usr/share/GeoIP/GeoIP.dat
/usr/share/GeoIP/GeoLite2-Country.mmdb +PathToGeoIPMaxmindCountryDataFile=Path to file containing Maxmind ip to country translation NoteOnPathLocation=Note that your ip to country data file must be inside a directory your PHP can read (Check your PHP open_basedir setup and filesystem permissions). YouCanDownloadFreeDatFileTo=You can download a free demo version of the Maxmind GeoIP country file at %s. YouCanDownloadAdvancedDatFileTo=You can also download a more complete version, with updates, of the Maxmind GeoIP country file at %s.