支持魔方云3.8.6

This commit is contained in:
aazooo 2024-10-21 17:39:38 +08:00
parent 2298dc6a26
commit 3b37333e48
3 changed files with 293 additions and 416 deletions

View File

@ -40,7 +40,7 @@
### 魔方云系统使用方法 ### 魔方云系统使用方法
*魔方云系统支持版本:**3.8.2*** *魔方云系统支持版本:**3.8.6***
1. 使用以下命令安装魔方云系统之前已经安装过免费版的直接跳到第3步 1. 使用以下命令安装魔方云系统之前已经安装过免费版的直接跳到第3步
@ -73,7 +73,7 @@
chmod +x /home/zjmf/dashboard/www/extend/other/check_main chmod +x /home/zjmf/dashboard/www/extend/other/check_main
wget https://raw.githubusercontent.com/aazooo/zjmf/main/ext/cloud/3.7.16/idcsmart.so -O /usr/lib64/php/modules/idcsmart.so wget https://raw.githubusercontent.com/aazooo/zjmf/main/ext/cloud/3.7.16/idcsmart.so -O /usr/lib64/php/modules/idcsmart.so
echo "extension=idcsmart.so" > /etc/php.d/40-idcsmart.ini echo "extension=idcsmart.so" > /etc/php.d/40-idcsmart.ini
wget https://raw.githubusercontent.com/aazooo/zjmf/main/other/Response.php -O /home/zjmf/dashboard/www/vendor/topthink/framework/src/think/Response.php wget https://raw.githubusercontent.com/aazooo/zjmf/main/other/helper.php -O /home/zjmf/dashboard/www/vendor/topthink/think-helper/src/helper.php
systemctl restart php-fpm systemctl restart php-fpm
``` ```
@ -86,7 +86,7 @@
chmod +x /home/zjmf/dashboard/www/extend/other/check_main chmod +x /home/zjmf/dashboard/www/extend/other/check_main
wget https://mirror.ghproxy.com/https://raw.githubusercontent.com/aazooo/zjmf/main/ext/cloud/3.7.16/idcsmart.so -O /usr/lib64/php/modules/idcsmart.so wget https://mirror.ghproxy.com/https://raw.githubusercontent.com/aazooo/zjmf/main/ext/cloud/3.7.16/idcsmart.so -O /usr/lib64/php/modules/idcsmart.so
echo "extension=idcsmart.so" > /etc/php.d/40-idcsmart.ini echo "extension=idcsmart.so" > /etc/php.d/40-idcsmart.ini
wget https://mirror.ghproxy.com/https://raw.githubusercontent.com/aazooo/zjmf/main/other/Response.php -O /home/zjmf/dashboard/www/vendor/topthink/framework/src/think/Response.php wget https://mirror.ghproxy.com/https://raw.githubusercontent.com/aazooo/zjmf/main/other/helper.php -O /home/zjmf/dashboard/www/vendor/topthink/think-helper/src/helper.php
systemctl restart php-fpm systemctl restart php-fpm
``` ```

View File

