当前位置: 首页>>代码示例>>PHP>>正文


PHP rcube_mime::decode方法代码示例

本文整理汇总了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;
//.........这里部分代码省略.........
开发者ID:JotapePinheiro,项目名称:roundcubemail,代码行数:101,代码来源:rcube_mime_decode.php

示例2: mime_decode

 public function mime_decode($input, $encoding = '7bit')
 {
     return rcube_mime::decode($input, $encoding);
 }
开发者ID:ehabqino,项目名称:roundcubemail,代码行数:4,代码来源:rcube_imap.php


注:本文中的rcube_mime::decode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。