403Webshell
Server IP : 119.36.225.67  /  Your IP : 43.159.78.200
Web Server : nginx/1.28.0
System : Linux 1763701629066 6.8.0-53-generic #55-Ubuntu SMP PREEMPT_DYNAMIC Fri Jan 17 15:37:52 UTC 2025 x86_64
User : www ( 1001)
PHP Version : 8.2.28
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 : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /www/wwwroot/www.lengcat.cn/wp-content/themes/onenav/vendor/yurunsoft/yurun-http/src/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /www/wwwroot/www.lengcat.cn/wp-content/themes/onenav/vendor/yurunsoft/yurun-http/src/YurunHttp.php
<?php

namespace Yurun\Util;

use Swoole\Coroutine;
use Yurun\Util\YurunHttp\Handler\IHandler;

abstract class YurunHttp
{
    /**
     * 默认处理器类.
     *
     * @var string|null
     */
    private static $defaultHandler;

    /**
     * 属性.
     *
     * @var array
     */
    private static $attributes = [];

    /**
     * 版本号.
     */
    const VERSION = '5.0';

    /**
     * 设置默认处理器类.
     *
     * @param string|null $class
     *
     * @return void
     */
    public static function setDefaultHandler($class)
    {
        self::$defaultHandler = $class;
    }

    /**
     * 获取默认处理器类.
     *
     * @return string|null
     */
    public static function getDefaultHandler()
    {
        return self::$defaultHandler;
    }

    /**
     * 获取处理器类.
     *
     * @param array $options
     *
     * @return \Yurun\Util\YurunHttp\Handler\IHandler
     */
    public static function getHandler($options = [])
    {
        if (self::$defaultHandler)
        {
            $class = self::$defaultHandler;
            // @phpstan-ignore-next-line
            if (!is_subclass_of($class, IHandler::class))
            {
                throw new \RuntimeException(sprintf('Class %s does not implement %s', $class, IHandler::class));
            }
        }
        elseif (\defined('SWOOLE_VERSION') && Coroutine::getuid() > -1)
        {
            $class = \Yurun\Util\YurunHttp\Handler\Swoole::class;
        }
        else
        {
            $class = \Yurun\Util\YurunHttp\Handler\Curl::class;
        }

        return new $class($options);
    }

    /**
     * 发送请求并获取结果.
     *
     * @param \Yurun\Util\YurunHttp\Http\Request                 $request
     * @param \Yurun\Util\YurunHttp\Handler\IHandler|string|null $handlerClass
     * @param array                                              $options
     *
     * @return \Yurun\Util\YurunHttp\Http\Response|null
     */
    public static function send($request, $handlerClass = null, $options = [])
    {
        if ($handlerClass instanceof IHandler)
        {
            $handler = $handlerClass;
            $needClose = false;
        }
        else
        {
            $needClose = true;
            if (null === $handlerClass)
            {
                $handler = static::getHandler($options);
            }
            else
            {
                /** @var IHandler $handler */
                $handler = new $handlerClass();
            }
        }
        foreach (self::$attributes as $name => $value)
        {
            if (null === $request->getAttribute($name))
            {
                $request = $request->withAttribute($name, $value);
            }
        }
        $handler->send($request);
        $response = $handler->recv();
        if ($needClose)
        {
            $handler->close();
        }

        return $response;
    }

    /**
     * 发起 WebSocket 连接.
     *
     * @param \Yurun\Util\YurunHttp\Http\Request            $request
     * @param \Yurun\Util\YurunHttp\Handler\IHandler|string $handlerClass
     * @param array                                         $options
     *
     * @return \Yurun\Util\YurunHttp\WebSocket\IWebSocketClient
     */
    public static function websocket($request, $handlerClass = null, $options = [])
    {
        if ($handlerClass instanceof IHandler)
        {
            $handler = $handlerClass;
        }
        elseif (null === $handlerClass)
        {
            $handler = static::getHandler($options);
        }
        else
        {
            $handler = new $handlerClass();
        }
        foreach (self::$attributes as $name => $value)
        {
            if (null === $request->getAttribute($name))
            {
                $request = $request->withAttribute($name, $value);
            }
        }

        return $handler->websocket($request);
    }

    /**
     * 获取所有全局属性.
     *
     * @return array
     */
    public static function getAttributes()
    {
        return self::$attributes;
    }

    /**
     * 获取全局属性值
     *
     * @param string $name
     * @param mixed  $default
     *
     * @return mixed
     */
    public static function getAttribute($name, $default = null)
    {
        if (\array_key_exists($name, self::$attributes))
        {
            return self::$attributes[$name];
        }
        else
        {
            return $default;
        }
    }

    /**
     * 设置全局属性值
     *
     * @param string $name
     * @param mixed  $value
     *
     * @return mixed
     */
    public static function setAttribute($name, $value)
    {
        self::$attributes[$name] = $value;
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit