* @param $current pays actuellement selectionné
*/
function geoloc_country($current) {
- global $globals;
$res = XDB::iterRow('SELECT a2,pays FROM geoloc_pays ORDER BY pays');
$html = "";
while (list($my_id, $my_pays) = $res->next()) {
* @param $current la region actuellement selectionnee
*/
function geoloc_region($country,$current) {
- global $globals;
$res = XDB::iterRow('SELECT region,name FROM geoloc_region where a2={?} ORDER BY name', $country);
$html = "<option value=\"\"></option>";
while (list($regid, $regname) = $res->next()) {
/** set new maps from url **/
function get_new_maps($url)
{
- if (!($f = @fopen($url, 'r'))) return false;
- global $globals;
- XDB::query('TRUNCATE TABLE geoloc_maps');
- $s = '';
- while (!feof($f)) {
- $l = fgetcsv($f, 1024, ';', '"');
- foreach ($l as $i => $val) if ($val != 'NULL') $l[$i] = '\''.addslashes($val).'\'';
- $s .= ',('.implode(',',$l).')';
- }
- XDB::execute('INSERT INTO geoloc_maps VALUES '.substr($s, 1));
- return true;
+ if (!($f = @fopen($url, 'r'))) {
+ return false;
+ }
+ XDB::query('TRUNCATE TABLE geoloc_maps');
+ $s = '';
+ while (!feof($f)) {
+ $l = fgetcsv($f, 1024, ';', '"');
+ foreach ($l as $i => $val) {
+ if ($val != 'NULL') {
+ $l[$i] = '\''.addslashes($val).'\'';
+ }
+ }
+ $s .= ',('.implode(',',$l).')';
+ }
+ XDB::execute('INSERT INTO geoloc_maps VALUES '.substr($s, 1));
+ return true;
}
// {{{ get_address_text($adr)
}
if ($l) $t .= "\n".trim($l);
if ($adr['country'] != '00' && (!$adr['countrytxt'] || $adr['countrytxt'] == strtoupper($adr['countrytxt']))) {
- global $globals;
$res = XDB::query("SELECT pays FROM geoloc_pays WHERE a2 = {?}", $adr['country']);
$adr['countrytxt'] = $res->fetchOneCell();
}
* @param $uid the id of the user
*/
function localize_addresses($uid) {
- global $globals;
$res = XDB::iterator("SELECT * FROM adresses WHERE uid = {?} and (cityid IS NULL OR cityid = 0)", $uid);
$erreur = Array();
// {{{ function fix_cities_not_on_map($limit)
function fix_cities_not_on_map($limit=false)
{
- global $globals;
$missing = XDB::query("SELECT c.id FROM geoloc_city AS c LEFT JOIN geoloc_city_in_maps AS m ON(c.id = m.city_id) WHERE m.city_id IS NULL".($limit?" LIMIT $limit":""));
$maps = get_cities_maps($missing->fetchColumn());
if ($maps)
}
function set_smallest_levels() {
- global $globals;
$maxlengths = XDB::iterRow("SELECT MAX(LENGTH(gm.path)), gcim.city_id
FROM geoloc_city_in_maps AS gcim
INNER JOIN geoloc_maps AS gm
function size_of_territory($nb) { return size_of_city($nb); }
function geoloc_getData_subcities($mapid, $SFields, &$cities, $direct=true) {
- global $globals;
for ($i_mapfield=0; $i_mapfield < count($SFields) ; $i_mapfield++) if ($SFields[$i_mapfield]->fieldFormName == 'mapid') break;
$SFields[$i_mapfield] = new MapSField('mapid', array('gcim.map_id'), array('adresses','geoloc_city_in_maps'), array('am','gcim'), array(getadr_join('am'), 'am.cityid = gcim.city_id'), $mapid);
}
function geoloc_getData_subcountries($mapid, $SFields, $minentities) {
- global $globals;
$countries = array();
$cities = array();