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