X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=sidebyside;f=modules%2Fregister.php;h=f77841c4c022aa6f2e57d655e37f4e03a1187d2a;hb=335363539b00f89cbc2009491c36bb29fc22f0a0;hp=2f6cfccf34e86c58856478a7bb63e887d063b5c5;hpb=7943b417bce3f7a6eafd3ee0ebb9519309c24aed;p=platal.git
diff --git a/modules/register.php b/modules/register.php
index 2f6cfcc..f77841c 100644
--- a/modules/register.php
+++ b/modules/register.php
@@ -1,6 +1,6 @@
buildCache();
if (Post::has('step1')) {
$sub_state['step'] = 1;
if (isset($sub_state['hash'])) {
$sub_state['step'] = 3;
- require_once(dirname(__FILE__) . '/register/register.inc.php');
+ $this->load('register.inc.php');
create_aliases($sub_state);
}
}
@@ -119,7 +119,7 @@ class RegisterModule extends PLModule
case 2:
if (count($_POST)) {
- require_once(dirname(__FILE__) . '/register/register.inc.php');
+ $this->load('register.inc.php');
$sub_state['prenom'] = Post::v('prenom');
$sub_state['nom'] = Post::v('nom');
$sub_state['mat'] = Post::v('mat');
@@ -136,7 +136,8 @@ class RegisterModule extends PLModule
case 3:
if (count($_POST)) {
- require_once(dirname(__FILE__) . '/register/register.inc.php');
+ $this->load('register.inc.php');
+ require_once 'emails.inc.php';
if (!isvalid_email(Post::v('email'))) {
$err[] = "Le champ 'E-mail' n'est pas valide.";
} elseif (!isvalid_email_redirection(Post::v('email'))) {
@@ -144,10 +145,14 @@ class RegisterModule extends PLModule
"valide, en particulier, il ne peut pas être renvoyé vers lui-même.";
}
$birth = trim(Env::v('naissance'));
- if (!preg_match('/^[0-3][0-9][01][0-9][12][90][0-9][0-9]$/', $birth)) {
+ if (!preg_match('@^[0-3]?\d/[01]?\d/(19|20)?\d{2}$@', $birth)) {
$err[] = "La 'Date de naissance' n'est pas correcte.";
} else {
- $year = (int)substr($birth, 4, 4);
+ $birth = explode('/', $birth, 3);
+ for ($i = 0; $i < 3; $i++)
+ $birth[$i] = intval($birth[$i]);
+ if ($birth[2] < 100) $birth[2] += 1900;
+ $year = $birth[2];
$promo = (int)$sub_state['promo'];
if ($year > $promo - 15 || $year < $promo - 30) {
$err[] = "La 'Date de naissance' n'est pas correcte.";
@@ -157,27 +162,21 @@ class RegisterModule extends PLModule
}
// Check if the given email is known as dangerous
- $res = Xdb::iterRow("SELECT w.state, w.description, a.alias
- FROM emails AS e
- INNER JOIN emails_watch AS w ON (e.email = w.email AND w.state != 'safe')
- INNER JOIN aliases AS a ON (e.uid = a.id AND a.type = 'a_vie')
- WHERE e.email = {?}
- ORDER BY a.alias", Post::v('email'));
- $aliases = array();
+ $res = XDB::query("SELECT w.state, w.description
+ FROM emails_watch AS w
+ WHERE w.email = {?} AND w.state != 'safe'",
+ Post::v('email'));
$email_banned = false;
- while(list($gstate, $gdescription, $alias) = $res->next()) {
- $state = $gstate;
+ if ($res->numRows()) {
+ list($state, $description) = $res->fetchOneRow();
+ $alert .= "Email surveille propose a l'inscription - ";
+ $sub_state['email_desc'] = $description;
if ($state == 'dangerous') {
$email_banned = true;
}
- $description = $gdescription;
- $aliases[] = $alias;
- }
- if (count($aliases) != 0) {
- $alert .= "Email surveille propose a l'inscription - ";
}
if ($sub_state['watch']) {
- $alter .= "Inscription d'un utilisateur surveillé - ";
+ $alert .= "Inscription d'un utilisateur surveillé - ";
}
if (check_ip('unsafe')) {
@@ -187,10 +186,8 @@ class RegisterModule extends PLModule
if (isset($err)) {
$err = join('
', $err);
} else {
- $sub_state['naissance'] = sprintf("%s-%s-%s",
- substr($birth,4,4),
- substr($birth,2,2),
- substr($birth,0,2));
+ $sub_state['naissance'] = sprintf("%04d-%02d-%02d",
+ intval($birth[2]), intval($birth[1]), intval($birth[0]));
if ($sub_state['naissance_ini'] != '0000-00-00' && $sub_state['naissance'] != $sub_state['naissance_ini']) {
$alert .= "Date de naissance incorrecte à l'inscription - ";
}
@@ -200,6 +197,7 @@ class RegisterModule extends PLModule
$alert .= "Tentative d'inscription depuis une IP surveillee";
}
if ($email_banned || $ip_banned) {
+ global $globals;
$err = "Une erreur s'est produite lors de l'inscription."
. " Merci de contacter changeTpl('register/step'.intval($sub_state['step']).'.tpl');
if (isset($err)) {
- $page->trig($err);
+ $page->trigError($err);
}
}
@@ -299,26 +297,51 @@ class RegisterModule extends PLModule
}
require_once('emails.inc.php');
- $redirect = new Redirect($uid);
+ $user = User::getSilent($uid);
+ $redirect = new Redirect($user);
$redirect->add_email($email);
// on cree un objet logger et on log l'inscription
- $logger = new CoreLogger($uid);
- $logger->log('inscription', $email);
-
+ S::logger($uid)->log('inscription', $email);
XDB::execute('UPDATE register_pending SET hash="INSCRIT" WHERE uid={?}', $uid);
- global $platal;
- $platal->on_subscribe($forlife, $uid, $promo, $password);
$mymail = new PlMailer('register/inscription.reussie.tpl');
$mymail->assign('forlife', $forlife);
$mymail->assign('prenom', $prenom);
$mymail->send();
+ // Enable search on the user
require_once('user.func.inc.php');
user_reindex($uid);
+ // Add notification for people looking for this registration
+ require_once 'notifs.inc.php';
+ register_watch_op($uid, WATCH_INSCR);
+ inscription_notifs_base($uid);
+
+ // Default registration on forums
+ $p_for = 'xorg.promo.x' . $promo;
+ $cible = array('xorg.general', 'xorg.pa.divers', 'xorg.pa.logements', $p_for);
+ foreach ($cible as $val) {
+ XDB::execute("INSERT INTO forums.abos (fid,uid)
+ SELECT fid, {?} FROM forums.list WHERE nom={?}", $uid, $val);
+ if (XDB::affectedRows() == 0 && $val == $p_for) {
+ $res = XDB::query("SELECT SUM(perms IN ('admin','user') AND deces = 0), COUNT(*)
+ FROM auth_user_md5
+ WHERE promo = {?}", $promo);
+ list($effau, $effid) = $res->fetchOneRow();
+ if (5 * $effau > $effid) { // +
+ $mymail = new PlMailer('admin/forums-promo.mail.tpl');
+ $mymail->assign('promo', $promo);
+ $mymail->send();
+ }
+ }
+ }
+
+ // update number of subscribers (perms has changed)
+ $globals->updateNbIns();
+
if (!start_connexion($uid, false)) {
return PL_FORBIDDEN;
}
@@ -328,16 +351,21 @@ class RegisterModule extends PLModule
/************* envoi d'un mail au démarcheur ***************/
/***********************************************************/
$res = XDB::iterRow(
- "SELECT DISTINCT sa.alias, IF(s.nom_usage,s.nom_usage,s.nom) AS nom,
- s.prenom, FIND_IN_SET('femme', s.flags) AS femme
+ "SELECT sa.alias, IF(s.nom_usage,s.nom_usage,s.nom) AS nom,
+ s.prenom, FIND_IN_SET('femme', s.flags) AS femme,
+ GROUP_CONCAT(m.email) AS mails, MAX(m.last) AS dateDernier
FROM register_marketing AS m
INNER JOIN auth_user_md5 AS s ON ( m.sender = s.user_id )
INNER JOIN aliases AS sa ON ( sa.id = m.sender
AND FIND_IN_SET('bestalias', sa.flags) )
- WHERE m.uid = {?}", $uid);
+ WHERE m.uid = {?}
+ GROUP BY m.sender
+ ORDER BY dateDernier DESC", $uid);
XDB::execute("UPDATE register_mstats SET success=NOW() WHERE uid={?}", $uid);
- while (list($salias, $snom, $sprenom, $sfemme) = $res->next()) {
+ $market = array();
+ while (list($salias, $snom, $sprenom, $sfemme, $mails, $dateDernier) = $res->next()) {
+ $market[] = " - par $snom $sprenom sur $mails (le plus récemment le $dateDernier)";
$mymail = new PlMailer();
$mymail->setSubject("$prenom $nom s'est inscrit à Polytechnique.org !");
$mymail->setFrom('"Marketing Polytechnique.org" mail->domain . '>');
@@ -359,6 +387,7 @@ class RegisterModule extends PLModule
$mymail->setSubject("Inscription de $prenom $nom (X$promo)");
$mymail->setFrom('"Webmaster Polytechnique.org" mail->domain . '>');
$mymail->addTo($globals->register->notif);
+ $mymail->addHeader('Reply-To', $globals->register->notif);
$msg = "$prenom $nom (X$promo) a terminé son inscription avec les données suivantes :\n"
. " - nom : $nom\n"
. " - prenom : $prenom\n"
@@ -368,7 +397,14 @@ class RegisterModule extends PLModule
. " - email : $email\n"
. " - sexe : $femme\n"
. " - ip : {$logger->ip} ({$logger->host})\n"
- . ($logger->proxy_ip ? " - proxy : {$logger->proxy_ip} ({$logger->proxy_host})\n" : "");
+ . ($logger->proxy_ip ? " - proxy : {$logger->proxy_ip} ({$logger->proxy_host})\n" : "")
+ . "\n\n";
+ if (count($market) > 0) {
+ $msg .= "Les marketings suivants avaient été effectués :\n"
+ . implode("\n", $market);
+ } else {
+ $msg .= "$prenom $nom n'a jamais reçu d\'email de marketing.";
+ }
$mymail->setTxtBody($msg);
$mymail->send();
}
@@ -381,7 +417,9 @@ class RegisterModule extends PLModule
function handler_success(&$page)
{
+ global $globals;
$page->changeTpl('register/success.tpl');
+ $page->assign('user', S::user());
$_SESSION['sub_state'] = array('step' => 5);
if (Env::has('response2')) {
@@ -391,8 +429,19 @@ class RegisterModule extends PLModule
WHERE user_id={?}', $password,
S::v('uid'));
+ // If GoogleApps is enabled, and the user did choose to use synchronized passwords,
+ // and if the (stupid) user has decided to use /register/success another time,
+ // updates the Google Apps password as well.
+ if ($globals->mailstorage->googleapps_domain) {
+ require_once 'googleapps.inc.php';
+ $account = new GoogleAppsAccount(S::user());
+ if ($account->active() && $account->sync_password) {
+ $account->set_password($password);
+ }
+ }
+
$log = S::v('log');
- $log->log('passwd', '');
+ S::logger()->log('passwd', '');
if (Cookie::v('ORGaccess')) {
require_once('secure_hash.inc.php');
@@ -438,7 +487,7 @@ class RegisterModule extends PLModule
NewsLetter::subscribe();
}
if (Post::v('add_to_ax')) {
- require_once dirname(__FILE__) . '/axletter/axletter.inc.php';
+ Platal::load('axletter', 'axletter.inc.php');
AXLetter::subscribe();
}
if (Post::v('add_to_promo')) {
@@ -463,6 +512,11 @@ class RegisterModule extends PLModule
$client->subscribe($sub);
}
}
+ if (Post::v('imap')) {
+ require_once 'emails.inc.php';
+ $storage = new EmailStorage(S::v('uid'), 'imap');
+ $storage->activate();
+ }
pl_redirect('profile/edit');
}