mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
ComposerUpdate
This commit is contained in:
parent
cbcc605ad9
commit
9132120745
8
composer.lock
generated
8
composer.lock
generated
@ -909,12 +909,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/zoujingli/ThinkLibrary.git",
|
||||
"reference": "89beab0c55d0fb9167913764b78ede9859485fad"
|
||||
"reference": "2858d5d77526e064d7dd89f793ae9269310a6cba"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/89beab0c55d0fb9167913764b78ede9859485fad",
|
||||
"reference": "89beab0c55d0fb9167913764b78ede9859485fad",
|
||||
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/2858d5d77526e064d7dd89f793ae9269310a6cba",
|
||||
"reference": "2858d5d77526e064d7dd89f793ae9269310a6cba",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
@ -958,7 +958,7 @@
|
||||
],
|
||||
"description": "ThinkPHP v6.0 Development Library",
|
||||
"homepage": "http://framework.thinkadmin.top",
|
||||
"time": "2020-04-22T06:44:38+00:00"
|
||||
"time": "2020-04-23T09:13:17+00:00"
|
||||
},
|
||||
{
|
||||
"name": "zoujingli/wechat-developer",
|
||||
|
8
vendor/composer/installed.json
vendored
8
vendor/composer/installed.json
vendored
@ -935,12 +935,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/zoujingli/ThinkLibrary.git",
|
||||
"reference": "89beab0c55d0fb9167913764b78ede9859485fad"
|
||||
"reference": "2858d5d77526e064d7dd89f793ae9269310a6cba"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/89beab0c55d0fb9167913764b78ede9859485fad",
|
||||
"reference": "89beab0c55d0fb9167913764b78ede9859485fad",
|
||||
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/2858d5d77526e064d7dd89f793ae9269310a6cba",
|
||||
"reference": "2858d5d77526e064d7dd89f793ae9269310a6cba",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
@ -956,7 +956,7 @@
|
||||
"ext-json": "*",
|
||||
"topthink/framework": "^6.0"
|
||||
},
|
||||
"time": "2020-04-22T06:44:38+00:00",
|
||||
"time": "2020-04-23T09:13:17+00:00",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"think": {
|
||||
|
2
vendor/services.php
vendored
2
vendor/services.php
vendored
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
// This file is automatically generated at:2020-04-22 14:46:30
|
||||
// This file is automatically generated at:2020-04-23 17:17:37
|
||||
declare (strict_types = 1);
|
||||
return array (
|
||||
0 => 'think\\app\\Service',
|
||||
|
@ -17,6 +17,7 @@ namespace think\admin;
|
||||
|
||||
use think\App;
|
||||
use think\Container;
|
||||
use think\Db;
|
||||
use think\db\Query;
|
||||
|
||||
/**
|
||||
@ -58,9 +59,9 @@ abstract class Helper
|
||||
/**
|
||||
* 获取数据库对象
|
||||
* @param string|Query $dbQuery
|
||||
* @return Query
|
||||
* @return Db|Query
|
||||
*/
|
||||
protected function buildQuery($dbQuery): Query
|
||||
protected function buildQuery($dbQuery)
|
||||
{
|
||||
return is_string($dbQuery) ? $this->app->db->name($dbQuery) : $dbQuery;
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ class Version extends Command
|
||||
|
||||
protected function execute(Input $input, Output $output)
|
||||
{
|
||||
$output->writeln("ThinkAdmin " . ProcessService::instance()->version());
|
||||
$output->writeln('ThinkPHPCore ' . App::VERSION);
|
||||
$output->writeln('ThinkLib ' . ProcessService::instance()->version());
|
||||
$output->writeln('ThinkPHP ' . App::VERSION);
|
||||
}
|
||||
}
|
38
vendor/zoujingli/think-library/src/common.php
vendored
38
vendor/zoujingli/think-library/src/common.php
vendored
@ -47,9 +47,9 @@ if (!function_exists('auth')) {
|
||||
}
|
||||
if (!function_exists('sysuri')) {
|
||||
/**
|
||||
* 生成最短URL地址
|
||||
* 生成最短 URL 地址
|
||||
* @param string $url 路由地址
|
||||
* @param array $vars 变量
|
||||
* @param array $vars PATH 变量
|
||||
* @param boolean|string $suffix 后缀
|
||||
* @param boolean|string $domain 域名
|
||||
* @return string
|
||||
@ -212,6 +212,23 @@ if (!function_exists('data_save')) {
|
||||
return SystemService::instance()->save($dbQuery, $data, $key, $where);
|
||||
}
|
||||
}
|
||||
if (!function_exists('format_bytes')) {
|
||||
/**
|
||||
* 文件字节单位转换
|
||||
* @param integer $size
|
||||
* @return string
|
||||
*/
|
||||
function format_bytes($size)
|
||||
{
|
||||
if (is_numeric($size)) {
|
||||
$units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
||||
for ($i = 0; $size >= 1024 && $i < 4; $i++) $size /= 1024;
|
||||
return round($size, 2) . ' ' . $units[$i];
|
||||
} else {
|
||||
return $size;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!function_exists('format_datetime')) {
|
||||
/**
|
||||
* 日期格式标准输出
|
||||
@ -264,21 +281,4 @@ if (!function_exists('down_file')) {
|
||||
$result = Storage::down($source, $force, $expire);
|
||||
return isset($result['url']) ? $result['url'] : $source;
|
||||
}
|
||||
}
|
||||
if (!function_exists('format_bytes')) {
|
||||
/**
|
||||
* 文件字节单位转换
|
||||
* @param integer $size
|
||||
* @return string
|
||||
*/
|
||||
function format_bytes($size)
|
||||
{
|
||||
if (is_numeric($size)) {
|
||||
$units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
||||
for ($i = 0; $size >= 1024 && $i < 4; $i++) $size /= 1024;
|
||||
return round($size, 2) . ' ' . $units[$i];
|
||||
} else {
|
||||
return $size;
|
||||
}
|
||||
}
|
||||
}
|
@ -67,7 +67,7 @@ class CodeExtend
|
||||
{
|
||||
$time = time() . '';
|
||||
if ($size < 10) $size = 10;
|
||||
$string = $prefix . ($time[0] + $time[1]) . substr($time, 2) . rand(0, 9);
|
||||
$string = $prefix . (intval($time[0]) + intval($time[1])) . substr($time, 2) . rand(0, 9);
|
||||
while (strlen($string) < $size) $string .= rand(0, 9);
|
||||
return $string;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ class FormHelper extends Helper
|
||||
|
||||
/**
|
||||
* 数据对象主键名称
|
||||
* @var array|string
|
||||
* @var string
|
||||
*/
|
||||
protected $field;
|
||||
|
||||
|
@ -29,7 +29,7 @@ class QueryHelper extends Helper
|
||||
{
|
||||
|
||||
/**
|
||||
* Query call.
|
||||
* QueryHelper call.
|
||||
* @param string $name 调用方法名称
|
||||
* @param array $args 调用参数内容
|
||||
* @return $this
|
||||
|
@ -27,13 +27,11 @@ class CaptchaService extends Service
|
||||
private $code; // 验证码
|
||||
private $uniqid; // 唯一序号
|
||||
private $charset = 'ABCDEFGHKMNPRSTUVWXYZ23456789'; // 随机因子
|
||||
private $codelen = 4; // 验证码长度
|
||||
private $width = 130; // 宽度
|
||||
private $height = 50; // 高度
|
||||
private $img; // 图形资源句柄
|
||||
private $font; // 指定的字体
|
||||
private $width = 130; // 图片宽度
|
||||
private $height = 50; // 图片高度
|
||||
private $length = 4; // 验证码长度
|
||||
private $fontfile; // 指定字体文件
|
||||
private $fontsize = 20; // 指定字体大小
|
||||
private $fontcolor; // 指定字体颜色
|
||||
|
||||
/**
|
||||
* 服务初始化
|
||||
@ -48,11 +46,11 @@ class CaptchaService extends Service
|
||||
$this->uniqid = uniqid('captcha') . mt_rand(1000, 9999);
|
||||
// 生成验证码字符串
|
||||
$length = strlen($this->charset) - 1;
|
||||
for ($i = 0; $i < $this->codelen; $i++) {
|
||||
for ($i = 0; $i < $this->length; $i++) {
|
||||
$this->code .= $this->charset[mt_rand(0, $length)];
|
||||
}
|
||||
// 设置字体文件路径
|
||||
$this->font = __DIR__ . '/bin/font.ttf';
|
||||
$this->fontfile = __DIR__ . '/bin/font.ttf';
|
||||
// 缓存验证码字符串
|
||||
$this->app->cache->set($this->uniqid, $this->code, 360);
|
||||
// 返回当前对象
|
||||
@ -143,34 +141,34 @@ class CaptchaService extends Service
|
||||
private function createImage()
|
||||
{
|
||||
// 生成背景
|
||||
$this->img = imagecreatetruecolor($this->width, $this->height);
|
||||
$color = imagecolorallocate($this->img, mt_rand(220, 255), mt_rand(220, 255), mt_rand(220, 255));
|
||||
imagefilledrectangle($this->img, 0, $this->height, $this->width, 0, $color);
|
||||
$img = imagecreatetruecolor($this->width, $this->height);
|
||||
$color = imagecolorallocate($img, mt_rand(220, 255), mt_rand(220, 255), mt_rand(220, 255));
|
||||
imagefilledrectangle($img, 0, $this->height, $this->width, 0, $color);
|
||||
// 生成线条
|
||||
for ($i = 0; $i < 6; $i++) {
|
||||
$color = imagecolorallocate($this->img, mt_rand(0, 50), mt_rand(0, 50), mt_rand(0, 50));
|
||||
imageline($this->img, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, $this->width), mt_rand(0, $this->height), $color);
|
||||
$color = imagecolorallocate($img, mt_rand(0, 50), mt_rand(0, 50), mt_rand(0, 50));
|
||||
imageline($img, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, $this->width), mt_rand(0, $this->height), $color);
|
||||
}
|
||||
// 生成雪花
|
||||
for ($i = 0; $i < 100; $i++) {
|
||||
$color = imagecolorallocate($this->img, mt_rand(200, 255), mt_rand(200, 255), mt_rand(200, 255));
|
||||
imagestring($this->img, mt_rand(1, 5), mt_rand(0, $this->width), mt_rand(0, $this->height), '*', $color);
|
||||
$color = imagecolorallocate($img, mt_rand(200, 255), mt_rand(200, 255), mt_rand(200, 255));
|
||||
imagestring($img, mt_rand(1, 5), mt_rand(0, $this->width), mt_rand(0, $this->height), '*', $color);
|
||||
}
|
||||
// 生成文字
|
||||
$_x = $this->width / $this->codelen;
|
||||
for ($i = 0; $i < $this->codelen; $i++) {
|
||||
$this->fontcolor = imagecolorallocate($this->img, mt_rand(0, 156), mt_rand(0, 156), mt_rand(0, 156));
|
||||
$_x = $this->width / $this->length;
|
||||
for ($i = 0; $i < $this->length; $i++) {
|
||||
$fontcolor = imagecolorallocate($img, mt_rand(0, 156), mt_rand(0, 156), mt_rand(0, 156));
|
||||
if (function_exists('imagettftext')) {
|
||||
imagettftext($this->img, $this->fontsize, mt_rand(-30, 30), $_x * $i + mt_rand(1, 5), $this->height / 1.4, $this->fontcolor, $this->font, $this->code[$i]);
|
||||
imagettftext($img, $this->fontsize, mt_rand(-30, 30), $_x * $i + mt_rand(1, 5), $this->height / 1.4, $fontcolor, $this->fontfile, $this->code[$i]);
|
||||
} else {
|
||||
imagestring($this->img, 15, $_x * $i + mt_rand(10, 15), mt_rand(10, 30), $this->code[$i], $this->fontcolor);
|
||||
imagestring($img, 15, $_x * $i + mt_rand(10, 15), mt_rand(10, 30), $this->code[$i], $fontcolor);
|
||||
}
|
||||
}
|
||||
ob_start();
|
||||
imagepng($this->img);
|
||||
imagepng($img);
|
||||
$data = ob_get_contents();
|
||||
ob_end_clean();
|
||||
imagedestroy($this->img);
|
||||
imagedestroy($img);
|
||||
return base64_encode($data);
|
||||
}
|
||||
}
|
@ -26,7 +26,7 @@ use think\admin\Service;
|
||||
class InstallService extends Service
|
||||
{
|
||||
/**
|
||||
* 目录地址
|
||||
* 代码地址
|
||||
* @var string
|
||||
*/
|
||||
protected $uri;
|
||||
|
@ -121,6 +121,23 @@ class SystemService extends Service
|
||||
return [$type, $field, strtolower($outer)];
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成最短URL地址
|
||||
* @param string $url 路由地址
|
||||
* @param array $vars PATH 变量
|
||||
* @param boolean|string $suffix 后缀
|
||||
* @param boolean|string $domain 域名
|
||||
* @return string
|
||||
*/
|
||||
public function sysuri($url = '', array $vars = [], $suffix = true, $domain = false)
|
||||
{
|
||||
$d1 = $this->app->config->get('app.default_app');
|
||||
$d3 = $this->app->config->get('route.default_action');
|
||||
$d2 = $this->app->config->get('route.default_controller');
|
||||
$location = $this->app->route->buildUrl($url, $vars)->suffix($suffix)->domain($domain)->build();
|
||||
return preg_replace('|/\.html$|', '', preg_replace(["|^/{$d1}/{$d2}/{$d3}(\.html)?$|i", "|/{$d2}/{$d3}(\.html)?$|i", "|/{$d3}(\.html)?$|i"], ['$1', '$1', '$1'], $location));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存数据内容
|
||||
* @param string $name
|
||||
@ -215,18 +232,23 @@ class SystemService extends Service
|
||||
* 设置实时运行配置
|
||||
* @param array|null $map 应用映射
|
||||
* @param string|null $run 支持模式
|
||||
* @param array|null $uri 域名映射
|
||||
* @return boolean 是否调试模式
|
||||
*/
|
||||
public function setRuntime($map = [], $run = null)
|
||||
public function setRuntime($map = [], $run = null, $uri = [])
|
||||
{
|
||||
$data = $this->getRuntime();
|
||||
if (is_array($map) && count($map) > 0 && count($data['app_map']) > 0) {
|
||||
foreach ($data['app_map'] as $kk => $vv) if (in_array($vv, $map)) unset($data['app_map'][$kk]);
|
||||
}
|
||||
if (is_array($uri) && count($uri) > 0 && count($data['app_uri']) > 0) {
|
||||
foreach ($data['app_uri'] as $kk => $vv) if (in_array($vv, $uri)) unset($data['app_uri'][$kk]);
|
||||
}
|
||||
$file = "{$this->app->getRootPath()}runtime/config.json";
|
||||
$data['app_run'] = is_null($run) ? $data['app_run'] : $run;
|
||||
$data['app_map'] = is_null($map) ? [] : array_merge($data['app_map'], $map);
|
||||
file_put_contents($file, json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
|
||||
$data['app_uri'] = is_null($uri) ? [] : array_merge($data['app_uri'], $uri);
|
||||
file_put_contents($file, json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
return $this->bindRuntime($data);
|
||||
}
|
||||
|
||||
@ -241,6 +263,7 @@ class SystemService extends Service
|
||||
$data = file_exists($file) ? json_decode(file_get_contents($file), true) : [];
|
||||
if (empty($data) || !is_array($data)) $data = [];
|
||||
if (empty($data['app_map']) || !is_array($data['app_map'])) $data['app_map'] = [];
|
||||
if (empty($data['app_uri']) || !is_array($data['app_uri'])) $data['app_uri'] = [];
|
||||
if (empty($data['app_run']) || !is_string($data['app_run'])) $data['app_run'] = 'developer';
|
||||
return is_null($key) ? $data : (isset($data[$key]) ? $data[$key] : null);
|
||||
}
|
||||
@ -252,8 +275,8 @@ class SystemService extends Service
|
||||
*/
|
||||
public function bindRuntime($data = [])
|
||||
{
|
||||
// 动态绑定应用映射
|
||||
if (empty($data)) $data = $this->getRuntime();
|
||||
// 动态绑定应用
|
||||
if (!empty($data['app_map'])) {
|
||||
$maps = $this->app->config->get('app.app_map', []);
|
||||
if (is_array($maps) && count($maps) > 0 && count($data['app_map']) > 0) {
|
||||
@ -261,25 +284,16 @@ class SystemService extends Service
|
||||
}
|
||||
$this->app->config->set(['app_map' => array_merge($maps, $data['app_map'])], 'app');
|
||||
}
|
||||
// 动态设置当前运行模式
|
||||
// 动态绑定域名
|
||||
if (!empty($data['app_uri'])) {
|
||||
$uris = $this->app->config->get('app.domain_bind', []);
|
||||
if (is_array($uris) && count($uris) > 0 && count($data['app_uri']) > 0) {
|
||||
foreach ($uris as $kk => $vv) if (in_array($vv, $data['app_uri'])) unset($uris[$kk]);
|
||||
}
|
||||
$this->app->config->set(['domain_bind' => array_merge($uris, $data['app_uri'])], 'app');
|
||||
}
|
||||
// 动态设置运行模式
|
||||
return $this->app->debug($data['app_run'] !== 'product')->isDebug();
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成最短URL地址
|
||||
* @param string $url 路由地址
|
||||
* @param array $vars 变量
|
||||
* @param boolean|string $suffix 后缀
|
||||
* @param boolean|string $domain 域名
|
||||
* @return string
|
||||
*/
|
||||
public function sysuri($url = '', array $vars = [], $suffix = true, $domain = false)
|
||||
{
|
||||
$d1 = $this->app->config->get('app.default_app');
|
||||
$d2 = $this->app->config->get('route.default_controller');
|
||||
$d3 = $this->app->config->get('route.default_action');
|
||||
$location = $this->app->route->buildUrl($url, $vars)->suffix($suffix)->domain($domain)->build();
|
||||
return preg_replace(["|^/{$d1}/{$d2}/{$d3}(\.html)?$|i", "|/{$d2}/{$d3}(\.html)?$|i", "|/{$d3}(\.html)?$|i", '|/\.html$|'], ['$1', '$1', '$1', ''], $location);
|
||||
}
|
||||
|
||||
}
|
@ -169,7 +169,7 @@ class LocalStorage extends Storage
|
||||
*/
|
||||
public function upload()
|
||||
{
|
||||
return url('@admin/api.upload/file')->build();
|
||||
return url('admin/api.upload/file')->build();
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user