@ -1,413 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
declare (strict_types = 1);
namespace think;
/**
* 响应输出基础类
* @package think
*/
abstract class Response
{
/**
* 原始数据
* @var mixed
*/
protected $data;
/**
* 当前contentType
* @var string
*/
protected $contentType = 'text/html';
/**
* 字符集
* @var string
*/
protected $charset = 'utf-8';
/**
* 状态码
* @var integer
*/
protected $code = 200;
/**
* 是否允许请求缓存
* @var bool
*/
protected $allowCache = true;
/**
* 输出参数
* @var array
*/
protected $options = [];
/**
* header参数
* @var array
*/
protected $header = [];
/**
* 输出内容
* @var string
*/
protected $content = null;
/**
* Cookie对象
* @var Cookie
*/
protected $cookie;
/**
* Session对象
* @var Session
*/
protected $session;
/**
* 初始化
* @access protected
* @param mixed $data 输出数据
* @param int $code 状态码
*/
protected function init($data = '', int $code = 200)
{
$this->data($data);
$this->code = $code;
$this->contentType($this->contentType, $this->charset);
}
/**
* 创建Response对象
* @access public
* @param mixed $data 输出数据
* @param string $type 输出类型
* @param int $code 状态码
* @return Response
*/
public static function create($data = '', string $type = 'html', int $code = 200): Response
{
$class = false !== strpos($type, '\\') ? $type : '\\think\\response\\' . ucfirst(strtolower($type));
return Container::getInstance()->invokeClass($class, [$data, $code]);
}
/**
* 设置Session对象
* @access public
* @param Session $session Session对象
* @return $this
*/
public function setSession(Session $session)
{
$this->session = $session;
return $this;
}
/**
* 发送数据到客户端
* @access public
* @return void
* @throws \InvalidArgumentException
*/
public function send(): void
{
// 处理输出数据
$data = $this->getContent();
if (!headers_sent()) {
if (!empty($this->header)) {
// 发送状态码
http_response_code($this->code);
// 发送头部信息
foreach ($this->header as $name => $val) {
header($name . (!is_null($val) ? ':' . $val : ''));
}
}
if ($this->cookie) {
$this->cookie->save();
}
}
$this->sendData($data);
if (function_exists('fastcgi_finish_request')) {
// 提高页面响应
fastcgi_finish_request();
}
}
/**
* 处理数据
* @access protected
* @param mixed $data 要处理的数据
* @return mixed
*/
protected function output($data)
{
return $data;
}
/**
* 输出数据
* @access protected
* @param string $data 要处理的数据
* @return void
*/
protected function sendData(string $data): void
{
echo $data;
}
/**
* 输出的参数
* @access public
* @param mixed $options 输出参数
* @return $this
*/
public function options(array $options = [])
{
$this->options = array_merge($this->options, $options);
return $this;
}
/**
* 输出数据设置
* @access public
* @param mixed $data 输出数据
* @return $this
*/
public function data($data)
{
$this->data = $data;
return $this;
}
/**
* 是否允许请求缓存
* @access public
* @param bool $cache 允许请求缓存
* @return $this
*/
public function allowCache(bool $cache)
{
$this->allowCache = $cache;
return $this;
}
/**
* 是否允许请求缓存
* @access public
* @return bool
*/
public function isAllowCache()
{
return $this->allowCache;
}
/**
* 设置Cookie
* @access public
* @param string $name cookie名称
* @param string $value cookie值
* @param mixed $option 可选参数
* @return $this
*/
public function cookie(string $name, string $value, $option = null)
{
$this->cookie->set($name, $value, $option);
return $this;
}
/**
* 设置响应头
* @access public
* @param array $header 参数
* @return $this
*/
public function header(array $header = [])
{
$this->header = array_merge($this->header, $header);
return $this;
}
/**
* 设置页面输出内容
* @access public
* @param mixed $content
* @return $this
*/
public function content($content)
{
if (null !== $content && !is_string($content) && !is_numeric($content) && !is_callable([
$content,
'__toString',
])
) {
throw new \InvalidArgumentException(sprintf('variable type error %s', gettype($content)));
}
$this->content = (string) $content;
return $this;
}
/**
* 发送HTTP状态
* @access public
* @param integer $code 状态码
* @return $this
*/
public function code(int $code)
{
$this->code = $code;
return $this;
}
/**
* LastModified
* @access public
* @param string $time
* @return $this
*/
public function lastModified(string $time)
{
$this->header['Last-Modified'] = $time;
return $this;
}
/**
* Expires
* @access public
* @param string $time
* @return $this
*/
public function expires(string $time)
{
$this->header['Expires'] = $time;
return $this;
}
/**
* ETag
* @access public
* @param string $eTag
* @return $this
*/
public function eTag(string $eTag)
{
$this->header['ETag'] = $eTag;
return $this;
}
/**
* 页面缓存控制
* @access public
* @param string $cache 状态码
* @return $this
*/
public function cacheControl(string $cache)
{
$this->header['Cache-control'] = $cache;
return $this;
}
/**
* 页面输出类型
* @access public
* @param string $contentType 输出类型
* @param string $charset 输出编码
* @return $this
*/
public function contentType(string $contentType, string $charset = 'utf-8')
{
$this->header['Content-Type'] = $contentType . '; charset=' . $charset;
return $this;
}
/**
* 获取头部信息
* @access public
* @param string $name 头部名称
* @return mixed
*/
public function getHeader(string $name = '')
{
if (!empty($name)) {
return $this->header[$name] ?? null;
}
return $this->header;
}
/**
* 获取原始数据
* @access public
* @return mixed
*/
public function getData()
{
return $this->data;
}
/**
* 获取输出数据
* @access public
* @return string
*/
public function getContent(): string
{
if (null == $this->content) {
$content = $this->output($this->data);
if (null !== $content && !is_string($content) && !is_numeric($content) && !is_callable([
$content,
'__toString',
])
) {
throw new \InvalidArgumentException(sprintf('variable type error %s', gettype($content)));
}
$this->content = (string) $content;
}
return $this->content;
}
/**
* 获取状态码
* @access public
* @return integer
*/
public function getCode(): int
{
return $this->code;
}
}

290
other/helper.php Normal file
View File

@ -0,0 +1,290 @@
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: yunwuxin <448901948@qq.com>
// +----------------------------------------------------------------------
use think\Collection;
use think\helper\Arr;
if (!function_exists('throw_if')) {
/**
* 按条件抛异常
*
* @template TValue
* @template TException of \Throwable
*
* @param TValue $condition
* @param TException|class-string<TException>|string $exception
* @param mixed ...$parameters
* @return TValue
*
* @throws TException
*/
function throw_if($condition, $exception, ...$parameters)
{
if ($condition) {
throw (is_string($exception) ? new $exception(...$parameters) : $exception);
}
return $condition;
}
}
if (!function_exists('throw_unless')) {
/**
* 按条件抛异常
*
* @template TValue
* @template TException of \Throwable
*
* @param TValue $condition
* @param TException|class-string<TException>|string $exception
* @param mixed ...$parameters
* @return TValue
*
* @throws TException
*/
function throw_unless($condition, $exception, ...$parameters)
{
if (!$condition) {
throw (is_string($exception) ? new $exception(...$parameters) : $exception);
}
return $condition;
}
}
if (!function_exists('tap')) {
/**
* 对一个值调用给定的闭包,然后返回该值
*
* @template TValue
*
* @param TValue $value
* @param (callable(TValue): mixed)|null $callback
* @return TValue
*/
function tap($value, $callback = null)
{
if (is_null($callback)) {
return $value;
}
$callback($value);
return $value;
}
}
if (!function_exists('value')) {
/**
* Return the default value of the given value.
*
* @template TValue
*
* @param TValue|\Closure(): TValue $value
* @return TValue
*/
function value($value)
{
return $value instanceof Closure ? $value() : $value;
}
}
if (!function_exists('collect')) {
/**
* Create a collection from the given value.
*
* @param mixed $value
* @return Collection
*/
function collect($value = null)
{
return new Collection($value);
}
}
if (!function_exists('data_fill')) {
/**
* Fill in data where it's missing.
*
* @param mixed $target
* @param string|array $key
* @param mixed $value
* @return mixed
*/
function data_fill(&$target, $key, $value)
{
return data_set($target, $key, $value, false);
}
}
if (!function_exists('data_get')) {
/**
* Get an item from an array or object using "dot" notation.
*
* @param mixed $target
* @param string|array|int $key
* @param mixed $default
* @return mixed
*/
function data_get($target, $key, $default = null)
{
if (is_null($key)) {
return $target;
}
$key = is_array($key) ? $key : explode('.', $key);
while (!is_null($segment = array_shift($key))) {
if ('*' === $segment) {
if ($target instanceof Collection) {
$target = $target->all();
} elseif (!is_array($target)) {
return value($default);
}
$result = [];
foreach ($target as $item) {
$result[] = data_get($item, $key);
}
return in_array('*', $key) ? Arr::collapse($result) : $result;
}
if (Arr::accessible($target) && Arr::exists($target, $segment)) {
$target = $target[$segment];
} elseif (is_object($target) && isset($target->{$segment})) {
$target = $target->{$segment};
} else {
return value($default);
}
}
return $target;
}
}
if (!function_exists('data_set')) {
/**
* Set an item on an array or object using dot notation.
*
* @param mixed $target
* @param string|array $key
* @param mixed $value
* @param bool $overwrite
* @return mixed
*/
function data_set(&$target, $key, $value, $overwrite = true)
{
$segments = is_array($key) ? $key : explode('.', $key);
if (($segment = array_shift($segments)) === '*') {
if (!Arr::accessible($target)) {
$target = [];
}
if ($segments) {
foreach ($target as &$inner) {
data_set($inner, $segments, $value, $overwrite);
}
} elseif ($overwrite) {
foreach ($target as &$inner) {
$inner = $value;
}
}
} elseif (Arr::accessible($target)) {
if ($segments) {
if (!Arr::exists($target, $segment)) {
$target[$segment] = [];
}
data_set($target[$segment], $segments, $value, $overwrite);
} elseif ($overwrite || !Arr::exists($target, $segment)) {
$target[$segment] = $value;
}
} elseif (is_object($target)) {
if ($segments) {
if (!isset($target->{$segment})) {
$target->{$segment} = [];
}
data_set($target->{$segment}, $segments, $value, $overwrite);
} elseif ($overwrite || !isset($target->{$segment})) {
$target->{$segment} = $value;
}
} else {
$target = [];
if ($segments) {
data_set($target[$segment], $segments, $value, $overwrite);
} elseif ($overwrite) {
$target[$segment] = $value;
}
}
return $target;
}
}
if (!function_exists('trait_uses_recursive')) {
/**
* 获取一个trait里所有引用到的trait
*
* @param string $trait Trait
* @return array
*/
function trait_uses_recursive(string $trait): array
{
$traits = class_uses($trait);
foreach ($traits as $trait) {
$traits += trait_uses_recursive($trait);
}
return $traits;
}
}
if (!function_exists('class_basename')) {
/**
* 获取类名(不包含命名空间)
*
* @param mixed $class 类名
* @return string
*/
function class_basename($class): string
{
$class = is_object($class) ? get_class($class) : $class;
return basename(str_replace('\\', '/', $class));
}
}
if (!function_exists('class_uses_recursive')) {
/**
*获取一个类里所有用到的trait包括父类的
*
* @param mixed $class 类名
* @return array
*/
function class_uses_recursive($class): array
{
if (is_object($class)) {
$class = get_class($class);
}
$results = [];
$classes = array_merge([$class => $class], class_parents($class));
foreach ($classes as $class) {
$results += trait_uses_recursive($class);
}
return array_unique($results);
}
}