1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the ZBateson\MailMimeParser project. |
4
|
|
|
* |
5
|
|
|
* @license http://opensource.org/licenses/bsd-license.php BSD |
6
|
|
|
*/ |
7
|
|
|
namespace ZBateson\MailMimeParser; |
8
|
|
|
|
9
|
|
|
use ZBateson\MailMimeParser\Header\HeaderFactory; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* A specialized NonMimePart representing a uuencoded part. |
13
|
|
|
* |
14
|
|
|
* This represents part of a message that is not a mime message. A multi-part |
15
|
|
|
* mime message may have a part with a Content-Transfer-Encoding of x-uuencode |
16
|
|
|
* but that would be represented by a normal MimePart. |
17
|
|
|
* |
18
|
|
|
* UUEncodedPart extends NonMimePart to return a Content-Transfer-Encoding of |
19
|
|
|
* x-uuencode, a Content-Type of application-octet-stream, and a |
20
|
|
|
* Content-Disposition of 'attachment'. It also expects a mode and filename to |
21
|
|
|
* initialize it, and adds 'filename' parts to the Content-Disposition and |
22
|
|
|
* 'name' to Content-Type. |
23
|
|
|
* |
24
|
|
|
* @author Zaahid Bateson <[email protected]> |
25
|
|
|
*/ |
26
|
|
|
class UUEncodedPart extends NonMimePart |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* @var int the unix file permission |
30
|
|
|
*/ |
31
|
|
|
protected $mode = null; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var string the name of the file in the uuencoding 'header'. |
35
|
|
|
*/ |
36
|
|
|
protected $filename = null; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Initiates the UUEncodedPart with the passed mode and filename. |
40
|
|
|
* |
41
|
|
|
* @param HeaderFactory $headerFactory |
42
|
|
|
* @param int $mode the unix file mode |
43
|
|
|
* @param string $filename the filename |
44
|
|
|
*/ |
45
|
|
|
public function __construct(HeaderFactory $headerFactory, $mode, $filename) |
46
|
|
|
{ |
47
|
|
|
parent::__construct($headerFactory); |
48
|
|
|
$this->mode = $mode; |
49
|
|
|
$this->filename = $filename; |
50
|
|
|
|
51
|
|
|
$this->setRawHeader( |
52
|
|
|
'Content-Type', |
53
|
|
|
'application/octet-stream; name="' . addcslashes($filename, '"') . '"' |
54
|
|
|
); |
55
|
|
|
$this->setRawHeader( |
56
|
|
|
'Content-Disposition', |
57
|
|
|
'attachment; filename="' . addcslashes($filename, '"') . '"' |
58
|
|
|
); |
59
|
|
|
$this->setRawHeader('Content-Transfer-Encoding', 'x-uuencode'); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Returns the file mode included in the uuencoded header for this part. |
64
|
|
|
* |
65
|
|
|
* @return int |
66
|
|
|
*/ |
67
|
|
|
public function getUnixFileMode() |
68
|
|
|
{ |
69
|
|
|
return $this->mode; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Returns the filename included in the uuencoded header for this part. |
74
|
|
|
* |
75
|
|
|
* @return string |
76
|
|
|
*/ |
77
|
|
|
public function getFilename() |
78
|
|
|
{ |
79
|
|
|
return $this->filename; |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|