X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fregister.inc.php;h=638df1350ba51e5ce5acd0f00a305765525b14a0;hb=4f9e482c39da76dd070b517485b79470d5ffc51b;hp=3a5b51f3fd0f976f3fb8c8954aa5aa794dd5dff7;hpb=eb8e3f3c080e398ad93ae933e0f511cc817855a3;p=platal.git
diff --git a/include/register.inc.php b/include/register.inc.php
index 3a5b51f..638df13 100644
--- a/include/register.inc.php
+++ b/include/register.inc.php
@@ -1,6 +1,6 @@
xdb->query(
+ $res = XDB::query(
'SELECT user_id, promo, perms IN ("admin","user"), nom, prenom
FROM auth_user_md5
WHERE matricule={?} and deces = 0', $ourmat);
@@ -105,9 +104,7 @@ function check_mat($promo, $mat, $nom, $prenom, &$ourmat, &$ourid)
function check_old_mat($promo, $mat, $nom, $prenom, &$ourmat, &$ourid)
{
- global $globals;
-
- $res = $globals->xdb->iterRow(
+ $res = XDB::iterRow(
'SELECT user_id, nom, prenom, matricule
FROM auth_user_md5
WHERE promo={?} AND deces=0 AND perms="pending"', $promo);
@@ -119,7 +116,7 @@ function check_old_mat($promo, $mat, $nom, $prenom, &$ourmat, &$ourid)
}
}
- $res = $globals->xdb->iterRow(
+ $res = XDB::iterRow(
'SELECT user_id, nom, prenom, matricule, alias
FROM auth_user_md5 AS u
INNER JOIN aliases AS a ON (u.user_id = a.id and FIND_IN_SET("bestalias", a.flags))
@@ -139,7 +136,6 @@ function check_old_mat($promo, $mat, $nom, $prenom, &$ourmat, &$ourid)
function check_new_user(&$sub)
{
- global $globals;
extract($sub);
$prenom = preg_replace("/[ \t]+/", ' ', trim($prenom));
@@ -172,20 +168,19 @@ function check_new_user(&$sub)
function create_aliases (&$sub)
{
- global $globals;
extract ($sub);
$mailorg = make_username($prenom, $nom);
$mailorg2 = $mailorg.sprintf(".%02u", ($promo%100));
$forlife = make_forlife($prenom, $nom, $promo);
- $res = $globals->xdb->query('SELECT COUNT(*) FROM aliases WHERE alias={?}', $forlife);
+ $res = XDB::query('SELECT COUNT(*) FROM aliases WHERE alias={?}', $forlife);
if ($res->fetchOneCell() > 0) {
return "Tu as un homonyme dans ta promo, il faut traiter ce cas manuellement.
".
"envoie un mail à support@polytechnique.org en expliquant ta situation.";
}
- $res = $globals->xdb->query('SELECT id, type, expire FROM aliases WHERE alias={?}', $mailorg);
+ $res = XDB::query('SELECT id, type, expire FROM aliases WHERE alias={?}', $mailorg);
if ( $res->numRows() ) {
@@ -193,10 +188,10 @@ function create_aliases (&$sub)
$res->free();
if ( $h_type != 'homonyme' and empty($expire) ) {
- $globals->xdb->execute('UPDATE aliases SET expire=ADDDATE(NOW(),INTERVAL 1 MONTH) WHERE alias={?}', $mailorg);
- $globals->xdb->execute('REPLACE INTO homonymes (homonyme_id,user_id) VALUES ({?},{?})', $h_id, $h_id);
- $globals->xdb->execute('REPLACE INTO homonymes (homonyme_id,user_id) VALUES ({?},{?})', $h_id, $uid);
- $res = $globals->xdb->query("SELECT alias FROM aliases WHERE id={?} AND expire IS NULL", $h_id);
+ XDB::execute('UPDATE aliases SET expire=ADDDATE(NOW(),INTERVAL 1 MONTH) WHERE alias={?}', $mailorg);
+ XDB::execute('REPLACE INTO homonymes (homonyme_id,user_id) VALUES ({?},{?})', $h_id, $h_id);
+ XDB::execute('REPLACE INTO homonymes (homonyme_id,user_id) VALUES ({?},{?})', $h_id, $uid);
+ $res = XDB::query("SELECT alias FROM aliases WHERE id={?} AND expire IS NULL", $h_id);
$als = $res->fetchColumn();
require_once('diogenes/diogenes.hermes.inc.php');
@@ -206,17 +201,26 @@ function create_aliases (&$sub)
$mailer->setSubject("perte de ton alias $mailorg dans un mois !");
$mailer->addCc('"Support Polytechnique.org" ');
$msg =
- "Un homonyme s'est inscrit, nous ne pouvons donc garder ton alias '$mailorg'.\n\n".
+ "Bonjour,\n\n".
+
+ "Un homonyme vient de s'inscrire. La politique de Polytechnique.org est de fournir des\n".
+ "adresses mail devinables, nous ne pouvons donc pas conserver ton alias '$mailorg' qui\n".
+ "correspond maintenant à deux personnes.\n\n".
+
"Tu gardes tout de même l'usage de cet alias pour un mois encore à compter de ce jour.\n\n".
- "Lorsque cet alias sera désactivé, l'adresse :\n".
- " $mailorg@polytechnique.org\n".
- "renverra vers un robot qui indique qu'il y a plusieurs personnes portant le même nom ;\n".
+
+ "Lorsque cet alias sera désactivé, l'adresse $mailorg@polytechnique.org renverra vers un \n".
+ "robot qui indiquera qu'il y a plusieurs personnes portant le même nom ;\n".
"cela évite que l'un des homonymes reçoive des courriels destinés à l'autre.\n\n".
- "Pour te connecter au site, tu pourras utiliser comme identifiant n'importe lequel de tes autres alias :\n".
+
+ "Pour te connecter au site, tu pourras utiliser comme identifiant n'importe lequel de tes\n".
+ "autres alias :\n".
" ".join(', ', $als)."\n";
"Commence dès aujourd'hui à communiquer à tes correspondants la nouvelle adresse que tu comptes utiliser !\n\n".
+
"En nous excusant pour le désagrément occasionné,\n".
- "cordialement,\n".
+ "Cordialement,\n\n".
+
"-- \n".
"L'équipe de Polytechnique.org\n".
"\"Le portail des élèves & anciens élèves de l'X\"";
@@ -237,26 +241,44 @@ function create_aliases (&$sub)
}
// }}}
+// {{{ function send_alert_mail
+
+function send_alert_mail($state, $body)
+{
+ require_once("diogenes/diogenes.hermes.inc.php");
+ $mailer = new HermesMailer();
+ $mailer->setFrom("webmaster@polytechnique.org");
+ $mailer->addTo("hotliners@polytechnique.org");
+ $mailer->setSubject("ALERTE LORS DE L'INSCRIPTION de "
+ . $state['prenom'] . ' ' . $state['nom'] . '(' . $promo . ')');
+ $mailer->setTxtBody($body
+ . "\n\nIndentifiants :\n" . var_export($state, true)
+ . "\n\nInformations de connexion :\n" . var_export($_SERVER, true));
+ $mailer->send();
+}
+
+// }}}
// {{{ function finish_ins
function finish_ins($sub_state)
{
global $globals;
extract($sub_state);
+ require_once('secure_hash.inc.php');
$pass = rand_pass();
- $pass_md5 = md5($pass_clair);
+ $pass_encrypted = hash_encrypt($pass_clair);
$hash = rand_url_id(12);
- $globals->xdb->execute('UPDATE auth_user_md5 SET last_known_email={?} WHERE matricule = {?}', $email, $mat);
+ XDB::execute('UPDATE auth_user_md5 SET last_known_email={?} WHERE matricule = {?}', $email, $mat);
- $globals->xdb->execute(
+ XDB::execute(
"REPLACE INTO register_pending (uid, forlife, bestalias, mailorg2, password, email, date, relance, naissance, hash)
VALUES ({?}, {?}, {?}, {?}, {?}, {?}, NOW(), 0, {?}, {?})",
- $uid, $forlife, $bestalias, $mailorg2, $pass_md5, $email, $naissance, $hash);
+ $uid, $forlife, $bestalias, $mailorg2, $pass_encrypted, $email, $naissance, $hash);
require_once('xorg.mailer.inc.php');
- $mymail = new XOrgMailer('inscrire.mail.tpl');
+ $mymail = new XOrgMailer('register/inscrire.mail.tpl');
$mymail->assign('mailorg', $bestalias);
$mymail->assign('lemail', $email);
$mymail->assign('pass', $pass);