diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 0b08e230c3a..3f459da02f8 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2241,17 +2241,9 @@ function dol_print_ip($ip,$mode=0) if (empty($mode)) $ret.=$ip; - if (! empty($conf->geoipmaxmind->enabled) && $mode != 2) + if ($mode != 2) { - $datafile=$conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE; - //$ip='24.24.24.24'; - //$datafile='E:\Mes Sites\Web\Admin1\awstats\maxmind\GeoIP.dat'; Note that this must be downloaded datafile (not same than datafile provided with ubuntu packages) - - include_once DOL_DOCUMENT_ROOT.'/core/class/dolgeoip.class.php'; - $geoip=new DolGeoIP('country',$datafile); - //print 'ip='.$ip.' databaseType='.$geoip->gi->databaseType." GEOIP_CITY_EDITION_REV1=".GEOIP_CITY_EDITION_REV1."\n"; - //print "geoip_country_id_by_addr=".geoip_country_id_by_addr($geoip->gi,$ip)."\n"; - $countrycode=$geoip->getCountryCodeFromIP($ip); + $countrycode=dolGetCountryCodeFromIp($ip); if ($countrycode) // If success, countrycode is us, fr, ... { if (file_exists(DOL_DOCUMENT_ROOT.'/theme/common/flags/'.$countrycode.'.png')) @@ -2265,6 +2257,35 @@ function dol_print_ip($ip,$mode=0) return $ret; } +/** + * Return a country code from IP. Empty string if not found. + * + * @param string $ip IP + * @return string Country code ('us', 'fr', ...) + */ +function dolGetCountryCodeFromIp($ip) +{ + global $conf; + + $countrycode=''; + + if (! empty($conf->geoipmaxmind->enabled)) + { + $datafile=$conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE; + //$ip='24.24.24.24'; + //$datafile='E:\Mes Sites\Web\Admin1\awstats\maxmind\GeoIP.dat'; Note that this must be downloaded datafile (not same than datafile provided with ubuntu packages) + + include_once DOL_DOCUMENT_ROOT.'/core/class/dolgeoip.class.php'; + $geoip=new DolGeoIP('country',$datafile); + //print 'ip='.$ip.' databaseType='.$geoip->gi->databaseType." GEOIP_CITY_EDITION_REV1=".GEOIP_CITY_EDITION_REV1."\n"; + //print "geoip_country_id_by_addr=".geoip_country_id_by_addr($geoip->gi,$ip)."\n"; + $countrycode=$geoip->getCountryCodeFromIP($ip); + } + + return $countrycode; +} + + /** * Return country code for current user. * If software is used inside a local network, detection may fails (we need a public ip) @@ -5746,26 +5767,27 @@ function setEventMessages($mesg, $mesgs, $style='mesgs') * Note: Calling dol_htmloutput_events is done into pages by standard llxFooter() function, so there is * no need to call it explicitely. * + * @param int $disabledoutputofmessages Clear all messages stored into session without diplaying them * @return void - * @see dol_htmloutput_mesg + * @see dol_htmloutput_mesg */ -function dol_htmloutput_events() +function dol_htmloutput_events($disabledoutputofmessages=0) { // Show mesgs if (isset($_SESSION['dol_events']['mesgs'])) { - dol_htmloutput_mesg('', $_SESSION['dol_events']['mesgs']); + if (empty($disabledoutputofmessages)) dol_htmloutput_mesg('', $_SESSION['dol_events']['mesgs']); unset($_SESSION['dol_events']['mesgs']); } // Show errors if (isset($_SESSION['dol_events']['errors'])) { - dol_htmloutput_mesg('', $_SESSION['dol_events']['errors'], 'error'); + if (empty($disabledoutputofmessages)) dol_htmloutput_mesg('', $_SESSION['dol_events']['errors'], 'error'); unset($_SESSION['dol_events']['errors']); } // Show warnings if (isset($_SESSION['dol_events']['warnings'])) { - dol_htmloutput_mesg('', $_SESSION['dol_events']['warnings'], 'warning'); + if (empty($disabledoutputofmessages)) dol_htmloutput_mesg('', $_SESSION['dol_events']['warnings'], 'warning'); unset($_SESSION['dol_events']['warnings']); } } diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 1c03cbc8a40..2c0141f3b40 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1090,8 +1090,8 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs print "\n"; if (GETPOST('dol_basehref','alpha')) print ''."\n"; // Displays meta - print ''."\n"; // Do not index - print ''; // Scale for mobile device + print ''."\n"; // Do not index + print ''."\n"; // Scale for mobile device print ''."\n"; // Favicon $favicon=dol_buildpath('/theme/'.$conf->theme.'/img/favicon.ico',1); @@ -1874,17 +1874,18 @@ if (! function_exists("llxFooter")) * Close div /DIV class=fiche + /DIV id-right + /DIV id-container + /BODY + /HTML. * If global var $delayedhtmlcontent was filled, we output it just before closing the body. * - * @param string $comment A text to add as HTML comment into HTML generated page - * @param string $zone 'private' (for private pages) or 'public' (for public pages) + * @param string $comment A text to add as HTML comment into HTML generated page + * @param string $zone 'private' (for private pages) or 'public' (for public pages) + * @param int $disabledoutputofmessages Clear all messages stored into session without diplaying them * @return void */ - function llxFooter($comment='',$zone='private') + function llxFooter($comment='',$zone='private', $disabledoutputofmessages=0) { global $conf, $langs, $user, $object; global $delayedhtmlcontent; // Global html output events ($mesgs, $errors, $warnings) - dol_htmloutput_events(); + dol_htmloutput_events($disabledoutputofmessages); // Code for search criteria persistence. // Save $user->lastsearch_values if defined (define on list pages when a form field search_xxx exists)