403Webshell
Server IP : 172.67.216.182  /  Your IP : 172.68.164.60
Web Server : Apache
System : Linux krdc-ubuntu-s-2vcpu-4gb-amd-blr1-01.localdomain 5.15.0-142-generic #152-Ubuntu SMP Mon May 19 10:54:31 UTC 2025 x86_64
User : www ( 1000)
PHP Version : 7.4.33
Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /www/wwwroot/coircraft.com/wp-content/plugins/wp-mail-logging/src/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /www/wwwroot/coircraft.com/wp-content/plugins/wp-mail-logging/src/WPML_Attachment.php
<?php

namespace No3x\WPML;


use No3x\WPML\FS\Filesystem;
use No3x\WPML\FS\IFilesystem;

class WPML_Attachment {

    /** @var IFilesystem */
    private static $fs;

    private $path;
    private $url;
    private $iconClass = null;
    private $gone = true;

    /**
     * WPML_Attachment constructor.
     * @param $path string
     * @param $url string
     * @param $gone bool
     */
    public function __construct($path, $url, $gone)
    {
        $this->path = $path;
        $this->url = $url;
        $this->gone = $gone;
    }

    public static function getFS()
    {
        if (self::$fs == null) {
            self::$fs = new Filesystem();
        }

        return self::$fs;
    }

    public static function setFS($fs)
    {
        self::$fs = $fs;
    }

    /**
     * @return string
     */
    public function getPath() {
        return $this->path;
    }

    /**
     * @return string
     */
    public function getUrl() {
        return $this->url;
    }

    /**
     * @return string
     */
    public function getIconClass() {
        if ($this->iconClass === null) {
            $this->iconClass = $this->determine_mime_icon_class($this->getPath());
        }

        return $this->iconClass;
    }

    /**
     * @return bool
     */
    public function isGone() {
        return $this->gone;
    }

    /**
     * @return string
     */
    public function getFileName() {
        return basename($this->getPath());
    }

    public static function fromAbsPath($absPath) {
        $gone = false; // assume it's there
        $url = "not supported";
        return new WPML_Attachment($absPath, $url, $gone);
    }

    public function toRelPath() {
        $basename_needle = '/uploads/';
        $posAttachmentInUploads = strrpos($this->getPath(), $basename_needle);
        if( false !== $posAttachmentInUploads ) {
            $path = substr($this->getPath(), $posAttachmentInUploads + strlen($basename_needle) - 1 );
        } else {
            // not found
            $path = basename($this->getPath());
        }

        return $path;
    }

    public static function fromRelPath($relPath) {
        $gone = true;
        $path = "";
        $url = "";

        // $relPath can be an empty string ''.
        if ( ! empty( $relPath ) ) {
            $basename = '/uploads';
            $path = WP_CONTENT_DIR . $basename . $relPath;
            $url = WP_CONTENT_URL . $basename . $relPath;

            if ( self::getFS()->is_file( $path ) ) {
                $gone = false;
            } else {
                $path = $relPath;
            }
        }

        return new WPML_Attachment($path, $url, $gone);
    }

    private function determine_mime_icon_class( $file_path ) {
        $defaultIconClass = 'file';

        if ( $this->gone ) {
            return $defaultIconClass;
        }

        $supported = [
            'archive' => [
                'application/zip',
                'application/x-rar-compressed',
                'application/x-rar',
                'application/x-gzip',
                'application/x-msdownload',
                'application/x-msdownload',
                'application/vnd.ms-cab-compressed',
            ],
            'audio',
            'code' => [
                'text/x-c',
                'text/x-c++'
            ],
            'excel' => [ 'application/vnd.ms-excel' ],
            'image',
            'text',
            'movie',
            'pdf' => [
                'application/pdf'
            ],
            'photo',
            'picture',
            'powerpoint' => [
                'application/vnd.ms-powerpoint'
            ],
            'sound',
            'video',
            'word' => [
                'application/msword'
            ],
            'zip',
        ];

        if( !function_exists('mime_content_type') ) {
            return $defaultIconClass;
        }

        $mime = self::getFS()->mime_content_type( $file_path );

        if(false === $mime) {
            return $defaultIconClass;
        }
        $mime_parts = explode( '/', $mime );
        $attribute = $mime_parts[0];
        $type = $mime_parts[1];

        $iconClass = false;
        if ( ($key = WPML_Utils::recursive_array_search( $mime, $supported ) ) !== false ) {
            // Use specific icon class for mime first.
            $iconClass = $key;
        } elseif ( in_array( $attribute, $supported ) ) {
            // Use generic icon class.
            $iconClass = $attribute;
        }

        if ( false === $iconClass  ) {
            return $defaultIconClass;
        } else {
            return $iconClass;
        }
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit