-
- function handler_trombino(&$page, $uid = null, $action = null) {
- $page->changeTpl('admin/admin_trombino.tpl');
- $page->assign('xorg_title','Polytechnique.org - Administration - Trombino');
- $page->assign('uid', $uid);
-
- $q = XDB::query(
- "SELECT a.alias,promo
- FROM auth_user_md5 AS u
- INNER JOIN aliases AS a ON ( u.user_id = a.id AND type='a_vie' )
- WHERE user_id = {?}", $uid);
- list($forlife, $promo) = $q->fetchOneRow();
-
- switch ($action) {
-
- case "original":
- header("Content-type: image/jpeg");
- readfile("/home/web/trombino/photos".$promo."/".$forlife.".jpg");
- exit;
- break;
-
- case "new":
- $data = file_get_contents($_FILES['userfile']['tmp_name']);
- list($x, $y) = getimagesize($_FILES['userfile']['tmp_name']);
- $mimetype = substr($_FILES['userfile']['type'], 6);
- unlink($_FILES['userfile']['tmp_name']);
- XDB::execute(
- "REPLACE INTO photo SET uid={?}, attachmime = {?}, attach={?}, x={?}, y={?}",
- $uid, $mimetype, $data, $x, $y);
- break;
-
- case "delete":
- XDB::execute('DELETE FROM photo WHERE uid = {?}', $uid);
+ function handler_mx_broken(&$page, $action = 'list', $id = null) {
+ $page->assign('xorg_title', 'Polytechnique.org - Administration - MX Défaillants');
+ $page->assign('title', 'MX Défaillant');
+ $table_editor = new PLTableEditor('admin/mx/broken', 'mx_watch', 'host', true);
+ $table_editor->describe('host', 'Masque', true);
+ $table_editor->describe('state', 'Niveau', true);
+ $table_editor->describe('text', 'Description du problème', false);
+ $table_editor->apply($page, $action, $id);
+ }
+ function handler_logger_actions(&$page, $action = 'list', $id = null) {
+ $page->assign('xorg_title','Polytechnique.org - Administration - Actions');
+ $page->assign('title', 'Gestion des actions de logger');
+ $table_editor = new PLTableEditor('admin/logger/actions','logger.actions','id');
+ $table_editor->describe('text','intitulé',true);
+ $table_editor->describe('description','description',true);
+ $table_editor->apply($page, $action, $id);
+ }
+ function handler_downtime(&$page, $action = 'list', $id = null) {
+ $page->assign('xorg_title','Polytechnique.org - Administration - Coupures');
+ $page->assign('title', 'Gestion des coupures');
+ $table_editor = new PLTableEditor('admin/downtime','coupures','id');
+ $table_editor->describe('debut','date',true);
+ $table_editor->describe('duree','durée',false);
+ $table_editor->describe('resume','résumé',true);
+ $table_editor->describe('services','services affectés',true);
+ $table_editor->describe('description','description',false);
+ $table_editor->apply($page, $action, $id);
+ }
+
+ function handler_wiki(&$page, $action='list', $wikipage='', $wikipage2='')
+ {
+ require_once 'wiki.inc.php';
+
+ if (S::v('core_rss_hash')) {
+ $page->setRssLink('Changement Récents',
+ '/Site/AllRecentChanges?action=rss&user=' . S::v('forlife') . '&hash=' . S::v('core_rss_hash'));
+ }
+
+ // update wiki perms
+ if ($action == 'update') {
+ $perms_read = Post::v('read');
+ $perms_edot = Post::v('edit');
+ if ($perms_read || $perms_edit) {
+ foreach ($_POST as $wiki_page => $val) if ($val == 'on') {
+ $wiki_page = str_replace('_', '/', $wiki_page);
+ if (!$perms_read || !$perms_edit)
+ list($perms0, $perms1) = wiki_get_perms($wiki_page);
+ if ($perms_read)
+ $perms0 = $perms_read;
+ if ($perms_edit)
+ $perms1 = $perms_edit;
+ wiki_set_perms($wiki_page, $perms0, $perms1);
+ }
+ }
+ }
+
+ if ($action == 'delete' && $wikipage != '') {
+ if (wiki_delete_page($wikipage)) {
+ $page->trig("La page ".$wikipage." a été supprimée.");
+ } else {
+ $page->trig("Impossible de supprimer la page ".$wikipage.".");
+ }
+ }
+
+ if ($action == 'rename' && $wikipage != '' && $wikipage2 != '' && $wikipage != $wikipage2) {
+ if ($changedLinks = wiki_rename_page($wikipage, $wikipage2)) {
+ $s = 'La page <em>'.$wikipage.'</em> a été déplacée en <em>'.$wikipage2.'</em>.';
+ if (is_numeric($changedLinks)) {
+ $s .= $changedLinks.' lien'.(($changedLinks>1)?'s ont été modifiés.':' a été modifié.');
+ }
+ $page->trig($s);
+ } else {
+ $page->trig("Impossible de déplacer la page ".$wikipage);
+ }
+ }
+
+ $perms = wiki_perms_options();
+
+ // list wiki pages and their perms
+ $wiki_pages = array();
+ $dir = wiki_work_dir();
+ if (is_dir($dir)) {
+ if ($dh = opendir($dir)) {
+ while (($file = readdir($dh)) !== false) if (substr($file,0,1) >= 'A' && substr($file,0,1) <= 'Z') {
+ list($read,$edit) = wiki_get_perms($file);
+ $wiki_pages[$file] = array('read' => $perms[$read], 'edit' => $perms[$edit]);
+ if (is_file($dir . '/cache_' . wiki_filename($file) . '.tpl')) {
+ $wiki_pages[$file]['cached'] = true;
+ }
+ }
+ closedir($dh);
+ }
+ }
+ ksort($wiki_pages);
+ $wiki_tree = array();
+ foreach ($wiki_pages as $file => $desc) {
+ list($cat, $name) = explode('.', $file);
+ if (!isset($wiki_tree[$cat])) {
+ $wiki_tree[$cat] = array();
+ }
+ $wiki_tree[$cat][$name] = $desc;
+ }
+
+ $page->changeTpl('admin/wiki.tpl');
+ $page->addJsLink('jquery.js');
+ $page->assign('wiki_pages', $wiki_tree);
+ $page->assign('perms_opts', $perms);
+ }
+
+ function handler_ipwatch(&$page, $action = 'list', $ip = null)
+ {
+ $page->changeTpl('admin/ipwatcher.tpl');
+
+ $states = array('safe' => 'Ne pas surveiller',
+ 'unsafe' => 'Surveiller les inscriptions',
+ 'dangerous' => 'Surveiller tous les accès',
+ 'ban' => 'Bannir cette adresse');
+ $page->assign('states', $states);
+
+ switch (Post::v('action')) {
+ case 'create':
+ if (trim(Post::v('ipN')) != '') {
+ if (!S::has_xsrf_token()) {
+ $page->trig("L'ajout d'une IP à surveiller a échoué, merci de réessayer.");
+ break;
+ }
+ Xdb::execute('INSERT IGNORE INTO ip_watch (ip, mask, state, detection, last, uid, description)
+ VALUES ({?}, {?}, {?}, CURDATE(), NOW(), {?}, {?})',
+ ip_to_uint(trim(Post::v('ipN'))), ip_to_uint(trim(Post::v('maskN'))),
+ Post::v('stateN'), S::i('uid'), Post::v('descriptionN'));
+ };
+ break;
+
+ case 'edit':
+ if (!S::has_xsrf_token()) {
+ $page->trig("L'édition de l'IP a échoué, merci de réessayer.");