Example #1
0
function send_robot_homonym(PlUser $user, $email)
{
    $cc = "validation+homonyme@" . Platal::globals()->mail->domain;
    $from = "\"Support Polytechnique.org\" <{$cc}>";
    $body = Post::has('mailbody') ? Post::t('mailbody') : get_robot_mail_text($user, $email);
    $user = User::getSilentWithUID($user->id());
    $mymail = new PlMailer();
    $mymail->setFrom($from);
    $mymail->setSubject("Mise en place du robot {$email}@" . $user->mainEmailDomain());
    $mymail->addCc($cc);
    $mymail->setTxtBody($body);
    $mymail->sendTo($user);
}
Example #2
0
 protected function sendmail($isok)
 {
     // Only sends email if the profile's owner exists and is registered.
     if ($this->ownerIsRegistered) {
         global $globals;
         $mailer = new PlMailer();
         $mailer->setSubject($this->_mail_subj());
         $mailer->setFrom("validation+{$this->type}@{$globals->mail->domain}");
         $mailer->addTo("\"{$this->profile->fullName()}\" <{$this->profileOwner->bestEmail()}>");
         $mailer->addCc("validation+{$this->type}@{$globals->mail->domain}");
         $body = ($this->profile->isFemale() ? "Chère camarade,\n\n" : "Cher camarade,\n\n") . $this->_mail_body($isok) . (Env::has('comm') ? "\n\n" . Env::v('comm') : '') . "\n\nCordialement,\n-- \nL'équipe de Polytechnique.org\n" . $this->_mail_ps($isok);
         $mailer->setTxtBody(wordwrap($body));
         $mailer->send();
     }
 }
Example #3
0
 function handler_moderate($page, $liste = null)
 {
     if (is_null($liste)) {
         return PL_NOT_FOUND;
     }
     $mlist = $this->prepare_list($liste);
     if (!$this->is_group_admin($page)) {
         $this->verify_list_owner($page, $mlist);
     }
     $page->changeTpl('lists/moderate.tpl');
     $page->register_modifier('hdc', 'list_header_decode');
     if (Env::has('sadd') || Env::has('sdel')) {
         S::assert_xsrf_token();
         if (Env::has('sadd')) {
             // Ensure the moderated request is still active
             $sub = $mlist->getPendingSubscription(Env::v('sadd'));
             $mlist->handleRequest(MailingList::REQ_SUBSCRIBE, Env::v('sadd'));
             $info = "validée";
         }
         if (Post::has('sdel')) {
             // Ensure the moderated request is still active
             $sub = $mlist->getPendingSubscription(Env::v('sdel'));
             $mlist->handleRequest(MailingList::REQ_REJECT, Post::v('sdel'), Post::v('reason'));
             $info = "refusée";
         }
         if ($sub) {
             $mailer = new PlMailer();
             $mailer->setFrom($mlist->getAddress(MailingList::KIND_BOUNCE));
             $mailer->addTo($mlist->getAddress(MailingList::KIND_OWNER));
             $mailer->addHeader('Reply-To', $mlist->getAddress(MailingList::KIND_OWNER));
             $mailer->setSubject("L'inscription de {$sub['name']} a été {$info}");
             $text = "L'inscription de {$sub['name']} à la liste " . $mlist->address . " a été {$info} par " . S::user()->fullName(true) . ".\n";
             if (trim(Post::v('reason'))) {
                 $text .= "\nLa raison invoquée est :\n" . Post::v('reason');
             }
             $mailer->setTxtBody(wordwrap($text, 72));
             $mailer->send();
         }
         if (Env::has('sadd')) {
             pl_redirect('lists/moderate/' . $liste);
         }
     }
     if (Post::has('moderate_mails') && Post::has('select_mails')) {
         S::assert_xsrf_token();
         $mails = array_keys(Post::v('select_mails'));
         foreach ($mails as $mail) {
             $this->moderate_mail($mlist, $mail);
         }
     } elseif (Env::has('mid')) {
         if (Get::has('mid') && !Env::has('mok') && !Env::has('mdel')) {
             require_once 'banana/moderate.inc.php';
             $page->changeTpl('lists/moderate_mail.tpl');
             $params = array('listname' => $mlist->mbox, 'domain' => $mlist->domain, 'artid' => Get::i('mid'), 'part' => Get::v('part'), 'action' => Get::v('action'));
             $params['client'] = $this->prepare_client();
             run_banana($page, 'ModerationBanana', $params);
             $msg = file_get_contents('/etc/mailman/fr/refuse.txt');
             $msg = str_replace("%(adminaddr)s", $mlist->getAddress(MailingList::KIND_OWNER), $msg);
             $msg = str_replace("%(request)s", "<< SUJET DU MAIL >>", $msg);
             $msg = str_replace("%(reason)s", "<< TON EXPLICATION >>", $msg);
             $msg = str_replace("%(listname)s", $liste, $msg);
             $page->assign('msg', $msg);
             return;
         }
         $this->moderate_mail($mlist, Env::i('mid'));
     } elseif (Env::has('sid')) {
         if (list($subs, $mails) = $this->get_pending_ops($mlist)) {
             foreach ($subs as $user) {
                 if ($user['id'] == Env::v('sid')) {
                     $page->changeTpl('lists/moderate_sub.tpl');
                     $page->assign('del_user', $user);
                     return;
                 }
             }
         }
     }
     if (list($subs, $mails) = $this->get_pending_ops($mlist)) {
         foreach ($mails as $key => $mail) {
             $mails[$key]['stamp'] = strftime("%Y%m%d%H%M%S", $mail['stamp']);
             if ($mail['fromx']) {
                 $page->assign('with_fromx', true);
             } else {
                 $page->assign('with_nonfromx', true);
             }
         }
         $page->assign_by_ref('subs', $subs);
         $page->assign_by_ref('mails', $mails);
     } else {
         $page->kill("La liste n'existe pas ou tu n'as pas le droit de la modérer.");
     }
 }
