X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=sidebyside;f=modules%2Fregister.php;h=7fea99343bd02556a121ebe95cd4446b6938e8a7;hb=e8dfa21cb3ade890694157170de1a1c6d7519531;hp=69a8ae59fe17098b8347b058b4e7dec7fa6b5dc3;hpb=756ff73fbb0cdd01cce2eda27ba18e1cc99bd735;p=platal.git diff --git a/modules/register.php b/modules/register.php index 69a8ae5..7fea993 100644 --- a/modules/register.php +++ b/modules/register.php @@ -148,8 +148,10 @@ class RegisterModule extends PLModule $err[] = "La 'Date de naissance' n'est pas correcte."; } else { $birth = explode('/', $birth, 3); - $year = intval($birth[2]); - if ($year < 100) $year += 1900; + 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."; @@ -159,20 +161,18 @@ 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(); - while(list($gstate, $gdescription, $alias) = $res->next()) { - $state = $gstate; - $description = $gdescription; - $aliases[] = $alias; - } - if (count($aliases) != 0) { + $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; + 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; + } } if ($sub_state['watch']) { $alter .= "Inscription d'un utilisateur surveillé - "; @@ -191,12 +191,16 @@ class RegisterModule extends PLModule $alert .= "Date de naissance incorrecte à l'inscription - "; } $sub_state['email'] = Post::v('email'); - if (check_ip('unsafe')) { + $ip_banned = check_ip('unsafe'); + if ($ip_banned) { + $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 = 3) { @@ -326,7 +330,7 @@ class RegisterModule extends PLModule $res = XDB::iterRow( "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 + 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 @@ -336,8 +340,8 @@ class RegisterModule extends PLModule XDB::execute("UPDATE register_mstats SET success=NOW() WHERE uid={?}", $uid); $market = array(); - while (list($salias, $snom, $sprenom, $sfemme, $mails) = $res->next()) { - $market[] = " - par $snom $sprenom sur $mails"; + 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 +363,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" @@ -369,9 +374,13 @@ class RegisterModule extends PLModule . " - sexe : $femme\n" . " - ip : {$logger->ip} ({$logger->host})\n" . ($logger->proxy_ip ? " - proxy : {$logger->proxy_ip} ({$logger->proxy_host})\n" : "") - . "\n\n" - . "Les marketings suivants avaient été effectués :\n" - . implode("\n", $market); + . "\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 de mail de marketing."; + } $mymail->setTxtBody($msg); $mymail->send(); } @@ -384,6 +393,7 @@ class RegisterModule extends PLModule function handler_success(&$page) { + global $globals; $page->changeTpl('register/success.tpl'); $_SESSION['sub_state'] = array('step' => 5); @@ -394,6 +404,17 @@ 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 user /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::v('uid'), S::v('forlife')); + if ($account->active() && $account->sync_password) { + $account->set_password($password); + } + } + $log = S::v('log'); $log->log('passwd', ''); @@ -466,6 +487,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'); }