<?php
/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
+ * Copyright (C) 2003-2009 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
function get_address_infos($txt)
{
global $globals;
+
$url = $globals->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]) {
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();
}
*/
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);