Uname:Linux ip-11-115-0-196 6.8.0-1039-aws #41~22.04.1-Ubuntu SMP Thu Sep 11 10:54:48 UTC 2025 x86_64

403WebShell
403Webshell
Server IP : 13.126.101.145  /  Your IP : 216.73.216.182
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux ip-11-115-0-196 6.8.0-1039-aws #41~22.04.1-Ubuntu SMP Thu Sep 11 10:54:48 UTC 2025 x86_64
User : www-data ( 33)
PHP Version : 8.3.17
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/html/rentals_updated/wp-content/plugins/wp-mail-logging/src/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/rentals_updated/wp-content/plugins/wp-mail-logging/src/WPML_MailExtractor.php
<?php

namespace No3x\WPML;


use No3x\WPML\Model\WPML_Mail as Mail;

class WPML_MailExtractor {

    const ERROR_NO_FIELD = "The message is not valid because it contains no message or html field.";

    public function __construct() {
    }

    public function extract($mailArray) {
        return Mail::create([
            'receiver' => $this->extractReceiver($mailArray['to']),
            'subject' => $mailArray['subject'],
            'message' => $this->extractMessage($mailArray),
            'headers' => $this->extractHeader($mailArray),
            'attachments' => $this->extractAttachments($mailArray),
        ]);
    }

    private function extractReceiver( $receiver ) {
        return $this->convertMultipartsToString($receiver);
    }

    private function extractMessage( $mail ) {
        if ( isset($mail['message']) ) {
            // usually the message is stored in the message field
            return $mail['message'];
        } elseif ( isset($mail['html']) ) {
            // for example Mandrill stores the message in the 'html' field (see gh-22)
            return $mail['html'];
        }
        throw new \Exception(self::ERROR_NO_FIELD);
    }

    private function extractHeader( $mail ) {
        $headers = isset($mail['headers']) ? $mail['headers'] : array();
        return $this->joinMultiParts($headers);
    }

    private function extractAttachments( $mail ) {
        $attachmentAbsPaths = isset($mail['attachments']) ? $mail['attachments'] : array();

        if(!is_array($attachmentAbsPaths)) {
            $attachmentAbsPaths = $this->splitAtComma($attachmentAbsPaths);
        }

        $attachment_urls = [];
        foreach ($attachmentAbsPaths as $attachmentAbsPath) {
            $attachment = WPML_Attachment::fromAbsPath($attachmentAbsPath);
            $attachment_urls[] = $attachment->toRelPath();
        }

        $string = $this->joinArrayWithCommaAndNewLine($attachment_urls);

        return $string;
    }

    private function convertMultipartsToString($multiparts) {

        if(is_array($multiparts)) {
            $multiPartArray = $multiparts;
        } else {
            $multiPartArray = $this->splitAtComma($multiparts);
        }

        $string = $this->joinArrayWithCommaAndNewLine($multiPartArray);

        return $string;
    }

    private function splitAtComma($string) {
        $parts = preg_split( "/(,|,\s)/", $string );
        return $parts;
    }

    private function joinMultiParts($multiPart) {
        return is_array($multiPart) ? $this->joinArrayWithCommaAndNewLine($multiPart) : $multiPart;
    }

    private function joinArrayWithCommaAndNewLine(array $array) {
        return implode(',\n', $array);
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit