示例#1
0
文件: Part.php 项目: gbcogivea/imap
 protected function parseStructure(\stdClass $structure)
 {
     $type = strtolower($structure->type);
     if (isset($this->typesMap[$type])) {
         $this->type = $this->typesMap[$type];
     } else {
         $this->type = self::TYPE_UNKNOWN;
     }
     //var_dump('encoding',$structure->encoding);
     if (array_key_exists($structure->encoding, $this->encodingsMap)) {
         $this->encoding = $this->encodingsMap[$structure->encoding];
     }
     //else{
     //var_dump('no encoding',$structure->encoding);
     //var_dump($this->doGetContent());
     //}
     $this->subtype = strtolower($structure->subtype);
     if (isset($structure->bytes)) {
         $this->bytes = $structure->bytes;
     }
     foreach (array('disposition', 'bytes', 'description') as $optional) {
         if (isset($structure->{$optional})) {
             $this->{$optional} = $structure->{$optional};
         }
     }
     $this->parameters = new Parameters();
     $this->parameters->setCharset(\Ddeboer\Imap\Message::$charset);
     if (is_array($structure->parameters)) {
         $this->parameters->add($structure->parameters);
     }
     if (isset($structure->dparameters)) {
         $this->parameters->add($structure->dparameters);
     }
     $charsetDft = $this->getCharset();
     \Ddeboer\Imap\Message::$charset = !empty($charsetDft) ? $charsetDft : \Ddeboer\Imap\Message::$charset;
     if (isset($structure->parts)) {
         foreach ($structure->parts as $key => $partStructure) {
             if (null === $this->partNumber) {
                 $partNumber = $key + 1;
             } else {
                 $partNumber = (string) ($this->partNumber . '.' . ($key + 1));
             }
             if ($this->isAttachment($partStructure)) {
                 $this->parts[] = $partEncours = new Attachment($this->stream, $this->messageNumber, $partNumber, $partStructure);
             } else {
                 $this->parts[] = $partEncours = new Part($this->stream, $this->messageNumber, $partNumber, $partStructure);
             }
             $charsetDft = $partEncours->getCharset();
             //le mot charset peut etre present il faut donc controler cela :
             $charsetDft = $charsetDft == "charset" ? "" : $charsetDft;
             \Ddeboer\Imap\Message::$charset = $charsetDft != "" ? $charsetDft : \Ddeboer\Imap\Message::$charset;
         }
     }
 }
示例#2
0
文件: Part.php 项目: pedrosoares/imap
 protected function parseStructure(\stdClass $structure)
 {
     if (isset($structure->type) && isset($this->typesMap[$structure->type])) {
         $this->type = $this->typesMap[$structure->type];
     } else {
         $this->type = self::TYPE_UNKNOWN;
     }
     if (isset($structure->encoding)) {
         $this->encoding = $this->encodingsMap[$structure->encoding];
     }
     if (isset($structure->subtype)) {
         $this->subtype = $structure->subtype;
     }
     if (isset($structure->bytes)) {
         $this->bytes = $structure->bytes;
     }
     foreach (array('disposition', 'bytes', 'description') as $optional) {
         if (isset($structure->{$optional})) {
             $this->{$optional} = $structure->{$optional};
         }
     }
     $this->parameters = new Parameters();
     if (isset($structure->parameters)) {
         if (is_array($structure->parameters)) {
             $this->parameters->add($structure->parameters);
         }
     }
     if (isset($structure->dparameters)) {
         $this->parameters->add($structure->dparameters);
     }
     if (isset($structure->parts)) {
         foreach ($structure->parts as $key => $partStructure) {
             if (null === $this->partNumber) {
                 $partNumber = $key + 1;
             } else {
                 $partNumber = (string) ($this->partNumber . '.' . ($key + 1));
             }
             if ($this->isAttachment($partStructure)) {
                 $this->parts[] = new Attachment($this->stream, $this->messageNumber, $partNumber, $partStructure);
             } else {
                 $this->parts[] = new Part($this->stream, $this->messageNumber, $partNumber, $partStructure);
             }
         }
     }
 }
示例#3
0
 /**
  * Get header
  *
  * @param string $key
  *
  * @return string
  */
 public function get($key)
 {
     return parent::get(strtolower($key));
 }
示例#4
0
文件: Part.php 项目: valix/imap
 protected function parseStructure(\stdClass $structure)
 {
     if (isset($this->typesMap[$structure->type])) {
         $this->type = $this->typesMap[$structure->type];
     } else {
         $this->type = self::TYPE_UNKNOWN;
     }
     if ($structure->encoding > 5) {
         $headers = \imap_fetchheader($this->stream, $this->messageNumber, \FT_UID);
         if (preg_match('/^Content-Transfer-Encoding: (.*)$/im', $headers, $matches)) {
             $matches[1] = strtolower(preg_replace('/\\s+/', '', $matches[1]));
             switch ($matches[1]) {
                 case self::ENCODING_7BIT:
                     $structure->encoding = 0;
                     break;
                 case self::ENCODING_8BIT:
                     $structure->encoding = 1;
                     break;
                 case self::ENCODING_BINARY:
                     $structure->encoding = 2;
                     break;
                 case self::ENCODING_BASE64:
                     $structure->encoding = 3;
                     break;
                 case self::ENCODING_QUOTED_PRINTABLE:
                     $structure->encoding = 4;
                     break;
                 default:
                     $structure->encoding = 5;
             }
         }
     }
     $this->encoding = $this->encodingsMap[$structure->encoding];
     $this->subtype = $structure->subtype;
     if (isset($structure->bytes)) {
         $this->bytes = $structure->bytes;
     }
     foreach (array('disposition', 'bytes', 'description') as $optional) {
         if (isset($structure->{$optional})) {
             $this->{$optional} = $structure->{$optional};
         }
     }
     $this->parameters = new Parameters();
     if (is_array($structure->parameters)) {
         $this->parameters->add($structure->parameters);
     }
     if (isset($structure->dparameters)) {
         $this->parameters->add($structure->dparameters);
     }
     if (isset($structure->parts)) {
         foreach ($structure->parts as $key => $partStructure) {
             if (null === $this->partNumber) {
                 $partNumber = $key + 1;
             } else {
                 $partNumber = (string) ($this->partNumber . '.' . ($key + 1));
             }
             if ($this->isAttachment($partStructure)) {
                 $this->parts[] = new Attachment($this->stream, $this->messageNumber, $partNumber, $partStructure);
             } else {
                 $this->parts[] = new Part($this->stream, $this->messageNumber, $partNumber, $partStructure);
             }
         }
     }
 }