X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fxorg%2Fsession.inc.php;h=6e8b3e84ff43a26142068c36884e81d43b0d43a8;hb=32111f706bcbf1d3244f64b7928b37bbc5210ab0;hp=b2e6d17651d1241ded3276584e79db8d2b3d694a;hpb=a7de4ef724d1a3b0bf978a50ce7cc9d23412c7a0;p=platal.git diff --git a/include/xorg/session.inc.php b/include/xorg/session.inc.php index b2e6d17..6e8b3e8 100644 --- a/include/xorg/session.inc.php +++ b/include/xorg/session.inc.php @@ -25,13 +25,13 @@ class XorgSession { // {{{ public static function init - public static function init() + public static function init() { S::init(); if (!S::has('uid')) { try_cookie(); } - if (check_ip('dangerous') && S::has('uid')) { + if ((check_ip('dangerous') && S::has('uid')) || check_account()) { $_SESSION['log']->log("view_page", $_SERVER['REQUEST_URI']); } } @@ -158,6 +158,7 @@ class XorgSession * @param page the calling page (by reference) */ public static function doAuthCookie() + { if (S::logged()) { return true; @@ -175,6 +176,22 @@ class XorgSession } // }}} + // {{{ public static function make_perms() + + public static function &make_perms($perm) + { + $flags = new FlagSet(); + if ($perm == 'disabled' || $perm == 'ext') { + return $flags; + } + $flags->addFlag(PERMS_USER); + if ($perm == 'admin') { + $flags->addFlag(PERMS_ADMIN); + } + return $flags; + } + + // }}} } // {{{ function try_cookie() @@ -222,9 +239,10 @@ function try_cookie() function start_connexion ($uid, $identified) { $res = XDB::query(" - SELECT u.user_id AS uid, prenom, nom, perms, promo, matricule, password, FIND_IN_SET('femme', u.flags) AS femme, + SELECT u.user_id AS uid, prenom, nom, nom_usage, perms, promo, matricule, password, FIND_IN_SET('femme', u.flags) AS femme, UNIX_TIMESTAMP(s.start) AS lastlogin, s.host, a.alias AS forlife, a2.alias AS bestalias, - q.core_mail_fmt AS mail_fmt, UNIX_TIMESTAMP(q.banana_last) AS banana_last, q.watch_last, q.core_rss_hash + q.core_mail_fmt AS mail_fmt, UNIX_TIMESTAMP(q.banana_last) AS banana_last, q.watch_last, q.core_rss_hash, + FIND_IN_SET('watch', u.flags) AS watch_account, q.last_version FROM auth_user_md5 AS u INNER JOIN auth_user_quick AS q USING(user_id) INNER JOIN aliases AS a ON (u.user_id = a.id AND a.type='a_vie') @@ -237,10 +255,9 @@ function start_connexion ($uid, $identified) $suid = S::v('suid'); if ($suid) { - $logger = new CoreLogger($uid, $suid); + $logger = new CoreLogger($uid, $suid['uid']); $logger->log("suid_start", S::v('forlife')." by {$suid['uid']}"); $sess['suid'] = $suid; - $sess['perms'] = $_SESSION['perms']; } else { $logger = S::v('log', new CoreLogger($uid)); $logger->log("connexion", Env::v('n')); @@ -250,17 +267,39 @@ function start_connexion ($uid, $identified) $_SESSION = array_merge($_SESSION, $sess); $_SESSION['log'] = $logger; $_SESSION['auth'] = ($identified ? AUTH_MDP : AUTH_COOKIE); + $_SESSION['perms'] =& XorgSession::make_perms($_SESSION['perms']); + $mail_subject = null; + if (check_account()) { + $mail_subject = "Connexion d'un utilisateur surveillé"; + } if (check_ip('unsafe')) { - send_warning_mail("Une IP surveillee a tente de se connecter"); + if ($mail_subject) { + $mail_subject .= ' - '; + } + $mail_subject .= "Une IP surveillee a tente de se connecter"; if (check_ip('ban')) { + send_warning_mail($mail_subject); $_SESSION = array(); + $_SESSION['perms'] = new FlagSet(); global $page; + $newpage = false; + if (!$page) { + require_once 'xorg.inc.php'; + new_skinned_page('platal/index.tpl'); + $newpage = true; + } $page->trig("Une erreur est survenue lors de la procédure d'authentification. " ."Merci de contacter au plus vite " ."support@polytechnique.org"); + if ($newpage) { + $page->run(); + } return false; } } + if ($mail_subject) { + send_warning_mail($mail_subject); + } set_skin(); check_redirect(); return true;