X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fxnet.php;h=c8e5611df0a9303cde1c8e0266a0cc1ecf3c087e;hb=afada5eb6cf23005f775fbab0d421c27393172f1;hp=fc4536599be10dd382662509972477dc1df9df50;hpb=9053ac09eebb5eedf230ce6ec16033879d3cfa74;p=platal.git diff --git a/modules/xnet.php b/modules/xnet.php index fc45365..c8e5611 100644 --- a/modules/xnet.php +++ b/modules/xnet.php @@ -1,6 +1,6 @@ $this->make_hook('groups', AUTH_PUBLIC), 'groupes.php' => $this->make_hook('groups2', AUTH_PUBLIC), 'plan' => $this->make_hook('plan', AUTH_PUBLIC), + 'photo' => $this->make_hook('photo', AUTH_MDP), + 'autologin' => $this->make_hook('autologin', AUTH_MDP), ); } + function handler_photo(&$page, $x = null) + { + if (is_null($x)) { + return PL_NOT_FOUND; + } + + $res = XDB::query("SELECT attachmime, attach + FROM aliases + INNER JOIN photo ON(id = uid) + WHERE alias = {?}", $x); + + if ((list($type, $data) = $res->fetchOneRow())) { + Header("Content-type: image/$type"); + echo $data; + } else { + Header('Content-type: image/png'); + echo file_get_contents(dirname(__FILE__).'/../htdocs/images/none.png'); + } + exit; + } + function handler_index(&$page) { + $page->nomenu = true; $page->changeTpl('xnet/index.tpl'); } function handler_exit(&$page) { + XnetSession::killSuid(); XnetSession::destroy(); $page->changeTpl('xnet/deconnexion.tpl'); - $page->useMenu(); } function handler_admin(&$page) { - new_admin_page('xnet/admin.tpl'); - $page->useMenu(); + $page->changeTpl('xnet/admin.tpl'); if (Get::has('del')) { $res = XDB::query('SELECT id, nom, mail_domain @@ -58,8 +81,10 @@ class XnetModule extends PLModule list($id, $nom, $domain) = $res->fetchOneRow(); $page->assign('nom', $nom); if ($id && Post::has('del')) { + S::assert_xsrf_token(); + XDB::query('DELETE FROM groupex.membres WHERE asso_id={?}', $id); - $page->trig('membres supprimés'); + $page->trig('membres supprimés'); if ($domain) { XDB::query('DELETE FROM virtual_domains WHERE domain={?}', $domain); @@ -68,18 +93,17 @@ class XnetModule extends PLModule WHERE alias LIKE {?}', '%@'.$domain); $page->trig('suppression des alias mails'); - require_once('lists.inc.php'); - $client =& lists_xmlrpc(S::v('uid'), S::v('password'), $domain); - if ($listes = $client->get_lists()) { + $mmlist = new MMList(S::v('uid'), S::v('password'), $domain); + if ($listes = $mmlist->get_lists()) { foreach ($listes as $l) { - $client->delete_list($l['list'], true); + $mmlist->delete_list($l['list'], true); } - $page->trig('mail lists surpprimées'); + $page->trig('mail lists surpprimées'); } } XDB::query('DELETE FROM groupex.asso WHERE id={?}', $id); - $page->trig("Groupe $nom supprimé"); + $page->trig("Groupe $nom supprimé"); Get::kill('del'); } if (!$id) { @@ -88,6 +112,8 @@ class XnetModule extends PLModule } if (Post::has('diminutif')) { + S::assert_xsrf_token(); + XDB::query('INSERT INTO groupex.asso (id,diminutif) VALUES(NULL,{?})', Post::v('diminutif')); pl_redirect('../'.Post::v('diminutif').'/edit'); @@ -136,7 +162,6 @@ class XnetModule extends PLModule WHERE FIND_IN_SET("Institutions", cat) ORDER BY diminutif'); $page->assign('inst', $res); - $page->useMenu(); } function handler_groups2(&$page) @@ -163,20 +188,30 @@ class XnetModule extends PLModule $page->assign('doms', $doms); if (empty($doms)) { - $res = XDB::query("SELECT diminutif, nom FROM groupex.asso + $res = XDB::query("SELECT diminutif, nom, site FROM groupex.asso WHERE FIND_IN_SET({?}, cat) ORDER BY nom", $cat); $page->assign('gps', $res->fetchAllAssoc()); } elseif (!is_null($dom)) { - $res = XDB::query("SELECT diminutif, nom FROM groupex.asso + $res = XDB::query("SELECT diminutif, nom, site FROM groupex.asso WHERE FIND_IN_SET({?}, cat) AND dom={?} ORDER BY nom", $cat, $dom); $page->assign('gps', $res->fetchAllAssoc()); } - $page->useMenu(); $page->setType($cat); } + + function handler_autologin(&$page) + { + $allkeys = func_get_args(); + unset($allkeys[0]); + $url = join('/',$allkeys); + header("Content-type: text/javascript; charset=utf-8"); + echo '$.ajax({ url: "'.$url.'?forceXml=1", dataType: "xml", success: function(xml) { $("body",xml).insertBefore("body"); $("body:eq(1)").remove(); }});'; + exit; + } } +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: ?>