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 'phpinfo' => $this->make_hook('phpinfo', AUTH_MDP
, 'admin'),
28 'admin' => $this->make_hook('default', AUTH_MDP
, 'admin'),
29 'admin/ax-xorg' => $this->make_hook('ax_xorg', AUTH_MDP
, 'admin'),
30 'admin/deaths' => $this->make_hook('deaths', AUTH_MDP
, 'admin'),
31 'admin/downtime' => $this->make_hook('downtime', AUTH_MDP
, 'admin'),
32 'admin/homonyms' => $this->make_hook('homonyms', AUTH_MDP
, 'admin'),
33 'admin/logger' => $this->make_hook('logger', AUTH_MDP
, 'admin'),
34 'admin/logger/actions' => $this->make_hook('logger_actions', AUTH_MDP
, 'admin'),
35 'admin/postfix/blacklist' => $this->make_hook('postfix_blacklist', AUTH_MDP
, 'admin'),
36 'admin/postfix/delayed' => $this->make_hook('postfix_delayed', AUTH_MDP
, 'admin'),
37 'admin/postfix/regexp_bounces' => $this->make_hook('postfix_regexpsbounces', AUTH_MDP
, 'admin'),
38 'admin/postfix/whitelist' => $this->make_hook('postfix_whitelist', AUTH_MDP
, 'admin'),
39 'admin/skins' => $this->make_hook('skins', AUTH_MDP
, 'admin'),
40 'admin/synchro_ax' => $this->make_hook('synchro_ax', AUTH_MDP
, 'admin'),
41 'admin/user' => $this->make_hook('user', AUTH_MDP
, 'admin'),
42 'admin/validate' => $this->make_hook('validate', AUTH_MDP
, 'admin'),
43 'admin/validate/answers' => $this->make_hook('validate_answers', AUTH_MDP
, 'admin'),
44 'admin/wiki' => $this->make_hook('wiki', AUTH_MDP
, 'admin'),
48 function handler_phpinfo(&$page)
54 function handler_default(&$page)
56 $page->changeTpl('admin/index.tpl');
57 $page->assign('xorg_title','Polytechnique.org - Administration');
60 function handler_postfix_delayed(&$page)
62 $page->changeTpl('admin/postfix_delayed.tpl');
63 $page->assign('xorg_title','Polytechnique.org - Administration - Postfix : Retardés');
65 if (Env
::has('del')) {
67 XDB
::execute("UPDATE postfix_mailseen SET release = 'del' WHERE crc = {?}", $crc);
68 $page->trig($crc." verra tous ses mails supprimés !");
69 } elseif (Env
::has('ok')) {
71 XDB
::execute("UPDATE postfix_mailseen SET release = 'ok' WHERE crc = {?}", $crc);
72 $page->trig($crc." a le droit de passer !");
76 "SELECT crc, nb, update_time, create_time,
77 FIND_IN_SET('del', release) AS del,
78 FIND_IN_SET('ok', release) AS ok
81 ORDER BY release != ''");
83 $page->assign_by_ref('mails', $sql);
86 function handler_postfix_regexpsbounces(&$page, $new = null
) {
87 $page->changeTpl('admin/emails_bounces_re.tpl');
88 $page->assign('xorg_title','Polytechnique.org - Administration - Postfix : Regexps Bounces');
89 $page->assign('new', $new);
91 if (Post
::has('submit')) {
92 foreach (Env
::v('lvl') as $id=>$val) {
94 "REPLACE INTO emails_bounces_re (id,pos,lvl,re,text) VALUES ({?}, {?}, {?}, {?}, {?})",
95 $id, $_POST['pos'][$id], $_POST['lvl'][$id], $_POST['re'][$id], $_POST['text'][$id]
100 $page->assign('bre', XDB
::iterator("SELECT * FROM emails_bounces_re ORDER BY pos"));
105 /** Retrieves the available days for a given year and month.
106 * Obtain a list of days of the given month in the given year
107 * that are within the range of dates that we have log entries for.
109 * @param integer year
110 * @param integer month
111 * @return array days in that month we have log entries covering.
114 function _getDays($year, $month)
116 // give a 'no filter' option
119 if ($year && $month) {
120 $day_max = Array(-1, 31, checkdate(2, 29, $year) ?
29 : 28 , 31,
121 30, 31, 30, 31, 31, 30, 31, 30, 31);
122 $res = XDB
::query("SELECT YEAR (MAX(start)), YEAR (MIN(start)),
123 MONTH(MAX(start)), MONTH(MIN(start)),
124 DAYOFMONTH(MAX(start)),
125 DAYOFMONTH(MIN(start))
126 FROM logger.sessions");
127 list($ymax, $ymin, $mmax, $mmin, $dmax, $dmin) = $res->fetchOneRow();
129 if (($year < $ymin) ||
($year == $ymin && $month < $mmin)) {
133 if (($year > $ymax) ||
($year == $ymax && $month > $mmax)) {
137 $min = ($year==$ymin && $month==$mmin) ?
intval($dmin) : 1;
138 $max = ($year==$ymax && $month==$mmax) ?
intval($dmax) : $day_max[$month];
140 for($i = $min; $i<=$max; $i++
) {
148 /** Retrieves the available months for a given year.
149 * Obtains a list of month numbers that are within the timeframe that
150 * we have log entries for.
152 * @param integer year
153 * @return array List of month numbers we have log info for.
156 function _getMonths($year)
158 // give a 'no filter' option
162 $res = XDB
::query("SELECT YEAR (MAX(start)), YEAR (MIN(start)),
163 MONTH(MAX(start)), MONTH(MIN(start))
164 FROM logger.sessions");
165 list($ymax, $ymin, $mmax, $mmin) = $res->fetchOneRow();
167 if (($year < $ymin) ||
($year > $ymax)) {
171 $min = $year == $ymin ?
intval($mmin) : 1;
172 $max = $year == $ymax ?
intval($mmax) : 12;
174 for($i = $min; $i<=$max; $i++
) {
182 /** Retrieves the available years.
183 * Obtains a list of years that we have log entries covering.
185 * @return array years we have log entries for.
190 // give a 'no filter' option
193 // retrieve available years
194 $res = XDB
::query("select YEAR(MAX(start)), YEAR(MIN(start)) FROM logger.sessions");
195 list($max, $min) = $res->fetchOneRow();
197 for($i = intval($min); $i<=$max; $i++
) {
204 /** Make a where clause to get a user's sessions.
205 * Prepare the where clause request that will retrieve the sessions.
207 * @param $year INTEGER Only get log entries made during the given year.
208 * @param $month INTEGER Only get log entries made during the given month.
209 * @param $day INTEGER Only get log entries made during the given day.
210 * @param $uid INTEGER Only get log entries referring to the given user ID.
212 * @return STRING the WHERE clause of a query, including the 'WHERE' keyword
215 function _makeWhere($year, $month, $day, $uid)
217 // start constructing the "where" clause
221 array_push($where, "uid='$uid'");
223 // we were given at least a year
226 $dmin = mktime(0, 0, 0, $month, $day, $year);
227 $dmax = mktime(0, 0, 0, $month, $day+
1, $year);
229 $dmin = mktime(0, 0, 0, $month, 1, $year);
230 $dmax = mktime(0, 0, 0, $month+
1, 1, $year);
232 $dmin = mktime(0, 0, 0, 1, 1, $year);
233 $dmax = mktime(0, 0, 0, 1, 1, $year+
1);
235 $where[] = "start >= " . date("Ymd000000", $dmin);
236 $where[] = "start < " . date("Ymd000000", $dmax);
239 if (!empty($where)) {
240 return ' WHERE ' . implode($where, " AND ");
244 // WE know it's totally reversed, so better use array_reverse than a SORT BY start DESC
249 function handler_logger(&$page, $action = null
, $arg = null
) {
250 if ($action == 'session') {
252 // we are viewing a session
253 $res = XDB
::query("SELECT ls.*, a.alias AS username, sa.alias AS suer
254 FROM logger.sessions AS ls
255 LEFT JOIN aliases AS a ON (a.id = ls.uid AND a.type='a_vie')
256 LEFT JOIN aliases AS sa ON (sa.id = ls.suid AND sa.type='a_vie')
257 WHERE ls.id = {?}", $arg);
259 $page->assign('session', $a = $res->fetchOneAssoc());
261 $res = XDB
::iterator('SELECT a.text, e.data, e.stamp
262 FROM logger.events AS e
263 LEFT JOIN logger.actions AS a ON e.action=a.id
264 WHERE e.session={?}', $arg);
265 while ($myarr = $res->next()) {
266 $page->append('events', $myarr);
270 $loguser = $action == 'user' ?
$arg : Env
::v('loguser');
272 $res = XDB
::query('SELECT id FROM aliases WHERE alias={?}',
274 $loguid = $res->fetchOneCell();
277 $year = Env
::i('year');
278 $month = Env
::i('month');
279 $day = Env
::i('day');
281 $year = Env
::i('year', intval(date('Y')));
282 $month = Env
::i('month', intval(date('m')));
283 $day = Env
::i('day', intval(date('d')));
291 // smarty assignments
292 // retrieve available years
293 $page->assign('years', $this->_getYears());
294 $page->assign('year', $year);
296 // retrieve available months for the current year
297 $page->assign('months', $this->_getMonths($year));
298 $page->assign('month', $month);
300 // retrieve available days for the current year and month
301 $page->assign('days', $this->_getDays($year, $month));
302 $page->assign('day', $day);
304 $page->assign('loguser', $loguser);
305 // smarty assignments
307 if ($loguid ||
$year) {
309 // get the requested sessions
310 $where = $this->_makeWhere($year, $month, $day, $loguid);
311 $select = "SELECT s.id, s.start, s.uid,
313 FROM logger.sessions AS s
314 LEFT JOIN aliases AS a ON (a.id = s.uid AND a.type='a_vie')
316 ORDER BY start DESC";
317 $res = XDB
::iterator($select);
320 while ($mysess = $res->next()) {
321 $mysess['events'] = array();
322 $sessions[$mysess['id']] = $mysess;
324 array_reverse($sessions);
327 $sql = "SELECT s.id, a.text
328 FROM logger.sessions AS s
329 LEFT JOIN logger.events AS e ON(e.session=s.id)
330 INNER JOIN logger.actions AS a ON(a.id=e.action)
333 $res = XDB
::iterator($sql);
334 while ($event = $res->next()) {
335 array_push($sessions[$event['id']]['events'], $event['text']);
337 $page->assign_by_ref('sessions', $sessions);
339 $page->assign('msg_nofilters', "Sélectionner une annuée et/ou un utilisateur");
343 $page->changeTpl('logger-view.tpl');
345 $page->assign('xorg_title','Polytechnique.org - Administration - Logs des sessions');
348 function handler_user(&$page, $login = false
)
350 $page->changeTpl('admin/utilisateurs.tpl');
351 $page->assign('xorg_title','Polytechnique.org - Administration - Edit/Su/Log');
352 require_once("emails.inc.php");
353 require_once("user.func.inc.php");
355 if (S
::has('suid')) {
356 $page->kill("déjà en SUID !!!");
359 if (Env
::has('user_id')) {
360 $login = get_user_login(Env
::i('user_id'));
362 $login = Env
::i('user_id');
364 } elseif (Env
::has('login')) {
365 $login = get_user_login(Env
::v('login'));
368 if(Env
::has('logs_button') && $login) {
369 pl_redirect("admin/logger?loguser=$login&year=".date('Y')."&month=".date('m'));
372 if (Env
::has('ax_button') && $login) {
373 pl_redirect("admin/synchro_ax/$login");
376 if(Env
::has('suid_button') && $login) {
377 $_SESSION['log']->log("suid_start", "login by ".S
::v('forlife'));
378 $_SESSION['suid'] = $_SESSION;
379 $r = XDB
::query("SELECT id FROM aliases WHERE alias={?}", $login);
380 if($uid = $r->fetchOneCell()) {
381 start_connexion($uid,true
);
387 if (is_numeric($login)) {
388 $r = XDB
::query("SELECT *, a.alias AS forlife, u.flags AS sexe,
389 (year(naissance) > promo - 15 or year(naissance) < promo - 25) AS naiss_err
390 FROM auth_user_md5 AS u
391 LEFT JOIN aliases AS a ON (a.id = u.user_id AND type= 'a_vie')
392 WHERE u.user_id = {?}", $login);
394 $r = XDB
::query("SELECT *, a.alias AS forlife, u.flags AS sexe,
395 (year(naissance) > promo - 15 or year(naissance) < promo - 25) AS naiss_err
396 FROM auth_user_md5 AS u
397 INNER JOIN aliases AS a ON ( a.id = u.user_id AND a.alias={?} AND type!='homonyme' )", $login);
399 $mr = $r->fetchOneAssoc();
401 if (!is_numeric($login)) { //user has a forlife
402 $redirect = new Redirect($mr['user_id']);
405 // Check if there was a submission
406 foreach($_POST as $key => $val) {
409 $email = trim(Env
::v('email'));
410 if (!isvalid_email_redirection($email)) {
411 $page->trig("invalid email $email");
413 $redirect->add_email($email);
414 $page->trig("Ajout de $email effectué");
420 $redirect->delete_email($val);
426 XDB
::execute("DELETE FROM aliases
427 WHERE id={?} AND alias={?}
428 AND type!='a_vie' AND type!='homonyme'", $mr['user_id'], $val);
429 XDB
::execute("UPDATE emails
431 WHERE uid = {?} AND rewrite LIKE CONCAT({?}, '@%')",
432 $mr['user_id'], $val);
433 fix_bestalias($mr['user_id']);
434 $page->trig($val." a été supprimé");
439 $redirect->modify_one_email($val, true
);
442 case "deactivate_fwd":
444 $redirect->modify_one_email($val, false
);
448 XDB
::execute("INSERT INTO aliases (id,alias,type) VALUES ({?}, {?}, 'alias')",
449 $mr['user_id'], Env
::v('email'));
453 // 'bestalias' is the first bit of the set : 1
454 // 255 is the max for flags (8 sets max)
455 XDB
::execute("UPDATE aliases SET flags= flags & (255 - 1) WHERE id={?}", $mr['user_id']);
456 XDB
::execute("UPDATE aliases
458 WHERE id={?} AND alias={?}", $mr['user_id'], $val);
464 require_once('secure_hash.inc.php');
465 $pass_encrypted = Env
::v('newpass_clair') != "********" ?
hash_encrypt(Env
::v('newpass_clair')) : Env
::v('passw');
466 $naiss = Env
::v('naissanceN');
467 $deces = Env
::v('decesN');
468 $perms = Env
::v('permsN');
469 $prenm = Env
::v('prenomN');
470 $nom = Env
::v('nomN');
471 $promo = Env
::i('promoN');
472 $sexe = Env
::v('sexeN');
473 $comm = Env
::v('commentN');
475 $query = "UPDATE auth_user_md5 SET
476 naissance = '$naiss',
478 password = '$pass_encrypted',
480 prenom = '".addslashes($prenm)."',
481 nom = '".addslashes($nom)."',
484 comment = '".addslashes($comm)."'
485 WHERE user_id = '{$mr['user_id']}'";
486 if (XDB
::execute($query)) {
487 user_reindex($mr['user_id']);
489 $mailer = new PlMailer();
490 $mailer->setFrom("webmaster@polytechnique.org");
491 $mailer->addTo("web@polytechnique.org");
492 $mailer->setSubject("INTERVENTION de ".S
::v('forlife'));
493 $mailer->setTxtBody(preg_replace("/[ \t]+/", ' ', $query));
496 $page->trig("updaté correctement.");
498 if (Env
::v('nomusageN') != $mr['nom_usage']) {
499 set_new_usage($mr['user_id'], Env
::v('nomusageN'), make_username(Env
::v('prenomN'), Env
::v('nomusageN')));
501 if (Env
::v('decesN') != $mr['deces']) {
502 user_clear_all_subs($mr['user_id'], false
);
504 $r = XDB
::query("SELECT *, a.alias AS forlife, u.flags AS sexe
505 FROM auth_user_md5 AS u
506 LEFT JOIN aliases AS a ON (a.id = u.user_id AND type= 'a_vie')
507 WHERE u.user_id = {?}", $mr['user_id']);
508 $mr = $r->fetchOneAssoc();
511 // DELETE FROM auth_user_md5
513 user_clear_all_subs($mr['user_id']);
514 $page->trig("'{$mr['user_id']}' a été désinscrit !");
515 $mailer = new PlMailer();
516 $mailer->setFrom("webmaster@polytechnique.org");
517 $mailer->addTo("web@polytechnique.org");
518 $mailer->setSubject("INTERVENTION de ".S
::v('forlife'));
519 $mailer->setTxtBody("\nUtilisateur $login effacé");
525 $res = XDB
::query("SELECT start, host
527 WHERE uid={?} AND suid=0
529 LIMIT 1", $mr['user_id']);
530 list($lastlogin,$host) = $res->fetchOneRow();
531 $page->assign('lastlogin', $lastlogin);
532 $page->assign('host', $host);
534 $page->assign('aliases', XDB
::iterator(
535 "SELECT alias, type='a_vie' AS for_life,FIND_IN_SET('bestalias',flags) AS best,expire
537 WHERE id = {?} AND type!='homonyme'
538 ORDER BY type!= 'a_vie'", $mr["user_id"]));
539 if ($mr['perms'] != 'pending') {
540 $page->assign('emails',$redirect->emails
);
543 $page->assign('mr',$mr);
546 function handler_homonyms(&$page, $op = 'list', $target = null
) {
547 $page->changeTpl('admin/homonymes.tpl');
548 $page->assign('xorg_title','Polytechnique.org - Administration - Homonymes');
549 require_once("homonymes.inc.php");
552 if (! list($prenom,$nom,$forlife,$loginbis) = select_if_homonyme($target)) {
555 $page->assign('nom',$nom);
556 $page->assign('prenom',$prenom);
557 $page->assign('forlife',$forlife);
558 $page->assign('loginbis',$loginbis);
562 $page->assign('op',$op);
563 $page->assign('target',$target);
565 // on a un $target valide, on prepare les mails
568 // on examine l'op a effectuer
571 send_warning_homonyme($prenom, $nom, $forlife, $loginbis);
572 switch_bestalias($target, $loginbis);
576 switch_bestalias($target, $loginbis);
577 XDB
::execute("UPDATE aliases SET type='homonyme',expire=NOW() WHERE alias={?}", $loginbis);
578 XDB
::execute("REPLACE INTO homonymes (homonyme_id,user_id) VALUES({?},{?})", $target, $target);
579 send_robot_homonyme($prenom, $nom, $forlife, $loginbis);
586 $res = XDB
::iterator(
587 "SELECT a.alias AS homonyme,s.id AS user_id,s.alias AS forlife,
589 IF(h.homonyme_id=s.id, a.expire, NULL) AS expire,
590 IF(h.homonyme_id=s.id, a.type, NULL) AS type
592 LEFT JOIN homonymes AS h ON (h.homonyme_id = a.id)
593 INNER JOIN aliases AS s ON (s.id = h.user_id AND s.type='a_vie')
594 INNER JOIN auth_user_md5 AS u ON (s.id=u.user_id)
595 WHERE a.type='homonyme' OR a.expire!=''
596 ORDER BY a.alias,promo");
598 while ($tab = $res->next()) {
599 $hnymes[$tab['homonyme']][] = $tab;
601 $page->assign_by_ref('hnymes',$hnymes);
605 function handler_ax_xorg(&$page) {
606 $page->changeTpl('admin/ax-xorg.tpl');
607 $page->assign('xorg_title','Polytechnique.org - Administration - AX/X.org');
609 // liste des différences
611 '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
612 FROM auth_user_md5 AS u
613 INNER JOIN identification_ax AS ia ON u.matricule_ax = ia.matricule_ax
614 WHERE (SOUNDEX(u.nom) != SOUNDEX(ia.nom) AND SOUNDEX(CONCAT(ia.particule,u.nom)) != SOUNDEX(ia.nom)
615 AND SOUNDEX(u.nom) != SOUNDEX(ia.nom_patro) AND SOUNDEX(CONCAT(ia.particule,u.nom)) != SOUNDEX(ia.nom_patro))
616 OR u.prenom != ia.prenom OR (u.promo != ia.promo AND u.promo != ia.promo+1 AND u.promo != ia.promo-1)
617 ORDER BY u.promo,u.nom,u.prenom');
618 $page->assign('diffs', $res->fetchAllAssoc());
620 // gens à l'ax mais pas chez nous
622 'SELECT ia.promo,ia.nom,ia.nom_patro,ia.prenom
623 FROM identification_ax as ia
624 LEFT JOIN auth_user_md5 AS u ON u.matricule_ax = ia.matricule_ax
625 WHERE u.nom IS NULL');
626 $page->assign('mank', $res->fetchAllAssoc());
628 // gens chez nous et pas à l'ax
629 $res = XDB
::query('SELECT promo,nom,prenom FROM auth_user_md5 WHERE matricule_ax IS NULL');
630 $page->assign('plus', $res->fetchAllAssoc());
633 function handler_deaths(&$page, $promo = 0, $validate = false
) {
634 $page->changeTpl('admin/deces_promo.tpl');
635 $page->assign('xorg_title','Polytechnique.org - Administration - Deces');
638 $promo = Env
::i('promo');
639 if (Env
::has('sub10')) $promo -= 10;
640 if (Env
::has('sub01')) $promo -= 1;
641 if (Env
::has('add01')) $promo +
= 1;
642 if (Env
::has('add10')) $promo +
= 10;
644 $page->assign('promo',$promo);
647 $new_deces = array();
648 $res = XDB
::iterRow("SELECT user_id,matricule,nom,prenom,deces FROM auth_user_md5 WHERE promo = {?}", $promo);
649 while (list($uid,$mat,$nom,$prenom,$deces) = $res->next()) {
651 if($val == $deces ||
empty($val)) continue;
652 XDB
::execute('UPDATE auth_user_md5 SET deces={?} WHERE matricule = {?}', $val, $mat);
653 $new_deces[] = array('name' => "$prenom $nom", 'date' => "$val");
654 if($deces=='0000-00-00' or empty($deces)) {
655 require_once('notifs.inc.php');
656 register_watch_op($uid, WATCH_DEATH
, $val);
657 require_once('user.func.inc.php');
658 user_clear_all_subs($uid, false
); // by default, dead ppl do not loose their email
661 $page->assign('new_deces',$new_deces);
664 $res = XDB
::iterator('SELECT matricule, nom, prenom, deces FROM auth_user_md5 WHERE promo = {?} ORDER BY nom,prenom', $promo);
665 $page->assign('decedes', $res);
668 function handler_synchro_ax(&$page, $user = null
, $action = null
) {
669 $page->changeTpl('admin/synchro_ax.tpl');
670 $page->assign('xorg_title','Polytechnique.org - Administration - Synchro AX');
672 require_once('synchro_ax.inc.php');
674 if (is_ax_key_missing()) {
675 $page->assign('no_private_key', true
);
679 require_once('user.func.inc.php');
682 $login = get_user_forlife($user);
684 if (Env
::has('user')) {
685 $login = get_user_forlife(Env
::v('user'));
686 if ($login === false
) {
691 if (Env
::has('mat')) {
695 INNER JOIN auth_user_md5 AS u ON (a.id=u.user_id AND a.type='a_vie')
696 WHERE matricule={?}", Env
::i('mat'));
697 $login = $res->fetchOneCell();
701 if ($action == 'import') {
702 ax_synchronize($login, S
::v('uid'));
704 // get details from user, but looking only info that can be seen by ax
705 $user = get_user_details($login, S
::v('uid'), 'ax');
706 $userax= get_user_ax($user['matricule_ax']);
707 require_once 'profil.func.inc.php';
708 $diff = diff_user_details($userax, $user, 'ax');
710 $page->assign('x', $user);
711 $page->assign('diff', $diff);
715 function handler_validate(&$page, $action = 'list', $id = null
) {
716 $page->changeTpl('admin/valider.tpl');
717 $page->assign('xorg_title','Polytechnique.org - Administration - Valider une demande');
718 require_once("validations.inc.php");
720 if ($action == 'edit' and !is_null($id)) {
721 $page->assign('preview_id', $id);
724 if(Env
::has('uid') && Env
::has('type') && Env
::has('stamp')) {
725 $req = Validate
::get_typed_request(Env
::v('uid'), Env
::v('type'), Env
::v('stamp'));
726 if($req) { $req->handle_formu(); }
729 $r = XDB
::iterator('SHOW COLUMNS FROM requests_answers');
730 while (($a = $r->next()) && $a['Field'] != 'category');
731 $page->assign('categories', $categories = explode(',', str_replace("'", '', substr($a['Type'], 5, -1))));
734 if (Post
::has('hide')) {
736 foreach ($categories as $cat)
737 if (!Post
::v($cat)) {
741 setcookie('hide_requests', join(',',$hide), time()+
(count($hide)?
25920000:(-3600)), '/', '', 0);
742 } elseif (Env
::has('hide_requests')) {
743 foreach (explode(',',Env
::v('hide_requests')) as $hide_type)
744 $hidden[$hide_type] = true
;
746 $page->assign('hide_requests', $hidden);
748 $page->assign('vit', new ValidateIterator());
750 function handler_validate_answers(&$page, $action = 'list', $id = null
) {
751 $page->assign('xorg_title','Polytechnique.org - Administration - Réponses automatiques de validation');
752 $page->assign('title', 'Gestion des réponses automatiques');
753 $table_editor = new PLTableEditor('admin/validate/answers','requests_answers','id');
754 $table_editor->describe('category','catégorie',true
);
755 $table_editor->describe('title','titre',true
);
756 $table_editor->describe('answer','texte',false
);
757 $table_editor->apply($page, $action, $id);
759 function handler_skins(&$page, $action = 'list', $id = null
) {
760 $page->assign('xorg_title','Polytechnique.org - Administration - Skins');
761 $page->assign('title', 'Gestion des skins');
762 $table_editor = new PLTableEditor('admin/skins','skins','id');
763 $table_editor->describe('name','nom',true
);
764 $table_editor->describe('skin_tpl','nom du template',true
);
765 $table_editor->describe('auteur','auteur',false
);
766 $table_editor->describe('comment','commentaire',true
);
767 $table_editor->describe('date','date',false
);
768 $table_editor->describe('ext','extension du screenshot',false
);
769 $table_editor->apply($page, $action, $id);
771 function handler_postfix_blacklist(&$page, $action = 'list', $id = null
) {
772 $page->assign('xorg_title','Polytechnique.org - Administration - Postfix : Blacklist');
773 $page->assign('title', 'Blacklist de postfix');
774 $table_editor = new PLTableEditor('admin/postfix/blacklist','postfix_blacklist','email', true
);
775 $table_editor->describe('reject_text','Texte de rejet',true
);
776 $table_editor->describe('email','email',true
);
777 $table_editor->apply($page, $action, $id);
779 function handler_postfix_whitelist(&$page, $action = 'list', $id = null
) {
780 $page->assign('xorg_title','Polytechnique.org - Administration - Postfix : Whitelist');
781 $page->assign('title', 'Whitelist de postfix');
782 $table_editor = new PLTableEditor('admin/postfix/whitelist','postfix_whitelist','email', true
);
783 $table_editor->describe('email','email',true
);
784 $table_editor->apply($page, $action, $id);
786 function handler_logger_actions(&$page, $action = 'list', $id = null
) {
787 $page->assign('xorg_title','Polytechnique.org - Administration - Actions');
788 $page->assign('title', 'Gestion des actions de logger');
789 $table_editor = new PLTableEditor('admin/logger/actions','logger.actions','id');
790 $table_editor->describe('text','intitulé',true
);
791 $table_editor->describe('description','description',true
);
792 $table_editor->apply($page, $action, $id);
794 function handler_downtime(&$page, $action = 'list', $id = null
) {
795 $page->assign('xorg_title','Polytechnique.org - Administration - Coupures');
796 $page->assign('title', 'Gestion des coupures');
797 $table_editor = new PLTableEditor('admin/downtime','coupures','id');
798 $table_editor->describe('debut','date',true
);
799 $table_editor->describe('duree','durée',false
);
800 $table_editor->describe('resume','résumé',true
);
801 $table_editor->describe('services','services affectés',true
);
802 $table_editor->describe('description','description',false
);
803 $table_editor->apply($page, $action, $id);
805 function handler_wiki(&$page, $action='list') {
806 require_once 'wiki.inc.php';
809 if ($action == 'update') {
810 $perms_read = Post
::v('read');
811 $perms_edot = Post
::v('edit');
812 if ($perms_read ||
$perms_edit) {
813 foreach ($_POST as $wiki_page => $val) if ($val == 'on') {
814 $wiki_page = str_replace('_', '/', $wiki_page);
815 if (!$perms_read ||
!$perms_edit)
816 list($perms0, $perms1) = wiki_get_perms($wiki_page);
818 $perms0 = $perms_read;
820 $perms1 = $perms_edit;
821 wiki_set_perms($wiki_page, $perms0, $perms1);
826 $perms = wiki_perms_options();
828 // list wiki pages and their perms
829 $wiki_pages = array();
830 $dir = wiki_work_dir();
832 if ($dh = opendir($dir)) {
833 while (($file = readdir($dh)) !== false
) if (substr($file,0,1) >= 'A' && substr($file,0,1) <= 'Z') {
834 list($read,$edit) = wiki_get_perms($file);
835 $wiki_pages[$file] = array('read' => $perms[$read], 'edit' => $perms[$edit]);
842 $page->changeTpl('admin/wiki.tpl');
843 $page->assign('wiki_pages', $wiki_pages);
844 $page->assign('perms_opts', $perms);