* Copyright (C) 2011-2013 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file htdocs/admin/geoipmaxmind.php * \ingroup geoipmaxmind * \brief Setup page for geoipmaxmind module */ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/dolgeoip.class.php'; // Security check if (!$user->admin) accessforbidden(); $langs->load("admin"); $langs->load("errors"); $action = GETPOST("action"); /* * Actions */ if ($action == 'set') { $error=0; $gimcdf= GETPOST("GEOIPMAXMIND_COUNTRY_DATAFILE"); if (! $gimcdf && ! file_exists($gimcdf)) { setEventMessage($langs->trans("ErrorFileNotFound",$gimcdf),'errors'); $error++; } if (! $error) { $res = dolibarr_set_const($db,"GEOIPMAXMIND_COUNTRY_DATAFILE",$gimcdf,'chaine',0,'',$conf->entity); if (! $res > 0) $error++; if (! $error) { setEventMessage($langs->trans("SetupSaved")); } else { setEventMessage($langs->trans("Error"),'errors'); } } } /* * View */ $form=new Form($db); llxHeader(); $linkback=''.$langs->trans("BackToModuleList").''; print_fiche_titre($langs->trans("GeoIPMaxmindSetup"),$linkback,'title_setup'); print '
'; $version=''; $geoip=''; if (! empty($conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE)) { $geoip=new DolGeoIP('country',$conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE); //if ($geoip->error) print dol_htmloutput_errors($geoip->errorlabel,'',1); if ($geoip->gi == 'NOGI') $geointernal=true; else $geointernal=false; } else { if (function_exists('geoip_country_code_by_name')) $geointernal=true; } // Mode $var=true; print '
'; print ''; print ''; print ''; print ''; print ''; print ''; print "\n"; $var=!$var; print ''; print ''; print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("PathToGeoIPMaxmindCountryDataFile").''; if ($geointernal) print 'Using geoip PHP internal functions. Value must be '.geoip_db_filename(GEOIP_COUNTRY_EDITION).' or '.geoip_db_filename(GEOIP_CITY_EDITION_REV1).'
'; print ''; if ($geoip) $version=$geoip->getVersion(); if ($version) { print '
'.$langs->trans("Version").': '.$version; } print '
'; print "
\n"; print '
'; print $langs->trans("NoteOnPathLocation").'
'; $url1='http://www.maxmind.com/en/city?rId=awstats'; print $langs->trans("YouCanDownloadFreeDatFileTo",''.$url1.''); print '
'; $url2='http://www.maxmind.com/en/city?rId=awstats'; print $langs->trans("YouCanDownloadAdvancedDatFileTo",''.$url2.''); if ($geoip) { print '

'; print '
'.$langs->trans("TestGeoIPResult",$ip).':'; $ip='24.24.24.24'; print '
'.$ip.' -> '; $result=dol_print_ip($ip,1); if ($result) print $result; else print $langs->trans("Error"); /* We disable this test because dol_print_ip need an ip as input $ip='www.google.com'; print '
'.$ip.' -> '; $result=dol_print_ip($ip,1); if ($result) print $result; else print $langs->trans("Error"); */ $geoip->close(); } llxFooter(); $db->close();