$actifs = Env::v('emails_actifs', Array());
print_r(Env::v('emails_rewrite'));
if (Env::v('emailop') == "ajouter" && Env::has('email')) {
- $result = $redirect->add_email(Env::v('email'));
+ $new_email = Env::v('email');
+ if ($new_email == "new@example.org") {
+ $new_email = Env::v('email_new');
+ }
+ $result = $redirect->add_email($new_email);
+ if ($result == ERROR_INVALID_EMAIL) {
+ $page->assign('email', $new_email);
+ }
+ $page->assign('retour', $result);
} elseif (empty($actifs)) {
$result = ERROR_INACTIVE_REDIRECTION;
} elseif (is_array($actifs)) {
// Display GoogleApps acount information.
require_once 'googleapps.inc.php';
$page->assign('googleapps', GoogleAppsAccount::account_status($user->id()));
+
+ require_once 'emails.combobox.inc.php';
+ fill_email_combobox($page);
}
function handler_antispam(&$page, $statut_filtre = null)
$to2 = getEmails(Env::v('to_contacts'));
$cc2 = getEmails(Env::v('cc_contacts'));
$txt = str_replace('^M', '', Env::v('contenu'));
- $to = Env::v('to');
- $subj = Env::v('sujet');
- $from = Env::v('from');
- $cc = trim(Env::v('cc'));
- $bcc = trim(Env::v('bcc'));
-
+ $to = str_replace(';', ',', Env::t('to'));
+ $subj = Env::t('sujet');
+ $from = Env::t('from');
+ $cc = str_replace(';', ',', Env::t('cc'));
+ $bcc = str_replace(';', ',', Env::t('bcc'));
+
+ $email_regex = '/^[a-z0-9.\-+_\$]+@([\-.+_]?[a-z0-9])+$/i';
+ foreach (explode(',', $to . ',' . $cc . ',' . $bcc) as $email) {
+ $email = trim($email);
+ if ($email != '' && !preg_match($email_regex, $email)) {
+ $page->trigError("L'adresse email " . $email . ' est erronée.');
+ $error = true;
+ }
+ }
if (empty($to) && empty($cc) && empty($to2) && empty($bcc) && empty($cc2)) {
$page->trigError("Indique au moins un destinataire.");
+ $error = true;
+ }
+
+ if ($error) {
$page->assign('uploaded_f', PlUpload::listFilenames(S::user()->login(), 'emails.send'));
} else {
$mymail = new PlMailer();
$mail->setSubject("Une de tes adresse de redirection Polytechnique.org ne marche plus !!");
$mail->setTxtBody($message);
$mail->send();
- $page->trigSuccess("Email envoyé !");
+ $page->trigSuccess('Email envoyé !');
}
} elseif (Post::has('email')) {
S::assert_xsrf_token();
foreach ($broken_list as $orig_email) {
$email = valide_email(trim($orig_email));
if (empty($email) || $email == '@') {
- $invalid_emails[] = "$orig_email: invalid email";
- } else {
+ $invalid_emails[] = trim($orig_email) . ': invalid email';
+ } elseif (!in_array($email, $valid_emails)) {
$res = XDB::query('SELECT COUNT(*)
FROM emails
WHERE email = {?}', $email);
// Output the list of users with recently broken addresses,
// along with the count of valid redirections.
- header('Content-Type: text/x-csv; charset=utf-8;');
- header('Cache-Control: no-cache');
+ require_once 'include/notifs.inc.php';
+ pl_content_headers("text/x-csv");
$csv = fopen('php://output', 'w');
- fputcsv($csv, array('nom', 'prenom', 'alias', 'bounce', 'nbmails', 'url'), ';');
+ fputcsv($csv, array('nom', 'prenom', 'promo', 'alias', 'bounce', 'nbmails', 'url'), ';');
foreach ($broken_user_list as $alias => $mails) {
$sel = Xdb::query(
"SELECT u.user_id, count(e.email) AS nb_mails, u.nom, u.prenom, u.promo
GROUP BY u.user_id", $alias);
if ($x = $sel->fetchOneAssoc()) {
+ if ($x['nb_mails'] == 0) {
+ register_profile_update($x['user_id'], 'broken');
+ }
fputcsv($csv, array($x['nom'], $x['prenom'], $x['promo'], $alias,
- join(',', $mails), $x['nb_mails']),
- 'https://www.polytechnique.org/marketing/broken/' . $alias, ';');
+ join(',', $mails), $x['nb_mails'],
+ 'https://www.polytechnique.org/marketing/broken/' . $alias), ';');
}
}
fclose($csv);