Example #4
0
    function handler_recovery($page)
    {
        global $globals;
        $page->changeTpl('platal/recovery.tpl');
        if (!Env::has('login') || !Env::has('birth')) {
            return;
        }
        if (!preg_match('/^[0-3][0-9][0-1][0-9][1][9]([0-9]{2})$/', Env::v('birth'))) {
            $page->trigError('Date de naissance incorrecte ou incohérente');
            return;
        }
        $birth = sprintf('%s-%s-%s', substr(Env::v('birth'), 4, 4), substr(Env::v('birth'), 2, 2), substr(Env::v('birth'), 0, 2));
        $mailorg = strtok(Env::v('login'), '@');
        $profile = Profile::get(Env::t('login'));
        if (is_null($profile) || $profile->birthdate != $birth) {
            $page->trigError('Les informations que tu as rentrées ne permettent pas de récupérer ton mot de passe.<br />' . 'Si tu as un homonyme, utilise prenom.nom.promo comme login');
            return;
        }
        $user = $profile->owner();
        if ($user->state != 'active') {
            $page->trigError('Ton compte n\'est pas activé.');
            return;
        }
        if ($user->lost) {
            $page->assign('no_addr', true);
            return;
        }
        $page->assign('ok', true);
        $url = rand_url_id();
        XDB::execute('INSERT INTO  account_lost_passwords (certificat,uid,created)
                           VALUES  ({?},{?},NOW())', $url, $user->id());
        $to = XDB::fetchOneCell('SELECT  redirect
                                   FROM  email_redirect_account
                                  WHERE  uid = {?} AND redirect = {?}', $user->id(), Post::t('email'));
        if (is_null($to)) {
            $emails = XDB::fetchColumn('SELECT  redirect
                                          FROM  email_redirect_account
                                         WHERE  uid = {?} AND flags = \'inactive\' AND type = \'smtp\'', $user->id());
            $inactives_to = implode(', ', $emails);
        }
        $mymail = new PlMailer();
        $mymail->setFrom('"Gestion des mots de passe" <support+password@' . $globals->mail->domain . '>');
        if (is_null($to)) {
            $mymail->addTo($user);
            $log_to = $user->bestEmail();
            if (!is_null($inactives_to)) {
                $log_to = $inactives_to . ', ' . $log_to;
                $mymail->addTo($inactives_to);
            }
        } else {
            $mymail->addTo($to);
            $log_to = $to;
        }
        $mymail->setSubject("Ton certificat d'authentification");
        $mymail->setTxtBody("Visite la page suivante qui expire dans six heures :\n{$globals->baseurl}/tmpPWD/{$url}\n\nSi en cliquant dessus tu n'y arrives pas, copie intégralement l'adresse dans la barre de ton navigateur. Si tu n'as pas utilisé ce lien dans six heures, tu peux tout simplement recommencer cette procédure.\n\n--\nPolytechnique.org\n\"Le portail des élèves & anciens élèves de l'École polytechnique\"\n\nEmail envoyé à " . Env::v('login') . (is_null($to) ? '' : '
Adresse de secours : ' . $to));
        $mymail->send();
        S::logger($user->id())->log('recovery', $log_to);
    }
Example #5
0
 public function commit()
 {
     global $globals;
     $email = $this->m_user->bestEmail();
     XDB::execute('UPDATE  email_redirect_account
                      SET  flags = \'active\', broken_level = 2
                    WHERE  uid = {?} AND redirect = {?}', $this->m_user->id(), $this->m_email);
     if (XDB::affectedRows() > 0) {
         $this->m_reactive = true;
         $mailer = new PlMailer();
         $mailer->setFrom('"Association Polytechnique.org" <register@' . $globals->mail->domain . '>');
         $mailer->addTo($email);
         $mailer->setSubject("Mise à jour de ton adresse {$email}");
         $mailer->setTxtBody(wordwrap("Cher Camarade,\n\n" . "Ton adresse {$email} étant en panne et ayant été informés que ta redirection {$this->m_email}, jusqu'à présent inactive, " . "est fonctionnelle, nous venons de réactiver cette adresse.\n\n" . "N'hésite pas à aller gérer toi-même tes redirections en te rendant à la page :\n" . "https://www.polytechnique.org/emails/redirect\n" . "Si tu as perdu ton mot de passe d'accès au site, tu peux également effectuer la procédure de récupération à l'adresse :\n" . "https://www.polytechnique.org/recovery\n\n" . "-- \nTrès Cordialement,\nL'Équipe de Polytechnique.org\n"));
         $mailer->send();
         return true;
     }
     if ($this->m_user->email) {
         $subject = "Ton adresse {$email} semble ne plus fonctionner";
         $reason = "Nous avons été informés que ton adresse {$email} ne fonctionne plus correctement par un camarade";
     } else {
         $res = XDB::iterRow('SELECT  redirect
                                FROM  email_redirect_account
                               WHERE  uid = {?} AND flags = \'broken\'', $this->m_user->id());
         $redirect = array();
         while (list($red) = $res->next()) {
             list(, $redirect[]) = explode('@', $red);
         }
         $subject = "Ton adresse {$email} ne fonctionne plus";
         $reason = "Ton adresse {$email} ne fonctionne plus";
         if (!count($redirect)) {
             $reason .= '.';
         } elseif (count($redirect) == 1) {
             $reason .= ' car sa redirection vers ' . $redirect[0] . ' est hors-service depuis plusieurs mois.';
         } else {
             $reason .= ' car ses redirections vers ' . implode(', ', $redirect) . ' sont hors-services depuis plusieurs mois.';
         }
     }
     $body = ($this->m_user->isFemale() ? 'Chère ' : 'Cher ') . $this->m_user->displayName() . ",\n\n" . $reason . "\n\n" . "L'adresse {$this->m_email} nous a été communiquée, veux-tu que cette adresse devienne ta nouvelle " . "adresse de redirection ? Si oui, envoie nous des informations qui " . "nous permettront de nous assurer de ton identité (par exemple ta date de naissance et ta promotion).\n\n" . "-- \nTrès Cordialement,\nL'Équipe de Polytechnique.org\n";
     $body = wordwrap($body, 78);
     $mailer = new PlMailer();
     $mailer->setFrom('"Association Polytechnique.org" <register@' . $globals->mail->domain . '>');
     $mailer->addTo($this->m_email);
     $mailer->setSubject($subject);
     $mailer->setTxtBody($body);
     return $mailer->send();
 }
Example #6
0
 function handler_rewrite_out($page, $mail, $hash)
 {
     $page->changeTpl('emails/rewrite.tpl');
     $page->assign('option', 'out');
     if (empty($mail) || empty($hash)) {
         return PL_NOT_FOUND;
     }
     $pos = strrpos($mail, '_');
     if ($pos === false) {
         return PL_NOT_FOUND;
     }
     $mail[$pos] = '@';
     $res = XDB::query('SELECT  COUNT(*)
                          FROM  email_redirect_account
                         WHERE  redirect = {?} AND hash = {?} AND type = \'smtp\'', $mail, $hash);
     $count = intval($res->fetchOneCell());
     if ($count > 0) {
         global $globals;
         $res = XDB::query('SELECT  e.redirect, e.rewrite, a.hruid
                              FROM  email_redirect_account AS e
                        INNER JOIN  accounts               AS a ON (e.uid = a.uid)
                             WHERE  e.redirect = {?} AND e.hash = {?}', $mail, $hash);
         XDB::query('UPDATE  email_redirect_account
                        SET  allow_rewrite = false, hash = NULL
                      WHERE  redirect = {?} AND hash = {?}', $mail, $hash);
         list($mail, $rewrite, $hruid) = $res->fetchOneRow();
         $mail = new PlMailer();
         $mail->setFrom("webmaster@" . $globals->mail->domain);
         $mail->addTo("support@" . $globals->mail->domain);
         $mail->setSubject("Tentative de détournement de correspondance via le rewrite");
         $mail->setTxtBody("{$hruid} a tenté un rewrite de {$mail} vers {$rewrite}. Cette demande a été rejetée via le web");
         $mail->send();
         $page->trigWarning("Un mail d'alerte a été envoyé à l'équipe de " . $globals->core->sitename);
         return;
     }
     return PL_NOT_FOUND;
 }
Example #7
0
    }
    $x_spam_flag = '';
    if (preg_match('/^X-Spam-Flag: ([a-zA-Z]+), tests=bogofilter/m', substr($raw_mail, 0, $end_of_headers + 1), $matches)) {
        $x_spam_flag = $matches[1];
    }
    if ($x_spam_flag == 'Unsure') {
        $mailer = new PlMailer();
        $mailer->addTo($type . '@' . $globals->mail->domain);
        $mailer->setFrom('"' . $fullname . '" <web@' . $globals->mail->domain . '>');
        $mailer->setTxtBody($type . ' soumis par ' . $fullname . ' via la modération de la liste ' . $list . '@' . $domain);
        $mailer->addAttachment($raw_mail, 'message/rfc822', $type . '.mail', false);
        $mailer->send();
    }
    // send feedback to the mailing list owners
    if ($mlist->handleRequest($action, $mid, $reason)) {
        $sent_mails += $count;
        $texte = "Le message suivant :\n\n" . "    Auteur: {$mail['sender']}\n" . "    Sujet : « {$mail['subj']} »\n" . "    Date  : " . strftime("le %d %b %Y à %H:%M:%S", (int) $mail['stamp']) . "\n\n" . $append;
        $mailer = new PlMailer();
        $mailer->addTo("{$list}-owner@{$domain}");
        $mailer->setFrom("{$list}-bounces@{$domain}");
        $mailer->addHeader('Reply-To', "{$list}-owner@{$domain}");
        $mailer->setSubject($subject);
        $mailer->setTxtBody($texte);
        $mailer->send();
    }
    // release the lock
    XDB::execute('DELETE FROM  email_list_moderate
                        WHERE  handler = {?}', $handler);
    sleep(60 * $count / $globals->lists->max_mail_per_min);
}
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8:
Example #8
0
} elseif ($age > 7) {
    $head = "[Armageddon imminent] ";
} elseif ($age > 5) {
    $head = "[Guerre nucléaire] ";
} elseif ($age > 3) {
    $head = "[ET Téléphone maison] ";
} elseif ($age > 1) {
    $head = "[Réveil !] ";
} elseif (!empty($nbveryold)) {
    $head = "[Urgent] ";
}
if (empty($nb)) {
    exit;
}
$plural = $nb == 1 ? '' : 's';
$mymail = new PlMailer();
$mymail->setFrom('validation@' . $globals->mail->domain);
$mymail->addTo('validation@' . $globals->mail->domain);
$mymail->setSubject($head . "Il y a {$nb} validation{$plural} non effectuée{$plural}");
$message = "Il y a {$nb} validation{$plural} à effectuer\n" . (empty($nbold) ? '' : "dont {$nbold} depuis le dernier mail !!!\n") . (empty($nbveryold) ? '' : "et dont *{$nbveryold}* " . ($nbveryold == 1 ? 'est' : 'sont') . ' en retard de plus de 6h !!!') . "\n" . "https://www.polytechnique.org/admin/validate\n\n" . "Par catégorie :\n";
$res = XDB::iterRow('SELECT  type, count(*)
                       FROM  requests
                   GROUP BY  type
                   ORDER BY  type');
while (list($type, $nb) = $res->next()) {
    $message .= "- {$type} : {$nb}\n";
}
$message = wordwrap($message, 78);
$mymail->setTxtBody($message);
$mymail->send();
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8:
Example #9
0
        }
        if ($profile->mainEducation() == 'X' && $data['cat'] == Group::CAT_PROMOTIONS) {
            $promoGroup = $promoGroup || $data['diminutif'] == $profile->yearpromo();
        }
    }
    $group = '';
    if (count($groupx)) {
        $group = $groupx[array_rand($groupx)];
    } elseif (count($binets)) {
        $group = $binets[array_rand($binets)];
    }
    $mailer->assign('group', $group);
    $mailer->assign('promoGroup', $promoGroup);
    //In testing phase, only send to Polytechnique.org members
    if ($user->inGroup(Group::get('Polytechnique.org')->id)) {
        $mailer->sendTo($user);
        // We want to keep trace of the emails sent
        $liste .= $user->fullName(true) . "\n";
        $count_mail += 1;
    }
    unset($mailer);
    unset($user);
}
$texte = "L'email anniversaire a bien été envoyé à {$count_mail} destinataires.\n\n" . "La liste des destinataires pour le " . date("d/m/Y") . " est la suivante :\n" . $liste;
$mailer = new PlMailer();
$mailer->addTo("*****@*****.**");
$mailer->setFrom('"Webmaster Polytechnique.org" <*****@*****.**>');
$mailer->setSubject("Envoi de l'email anniversaire");
$mailer->setTxtBody($texte);
$mailer->send();
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8:
Example #10
0
 public function send($title = null, $text = null)
 {
     $this->hash = rand_url_id(12);
     if (!$title) {
         $title = $this->engine->getTitle();
     }
     if (!$text) {
         $text = $this->engine->getText($this->user);
     }
     $sender = substr($this->sender_mail, 1, strpos($this->sender_mail, '"', 2) - 1);
     $text = str_replace(array('%%hash%%', '%%sender%%', '%%personal_notes%%'), array($this->hash, "Cordialement,\n-- \n" . $this->sender_mail, ''), $text);
     $mailer = new PlMailer();
     $mailer->setFrom($this->sender_mail);
     $mailer->addTo($this->user['mail']);
     $mailer->setSubject($title);
     $mailer->setTxtBody($text);
     $mailer->send();
     $this->incr();
 }
Example #11
0
 *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
 ***************************************************************************/
require 'connect.db.inc.php';
$message = '';
$res = XDB::iterRow("SELECT  DATE(a.registration_date), a.hruid, GROUP_CONCAT(DISTINCT r.redirect SEPARATOR ', ')\n                       FROM  accounts               AS a\n                 INNER JOIN  account_profiles       AS ap ON (ap.uid = a.uid AND FIND_IN_SET('owner', ap.perms))\n                 INNER JOIN  profile_display        AS pd ON (ap.pid = pd.pid)\n                  LEFT JOIN  email_source_account   AS s  ON (a.uid = s.uid)\n                  LEFT JOIN  email_redirect_account AS r  ON (a.uid = r.uid)\n                      WHERE  a.registration_date > {?}\n                   GROUP BY  a.hruid\n                   ORDER BY  pd.promo", date("Ymd000000", strtotime('last Monday')));
if ($count = $res->total()) {
    $message .= "{$count} INSCRIPTIONS CONFIRMÉES CETTE SEMAINE :\n";
    while (list($date, $hruid, $email, $redirect) = $res->next()) {
        $message .= "{$date}, {$hruid}, {$email}, {$redirect}\n";
    }
}
$res = XDB::iterRow("SELECT  r.date, a.hruid, r.email\n                       FROM  register_pending AS r\n                 INNER JOIN  accounts         AS a ON (a.uid = r.uid)\n                 INNER JOIN  account_profiles AS ap ON (ap.uid = a.uid AND FIND_IN_SET('owner', ap.perms))\n                 INNER JOIN  profile_display  AS pd ON (ap.pid = pd.pid)\n                      WHERE  r.hash != 'INSCRIT'\n                   GROUP BY  a.hruid\n                   ORDER BY  pd.promo");
if ($count = $res->total()) {
    $message .= "\n{$count} INSCRIPTIONS NON CONFIRMÉES :\n";
    while (list($date, $hruid, $email) = $res->next()) {
        $message .= "{$date}, {$hruid}, {$email}\n";
    }
}
$res = XDB::query('SELECT  COUNT(DISTINCT uid), COUNT(*)
                     FROM  register_marketing');
list($a, $b) = $res->fetchOneRow();
$message .= "\nINSCRIPTIONS SOLLICITÉES :\n";
$message .= "    {$a} utilisateurs\n    {$b} adresses email\n";
$message .= "\n\n";
$mailer = new PlMailer();
$mailer->setSubject('Rapport des inscriptions de la semaine');
$mailer->setFrom($globals->register->notif);
$mailer->addTo($globals->register->notif);
$mailer->setTxtBody($message);
$mailer->send();
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8:
Example #12
0
 function handler_subscribe($page, $u = null)
 {
     global $globals;
     $page->changeTpl('xnetgrp/inscrire.tpl');
     if (!$globals->asso('inscriptible')) {
         $page->kill("Il n'est pas possible de s'inscire en ligne à ce " . "groupe. Essaie de joindre le contact indiqué " . "sur la page de présentation.");
     }
     if (!is_null($u) && may_update()) {
         $user = User::get($u);
         if (!$user) {
             return PL_NOT_FOUND;
         } else {
             $page->assign('user', $user);
         }
         // Retrieves the subscription status, and the reason.
         $res = XDB::query("SELECT  reason\n                                 FROM  group_member_sub_requests\n                                WHERE  asso_id = {?} AND uid = {?}", $globals->asso('id'), $user->id());
         $reason = $res->numRows() ? $res->fetchOneCell() : null;
         $res = XDB::query("SELECT  COUNT(*)\n                                 FROM  group_members\n                                WHERE  asso_id = {?} AND uid = {?}", $globals->asso('id'), $user->id());
         $already_member = $res->fetchOneCell() > 0;
         // Handles the membership request.
         if ($already_member) {
             $this->removeSubscriptionRequest($user->id());
             $page->kill($user->fullName() . ' est déjà membre du groupe&nbsp;!');
         } elseif (Env::has('accept')) {
             S::assert_xsrf_token();
             $this->validSubscription($user);
             pl_redirect("member/" . $user->login());
         } elseif (Env::has('refuse')) {
             S::assert_xsrf_token();
             $this->removeSubscriptionRequest($user->id());
             if ($user->forlifeEmail()) {
                 $mailer = new PlMailer();
                 $mailer->addTo($user->forlifeEmail());
                 $mailer->setFrom('"' . S::user()->fullName() . '" <' . S::user()->forlifeEmail() . '>');
                 $mailer->setSubject('[' . $globals->asso('nom') . '] Demande d\'inscription annulée');
                 $mailer->setTxtBody(Env::v('motif'));
                 $mailer->send();
             }
             $page->killSuccess("La demande de {$user->fullName()} a bien été refusée.");
         } else {
             $page->assign('show_form', true);
             $page->assign('reason', $reason);
         }
         return;
     }
     if (is_member()) {
         $page->kill("Tu es déjà membre&nbsp;!");
         return;
     }
     $res = XDB::query("SELECT  uid\n                             FROM  group_member_sub_requests\n                            WHERE  uid = {?} AND asso_id = {?}", S::i('uid'), $globals->asso('id'));
     if ($res->numRows() != 0) {
         $page->kill("Tu as déjà demandé ton inscription à ce groupe. Cette demande est actuellement en attente de validation.");
         return;
     }
     if (Post::has('inscrire')) {
         S::assert_xsrf_token();
         XDB::execute("INSERT INTO  group_member_sub_requests (asso_id, uid, ts, reason)\n                               VALUES  ({?}, {?}, NOW(), {?})", $globals->asso('id'), S::i('uid'), Post::v('message'));
         XDB::execute('DELETE FROM  group_former_members
                             WHERE  uid = {?} AND asso_id = {?}', S::i('uid'), $globals->asso('id'));
         $admins = $globals->asso()->iterToNotify();
         $admin = $admins->next();
         if (!is_null($admin)) {
             $to = $admin->bestEmail();
             while ($admin = $admins->next()) {
                 $to .= ', ' . $admin->bestEmail();
             }
         } else {
             $to = '';
         }
         $append = "\n" . "-- \n" . "Ce message a été envoyé suite à la demande d'inscription de\n" . S::user()->fullName(true) . "\n" . "Via le site www.polytechnique.net. Tu peux choisir de valider ou\n" . "de refuser sa demande d'inscription depuis la page :\n" . "http://www.polytechnique.net/" . $globals->asso("diminutif") . "/subscribe/" . S::user()->login() . "\n" . "\n" . "En cas de problème, contacter l'équipe de Polytechnique.org\n" . "à l'adresse : support@polytechnique.org\n";
         if (!$to) {
             $to = $globals->asso('mail') != '' ? $globals->asso('mail') . ', ' : '';
             $to .= '*****@*****.**';
             $append = "\n-- \nLe groupe " . $globals->asso("nom") . " n'a pas d'administrateur, l'équipe de" . " Polytechnique.org a été prévenue et va rapidement" . " résoudre ce problème.\n";
         }
         $mailer = new PlMailer();
         $mailer->addTo($to);
         $mailer->setFrom('"' . S::user()->fullName() . '" <' . S::user()->forlifeEmail() . '>');
         $mailer->setSubject('[' . $globals->asso('nom') . '] Demande d\'inscription');
         $mailer->setTxtBody(Post::v('message') . $append);
         $mailer->send();
     }
 }
Example #13
0
 function handler_paypal_return($page, $uid = null)
 {
     $page->changeTpl('payment/retour_paypal.tpl');
     /* reference banque (numero de transaction) */
     $no_transaction = Env::s('tx');
     /* token a renvoyer pour avoir plus d'information */
     $clef = Env::s('sig');
     /* code retour */
     $status = Env::s('st');
     /* raison */
     $reason = $status == 'Pending' ? Env::s('pending_reason') : Env::s('reason_code');
     /* reference complete de la commande */
     $fullref = str_replace('%2d', '-', Env::s('cm'));
     /* montant de la transaction */
     $montant = Env::s('amt');
     /* devise */
     if (Env::s('cc') != 'EUR') {
         cb_erreur("monnaie autre que l'euro");
     }
     /* on extrait le code de retour */
     if ($status != "Completed") {
         if ($status) {
             paypal_erreur("erreur lors du paiement : {$status} - {$reason}");
         } else {
             paypal_erreur("Paiement annulé", false);
         }
     }
     /* on extrait les informations sur l'utilisateur */
     $user = User::get($uid);
     if (!$user) {
         paypal_erreur("uid invalide");
     }
     /* on extrait la reference de la commande */
     if (!preg_match('/-xorg-([0-9]+)$/', $fullref, $matches)) {
         paypal_erreur("référence de commande invalide");
     }
     $ref = $matches[1];
     $res = XDB::query('SELECT  mail, text, confirmation
                          FROM  payments
                         WHERE  id = {?}', $ref);
     if (!(list($conf_mail, $conf_title, $conf_text) = $res->fetchOneRow())) {
         paypal_erreur('référence de commande inconnue');
     }
     /* on fait l'insertion en base de donnees */
     XDB::execute("INSERT INTO  payment_transactions (id, method_id, uid, ref, fullref, ts_confirmed, amount, pkey, comment, status, display)\n                           VALUES  ({?}, 1, {?}, {?}, {?}, NOW(), {?}, {?}, {?}, 'confirmed', {?})", $no_transaction, $user->id(), $ref, $fullref, $montant, $clef, Env::v('comment'), Get::i('display'));
     // We check if it is an Xnet payment and then update the related ML.
     $res = XDB::query('SELECT  eid, asso_id
                          FROM  group_events
                         WHERE  paiement_id = {?}', $ref);
     if ($res->numRows() == 1) {
         list($eid, $asso_id) = $res->fetchOneRow();
         require_once dirname(__FILE__) . '/xnetevents/xnetevents.inc.php';
         $evt = get_event_detail($eid, false, $asso_id);
         subscribe_lists_event($user->id(), $evt['short_name'], 1, $montant, true);
     }
     /* on genere le mail de confirmation */
     $conf_text = str_replace(array('<prenom>', '<nom>', '<promo>', '<montant>', '<salutation>', '<cher>', '<comment>'), array($user->firstName(), $user->lastName(), $user->promo(), $montant, $user->isFemale() ? 'Chère' : 'Cher', $user->isFemale() ? 'Chère' : 'Cher', Env::v('comment')), $conf_text);
     global $globals;
     $mymail = new PlMailer();
     $mymail->setFrom($conf_mail);
     $mymail->addCc($conf_mail);
     $mymail->setSubject($conf_title);
     $mymail->setWikiBody($conf_text);
     $mymail->sendTo($user);
     /* on envoie les details de la transaction à telepaiement@ */
     $mymail = new PlMailer();
     $mymail->setFrom("webmaster@" . $globals->mail->domain);
     $mymail->addTo($globals->money->email);
     $mymail->setSubject($conf_title);
     $msg = 'utilisateur : ' . $user->login() . ' (' . $user->id() . ')' . "\n" . 'mail : ' . $user->forlifeEmail() . "\n\n" . "paiement : {$conf_title} ({$conf_mail})\n" . "reference : {$champ200}\n" . "montant : {$montant}\n\n" . "dump de REQUEST:\n" . var_export($_REQUEST, true);
     $mymail->setTxtBody($msg);
     $mymail->send();
     $page->assign('texte', $conf_text);
     $page->assign('erreur', $erreur);
 }
Example #14
0
function send_warning_mail($title, $body = '')
{
    global $globals;
    $mailer = new PlMailer();
    $mailer->setFrom("webmaster@" . $globals->mail->domain);
    $mailer->addTo($globals->core->admin_email);
    $mailer->setSubject("[Plat/al Security Alert] {$title}");
    // Note: we can't do $session = var_export($_SESSION, true) as var_export
    // doesn't handle circular dependency correctly.
    ob_start();
    var_dump($_SESSION);
    $session = ob_get_clean();
    $mailer->setTxtBody($body . "Identifiants de session :\n" . $session . "\n\n" . "Identifiants de connexion :\n" . var_export($_SERVER, true));
    $mailer->send();
}
Example #15
0
function send_xnet_mails($from, $sujet, $body, $wiki, $tos, $replyto = null, $upload = null, $name = null)
{
    global $globals;
    $sent = array();
    $mailer = new PlMailer();
    $mailer->setSubject($sujet);
    $mailer->setFrom($from);
    if ($upload && $upload->exists()) {
        $mailer->addUploadAttachment($upload, $name);
    }
    foreach ($tos as $user) {
        if ($user instanceof User) {
            $email = $user->bestEmail();
        } else {
            $email = $user;
        }
        if (!$email) {
            continue;
        }
        if (!isset($sent[$email])) {
            _send_xnet_mail($user, $body, $wiki, $mailer, $replyto);
            $sent[$email] = true;
        }
    }
}