本文整理汇总了PHP中rcube_mime::decode方法的典型用法代码示例。如果您正苦于以下问题:PHP rcube_mime::decode方法的具体用法?PHP rcube_mime::decode怎么用?PHP rcube_mime::decode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rcube_mime
的用法示例。
在下文中一共展示了rcube_mime::decode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: do_decode
/**
* Performs the decoding. Decodes the body string passed to it
* If it finds certain content-types it will call itself in a
* recursive fashion
*
* @param string $headers Header section
* @param string $body Body section
* @param string $default_ctype Default content type
*
* @return object|bool Decoded results or False on error
*/
protected function do_decode($headers, $body, $default_ctype = 'text/plain')
{
$return = new stdClass();
$headers = $this->parseHeaders($headers);
while (list($key, $value) = each($headers)) {
$header_name = strtolower($value['name']);
if (isset($return->headers[$header_name]) && !is_array($return->headers[$header_name])) {
$return->headers[$header_name] = array($return->headers[$header_name]);
$return->headers[$header_name][] = $value['value'];
} else {
if (isset($return->headers[$header_name])) {
$return->headers[$header_name][] = $value['value'];
} else {
$return->headers[$header_name] = $value['value'];
}
}
switch ($header_name) {
case 'content-type':
$content_type = $this->parseHeaderValue($value['value']);
if (preg_match('/([0-9a-z+.-]+)\\/([0-9a-z+.-]+)/i', $content_type['value'], $regs)) {
$return->ctype_primary = $regs[1];
$return->ctype_secondary = $regs[2];
}
if (isset($content_type['other'])) {
while (list($p_name, $p_value) = each($content_type['other'])) {
$return->ctype_parameters[$p_name] = $p_value;
}
}
break;
case 'content-disposition':
$content_disposition = $this->parseHeaderValue($value['value']);
$return->disposition = $content_disposition['value'];
if (isset($content_disposition['other'])) {
while (list($p_name, $p_value) = each($content_disposition['other'])) {
$return->d_parameters[$p_name] = $p_value;
}
}
break;
case 'content-transfer-encoding':
$content_transfer_encoding = $this->parseHeaderValue($value['value']);
break;
}
}
if (isset($content_type)) {
$ctype = strtolower($content_type['value']);
switch ($ctype) {
case 'text/plain':
$encoding = isset($content_transfer_encoding) ? $content_transfer_encoding['value'] : '7bit';
if ($this->params['include_bodies']) {
$return->body = $this->params['decode_bodies'] ? rcube_mime::decode($body, $encoding) : $body;
}
break;
case 'text/html':
$encoding = isset($content_transfer_encoding) ? $content_transfer_encoding['value'] : '7bit';
if ($this->params['include_bodies']) {
$return->body = $this->params['decode_bodies'] ? rcube_mime::decode($body, $encoding) : $body;
}
break;
case 'multipart/digest':
case 'multipart/alternative':
case 'multipart/related':
case 'multipart/mixed':
if (!isset($content_type['other']['boundary'])) {
return false;
}
$default_ctype = $ctype === 'multipart/digest' ? 'message/rfc822' : 'text/plain';
$parts = $this->boundarySplit($body, $content_type['other']['boundary']);
for ($i = 0; $i < count($parts); $i++) {
list($part_header, $part_body) = $this->splitBodyHeader($parts[$i]);
$return->parts[] = $this->do_decode($part_header, $part_body, $default_ctype);
}
break;
case 'message/rfc822':
$obj = new rcube_mime_decode($this->params);
$return->parts[] = $obj->decode($body);
unset($obj);
break;
default:
if ($this->params['include_bodies']) {
$return->body = $this->params['decode_bodies'] ? rcube_mime::decode($body, $content_transfer_encoding['value']) : $body;
}
break;
}
} else {
$ctype = explode('/', $default_ctype);
$return->ctype_primary = $ctype[0];
$return->ctype_secondary = $ctype[1];
if ($this->params['include_bodies']) {
$return->body = $this->params['decode_bodies'] ? rcube_mime::decode($body) : $body;
//.........这里部分代码省略.........
示例2: mime_decode
public function mime_decode($input, $encoding = '7bit')
{
return rcube_mime::decode($input, $encoding);
}