403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/letme.watchman/lib/Report/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/letme.watchman/lib/Report/Report.php
<?php

namespace Letme\Watchman\Report;

use Bitrix\Main\Context;
use Letme\Watchman\Common\Helper;
use Letme\Watchman\Drivers\BuildReportException;
use Letme\Watchman\Drivers\IReport;
use Letme\Watchman\Report\Convert\DecoderJson;
use Letme\Watchman\Report\Convert\EncoderJson;
use Letme\Watchman\Report\Convert\Fields;

class Report implements IReport
{
    /** @var ExceptionSnapshot|null  */
    protected $exception = null;

    /** @var ServerSnapshot|null */
    protected $serverSnapshot;
    protected $userId     = '';
    protected $requestUri = '';
    protected $methodType = '';
    protected $siteId     = '';

    protected string $encoderClass = EncoderJson::class;
    protected string $decoderClass = DecoderJson::class;

    protected function __construct() {
        $this->siteId = SITE_ID ?: '';
    }

    public function initServerSnapshot() {
        $this->serverSnapshot = ServerSnapshot::init();
        return $this;
    }

    public static function makeByException(\Throwable $exception) {
        $obj = (new self())
            ->initUser()
            ->initRequest()
            ->initServerSnapshot();

        $obj->exception = new ExceptionSnapshot($exception);

        return $obj;
    }

    public function getHash():string {
        return md5($this->exception->file . $this->exception->line);
    }

    /**
     * @param string $json
     *
     * @return self
     *
     * @throws BuildReportException
     */
    public static function fromJSON(string $json): self {
        $obj = new self();

        $decoder = new ($obj->getDecoderClass());
        $fields  = $decoder->decode($json);

        if ($fields[Fields::FIELD_EXCEPTION]) {
            $obj->exception  = $fields[Fields::FIELD_EXCEPTION];
            $obj->userId     = $fields[Fields::FIELD_USER_ID] ?? '';
            $obj->requestUri = $fields[Fields::FIELD_REQUEST_URI] ?? '';
            $obj->methodType = $fields[Fields::FIELD_METHOD_TYPE] ?? '';
            $obj->siteId     = $fields[Fields::FIELD_SITE_ID] ?? '';
            $obj->serverSnapshot = ServerSnapshot::initFromArray($fields[Fields::FIELD_SNAPSHOT] ?? []);

            return $obj;
        }

        throw new BuildReportException(GetMessage('LETME_WATCHMAN_RU_EXCEPTION_BUILD_REPORT'));
    }

    protected function getDecoderClass(): string {
        return $this->decoderClass;
    }

    protected function initUser(): self {
        global $USER;
        $this->userId = $USER ? $USER->GetID() : '';

        return $this;
    }

    protected function initRequest(): self {
        $this->requestUri = Context::getCurrent()->getRequest()->getRequestUri();
        $this->methodType = Context::getCurrent()->getRequest()->getRequestMethod();

        return $this;
    }

    public function getServerSnapshot() {
        return clone $this->serverSnapshot;
    }

    public function getException(): ExceptionSnapshot {
        return clone $this->exception;
    }

    public function getRequestUri(): string {
        return $this->requestUri;
    }

    public function getMethodType(): string {
        return $this->methodType;
    }

    public function getUserId(): string {
        return $this->userId;
    }

    public function toJSON(): string {
        return (new $this->encoderClass($this))->encode();
    }

    public function toText(): string {
        $request = Context::getCurrent()->getRequest();
        
        $fields  = [
            'SITE_NAME' => $request->getHttpHost(),
            'REQUEST_URI' => $this->getRequestUri(),
            'EXCEPTION_CLASS' => $this->getException()->className,
            'MESSAGE' => $this->exception->message,
            'FILE' => $this->exception->file,
            'LINE' => $this->exception->line,
            'DETAIL_PAGE' => Helper::getSiteUrlFromRequest($request) .
                Helper::getPage('issue', ['ID' => $this->getHash()]),
        ];
        $message = GetMessage('LETME_WATCHMAN_RU_REPORT_TEXT');
        foreach ($fields as $code => $value) {
            $message = str_replace("#$code#", $value, $message);
        }

        return $message;
    }

    public function getSiteId(): string {
        return $this->siteId;
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit