From 7b14a2a019713bcd39650c7631031a26f70ee4c2 Mon Sep 17 00:00:00 2001 From: x2000habouzit Date: Thu, 13 Jul 2006 11:45:23 +0000 Subject: [PATCH 1/1] move geoloc as is into a geoloc module. no rewrite planned at all git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@462 839d8a87-29fc-0310-9880-83ba4fa771e5 --- Makefile | 11 --- htdocs/geoloc/dynamap.php | 44 ---------- htdocs/geoloc/geolocInit.php | 13 --- htdocs/geoloc/getCityInfos.php | 53 ------------ htdocs/geoloc/getData.php | 54 ------------ htdocs/geoloc/icon.php | 32 ------- htdocs/geoloc/index.php | 40 --------- modules/core.php | 10 ++- modules/geoloc.php | 186 +++++++++++++++++++++++++++++++++++++++++ 9 files changed, 195 insertions(+), 248 deletions(-) delete mode 100644 htdocs/geoloc/dynamap.php delete mode 100644 htdocs/geoloc/geolocInit.php delete mode 100644 htdocs/geoloc/getCityInfos.php delete mode 100644 htdocs/geoloc/getData.php delete mode 100644 htdocs/geoloc/icon.php delete mode 100644 htdocs/geoloc/index.php create mode 100644 modules/geoloc.php diff --git a/Makefile b/Makefile index 6910a15..7b780d0 100644 --- a/Makefile +++ b/Makefile @@ -16,12 +16,6 @@ VCS_FILTER = ! -name .arch-ids ! -name CVS all: build -devel: build htdocs/valid.html - -headers: - headache -c install.d/platal-dev/templates/header.conf -h install.d/platal-dev/templates/header \ - `find templates -name '*.tpl' ! -path 'templates/xnet/skin.tpl' ! -path 'templates/skin/*.tpl' ! -name 'vcard.tpl' ` - build: spool/templates_c wiki include/platal/globals.inc.php banana clean: @@ -45,11 +39,6 @@ spool/wiki.d: wiki/cookbook/e-protect.php: cd wiki/cookbook && ln -sf ../../install.d/wiki/e-protect.php -htdocs/valid.html: - touch spool/templates_c/valid.html - chmod o+w spool/templates_c/valid.html - cd htdocs && ln -sf ../spool/templates_c/valid.html - htdocs/uploads: cd htdocs && ln -sf ../spool/uploads diff --git a/htdocs/geoloc/dynamap.php b/htdocs/geoloc/dynamap.php deleted file mode 100644 index b2925c4..0000000 --- a/htdocs/geoloc/dynamap.php +++ /dev/null @@ -1,44 +0,0 @@ - $a) - if ($v != 'initfile') - $querystring .= '&'.urlencode($v).'='.urlencode($a); -$initfile = urlencode('geolocInit.php?'.$querystring); - -if (urlencode(Env::get('initfile')) != $initfile) -{ - header("Location: dynamap.php?initfile=$initfile{$querystring}"); - die(); -} - -header("Content-type: application/x-shockwave-flash"); - -if ($globals->geoloc->use_map()) - readfile($globals->geoloc->dynamap_path); - -?> diff --git a/htdocs/geoloc/geolocInit.php b/htdocs/geoloc/geolocInit.php deleted file mode 100644 index 6ecc2ca..0000000 --- a/htdocs/geoloc/geolocInit.php +++ /dev/null @@ -1,13 +0,0 @@ - $a) - if ($v != 'initfile') - $querystring .= '&'.urlencode($v).'='.urlencode($a); -$page->assign('querystring',$querystring); -$page->run(); -?> diff --git a/htdocs/geoloc/getCityInfos.php b/htdocs/geoloc/getCityInfos.php deleted file mode 100644 index 5014135..0000000 --- a/htdocs/geoloc/getCityInfos.php +++ /dev/null @@ -1,53 +0,0 @@ -get_where_statement(); -if ($where) $where = "WHERE ".$where; - -$users = $globals->xdb->iterator(" - SELECT u.user_id AS id, u.prenom, u.nom, u.promo - FROM adresses AS a -INNER JOIN auth_user_md5 AS u ON(u.user_id = a.uid) -INNER JOIN auth_user_quick AS q ON(q.user_id = a.uid) - ".$fields->get_select_statement()." - ".$where." - GROUP BY u.user_id LIMIT 11", - $id); - -$page->assign('users', $users); - -$page->run(); -// vim:set et sw=4 sts=4 sws=4 foldmethod=marker: -?> diff --git a/htdocs/geoloc/getData.php b/htdocs/geoloc/getData.php deleted file mode 100644 index d358631..0000000 --- a/htdocs/geoloc/getData.php +++ /dev/null @@ -1,54 +0,0 @@ - $a) - if ($v != 'mapid') - $querystring .= urlencode($v).'='.urlencode($a).'&'; -$page->assign('searchvars', $querystring); -if (Env::has('mapid')) - $mapid = Env::getInt('mapid', -2); -else - $mapid = false; - -list($countries, $cities) = geoloc_getData_subcountries($mapid, advancedSearchFromInput(), 10); - -$page->assign('countries', $countries); -$page->assign('cities', $cities); - -$page->run(); -// vim:set et sw=4 sts=4 sws=4 foldmethod=marker: -?> diff --git a/htdocs/geoloc/icon.php b/htdocs/geoloc/icon.php deleted file mode 100644 index 07bd17c..0000000 --- a/htdocs/geoloc/icon.php +++ /dev/null @@ -1,32 +0,0 @@ -geoloc->use_map()) - readfile($globals->geoloc->icon_path); - -?> diff --git a/htdocs/geoloc/index.php b/htdocs/geoloc/index.php deleted file mode 100644 index 8f13d57..0000000 --- a/htdocs/geoloc/index.php +++ /dev/null @@ -1,40 +0,0 @@ -xdb->query('SELECT COUNT(DISTINCT uid) FROM adresses WHERE cityid IS NOT NULL'); -$page->assign('localises', $res->fetchOneCell()); - - require_once('search.inc.php'); -$fields = new SFieldGroup(true, advancedSearchFromInput()); -$search = $fields->get_url(); -if (Env::has('only_current') && Env::get('only_current') != 'on') $search .= '&only_current='; -$search = preg_replace('/(^|&)mapid=([0-9]+)(&|$)/','\1\3', $search); -if ($search) - $page->assign('dynamap_vars', $search); - -$page->assign('use_map', $globals->geoloc->use_map()); -$page->run(); - -// vim:set et sws=4 sw=4 sts=4: -?> diff --git a/modules/core.php b/modules/core.php index 1998766..0ce18ee 100644 --- a/modules/core.php +++ b/modules/core.php @@ -43,10 +43,18 @@ class CoreModule extends PLModule 'exit' => $this->make_hook('exit', AUTH_PUBLIC), 'cacert.pem' => $this->make_hook('cacert', AUTH_PUBLIC), 'changelog' => $this->make_hook('changelog', AUTH_PUBLIC), - 'purge_cache' => $this->make_hook('purge_cache', AUTH_COOKIE, 'admin') + 'purge_cache' => $this->make_hook('purge_cache', AUTH_COOKIE, 'admin'), + + 'valid.html' => $this->make_hook('valid', AUTH_PUBLIC), ); } + function handler_valid(&$page) + { + readfile($page->compile_dir.'/valid.html'); + exit; + } + function handler_index(&$page) { if (logged()) { diff --git a/modules/geoloc.php b/modules/geoloc.php new file mode 100644 index 0000000..db56da2 --- /dev/null +++ b/modules/geoloc.php @@ -0,0 +1,186 @@ + $this->make_hook('default', AUTH_COOKIE), + 'geoloc/icon.php' => $this->make_hook('icon', AUTH_COOKIE), + 'geoloc/dynamap.php' => $this->make_hook('dynamap', AUTH_COOKIE), + 'geoloc/geolocInit.php' => $this->make_hook('init', AUTH_COOKIE), + 'geoloc/getCityInfos.php' => $this->make_hook('city', AUTH_COOKIE), + 'geoloc/getData.php' => $this->make_hook('data', AUTH_COOKIE), + ); + } + + function _make_qs() + { + $querystring = ""; + + foreach ($_GET as $v => $a) { + if ($v != 'initfile') { + $querystring .= '&'.urlencode($v).'='.urlencode($a); + } + } + + return $querystring; + } + + function handler_default(&$page) + { + global $globals; + + require_once 'search.inc.php'; + + $page->changeTpl('geoloc/index.tpl'); + + $res = $globals->xdb->query('SELECT COUNT(DISTINCT uid) + FROM adresses WHERE cityid IS NOT NULL'); + $page->assign('localises', $res->fetchOneCell()); + + $fields = new SFieldGroup(true, advancedSearchFromInput()); + $search = $fields->get_url(); + if (Env::has('only_current') && Env::get('only_current') != 'on') { + $search .= '&only_current='; + } + $search = preg_replace('/(^|&)mapid=([0-9]+)(&|$)/','\1\3', $search); + if ($search) { + $page->assign('dynamap_vars', $search); + } + + $page->assign('use_map', $globals->geoloc->use_map()); + + return PL_OK; + } + + function handler_icon(&$page) + { + global $globals; + + header("Content-type: application/x-shockwave-flash"); + + if ($globals->geoloc->use_map()) { + readfile($globals->geoloc->icon_path); + exit; + } + + return PL_NOT_FOUND; + } + + function handler_dynamap(&$page) + { + global $globals; + + $querystring = $this->_make_qs(); + $initfile = urlencode('geolocInit.php?'.$querystring); + + if (urlencode(Env::get('initfile')) != $initfile) { + header("Location: dynamap.php?initfile=$initfile{$querystring}"); + die(); + } + + header("Content-type: application/x-shockwave-flash"); + + if ($globals->geoloc->use_map()) { + readfile($globals->geoloc->dynamap_path); + exit; + } + + return PL_NOT_FOUND; + } + + function handler_init(&$page) + { + global $globals; + + new_nonhtml_page('geoloc/geolocInit.tpl', AUTH_COOKIE); + + header('Content-type: text/xml'); + $page->assign('querystring', $this->_make_qs()); + + return PL_OK; + } + + function handler_city(&$page) + { + global $globals; + + header("Content-type: text/xml"); + + new_nonhtml_page('geoloc/getCityInfos.tpl', AUTH_COOKIE); + // to debug sql use the next line + //new_skinned_page('', AUTH_COOKIE); + + require_once('geoloc.inc.php'); + require_once('search.inc.php'); + + $usual_fields = advancedSearchFromInput(); + $fields = new SFieldGroup(true, $usual_fields); + $where = $fields->get_where_statement(); + if ($where) $where = "WHERE ".$where; + + $users = $globals->xdb->iterator(" + SELECT u.user_id AS id, u.prenom, u.nom, u.promo + FROM adresses AS a + INNER JOIN auth_user_md5 AS u ON(u.user_id = a.uid) + INNER JOIN auth_user_quick AS q ON(q.user_id = a.uid) + ".$fields->get_select_statement()." + ".$where." + GROUP BY u.user_id LIMIT 11", $id); + + $page->assign('users', $users); + + return PL_OK; + } + + function handler_data(&$page) + { + global $globals; + + // to debug sql use the next line + if (Env::has('debug')) { + $page->changeTpl('geoloc/getData.tpl'); + $page->assign('simple', true); + } else { + header("Content-type: text/xml"); + new_nonhtml_page('geoloc/getData.tpl', AUTH_COOKIE); + } + + require_once 'geoloc.inc.php'; + require_once 'search.inc.php'; + + $querystring = $this->_make_qs(); + $page->assign('searchvars', $querystring); + + $mapid = Env::has('mapid') ? Env::getInt('mapid', -2) : false; + + list($countries, $cities) = geoloc_getData_subcountries($mapid, advancedSearchFromInput(), 10); + + $page->assign('countries', $countries); + $page->assign('cities', $cities); + + return PL_OK; + } +} + +?> -- 2.1.4