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 class AdminModule
extends PLModule
27 'admin' => $this->make_hook('default', AUTH_MDP
, 'admin'),
28 'admin/ax-xorg' => $this->make_hook('ax_xorg', AUTH_MDP
, 'admin'),
29 'admin/deaths' => $this->make_hook('deaths', AUTH_MDP
, 'admin'),
30 'admin/downtime' => $this->make_hook('downtime', AUTH_MDP
, 'admin'),
31 'admin/homonyms' => $this->make_hook('homonyms', AUTH_MDP
, 'admin'),
32 'admin/logger' => $this->make_hook('logger', AUTH_MDP
, 'admin'),
33 'admin/logger/actions' => $this->make_hook('logger_actions', AUTH_MDP
, 'admin'),
34 'admin/postfix/blacklist' => $this->make_hook('postfix_blacklist', AUTH_MDP
, 'admin'),
35 'admin/postfix/delayed' => $this->make_hook('postfix_delayed', AUTH_MDP
, 'admin'),
36 'admin/postfix/regexp_bounces' => $this->make_hook('postfix_regexpsbounces', AUTH_MDP
, 'admin'),
37 'admin/postfix/whitelist' => $this->make_hook('postfix_whitelist', AUTH_MDP
, 'admin'),
38 'admin/skins' => $this->make_hook('skins', AUTH_MDP
, 'admin'),
39 'admin/synchro_ax' => $this->make_hook('synchro_ax', AUTH_MDP
, 'admin'),
40 'admin/user' => $this->make_hook('user', AUTH_MDP
, 'admin'),
41 'admin/validate' => $this->make_hook('validate', AUTH_MDP
, 'admin'),
42 'admin/validate/answers' => $this->make_hook('validate_answers', AUTH_MDP
, 'admin'),
43 'admin/wiki' => $this->make_hook('wiki', AUTH_MDP
, 'admin'),
47 function handler_default(&$page)
49 $page->changeTpl('admin/index.tpl');
50 $page->assign('xorg_title','Polytechnique.org - Administration');
53 function handler_postfix_delayed(&$page)
55 $page->changeTpl('admin/postfix_delayed.tpl');
56 $page->assign('xorg_title','Polytechnique.org - Administration - Postfix : Retardés');
58 if (Env
::has('del')) {
60 XDB
::execute("UPDATE postfix_mailseen SET release = 'del' WHERE crc = {?}", $crc);
61 $page->trig($crc." verra tous ses mails supprimés !");
62 } elseif (Env
::has('ok')) {
64 XDB
::execute("UPDATE postfix_mailseen SET release = 'ok' WHERE crc = {?}", $crc);
65 $page->trig($crc." a le droit de passer !");
69 "SELECT crc, nb, update_time, create_time,
70 FIND_IN_SET('del', release) AS del,
71 FIND_IN_SET('ok', release) AS ok
74 ORDER BY release != ''");
76 $page->assign_by_ref('mails', $sql);
79 function handler_postfix_regexpsbounces(&$page, $new = null
) {
80 $page->changeTpl('admin/emails_bounces_re.tpl');
81 $page->assign('xorg_title','Polytechnique.org - Administration - Postfix : Regexps Bounces');
82 $page->assign('new', $new);
84 if (Post
::has('submit')) {
85 foreach (Env
::v('lvl') as $id=>$val) {
87 "REPLACE INTO emails_bounces_re (id,pos,lvl,re,text) VALUES ({?}, {?}, {?}, {?}, {?})",
88 $id, $_POST['pos'][$id], $_POST['lvl'][$id], $_POST['re'][$id], $_POST['text'][$id]
93 $page->assign('bre', XDB
::iterator("SELECT * FROM emails_bounces_re ORDER BY pos"));
98 /** Retrieves the available days for a given year and month.
99 * Obtain a list of days of the given month in the given year
100 * that are within the range of dates that we have log entries for.
102 * @param integer year
103 * @param integer month
104 * @return array days in that month we have log entries covering.
107 function _getDays($year, $month)
109 // give a 'no filter' option
112 if ($year && $month) {
113 $day_max = Array(-1, 31, checkdate(2, 29, $year) ?
29 : 28 , 31,
114 30, 31, 30, 31, 31, 30, 31, 30, 31);
115 $res = XDB
::query("SELECT YEAR (MAX(start)), YEAR (MIN(start)),
116 MONTH(MAX(start)), MONTH(MIN(start)),
117 DAYOFMONTH(MAX(start)),
118 DAYOFMONTH(MIN(start))
119 FROM logger.sessions");
120 list($ymax, $ymin, $mmax, $mmin, $dmax, $dmin) = $res->fetchOneRow();
122 if (($year < $ymin) ||
($year == $ymin && $month < $mmin)) {
126 if (($year > $ymax) ||
($year == $ymax && $month > $mmax)) {
130 $min = ($year==$ymin && $month==$mmin) ?
intval($dmin) : 1;
131 $max = ($year==$ymax && $month==$mmax) ?
intval($dmax) : $day_max[$month];
133 for($i = $min; $i<=$max; $i++
) {
141 /** Retrieves the available months for a given year.
142 * Obtains a list of month numbers that are within the timeframe that
143 * we have log entries for.
145 * @param integer year
146 * @return array List of month numbers we have log info for.
149 function _getMonths($year)
151 // give a 'no filter' option
155 $res = XDB
::query("SELECT YEAR (MAX(start)), YEAR (MIN(start)),
156 MONTH(MAX(start)), MONTH(MIN(start))
157 FROM logger.sessions");
158 list($ymax, $ymin, $mmax, $mmin) = $res->fetchOneRow();
160 if (($year < $ymin) ||
($year > $ymax)) {
164 $min = $year == $ymin ?
intval($mmin) : 1;
165 $max = $year == $ymax ?
intval($mmax) : 12;
167 for($i = $min; $i<=$max; $i++
) {
175 /** Retrieves the available years.
176 * Obtains a list of years that we have log entries covering.
178 * @return array years we have log entries for.
183 // give a 'no filter' option
186 // retrieve available years
187 $res = XDB
::query("select YEAR(MAX(start)), YEAR(MIN(start)) FROM logger.sessions");
188 list($max, $min) = $res->fetchOneRow();
190 for($i = intval($min); $i<=$max; $i++
) {
197 /** Make a where clause to get a user's sessions.
198 * Prepare the where clause request that will retrieve the sessions.
200 * @param $year INTEGER Only get log entries made during the given year.
201 * @param $month INTEGER Only get log entries made during the given month.
202 * @param $day INTEGER Only get log entries made during the given day.
203 * @param $uid INTEGER Only get log entries referring to the given user ID.
205 * @return STRING the WHERE clause of a query, including the 'WHERE' keyword
208 function _makeWhere($year, $month, $day, $uid)
210 // start constructing the "where" clause
214 array_push($where, "uid='$uid'");
216 // we were given at least a year
219 $dmin = mktime(0, 0, 0, $month, $day, $year);
220 $dmax = mktime(0, 0, 0, $month, $day+
1, $year);
222 $dmin = mktime(0, 0, 0, $month, 1, $year);
223 $dmax = mktime(0, 0, 0, $month+
1, 1, $year);
225 $dmin = mktime(0, 0, 0, 1, 1, $year);
226 $dmax = mktime(0, 0, 0, 1, 1, $year+
1);
228 $where[] = "start >= " . date("Ymd000000", $dmin);
229 $where[] = "start < " . date("Ymd000000", $dmax);
232 if (!empty($where)) {
233 return ' WHERE ' . implode($where, " AND ");
237 // WE know it's totally reversed, so better use array_reverse than a SORT BY start DESC
242 function handler_logger(&$page, $action = null
, $arg = null
) {
243 if ($action == 'session') {
245 // we are viewing a session
246 $res = XDB
::query("SELECT ls.*, a.alias AS username, sa.alias AS suer
247 FROM logger.sessions AS ls
248 LEFT JOIN aliases AS a ON (a.id = ls.uid AND a.type='a_vie')
249 LEFT JOIN aliases AS sa ON (sa.id = ls.suid AND sa.type='a_vie')
250 WHERE ls.id = {?}", $arg);
252 $page->assign('session', $a = $res->fetchOneAssoc());
254 $res = XDB
::iterator('SELECT a.text, e.data, UNIX_TIMESTAMP(e.stamp) AS stamp
255 FROM logger.events AS e
256 LEFT JOIN logger.actions AS a ON e.action=a.id
257 WHERE e.session={?}', $arg);
258 while ($myarr = $res->next()) {
259 $page->append('events', $myarr);
263 $loguser = $action == 'user' ?
$arg : Env
::v('loguser');
265 $res = XDB
::query('SELECT id FROM aliases WHERE alias={?}',
267 $loguid = $res->fetchOneCell();
270 $year = Env
::i('year');
271 $month = Env
::i('month');
272 $day = Env
::i('day');
274 $year = Env
::i('year', intval(date('Y')));
275 $month = Env
::i('month', intval(date('m')));
276 $day = Env
::i('day', intval(date('d')));
284 // smarty assignments
285 // retrieve available years
286 $page->assign('years', $this->_getYears());
287 $page->assign('year', $year);
289 // retrieve available months for the current year
290 $page->assign('months', $this->_getMonths($year));
291 $page->assign('month', $month);
293 // retrieve available days for the current year and month
294 $page->assign('days', $this->_getDays($year, $month));
295 $page->assign('day', $day);
297 $page->assign('loguser', $loguser);
298 // smarty assignments
300 if ($loguid ||
$year) {
302 // get the requested sessions
303 $where = $this->_makeWhere($year, $month, $day, $loguid);
304 $select = "SELECT s.id, UNIX_TIMESTAMP(s.start) as start, s.uid,
306 FROM logger.sessions AS s
307 LEFT JOIN aliases AS a ON (a.id = s.uid AND a.type='a_vie')
309 ORDER BY start DESC";
310 $res = XDB
::iterator($select);
313 while ($mysess = $res->next()) {
314 $mysess['events'] = array();
315 $sessions[$mysess['id']] = $mysess;
317 array_reverse($sessions);
320 $sql = "SELECT s.id, a.text
321 FROM logger.sessions AS s
322 LEFT JOIN logger.events AS e ON(e.session=s.id)
323 INNER JOIN logger.actions AS a ON(a.id=e.action)
326 $res = XDB
::iterator($sql);
327 while ($event = $res->next()) {
328 array_push($sessions[$event['id']]['events'], $event['text']);
330 $page->assign_by_ref('sessions', $sessions);
332 $page->assign('msg_nofilters', "Sélectionner une annuée et/ou un utilisateur");
336 $page->changeTpl('logger-view.tpl');
338 $page->assign('xorg_title','Polytechnique.org - Administration - Logs des sessions');
341 function handler_user(&$page, $login = false
) {
342 $page->changeTpl('admin/utilisateurs.tpl');
343 $page->assign('xorg_title','Polytechnique.org - Administration - Edit/Su/Log');
344 require_once("emails.inc.php");
345 require_once("user.func.inc.php");
347 if (S
::has('suid')) {
348 $page->kill("déjà en SUID !!!");
351 if (Env
::has('user_id')) {
352 $login = get_user_login(Env
::i('user_id'));
353 } elseif (Env
::has('login')) {
354 $login = get_user_login(Env
::v('login'));
357 if(Env
::has('logs_button') && $login) {
358 pl_redirect("admin/logger?login=$login&year=".date('Y')."&month=".date('m'));
361 if (Env
::has('ax_button') && $login) {
362 pl_redirect("admin/synchro_ax/$login");
365 if(Env
::has('suid_button') && $login) {
366 $_SESSION['log']->log("suid_start", "login by ".S
::v('forlife'));
367 $_SESSION['suid'] = $_SESSION;
368 $r = XDB
::query("SELECT id FROM aliases WHERE alias={?}", $login);
369 if($uid = $r->fetchOneCell()) {
370 start_connexion($uid,true
);
376 $r = XDB
::query("SELECT *, a.alias AS forlife, u.flags AS sexe
377 FROM auth_user_md5 AS u
378 INNER JOIN aliases AS a ON ( a.id = u.user_id AND a.alias={?} AND type!='homonyme' )", $login);
379 $mr = $r->fetchOneAssoc();
381 $redirect = new Redirect($mr['user_id']);
383 // Check if there was a submission
384 foreach($_POST as $key => $val) {
387 $email = trim(Env
::v('email'));
388 if (!isvalid_email_redirection($email)) {
389 $page->trig("invalid email $email");
391 $redirect->add_email($email);
392 $page->trig("Ajout de $email effectué");
398 $redirect->delete_email($val);
404 XDB
::execute("DELETE FROM aliases WHERE id={?} AND alias={?}
405 AND type!='a_vie' AND type!='homonyme'", $mr['user_id'], $val);
406 XDB
::execute("UPDATE emails
408 WHERE uid = {?} AND rewrite LIKE CONCAT({?}, '@%')",
409 $mr['user_id'], $val);
410 fix_bestalias($mr['user_id']);
411 $page->trig($val." a été supprimé");
416 $redirect->modify_one_email($val, true
);
419 case "deactivate_fwd":
421 $redirect->modify_one_email($val, false
);
425 XDB
::execute("INSERT INTO aliases (id,alias,type) VALUES ({?}, {?}, 'alias')",
426 $mr['user_id'], Env
::v('email'));
430 // 'bestalias' is the first bit of the set : 1
431 // 255 is the max for flags (8 sets max)
432 XDB
::execute("UPDATE aliases SET flags= flags & (255 - 1) WHERE id={?}", $mr['user_id']);
433 XDB
::execute("UPDATE aliases
435 WHERE id={?} AND alias={?}", $mr['user_id'], $val);
441 require_once('secure_hash.inc.php');
442 $pass_encrypted = Env
::v('newpass_clair') != "********" ?
hash_encrypt(Env
::v('newpass_clair')) : Env
::v('passw');
443 $naiss = Env
::v('naissanceN');
444 $deces = Env
::v('decesN');
445 $perms = Env
::v('permsN');
446 $prenm = Env
::v('prenomN');
447 $nom = Env
::v('nomN');
448 $promo = Env
::i('promoN');
449 $sexe = Env
::v('sexeN');
450 $comm = Env
::v('commentN');
452 $query = "UPDATE auth_user_md5 SET
453 naissance = '$naiss',
455 password = '$pass_encrypted',
457 prenom = '".addslashes($prenm)."',
458 nom = '".addslashes($nom)."',
461 comment = '".addslashes($comm)."'
462 WHERE user_id = '{$mr['user_id']}'";
463 if (XDB
::execute($query)) {
464 user_reindex($mr['user_id']);
466 require_once("diogenes/diogenes.hermes.inc.php");
467 $mailer = new HermesMailer();
468 $mailer->setFrom("webmaster@polytechnique.org");
469 $mailer->addTo("web@polytechnique.org");
470 $mailer->setSubject("INTERVENTION de ".S
::v('forlife'));
471 $mailer->setTxtBody(preg_replace("/[ \t]+/", ' ', $query));
474 $page->trig("updaté correctement.");
476 if (Env
::v('nomusageN') != $mr['nom_usage']) {
477 set_new_usage($mr['user_id'], Env
::v('nomusageN'), make_username(Env
::v('prenomN'), Env
::v('nomusageN')));
479 $r = XDB
::query("SELECT *, a.alias AS forlife, u.flags AS sexe
480 FROM auth_user_md5 AS u
481 INNER JOIN aliases AS a ON (u.user_id=a.id)
482 WHERE user_id = {?}", $mr['user_id']);
483 $mr = $r->fetchOneAssoc();
486 // DELETE FROM auth_user_md5
488 user_clear_all_subs($mr['user_id']);
489 $page->trig("'{$mr['user_id']}' a été désinscrit !");
490 require_once("diogenes/diogenes.hermes.inc.php");
491 $mailer = new HermesMailer();
492 $mailer->setFrom("webmaster@polytechnique.org");
493 $mailer->addTo("web@polytechnique.org");
494 $mailer->setSubject("INTERVENTION de ".S
::v('forlife'));
495 $mailer->setTxtBody("\nUtilisateur $login effacé");
501 $res = XDB
::query("SELECT UNIX_TIMESTAMP(start), host
503 WHERE uid={?} AND suid=0
505 LIMIT 1", $mr['user_id']);
506 list($lastlogin,$host) = $res->fetchOneRow();
507 $page->assign('lastlogin', $lastlogin);
508 $page->assign('host', $host);
510 $page->assign('aliases', XDB
::iterator(
511 "SELECT alias, type='a_vie' AS for_life,FIND_IN_SET('bestalias',flags) AS best,expire
513 WHERE id = {?} AND type!='homonyme'
514 ORDER BY type!= 'a_vie'", $mr["user_id"]));
515 $page->assign('emails',$redirect->emails
);
517 $page->assign('mr',$mr);
520 function handler_homonyms(&$page, $op = 'list', $target = null
) {
521 $page->changeTpl('admin/homonymes.tpl');
522 $page->assign('xorg_title','Polytechnique.org - Administration - Homonymes');
523 require_once("homonymes.inc.php");
526 if (! list($prenom,$nom,$forlife,$loginbis) = select_if_homonyme($target)) {
529 $page->assign('nom',$nom);
530 $page->assign('prenom',$prenom);
531 $page->assign('forlife',$forlife);
532 $page->assign('loginbis',$loginbis);
536 $page->assign('op',$op);
537 $page->assign('target',$target);
539 // on a un $target valide, on prepare les mails
542 // on examine l'op a effectuer
545 send_warning_homonyme($prenom, $nom, $forlife, $loginbis);
546 switch_bestalias($target, $loginbis);
550 switch_bestalias($target, $loginbis);
551 XDB
::execute("UPDATE aliases SET type='homonyme',expire=NOW() WHERE alias={?}", $loginbis);
552 XDB
::execute("REPLACE INTO homonymes (homonyme_id,user_id) VALUES({?},{?})", $target, $target);
553 send_robot_homonyme($prenom, $nom, $forlife, $loginbis);
560 $res = XDB
::iterator(
561 "SELECT a.alias AS homonyme,s.id AS user_id,s.alias AS forlife,
563 IF(h.homonyme_id=s.id, a.expire, NULL) AS expire,
564 IF(h.homonyme_id=s.id, a.type, NULL) AS type
566 LEFT JOIN homonymes AS h ON (h.homonyme_id = a.id)
567 INNER JOIN aliases AS s ON (s.id = h.user_id AND s.type='a_vie')
568 INNER JOIN auth_user_md5 AS u ON (s.id=u.user_id)
569 WHERE a.type='homonyme' OR a.expire!=''
570 ORDER BY a.alias,promo");
572 while ($tab = $res->next()) {
573 $hnymes[$tab['homonyme']][] = $tab;
575 $page->assign_by_ref('hnymes',$hnymes);
579 function handler_ax_xorg(&$page) {
580 $page->changeTpl('admin/ax-xorg.tpl');
581 $page->assign('xorg_title','Polytechnique.org - Administration - AX/X.org');
583 // liste des différences
585 'SELECT u.promo,u.nom AS nom,u.prenom AS prenom,ia.nom AS nomax,ia.prenom AS prenomax,u.matricule AS mat,ia.matricule_ax AS matax
586 FROM auth_user_md5 AS u
587 INNER JOIN identification_ax AS ia ON u.matricule_ax = ia.matricule_ax
588 WHERE (SOUNDEX(u.nom) != SOUNDEX(ia.nom) AND SOUNDEX(CONCAT(ia.particule,u.nom)) != SOUNDEX(ia.nom)
589 AND SOUNDEX(u.nom) != SOUNDEX(ia.nom_patro) AND SOUNDEX(CONCAT(ia.particule,u.nom)) != SOUNDEX(ia.nom_patro))
590 OR u.prenom != ia.prenom OR (u.promo != ia.promo AND u.promo != ia.promo+1 AND u.promo != ia.promo-1)
591 ORDER BY u.promo,u.nom,u.prenom');
592 $page->assign('diffs', $res->fetchAllAssoc());
594 // gens à l'ax mais pas chez nous
596 'SELECT ia.promo,ia.nom,ia.nom_patro,ia.prenom
597 FROM identification_ax as ia
598 LEFT JOIN auth_user_md5 AS u ON u.matricule_ax = ia.matricule_ax
599 WHERE u.nom IS NULL');
600 $page->assign('mank', $res->fetchAllAssoc());
602 // gens chez nous et pas à l'ax
603 $res = XDB
::query('SELECT promo,nom,prenom FROM auth_user_md5 WHERE matricule_ax IS NULL');
604 $page->assign('plus', $res->fetchAllAssoc());
607 function handler_deaths(&$page, $promo = 0, $validate = false
) {
608 $page->changeTpl('admin/deces_promo.tpl');
609 $page->assign('xorg_title','Polytechnique.org - Administration - Deces');
612 $promo = Env
::i('promo');
613 if (Env
::has('sub10')) $promo -= 10;
614 if (Env
::has('sub01')) $promo -= 1;
615 if (Env
::has('add01')) $promo +
= 1;
616 if (Env
::has('add10')) $promo +
= 10;
618 $page->assign('promo',$promo);
621 $new_deces = array();
622 $res = XDB
::iterRow("SELECT user_id,matricule,nom,prenom,deces FROM auth_user_md5 WHERE promo = {?}", $promo);
623 while (list($uid,$mat,$nom,$prenom,$deces) = $res->next()) {
625 if($val == $deces ||
empty($val)) continue;
626 XDB
::execute('UPDATE auth_user_md5 SET deces={?} WHERE matricule = {?}', $val, $mat);
627 $new_deces[] = array('name' => "$prenom $nom", 'date' => "$val");
628 if($deces=='0000-00-00' or empty($deces)) {
629 require_once('notifs.inc.php');
630 register_watch_op($uid, WATCH_DEATH
, $val);
631 require_once('user.func.inc.php');
632 user_clear_all_subs($uid, false
); // by default, dead ppl do not loose their email
635 $page->assign('new_deces',$new_deces);
638 $res = XDB
::iterator('SELECT matricule, nom, prenom, deces FROM auth_user_md5 WHERE promo = {?} ORDER BY nom,prenom', $promo);
639 $page->assign('decedes', $res);
642 function handler_synchro_ax(&$page, $user = null
, $action = null
) {
643 $page->changeTpl('admin/synchro_ax.tpl');
644 $page->assign('xorg_title','Polytechnique.org - Administration - Synchro AX');
646 require_once('synchro_ax.inc.php');
648 if (is_ax_key_missing()) {
649 $page->assign('no_private_key', true
);
653 require_once('user.func.inc.php');
656 $login = get_user_forlife($user);
658 if (Env
::has('user')) {
659 $login = get_user_forlife(Env
::v('user'));
660 if ($login === false
) {
665 if (Env
::has('mat')) {
669 INNER JOIN auth_user_md5 AS u ON (a.id=u.user_id AND a.type='a_vie')
670 WHERE matricule={?}", Env
::i('mat'));
671 $login = $res->fetchOneCell();
675 if ($action == 'import') {
676 ax_synchronize($login, S
::v('uid'));
678 // get details from user, but looking only info that can be seen by ax
679 $user = get_user_details($login, S
::v('uid'), 'ax');
680 $userax= get_user_ax($user['matricule_ax']);
681 require_once 'profil.func.inc.php';
682 $diff = diff_user_details($userax, $user, 'ax');
684 $page->assign('x', $user);
685 $page->assign('diff', $diff);
689 function handler_validate(&$page, $action = 'list', $id = null
) {
690 $page->changeTpl('admin/valider.tpl');
691 $page->assign('xorg_title','Polytechnique.org - Administration - Valider une demande');
692 require_once("validations.inc.php");
694 if ($action == 'edit' and !is_null($id)) {
695 $page->assign('preview_id', $id);
698 if(Env
::has('uid') && Env
::has('type') && Env
::has('stamp')) {
699 $req = Validate
::get_request(Env
::v('uid'), Env
::v('type'), Env
::v('stamp'));
700 if($req) { $req->handle_formu(); }
703 $r = XDB
::iterator('SHOW COLUMNS FROM requests_answers');
704 while (($a = $r->next()) && $a['Field'] != 'category');
705 $page->assign('categories', $categories = explode(',', str_replace("'", '', substr($a['Type'], 5, -1))));
708 if (Post
::has('hide')) {
710 foreach ($categories as $cat)
711 if (!Post
::v($cat)) {
715 setcookie('hide_requests', join(',',$hide), time()+
(count($hide)?
25920000:(-3600)), '/', '', 0);
716 } elseif (Env
::has('hide_requests')) {
717 foreach (explode(',',Env
::v('hide_requests')) as $hide_type)
718 $hidden[$hide_type] = true
;
720 $page->assign('hide_requests', $hidden);
722 $page->assign('vit', new ValidateIterator());
724 function handler_validate_answers(&$page, $action = 'list', $id = null
) {
725 $page->assign('xorg_title','Polytechnique.org - Administration - Réponses automatiques de validation');
726 $page->assign('title', 'Gestion des réponses automatiques');
727 $table_editor = new PLTableEditor('admin/validate/answers','requests_answers','id');
728 $table_editor->describe('category','catégorie',true
);
729 $table_editor->describe('title','titre',true
);
730 $table_editor->describe('answer','texte',false
);
731 $table_editor->apply($page, $action, $id);
733 function handler_skins(&$page, $action = 'list', $id = null
) {
734 $page->assign('xorg_title','Polytechnique.org - Administration - Skins');
735 $page->assign('title', 'Gestion des skins');
736 $table_editor = new PLTableEditor('admin/skins','skins','id');
737 $table_editor->describe('name','nom',true
);
738 $table_editor->describe('skin_tpl','nom du template',true
);
739 $table_editor->describe('auteur','auteur',false
);
740 $table_editor->describe('comment','commentaire',true
);
741 $table_editor->describe('date','date',false
);
742 $table_editor->describe('ext','extension du screenshot',false
);
743 $table_editor->apply($page, $action, $id);
745 function handler_postfix_blacklist(&$page, $action = 'list', $id = null
) {
746 $page->assign('xorg_title','Polytechnique.org - Administration - Postfix : Blacklist');
747 $page->assign('title', 'Blacklist de postfix');
748 $table_editor = new PLTableEditor('admin/postfix/blacklist','postfix_blacklist','email', true
);
749 $table_editor->describe('reject_text','Texte de rejet',true
);
750 $table_editor->describe('email','email',true
);
751 $table_editor->apply($page, $action, $id);
753 function handler_postfix_whitelist(&$page, $action = 'list', $id = null
) {
754 $page->assign('xorg_title','Polytechnique.org - Administration - Postfix : Whitelist');
755 $page->assign('title', 'Whitelist de postfix');
756 $table_editor = new PLTableEditor('admin/postfix/whitelist','postfix_whitelist','email', true
);
757 $table_editor->describe('email','email',true
);
758 $table_editor->apply($page, $action, $id);
760 function handler_logger_actions(&$page, $action = 'list', $id = null
) {
761 $page->assign('xorg_title','Polytechnique.org - Administration - Actions');
762 $page->assign('title', 'Gestion des actions de logger');
763 $table_editor = new PLTableEditor('admin/logger/actions','logger.actions','id');
764 $table_editor->describe('text','intitulé',true
);
765 $table_editor->describe('description','description',true
);
766 $table_editor->apply($page, $action, $id);
768 function handler_downtime(&$page, $action = 'list', $id = null
) {
769 $page->assign('xorg_title','Polytechnique.org - Administration - Coupures');
770 $page->assign('title', 'Gestion des coupures');
771 $table_editor = new PLTableEditor('admin/downtime','coupures','id');
772 $table_editor->describe('debut','date',true
);
773 $table_editor->describe('duree','durée',false
);
774 $table_editor->describe('resume','résumé',true
);
775 $table_editor->describe('services','services affectés',true
);
776 $table_editor->describe('description','description',false
);
777 $table_editor->apply($page, $action, $id);
779 function handler_wiki(&$page, $action='list') {
780 require_once 'wiki.inc.php';
783 if ($action == 'update') {
784 $perms_read = Post
::v('read');
785 $perms_edot = Post
::v('edit');
786 if ($perms_read ||
$perms_edit) {
787 foreach ($_POST as $wiki_page => $val) if ($val == 'on') {
788 $wiki_page = str_replace('_', '/', $wiki_page);
789 if (!$perms_read ||
!$perms_edit)
790 list($perms0, $perms1) = wiki_get_perms($wiki_page);
792 $perms0 = $perms_read;
794 $perms1 = $perms_edit;
795 wiki_set_perms($wiki_page, $perms0, $perms1);
800 $perms = wiki_perms_options();
802 // list wiki pages and their perms
803 $wiki_pages = array();
804 $dir = wiki_work_dir();
806 if ($dh = opendir($dir)) {
807 while (($file = readdir($dh)) !== false
) if (substr($file,0,1) >= 'A' && substr($file,0,1) <= 'Z') {
808 list($read,$edit) = wiki_get_perms($file);
809 $wiki_pages[$file] = array('read' => $perms[$read], 'edit' => $perms[$edit]);
816 $page->changeTpl('admin/wiki.tpl');
817 $page->assign('wiki_pages', $wiki_pages);
818 $page->assign('perms_opts', $perms);