if( !empty($params[1]) ){ // on verifie qu'on a bien un matricule
$res = XDB::query(
- "SELECT a.nom, a.nom_usage,a.prenom,a.flags='femme' as femme ,a.deces!= 0 as decede ,
+ "SELECT a.nom, a.nom_usage,a.prenom, FIND_IN_SET('femme', a.flags) as femme ,a.deces!= 0 as decede ,
a.naissance, a.promo, concat(al.alias, '@m4x.org') as mail
FROM auth_user_md5 AS a
INNER JOIN aliases as al ON a.user_id=al.id
return false;
}
+function check_account()
+{
+ return S::v('watch');
+}
+
function check_redirect($red = null)
{
require_once 'emails.inc.php';
$red = new Redirect(S::v('uid'));
}
$_SESSION['no_redirect'] = !$red->other_active('');
- $_SESSION['mx_failures'] = $red->get_broken_mx();
-
+ $_SESSION['mx_failures'] = $red->get_broken_mx();
}
function send_warning_mail($title)
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']);
}
}
$res = XDB::query("
SELECT u.user_id AS uid, prenom, nom, 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
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')
$_SESSION = array_merge($_SESSION, $sess);
$_SESSION['log'] = $logger;
$_SESSION['auth'] = ($identified ? AUTH_MDP : AUTH_COOKIE);
+ $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";
+ send_warning_mail($mail_subject);
if (check_ip('ban')) {
$_SESSION = array();
global $page;
return false;
}
}
+ if ($mail_subject) {
+ send_warning_mail($mail_subject);
+ }
set_skin();
check_redirect();
return true;
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);
$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 (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']);
if ($hash) {
$res = XDB::query(
- "SELECT m.uid, u.promo, u.nom, u.prenom, u.matricule
+ "SELECT m.uid, u.promo, u.nom, u.prenom, u.matricule, FIND_IN_SET('watch', u.flags)
FROM register_marketing AS m
INNER JOIN auth_user_md5 AS u ON u.user_id = m.uid
WHERE m.hash={?}", $hash);
- if (list($uid, $promo, $nom, $prenom, $ourmat) = $res->fetchOneRow()) {
+ if (list($uid, $promo, $nom, $prenom, $ourmat, $watch) = $res->fetchOneRow()) {
$sub_state['uid'] = $uid;
$sub_state['hash'] = $hash;
$sub_state['promo'] = $promo;
$sub_state['nom'] = $nom;
$sub_state['prenom'] = $prenom;
$sub_state['ourmat'] = $ourmat;
+ $sub_state['watch'] = $watch;
XDB::execute(
"REPLACE INTO register_mstats (uid,sender,success)
if (count($aliases) != 0) {
$alert .= "Email surveille propose a l'inscription - ";
}
+ if ($sub_state['watch']) {
+ $alter .= "Inscription d'un utilisateur surveillé - ";
+ }
if (check_ip('unsafe')) {
unset($err);
// }}}
// {{{ function check_mat
-function check_mat($promo, $mat, $nom, $prenom, &$ourmat, &$ourid)
+function check_mat($promo, $mat, $nom, $prenom, &$ourmat, &$ourid, &$watch)
{
if (!preg_match('/^[0-9][0-9][0-9][0-9][0-9][0-9]$/', $mat)) {
return "Le matricule doit comporter 6 chiffres.";
}
$res = XDB::query(
- 'SELECT user_id, promo, perms IN ("admin","user"), nom, prenom
+ 'SELECT user_id, promo, perms IN ("admin","user"), nom, prenom, FIND_IN_SET(\'watch\', u.flags)
FROM auth_user_md5
WHERE matricule={?} and deces = 0', $ourmat);
- list ($uid, $_promo, $_already, $_nom, $_prenom) = $res->fetchOneRow();
+ list ($uid, $_promo, $_already, $_nom, $_prenom, $watch) = $res->fetchOneRow();
if ($_already) { return "tu es déjà inscrit ou ton matricule est incorrect !"; }
if ($_promo != $promo) { return "erreur de matricule"; }
// }}}
// {{{ function check_old_mat
-function check_old_mat($promo, $mat, $nom, $prenom, &$ourmat, &$ourid)
+function check_old_mat($promo, $mat, $nom, $prenom, &$ourmat, &$ourid, &$watch)
{
$res = XDB::iterRow(
- 'SELECT user_id, nom, prenom, matricule
+ 'SELECT user_id, nom, prenom, matricule, FIND_IN_SET(\'watch\', flags)
FROM auth_user_md5
WHERE promo={?} AND deces=0 AND perms="pending"', $promo);
- while (list($_uid, $_nom, $_prenom, $_mat) = $res->next()) {
+ while (list($_uid, $_nom, $_prenom, $_mat, $watch) = $res->next()) {
if (user_cmp($prenom, $nom, $_prenom, $_nom)) {
$ourid = $_uid;
$ourmat = $_mat;
}
$res = XDB::iterRow(
- 'SELECT user_id, nom, prenom, matricule, alias
+ 'SELECT user_id, nom, prenom, matricule, alias, FIND_IN_SET(\'watch\', u.flags)
FROM auth_user_md5 AS u
INNER JOIN aliases AS a ON (u.user_id = a.id and FIND_IN_SET("bestalias", a.flags))
WHERE promo={?} AND deces=0 AND perms IN ("user","admin")', $promo);
- while (list($_uid, $_nom, $_prenom, $_mat, $alias) = $res->next()) {
+ while (list($_uid, $_nom, $_prenom, $_mat, $alias, $watch) = $res->next()) {
if (user_cmp($prenom, $nom, $_prenom, $_nom)) {
$ourid = $_uid;
$ourmat = $_mat;
$nom = strtoupper(replace_accent($nom));
if ($promo >= 1996) {
- $res = check_mat($promo, $mat, $nom, $prenom, $ourmat, $ourid);
+ $res = check_mat($promo, $mat, $nom, $prenom, $ourmat, $ourid, $watch);
} else {
- $res = check_old_mat($promo, $mat, $nom, $prenom, $ourmat, $ourid);
+ $res = check_old_mat($promo, $mat, $nom, $prenom, $ourmat, $ourid, $watch);
}
if ($res !== true) { return $res; }
$sub['prenom'] = $prenom;
$sub['ourmat'] = $ourmat;
$sub['uid'] = $ourid;
+ $sub['watch'] = $watch;
return true;
}
Sexe
</td>
<td>
- femme <input type="radio" name="sexeN" {if $mr.sexe eq 'femme'}checked="checked"{/if} value='femme'/>
- <input type="radio" name="sexeN" {if $mr.sexe neq 'femme'}checked="checked"{/if} value=''/> homme
+ femme <input type="radio" name="sexeN" {if $mr.sexe}checked="checked"{/if} value='1'/>
+ <input type="radio" name="sexeN" {if !$mr.sexe}checked="checked"{/if} value='0'/> homme
</td>
</tr>
<tr class="pair">
<input type="text" name="promoN" size="4" maxlength="4" value="{$mr.promo}" />
</td>
</tr>
+ <tr class "impair">
+ <td class="titre">
+ Surveillance
+ </td>
+ <td>
+ <input type="checkbox" name="watchN" {if $mr.watch}checked="checked"{/if} />
+ Surveiller l'activité de ce compte<br />
+ <span class="smaller">Cette option permet d'avoir des logs complets de l'activité
+ du compte via le logger, et d'être alerté lors des connexions de l'utilisateur</span>
+ </td>
+ </tr>
<tr class="impair">
<td class="titre">
Commentaire
--- /dev/null
+alter table auth_user_md5 change flags flags set('femme', 'watch') not null;
+
+# vim:set syntax=mysql: