From 73423688882e7f2510089f7e1a0e5747e3a7ebd3 Mon Sep 17 00:00:00 2001 From: Pascal Corpet Date: Sat, 11 Jun 2005 18:35:26 +0000 Subject: [PATCH] open test sur la geoloc svp git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-702 --- ChangeLog | 3 +++ htdocs/geoloc/globe.php | 38 ++++++++++++++++++++++++++++++++ htdocs/geoloc/index.php | 31 ++++++++++++++++++++++++++ include/geoloc.inc.php | 7 +++++- include/profil/verif_adresses.inc.php | 26 ++++++++++++---------- templates/geoloc/form.address.tpl | 24 ++++++++++++++------ templates/geoloc/index.tpl | 41 +++++++++++++++++++++++++++++++++++ 7 files changed, 151 insertions(+), 19 deletions(-) create mode 100644 htdocs/geoloc/globe.php create mode 100644 htdocs/geoloc/index.php create mode 100644 templates/geoloc/index.tpl diff --git a/ChangeLog b/ChangeLog index b0bcbcd..f7b1044 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,9 @@ VERSION 0.9.7 07 May 2004 New : + * Profile : + - Address parser. -Car + * Search : - Nickname are used in fast search. -Car diff --git a/htdocs/geoloc/globe.php b/htdocs/geoloc/globe.php new file mode 100644 index 0000000..05c3497 --- /dev/null +++ b/htdocs/geoloc/globe.php @@ -0,0 +1,38 @@ +xdb->iterRow('SELECT lat, lon FROM geoloc_city AS gc LEFT JOIN adresses AS a ON(gc.id = a.cityid) WHERE a.cityid IS NOT NULL GROUP BY gc.id'); + +$img = imageCreateFromPng("../images/globe.png"); + +$coul = imagecolorallocate($img, 0, 0, 0); + +while ($a = $res->next()) + imagefilledellipse($img, round(($a[1]/100000 + 180 )/360*600), round((90 - $a[0]/100000)/180*300), 5, 5, $coul); + +imagePng($img); +imagedestroy($img); +// vim:set et sws=4 sw=4 sts=4: +?> diff --git a/htdocs/geoloc/index.php b/htdocs/geoloc/index.php new file mode 100644 index 0000000..ad1da96 --- /dev/null +++ b/htdocs/geoloc/index.php @@ -0,0 +1,31 @@ +xdb->query('SELECT COUNT(DISTINCT uid) FROM adresses WHERE cityid IS NOT NULL'); +$page->assign('localises', $res->fetchOneCell()); + +$page->run(); + +// vim:set et sws=4 sw=4 sts=4: +?> diff --git a/include/geoloc.inc.php b/include/geoloc.inc.php index 4cf977a..717436d 100644 --- a/include/geoloc.inc.php +++ b/include/geoloc.inc.php @@ -76,7 +76,7 @@ function get_address_infos($txt) { $keys = explode('|',fgets($f)); $vals = explode('|',fgets($f)); $infos = array(); - foreach ($keys as $i=>$key) if($vals[$i]) $infos[$key] = $vals[$i]; + foreach ($keys as $i=>$key) if($vals[$i]) $infos[$key] = ($key == 'sql')?$vals[$i]:utf8_decode($vals[$i]); global $globals; if ($infos['sql']) $globals->xdb->execute("REPLACE INTO geoloc_city VALUES ".$infos['sql']); @@ -99,6 +99,11 @@ function get_address_text($adr) { if ($adr['city']) $l .= $adr['city']; } if ($l) $t .= "\n".trim($l); + if ($adr['country'] != '00' && !$adr['countrytxt']) { + global $globals; + $res = $globals->xdb->query("SELECT pays FROM geoloc_pays WHERE a2 = {?}", $adr['country']); + $adr['countrytxt'] = $res->fetchOneCell(); + } if ($adr['countrytxt']) $t .= "\n".$adr['countrytxt']; return trim($t); } diff --git a/include/profil/verif_adresses.inc.php b/include/profil/verif_adresses.inc.php index 39d9121..b13a1bb 100644 --- a/include/profil/verif_adresses.inc.php +++ b/include/profil/verif_adresses.inc.php @@ -85,20 +85,24 @@ function replace_address($i){ replace_ifset_adr('pub', $i); replace_ifset_adr('tel_pub', $i); replace_ifset_adr('txt', $i); - if ($GLOBALS['adresses'][$i]['txt'] && !Env::get('nochange'.$i, true)) { + if ($GLOBALS['adresses'][$i]['txt'] && Env::get('change'.$i, false)) { require_once('geoloc.inc.php'); $new = get_address_infos($GLOBALS['adresses'][$i]['txt']); - $GLOBALS['adresses'][$i]['adr1'] = ''; - $GLOBALS['adresses'][$i]['adr2'] = ''; - $GLOBALS['adresses'][$i]['adr3'] = ''; - $GLOBALS['adresses'][$i]['postcode'] = ''; - $GLOBALS['adresses'][$i]['city'] = ''; - unset($GLOBALS['adresses'][$i]['cityid']); - $GLOBALS['adresses'][$i]['country'] = '00'; - $GLOBALS['adresses'][$i]['region'] = ''; - $GLOBALS['adresses'][$i] = array_merge($GLOBALS['adresses'][$i], $new); - $GLOBALS['adresses'][$i]['txt'] = get_address_text($GLOBALS['adresses'][$i]); + // if we found a localisation, erase old address + if ($new['sql']) { + $GLOBALS['adresses'][$i]['adr1'] = ''; + $GLOBALS['adresses'][$i]['adr2'] = ''; + $GLOBALS['adresses'][$i]['adr3'] = ''; + $GLOBALS['adresses'][$i]['postcode'] = ''; + $GLOBALS['adresses'][$i]['city'] = ''; + unset($GLOBALS['adresses'][$i]['cityid']); + $GLOBALS['adresses'][$i]['country'] = '00'; + $GLOBALS['adresses'][$i]['countrytxt'] = ''; + $GLOBALS['adresses'][$i]['region'] = ''; + $GLOBALS['adresses'][$i] = array_merge($GLOBALS['adresses'][$i], $new); + } } + $GLOBALS['adresses'][$i]['txt'] = get_address_text($GLOBALS['adresses'][$i]); $tab = Env::getMixed('numero_formulaire', Array()); if($tab[$i]) $GLOBALS['adresses'][$i]['numero_formulaire'] = $tab[$i]; diff --git a/templates/geoloc/form.address.tpl b/templates/geoloc/form.address.tpl index dd8d632..0d6fc50 100644 --- a/templates/geoloc/form.address.tpl +++ b/templates/geoloc/form.address.tpl @@ -1,18 +1,22 @@ {$titre} - {if $adr.nouvelle != 'new' && !$smarty.request.detail[$adrid]} + {if !$smarty.request.detail[$adrid]}
- [corriger] - {/if} - {if $adr.nouvelle != 'new' && !$adr.cityid} + [{if $adr.nouvelle != 'new'}corriger{else}préciser{/if}] + {/if} + {if $adr.nouvelle != 'new' && !$adr.cityid && !$smarty.request.detail[$adrid]}
non géolocalisée - {/if} +
+ + + {else} + + {/if} {if $smarty.request.detail[$adrid] neq 1} - @@ -21,7 +25,13 @@ - + {else} diff --git a/templates/geoloc/index.tpl b/templates/geoloc/index.tpl new file mode 100644 index 0000000..555ce6d --- /dev/null +++ b/templates/geoloc/index.tpl @@ -0,0 +1,41 @@ +{**************************************************************************} +{* *} +{* Copyright (C) 2004-2005 Polytechnique.org *} +{* http://opensource.polytechnique.org/ *} +{* *} +{* 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 2 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, write to the Free Software *} +{* Foundation, Inc., *} +{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *} +{* *} +{**************************************************************************} + +

Géolocalisation

+ +

Aujourd'hui {$localises} de nos camarades sont localisés grâce à leurs adresses personnelles. La géolocalisation permet de : +

+ + +

+Carte du monde des X +

+ +

Pour savoir comment ça marche tu peux aller faire un tour sur le site de développement du projet.

+ +

Pour toute question, problème ou suggestion tu peux envoyer un mail à contact+geoloc@polytechnique.org

+ +{* vim:set et sw=2 sts=2 sws=2: *} -- 2.1.4