X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=sidebyside;f=include%2Fregister.inc.php;h=04d56a6b354af1c83273c0a3ad68c1b7336291aa;hb=77254e96f9bb2fd88258f00bd72719b60dcd0456;hp=aa5e0d6cd3cae39f3c3f1a7c3513413d520a060b;hpb=e945001b40c2dcd28dd739895a36b0029cd9118e;p=platal.git
diff --git a/include/register.inc.php b/include/register.inc.php
index aa5e0d6..04d56a6 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,31 +168,29 @@ 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() ) {
list($h_id, $h_type, $expire) = $res->fetchOneRow();
- $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');
@@ -246,26 +240,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@staff.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);