/usr/share/awl/inc/Multipart.php is in libawl-php 0.56-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | <?php
require_once('AWLUtilities.php');
class SinglePart {
private $content;
private $type;
private $otherHeaders;
private $disposition;
private $id;
public static $crlf = "\r\n";
function __construct( $content, $type='text/plain', $otherHeaders=array() ) {
$this->content = $content;
$this->type = $type;
$this->otherHeaders = $otherHeaders;
}
function render() {
$result = 'Content-Type: '.$this->type.self::$crlf;
$encoded = false;
foreach( $this->otherHeaders AS $header => $value ) {
$result .= $header.': '.$value.self::$crlf;
if ( $header == 'Content-Transfer-Encoding' ) $encoded = true;
}
if ( $encoded )
return $result . self::$crlf . $this->content;
return $result . 'Content-Transfer-Encoding: base64' . self::$crlf
. self::$crlf
. base64_encode($this->content);
}
}
class Multipart {
private $parts; // Always good for a giggle :-)
private $boundary;
function __construct() {
$this->parts = array();
$this->boundary = uuid();
}
function addPart() {
$args = func_get_args();
if ( is_string($args[0]) ) {
$newPart = new SinglePart( $args[0], (isset($args[1])?$args[1]:'text/plain'), (isset($args[2])?$args[2]:array()));
}
else
$newPart = $args[0];
$this->parts[] = $newPart;
return $newPart;
}
function getMimeHeaders() {
return 'MIME-Version: 1.0' . SinglePart::$crlf
.'Content-Type: multipart/mixed; boundary='.$this->boundary . SinglePart::$crlf ;
}
function getMimeParts() {
$result = '--' . $this->boundary . SinglePart::$crlf;
foreach( $this->parts AS $part ) {
$result .= $part->render() . SinglePart::$crlf . '--' . $this->boundary;
}
$result .= '--' . SinglePart::$crlf;
return $result;
}
}
|