X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=sidebyside;f=include%2Fgeoloc.inc.php;h=89abd27ce819275473d26d9873331b6d70ccb0c9;hb=7c7d62fce3e3973b576ffbc4051ba443d6a6b849;hp=85687bc289b32ad077a10e7d786852a6058d3022;hpb=a25cdc91a68f7d960496d4b7e4de158f8e1bf752;p=platal.git diff --git a/include/geoloc.inc.php b/include/geoloc.inc.php index 85687bc..89abd27 100644 --- a/include/geoloc.inc.php +++ b/include/geoloc.inc.php @@ -1,6 +1,6 @@ geoloc->webservice_url."address.php?precise=1&txt=" . urlencode($txt); - if (!($f = @fopen($url, 'r'))) return false; + if ($globals->debug & DEBUG_BT) { + if (!isset(PlBacktrace::$bt['Geoloc'])) { + new PlBacktrace('Geoloc'); + } + PlBacktrace::$bt['Geoloc']->start($url); + } + $f = @fopen($url, 'r'); + if ($f === false) { + if ($globals->debug & DEBUG_BT) { + PlBacktrace::$bt['Geoloc']->stop(0, 'Can\'t fetch result'); + } + return false; + } $keys = explode('|',fgets($f)); $vals = explode('|',fgets($f)); + if ($globals->debug & DEBUG_BT) { + $data = array(); + for ($i = 0 ; $i < count($keys) ; ++$i) { + $data[] = array($keys[$i], $vals[$i]); + } + PlBacktrace::$bt['Geoloc']->stop(count($keys), null, $data); + } $infos = empty_address(); foreach ($keys as $i=>$key) { if($vals[$i]) { @@ -206,7 +226,7 @@ function get_address_text($adr) if (isset($adr['city']) && $adr['city']) $l .= $adr['city']; } if ($l) $t .= "\n".trim($l); - if ($adr['country'] != '00' && (!$adr['countrytxt'] || $adr['countrytxt'] == strtoupper($adr['countrytxt']))) { + if ($adr['country'] != '00' && (!$adr['countrytxt'] || $adr['countrytxt'] == mb_strtoupper($adr['countrytxt']))) { $res = XDB::query("SELECT pays FROM geoloc_pays WHERE a2 = {?}", $adr['country']); $adr['countrytxt'] = $res->fetchOneCell(); } @@ -224,8 +244,8 @@ function get_address_text($adr) */ function compare_addresses_text($a, $b) { - $ta = strtoupper(preg_replace(array("/[0-9,\"'#~:;_\- ]/", "/\r\n/"), array("", "\n"), $a)); - $tb = strtoupper(preg_replace(array("/[0-9,\"'#~:;_\- ]/", "/\r\n/"), array("", "\n"), $b)); + $ta = mb_strtoupper(preg_replace(array("/[0-9,\"'#~:;_\- ]/", "/\r\n/"), array("", "\n"), $a)); + $tb = mb_strtoupper(preg_replace(array("/[0-9,\"'#~:;_\- ]/", "/\r\n/"), array("", "\n"), $b)); $la = explode("\n", $ta); $lb = explode("\n", $tb);