本文整理汇总了PHP中Horde_Mime::uudecode方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Mime::uudecode方法的具体用法?PHP Horde_Mime::uudecode怎么用?PHP Horde_Mime::uudecode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde_Mime
的用法示例。
在下文中一共展示了Horde_Mime::uudecode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testUudecode
public function testUudecode()
{
$data = Horde_Mime::uudecode(file_get_contents(__DIR__ . '/fixtures/uudecode.txt'));
$this->assertEquals(2, count($data));
$this->assertArrayHasKey('data', $data[0]);
$this->assertEquals('Test string', $data[0]['data']);
$this->assertArrayHasKey('name', $data[0]);
$this->assertEquals('test.txt', $data[0]['name']);
$this->assertArrayHasKey('perm', $data[0]);
$this->assertEquals('644', $data[0]['perm']);
$this->assertArrayHasKey('data', $data[1]);
$this->assertEquals('2nd string', $data[1]['data']);
$this->assertArrayHasKey('name', $data[1]);
$this->assertEquals('test2.txt', $data[1]['name']);
$this->assertArrayHasKey('perm', $data[1]);
$this->assertEquals('755', $data[1]['perm']);
}
示例2: _parseUUencode
/**
* Scan text for UUencode data an, if it exists, convert the part to the
* embedded MIME representation.
*
* @return mixed See self::_getEmbeddedMimeParts().
*/
protected function _parseUUencode()
{
$text = Horde_String::convertCharset($this->_mimepart->getContents(), $this->_mimepart->getCharset(), 'UTF-8');
$files = Horde_Mime::uudecode($text);
if (empty($files)) {
return null;
}
$new_part = new Horde_Mime_Part();
$new_part->setType('multipart/mixed');
$text_part = new Horde_Mime_Part();
$text_part->setType('text/plain');
$text_part->setCharset($this->getConfigParam('charset'));
$text_part->setContents(preg_replace("/begin [0-7]{3} .+\r?\n.+\r?\nend/Us", "\n", $text));
$new_part->addPart($text_part);
reset($files);
while (list(, $file) = each($files)) {
$uupart = new Horde_Mime_Part();
$uupart->setType('application/octet-stream');
$uupart->setContents($file['data']);
$uupart->setName(strip_tags($file['name']));
$new_part->addPart($uupart);
}
return $new_part;
}
示例3: _transferDecode
/**
* Decodes the contents of the part to binary encoding.
*
* @param resource $fp A stream containing the data to decode.
* @param string $encoding The original file encoding.
*
* @return resource A new file resource with the decoded data.
*/
protected function _transferDecode($fp, $encoding)
{
/* If the contents are empty, return now. */
fseek($fp, 0, SEEK_END);
if (ftell($fp)) {
switch ($encoding) {
case 'base64':
try {
return $this->_writeStream($fp, array('error' => true, 'filter' => array('convert.base64-decode' => array())));
} catch (ErrorException $e) {
}
rewind($fp);
return $this->_writeStream(base64_decode(stream_get_contents($fp)));
case 'quoted-printable':
try {
return $this->_writeStream($fp, array('error' => true, 'filter' => array('convert.quoted-printable-decode' => array())));
} catch (ErrorException $e) {
}
// Workaround for Horde Bug #8747
rewind($fp);
return $this->_writeStream(quoted_printable_decode(stream_get_contents($fp)));
case 'uuencode':
case 'x-uuencode':
case 'x-uue':
/* Support for uuencoded encoding - although not required by
* RFCs, some mailers may still encode this way. */
$res = Horde_Mime::uudecode($this->_readStream($fp));
return $this->_writeStream($res[0]['data']);
}
}
return $fp;
}