2 /***************************************************************************
3 * Copyright (C) 2003-2006 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
22 function bugize($list)
24 $list = split(',', $list);
27 foreach ($list as $bug) {
28 $clean = str_replace('#', '', $bug);
29 $ans[] = "<a href='http://trackers.polytechnique.org/task/$clean'>$bug</a>";
32 return join(',', $ans);
36 class CoreModule
extends PLModule
41 '403' => $this->make_hook('403', AUTH_PUBLIC
),
42 '404' => $this->make_hook('404', AUTH_PUBLIC
),
43 'exit' => $this->make_hook('exit', AUTH_PUBLIC
),
44 'cacert.pem' => $this->make_hook('cacert', AUTH_PUBLIC
),
45 'changelog' => $this->make_hook('changelog', AUTH_PUBLIC
),
46 'purge_cache' => $this->make_hook('purge_cache', AUTH_COOKIE
, 'admin'),
48 'valid.html' => $this->make_hook('valid', AUTH_PUBLIC
),
52 function handler_valid(&$page)
54 readfile($page->compile_dir
.'/valid.html');
58 function handler_index(&$page)
67 function handler_cacert(&$page)
69 $data = file_get_contents('/etc/ssl/xorgCA/cacert.pem');
70 header('Content-Type: application/x-x509-ca-cert');
71 header('Content-Length: '.strlen($data));
76 function handler_changelog(&$page)
78 $page->changeTpl('changeLog.tpl');
80 $clog = htmlentities(file_get_contents(dirname(__FILE__
).'/../ChangeLog'));
81 $clog = preg_replace('!(#[0-9]+(,[0-9]+)*)!e', 'bugize("\1")', $clog);
82 $page->assign('ChangeLog', $clog);
85 function handler_exit(&$page, $level = null
)
87 if (Session
::has('suid')) {
88 if (Session
::has('suid')) {
89 $a4l = Session
::get('forlife');
90 $suid = Session
::getMixed('suid');
91 $log = Session
::getMixed('log');
92 $log->log("suid_stop", Session
::get('forlife') . " by " . $suid['forlife']);
94 Session
::kill('suid');
95 redirect($globals->baseurl
.'/admin/utilisateurs.php?login='.$a4l);
101 if ($level == 'forget' ||
$level == 'forgetall') {
102 setcookie('ORGaccess', '', time() - 3600, '/', '', 0);
103 Cookie
::kill('ORGaccess');
104 if (isset($_SESSION['log']))
105 $_SESSION['log']->log("cookie_off");
108 if ($level == 'forgetuid' ||
$level == 'forgetall') {
109 setcookie('ORGuid', '', time() - 3600, '/', '', 0);
110 Cookie
::kill('ORGuid');
111 setcookie('ORGdomain', '', time() - 3600, '/', '', 0);
112 Cookie
::kill('ORGdomain');
115 if (isset($_SESSION['log'])) {
116 $ref = isset($_SERVER['HTTP_REFERER']) ?
$_SERVER['HTTP_REFERER'] : '';
117 $_SESSION['log']->log('deconnexion',$ref);
120 XorgSession
::destroy();
122 if (Get
::has('redirect')) {
123 redirect(rawurldecode(Get
::get('redirect')));
125 $page->changeTpl('exit.tpl');
130 function handler_403(&$page)
132 header('HTTP/1.0 403 Forbidden');
133 $page->changeTpl('403.tpl');
137 function handler_404(&$page)
139 header('HTTP/1.0 404 Not Found');
140 $page->changeTpl('404.tpl');
144 function handler_purge_cache(&$page)
146 require_once 'wiki.inc.php';
148 $page->clear_compiled_tpl();
149 wiki_clear_all_cache();
151 redirect(empty($_SERVER['HTTP_REFERER']) ?
'./' : $_SERVER['HTTP_REFERER']);