'admin/postfix/delayed' => $this->make_hook('postfix_delayed', AUTH_MDP, 'admin'),
'admin/postfix/regexp_bounces' => $this->make_hook('postfix_regexpsbounces', AUTH_MDP, 'admin'),
'admin/postfix/whitelist' => $this->make_hook('postfix_whitelist', AUTH_MDP, 'admin'),
+ 'admin/mx/broken' => $this->make_hook('mx_broken', AUTH_MDP, 'admin'),
'admin/skins' => $this->make_hook('skins', AUTH_MDP, 'admin'),
'admin/synchro_ax' => $this->make_hook('synchro_ax', AUTH_MDP, 'admin'),
'admin/user' => $this->make_hook('user', AUTH_MDP, 'admin'),
'admin/validate' => $this->make_hook('validate', AUTH_MDP, 'admin'),
'admin/validate/answers' => $this->make_hook('validate_answers', AUTH_MDP, 'admin'),
'admin/wiki' => $this->make_hook('wiki', AUTH_MDP, 'admin'),
+ 'admin/ipwatch' => $this->make_hook('ipwatch', AUTH_MDP, 'admin'),
);
}
function handler_postfix_delayed(&$page)
{
$page->changeTpl('admin/postfix_delayed.tpl');
- $page->assign('xorg_title','Polytechnique.org - Administration - Postfix : Retardés');
+ $page->assign('xorg_title','Polytechnique.org - Administration - Postfix : Retardés');
if (Env::has('del')) {
$crc = Env::v('crc');
XDB::execute("UPDATE postfix_mailseen SET release = 'del' WHERE crc = {?}", $crc);
- $page->trig($crc." verra tous ses mails supprimés !");
+ $page->trig($crc." verra tous ses mails supprimés !");
} elseif (Env::has('ok')) {
$crc = Env::v('crc');
XDB::execute("UPDATE postfix_mailseen SET release = 'ok' WHERE crc = {?}", $crc);
}
$page->assign_by_ref('sessions', $sessions);
} else {
- $page->assign('msg_nofilters', "Sélectionner une annuée et/ou un utilisateur");
+ $page->assign('msg_nofilters', "Sélectionner une annuée et/ou un utilisateur");
}
}
require_once("user.func.inc.php");
if (S::has('suid')) {
- $page->kill("déjà en SUID !!!");
+ $page->kill("déjà en SUID !!!");
}
if (Env::has('user_id')) {
if ($login) {
if (is_numeric($login)) {
- $r = XDB::query("SELECT *, a.alias AS forlife, u.flags AS sexe,
+ $r = XDB::query("SELECT *, a.alias AS forlife,
+ FIND_IN_SET('watch', u.flags) AS watch, FIND_IN_SET('femme', u.flags) AS sexe,
(year(naissance) > promo - 15 or year(naissance) < promo - 25) AS naiss_err
FROM auth_user_md5 AS u
LEFT JOIN aliases AS a ON (a.id = u.user_id AND type= 'a_vie')
WHERE u.user_id = {?}", $login);
} else {
- $r = XDB::query("SELECT *, a.alias AS forlife, u.flags AS sexe,
+ $r = XDB::query("SELECT *, a.alias AS forlife,
+ FIND_IN_SET('watch', u.flags) AS watch, FIND_IN_SET('femme', u.flags) AS sexe,
(year(naissance) > promo - 15 or year(naissance) < promo - 25) AS naiss_err
FROM auth_user_md5 AS u
INNER JOIN aliases AS a ON ( a.id = u.user_id AND a.alias={?} AND type!='homonyme' )", $login);
$page->trig("invalid email $email");
} else {
$redirect->add_email($email);
- $page->trig("Ajout de $email effectué");
+ $page->trig("Ajout de $email effectué");
}
break;
WHERE uid = {?} AND rewrite LIKE CONCAT({?}, '@%')",
$mr['user_id'], $val);
fix_bestalias($mr['user_id']);
- $page->trig($val." a été supprimé");
+ $page->trig($val." a été supprimé");
}
break;
case "activate_fwd":
$nom = Env::v('nomN');
$promo = Env::i('promoN');
$sexe = Env::v('sexeN');
- $comm = Env::v('commentN');
+ $comm = trim(Env::v('commentN'));
+ $watch = Env::v('watchN');
+ $flags = '';
+ if ($sexe) {
+ $flags = 'femme';
+ }
+ if ($watch) {
+ if ($flags) {
+ $flags .= ',';
+ }
+ $flags .= 'watch';
+ }
+
+ if ($watch && !$comm) {
+ $page->trig("Il est nécessaire de mettre un commentaire pour surveiller un compte");
+ break;
+ }
$query = "UPDATE auth_user_md5 SET
naissance = '$naiss',
perms = '$perms',
prenom = '".addslashes($prenm)."',
nom = '".addslashes($nom)."',
- flags = '$sexe',
+ flags = '$flags',
promo = $promo,
comment = '".addslashes($comm)."'
WHERE user_id = '{$mr['user_id']}'";
if (XDB::execute($query)) {
user_reindex($mr['user_id']);
- $mailer = new PlMailer();
- $mailer->setFrom("webmaster@polytechnique.org");
- $mailer->addTo("web@polytechnique.org");
- $mailer->setSubject("INTERVENTION de ".S::v('forlife'));
- $mailer->setTxtBody(preg_replace("/[ \t]+/", ' ', $query));
+ $mailer = new PlMailer("admin/mail_intervention.tpl");
+ $mailer->assign("user", S::v('forlife'));
+ $mailer->assign("query", $query);
$mailer->send();
- $page->trig("updaté correctement.");
+ $page->trig("updaté correctement.");
}
if (Env::v('nomusageN') != $mr['nom_usage']) {
+ require_once "xorg.misc.inc.php";
set_new_usage($mr['user_id'], Env::v('nomusageN'), make_username(Env::v('prenomN'), Env::v('nomusageN')));
}
if (Env::v('decesN') != $mr['deces']) {
user_clear_all_subs($mr['user_id'], false);
}
- $r = XDB::query("SELECT *, a.alias AS forlife, u.flags AS sexe
+ $r = XDB::query("SELECT *, a.alias AS forlife,
+ FIND_IN_SET('watch', u.flags) AS watch, FIND_IN_SET('femme', u.flags) AS sexe
FROM auth_user_md5 AS u
LEFT JOIN aliases AS a ON (a.id = u.user_id AND type= 'a_vie')
WHERE u.user_id = {?}", $mr['user_id']);
// DELETE FROM auth_user_md5
case "u_kill":
user_clear_all_subs($mr['user_id']);
- $page->trig("'{$mr['user_id']}' a été désinscrit !");
- $mailer = new PlMailer();
- $mailer->setFrom("webmaster@polytechnique.org");
- $mailer->addTo("web@polytechnique.org");
- $mailer->setSubject("INTERVENTION de ".S::v('forlife'));
- $mailer->setTxtBody("\nUtilisateur $login désinscrit");
+ $page->trig("'{$mr['user_id']}' a été désinscrit !");
+ $mailer = new PlMailer("admin/mail_intervention.tpl");
+ $mailer->assign("user", S::v('forlife'));
+ $mailer->assign("query", "\nUtilisateur $login désinscrit");
$mailer->send();
break;
}
$page->changeTpl('admin/ax-xorg.tpl');
$page->assign('xorg_title','Polytechnique.org - Administration - AX/X.org');
- // liste des différences
+ // liste des différences
$res = XDB::query(
'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
FROM auth_user_md5 AS u
ORDER BY u.promo,u.nom,u.prenom');
$page->assign('diffs', $res->fetchAllAssoc());
- // gens à l'ax mais pas chez nous
+ // gens à l'ax mais pas chez nous
$res = XDB::query(
'SELECT ia.promo,ia.nom,ia.nom_patro,ia.prenom
FROM identification_ax as ia
WHERE u.nom IS NULL');
$page->assign('mank', $res->fetchAllAssoc());
- // gens chez nous et pas à l'ax
+ // gens chez nous et pas à l'ax
$res = XDB::query('SELECT promo,nom,prenom FROM auth_user_md5 WHERE matricule_ax IS NULL');
$page->assign('plus', $res->fetchAllAssoc());
}
}
}
- function handler_validate(&$page, $action = 'list', $id = null) {
+ function handler_validate(&$page, $action = 'list', $id = null)
+ {
$page->changeTpl('admin/valider.tpl');
$page->assign('xorg_title','Polytechnique.org - Administration - Valider une demande');
+ $page->addCssLink('nl.css');
require_once("validations.inc.php");
+
if ($action == 'edit' and !is_null($id)) {
$page->assign('preview_id', $id);
}
$page->assign('vit', new ValidateIterator());
}
+
function handler_validate_answers(&$page, $action = 'list', $id = null) {
- $page->assign('xorg_title','Polytechnique.org - Administration - Réponses automatiques de validation');
- $page->assign('title', 'Gestion des réponses automatiques');
+ $page->assign('xorg_title','Polytechnique.org - Administration - Réponses automatiques de validation');
+ $page->assign('title', 'Gestion des réponses automatiques');
$table_editor = new PLTableEditor('admin/validate/answers','requests_answers','id');
- $table_editor->describe('category','catégorie',true);
+ $table_editor->describe('category','catégorie',true);
$table_editor->describe('title','titre',true);
$table_editor->describe('answer','texte',false);
$table_editor->apply($page, $action, $id);
$table_editor->describe('email','email',true);
$table_editor->apply($page, $action, $id);
}
+ 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('text','intitulé',true);
$table_editor->describe('description','description',true);
$table_editor->apply($page, $action, $id);
}
$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('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);
}
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);
}
$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')) != '') {
+ Xdb::execute('INSERT IGNORE INTO ip_watch (ip, state, detection, last, uid, description)
+ VALUES ({?}, {?}, CURDATE(), NOW(), {?}, {?})',
+ trim(Post::v('ipN')), Post::v('stateN'), S::i('uid'), Post::v('descriptionN'));
+ };
+ break;
+
+ case 'edit':
+ Xdb::execute('UPDATE ip_watch
+ SET state = {?}, last = NOW(), uid = {?}, description = {?}
+ WHERE ip = {?}', Post::v('stateN'), S::i('uid'), Post::v('descriptionN'), Post::v('ipN'));
+ break;
+
+ default:
+ if ($action == 'delete' && !is_null($ip)) {
+ Xdb::execute('DELETE FROM emails_watch WHERE ip = {?}', $ip);
+ }
+ }
+ if ($action != 'create' && $action != 'edit') {
+ $action = 'list';
+ }
+ $page->assign('action', $action);
+
+ if ($action == 'list') {
+ $sql = "SELECT w.ip, IF(w.ip = s.ip, s.host, s.forward_host), w.detection, w.state, a.alias AS forlife
+ FROM ip_watch AS w
+ LEFT JOIN logger.sessions AS s ON (s.ip = w.ip OR s.forward_ip = w.ip)
+ LEFT JOIN aliases AS a ON (a.id = s.uid AND a.type = 'a_vie')
+ GROUP BY w.ip, a.alias
+ ORDER BY w.state, w.ip, a.alias";
+ $it = Xdb::iterRow($sql);
+
+ $table = array();
+ $props = array();
+ while (list($ip, $host, $date, $state, $forlife) = $it->next()) {
+ if (count($props) == 0 || $props['ip'] != $ip) {
+ if (count($props) > 0) {
+ $table[] = $props;
+ }
+ $props = array('ip' => $ip,
+ 'host' => $host,
+ 'detection' => $date,
+ 'state' => $state,
+ 'users' => array($forlife));
+ } else {
+ $props['users'][] = $forlife;
+ }
+ }
+ if (count($props) > 0) {
+ $table[] = $props;
+ }
+ $page->assign('table', $table);
+ } elseif ($action == 'edit') {
+ $sql = "SELECT w.detection, w.state, w.last, w.description,
+ a1.alias AS edit, a2.alias AS forlife, s.host
+ FROM ip_watch AS w
+ LEFT JOIN aliases AS a1 ON (a1.id = w.uid AND a1.type = 'a_vie')
+ LEFT JOIN logger.sessions AS s ON (w.ip = s.ip)
+ LEFT JOIN aliases AS a2 ON (a2.id = s.uid AND a2.type = 'a_vie')
+ WHERE w.ip = {?}
+ GROUP BY a2.alias
+ ORDER BY a2.alias";
+ $it = Xdb::iterRow($sql, $ip);
+
+ $props = array();
+ while (list($detection, $state, $last, $description, $edit, $forlife, $host) = $it->next()) {
+ if (count($props) == 0) {
+ $props = array('ip' => $ip,
+ 'host' => $host,
+ 'detection' => $detection,
+ 'state' => $state,
+ 'last' => $last,
+ 'description' => $description,
+ 'edit' => $edit,
+ 'users' => array($forlife));
+ } else {
+ $props['users'][] = $forlife;
+ }
+ }
+ $page->assign('ip', $props);
+ }
+ }
}
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
?>