From 1560308460f37e56041f1d6e3c616909444e20ec Mon Sep 17 00:00:00 2001 From: x2003bruneau Date: Wed, 1 Aug 2007 20:00:32 +0000 Subject: [PATCH] Use PlUpload on the spam submission form -> rename the file to "(non)?spam.mail" in order to avoid the ".com" attachment prohibition email.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1892 839d8a87-29fc-0310-9880-83ba4fa771e5 --- modules/email.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/email.php b/modules/email.php index 98bccb5..141b309 100644 --- a/modules/email.php +++ b/modules/email.php @@ -275,13 +275,14 @@ class EmailModule extends PLModule $page->changeTpl('emails/submit_spam.tpl'); if (Post::has('send_email')) { - $upload = $_FILES['mail']['tmp_name']; - if (!is_uploaded_file($upload)) { + $upload = PlUpload::get($_FILES['mail'], S::v('forlife'), 'spam.submit', true); + if (!$upload) { $page->trig('Une erreur a été rencontrée lors du transfert du fichier'); return; } - $mime = trim(mime_content_type($upload)); + $mime = $upload->contentType(); if ($mime != 'text/x-mail' && $mime != 'message/rfc822') { + $upload->clear(); $page->trig('Le fichier ne contient pas un mail complet'); return; } @@ -291,16 +292,16 @@ class EmailModule extends PLModule $mailer->addTo($box); $mailer->setFrom('"' . S::v('prenom') . ' ' . S::v('nom') . '" mail->domain . '>'); $mailer->setTxtBody(Post::v('type') . ' soumis par ' . S::v('forlife') . ' via le web'); - $mailer->addAttachment($upload, 'message/rfc822', $_FILES['mail']['name']); + $mailer->addUploadAttachment($upload, Post::v('type') . '.mail'); $mailer->send(); $page->trig('Le message a été transmis à ' . $box); + $upload->clear(); } } function handler_send(&$page) { global $globals; - $page->changeTpl('emails/send.tpl'); $page->addJsLink('ajax.js'); -- 2.1.4