diff options
author | Evan Prodromou <evan@controlyourself.ca> | 2009-07-21 12:50:45 -0700 |
---|---|---|
committer | Evan Prodromou <evan@controlyourself.ca> | 2009-07-21 12:50:45 -0700 |
commit | 0a602725b1c49d246e77b24c723a65cdb0119e8e (patch) | |
tree | 83a9b97c7ccc77e645f44df8aa405e2471aea5ff /scripts | |
parent | de987a9e63f38a3752491032d7a21759f2cc7560 (diff) | |
parent | 3649b9ffbc40c3695344597330ad9c35b26a4976 (diff) |
Merge branch '0.8.x' of git@gitorious.org:laconica/mainline into 0.8.x
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/maildaemon.php | 43 | ||||
-rwxr-xr-x | scripts/xmppdaemon.php | 5 |
2 files changed, 34 insertions, 14 deletions
diff --git a/scripts/maildaemon.php b/scripts/maildaemon.php index 11ddf06b7..a4003b6b2 100755 --- a/scripts/maildaemon.php +++ b/scripts/maildaemon.php @@ -299,25 +299,40 @@ class MailerDaemon $attachments = array(); + $this->extract_part($parsed,$msg,$attachments); + + return array($from, $to, $msg, $attachments); + } + + function extract_part($parsed,&$msg,&$attachments){ if ($parsed->ctype_primary == 'multipart') { - foreach ($parsed->parts as $part) { - if ($part->ctype_primary == 'text' && - $part->ctype_secondary == 'plain') { - $msg = $part->body; - }else{ - if ($part->body) { - $attachment = tmpfile(); - fwrite($attachment, $part->body); - $attachments[] = $attachment; - } + if($parsed->ctype_secondary == 'alternative'){ + $altmsg = $this->extract_msg_from_multipart_alternative_part($parsed); + if(!empty($altmsg)) $msg = $altmsg; + }else{ + foreach($parsed->parts as $part){ + $this->extract_part($part,$msg,$attachments); } } - } else if ($type == 'text/plain') { + } else if ($parsed->ctype_primary == 'text' + && $parsed->ctype_secondary=='plain') { $msg = $parsed->body; - } else { - $this->unsupported_type($type); + }else if(!empty($parsed->body)){ + if(common_config('attachments', 'uploads')){ + //only save attachments if uploads are enabled + $attachment = tmpfile(); + fwrite($attachment, $parsed->body); + $attachments[] = $attachment; + } } - return array($from, $to, $msg, $attachments); + } + + function extract_msg_from_multipart_alternative_part($parsed){ + foreach ($parsed->parts as $part) { + $this->extract_part($part,$msg,$attachments); + } + //we don't want any attachments that are a result of this parsing + return $msg; } function unsupported_type($type) diff --git a/scripts/xmppdaemon.php b/scripts/xmppdaemon.php index 488b4b514..69512f243 100755 --- a/scripts/xmppdaemon.php +++ b/scripts/xmppdaemon.php @@ -175,6 +175,10 @@ class XMPPDaemon extends Daemon $user = $this->get_user($from); + // For common_current_user to work + global $_cur; + $_cur = $user; + if (!$user) { $this->from_site($from, 'Unknown user; go to ' . common_local_url('imsettings') . @@ -211,6 +215,7 @@ class XMPPDaemon extends Daemon $user->free(); unset($user); + unset($_cur); unset($pl['xml']); $pl['xml'] = null; |