}
if (empty($hdr_values['Subject'])) {
Banana::$page->trig(_b_('Le message doit avoir un sujet'));
- } elseif (Banana::$msgedit_canattach && isset($_FILES['attachment'])) {
- $uploaded = $_FILES['attachment'];
+ } elseif (Banana::$msgedit_canattach && isset($_FILES['attachment']) && $_FILES['attachment']['name']) {
+ $uploaded =& $_FILES['attachment'];
if (!is_uploaded_file($uploaded['tmp_name'])) {
Banana::$page->trig(_b_('Une erreur est survenue lors du téléchargement du fichier'));
} else {
$this->loadSpool($group);
$newid = Banana::$spool->updateUnread(Banana::$profile['lastnews']);
Banana::$page->redirect(array('group' => $group, 'artid' => $newid ? $newid : $artid));
- }
- Banana::$page->trig(_b_('Une erreur est survenue lors de l\'envoi du message :') . '<br />'
+ } else {
+ Banana::$page->trig(_b_('Une erreur est survenue lors de l\'envoi du message :') . '<br />'
. Banana::$protocole->lastError());
+ }
}
} else {
if (!is_null($artid)) {
protected function __construct($data = null)
{
- if (!is_null($data)) {
+ if ($data instanceof BananaMimePart) {
+ foreach ($this as $key=>$value) {
+ $this->$key = $data->$key;
+ }
+ } elseif (!is_null($data)) {
$this->fromRaw($data);
- }
+ }
}
protected function makeTextPart($body, $content_type, $encoding, $charset = null, $format = 'fixed')
}
}
- protected function makeFilePart($file, $content_type =null, $disposition = 'attachment')
+ protected function makeFilePart(array $file, $content_type = null, $disposition = 'attachment')
{
$body = file_get_contents($file['tmp_name']);
if ($body === false || strlen($body) != $file['size']) {
protected function convertToMultiPart()
{
if (!$this->isType('multipart', 'mixed')) {
- $newpart = $this;
+ $newpart = new BananaMimePart($this);
$this->content_type = 'multipart/mixed';
$this->encoding = '8bit';
$this->multipart = array($newpart);
public function addAttachment(array $file, $content_type = null, $disposition = 'attachment')
{
- $newpart = new BananaMimePart;
if (!is_uploaded_file($file['tmp_name'])) {
return false;
}
+ $newpart = new BananaMimePart;
if ($newpart->makeFilePart($file, $content_type, $disposition)) {
$this->convertToMultiPart();
$this->multipart[] = $newpart;
public static function getMimeType($data, $is_filename = true)
{
if ($is_filename) {
- $type = mime_content_type($arg);
+ $type = mime_content_type($data);
} else {
$arg = escapeshellarg($data);
$type = preg_replace('/;.*/', '', trim(shell_exec("echo $arg | file -bi -")));