86f0a6af |
1 | <?php |
2 | /*************************************************************************** |
3 | * Copyright (C) 2003-2006 Polytechnique.org * |
4 | * http://opensource.polytechnique.org/ * |
5 | * * |
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. * |
10 | * * |
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. * |
15 | * * |
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 * |
18 | * Foundation, Inc., * |
19 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * |
20 | ***************************************************************************/ |
21 | |
22 | class AdminModule extends PLModule |
23 | { |
24 | function handlers() |
25 | { |
26 | return array( |
27 | 'admin' => $this->make_hook('default', AUTH_MDP, 'admin'), |
86f0a6af |
28 | 'admin/ax-xorg' => $this->make_hook('ax_xorg', AUTH_MDP, 'admin'), |
29 | 'admin/deaths' => $this->make_hook('deaths', AUTH_MDP, 'admin'), |
e7ae7df9 |
30 | 'admin/downtime' => $this->make_hook('downtime', AUTH_MDP, 'admin'), |
e7ae7df9 |
31 | 'admin/homonyms' => $this->make_hook('homonyms', AUTH_MDP, 'admin'), |
e7ae7df9 |
32 | 'admin/logger' => $this->make_hook('logger', AUTH_MDP, 'admin'), |
33 | 'admin/logger/actions' => $this->make_hook('logger_actions', AUTH_MDP, 'admin'), |
e7ae7df9 |
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'), |
e7ae7df9 |
40 | 'admin/user' => $this->make_hook('user', AUTH_MDP, 'admin'), |
41 | 'admin/validate' => $this->make_hook('validate', AUTH_MDP, 'admin'), |
3aec1c21 |
42 | 'admin/wiki' => $this->make_hook('wiki', AUTH_MDP, 'admin'), |
86f0a6af |
43 | ); |
44 | } |
45 | |
46 | function handler_default(&$page) |
47 | { |
48 | $page->changeTpl('admin/index.tpl'); |
49 | $page->assign('xorg_title','Polytechnique.org - Administration'); |
50 | } |
51 | |
52 | function handler_postfix_delayed(&$page) |
53 | { |
54 | $page->changeTpl('admin/postfix_delayed.tpl'); |
55 | $page->assign('xorg_title','Polytechnique.org - Administration - Postfix : Retardés'); |
56 | |
57 | if (Env::has('del')) { |
58 | $crc = Env::v('crc'); |
59 | XDB::execute("UPDATE postfix_mailseen SET release = 'del' WHERE crc = {?}", $crc); |
60 | $page->trig($crc." verra tous ses mails supprimés !"); |
61 | } elseif (Env::has('ok')) { |
62 | $crc = Env::v('crc'); |
63 | XDB::execute("UPDATE postfix_mailseen SET release = 'ok' WHERE crc = {?}", $crc); |
64 | $page->trig($crc." a le droit de passer !"); |
65 | } |
66 | |
67 | $sql = XDB::iterator( |
68 | "SELECT crc, nb, update_time, create_time, |
69 | FIND_IN_SET('del', release) AS del, |
70 | FIND_IN_SET('ok', release) AS ok |
71 | FROM postfix_mailseen |
72 | WHERE nb >= 30 |
73 | ORDER BY release != ''"); |
74 | |
75 | $page->assign_by_ref('mails', $sql); |
76 | } |
77 | |
78 | function handler_postfix_regexpsbounces(&$page, $new = null) { |
79 | $page->changeTpl('admin/emails_bounces_re.tpl'); |
80 | $page->assign('xorg_title','Polytechnique.org - Administration - Postfix : Regexps Bounces'); |
81 | $page->assign('new', $new); |
82 | |
83 | if (Post::has('submit')) { |
84 | foreach (Env::v('lvl') as $id=>$val) { |
85 | XDB::query( |
86 | "REPLACE INTO emails_bounces_re (id,pos,lvl,re,text) VALUES ({?}, {?}, {?}, {?}, {?})", |
87 | $id, $_POST['pos'][$id], $_POST['lvl'][$id], $_POST['re'][$id], $_POST['text'][$id] |
88 | ); |
89 | } |
90 | } |
91 | |
92 | $page->assign('bre', XDB::iterator("SELECT * FROM emails_bounces_re ORDER BY pos")); |
93 | } |
94 | |
95 | function handler_logger(&$page) { |
96 | $page->changeTpl('logger-view.tpl'); |
97 | $page->assign('xorg_title','Polytechnique.org - Administration - Logs des sessions'); |
98 | require_once('diogenes/diogenes.logger-view.inc.php'); |
99 | |
100 | if (!Env::has('logauth')) { |
101 | $_REQUEST['logauth'] = 'native'; |
102 | } |
103 | |
104 | $logview = new DiogenesLoggerView; |
105 | $logview->run($page); |
106 | |
107 | $page->fakeDiogenes(); |
108 | } |
109 | |
110 | function handler_user(&$page, $login = false) { |
111 | $page->changeTpl('admin/utilisateurs.tpl'); |
112 | $page->assign('xorg_title','Polytechnique.org - Administration - Edit/Su/Log'); |
113 | require_once("emails.inc.php"); |
114 | require_once("user.func.inc.php"); |
115 | |
116 | if (S::has('suid')) { |
117 | $page->kill("déjà en SUID !!!"); |
118 | } |
119 | |
120 | if (Env::has('user_id')) { |
121 | $login = get_user_login(Env::i('user_id')); |
122 | } elseif (Env::has('login')) { |
123 | $login = get_user_login(Env::v('login')); |
124 | } |
125 | |
126 | if(Env::has('logs_button') && $login) { |
127 | pl_redirect("admin/logger?login=$login&year=".date('Y')."&month=".date('m')); |
128 | } |
129 | |
130 | if (Env::has('ax_button') && $login) { |
131 | pl_redirect("admin/synchro_ax/$login"); |
132 | } |
133 | |
134 | if(Env::has('suid_button') && $login) { |
135 | $_SESSION['log']->log("suid_start", "login by ".S::v('forlife')); |
136 | $_SESSION['suid'] = $_SESSION; |
137 | $r = XDB::query("SELECT id FROM aliases WHERE alias={?}", $login); |
138 | if($uid = $r->fetchOneCell()) { |
139 | start_connexion($uid,true); |
140 | pl_redirect(""); |
141 | } |
142 | } |
143 | |
144 | if ($login) { |
145 | $r = XDB::query("SELECT *, a.alias AS forlife, u.flags AS sexe |
146 | FROM auth_user_md5 AS u |
147 | INNER JOIN aliases AS a ON ( a.id = u.user_id AND a.alias={?} AND type!='homonyme' )", $login); |
148 | $mr = $r->fetchOneAssoc(); |
149 | |
150 | $redirect = new Redirect($mr['user_id']); |
151 | |
152 | // Check if there was a submission |
153 | foreach($_POST as $key => $val) { |
154 | switch ($key) { |
155 | case "add_fwd": |
156 | $email = trim(Env::v('email')); |
157 | if (!isvalid_email_redirection($email)) { |
158 | $page->trig("invalid email $email"); |
159 | } else { |
160 | $redirect->add_email($email); |
161 | $page->trig("Ajout de $email effectué"); |
162 | } |
163 | break; |
164 | |
165 | case "del_fwd": |
166 | if (!empty($val)) { |
167 | $redirect->delete_email($val); |
168 | } |
169 | break; |
170 | |
171 | case "del_alias": |
172 | if (!empty($val)) { |
173 | XDB::execute("DELETE FROM aliases WHERE id={?} AND alias={?} |
174 | AND type!='a_vie' AND type!='homonyme'", $mr['user_id'], $val); |
175 | fix_bestalias($mr['user_id']); |
176 | $page->trig($val." a été supprimé"); |
177 | } |
178 | break; |
179 | case "activate_fwd": |
180 | if (!empty($val)) { |
181 | $redirect->modify_one_email($val, true); |
182 | } |
183 | break; |
184 | case "deactivate_fwd": |
185 | if (!empty($val)) { |
186 | $redirect->modify_one_email($val, false); |
187 | } |
188 | break; |
189 | case "add_alias": |
190 | XDB::execute("INSERT INTO aliases (id,alias,type) VALUES ({?}, {?}, 'alias')", |
191 | $mr['user_id'], Env::v('email')); |
192 | break; |
193 | |
194 | case "best": |
195 | // 'bestalias' is the first bit of the set : 1 |
196 | // 255 is the max for flags (8 sets max) |
197 | XDB::execute("UPDATE aliases SET flags= flags & (255 - 1) WHERE id={?}", $mr['user_id']); |
198 | XDB::execute("UPDATE aliases |
199 | SET flags= flags | 1 |
200 | WHERE id={?} AND alias={?}", $mr['user_id'], $val); |
201 | break; |
202 | |
203 | |
204 | // Editer un profil |
205 | case "u_edit": |
206 | require_once('secure_hash.inc.php'); |
207 | $pass_encrypted = Env::v('newpass_clair') != "********" ? hash_encrypt(Env::v('newpass_clair')) : Env::v('passw'); |
208 | $naiss = Env::v('naissanceN'); |
34ffe99a |
209 | $deces = Env::v('decesN'); |
86f0a6af |
210 | $perms = Env::v('permsN'); |
211 | $prenm = Env::v('prenomN'); |
212 | $nom = Env::v('nomN'); |
213 | $promo = Env::i('promoN'); |
214 | $sexe = Env::v('sexeN'); |
215 | $comm = Env::v('commentN'); |
216 | |
217 | $query = "UPDATE auth_user_md5 SET |
218 | naissance = '$naiss', |
34ffe99a |
219 | deces = '$deces', |
86f0a6af |
220 | password = '$pass_encrypted', |
221 | perms = '$perms', |
222 | prenom = '".addslashes($prenm)."', |
223 | nom = '".addslashes($nom)."', |
224 | flags = '$sexe', |
225 | promo = $promo, |
226 | comment = '".addslashes($comm)."' |
227 | WHERE user_id = '{$mr['user_id']}'"; |
228 | if (XDB::execute($query)) { |
229 | user_reindex($mr['user_id']); |
230 | |
231 | require_once("diogenes/diogenes.hermes.inc.php"); |
232 | $mailer = new HermesMailer(); |
233 | $mailer->setFrom("webmaster@polytechnique.org"); |
234 | $mailer->addTo("web@polytechnique.org"); |
235 | $mailer->setSubject("INTERVENTION de ".S::v('forlife')); |
236 | $mailer->setTxtBody(preg_replace("/[ \t]+/", ' ', $query)); |
237 | $mailer->send(); |
238 | |
239 | $page->trig("updaté correctement."); |
240 | } |
241 | if (Env::v('nomusageN') != $mr['nom_usage']) { |
242 | require_once('nomusage.inc.php'); |
243 | set_new_usage($mr['user_id'], Env::v('nomusageN'), make_username(Env::v('prenomN'), Env::v('nomusageN'))); |
244 | } |
245 | $r = XDB::query("SELECT *, a.alias AS forlife, u.flags AS sexe |
246 | FROM auth_user_md5 AS u |
247 | INNER JOIN aliases AS a ON (u.user_id=a.id) |
248 | WHERE user_id = {?}", $mr['user_id']); |
249 | $mr = $r->fetchOneAssoc(); |
250 | break; |
251 | |
252 | // DELETE FROM auth_user_md5 |
253 | case "u_kill": |
254 | user_clear_all_subs($mr['user_id']); |
255 | $page->trig("'{$mr['user_id']}' a été désinscrit !"); |
256 | require_once("diogenes/diogenes.hermes.inc.php"); |
257 | $mailer = new HermesMailer(); |
258 | $mailer->setFrom("webmaster@polytechnique.org"); |
259 | $mailer->addTo("web@polytechnique.org"); |
260 | $mailer->setSubject("INTERVENTION de ".S::v('forlife')); |
261 | $mailer->setTxtBody("\nUtilisateur $login effacé"); |
262 | $mailer->send(); |
263 | break; |
264 | } |
265 | } |
266 | |
267 | $res = XDB::query("SELECT UNIX_TIMESTAMP(start), host |
268 | FROM logger.sessions |
269 | WHERE uid={?} AND suid=0 |
270 | ORDER BY start DESC |
271 | LIMIT 1", $mr['user_id']); |
272 | list($lastlogin,$host) = $res->fetchOneRow(); |
273 | $page->assign('lastlogin', $lastlogin); |
274 | $page->assign('host', $host); |
275 | |
276 | $page->assign('aliases', XDB::iterator( |
277 | "SELECT alias, type='a_vie' AS for_life,FIND_IN_SET('bestalias',flags) AS best,expire |
278 | FROM aliases |
279 | WHERE id = {?} AND type!='homonyme' |
280 | ORDER BY type!= 'a_vie'", $mr["user_id"])); |
281 | $page->assign('xorgmails', $xorgmails); |
282 | $page->assign('email_panne', $email_panne); |
283 | $page->assign('emails',$redirect->emails); |
284 | |
285 | $page->assign('mr',$mr); |
286 | } |
287 | } |
288 | function handler_homonyms(&$page, $op = 'list', $target = null) { |
289 | $page->changeTpl('admin/homonymes.tpl'); |
290 | $page->assign('xorg_title','Polytechnique.org - Administration - Homonymes'); |
291 | require_once("homonymes.inc.php"); |
292 | |
293 | if ($target) { |
294 | if (! list($prenom,$nom,$forlife,$loginbis) = select_if_homonyme($target)) { |
295 | $target=0; |
296 | } else { |
297 | $page->assign('nom',$nom); |
298 | $page->assign('prenom',$prenom); |
299 | $page->assign('forlife',$forlife); |
300 | $page->assign('loginbis',$loginbis); |
301 | } |
302 | } |
303 | |
304 | $page->assign('op',$op); |
305 | $page->assign('target',$target); |
306 | |
307 | // on a un $target valide, on prepare les mails |
308 | if ($target) { |
309 | |
310 | // on examine l'op a effectuer |
311 | switch ($op) { |
312 | case 'mail': |
313 | send_warning_homonyme($prenom, $nom, $forlife, $loginbis); |
314 | switch_bestalias($target, $loginbis); |
315 | $op = 'list'; |
316 | break; |
317 | case 'correct': |
318 | switch_bestalias($target, $loginbis); |
319 | XDB::execute("UPDATE aliases SET type='homonyme',expire=NOW() WHERE alias={?}", $loginbis); |
320 | XDB::execute("REPLACE INTO homonymes (homonyme_id,user_id) VALUES({?},{?})", $target, $target); |
321 | send_robot_homonyme($prenom, $nom, $forlife, $loginbis); |
322 | $op = 'list'; |
323 | break; |
324 | } |
325 | } |
326 | |
327 | if ($op == 'list') { |
328 | $res = XDB::iterator( |
329 | "SELECT a.alias AS homonyme,s.id AS user_id,s.alias AS forlife, |
330 | promo,prenom,nom, |
331 | IF(h.homonyme_id=s.id, a.expire, NULL) AS expire, |
332 | IF(h.homonyme_id=s.id, a.type, NULL) AS type |
333 | FROM aliases AS a |
334 | LEFT JOIN homonymes AS h ON (h.homonyme_id = a.id) |
335 | INNER JOIN aliases AS s ON (s.id = h.user_id AND s.type='a_vie') |
336 | INNER JOIN auth_user_md5 AS u ON (s.id=u.user_id) |
337 | WHERE a.type='homonyme' OR a.expire!='' |
338 | ORDER BY a.alias,promo"); |
339 | $hnymes = Array(); |
340 | while ($tab = $res->next()) { |
341 | $hnymes[$tab['homonyme']][] = $tab; |
342 | } |
343 | $page->assign_by_ref('hnymes',$hnymes); |
344 | } |
345 | } |
346 | |
347 | function handler_ax_xorg(&$page) { |
348 | $page->changeTpl('admin/ax-xorg.tpl'); |
349 | $page->assign('xorg_title','Polytechnique.org - Administration - AX/X.org'); |
350 | |
351 | // liste des différences |
352 | $res = XDB::query( |
353 | '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 |
354 | FROM auth_user_md5 AS u |
355 | INNER JOIN identification_ax AS ia ON u.matricule_ax = ia.matricule_ax |
356 | WHERE (SOUNDEX(u.nom) != SOUNDEX(ia.nom) AND SOUNDEX(CONCAT(ia.particule,u.nom)) != SOUNDEX(ia.nom) |
357 | AND SOUNDEX(u.nom) != SOUNDEX(ia.nom_patro) AND SOUNDEX(CONCAT(ia.particule,u.nom)) != SOUNDEX(ia.nom_patro)) |
358 | OR u.prenom != ia.prenom OR (u.promo != ia.promo AND u.promo != ia.promo+1 AND u.promo != ia.promo-1) |
359 | ORDER BY u.promo,u.nom,u.prenom'); |
360 | $page->assign('diffs', $res->fetchAllAssoc()); |
361 | |
362 | // gens à l'ax mais pas chez nous |
363 | $res = XDB::query( |
364 | 'SELECT ia.promo,ia.nom,ia.nom_patro,ia.prenom |
365 | FROM identification_ax as ia |
366 | LEFT JOIN auth_user_md5 AS u ON u.matricule_ax = ia.matricule_ax |
367 | WHERE u.nom IS NULL'); |
368 | $page->assign('mank', $res->fetchAllAssoc()); |
369 | |
370 | // gens chez nous et pas à l'ax |
371 | $res = XDB::query('SELECT promo,nom,prenom FROM auth_user_md5 WHERE matricule_ax IS NULL'); |
372 | $page->assign('plus', $res->fetchAllAssoc()); |
373 | } |
374 | |
375 | function handler_deaths(&$page, $promo = 0, $validate = false) { |
376 | $page->changeTpl('admin/deces_promo.tpl'); |
377 | $page->assign('xorg_title','Polytechnique.org - Administration - Deces'); |
378 | |
379 | if (!$promo) |
380 | $promo = Env::i('promo'); |
381 | if (Env::has('sub10')) $promo -= 10; |
382 | if (Env::has('sub01')) $promo -= 1; |
383 | if (Env::has('add01')) $promo += 1; |
384 | if (Env::has('add10')) $promo += 10; |
385 | |
386 | $page->assign('promo',$promo); |
387 | |
388 | if ($validate) { |
389 | $new_deces = array(); |
390 | $res = XDB::iterRow("SELECT user_id,matricule,nom,prenom,deces FROM auth_user_md5 WHERE promo = {?}", $promo); |
391 | while (list($uid,$mat,$nom,$prenom,$deces) = $res->next()) { |
392 | $val = Env::v($mat); |
393 | if($val == $deces || empty($val)) continue; |
394 | XDB::execute('UPDATE auth_user_md5 SET deces={?} WHERE matricule = {?}', $val, $mat); |
395 | $new_deces[] = array('name' => "$prenom $nom", 'date' => "$val"); |
396 | if($deces=='0000-00-00' or empty($deces)) { |
397 | require_once('notifs.inc.php'); |
398 | register_watch_op($uid, WATCH_DEATH, $val); |
399 | require_once('user.func.inc.php'); |
400 | user_clear_all_subs($uid, false); // by default, dead ppl do not loose their email |
401 | } |
402 | } |
403 | $page->assign('new_deces',$new_deces); |
404 | } |
405 | |
406 | $res = XDB::iterator('SELECT matricule, nom, prenom, deces FROM auth_user_md5 WHERE promo = {?} ORDER BY nom,prenom', $promo); |
407 | $page->assign('decedes', $res); |
408 | } |
409 | |
410 | function handler_synchro_ax(&$page, $user = null, $action = null) { |
411 | $page->changeTpl('admin/synchro_ax.tpl'); |
412 | $page->assign('xorg_title','Polytechnique.org - Administration - Synchro AX'); |
413 | |
414 | require_once('synchro_ax.inc.php'); |
415 | |
416 | if (is_ax_key_missing()) { |
417 | $page->assign('no_private_key', true); |
418 | $page->run(); |
419 | } |
420 | |
421 | require_once('user.func.inc.php'); |
422 | |
423 | if ($user) |
424 | $login = get_user_forlife($user); |
425 | |
426 | if (Env::has('user')) { |
427 | $login = get_user_forlife(Env::v('user')); |
428 | if ($login === false) { |
429 | return; |
430 | } |
431 | } |
432 | |
433 | if (Env::has('mat')) { |
434 | $res = XDB::query( |
435 | "SELECT alias |
436 | FROM aliases AS a |
437 | INNER JOIN auth_user_md5 AS u ON (a.id=u.user_id AND a.type='a_vie') |
438 | WHERE matricule={?}", Env::i('mat')); |
439 | $login = $res->fetchOneCell(); |
440 | } |
441 | |
442 | if ($login) { |
443 | if ($action == 'import') { |
444 | ax_synchronize($login, S::v('uid')); |
445 | } |
446 | // get details from user, but looking only info that can be seen by ax |
447 | $user = get_user_details($login, S::v('uid'), 'ax'); |
448 | $userax= get_user_ax($user['matricule_ax']); |
449 | require_once 'profil.func.inc.php'; |
450 | $diff = diff_user_details($userax, $user, 'ax'); |
451 | |
452 | $page->assign('x', $user); |
453 | $page->assign('diff', $diff); |
454 | } |
455 | } |
456 | |
86f0a6af |
457 | function handler_validate(&$page) { |
458 | $page->changeTpl('admin/valider.tpl'); |
459 | $page->assign('xorg_title','Polytechnique.org - Administration - Valider une demande'); |
460 | require_once("validations.inc.php"); |
461 | |
462 | if(Env::has('uid') && Env::has('type') && Env::has('stamp')) { |
463 | $req = Validate::get_request(Env::v('uid'), Env::v('type'), Env::v('stamp')); |
464 | if($req) { $req->handle_formu(); } |
465 | } |
466 | |
467 | $page->assign('vit', new ValidateIterator()); |
468 | } |
e7ae7df9 |
469 | function handler_skins(&$page, $action = 'list', $id = null) { |
470 | require_once('../classes/PLTableEditor.php'); |
471 | $page->assign('xorg_title','Polytechnique.org - Administration - Skins'); |
472 | $page->assign('title', 'Gestion des skins'); |
473 | $table_editor = new PLTableEditor('admin/skins','skins','id'); |
474 | $table_editor->describe('name','nom',true); |
475 | $table_editor->describe('skin_tpl','nom du template',true); |
476 | $table_editor->describe('auteur','auteur',false); |
477 | $table_editor->describe('comment','commentaire',true); |
478 | $table_editor->describe('date','date',false); |
479 | $table_editor->describe('ext','extension du screenshot',false); |
480 | $table_editor->apply($page, $action, $id); |
481 | } |
e7ae7df9 |
482 | function handler_postfix_blacklist(&$page, $action = 'list', $id = null) { |
483 | require_once('../classes/PLTableEditor.php'); |
484 | $page->assign('xorg_title','Polytechnique.org - Administration - Postfix : Blacklist'); |
485 | $page->assign('title', 'Blacklist de postfix'); |
486 | $table_editor = new PLTableEditor('admin/postfix/blacklist','postfix_blacklist','email', true); |
487 | $table_editor->describe('reject_text','Texte de rejet',true); |
488 | $table_editor->describe('email','email',true); |
489 | $table_editor->apply($page, $action, $id); |
490 | } |
491 | function handler_postfix_whitelist(&$page, $action = 'list', $id = null) { |
492 | require_once('../classes/PLTableEditor.php'); |
493 | $page->assign('xorg_title','Polytechnique.org - Administration - Postfix : Whitelist'); |
494 | $page->assign('title', 'Whitelist de postfix'); |
495 | $table_editor = new PLTableEditor('admin/postfix/whitelist','postfix_whitelist','email', true); |
496 | $table_editor->describe('email','email',true); |
497 | $table_editor->apply($page, $action, $id); |
498 | } |
499 | function handler_logger_actions(&$page, $action = 'list', $id = null) { |
500 | require_once('../classes/PLTableEditor.php'); |
501 | $page->assign('xorg_title','Polytechnique.org - Administration - Actions'); |
502 | $page->assign('title', 'Gestion des actions de logger'); |
503 | $table_editor = new PLTableEditor('admin/logger/actions','logger.actions','id'); |
504 | $table_editor->describe('text','intitulé',true); |
505 | $table_editor->describe('description','description',true); |
506 | $table_editor->apply($page, $action, $id); |
507 | } |
508 | function handler_downtime(&$page, $action = 'list', $id = null) { |
509 | require_once('../classes/PLTableEditor.php'); |
510 | $page->assign('xorg_title','Polytechnique.org - Administration - Coupures'); |
511 | $page->assign('title', 'Gestion des coupures'); |
512 | $table_editor = new PLTableEditor('admin/downtime','coupures','id'); |
513 | $table_editor->describe('debut','date',true); |
514 | $table_editor->describe('duree','durée',false); |
515 | $table_editor->describe('resume','résumé',true); |
516 | $table_editor->describe('services','services affectés',true); |
517 | $table_editor->describe('description','description',false); |
518 | $table_editor->apply($page, $action, $id); |
519 | } |
3aec1c21 |
520 | function handler_wiki(&$page, $action='list') { |
521 | require_once 'wiki.inc.php'; |
522 | |
523 | // update wiki perms |
524 | if ($action == 'update') { |
525 | $perms_read = Post::v('read'); |
526 | $perms_edot = Post::v('edit'); |
527 | if ($perms_read || $perms_edit) { |
528 | foreach ($_POST as $wiki_page => $val) if ($val == 'on') { |
529 | $wiki_page = str_replace('_', '/', $wiki_page); |
530 | if (!$perms_read || !$perms_edit) |
531 | list($perms0, $perms1) = wiki_get_perms($wiki_page); |
532 | if ($perms_read) |
533 | $perms0 = $perms_read; |
534 | if ($perms_edit) |
535 | $perms1 = $perms_edit; |
536 | wiki_set_perms($wiki_page, $perms0, $perms1); |
537 | } |
538 | } |
539 | } |
540 | |
541 | $perms = wiki_perms_options(); |
542 | |
543 | // list wiki pages and their perms |
544 | $wiki_pages = array(); |
545 | $dir = wiki_work_dir(); |
546 | if (is_dir($dir)) { |
547 | if ($dh = opendir($dir)) { |
548 | while (($file = readdir($dh)) !== false) if (substr($file,0,1) >= 'A' && substr($file,0,1) <= 'Z') { |
549 | list($read,$edit) = wiki_get_perms($file); |
550 | $wiki_pages[$file] = array('read' => $perms[$read], 'edit' => $perms[$edit]); |
551 | } |
552 | closedir($dh); |
553 | } |
554 | } |
555 | ksort($wiki_pages); |
556 | |
557 | $page->changeTpl('admin/wiki.tpl'); |
558 | $page->assign('wiki_pages', $wiki_pages); |
559 | $page->assign('perms_opts', $perms); |
560 | } |
86f0a6af |
561 | } |
562 | |
563 | ?> |