Debug v17

This commit is contained in:
Laurent Destailleur 2022-11-19 13:36:52 +01:00
parent 0117e65651
commit 728bcf677e
2 changed files with 35 additions and 25 deletions

View File

@ -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 '<td class="right"><input type="submit" class="button button-edit" value="
print "</tr>\n";
// Lib version
print '<tr class="oddeven"><td width="50%">'.$langs->trans("GeoIPLibVersion").'</td>';
print '<td colspan="2">';
print '<tr class="oddeven"><td>'.$langs->trans("GeoIPLibVersion").'</td>';
print '<td>';
$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 '<br>'.$langs->trans("Version").': '.$version;
}
}
print '</td>';
print '<td>';
print '</td></tr>';
$gimcdf = getDolGlobalString('GEOIPMAXMIND_COUNTRY_DATAFILE');
// Path to database file
print '<tr class="oddeven"><td>'.$langs->trans("PathToGeoIPMaxmindCountryDataFile").'</td>';
print '<td colspan="2">';
print '<td>';
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<br>';
}
print '<input type="text" class="minwidth200" name="GEOIPMAXMIND_COUNTRY_DATAFILE" value="'.dol_escape_htmltag($conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE).'">';
print '<input type="text" class="minwidth200" name="GEOIPMAXMIND_COUNTRY_DATAFILE" value="'.dol_escape_htmltag(getDolGlobalString('GEOIPMAXMIND_COUNTRY_DATAFILE')).'">';
if (!file_exists($gimcdf)) {
print '<div class="error">'.$langs->trans("ErrorFileNotFound", $gimcdf).'</div>';
}
print '</td><td>';
print '<span class="opacitymedium">';
print $langs->trans("Example").'<br>';
print '/usr/local/share/GeoIP/GeoIP.dat<br>
/usr/share/GeoIP/GeoIP.dat<br>
/usr/share/GeoIP/GeoLite2-Country.mmdb';
print '</span>';
print '</td></tr>';
print '</table>';
@ -145,12 +151,16 @@ print '<br>';
print $langs->trans("NoteOnPathLocation").'<br>';
$url1 = 'http://www.maxmind.com/en/city?rId=awstats';
print $langs->trans("YouCanDownloadFreeDatFileTo", '<a href="'.$url1.'" target="_blank" rel="noopener noreferrer external">'.$url1.'</a>');
$textoshow = $langs->trans("YouCanDownloadFreeDatFileTo", '{s1}');
$textoshow = str_replace('{s1}', '<a href="'.$url1.'" target="_blank" rel="noopener noreferrer external">'.$url1.'</a>', $textoshow);
print $textoshow;
print '<br>';
$url2 = 'http://www.maxmind.com/en/city?rId=awstats';
print $langs->trans("YouCanDownloadAdvancedDatFileTo", '<a href="'.$url2.'" target="_blank" rel="noopener noreferrer external">'.$url2.'</a>');
$textoshow = $langs->trans("YouCanDownloadAdvancedDatFileTo", '{s1}');
$textoshow = str_replace('{s1}', '<a href="'.$url2.'" target="_blank" rel="noopener noreferrer external">'.$url2.'</a>', $textoshow);
print $textoshow;
if ($geoip) {
print '<br><br>';

View File

@ -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.<br>Examples:<br>/usr/local/share/GeoIP/GeoIP.dat<br>/usr/share/GeoIP/GeoIP.dat<br>/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 <b>free demo version</b> of the Maxmind GeoIP country file at %s.
YouCanDownloadAdvancedDatFileTo=You can also download a more <b>complete version, with updates,</b> of the Maxmind GeoIP country file at %s.