Compare commits

..

No commits in common. "master" and "v1.3.2.20220113" have entirely different histories.

180 changed files with 37273 additions and 2846 deletions

View File

@ -1,22 +0,0 @@
### 类型
类型(问题/建议/其他):?
### 现象
现象(请详细描述一下复现过程):?
### 期望结果
期望结果(请详细描述一下你说期望的结果):?
### 环境
(请详细说明一下你的运行环境)
- 操作系统Linux/Windows/Other
- Web ServerNGINX/Apache/Other
- PHP 版本7.2/7.3/7.4/8.0/8.1/8.2/Other
- MySQL 版本(5.6/5.7/8.0/Other)
- 服务器面板BT/phpStudy/XAMPP/其他/无):?
- FastAdmin 版本:?
- 浏览器Chrome/IE/Edge/其他):?
- 报错信息:?

2
.gitignore vendored
View File

@ -3,6 +3,7 @@
/vendor/ /vendor/
/runtime/* /runtime/*
/addons/* /addons/*
/application/admin/command/Install/*.lock
/public/assets/libs/ /public/assets/libs/
/public/assets/addons/* /public/assets/addons/*
/public/uploads/* /public/uploads/*
@ -15,4 +16,3 @@ composer.lock
.svn .svn
.vscode .vscode
node_modules node_modules
.user.ini

View File

@ -24,10 +24,12 @@ FastAdmin是一款基于ThinkPHP+Bootstrap的极速后台开发框架。
* 多语言支持,服务端及客户端支持 * 多语言支持,服务端及客户端支持
* 支持大文件分片上传、剪切板粘贴上传、拖拽上传,进度条显示,图片上传前压缩 * 支持大文件分片上传、剪切板粘贴上传、拖拽上传,进度条显示,图片上传前压缩
* 支持表格固定列、固定表头、跨页选择、Excel导出、模板渲染等功能 * 支持表格固定列、固定表头、跨页选择、Excel导出、模板渲染等功能
* 强大的第三方应用模块支持([CMS](https://www.fastadmin.net/store/cms.html)、[CRM](https://www.fastadmin.net/store/facrm.html)、[企业网站管理系统](https://www.fastadmin.net/store/ldcms.html)、[知识库文档系统](https://www.fastadmin.net/store/knowbase.html)、[在线投票系统](https://www.fastadmin.net/store/vote.html)、[B2C商城](https://www.fastadmin.net/store/shopro.html)、[B2B2C商城](https://www.fastadmin.net/store/wanlshop.html)) * 强大的第三方应用模块支持([CMS](https://www.fastadmin.net/store/cms.html)、[博客](https://www.fastadmin.net/store/blog.html)、[知识付费问答](https://www.fastadmin.net/store/ask.html)、[在线投票系统](https://www.fastadmin.net/store/vote.html)、[B2C商城](https://www.fastadmin.net/store/shopro.html)、[B2B2C商城](https://www.fastadmin.net/store/wanlshop.html))
* 支持CMS、博客、知识付费问答无缝整合[Xunsearch全文搜索](https://www.fastadmin.net/store/xunsearch.html)
* 第三方小程序支持([CMS小程序](https://www.fastadmin.net/store/cms.html)、[预订小程序](https://www.fastadmin.net/store/ball.html)、[问答小程序](https://www.fastadmin.net/store/ask.html)、[点餐小程序](https://www.fastadmin.net/store/unidrink.html)、[B2C小程序](https://www.fastadmin.net/store/shopro.html)、[B2B2C小程序](https://www.fastadmin.net/store/wanlshop.html)、[博客小程序](https://www.fastadmin.net/store/blog.html))
* 整合第三方短信接口(阿里云、腾讯云短信) * 整合第三方短信接口(阿里云、腾讯云短信)
* 无缝整合第三方云存储(七牛云、阿里云OSS、腾讯云存储、又拍云)功能,支持云储存分片上传 * 无缝整合第三方云存储(七牛云、阿里云OSS、又拍云)功能,支持云储存分片上传
* 第三方富文本编辑器支持(Summernote、百度编辑器) * 第三方富文本编辑器支持(Summernote、Kindeditor、百度编辑器)
* 第三方登录(QQ、微信、微博)整合 * 第三方登录(QQ、微信、微博)整合
* 第三方支付(微信、支付宝)无缝整合微信支持PC端扫码支付 * 第三方支付(微信、支付宝)无缝整合微信支持PC端扫码支付
* 丰富的插件应用市场 * 丰富的插件应用市场
@ -53,7 +55,9 @@ https://demo.fastadmin.net
在使用中有任何问题,请使用以下联系方式联系我们 在使用中有任何问题,请使用以下联系方式联系我们
问答社区: https://ask.fastadmin.net 交流社区: https://ask.fastadmin.net
QQ群: [636393962](https://jq.qq.com/?_wv=1027&k=487PNBb)(满) [708784003](https://jq.qq.com/?_wv=1027&k=5ObjtwM)(满) [964776039](https://jq.qq.com/?_wv=1027&k=59qjU2P)(3群) [749803490](https://jq.qq.com/?_wv=1027&k=5tczi88)(满) [767103006](https://jq.qq.com/?_wv=1027&k=5Z1U751)(满) [675115483](https://jq.qq.com/?_wv=1027&k=54I6mts)(6群)
Github: https://github.com/karsonzhang/fastadmin Github: https://github.com/karsonzhang/fastadmin
@ -77,7 +81,7 @@ Nice-validator: https://validator.niceue.com
SelectPage: https://github.com/TerryZ/SelectPage SelectPage: https://github.com/TerryZ/SelectPage
Layer: https://layuion.com/layer/ Layer: https://layer.layui.com
DropzoneJS: https://www.dropzonejs.com DropzoneJS: https://www.dropzonejs.com
@ -88,6 +92,6 @@ FastAdmin遵循Apache2开源协议发布并提供免费使用。
本项目包含的第三方源码和二进制文件之版权信息另行标注。 本项目包含的第三方源码和二进制文件之版权信息另行标注。
版权所有Copyright © 2017-2024 by FastAdmin (https://www.fastadmin.net) 版权所有Copyright © 2017-2020 by FastAdmin (https://www.fastadmin.net)
All rights reserved。 All rights reserved。

View File

@ -4,7 +4,7 @@ namespace app\admin\behavior;
class AdminLog class AdminLog
{ {
public function run(&$response) public function run(&$params)
{ {
//只记录POST请求的日志 //只记录POST请求的日志
if (request()->isPost() && config('fastadmin.auto_record_log')) { if (request()->isPost() && config('fastadmin.auto_record_log')) {

View File

@ -15,6 +15,7 @@ use think\exception\PDOException;
class Addon extends Command class Addon extends Command
{ {
protected function configure() protected function configure()
{ {
$this $this
@ -32,7 +33,6 @@ class Addon extends Command
protected function execute(Input $input, Output $output) protected function execute(Input $input, Output $output)
{ {
\think\Config::load(dirname(dirname(__FILE__)) . DS . 'config.php');
$name = $input->getOption('name') ?: ''; $name = $input->getOption('name') ?: '';
$action = $input->getOption('action') ?: ''; $action = $input->getOption('action') ?: '';
if (stripos($name, 'addons' . DS) !== false) { if (stripos($name, 'addons' . DS) !== false) {
@ -82,6 +82,7 @@ class Addon extends Command
$createTableSql = $result[0]['Create Table']; $createTableSql = $result[0]['Create Table'];
} }
} catch (PDOException $e) { } catch (PDOException $e) {
} }
$data = [ $data = [
@ -176,12 +177,12 @@ class Addon extends Command
if (!$info) { if (!$info) {
throw new Exception(__('Addon info file data incorrect')); throw new Exception(__('Addon info file data incorrect'));
} }
$infoname = $info['name'] ?? ''; $infoname = isset($info['name']) ? $info['name'] : '';
if (!$infoname || !preg_match("/^[a-z]+$/i", $infoname) || $infoname != $name) { if (!$infoname || !preg_match("/^[a-z]+$/i", $infoname) || $infoname != $name) {
throw new Exception(__('Addon info name incorrect')); throw new Exception(__('Addon info name incorrect'));
} }
$infoversion = $info['version'] ?? ''; $infoversion = isset($info['version']) ? $info['version'] : '';
if (!$infoversion || !preg_match("/^\d+\.\d+\.\d+$/i", $infoversion)) { if (!$infoversion || !preg_match("/^\d+\.\d+\.\d+$/i", $infoversion)) {
throw new Exception(__('Addon info version incorrect')); throw new Exception(__('Addon info version incorrect'));
} }
@ -339,4 +340,5 @@ class Addon extends Command
{ {
return __DIR__ . '/Addon/stubs/' . $name . '.stub'; return __DIR__ . '/Addon/stubs/' . $name . '.stub';
} }
} }

View File

@ -3,15 +3,11 @@
return [ return [
[ [
//配置唯一标识 //配置唯一标识
'name' => 'username', 'name' => 'usernmae',
//显示的标题 //显示的标题
'title' => '用户名', 'title' => '用户名',
//类型 //类型
'type' => 'string', 'type' => 'string',
//分组
'group' => '',
//动态显示
'visible' => '',
//数据字典 //数据字典
'content' => [ 'content' => [
], ],

View File

@ -98,13 +98,13 @@ class Api extends Command
foreach ($files as $name => $file) { foreach ($files as $name => $file) {
if (!$file->isDir() && $file->getExtension() == 'php') { if (!$file->isDir() && $file->getExtension() == 'php') {
$filePath = $file->getRealPath(); $filePath = $file->getRealPath();
$classes[] = $this->getClassFromFile($filePath); $classes[] = $this->get_class_from_file($filePath);
} }
} }
} else { } else {
foreach ($controller as $index => $item) { foreach ($controller as $index => $item) {
$filePath = $moduleDir . Config::get('url_controller_layer') . DS . $item . '.php'; $filePath = $moduleDir . Config::get('url_controller_layer') . DS . $item . '.php';
$classes[] = $this->getClassFromFile($filePath); $classes[] = $this->get_class_from_file($filePath);
} }
} }
@ -129,61 +129,67 @@ class Api extends Command
} }
/** /**
* 从文件获取命名空间和类名 * get full qualified class name
* *
* @param string $filename * @param string $path_to_file
* @return string * @return string
* @author JBYRNE http://jarretbyrne.com/2015/06/197/
*/ */
protected function getClassFromFile($filename) protected function get_class_from_file($path_to_file)
{ {
$getNext = null; //Grab the contents of the file
$isNamespace = false; $contents = file_get_contents($path_to_file);
$skipNext = false;
$namespace = ''; //Start with a blank namespace and class
$class = ''; $namespace = $class = "";
foreach (\PhpToken::tokenize(file_get_contents($filename)) as $token) {
if (!$token->isIgnorable()) { //Set helper values to know that we have found the namespace/class token and need to collect the string values after them
$name = $token->getTokenName(); $getting_namespace = $getting_class = false;
switch ($name) {
case 'T_NAMESPACE': //Go through each token and evaluate it as necessary
$isNamespace = true; foreach (token_get_all($contents) as $token) {
break;
case 'T_EXTENDS': //If this token is the namespace declaring, then flag that the next tokens will be the namespace name
case 'T_USE': if (is_array($token) && $token[0] == T_NAMESPACE) {
case 'T_IMPLEMENTS': $getting_namespace = true;
$skipNext = true; }
break;
case 'T_CLASS': //If this token is the class declaring, then flag that the next tokens will be the class name
if ($skipNext) { if (is_array($token) && $token[0] == T_CLASS) {
$skipNext = false; $getting_class = true;
} else { }
$getNext = strtolower(substr($name, 2));
} //While we're grabbing the namespace name...
break; if ($getting_namespace === true) {
case 'T_NAME_QUALIFIED':
case 'T_NS_SEPARATOR': //If the token is a string or the namespace separator...
case 'T_STRING': if (is_array($token) && in_array($token[0], [T_STRING, T_NS_SEPARATOR])) {
case ';':
if ($isNamespace) { //Append the token's value to the name of the namespace
if ($name == ';') { $namespace .= $token[1];
$isNamespace = false; } elseif ($token === ';') {
} else {
$namespace .= $token->text; //If the token is the semicolon, then we're done with the namespace declaration
} $getting_namespace = false;
} elseif ($skipNext) { }
$skipNext = false; }
} elseif ($getNext == 'class') {
$class = $token->text; //While we're grabbing the class name...
$getNext = null; if ($getting_class === true) {
break 2;
} //If the token is a string, it's the name of the class
break; if (is_array($token) && $token[0] == T_STRING) {
default:
$getNext = null; //Store the token's value as the class name
$class = $token[1];
//Got what we need, stope here
break;
} }
} }
} }
return $namespace . '\\' . $class; //Build the fully-qualified class name and return it
return $namespace ? $namespace . '\\' . $class : $class;
} }
} }

View File

@ -88,17 +88,11 @@ class Builder
return []; return [];
} }
$typeArr = [
'integer' => 'number',
'file' => 'file',
];
$paramslist = array(); $paramslist = array();
foreach ($docs['ApiParams'] as $params) { foreach ($docs['ApiParams'] as $params) {
$inputtype = $params['type'] && isset($typeArr[$params['type']]) ? $typeArr[$params['type']] : ($params['name'] == 'password' ? 'password' : 'text');
$tr = array( $tr = array(
'name' => $params['name'], 'name' => $params['name'],
'type' => $params['type'] ?? 'string', 'type' => $params['type'] ?? 'string',
'inputtype' => $inputtype,
'sample' => $params['sample'] ?? '', 'sample' => $params['sample'] ?? '',
'required' => $params['required'] ?? true, 'required' => $params['required'] ?? true,
'description' => $params['description'] ?? '', 'description' => $params['description'] ?? '',

View File

@ -1,5 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html lang="{$config.language}">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
@ -8,15 +8,15 @@
<title>{$config.title}</title> <title>{$config.title}</title>
<!-- Bootstrap Core CSS --> <!-- Bootstrap Core CSS -->
<link href="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/twitter-bootstrap/3.4.1/css/bootstrap.min.css" rel="stylesheet"> <link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<!-- Plugin CSS --> <!-- Plugin CSS -->
<link href="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"> <link href="https://cdn.staticfile.org/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --> <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/html5shiv/3.7.3/html5shiv.min.js"></script> <script src="https://cdn.staticfile.org/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/respond.js/1.4.2/respond.min.js"></script> <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
<![endif]--> <![endif]-->
<style type="text/css"> <style type="text/css">
@ -137,7 +137,7 @@
Apiurl: Apiurl:
</div> </div>
<div class="form-group"> <div class="form-group">
<input id="apiUrl" type="text" class="form-control input-sm" data-toggle="tooltip" title="{$lang.Apiurltips}" placeholder="https://api.example.com" value="{$config.apiurl}" /> <input id="apiUrl" type="text" class="form-control input-sm" data-toggle="tooltip" title="{$lang.Apiurltips}" placeholder="https://api.mydomain.com" value="{$config.apiurl}" />
</div> </div>
<div class="form-group"> <div class="form-group">
<button type="button" class="btn btn-success btn-sm" data-toggle="tooltip" title="{$lang.Savetips}" id="save_data"> <button type="button" class="btn btn-success btn-sm" data-toggle="tooltip" title="{$lang.Savetips}" id="save_data">
@ -295,7 +295,7 @@
{foreach name="api['headersList']" id="param"} {foreach name="api['headersList']" id="param"}
<div class="form-group"> <div class="form-group">
<label class="control-label" for="{$param.name}">{$param.name}</label> <label class="control-label" for="{$param.name}">{$param.name}</label>
<input type="{$param.inputtype|default='text'}" class="form-control input-sm" id="{$param.name}" {if $param.required}required{/if} placeholder="{$param.description} - Ex: {$param.sample}" name="{$param.name}"> <input type="{$param.type}" class="form-control input-sm" id="{$param.name}" {if $param.required}required{/if} placeholder="{$param.description} - Ex: {$param.sample}" name="{$param.name}">
</div> </div>
{/foreach} {/foreach}
</div> </div>
@ -314,7 +314,7 @@
{foreach name="api['paramsList']" id="param"} {foreach name="api['paramsList']" id="param"}
<div class="form-group"> <div class="form-group">
<label class="control-label" for="{$param.name}">{$param.name}</label> <label class="control-label" for="{$param.name}">{$param.name}</label>
<input type="{$param.inputtype|default='text'}" class="form-control input-sm" id="{$param.name}" {if $param.required}required{/if} placeholder="{$param.description}{if $param.sample} - 例: {$param.sample}{/if}" name="{$param.name}"> <input type="{$param.type}" class="form-control input-sm" id="{$param.name}" {if $param.required}required{/if} placeholder="{$param.description}{if $param.sample} - 例: {$param.sample}{/if}" name="{$param.name}">
</div> </div>
{/foreach} {/foreach}
{else /} {else /}
@ -401,10 +401,10 @@
</div> <!-- /container --> </div> <!-- /container -->
<!-- jQuery --> <!-- jQuery -->
<script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery/3.6.0/jquery.min.js"></script> <script src="https://cdn.staticfile.org/jquery/2.1.4/jquery.min.js"></script>
<!-- Bootstrap Core JavaScript --> <!-- Bootstrap Core JavaScript -->
<script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/twitter-bootstrap/3.4.1/js/bootstrap.min.js"></script> <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script type="text/javascript"> <script type="text/javascript">
function syntaxHighlight(json) { function syntaxHighlight(json) {

View File

@ -152,7 +152,7 @@ class Crud extends Command
/** /**
* JSON后缀 * JSON后缀
*/ */
protected $jsonSuffix = ['json', 'array']; protected $jsonSuffix = ['json'];
/** /**
* 标签后缀 * 标签后缀
@ -185,7 +185,7 @@ class Crud extends Command
'switch' => 'toggle', 'switch' => 'toggle',
'tag' => 'flag', 'tag' => 'flag',
'tags' => 'flag', 'tags' => 'flag',
'time' => ['type' => ['int', 'bigint', 'timestamp'], 'name' => 'datetime'], 'time' => ['type' => ['int', 'timestamp'], 'name' => 'datetime'],
]; ];
/** /**
@ -435,19 +435,16 @@ class Crud extends Command
$modelName = $table = stripos($table, $prefix) === 0 ? substr($table, strlen($prefix)) : $table; $modelName = $table = stripos($table, $prefix) === 0 ? substr($table, strlen($prefix)) : $table;
$modelTableType = 'table'; $modelTableType = 'table';
$modelTableTypeName = $modelTableName = $modelName; $modelTableTypeName = $modelTableName = $modelName;
$modelTableInfo = null; $modelTableInfo = $dbconnect->query("SHOW TABLE STATUS LIKE '{$modelTableName}'", [], true);
if (!$input->getOption('delete')) { if (!$modelTableInfo) {
$modelTableType = 'name';
$modelTableName = $prefix . $modelName;
$modelTableInfo = $dbconnect->query("SHOW TABLE STATUS LIKE '{$modelTableName}'", [], true); $modelTableInfo = $dbconnect->query("SHOW TABLE STATUS LIKE '{$modelTableName}'", [], true);
if (!$modelTableInfo) { if (!$modelTableInfo) {
$modelTableType = 'name'; throw new Exception("table not found");
$modelTableName = $prefix . $modelName;
$modelTableInfo = $dbconnect->query("SHOW TABLE STATUS LIKE '{$modelTableName}'", [], true);
if (!$modelTableInfo) {
throw new Exception("table not found");
}
} }
$modelTableInfo = $modelTableInfo[0];
} }
$modelTableInfo = $modelTableInfo[0];
$relations = []; $relations = [];
//检查关联表 //检查关联表
@ -469,7 +466,7 @@ class Crud extends Command
} }
} }
$relationTableInfo = $relationTableInfo[0]; $relationTableInfo = $relationTableInfo[0];
$relationModel = $relationModels[$index] ?? ''; $relationModel = isset($relationModels[$index]) ? $relationModels[$index] : '';
list($relationNamespace, $relationName, $relationFile) = $this->getModelData($modelModuleName, $relationModel, $relationName); list($relationNamespace, $relationName, $relationFile) = $this->getModelData($modelModuleName, $relationModel, $relationName);
@ -669,8 +666,8 @@ class Crud extends Command
//如果是关联模型 //如果是关联模型
foreach ($relations as $index => &$relation) { foreach ($relations as $index => &$relation) {
if ($relation['relationMode'] == 'hasone') { if ($relation['relationMode'] == 'hasone') {
$relationForeignKey = $relation['relationForeignKey'] ?: $table . "_id"; $relationForeignKey = $relation['relationForeignKey'] ? $relation['relationForeignKey'] : $table . "_id";
$relationPrimaryKey = $relation['relationPrimaryKey'] ?: $priKey; $relationPrimaryKey = $relation['relationPrimaryKey'] ? $relation['relationPrimaryKey'] : $priKey;
if (!in_array($relationForeignKey, $relation['relationFieldList'])) { if (!in_array($relationForeignKey, $relation['relationFieldList'])) {
throw new Exception('relation table [' . $relation['relationTableName'] . '] must be contain field [' . $relationForeignKey . ']'); throw new Exception('relation table [' . $relation['relationTableName'] . '] must be contain field [' . $relationForeignKey . ']');
@ -679,8 +676,8 @@ class Crud extends Command
throw new Exception('table [' . $modelTableName . '] must be contain field [' . $relationPrimaryKey . ']'); throw new Exception('table [' . $modelTableName . '] must be contain field [' . $relationPrimaryKey . ']');
} }
} elseif ($relation['relationMode'] == 'belongsto') { } elseif ($relation['relationMode'] == 'belongsto') {
$relationForeignKey = $relation['relationForeignKey'] ?: Loader::parseName($relation['relationName']) . "_id"; $relationForeignKey = $relation['relationForeignKey'] ? $relation['relationForeignKey'] : Loader::parseName($relation['relationName']) . "_id";
$relationPrimaryKey = $relation['relationPrimaryKey'] ?: $relation['relationPriKey']; $relationPrimaryKey = $relation['relationPrimaryKey'] ? $relation['relationPrimaryKey'] : $relation['relationPriKey'];
if (!in_array($relationForeignKey, $fieldArr)) { if (!in_array($relationForeignKey, $fieldArr)) {
throw new Exception('table [' . $modelTableName . '] must be contain field [' . $relationForeignKey . ']'); throw new Exception('table [' . $modelTableName . '] must be contain field [' . $relationForeignKey . ']');
} }
@ -688,8 +685,8 @@ class Crud extends Command
throw new Exception('relation table [' . $relation['relationTableName'] . '] must be contain field [' . $relationPrimaryKey . ']'); throw new Exception('relation table [' . $relation['relationTableName'] . '] must be contain field [' . $relationPrimaryKey . ']');
} }
} elseif ($relation['relationMode'] == 'hasmany') { } elseif ($relation['relationMode'] == 'hasmany') {
$relationForeignKey = $relation['relationForeignKey'] ?: $table . "_id"; $relationForeignKey = $relation['relationForeignKey'] ? $relation['relationForeignKey'] : $table . "_id";
$relationPrimaryKey = $relation['relationPrimaryKey'] ?: $priKey; $relationPrimaryKey = $relation['relationPrimaryKey'] ? $relation['relationPrimaryKey'] : $priKey;
if (!in_array($relationForeignKey, $relation['relationFieldList'])) { if (!in_array($relationForeignKey, $relation['relationFieldList'])) {
throw new Exception('relation table [' . $relation['relationTableName'] . '] must be contain field [' . $relationForeignKey . ']'); throw new Exception('relation table [' . $relation['relationTableName'] . '] must be contain field [' . $relationForeignKey . ']');
} }
@ -715,7 +712,6 @@ class Crud extends Command
$headingHtml = '{:build_heading()}'; $headingHtml = '{:build_heading()}';
$controllerImport = ''; $controllerImport = '';
$importHtml = ''; $importHtml = '';
$multipleHtml = '';
$recyclebinHtml = ''; $recyclebinHtml = '';
if ($import) { if ($import) {
@ -882,7 +878,7 @@ class Crud extends Command
$formEditElement = Form::input('text', $fieldName, $editValue, $attrArr); $formEditElement = Form::input('text', $fieldName, $editValue, $attrArr);
} elseif ($inputType == 'fieldlist') { } elseif ($inputType == 'fieldlist') {
$itemArr = $this->getItemArray($itemArr, $field, $v['COLUMN_COMMENT']); $itemArr = $this->getItemArray($itemArr, $field, $v['COLUMN_COMMENT']);
$templateName = !isset($itemArr['key']) && count($itemArr) > 0 ? (isset($itemArr['value']) && count($itemArr) === 1 ? 'fieldlist-array' : 'fieldlist-template') : 'fieldlist'; $templateName = !isset($itemArr['key']) && !isset($itemArr['value']) && count($itemArr) > 0 ? 'fieldlist-template' : 'fieldlist';
$itemKey = isset($itemArr['key']) ? ucfirst($itemArr['key']) : 'Key'; $itemKey = isset($itemArr['key']) ? ucfirst($itemArr['key']) : 'Key';
$itemValue = isset($itemArr['value']) ? ucfirst($itemArr['value']) : 'Value'; $itemValue = isset($itemArr['value']) ? ucfirst($itemArr['value']) : 'Value';
$theadListArr = $tbodyListArr = []; $theadListArr = $tbodyListArr = [];
@ -904,12 +900,6 @@ class Crud extends Command
$cssClassArr[] = 'selectpage'; $cssClassArr[] = 'selectpage';
$selectpageTable = substr($field, 0, strripos($field, '_')); $selectpageTable = substr($field, 0, strripos($field, '_'));
$selectpageField = ''; $selectpageField = '';
foreach ($relations as $index => $relation) {
if ($relation['relationForeignKey'] === $field) {
$selectpageTable = substr($relation['relationTableName'], strlen($prefix));
break;
}
}
$selectpageController = str_replace('_', '/', $selectpageTable); $selectpageController = str_replace('_', '/', $selectpageTable);
$attrArr['data-source'] = $selectpageController . "/index"; $attrArr['data-source'] = $selectpageController . "/index";
//如果是类型表需要特殊处理下 //如果是类型表需要特殊处理下
@ -940,6 +930,7 @@ class Crud extends Command
} }
} }
} catch (\Exception $e) { } catch (\Exception $e) {
} }
if (!$selectpageField) { if (!$selectpageField) {
foreach ($this->fieldSelectpageMap as $m => $n) { foreach ($this->fieldSelectpageMap as $m => $n) {
@ -966,11 +957,6 @@ class Crud extends Command
$attrArr['size'] = 50; $attrArr['size'] = 50;
} }
//字段默认值判断
if ('NULL' == $defaultValue || "''" == $defaultValue) {
$defaultValue = '';
}
$formAddElement = Form::input($inputType, $fieldName, $defaultValue, $attrArr); $formAddElement = Form::input($inputType, $fieldName, $defaultValue, $attrArr);
$formEditElement = Form::input($inputType, $fieldName, $editValue, $attrArr); $formEditElement = Form::input($inputType, $fieldName, $editValue, $attrArr);
if ($search && $replace) { if ($search && $replace) {
@ -1001,11 +987,10 @@ class Crud extends Command
} }
if (!$fields || in_array($field, explode(',', $fields))) { if (!$fields || in_array($field, explode(',', $fields))) {
//构造JS列信息 //构造JS列信息
$javascriptList[] = $this->getJsColumn($field, $v['DATA_TYPE'], $inputType && in_array($inputType, ['select', 'checkbox', 'radio']) ? '_text' : '', $itemArr, $v); $javascriptList[] = $this->getJsColumn($field, $v['DATA_TYPE'], $inputType && in_array($inputType, ['select', 'checkbox', 'radio']) ? '_text' : '', $itemArr);
} }
if ($this->headingFilterField && $this->headingFilterField == $field && $itemArr) { if ($this->headingFilterField && $this->headingFilterField == $field && $itemArr) {
$headingHtml = $this->getReplacedStub('html/heading-html', ['field' => $field, 'fieldName' => Loader::parseName($field, 1, false)]); $headingHtml = $this->getReplacedStub('html/heading-html', ['field' => $field, 'fieldName' => Loader::parseName($field, 1, false)]);
$multipleHtml = $this->getReplacedStub('html/multiple-html', ['field' => $field, 'fieldName' => Loader::parseName($field, 1, false), 'controllerUrl' => $controllerUrl]);
} }
//排序方式,如果有指定排序字段,否则按主键排序 //排序方式,如果有指定排序字段,否则按主键排序
$order = $field == $this->sortField ? $this->sortField : $order; $order = $field == $this->sortField ? $this->sortField : $order;
@ -1056,7 +1041,7 @@ class Crud extends Command
//过滤text类型字段 //过滤text类型字段
if ($v['DATA_TYPE'] != 'text') { if ($v['DATA_TYPE'] != 'text') {
//构造JS列信息 //构造JS列信息
$javascriptList[] = $this->getJsColumn($relationField, $v['DATA_TYPE'], '', [], $v); $javascriptList[] = $this->getJsColumn($relationField, $v['DATA_TYPE']);
} }
} }
} }
@ -1084,7 +1069,7 @@ class Crud extends Command
} }
//表注释 //表注释
$tableComment = $modelTableInfo ? $modelTableInfo['Comment'] : ''; $tableComment = $modelTableInfo['Comment'];
$tableComment = mb_substr($tableComment, -1) == '表' ? mb_substr($tableComment, 0, -1) . '管理' : $tableComment; $tableComment = mb_substr($tableComment, -1) == '表' ? mb_substr($tableComment, 0, -1) . '管理' : $tableComment;
$modelInit = ''; $modelInit = '';
@ -1118,7 +1103,7 @@ class Crud extends Command
'langList' => $langList, 'langList' => $langList,
'softDeleteClassPath' => in_array($this->deleteTimeField, $fieldArr) ? "use traits\model\SoftDelete;" : '', 'softDeleteClassPath' => in_array($this->deleteTimeField, $fieldArr) ? "use traits\model\SoftDelete;" : '',
'softDelete' => in_array($this->deleteTimeField, $fieldArr) ? "use SoftDelete;" : '', 'softDelete' => in_array($this->deleteTimeField, $fieldArr) ? "use SoftDelete;" : '',
'modelAutoWriteTimestamp' => in_array($this->createTimeField, $fieldArr) || in_array($this->updateTimeField, $fieldArr) ? "'integer'" : 'false', 'modelAutoWriteTimestamp' => in_array($this->createTimeField, $fieldArr) || in_array($this->updateTimeField, $fieldArr) ? "'int'" : 'false',
'createTime' => in_array($this->createTimeField, $fieldArr) ? "'{$this->createTimeField}'" : 'false', 'createTime' => in_array($this->createTimeField, $fieldArr) ? "'{$this->createTimeField}'" : 'false',
'updateTime' => in_array($this->updateTimeField, $fieldArr) ? "'{$this->updateTimeField}'" : 'false', 'updateTime' => in_array($this->updateTimeField, $fieldArr) ? "'{$this->updateTimeField}'" : 'false',
'deleteTime' => in_array($this->deleteTimeField, $fieldArr) ? "'{$this->deleteTimeField}'" : 'false', 'deleteTime' => in_array($this->deleteTimeField, $fieldArr) ? "'{$this->deleteTimeField}'" : 'false',
@ -1129,7 +1114,6 @@ class Crud extends Command
'controllerIndex' => '', 'controllerIndex' => '',
'recyclebinJs' => '', 'recyclebinJs' => '',
'headingHtml' => $headingHtml, 'headingHtml' => $headingHtml,
'multipleHtml' => $multipleHtml,
'importHtml' => $importHtml, 'importHtml' => $importHtml,
'recyclebinHtml' => $recyclebinHtml, 'recyclebinHtml' => $recyclebinHtml,
'visibleFieldList' => $fields ? "\$row->visible(['" . implode("','", array_filter(in_array($priKey, explode(',', $fields)) ? explode(',', $fields) : explode(',', $priKey . ',' . $fields))) . "']);" : '', 'visibleFieldList' => $fields ? "\$row->visible(['" . implode("','", array_filter(in_array($priKey, explode(',', $fields)) ? explode(',', $fields) : explode(',', $priKey . ',' . $fields))) . "']);" : '',
@ -1477,7 +1461,7 @@ EOD;
if ($content || !Lang::has($field)) { if ($content || !Lang::has($field)) {
$this->fieldMaxLen = strlen($field) > $this->fieldMaxLen ? strlen($field) : $this->fieldMaxLen; $this->fieldMaxLen = strlen($field) > $this->fieldMaxLen ? strlen($field) : $this->fieldMaxLen;
$content = str_replace('', ',', $content); $content = str_replace('', ',', $content);
if (stripos($content, ':') !== false && stripos($content, '=') !== false) { if (stripos($content, ':') !== false && stripos($content, ',') && stripos($content, '=') !== false) {
list($fieldLang, $item) = explode(':', $content); list($fieldLang, $item) = explode(':', $content);
$itemArr = [$field => $fieldLang]; $itemArr = [$field => $fieldLang];
foreach (explode(',', $item) as $k => $v) { foreach (explode(',', $item) as $k => $v) {
@ -1485,9 +1469,6 @@ EOD;
if (count($valArr) == 2) { if (count($valArr) == 2) {
list($key, $value) = $valArr; list($key, $value) = $valArr;
$itemArr[$field . ' ' . $key] = $value; $itemArr[$field . ' ' . $key] = $value;
if ($this->headingFilterField == $field) {
$itemArr['Set ' . $field . ' to ' . $key] = '设为' . $value;
}
$this->fieldMaxLen = strlen($field . ' ' . $key) > $this->fieldMaxLen ? strlen($field . ' ' . $key) : $this->fieldMaxLen; $this->fieldMaxLen = strlen($field . ' ' . $key) > $this->fieldMaxLen ? strlen($field . ' ' . $key) : $this->fieldMaxLen;
} }
} }
@ -1545,7 +1526,7 @@ EOD;
{ {
$itemArr = []; $itemArr = [];
$comment = str_replace('', ',', $comment); $comment = str_replace('', ',', $comment);
if (stripos($comment, ':') !== false && stripos($comment, '=') !== false) { if (stripos($comment, ':') !== false && stripos($comment, ',') && stripos($comment, '=') !== false) {
list($fieldLang, $item) = explode(':', $comment); list($fieldLang, $item) = explode(':', $comment);
$itemArr = []; $itemArr = [];
foreach (explode(',', $item) as $k => $v) { foreach (explode(',', $item) as $k => $v) {
@ -1563,7 +1544,7 @@ EOD;
return $itemArr; return $itemArr;
} }
protected function getFieldType(&$v) protected function getFieldType(& $v)
{ {
$inputType = 'text'; $inputType = 'text';
switch ($v['DATA_TYPE']) { switch ($v['DATA_TYPE']) {
@ -1707,10 +1688,9 @@ EOD;
* @param string $datatype * @param string $datatype
* @param string $extend * @param string $extend
* @param array $itemArr * @param array $itemArr
* @param array $fieldConfig
* @return string * @return string
*/ */
protected function getJsColumn($field, $datatype = '', $extend = '', $itemArr = [], $fieldConfig = []) protected function getJsColumn($field, $datatype = '', $extend = '', $itemArr = [])
{ {
$lang = mb_ucfirst($field); $lang = mb_ucfirst($field);
$formatter = ''; $formatter = '';
@ -1748,7 +1728,7 @@ EOD;
$noSearchFiles = ['file$', 'files$', 'image$', 'images$', '^weigh$']; $noSearchFiles = ['file$', 'files$', 'image$', 'images$', '^weigh$'];
if (preg_match("/" . implode('|', $noSearchFiles) . "/i", $field)) { if (preg_match("/" . implode('|', $noSearchFiles) . "/i", $field)) {
$html .= ", operate: false"; $html .= ", operate: false";
} elseif (in_array($datatype, ['varchar'])) { } else if (in_array($datatype, ['varchar'])) {
$html .= ", operate: 'LIKE'"; $html .= ", operate: 'LIKE'";
} }
@ -1760,10 +1740,6 @@ EOD;
if (in_array($datatype, ['set'])) { if (in_array($datatype, ['set'])) {
$html .= ", operate:'FIND_IN_SET'"; $html .= ", operate:'FIND_IN_SET'";
} }
if (isset($fieldConfig['CHARACTER_MAXIMUM_LENGTH']) && $fieldConfig['CHARACTER_MAXIMUM_LENGTH'] >= 255 && in_array($datatype, ['varchar']) && !$formatter) {
$formatter = 'content';
$html .= ", table: table, class: 'autocontent'";
}
if (in_array($formatter, ['image', 'images'])) { if (in_array($formatter, ['image', 'images'])) {
$html .= ", events: Table.api.events.image"; $html .= ", events: Table.api.events.image";
} }

View File

@ -5,6 +5,7 @@
<label class="control-label col-xs-12 col-sm-2"></label> <label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8"> <div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button> <button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div> </div>
</div> </div>
</form> </form>

View File

@ -5,6 +5,7 @@
<label class="control-label col-xs-12 col-sm-2"></label> <label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8"> <div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button> <button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div> </div>
</div> </div>
</form> </form>

View File

@ -1,21 +0,0 @@
<dl class="list-unstyled fieldlist" data-name="{%fieldName%}" data-template="{%fieldName%}tpl">
<dd>
<ins>{:__('{%itemValue%}')}</ins>
</dd>
<dd>
<ins><a href="javascript:;" class="btn btn-sm btn-success btn-append"><i class="fa fa-plus"></i> {:__('Append')}</a></ins>
</dd>
</dl>
<textarea name="{%fieldName%}" class="form-control hide" cols="30" rows="5">{%fieldValue%}</textarea>
<script id="{%fieldName%}tpl" type="text/html">
<dd class="form-inline">
<ins><input type="text" name="<%=name%>[<%=index%>][value]" class="form-control" size="15" value="<%=row%>"/></ins>
<ins>
<span class="btn btn-sm btn-danger btn-remove"><i class="fa fa-times"></i></span>
<span class="btn btn-sm btn-primary btn-dragsort"><i class="fa fa-arrows"></i></span>
</ins>
</dd>
</script>

View File

@ -1,8 +0,0 @@
<div class="dropdown btn-group {:$auth->check('{%controllerUrl%}/multi')?'':'hide'}">
<a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
<ul class="dropdown-menu text-left" role="menu">
{foreach name="{%fieldName%}List" item="vo"}
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:" data-params="{%field%}={$key}">{:__('Set {%field%} to ' . $key)}</a></li>
{/foreach}
</ul>
</div>

View File

@ -12,7 +12,13 @@
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('{%controllerUrl%}/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a> <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('{%controllerUrl%}/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
{%importHtml%} {%importHtml%}
{%multipleHtml%} <div class="dropdown btn-group {:$auth->check('{%controllerUrl%}/multi')?'':'hide'}">
<a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
<ul class="dropdown-menu text-left" role="menu">
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
</ul>
</div>
{%recyclebinHtml%} {%recyclebinHtml%}
</div> </div>

View File

@ -2,9 +2,7 @@
protected static function init() protected static function init()
{ {
self::afterInsert(function ($row) { self::afterInsert(function ($row) {
if (!$row['{%order%}']) { $pk = $row->getPk();
$pk = $row->getPk(); $row->getQuery()->where($pk, $row[$pk])->update(['{%order%}' => $row[$pk]]);
$row->getQuery()->where($pk, $row[$pk])->update(['{%order%}' => $row[$pk]]);
}
}); });
} }

View File

@ -1,7 +1,7 @@
public function {%methodName%}($value, $data) public function {%methodName%}($value, $data)
{ {
$value = $value ?: ($data['{%field%}'] ?? ''); $value = $value ? $value : (isset($data['{%field%}']) ? $data['{%field%}'] : '');
$valueArr = explode(',', $value); $valueArr = explode(',', $value);
$list = $this->{%listMethodName%}(); $list = $this->{%listMethodName%}();
return implode(',', array_intersect_key($list, array_flip($valueArr))); return implode(',', array_intersect_key($list, array_flip($valueArr)));

View File

@ -27,7 +27,7 @@
}, },
{ {
field: 'operate', field: 'operate',
width: '140px', width: '130px',
title: __('Operate'), title: __('Operate'),
table: table, table: table,
events: Table.api.events.operate, events: Table.api.events.operate,

View File

@ -70,7 +70,7 @@ class Install extends Command
$adminName = $this->installation($hostname, $hostport, $database, $username, $password, $prefix, $adminUsername, $adminPassword, $adminEmail, $siteName); $adminName = $this->installation($hostname, $hostport, $database, $username, $password, $prefix, $adminUsername, $adminPassword, $adminEmail, $siteName);
if ($adminName) { if ($adminName) {
$output->highlight("Admin url:http://www.example.com/{$adminName}"); $output->highlight("Admin url:http://www.yoursite.com/{$adminName}");
} }
$output->highlight("Admin username:{$adminUsername}"); $output->highlight("Admin username:{$adminUsername}");
@ -86,15 +86,12 @@ class Install extends Command
*/ */
public function index() public function index()
{ {
$this->view = View::instance(array_merge(Config::get('template'), ['tpl_cache' => false])); $this->view = View::instance(Config::get('template'), Config::get('view_replace_str'));
$this->request = Request::instance(); $this->request = Request::instance();
define('INSTALL_PATH', APP_PATH . 'admin' . DS . 'command' . DS . 'Install' . DS); define('INSTALL_PATH', APP_PATH . 'admin' . DS . 'command' . DS . 'Install' . DS);
$langSet = strtolower($this->request->langset());
$lang = $this->request->langset(); if (!$langSet || in_array($langSet, ['zh-cn', 'zh-hans-cn'])) {
$lang = preg_match("/^([a-zA-Z\-_]{2,10})\$/i", $lang) ? $lang : 'zh-cn';
if (!$lang || in_array($lang, ['zh-cn', 'zh-hans-cn'])) {
Lang::load(INSTALL_PATH . 'zh-cn.php'); Lang::load(INSTALL_PATH . 'zh-cn.php');
} }
@ -182,7 +179,7 @@ class Install extends Command
try { try {
$pdo = new PDO("{$config['type']}:host={$mysqlHostname}" . ($mysqlHostport ? ";port={$mysqlHostport}" : ''), $mysqlUsername, $mysqlPassword); $pdo = new PDO("{$config['type']}:host={$mysqlHostname}" . ($mysqlHostport ? ";port={$mysqlHostport}" : ''), $mysqlUsername, $mysqlPassword);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo->query("CREATE DATABASE IF NOT EXISTS `{$mysqlDatabase}` CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;"); $pdo->query("CREATE DATABASE IF NOT EXISTS `{$mysqlDatabase}` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;");
// 连接install命令中指定的数据库 // 连接install命令中指定的数据库
$instance = Db::connect([ $instance = Db::connect([
@ -284,13 +281,6 @@ class Install extends Command
throw new Exception(__('The current permissions are insufficient to write the file %s', 'application/admin/command/Install/install.lock')); throw new Exception(__('The current permissions are insufficient to write the file %s', 'application/admin/command/Install/install.lock'));
} }
try {
//删除安装脚本
@unlink(ROOT_PATH . 'public' . DS . 'install.php');
} catch (\Exception $e) {
}
return $adminName; return $adminName;
} }
@ -309,8 +299,8 @@ class Install extends Command
//数据库配置文件 //数据库配置文件
$dbConfigFile = APP_PATH . 'database.php'; $dbConfigFile = APP_PATH . 'database.php';
if (version_compare(PHP_VERSION, '7.4.0', '<')) { if (version_compare(PHP_VERSION, '7.1.0', '<')) {
throw new Exception(__("The current version %s is too low, please use PHP 7.4 or higher", PHP_VERSION)); throw new Exception(__("The current version %s is too low, please use PHP 7.1 or higher", PHP_VERSION));
} }
if (!extension_loaded("PDO")) { if (!extension_loaded("PDO")) {
throw new Exception(__("PDO is not currently installed and cannot be installed")); throw new Exception(__("PDO is not currently installed and cannot be installed"));

View File

@ -1,6 +1,6 @@
/* /*
FastAdmin Install SQL FastAdmin Install SQL
Date: 2024-09-03 15:05:25 Date: 2020-06-11 22:11:09
*/ */
SET FOREIGN_KEY_CHECKS = 0; SET FOREIGN_KEY_CHECKS = 0;
@ -8,6 +8,7 @@ SET FOREIGN_KEY_CHECKS = 0;
-- ---------------------------- -- ----------------------------
-- Table structure for fa_admin -- Table structure for fa_admin
-- ---------------------------- -- ----------------------------
DROP TABLE IF EXISTS `fa_admin`;
CREATE TABLE `fa_admin` ( CREATE TABLE `fa_admin` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID', `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`username` varchar(20) DEFAULT '' COMMENT '用户名', `username` varchar(20) DEFAULT '' COMMENT '用户名',
@ -16,28 +17,28 @@ CREATE TABLE `fa_admin` (
`salt` varchar(30) DEFAULT '' COMMENT '密码盐', `salt` varchar(30) DEFAULT '' COMMENT '密码盐',
`avatar` varchar(255) DEFAULT '' COMMENT '头像', `avatar` varchar(255) DEFAULT '' COMMENT '头像',
`email` varchar(100) DEFAULT '' COMMENT '电子邮箱', `email` varchar(100) DEFAULT '' COMMENT '电子邮箱',
`mobile` varchar(11) DEFAULT '' COMMENT '手机号码',
`loginfailure` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '失败次数', `loginfailure` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '失败次数',
`logintime` bigint(16) DEFAULT NULL COMMENT '登录时间', `logintime` int(10) DEFAULT NULL COMMENT '登录时间',
`loginip` varchar(50) DEFAULT NULL COMMENT '登录IP', `loginip` varchar(50) DEFAULT NULL COMMENT '登录IP',
`createtime` bigint(16) DEFAULT NULL COMMENT '创建时间', `createtime` int(10) DEFAULT NULL COMMENT '创建时间',
`updatetime` bigint(16) DEFAULT NULL COMMENT '更新时间', `updatetime` int(10) DEFAULT NULL COMMENT '更新时间',
`token` varchar(59) DEFAULT '' COMMENT 'Session标识', `token` varchar(59) DEFAULT '' COMMENT 'Session标识',
`status` varchar(30) NOT NULL DEFAULT 'normal' COMMENT '状态', `status` varchar(30) NOT NULL DEFAULT 'normal' COMMENT '状态',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE KEY `username` (`username`) USING BTREE UNIQUE KEY `username` (`username`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci COMMENT='管理员表'; ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT='管理员表';
-- ---------------------------- -- ----------------------------
-- Records of fa_admin -- Records of fa_admin
-- ---------------------------- -- ----------------------------
BEGIN; BEGIN;
INSERT INTO `fa_admin` VALUES (1, 'admin', 'Admin', '', '', '/assets/img/avatar.png', 'admin@example.com', '', 0, 1491635035, '127.0.0.1',1491635035, 1491635035, '', 'normal'); INSERT INTO `fa_admin` VALUES (1, 'admin', 'Admin', '', '', '/assets/img/avatar.png', 'admin@admin.com', 0, 1491635035, '127.0.0.1',1491635035, 1491635035, '', 'normal');
COMMIT; COMMIT;
-- ---------------------------- -- ----------------------------
-- Table structure for fa_admin_log -- Table structure for fa_admin_log
-- ---------------------------- -- ----------------------------
DROP TABLE IF EXISTS `fa_admin_log`;
CREATE TABLE `fa_admin_log` ( CREATE TABLE `fa_admin_log` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID', `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`admin_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '管理员ID', `admin_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '管理员ID',
@ -47,14 +48,15 @@ CREATE TABLE `fa_admin_log` (
`content` longtext NOT NULL COMMENT '内容', `content` longtext NOT NULL COMMENT '内容',
`ip` varchar(50) DEFAULT '' COMMENT 'IP', `ip` varchar(50) DEFAULT '' COMMENT 'IP',
`useragent` varchar(255) DEFAULT '' COMMENT 'User-Agent', `useragent` varchar(255) DEFAULT '' COMMENT 'User-Agent',
`createtime` bigint(16) DEFAULT NULL COMMENT '操作时间', `createtime` int(10) DEFAULT NULL COMMENT '操作时间',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `name` (`username`) KEY `name` (`username`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci COMMENT='管理员日志表'; ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT='管理员日志表';
-- ---------------------------- -- ----------------------------
-- Table structure for fa_area -- Table structure for fa_area
-- ---------------------------- -- ----------------------------
DROP TABLE IF EXISTS `fa_area`;
CREATE TABLE `fa_area` ( CREATE TABLE `fa_area` (
`id` int(10) NOT NULL AUTO_INCREMENT COMMENT 'ID', `id` int(10) NOT NULL AUTO_INCREMENT COMMENT 'ID',
`pid` int(10) DEFAULT NULL COMMENT '父id', `pid` int(10) DEFAULT NULL COMMENT '父id',
@ -70,32 +72,33 @@ CREATE TABLE `fa_area` (
`lat` varchar(100) DEFAULT NULL COMMENT '纬度', `lat` varchar(100) DEFAULT NULL COMMENT '纬度',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `pid` (`pid`) KEY `pid` (`pid`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci COMMENT='地区表'; ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT='地区表';
-- ---------------------------- -- ----------------------------
-- Table structure for fa_attachment -- Table structure for fa_attachment
-- ---------------------------- -- ----------------------------
DROP TABLE IF EXISTS `fa_attachment`;
CREATE TABLE `fa_attachment` ( CREATE TABLE `fa_attachment` (
`id` int(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID', `id` int(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`category` varchar(50) DEFAULT '' COMMENT '类别', `category` varchar(50) DEFAULT '' COMMENT '类别',
`admin_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '管理员ID', `admin_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '管理员ID',
`user_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '会员ID', `user_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '会员ID',
`url` varchar(255) DEFAULT '' COMMENT '物理路径', `url` varchar(255) DEFAULT '' COMMENT '物理路径',
`imagewidth` int(10) unsigned DEFAULT 0 COMMENT '宽度', `imagewidth` varchar(30) DEFAULT '' COMMENT '宽度',
`imageheight` int(10) unsigned DEFAULT 0 COMMENT '高度', `imageheight` varchar(30) DEFAULT '' COMMENT '高度',
`imagetype` varchar(30) DEFAULT '' COMMENT '图片类型', `imagetype` varchar(30) DEFAULT '' COMMENT '图片类型',
`imageframes` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '图片帧数', `imageframes` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '图片帧数',
`filename` varchar(100) DEFAULT '' COMMENT '文件名称', `filename` varchar(100) DEFAULT '' COMMENT '文件名称',
`filesize` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '文件大小', `filesize` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '文件大小',
`mimetype` varchar(100) DEFAULT '' COMMENT 'mime类型', `mimetype` varchar(100) DEFAULT '' COMMENT 'mime类型',
`extparam` varchar(255) DEFAULT '' COMMENT '透传数据', `extparam` varchar(255) DEFAULT '' COMMENT '透传数据',
`createtime` bigint(16) DEFAULT NULL COMMENT '创建日期', `createtime` int(10) DEFAULT NULL COMMENT '创建日期',
`updatetime` bigint(16) DEFAULT NULL COMMENT '更新时间', `updatetime` int(10) DEFAULT NULL COMMENT '更新时间',
`uploadtime` bigint(16) DEFAULT NULL COMMENT '上传时间', `uploadtime` int(10) DEFAULT NULL COMMENT '上传时间',
`storage` varchar(100) NOT NULL DEFAULT 'local' COMMENT '存储位置', `storage` varchar(100) NOT NULL DEFAULT 'local' COMMENT '存储位置',
`sha1` varchar(40) DEFAULT '' COMMENT '文件 sha1编码', `sha1` varchar(40) DEFAULT '' COMMENT '文件 sha1编码',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci COMMENT='附件表'; ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT='附件表';
-- ---------------------------- -- ----------------------------
-- Records of fa_attachment -- Records of fa_attachment
@ -107,16 +110,17 @@ COMMIT;
-- ---------------------------- -- ----------------------------
-- Table structure for fa_auth_group -- Table structure for fa_auth_group
-- ---------------------------- -- ----------------------------
DROP TABLE IF EXISTS `fa_auth_group`;
CREATE TABLE `fa_auth_group` ( CREATE TABLE `fa_auth_group` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`pid` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '父组别', `pid` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '父组别',
`name` varchar(100) DEFAULT '' COMMENT '组名', `name` varchar(100) DEFAULT '' COMMENT '组名',
`rules` text NOT NULL COMMENT '规则ID', `rules` text NOT NULL COMMENT '规则ID',
`createtime` bigint(16) DEFAULT NULL COMMENT '创建时间', `createtime` int(10) DEFAULT NULL COMMENT '创建时间',
`updatetime` bigint(16) DEFAULT NULL COMMENT '更新时间', `updatetime` int(10) DEFAULT NULL COMMENT '更新时间',
`status` varchar(30) DEFAULT '' COMMENT '状态', `status` varchar(30) DEFAULT '' COMMENT '状态',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci COMMENT='分组表'; ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT='分组表';
-- ---------------------------- -- ----------------------------
-- Records of fa_auth_group -- Records of fa_auth_group
@ -132,13 +136,14 @@ COMMIT;
-- ---------------------------- -- ----------------------------
-- Table structure for fa_auth_group_access -- Table structure for fa_auth_group_access
-- ---------------------------- -- ----------------------------
DROP TABLE IF EXISTS `fa_auth_group_access`;
CREATE TABLE `fa_auth_group_access` ( CREATE TABLE `fa_auth_group_access` (
`uid` int(10) unsigned NOT NULL COMMENT '会员ID', `uid` int(10) unsigned NOT NULL COMMENT '会员ID',
`group_id` int(10) unsigned NOT NULL COMMENT '级别ID', `group_id` int(10) unsigned NOT NULL COMMENT '级别ID',
UNIQUE KEY `uid_group_id` (`uid`,`group_id`), UNIQUE KEY `uid_group_id` (`uid`,`group_id`),
KEY `uid` (`uid`), KEY `uid` (`uid`),
KEY `group_id` (`group_id`) KEY `group_id` (`group_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci COMMENT='权限分组表'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT='权限分组表';
-- ---------------------------- -- ----------------------------
-- Records of fa_auth_group_access -- Records of fa_auth_group_access
@ -150,6 +155,7 @@ COMMIT;
-- ---------------------------- -- ----------------------------
-- Table structure for fa_auth_rule -- Table structure for fa_auth_rule
-- ---------------------------- -- ----------------------------
DROP TABLE IF EXISTS `fa_auth_rule`;
CREATE TABLE `fa_auth_rule` ( CREATE TABLE `fa_auth_rule` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`type` enum('menu','file') NOT NULL DEFAULT 'file' COMMENT 'menu为菜单,file为权限节点', `type` enum('menu','file') NOT NULL DEFAULT 'file' COMMENT 'menu为菜单,file为权限节点',
@ -165,15 +171,15 @@ CREATE TABLE `fa_auth_rule` (
`extend` varchar(255) DEFAULT '' COMMENT '扩展属性', `extend` varchar(255) DEFAULT '' COMMENT '扩展属性',
`py` varchar(30) DEFAULT '' COMMENT '拼音首字母', `py` varchar(30) DEFAULT '' COMMENT '拼音首字母',
`pinyin` varchar(100) DEFAULT '' COMMENT '拼音', `pinyin` varchar(100) DEFAULT '' COMMENT '拼音',
`createtime` bigint(16) DEFAULT NULL COMMENT '创建时间', `createtime` int(10) DEFAULT NULL COMMENT '创建时间',
`updatetime` bigint(16) DEFAULT NULL COMMENT '更新时间', `updatetime` int(10) DEFAULT NULL COMMENT '更新时间',
`weigh` int(10) NOT NULL DEFAULT '0' COMMENT '权重', `weigh` int(10) NOT NULL DEFAULT '0' COMMENT '权重',
`status` varchar(30) DEFAULT '' COMMENT '状态', `status` varchar(30) DEFAULT '' COMMENT '状态',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`) USING BTREE, UNIQUE KEY `name` (`name`) USING BTREE,
KEY `pid` (`pid`), KEY `pid` (`pid`),
KEY `weigh` (`weigh`) KEY `weigh` (`weigh`)
) ENGINE=InnoDB AUTO_INCREMENT=66 DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci COMMENT='节点表'; ) ENGINE=InnoDB AUTO_INCREMENT=66 DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT='节点表';
-- ---------------------------- -- ----------------------------
-- Records of fa_auth_rule -- Records of fa_auth_rule
@ -181,7 +187,7 @@ CREATE TABLE `fa_auth_rule` (
BEGIN; BEGIN;
INSERT INTO `fa_auth_rule` VALUES (1, 'file', 0, 'dashboard', 'Dashboard', 'fa fa-dashboard', '', '', 'Dashboard tips', 1, NULL, '', 'kzt', 'kongzhitai', 1491635035, 1491635035, 143, 'normal'); INSERT INTO `fa_auth_rule` VALUES (1, 'file', 0, 'dashboard', 'Dashboard', 'fa fa-dashboard', '', '', 'Dashboard tips', 1, NULL, '', 'kzt', 'kongzhitai', 1491635035, 1491635035, 143, 'normal');
INSERT INTO `fa_auth_rule` VALUES (2, 'file', 0, 'general', 'General', 'fa fa-cogs', '', '', '', 1, NULL, '', 'cggl', 'changguiguanli', 1491635035, 1491635035, 137, 'normal'); INSERT INTO `fa_auth_rule` VALUES (2, 'file', 0, 'general', 'General', 'fa fa-cogs', '', '', '', 1, NULL, '', 'cggl', 'changguiguanli', 1491635035, 1491635035, 137, 'normal');
INSERT INTO `fa_auth_rule` VALUES (3, 'file', 0, 'category', 'Category', 'fa fa-leaf', '', '', 'Category tips', 0, NULL, '', 'flgl', 'fenleiguanli', 1491635035, 1491635035, 119, 'normal'); INSERT INTO `fa_auth_rule` VALUES (3, 'file', 0, 'category', 'Category', 'fa fa-leaf', '', '', 'Category tips', 1, NULL, '', 'flgl', 'fenleiguanli', 1491635035, 1491635035, 119, 'normal');
INSERT INTO `fa_auth_rule` VALUES (4, 'file', 0, 'addon', 'Addon', 'fa fa-rocket', '', '', 'Addon tips', 1, NULL, '', 'cjgl', 'chajianguanli', 1491635035, 1491635035, 0, 'normal'); INSERT INTO `fa_auth_rule` VALUES (4, 'file', 0, 'addon', 'Addon', 'fa fa-rocket', '', '', 'Addon tips', 1, NULL, '', 'cjgl', 'chajianguanli', 1491635035, 1491635035, 0, 'normal');
INSERT INTO `fa_auth_rule` VALUES (5, 'file', 0, 'auth', 'Auth', 'fa fa-group', '', '', '', 1, NULL, '', 'qxgl', 'quanxianguanli', 1491635035, 1491635035, 99, 'normal'); INSERT INTO `fa_auth_rule` VALUES (5, 'file', 0, 'auth', 'Auth', 'fa fa-group', '', '', '', 1, NULL, '', 'qxgl', 'quanxianguanli', 1491635035, 1491635035, 99, 'normal');
INSERT INTO `fa_auth_rule` VALUES (6, 'file', 2, 'general/config', 'Config', 'fa fa-cog', '', '', 'Config tips', 1, NULL, '', 'xtpz', 'xitongpeizhi', 1491635035, 1491635035, 60, 'normal'); INSERT INTO `fa_auth_rule` VALUES (6, 'file', 2, 'general/config', 'Config', 'fa fa-cog', '', '', 'Config tips', 1, NULL, '', 'xtpz', 'xitongpeizhi', 1491635035, 1491635035, 60, 'normal');
@ -266,6 +272,7 @@ COMMIT;
-- ---------------------------- -- ----------------------------
-- Table structure for fa_category -- Table structure for fa_category
-- ---------------------------- -- ----------------------------
DROP TABLE IF EXISTS `fa_category`;
CREATE TABLE `fa_category` ( CREATE TABLE `fa_category` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`pid` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '父ID', `pid` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '父ID',
@ -277,14 +284,14 @@ CREATE TABLE `fa_category` (
`keywords` varchar(255) DEFAULT '' COMMENT '关键字', `keywords` varchar(255) DEFAULT '' COMMENT '关键字',
`description` varchar(255) DEFAULT '' COMMENT '描述', `description` varchar(255) DEFAULT '' COMMENT '描述',
`diyname` varchar(30) DEFAULT '' COMMENT '自定义名称', `diyname` varchar(30) DEFAULT '' COMMENT '自定义名称',
`createtime` bigint(16) DEFAULT NULL COMMENT '创建时间', `createtime` int(10) DEFAULT NULL COMMENT '创建时间',
`updatetime` bigint(16) DEFAULT NULL COMMENT '更新时间', `updatetime` int(10) DEFAULT NULL COMMENT '更新时间',
`weigh` int(10) NOT NULL DEFAULT '0' COMMENT '权重', `weigh` int(10) NOT NULL DEFAULT '0' COMMENT '权重',
`status` varchar(30) DEFAULT '' COMMENT '状态', `status` varchar(30) DEFAULT '' COMMENT '状态',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `weigh` (`weigh`,`id`), KEY `weigh` (`weigh`,`id`),
KEY `pid` (`pid`) KEY `pid` (`pid`)
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci COMMENT='分类表'; ) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT='分类表';
-- ---------------------------- -- ----------------------------
-- Records of fa_category -- Records of fa_category
@ -308,6 +315,7 @@ COMMIT;
-- ---------------------------- -- ----------------------------
-- Table structure for fa_config -- Table structure for fa_config
-- ---------------------------- -- ----------------------------
DROP TABLE IF EXISTS `fa_config`;
CREATE TABLE `fa_config` ( CREATE TABLE `fa_config` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(30) DEFAULT '' COMMENT '变量名', `name` varchar(30) DEFAULT '' COMMENT '变量名',
@ -315,7 +323,6 @@ CREATE TABLE `fa_config` (
`title` varchar(100) DEFAULT '' COMMENT '变量标题', `title` varchar(100) DEFAULT '' COMMENT '变量标题',
`tip` varchar(100) DEFAULT '' COMMENT '变量描述', `tip` varchar(100) DEFAULT '' COMMENT '变量描述',
`type` varchar(30) DEFAULT '' COMMENT '类型:string,text,int,bool,array,datetime,date,file', `type` varchar(30) DEFAULT '' COMMENT '类型:string,text,int,bool,array,datetime,date,file',
`visible` varchar(255) DEFAULT '' COMMENT '可见条件',
`value` text COMMENT '变量值', `value` text COMMENT '变量值',
`content` text COMMENT '变量字典数据', `content` text COMMENT '变量字典数据',
`rule` varchar(100) DEFAULT '' COMMENT '验证规则', `rule` varchar(100) DEFAULT '' COMMENT '验证规则',
@ -323,35 +330,36 @@ CREATE TABLE `fa_config` (
`setting` varchar(255) DEFAULT '' COMMENT '配置', `setting` varchar(255) DEFAULT '' COMMENT '配置',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`) UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci COMMENT='系统配置'; ) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT='系统配置';
-- ---------------------------- -- ----------------------------
-- Records of fa_config -- Records of fa_config
-- ---------------------------- -- ----------------------------
BEGIN; BEGIN;
INSERT INTO `fa_config` VALUES (1, 'name', 'basic', 'Site name', '请填写站点名称', 'string', '', '我的网站', '', 'required', '', ''); INSERT INTO `fa_config` VALUES (1, 'name', 'basic', 'Site name', '请填写站点名称', 'string', '我的网站', '', 'required', '', '');
INSERT INTO `fa_config` VALUES (2, 'beian', 'basic', 'Beian', '粤ICP备15000000号-1', 'string', '', '', '', '', '', ''); INSERT INTO `fa_config` VALUES (2, 'beian', 'basic', 'Beian', '粤ICP备15000000号-1', 'string', '', '', '', '', '');
INSERT INTO `fa_config` VALUES (3, 'cdnurl', 'basic', 'Cdn url', '如果全站静态资源使用第三方云储存请配置该值', 'string', '', '', '', '', '', ''); INSERT INTO `fa_config` VALUES (3, 'cdnurl', 'basic', 'Cdn url', '如果全站静态资源使用第三方云储存请配置该值', 'string', '', '', '', '', '');
INSERT INTO `fa_config` VALUES (4, 'version', 'basic', 'Version', '如果静态资源有变动请重新配置该值', 'string', '', '1.0.1', '', 'required', '', ''); INSERT INTO `fa_config` VALUES (4, 'version', 'basic', 'Version', '如果静态资源有变动请重新配置该值', 'string', '1.0.1', '', 'required', '', '');
INSERT INTO `fa_config` VALUES (5, 'timezone', 'basic', 'Timezone', '', 'string', '', 'Asia/Shanghai', '', 'required', '', ''); INSERT INTO `fa_config` VALUES (5, 'timezone', 'basic', 'Timezone', '', 'string', 'Asia/Shanghai', '', 'required', '', '');
INSERT INTO `fa_config` VALUES (6, 'forbiddenip', 'basic', 'Forbidden ip', '一行一条记录', 'text', '', '', '', '', '', ''); INSERT INTO `fa_config` VALUES (6, 'forbiddenip', 'basic', 'Forbidden ip', '一行一条记录', 'text', '', '', '', '', '');
INSERT INTO `fa_config` VALUES (7, 'languages', 'basic', 'Languages', '', 'array', '', '{\"backend\":\"zh-cn\",\"frontend\":\"zh-cn\"}', '', 'required', '', ''); INSERT INTO `fa_config` VALUES (7, 'languages', 'basic', 'Languages', '', 'array', '{\"backend\":\"zh-cn\",\"frontend\":\"zh-cn\"}', '', 'required', '', '');
INSERT INTO `fa_config` VALUES (8, 'fixedpage', 'basic', 'Fixed page', '输入左侧菜单栏存在的链接', 'string', '', 'dashboard', '', 'required', '', ''); INSERT INTO `fa_config` VALUES (8, 'fixedpage', 'basic', 'Fixed page', '尽量输入左侧菜单栏存在的链接', 'string', 'dashboard', '', 'required', '', '');
INSERT INTO `fa_config` VALUES (9, 'categorytype', 'dictionary', 'Category type', '', 'array', '', '{\"default\":\"Default\",\"page\":\"Page\",\"article\":\"Article\",\"test\":\"Test\"}', '', '', '', ''); INSERT INTO `fa_config` VALUES (9, 'categorytype', 'dictionary', 'Category type', '', 'array', '{\"default\":\"Default\",\"page\":\"Page\",\"article\":\"Article\",\"test\":\"Test\"}', '', '', '', '');
INSERT INTO `fa_config` VALUES (10, 'configgroup', 'dictionary', 'Config group', '', 'array', '', '{\"basic\":\"Basic\",\"email\":\"Email\",\"dictionary\":\"Dictionary\",\"user\":\"User\",\"example\":\"Example\"}', '', '', '', ''); INSERT INTO `fa_config` VALUES (10, 'configgroup', 'dictionary', 'Config group', '', 'array', '{\"basic\":\"Basic\",\"email\":\"Email\",\"dictionary\":\"Dictionary\",\"user\":\"User\",\"example\":\"Example\"}', '', '', '', '');
INSERT INTO `fa_config` VALUES (11, 'mail_type', 'email', 'Mail type', '选择邮件发送方式', 'select', '', '1', '[\"请选择\",\"SMTP\"]', '', '', ''); INSERT INTO `fa_config` VALUES (11, 'mail_type', 'email', 'Mail type', '选择邮件发送方式', 'select', '1', '[\"请选择\",\"SMTP\"]', '', '', '');
INSERT INTO `fa_config` VALUES (12, 'mail_smtp_host', 'email', 'Mail smtp host', '错误的配置发送邮件会导致服务器超时', 'string', '', 'smtp.qq.com', '', '', '', ''); INSERT INTO `fa_config` VALUES (12, 'mail_smtp_host', 'email', 'Mail smtp host', '错误的配置发送邮件会导致服务器超时', 'string', 'smtp.qq.com', '', '', '', '');
INSERT INTO `fa_config` VALUES (13, 'mail_smtp_port', 'email', 'Mail smtp port', '(不加密默认25,SSL默认465,TLS默认587)', 'string', '', '465', '', '', '', ''); INSERT INTO `fa_config` VALUES (13, 'mail_smtp_port', 'email', 'Mail smtp port', '(不加密默认25,SSL默认465,TLS默认587)', 'string', '465', '', '', '', '');
INSERT INTO `fa_config` VALUES (14, 'mail_smtp_user', 'email', 'Mail smtp user', '(填写完整用户名)', 'string', '', '', '', '', '', ''); INSERT INTO `fa_config` VALUES (14, 'mail_smtp_user', 'email', 'Mail smtp user', '(填写完整用户名)', 'string', '10000', '', '', '', '');
INSERT INTO `fa_config` VALUES (15, 'mail_smtp_pass', 'email', 'Mail smtp password', '(填写您的密码或授权码)', 'password', '', '', '', '', '', ''); INSERT INTO `fa_config` VALUES (15, 'mail_smtp_pass', 'email', 'Mail smtp password', '(填写您的密码或授权码)', 'string', 'password', '', '', '', '');
INSERT INTO `fa_config` VALUES (16, 'mail_verify_type', 'email', 'Mail vertify type', 'SMTP验证方式[推荐SSL]', 'select', '', '2', '[\"无\",\"TLS\",\"SSL\"]', '', '', ''); INSERT INTO `fa_config` VALUES (16, 'mail_verify_type', 'email', 'Mail vertify type', 'SMTP验证方式[推荐SSL]', 'select', '2', '[\"无\",\"TLS\",\"SSL\"]', '', '', '');
INSERT INTO `fa_config` VALUES (17, 'mail_from', 'email', 'Mail from', '', 'string', '', '', '', '', '', ''); INSERT INTO `fa_config` VALUES (17, 'mail_from', 'email', 'Mail from', '', 'string', '10000@qq.com', '', '', '', '');
INSERT INTO `fa_config` VALUES (18, 'attachmentcategory', 'dictionary', 'Attachment category', '', 'array', '', '{\"category1\":\"Category1\",\"category2\":\"Category2\",\"custom\":\"Custom\"}', '', '', '', ''); INSERT INTO `fa_config` VALUES (18, 'attachmentcategory', 'dictionary', 'Attachment category', '', 'array', '{\"category1\":\"Category1\",\"category2\":\"Category2\",\"custom\":\"Custom\"}', '', '', '', '');
COMMIT; COMMIT;
-- ---------------------------- -- ----------------------------
-- Table structure for fa_ems -- Table structure for fa_ems
-- ---------------------------- -- ----------------------------
DROP TABLE IF EXISTS `fa_ems`;
CREATE TABLE `fa_ems` ( CREATE TABLE `fa_ems` (
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'ID', `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'ID',
`event` varchar(30) DEFAULT '' COMMENT '事件', `event` varchar(30) DEFAULT '' COMMENT '事件',
@ -359,13 +367,14 @@ CREATE TABLE `fa_ems` (
`code` varchar(10) DEFAULT '' COMMENT '验证码', `code` varchar(10) DEFAULT '' COMMENT '验证码',
`times` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '验证次数', `times` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '验证次数',
`ip` varchar(30) DEFAULT '' COMMENT 'IP', `ip` varchar(30) DEFAULT '' COMMENT 'IP',
`createtime` bigint(16) DEFAULT NULL COMMENT '创建时间', `createtime` int(10) DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci COMMENT='邮箱验证码表'; ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT='邮箱验证码表';
-- ---------------------------- -- ----------------------------
-- Table structure for fa_sms -- Table structure for fa_sms
-- ---------------------------- -- ----------------------------
DROP TABLE IF EXISTS `fa_sms`;
CREATE TABLE `fa_sms` ( CREATE TABLE `fa_sms` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID', `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`event` varchar(30) DEFAULT '' COMMENT '事件', `event` varchar(30) DEFAULT '' COMMENT '事件',
@ -373,13 +382,14 @@ CREATE TABLE `fa_sms` (
`code` varchar(10) DEFAULT '' COMMENT '验证码', `code` varchar(10) DEFAULT '' COMMENT '验证码',
`times` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '验证次数', `times` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '验证次数',
`ip` varchar(30) DEFAULT '' COMMENT 'IP', `ip` varchar(30) DEFAULT '' COMMENT 'IP',
`createtime` bigint(16) unsigned DEFAULT '0' COMMENT '创建时间', `createtime` int(10) unsigned DEFAULT '0' COMMENT '创建时间',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci COMMENT='短信验证码表'; ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT='短信验证码表';
-- ---------------------------- -- ----------------------------
-- Table structure for fa_test -- Table structure for fa_test
-- ---------------------------- -- ----------------------------
DROP TABLE IF EXISTS `fa_test`;
CREATE TABLE `fa_test` ( CREATE TABLE `fa_test` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID', `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`user_id` int(10) DEFAULT '0' COMMENT '会员ID', `user_id` int(10) DEFAULT '0' COMMENT '会员ID',
@ -399,8 +409,7 @@ CREATE TABLE `fa_test` (
`keywords` varchar(255) DEFAULT '' COMMENT '关键字', `keywords` varchar(255) DEFAULT '' COMMENT '关键字',
`description` varchar(255) DEFAULT '' COMMENT '描述', `description` varchar(255) DEFAULT '' COMMENT '描述',
`city` varchar(100) DEFAULT '' COMMENT '省市', `city` varchar(100) DEFAULT '' COMMENT '省市',
`array` varchar(255) DEFAULT '' COMMENT '数组:value=值', `json` varchar(255) DEFAULT NULL COMMENT '配置:key=名称,value=值',
`json` varchar(255) DEFAULT '' COMMENT '配置:key=名称,value=值',
`multiplejson` varchar(1500) DEFAULT '' COMMENT '二维数组:title=标题,intro=介绍,author=作者,age=年龄', `multiplejson` varchar(1500) DEFAULT '' COMMENT '二维数组:title=标题,intro=介绍,author=作者,age=年龄',
`price` decimal(10,2) unsigned DEFAULT '0.00' COMMENT '价格', `price` decimal(10,2) unsigned DEFAULT '0.00' COMMENT '价格',
`views` int(10) unsigned DEFAULT '0' COMMENT '点击', `views` int(10) unsigned DEFAULT '0' COMMENT '点击',
@ -409,27 +418,28 @@ CREATE TABLE `fa_test` (
`activitytime` datetime DEFAULT NULL COMMENT '活动时间(datetime)', `activitytime` datetime DEFAULT NULL COMMENT '活动时间(datetime)',
`year` year(4) DEFAULT NULL COMMENT '', `year` year(4) DEFAULT NULL COMMENT '',
`times` time DEFAULT NULL COMMENT '时间', `times` time DEFAULT NULL COMMENT '时间',
`refreshtime` bigint(16) DEFAULT NULL COMMENT '刷新时间', `refreshtime` int(10) DEFAULT NULL COMMENT '刷新时间(int)',
`createtime` bigint(16) DEFAULT NULL COMMENT '创建时间', `createtime` int(10) DEFAULT NULL COMMENT '创建时间',
`updatetime` bigint(16) DEFAULT NULL COMMENT '更新时间', `updatetime` int(10) DEFAULT NULL COMMENT '更新时间',
`deletetime` bigint(16) DEFAULT NULL COMMENT '删除时间', `deletetime` int(10) DEFAULT NULL COMMENT '删除时间',
`weigh` int(10) DEFAULT '0' COMMENT '权重', `weigh` int(10) DEFAULT '0' COMMENT '权重',
`switch` tinyint(1) DEFAULT '0' COMMENT '开关', `switch` tinyint(1) DEFAULT '0' COMMENT '开关',
`status` enum('normal','hidden') DEFAULT 'normal' COMMENT '状态', `status` enum('normal','hidden') DEFAULT 'normal' COMMENT '状态',
`state` enum('0','1','2') DEFAULT '1' COMMENT '状态值:0=禁用,1=正常,2=推荐', `state` enum('0','1','2') DEFAULT '1' COMMENT '状态值:0=禁用,1=正常,2=推荐',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci COMMENT='测试表'; ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT='测试表';
-- ---------------------------- -- ----------------------------
-- Records of fa_test -- Records of fa_test
-- ---------------------------- -- ----------------------------
BEGIN; BEGIN;
INSERT INTO `fa_test` VALUES (1, 1, 1, 12, '12,13', '互联网,计算机', 'monday', 'hot,index', 'male', 'music,reading', '我是一篇测试文章', '<p>我是测试内容</p>', '/assets/img/avatar.png', '/assets/img/avatar.png,/assets/img/qrcode.png', '/assets/img/avatar.png', '关键字', '我是一篇测试文章描述,内容过多时将自动隐藏', '广西壮族自治区/百色市/平果县', '[\"a\",\"b\"]', '{\"a\":\"1\",\"b\":\"2\"}', '[{\"title\":\"标题一\",\"intro\":\"介绍一\",\"author\":\"小明\",\"age\":\"21\"}]', 0.00, 0, '2020-10-01 00:00:00 - 2021-10-31 23:59:59', '2017-07-10', '2017-07-10 18:24:45', 2017, '18:24:45', 1491635035, 1491635035, 1491635035, NULL, 0, 1, 'normal', '1'); INSERT INTO `fa_test` VALUES (1, 1, 1, 12, '12,13', '互联网,计算机', 'monday', 'hot,index', 'male', 'music,reading', '我是一篇测试文章', '<p>我是测试内容</p>', '/assets/img/avatar.png', '/assets/img/avatar.png,/assets/img/qrcode.png', '/assets/img/avatar.png', '关键字', '描述', '广西壮族自治区/百色市/平果县', '{\"a\":\"1\",\"b\":\"2\"}', '[{\"title\":\"标题一\",\"intro\":\"介绍一\",\"author\":\"小明\",\"age\":\"21\"}]', 0.00, 0, '2020-10-01 00:00:00 - 2021-10-31 23:59:59', '2017-07-10', '2017-07-10 18:24:45', 2017, '18:24:45', 1491635035, 1491635035, 1491635035, NULL, 0, 1, 'normal', '1');
COMMIT; COMMIT;
-- ---------------------------- -- ----------------------------
-- Table structure for fa_user -- Table structure for fa_user
-- ---------------------------- -- ----------------------------
DROP TABLE IF EXISTS `fa_user`;
CREATE TABLE `fa_user` ( CREATE TABLE `fa_user` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID', `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`group_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '组别ID', `group_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '组别ID',
@ -448,15 +458,14 @@ CREATE TABLE `fa_user` (
`score` int(10) NOT NULL DEFAULT '0' COMMENT '积分', `score` int(10) NOT NULL DEFAULT '0' COMMENT '积分',
`successions` int(10) unsigned NOT NULL DEFAULT '1' COMMENT '连续登录天数', `successions` int(10) unsigned NOT NULL DEFAULT '1' COMMENT '连续登录天数',
`maxsuccessions` int(10) unsigned NOT NULL DEFAULT '1' COMMENT '最大连续登录天数', `maxsuccessions` int(10) unsigned NOT NULL DEFAULT '1' COMMENT '最大连续登录天数',
`prevtime` bigint(16) DEFAULT NULL COMMENT '上次登录时间', `prevtime` int(10) DEFAULT NULL COMMENT '上次登录时间',
`logintime` bigint(16) DEFAULT NULL COMMENT '登录时间', `logintime` int(10) DEFAULT NULL COMMENT '登录时间',
`loginip` varchar(50) DEFAULT '' COMMENT '登录IP', `loginip` varchar(50) DEFAULT '' COMMENT '登录IP',
`loginfailure` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '失败次数', `loginfailure` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '失败次数',
`loginfailuretime` bigint(16) DEFAULT NULL COMMENT '最后登录失败时间',
`joinip` varchar(50) DEFAULT '' COMMENT '加入IP', `joinip` varchar(50) DEFAULT '' COMMENT '加入IP',
`jointime` bigint(16) DEFAULT NULL COMMENT '加入时间', `jointime` int(10) DEFAULT NULL COMMENT '加入时间',
`createtime` bigint(16) DEFAULT NULL COMMENT '创建时间', `createtime` int(10) DEFAULT NULL COMMENT '创建时间',
`updatetime` bigint(16) DEFAULT NULL COMMENT '更新时间', `updatetime` int(10) DEFAULT NULL COMMENT '更新时间',
`token` varchar(50) DEFAULT '' COMMENT 'Token', `token` varchar(50) DEFAULT '' COMMENT 'Token',
`status` varchar(30) DEFAULT '' COMMENT '状态', `status` varchar(30) DEFAULT '' COMMENT '状态',
`verification` varchar(255) DEFAULT '' COMMENT '验证', `verification` varchar(255) DEFAULT '' COMMENT '验证',
@ -464,27 +473,28 @@ CREATE TABLE `fa_user` (
KEY `username` (`username`), KEY `username` (`username`),
KEY `email` (`email`), KEY `email` (`email`),
KEY `mobile` (`mobile`) KEY `mobile` (`mobile`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci COMMENT='会员表'; ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT='会员表';
-- ---------------------------- -- ----------------------------
-- Records of fa_user -- Records of fa_user
-- ---------------------------- -- ----------------------------
BEGIN; BEGIN;
INSERT INTO `fa_user` VALUES (1, 1, 'admin', 'admin', '', '', 'admin@163.com', '13000000000', '', 0, 0, '2017-04-08', '', 0, 0, 1, 1, 1491635035, 1491635035, '127.0.0.1', 0, 1491635035,'127.0.0.1', 1491635035, 0, 1491635035, '', 'normal',''); INSERT INTO `fa_user` VALUES (1, 1, 'admin', 'admin', '', '', 'admin@163.com', '13888888888', '', 0, 0, '2017-04-08', '', 0, 0, 1, 1, 1491635035, 1491635035, '127.0.0.1', 0, '127.0.0.1', 1491635035, 0, 1491635035, '', 'normal','');
COMMIT; COMMIT;
-- ---------------------------- -- ----------------------------
-- Table structure for fa_user_group -- Table structure for fa_user_group
-- ---------------------------- -- ----------------------------
DROP TABLE IF EXISTS `fa_user_group`;
CREATE TABLE `fa_user_group` ( CREATE TABLE `fa_user_group` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(50) DEFAULT '' COMMENT '组名', `name` varchar(50) DEFAULT '' COMMENT '组名',
`rules` text COMMENT '权限节点', `rules` text COMMENT '权限节点',
`createtime` bigint(16) DEFAULT NULL COMMENT '添加时间', `createtime` int(10) DEFAULT NULL COMMENT '添加时间',
`updatetime` bigint(16) DEFAULT NULL COMMENT '更新时间', `updatetime` int(10) DEFAULT NULL COMMENT '更新时间',
`status` enum('normal','hidden') DEFAULT NULL COMMENT '状态', `status` enum('normal','hidden') DEFAULT NULL COMMENT '状态',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci COMMENT='会员组表'; ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT='会员组表';
-- ---------------------------- -- ----------------------------
-- Records of fa_user_group -- Records of fa_user_group
@ -496,6 +506,7 @@ COMMIT;
-- ---------------------------- -- ----------------------------
-- Table structure for fa_user_money_log -- Table structure for fa_user_money_log
-- ---------------------------- -- ----------------------------
DROP TABLE IF EXISTS `fa_user_money_log`;
CREATE TABLE `fa_user_money_log` ( CREATE TABLE `fa_user_money_log` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`user_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '会员ID', `user_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '会员ID',
@ -503,13 +514,14 @@ CREATE TABLE `fa_user_money_log` (
`before` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '变更前余额', `before` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '变更前余额',
`after` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '变更后余额', `after` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '变更后余额',
`memo` varchar(255) DEFAULT '' COMMENT '备注', `memo` varchar(255) DEFAULT '' COMMENT '备注',
`createtime` bigint(16) DEFAULT NULL COMMENT '创建时间', `createtime` int(10) DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci COMMENT='会员余额变动表'; ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT='会员余额变动表';
-- ---------------------------- -- ----------------------------
-- Table structure for fa_user_rule -- Table structure for fa_user_rule
-- ---------------------------- -- ----------------------------
DROP TABLE IF EXISTS `fa_user_rule`;
CREATE TABLE `fa_user_rule` ( CREATE TABLE `fa_user_rule` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`pid` int(10) DEFAULT NULL COMMENT '父ID', `pid` int(10) DEFAULT NULL COMMENT '父ID',
@ -517,12 +529,12 @@ CREATE TABLE `fa_user_rule` (
`title` varchar(50) DEFAULT '' COMMENT '标题', `title` varchar(50) DEFAULT '' COMMENT '标题',
`remark` varchar(100) DEFAULT NULL COMMENT '备注', `remark` varchar(100) DEFAULT NULL COMMENT '备注',
`ismenu` tinyint(1) DEFAULT NULL COMMENT '是否菜单', `ismenu` tinyint(1) DEFAULT NULL COMMENT '是否菜单',
`createtime` bigint(16) DEFAULT NULL COMMENT '创建时间', `createtime` int(10) DEFAULT NULL COMMENT '创建时间',
`updatetime` bigint(16) DEFAULT NULL COMMENT '更新时间', `updatetime` int(10) DEFAULT NULL COMMENT '更新时间',
`weigh` int(10) DEFAULT '0' COMMENT '权重', `weigh` int(10) DEFAULT '0' COMMENT '权重',
`status` enum('normal','hidden') DEFAULT NULL COMMENT '状态', `status` enum('normal','hidden') DEFAULT NULL COMMENT '状态',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci COMMENT='会员规则表'; ) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT='会员规则表';
-- ---------------------------- -- ----------------------------
-- Records of fa_user_rule -- Records of fa_user_rule
@ -545,6 +557,7 @@ COMMIT;
-- ---------------------------- -- ----------------------------
-- Table structure for fa_user_score_log -- Table structure for fa_user_score_log
-- ---------------------------- -- ----------------------------
DROP TABLE IF EXISTS `fa_user_score_log`;
CREATE TABLE `fa_user_score_log` ( CREATE TABLE `fa_user_score_log` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`user_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '会员ID', `user_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '会员ID',
@ -552,24 +565,26 @@ CREATE TABLE `fa_user_score_log` (
`before` int(10) NOT NULL DEFAULT '0' COMMENT '变更前积分', `before` int(10) NOT NULL DEFAULT '0' COMMENT '变更前积分',
`after` int(10) NOT NULL DEFAULT '0' COMMENT '变更后积分', `after` int(10) NOT NULL DEFAULT '0' COMMENT '变更后积分',
`memo` varchar(255) DEFAULT '' COMMENT '备注', `memo` varchar(255) DEFAULT '' COMMENT '备注',
`createtime` bigint(16) DEFAULT NULL COMMENT '创建时间', `createtime` int(10) DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci COMMENT='会员积分变动表'; ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT='会员积分变动表';
-- ---------------------------- -- ----------------------------
-- Table structure for fa_user_token -- Table structure for fa_user_token
-- ---------------------------- -- ----------------------------
DROP TABLE IF EXISTS `fa_user_token`;
CREATE TABLE `fa_user_token` ( CREATE TABLE `fa_user_token` (
`token` varchar(50) NOT NULL COMMENT 'Token', `token` varchar(50) NOT NULL COMMENT 'Token',
`user_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '会员ID', `user_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '会员ID',
`createtime` bigint(16) DEFAULT NULL COMMENT '创建时间', `createtime` int(10) DEFAULT NULL COMMENT '创建时间',
`expiretime` bigint(16) DEFAULT NULL COMMENT '过期时间', `expiretime` int(10) DEFAULT NULL COMMENT '过期时间',
PRIMARY KEY (`token`) PRIMARY KEY (`token`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci COMMENT='会员Token表'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT='会员Token表';
-- ---------------------------- -- ----------------------------
-- Table structure for fa_version -- Table structure for fa_version
-- ---------------------------- -- ----------------------------
DROP TABLE IF EXISTS `fa_version`;
CREATE TABLE `fa_version` ( CREATE TABLE `fa_version` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID', `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
`oldversion` varchar(30) DEFAULT '' COMMENT '旧版本号', `oldversion` varchar(30) DEFAULT '' COMMENT '旧版本号',
@ -578,11 +593,11 @@ CREATE TABLE `fa_version` (
`content` varchar(500) DEFAULT '' COMMENT '升级内容', `content` varchar(500) DEFAULT '' COMMENT '升级内容',
`downloadurl` varchar(255) DEFAULT '' COMMENT '下载地址', `downloadurl` varchar(255) DEFAULT '' COMMENT '下载地址',
`enforce` tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '强制更新', `enforce` tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '强制更新',
`createtime` bigint(16) DEFAULT NULL COMMENT '创建时间', `createtime` int(10) DEFAULT NULL COMMENT '创建时间',
`updatetime` bigint(16) DEFAULT NULL COMMENT '更新时间', `updatetime` int(10) DEFAULT NULL COMMENT '更新时间',
`weigh` int(10) NOT NULL DEFAULT 0 COMMENT '权重', `weigh` int(10) NOT NULL DEFAULT 0 COMMENT '权重',
`status` varchar(30) DEFAULT '' COMMENT '状态', `status` varchar(30) DEFAULT '' COMMENT '状态',
PRIMARY KEY (`id`) USING BTREE PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci COMMENT='版本表'; ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT='版本表';
SET FOREIGN_KEY_CHECKS = 1; SET FOREIGN_KEY_CHECKS = 1;

View File

@ -254,7 +254,7 @@
</form> </form>
<!-- jQuery --> <!-- jQuery -->
<script src="__ROOT__/assets/libs/jquery/dist/jquery.min.js"></script> <script src="https://cdn.staticfile.org/jquery/2.1.4/jquery.min.js"></script>
<script> <script>
$(function () { $(function () {

View File

@ -20,14 +20,14 @@ return [
'Dashboard' => '进入后台', 'Dashboard' => '进入后台',
'Go back' => '返回上一页', 'Go back' => '返回上一页',
'Install Successed' => '安装成功!', 'Install Successed' => '安装成功!',
'Security tips' => '温馨提示:请将以下后台登录入口添加到你的收藏夹,为了你的站点安全,不要泄漏或发送给他人!如有泄漏请及时修改!', 'Security tips' => '温馨提示:请将以下后台登录入口添加到你的收藏夹,为了你的安全,不要泄漏或发送给他人!如有泄漏请及时修改!',
'Please input correct database' => '请输入正确的数据库名', 'Please input correct database' => '请输入正确的数据库名',
'Please input correct username' => '用户名只能由3-30位数字、字母、下划线组合', 'Please input correct username' => '用户名只能由3-30位数字、字母、下划线组合',
'Please input correct password' => '密码长度必须在6-30位之间不能包含空格', 'Please input correct password' => '密码长度必须在6-30位之间不能包含空格',
'Password is too weak' => '密码太简单,请重新输入', 'Password is too weak' => '密码太简单,请重新输入',
'The two passwords you entered did not match' => '两次输入的密码不一致', 'The two passwords you entered did not match' => '两次输入的密码不一致',
'Please input correct website' => '网站名称输入不正确', 'Please input correct website' => '网站名称输入不正确',
'The current version %s is too low, please use PHP 7.4 or higher' => '当前版本%s过低请使用PHP7.4及以上版本', 'The current version %s is too low, please use PHP 7.1 or higher' => '当前版本%s过低请使用PHP7.1以上版本',
'PDO is not currently installed and cannot be installed' => '当前未开启PDO无法进行安装', 'PDO is not currently installed and cannot be installed' => '当前未开启PDO无法进行安装',
'The current permissions are insufficient to write the file %s' => '当前权限不足,无法写入文件%s', 'The current permissions are insufficient to write the file %s' => '当前权限不足,无法写入文件%s',
'Please go to the official website to download the full package or resource package and try to install' => '当前代码仅包含核心代码,请前往官网下载完整包或资源包覆盖后再尝试安装', 'Please go to the official website to download the full package or resource package and try to install' => '当前代码仅包含核心代码,请前往官网下载完整包或资源包覆盖后再尝试安装',

View File

@ -104,7 +104,6 @@ class Min extends Command
continue; continue;
} }
$config = preg_replace("/(urlArgs|baseUrl):(.*)\n/", '', $matches[1]); $config = preg_replace("/(urlArgs|baseUrl):(.*)\n/", '', $matches[1]);
$config = preg_replace("/('tableexport'):(.*)\,\n/", "'tableexport': 'empty:',\n", $config);
$data['config'] = $config; $data['config'] = $config;
} }
// 生成压缩文件 // 生成压缩文件

View File

@ -4,7 +4,6 @@ use app\common\model\Category;
use fast\Form; use fast\Form;
use fast\Tree; use fast\Tree;
use think\Db; use think\Db;
use think\Loader;
if (!function_exists('build_select')) { if (!function_exists('build_select')) {
@ -18,8 +17,8 @@ if (!function_exists('build_select')) {
*/ */
function build_select($name, $options, $selected = [], $attr = []) function build_select($name, $options, $selected = [], $attr = [])
{ {
$options = is_array($options) ? $options : explode(',', $options ?? ''); $options = is_array($options) ? $options : explode(',', $options);
$selected = is_array($selected) ? $selected : explode(',', $selected ?? ''); $selected = is_array($selected) ? $selected : explode(',', $selected);
return Form::select($name, $options, $selected, $attr); return Form::select($name, $options, $selected, $attr);
} }
} }
@ -39,7 +38,7 @@ if (!function_exists('build_radios')) {
$selected = is_null($selected) ? key($list) : $selected; $selected = is_null($selected) ? key($list) : $selected;
$selected = is_array($selected) ? $selected : explode(',', $selected); $selected = is_array($selected) ? $selected : explode(',', $selected);
foreach ($list as $k => $v) { foreach ($list as $k => $v) {
$html[] = sprintf(Form::label("{$name}-{$k}", "%s " . str_replace('%', '%%', $v)), Form::radio($name, $k, in_array($k, $selected), ['id' => "{$name}-{$k}"])); $html[] = sprintf(Form::label("{$name}-{$k}", "%s {$v}"), Form::radio($name, $k, in_array($k, $selected), ['id' => "{$name}-{$k}"]));
} }
return '<div class="radio">' . implode(' ', $html) . '</div>'; return '<div class="radio">' . implode(' ', $html) . '</div>';
} }
@ -60,7 +59,7 @@ if (!function_exists('build_checkboxs')) {
$selected = is_null($selected) ? [] : $selected; $selected = is_null($selected) ? [] : $selected;
$selected = is_array($selected) ? $selected : explode(',', $selected); $selected = is_array($selected) ? $selected : explode(',', $selected);
foreach ($list as $k => $v) { foreach ($list as $k => $v) {
$html[] = sprintf(Form::label("{$name}-{$k}", "%s " . str_replace('%', '%%', $v)), Form::checkbox($name, $k, in_array($k, $selected), ['id' => "{$name}-{$k}"])); $html[] = sprintf(Form::label("{$name}-{$k}", "%s {$v}"), Form::checkbox($name, $k, in_array($k, $selected), ['id' => "{$name}-{$k}"]));
} }
return '<div class="checkbox">' . implode(' ', $html) . '</div>'; return '<div class="checkbox">' . implode(' ', $html) . '</div>';
} }
@ -103,7 +102,7 @@ if (!function_exists('build_toolbar')) {
function build_toolbar($btns = null, $attr = []) function build_toolbar($btns = null, $attr = [])
{ {
$auth = \app\admin\library\Auth::instance(); $auth = \app\admin\library\Auth::instance();
$controller = str_replace('.', '/', Loader::parseName(request()->controller())); $controller = str_replace('.', '/', strtolower(think\Request::instance()->controller()));
$btns = $btns ? $btns : ['refresh', 'add', 'edit', 'del', 'import']; $btns = $btns ? $btns : ['refresh', 'add', 'edit', 'del', 'import'];
$btns = is_array($btns) ? $btns : explode(',', $btns); $btns = is_array($btns) ? $btns : explode(',', $btns);
$index = array_search('delete', $btns); $index = array_search('delete', $btns);
@ -121,7 +120,7 @@ if (!function_exists('build_toolbar')) {
$html = []; $html = [];
foreach ($btns as $k => $v) { foreach ($btns as $k => $v) {
//如果未定义或没有权限 //如果未定义或没有权限
if (!isset($btnAttr[$v]) || ($v !== 'refresh' && !$auth->check("{$controller}/{$v}", $auth->id))) { if (!isset($btnAttr[$v]) || ($v !== 'refresh' && !$auth->check("{$controller}/{$v}"))) {
continue; continue;
} }
list($href, $class, $icon, $text, $title) = $btnAttr[$v]; list($href, $class, $icon, $text, $title) = $btnAttr[$v];
@ -176,7 +175,7 @@ if (!function_exists('build_heading')) {
$title = $content = ''; $title = $content = '';
if (is_null($path)) { if (is_null($path)) {
$action = request()->action(); $action = request()->action();
$controller = str_replace('.', '/', Loader::parseName(request()->controller())); $controller = str_replace('.', '/', request()->controller());
$path = strtolower($controller . ($action && $action != 'index' ? '/' . $action : '')); $path = strtolower($controller . ($action && $action != 'index' ? '/' . $action : ''));
} }
// 根据当前的URI自动匹配父节点的标题和备注 // 根据当前的URI自动匹配父节点的标题和备注

View File

@ -94,26 +94,12 @@ class Addon extends Backend
$this->error(__('Parameter %s can not be empty', '')); $this->error(__('Parameter %s can not be empty', ''));
} }
$tips = []; $tips = [];
$groupList = [];
$ungroupList = [];
foreach ($config as $index => &$item) { foreach ($config as $index => &$item) {
//如果有设置分组
if (isset($item['group']) && $item['group']) {
if (!in_array($item['group'], $groupList)) {
$groupList["custom" . (count($groupList) + 1)] = $item['group'];
}
} elseif ($item['name'] != '__tips__') {
$ungroupList[] = $item['name'];
}
if ($item['name'] == '__tips__') { if ($item['name'] == '__tips__') {
$tips = $item; $tips = $item;
unset($config[$index]); unset($config[$index]);
} }
} }
if ($ungroupList) {
$groupList['other'] = '其它';
}
$this->view->assign("groupList", $groupList);
$this->view->assign("addon", ['info' => $info, 'config' => $config, 'tips' => $tips]); $this->view->assign("addon", ['info' => $info, 'config' => $config, 'tips' => $tips]);
$configFile = ADDON_PATH . $name . DS . 'config.html'; $configFile = ADDON_PATH . $name . DS . 'config.html';
$viewFile = is_file($configFile) ? $configFile : ''; $viewFile = is_file($configFile) ? $configFile : '';
@ -235,7 +221,6 @@ class Addon extends Backend
$uid = $this->request->post("uid"); $uid = $this->request->post("uid");
$token = $this->request->post("token"); $token = $this->request->post("token");
$faversion = $this->request->post("faversion"); $faversion = $this->request->post("faversion");
$force = $this->request->post("force");
if (!$uid || !$token) { if (!$uid || !$token) {
throw new Exception(__('Please login and try to install')); throw new Exception(__('Please login and try to install'));
} }
@ -244,7 +229,7 @@ class Addon extends Backend
'token' => $token, 'token' => $token,
'faversion' => $faversion 'faversion' => $faversion
]; ];
$info = Service::local($file, $extend, $force); $info = Service::local($file, $extend);
} catch (AddonException $e) { } catch (AddonException $e) {
$this->result($e->getData(), $e->getCode(), __($e->getMessage())); $this->result($e->getData(), $e->getCode(), __($e->getMessage()));
} catch (Exception $e) { } catch (Exception $e) {
@ -272,17 +257,15 @@ class Addon extends Backend
$info = []; $info = [];
try { try {
$info = get_addon_info($name);
$uid = $this->request->post("uid"); $uid = $this->request->post("uid");
$token = $this->request->post("token"); $token = $this->request->post("token");
$version = $this->request->post("version"); $version = $this->request->post("version");
$faversion = $this->request->post("faversion"); $faversion = $this->request->post("faversion");
$extend = [ $extend = [
'uid' => $uid, 'uid' => $uid,
'token' => $token, 'token' => $token,
'version' => $version, 'version' => $version,
'oldversion' => $info['version'] ?? '', 'faversion' => $faversion
'faversion' => $faversion
]; ];
//调用更新的方法 //调用更新的方法
$info = Service::upgrade($name, $extend); $info = Service::upgrade($name, $extend);
@ -325,8 +308,9 @@ class Addon extends Backend
{ {
$offset = (int)$this->request->get("offset"); $offset = (int)$this->request->get("offset");
$limit = (int)$this->request->get("limit"); $limit = (int)$this->request->get("limit");
$filter = $this->request->get("filter", ''); $filter = $this->request->get("filter");
$search = $this->request->get("search", '', 'strip_tags,htmlspecialchars'); $search = $this->request->get("search");
$search = htmlspecialchars(strip_tags($search));
$onlineaddons = $this->getAddonList(); $onlineaddons = $this->getAddonList();
$filter = (array)json_decode($filter, true); $filter = (array)json_decode($filter, true);
$addons = get_addon_list(); $addons = get_addon_list();
@ -344,6 +328,7 @@ class Addon extends Backend
$v['flag'] = ''; $v['flag'] = '';
$v['banner'] = ''; $v['banner'] = '';
$v['image'] = ''; $v['image'] = '';
$v['donateimage'] = '';
$v['demourl'] = ''; $v['demourl'] = '';
$v['price'] = __('None'); $v['price'] = __('None');
$v['screenshots'] = []; $v['screenshots'] = [];
@ -447,11 +432,8 @@ class Addon extends Backend
} catch (\Exception $e) { } catch (\Exception $e) {
} }
$rows = $json['rows'] ?? []; $rows = isset($json['rows']) ? $json['rows'] : [];
foreach ($rows as $index => $row) { foreach ($rows as $index => $row) {
if (!isset($row['name'])) {
continue;
}
$onlineaddons[$row['name']] = $row; $onlineaddons[$row['name']] = $row;
} }
Cache::set("onlineaddons", $onlineaddons, 600); Cache::set("onlineaddons", $onlineaddons, 600);

View File

@ -11,7 +11,6 @@ use think\Cache;
use think\Config; use think\Config;
use think\Db; use think\Db;
use think\Lang; use think\Lang;
use think\Loader;
use think\Response; use think\Response;
use think\Validate; use think\Validate;
@ -39,7 +38,7 @@ class Ajax extends Backend
*/ */
public function lang() public function lang()
{ {
$this->request->get(['callback' => 'define']);
$header = ['Content-Type' => 'application/javascript']; $header = ['Content-Type' => 'application/javascript'];
if (!config('app_debug')) { if (!config('app_debug')) {
$offset = 30 * 60 * 60 * 24; // 缓存一个月 $offset = 30 * 60 * 60 * 24; // 缓存一个月
@ -48,20 +47,9 @@ class Ajax extends Backend
$header['Expires'] = gmdate("D, d M Y H:i:s", time() + $offset) . " GMT"; $header['Expires'] = gmdate("D, d M Y H:i:s", time() + $offset) . " GMT";
} }
$controllername = $this->request->get('controllername');
$lang = $this->request->get('lang');
if (!$lang || !in_array($lang, config('allow_lang_list')) || !$controllername || !preg_match("/^[a-z0-9_\.]+$/i", $controllername)) {
return jsonp(['errmsg' => '参数错误'], 200, [], ['json_encode_param' => JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE]);
}
$controllername = input("controllername"); $controllername = input("controllername");
$className = Loader::parseClass($this->request->module(), 'controller', $controllername, false); //默认只加载了控制器对应的语言名,你还根据控制器名来加载额外的语言包
$this->loadlang($controllername);
//存在对应的类才加载
if (class_exists($className)) {
$this->loadlang($controllername);
}
return jsonp(Lang::get(), 200, $header, ['json_encode_param' => JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE]); return jsonp(Lang::get(), 200, $header, ['json_encode_param' => JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE]);
} }
@ -71,10 +59,8 @@ class Ajax extends Backend
public function upload() public function upload()
{ {
Config::set('default_return_type', 'json'); Config::set('default_return_type', 'json');
//必须设定cdnurl为空,否则cdnurl函数计算错误
//必须还原upload配置,否则分片及cdnurl函数计算错误 Config::set('upload.cdnurl', '');
Config::load(APP_PATH . 'extra/upload.php', 'upload');
$chunkid = $this->request->post("chunkid"); $chunkid = $this->request->post("chunkid");
if ($chunkid) { if ($chunkid) {
if (!Config::get('upload.chunking')) { if (!Config::get('upload.chunking')) {
@ -287,18 +273,18 @@ class Ajax extends Backend
{ {
$params = $this->request->get("row/a"); $params = $this->request->get("row/a");
if (!empty($params)) { if (!empty($params)) {
$province = isset($params['province']) ? $params['province'] : null; $province = isset($params['province']) ? $params['province'] : '';
$city = isset($params['city']) ? $params['city'] : null; $city = isset($params['city']) ? $params['city'] : '';
} else { } else {
$province = $this->request->get('province'); $province = $this->request->get('province', '');
$city = $this->request->get('city'); $city = $this->request->get('city', '');
} }
$where = ['pid' => 0, 'level' => 1]; $where = ['pid' => 0, 'level' => 1];
$provincelist = null; $provincelist = null;
if ($province !== null) { if ($province !== '') {
$where['pid'] = $province; $where['pid'] = $province;
$where['level'] = 2; $where['level'] = 2;
if ($city !== null) { if ($city !== '') {
$where['pid'] = $city; $where['pid'] = $city;
$where['level'] = 3; $where['level'] = 3;
} }

View File

@ -45,34 +45,25 @@ class Dashboard extends Backend
} }
$dbTableList = Db::query("SHOW TABLE STATUS"); $dbTableList = Db::query("SHOW TABLE STATUS");
$addonList = get_addon_list();
$totalworkingaddon = 0;
$totaladdon = count($addonList);
foreach ($addonList as $index => $item) {
if ($item['state']) {
$totalworkingaddon += 1;
}
}
$this->view->assign([ $this->view->assign([
'totaluser' => User::count(), 'totaluser' => User::count(),
'totaladdon' => $totaladdon, 'totaladdon' => count(get_addon_list()),
'totaladmin' => Admin::count(), 'totaladmin' => Admin::count(),
'totalcategory' => \app\common\model\Category::count(), 'totalcategory' => \app\common\model\Category::count(),
'todayusersignup' => User::whereTime('jointime', 'today')->count(), 'todayusersignup' => User::whereTime('jointime', 'today')->count(),
'todayuserlogin' => User::whereTime('logintime', 'today')->count(), 'todayuserlogin' => User::whereTime('logintime', 'today')->count(),
'sevendau' => User::whereTime('jointime|logintime|prevtime', '-7 days')->count(), 'sevendau' => User::whereTime('jointime|logintime|prevtime', '-7 days')->count(),
'thirtydau' => User::whereTime('jointime|logintime|prevtime', '-30 days')->count(), 'thirtydau' => User::whereTime('jointime|logintime|prevtime', '-30 days')->count(),
'threednu' => User::whereTime('jointime', '-3 days')->count(), 'threednu' => User::whereTime('jointime', '-3 days')->count(),
'sevendnu' => User::whereTime('jointime', '-7 days')->count(), 'sevendnu' => User::whereTime('jointime', '-7 days')->count(),
'dbtablenums' => count($dbTableList), 'dbtablenums' => count($dbTableList),
'dbsize' => array_sum(array_map(function ($item) { 'dbsize' => array_sum(array_map(function ($item) {
return $item['Data_length'] + $item['Index_length']; return $item['Data_length'] + $item['Index_length'];
}, $dbTableList)), }, $dbTableList)),
'totalworkingaddon' => $totalworkingaddon, 'attachmentnums' => Attachment::count(),
'attachmentnums' => Attachment::count(), 'attachmentsize' => Attachment::sum('filesize'),
'attachmentsize' => Attachment::sum('filesize'), 'picturenums' => Attachment::where('mimetype', 'like', 'image/%')->count(),
'picturenums' => Attachment::where('mimetype', 'like', 'image/%')->count(), 'picturesize' => Attachment::where('mimetype', 'like', 'image/%')->sum('filesize'),
'picturesize' => Attachment::where('mimetype', 'like', 'image/%')->sum('filesize'),
]); ]);
$this->assignconfig('column', array_keys($userlist)); $this->assignconfig('column', array_keys($userlist));

View File

@ -32,7 +32,7 @@ class Index extends Backend
*/ */
public function index() public function index()
{ {
$cookieArr = ['adminskin' => "/^skin\-([a-z\-]+)\$/i", 'multiplenav' => "/^(0|1)\$/", 'multipletab' => "/^(0|1)\$/", 'show_submenu' => "/^(0|1)\$/"]; $cookieArr = ['adminskin' => "/^skin\-([a-z\-]+)\$/i", 'multiplenav' => "/^(0|1)\$/", 'multipletab' => "/^(0|1)\$/"];
foreach ($cookieArr as $key => $regex) { foreach ($cookieArr as $key => $regex) {
$cookieValue = $this->request->cookie($key); $cookieValue = $this->request->cookie($key);
if (!is_null($cookieValue) && preg_match($regex, $cookieValue)) { if (!is_null($cookieValue) && preg_match($regex, $cookieValue)) {
@ -44,6 +44,7 @@ class Index extends Backend
'dashboard' => 'hot', 'dashboard' => 'hot',
'addon' => ['new', 'red', 'badge'], 'addon' => ['new', 'red', 'badge'],
'auth/rule' => __('Menu'), 'auth/rule' => __('Menu'),
'general' => ['new', 'purple'],
], $this->view->site['fixedpage']); ], $this->view->site['fixedpage']);
$action = $this->request->request('action'); $action = $this->request->request('action');
if ($this->request->isPost()) { if ($this->request->isPost()) {
@ -65,16 +66,13 @@ class Index extends Backend
*/ */
public function login() public function login()
{ {
$url = $this->request->get('url', '', 'url_clean'); $url = $this->request->get('url', 'index/index');
$url = $url ?: 'index/index';
if ($this->auth->isLogin()) { if ($this->auth->isLogin()) {
$this->success(__("You've logged in, do not login again"), $url); $this->success(__("You've logged in, do not login again"), $url);
} }
//保持会话有效时长,单位:小时
$keeyloginhours = 24;
if ($this->request->isPost()) { if ($this->request->isPost()) {
$username = $this->request->post('username'); $username = $this->request->post('username');
$password = $this->request->post('password', '', null); $password = $this->request->post('password');
$keeplogin = $this->request->post('keeplogin'); $keeplogin = $this->request->post('keeplogin');
$token = $this->request->post('__token__'); $token = $this->request->post('__token__');
$rule = [ $rule = [
@ -97,7 +95,7 @@ class Index extends Backend
$this->error($validate->getError(), $url, ['token' => $this->request->token()]); $this->error($validate->getError(), $url, ['token' => $this->request->token()]);
} }
AdminLog::setTitle(__('Login')); AdminLog::setTitle(__('Login'));
$result = $this->auth->login($username, $password, $keeplogin ? $keeyloginhours * 3600 : 0); $result = $this->auth->login($username, $password, $keeplogin ? 86400 : 0);
if ($result === true) { if ($result === true) {
Hook::listen("admin_login_after", $this->request); Hook::listen("admin_login_after", $this->request);
$this->success(__('Login successful'), $url, ['url' => $url, 'id' => $this->auth->id, 'username' => $username, 'avatar' => $this->auth->avatar]); $this->success(__('Login successful'), $url, ['url' => $url, 'id' => $this->auth->id, 'username' => $username, 'avatar' => $this->auth->avatar]);
@ -115,7 +113,6 @@ class Index extends Backend
} }
$background = Config::get('fastadmin.login_background'); $background = Config::get('fastadmin.login_background');
$background = $background ? (stripos($background, 'http') === 0 ? $background : config('site.cdnurl') . $background) : ''; $background = $background ? (stripos($background, 'http') === 0 ? $background : config('site.cdnurl') . $background) : '';
$this->view->assign('keeyloginhours', $keeyloginhours);
$this->view->assign('background', $background); $this->view->assign('background', $background);
$this->view->assign('title', __('Login')); $this->view->assign('title', __('Login'));
Hook::listen("admin_login_init", $this->request); Hook::listen("admin_login_init", $this->request);

View File

@ -129,7 +129,7 @@ class Admin extends Backend
exception(__("Please input correct password")); exception(__("Please input correct password"));
} }
$params['salt'] = Random::alnum(); $params['salt'] = Random::alnum();
$params['password'] = $this->auth->getEncryptPassword($params['password'], $params['salt']); $params['password'] = md5(md5($params['password']) . $params['salt']);
$params['avatar'] = '/assets/img/avatar.png'; //设置新管理员默认头像。 $params['avatar'] = '/assets/img/avatar.png'; //设置新管理员默认头像。
$result = $this->model->validate('Admin.add')->save($params); $result = $this->model->validate('Admin.add')->save($params);
if ($result === false) { if ($result === false) {
@ -183,7 +183,7 @@ class Admin extends Backend
exception(__("Please input correct password")); exception(__("Please input correct password"));
} }
$params['salt'] = Random::alnum(); $params['salt'] = Random::alnum();
$params['password'] = $this->auth->getEncryptPassword($params['password'], $params['salt']); $params['password'] = md5(md5($params['password']) . $params['salt']);
} else { } else {
unset($params['password'], $params['salt']); unset($params['password'], $params['salt']);
} }
@ -192,7 +192,6 @@ class Admin extends Backend
$adminValidate->rule([ $adminValidate->rule([
'username' => 'require|regex:\w{3,30}|unique:admin,username,' . $row->id, 'username' => 'require|regex:\w{3,30}|unique:admin,username,' . $row->id,
'email' => 'require|email|unique:admin,email,' . $row->id, 'email' => 'require|email|unique:admin,email,' . $row->id,
'mobile' => 'regex:1[3-9]\d{9}|unique:admin,mobile,' . $row->id,
'password' => 'regex:\S{32}', 'password' => 'regex:\S{32}',
]); ]);
$result = $row->validate('Admin.edit')->save($params); $result = $row->validate('Admin.edit')->save($params);

View File

@ -44,16 +44,9 @@ class Adminlog extends Backend
$this->request->filter(['strip_tags', 'trim']); $this->request->filter(['strip_tags', 'trim']);
if ($this->request->isAjax()) { if ($this->request->isAjax()) {
list($where, $sort, $order, $offset, $limit) = $this->buildparams(); list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$isSuperAdmin = $this->auth->isSuperAdmin();
$childrenAdminIds = $this->childrenAdminIds;
$list = $this->model $list = $this->model
->where($where) ->where($where)
->where(function ($query) use ($isSuperAdmin, $childrenAdminIds) { ->where('admin_id', 'in', $this->childrenAdminIds)
if (!$isSuperAdmin) {
$query->where('admin_id', 'in', $childrenAdminIds);
}
})
->field('content,useragent', true)
->order($sort, $order) ->order($sort, $order)
->paginate($limit); ->paginate($limit);
@ -73,10 +66,8 @@ class Adminlog extends Backend
if (!$row) { if (!$row) {
$this->error(__('No Results were found')); $this->error(__('No Results were found'));
} }
if (!$this->auth->isSuperAdmin()) { if (!$row['admin_id'] || !in_array($row['admin_id'], $this->childrenAdminIds)) {
if (!$row['admin_id'] || !in_array($row['admin_id'], $this->childrenAdminIds)) { $this->error(__('You have no permission'));
$this->error(__('You have no permission'));
}
} }
$this->view->assign("row", $row->toArray()); $this->view->assign("row", $row->toArray());
return $this->view->fetch(); return $this->view->fetch();
@ -110,15 +101,7 @@ class Adminlog extends Backend
} }
$ids = $ids ? $ids : $this->request->post("ids"); $ids = $ids ? $ids : $this->request->post("ids");
if ($ids) { if ($ids) {
$isSuperAdmin = $this->auth->isSuperAdmin(); $adminList = $this->model->where('id', 'in', $ids)->where('admin_id', 'in', $this->childrenAdminIds)->select();
$childrenAdminIds = $this->childrenAdminIds;
$adminList = $this->model->where('id', 'in', $ids)
->where(function ($query) use ($isSuperAdmin, $childrenAdminIds) {
if (!$isSuperAdmin) {
$query->where('admin_id', 'in', $childrenAdminIds);
}
})
->select();
if ($adminList) { if ($adminList) {
$deleteIds = []; $deleteIds = [];
foreach ($adminList as $k => $v) { foreach ($adminList as $k => $v) {
@ -143,4 +126,8 @@ class Adminlog extends Backend
$this->error(); $this->error();
} }
public function selectpage()
{
return parent::selectpage();
}
} }

View File

@ -36,7 +36,7 @@ class Rule extends Backend
$v['title'] = __($v['title']); $v['title'] = __($v['title']);
} }
unset($v); unset($v);
Tree::instance()->init($ruleList)->icon = ['&nbsp;&nbsp;&nbsp;&nbsp;', '&nbsp;&nbsp;&nbsp;&nbsp;', '&nbsp;&nbsp;&nbsp;&nbsp;']; Tree::instance()->init($ruleList);
$this->rulelist = Tree::instance()->getTreeList(Tree::instance()->getTreeArray(0), 'title'); $this->rulelist = Tree::instance()->getTreeList(Tree::instance()->getTreeArray(0), 'title');
$ruledata = [0 => __('None')]; $ruledata = [0 => __('None')];
foreach ($this->rulelist as $k => &$v) { foreach ($this->rulelist as $k => &$v) {

View File

@ -59,7 +59,7 @@ class Profile extends Backend
$this->error(__("Please input correct email")); $this->error(__("Please input correct email"));
} }
if (isset($params['password'])) { if (isset($params['password'])) {
if (!Validate::is($params['password'], "/^[\S]{6,30}$/")) { if (!Validate::is($params['password'], "/^[\S]{6,16}$/")) {
$this->error(__("Please input correct password")); $this->error(__("Please input correct password"));
} }
$params['salt'] = Random::alnum(); $params['salt'] = Random::alnum();
@ -74,7 +74,6 @@ class Profile extends Backend
$admin->save($params); $admin->save($params);
//因为个人资料面板读取的Session显示修改自己资料后同时更新Session //因为个人资料面板读取的Session显示修改自己资料后同时更新Session
Session::set("admin", $admin->toArray()); Session::set("admin", $admin->toArray());
Session::set("admin.safecode", $this->auth->getEncryptSafecode($admin));
$this->success(); $this->success();
} }
$this->error(); $this->error();

View File

@ -32,7 +32,7 @@ class Rule extends Backend
$v['remark'] = __($v['remark']); $v['remark'] = __($v['remark']);
} }
unset($v); unset($v);
Tree::instance()->init($ruleList)->icon = ['&nbsp;&nbsp;&nbsp;&nbsp;', '&nbsp;&nbsp;&nbsp;&nbsp;', '&nbsp;&nbsp;&nbsp;&nbsp;']; Tree::instance()->init($ruleList);
$this->rulelist = Tree::instance()->getTreeList(Tree::instance()->getTreeArray(0), 'title'); $this->rulelist = Tree::instance()->getTreeList(Tree::instance()->getTreeArray(0), 'title');
$ruledata = [0 => __('None')]; $ruledata = [0 => __('None')];
foreach ($this->rulelist as $k => &$v) { foreach ($this->rulelist as $k => &$v) {

View File

@ -24,7 +24,7 @@ class User extends Backend
public function _initialize() public function _initialize()
{ {
parent::_initialize(); parent::_initialize();
$this->model = new \app\admin\model\User; $this->model = model('User');
} }
/** /**

View File

@ -4,8 +4,6 @@ return [
'User id' => '会员ID', 'User id' => '会员ID',
'Username' => '用户名', 'Username' => '用户名',
'Nickname' => '昵称', 'Nickname' => '昵称',
'Mobile' => '手机',
'Email' => '邮箱',
'Password' => '密码', 'Password' => '密码',
'Sign up' => '注 册', 'Sign up' => '注 册',
'Sign in' => '登 录', 'Sign in' => '登 录',
@ -125,8 +123,6 @@ return [
'%d year%s after' => '%d年后', '%d year%s after' => '%d年后',
'Set to normal' => '设为正常', 'Set to normal' => '设为正常',
'Set to hidden' => '设为隐藏', 'Set to hidden' => '设为隐藏',
'Set status to normal' => '设为正常',
'Set status to hidden' => '设为隐藏',
'Recycle bin' => '回收站', 'Recycle bin' => '回收站',
'Restore' => '还原', 'Restore' => '还原',
'Restore all' => '还原全部', 'Restore all' => '还原全部',

View File

@ -14,8 +14,11 @@ return [
'Refresh addon cache' => '刷新插件缓存', 'Refresh addon cache' => '刷新插件缓存',
'Userinfo' => '会员信息', 'Userinfo' => '会员信息',
'Reload authorization' => '刷新授权', 'Reload authorization' => '刷新授权',
'Online store' => '在线商店',
'Local addon' => '本地插件', 'Local addon' => '本地插件',
'Conflict tips' => '此插件中发现和现有系统中部分文件发现冲突!以下文件将会被影响,请备份好相关文件后再继续操作', 'Conflict tips' => '此插件中发现和现有系统中部分文件发现冲突!以下文件将会被影响,请备份好相关文件后再继续操作',
'Login tips' => '此处登录账号为<a href="https://www.fastadmin.net" target="_blank">FastAdmin官网账号</a>',
'Logined tips' => '你好!%s<br />当前你已经登录,将同步保存你的购买记录',
'Pay tips' => '扫码支付后如果仍然无法安装,请不要重复支付,请稍后再重试安装!', 'Pay tips' => '扫码支付后如果仍然无法安装,请不要重复支付,请稍后再重试安装!',
'Pay successful tips' => '购买成功!请点击继续安装按钮完成安装!', 'Pay successful tips' => '购买成功!请点击继续安装按钮完成安装!',
'Pay click tips' => '请点击这里在新窗口中进行支付!', 'Pay click tips' => '请点击这里在新窗口中进行支付!',
@ -23,7 +26,8 @@ return [
'Upgrade tips' => '确认升级<b>《%s》</b><p class="text-danger">1、请务必做好代码和数据库备份备份备份<br>2、升级后如出现冗余数据请根据需要移除即可!<br>3、不建议在生产环境升级请在本地完成升级测试</p>如有重要数据请备份后再操作!', 'Upgrade tips' => '确认升级<b>《%s》</b><p class="text-danger">1、请务必做好代码和数据库备份备份备份<br>2、升级后如出现冗余数据请根据需要移除即可!<br>3、不建议在生产环境升级请在本地完成升级测试</p>如有重要数据请备份后再操作!',
'Offline installed tips' => '安装成功!清除浏览器缓存和框架缓存后生效!', 'Offline installed tips' => '安装成功!清除浏览器缓存和框架缓存后生效!',
'Online installed tips' => '安装成功!清除浏览器缓存和框架缓存后生效!', 'Online installed tips' => '安装成功!清除浏览器缓存和框架缓存后生效!',
'Please login and try to install' => '请登录FastAdmin后再进行本地安装', 'Not login tips' => '你当前未登录FastAdmin请登录后操作',
'Please login and try to install' => '请登录FastAdmin后再进行离线安装',
'Not installed tips' => '请安装后再访问插件前台页面!', 'Not installed tips' => '请安装后再访问插件前台页面!',
'Not enabled tips' => '插件已经禁用,请启用后再访问插件前台页面!', 'Not enabled tips' => '插件已经禁用,请启用后再访问插件前台页面!',
'New version tips' => '发现新版本:%s 点击查看更新日志', 'New version tips' => '发现新版本:%s 点击查看更新日志',
@ -33,7 +37,6 @@ return [
'Store not available tips' => '插件市场暂不可用,是否切换到本地插件?', 'Store not available tips' => '插件市场暂不可用,是否切换到本地插件?',
'Switch to the local' => '切换到本地插件', 'Switch to the local' => '切换到本地插件',
'try to reload' => '重新尝试加载', 'try to reload' => '重新尝试加载',
'Please disable addon first' => '请先禁用插件再进行操作',
'Please disable the add before trying to upgrade' => '请先禁用插件再进行升级', 'Please disable the add before trying to upgrade' => '请先禁用插件再进行升级',
'Please disable the add before trying to uninstall' => '请先禁用插件再进行卸载', 'Please disable the add before trying to uninstall' => '请先禁用插件再进行卸载',
'Login now' => '立即登录', 'Login now' => '立即登录',
@ -77,6 +80,7 @@ return [
'Enable' => '启用', 'Enable' => '启用',
'Your username or email' => '你的手机号、用户名或邮箱', 'Your username or email' => '你的手机号、用户名或邮箱',
'Your password' => '你的密码', 'Your password' => '你的密码',
'Login FastAdmin' => '登录',
'Login' => '登录', 'Login' => '登录',
'Logout' => '退出登录', 'Logout' => '退出登录',
'Register' => '注册账号', 'Register' => '注册账号',

View File

@ -1,8 +1,6 @@
<?php <?php
return [ return [
'Email' => '电子邮箱',
'Mobile' => '手机号',
'Group' => '所属组别', 'Group' => '所属组别',
'Loginfailure' => '登录失败次数', 'Loginfailure' => '登录失败次数',
'Login time' => '最后登录', 'Login time' => '最后登录',

View File

@ -1,50 +1,47 @@
<?php <?php
return [ return [
'Custom' => '自定义', 'Custom' => '自定义',
'Pid' => '父ID', 'Pid' => '父ID',
'Type' => '栏目类型', 'Type' => '栏目类型',
'Image' => '图片', 'Image' => '图片',
'Total user' => '总会员数', 'Total user' => '总会员数',
'Total addon' => '总插件数', 'Total addon' => '总插件数',
'Total category' => '总分类数', 'Total category' => '总分类数',
'Total attachment' => '总附件数', 'Total admin' => '总管理员数',
'Total admin' => '总管理员数', 'Today user signup' => '今日注册',
'Today user signup' => '今日注册', 'Today user login' => '今日登录',
'Today user login' => '今日登录', 'Today order' => '今日订单',
'Today order' => '今日订单', 'Unsettle order' => '未处理订单',
'Unsettle order' => '未处理订单', 'Three dnu' => '三日新增',
'Three dnu' => '三日新增', 'Seven dnu' => '七日新增',
'Seven dnu' => '七日新增', 'Seven dau' => '七日活跃',
'Seven dau' => '七日活跃', 'Thirty dau' => '月活跃',
'Thirty dau' => '月活跃', 'Custom zone' => '这里是你的自定义数据',
'Custom zone' => '这里是你的自定义数据', 'Register user' => '注册用户数',
'Register user' => '注册用户数', 'Real time' => '实时',
'Real time' => '实时', 'Category count' => '分类统计',
'Category count' => '分类统计', 'Category count tips' => '当前分类总记录数',
'Working addon count' => '运行中的插件', 'Database count' => '数据库统计',
'Category count tips' => '当前分类总记录数', 'Database table nums' => '数据表数量',
'Working addon count tips' => '当前运行中的插件数', 'Database size' => '占用空间',
'Database count' => '数据库统计', 'Attachment count' => '附件统计',
'Database table nums' => '数据表数量', 'Attachment nums' => '附件数量',
'Database size' => '占用空间', 'Attachment size' => '附件大小',
'Attachment count' => '附件统计', 'Attachment count tips' => '当前上传的附件数量',
'Attachment nums' => '附件数量', 'Picture count' => '图片统计',
'Attachment size' => '附件大小', 'Picture nums' => '图片数量',
'Attachment count tips' => '当前上传的附件数量', 'Picture size' => '图片大小',
'Picture count' => '图片统计', 'Server info' => '服务器信息',
'Picture nums' => '图片数量', 'PHP version' => 'PHP版本',
'Picture size' => '图片大小', 'Sapi name' => '运行方式',
'Server info' => '服务器信息', 'Debug mode' => '调试模式',
'PHP version' => 'PHP版本', 'Software' => '环境信息',
'Sapi name' => '运行方式', 'Upload mode' => '上传模式',
'Debug mode' => '调试模式', 'Upload url' => '上传URL',
'Software' => '环境信息', 'Upload cdn url' => '上传CDN',
'Upload mode' => '上传模式', 'Cdn url' => '静态资源CDN',
'Upload url' => '上传URL', 'Timezone' => '时区',
'Upload cdn url' => '上传CDN', 'Language' => '语言',
'Cdn url' => '静态资源CDN', 'View more' => '查看更多',
'Timezone' => '时区',
'Language' => '语言',
'View more' => '查看更多',
]; ];

View File

@ -48,7 +48,6 @@ return [
'Field value' => '字段值', 'Field value' => '字段值',
'Content' => '数据列表', 'Content' => '数据列表',
'Rule' => '校验规则', 'Rule' => '校验规则',
'Visible condition' => '可见条件',
'Site name' => '站点名称', 'Site name' => '站点名称',
'Beian' => '备案号', 'Beian' => '备案号',
'Cdn url' => 'CDN地址', 'Cdn url' => 'CDN地址',

View File

@ -2,7 +2,7 @@
return [ return [
'Url' => '链接', 'Url' => '链接',
'Username' => '用户名', 'Userame' => '用户名',
'Createtime' => '操作时间', 'Createtime' => '操作时间',
'Click to edit' => '点击编辑', 'Click to edit' => '点击编辑',
'Admin log' => '操作日志', 'Admin log' => '操作日志',

View File

@ -25,8 +25,6 @@ return [
'Disable top menu badge' => '禁用顶部彩色小角标', 'Disable top menu badge' => '禁用顶部彩色小角标',
'Disable top menu badge without left menu' => '左边菜单栏的彩色小角标不受影响', 'Disable top menu badge without left menu' => '左边菜单栏的彩色小角标不受影响',
'Skins' => '皮肤', 'Skins' => '皮肤',
'Username must be 3 to 30 characters' => '用户名只能由3-30位数字、字母、下划线组合',
'Password must be 6 to 30 characters' => '密码长度必须在6-30位之间不能包含空格',
'You\'ve logged in, do not login again' => '你已经登录,无需重复登录', 'You\'ve logged in, do not login again' => '你已经登录,无需重复登录',
'Username or password can not be empty' => '用户名密码不能为空', 'Username or password can not be empty' => '用户名密码不能为空',
'Username or password is incorrect' => '用户名或密码不正确', 'Username or password is incorrect' => '用户名或密码不正确',
@ -62,6 +60,5 @@ return [
'Forum' => '交流社区', 'Forum' => '交流社区',
'QQ qun' => 'QQ交流群', 'QQ qun' => 'QQ交流群',
'Captcha' => '验证码', 'Captcha' => '验证码',
'The duration of the session is %s hours' => '设定会话有效时长为%s小时',
'Security tips' => '<i class="fa fa-warning"></i> 安全提示为了你的后台安全请勿将后台管理入口设置为admin或admin.php', 'Security tips' => '<i class="fa fa-warning"></i> 安全提示为了你的后台安全请勿将后台管理入口设置为admin或admin.php',
]; ];

View File

@ -1,10 +1,9 @@
<?php <?php
return [ return [
'Name' => '组名', 'Name' => '组名',
'Rules' => '权限节点', 'Rules' => '权限节点',
'Change password' => '修改密码', 'Createtime' => '添加时间',
'Createtime' => '添加时间', 'Updatetime' => '更新时间',
'Updatetime' => '更新时间', 'Status' => '状态'
'Status' => '状态'
]; ];

View File

@ -1,19 +1,15 @@
<?php <?php
return [ return [
'Pid' => '父ID', 'Pid' => '父ID',
'Name' => '规则', 'Name' => '规则',
'Title' => '标题', 'Title' => '标题',
'Remark' => '备注', 'Remark' => '备注',
'Ismenu' => '是否菜单', 'Ismenu' => '是否菜单',
'Change password' => '修改密码', 'Createtime' => '创建时间',
'Createtime' => '创建时间', 'Updatetime' => '更新时间',
'Updatetime' => '更新时间', 'Menu tips' => '规则任意,请不可重复,仅做层级显示,无需匹配控制器和方法',
'Menu tips' => '规则任意,请不可重复,仅做层级显示,无需匹配控制器和方法', 'Node tips' => '模块/控制器/方法名',
'Node tips' => '模块/控制器/方法名', 'Weigh' => '权重',
'Weigh' => '权重', 'Status' => '状态'
'Status' => '状态',
'Toggle all' => '显示全部',
'Toggle menu visible' => '点击切换菜单显示',
'Toggle sub menu' => '点击切换子菜单',
]; ];

View File

@ -51,7 +51,7 @@ class Auth extends \fast\Auth
$this->setError('Please try again after 1 day'); $this->setError('Please try again after 1 day');
return false; return false;
} }
if ($admin->password != $this->getEncryptPassword($password, $admin->salt)) { if ($admin->password != md5(md5($password) . $admin->salt)) {
$admin->loginfailure++; $admin->loginfailure++;
$admin->save(); $admin->save();
$this->setError('Password is incorrect'); $this->setError('Password is incorrect');
@ -63,8 +63,7 @@ class Auth extends \fast\Auth
$admin->token = Random::uuid(); $admin->token = Random::uuid();
$admin->save(); $admin->save();
Session::set("admin", $admin->toArray()); Session::set("admin", $admin->toArray());
Session::set("admin.safecode", $this->getEncryptSafecode($admin)); $this->keeplogin($keeptime);
$this->keeplogin($admin, $keeptime);
return true; return true;
} }
@ -81,7 +80,6 @@ class Auth extends \fast\Auth
$this->logined = false; //重置登录状态 $this->logined = false; //重置登录状态
Session::delete("admin"); Session::delete("admin");
Cookie::delete("keeplogin"); Cookie::delete("keeplogin");
setcookie('fastadmin_userinfo', '', $_SERVER['REQUEST_TIME'] - 3600, rtrim(url("/" . request()->module(), '', false), '/'));
return true; return true;
} }
@ -102,7 +100,7 @@ class Auth extends \fast\Auth
return false; return false;
} }
//token有变更 //token有变更
if ($key != $this->getKeeploginKey($admin, $keeptime, $expiretime)) { if ($key != md5(md5($id) . md5($keeptime) . md5($expiretime) . $admin->token . config('token.key'))) {
return false; return false;
} }
$ip = request()->ip(); $ip = request()->ip();
@ -111,9 +109,8 @@ class Auth extends \fast\Auth
return false; return false;
} }
Session::set("admin", $admin->toArray()); Session::set("admin", $admin->toArray());
Session::set("admin.safecode", $this->getEncryptSafecode($admin));
//刷新自动登录的时效 //刷新自动登录的时效
$this->keeplogin($admin, $keeptime); $this->keeplogin($keeptime);
return true; return true;
} else { } else {
return false; return false;
@ -126,64 +123,18 @@ class Auth extends \fast\Auth
* @param int $keeptime * @param int $keeptime
* @return boolean * @return boolean
*/ */
protected function keeplogin($admin, $keeptime = 0) protected function keeplogin($keeptime = 0)
{ {
if ($keeptime) { if ($keeptime) {
$expiretime = time() + $keeptime; $expiretime = time() + $keeptime;
$key = $this->getKeeploginKey($admin, $keeptime, $expiretime); $key = md5(md5($this->id) . md5($keeptime) . md5($expiretime) . $this->token . config('token.key'));
Cookie::set('keeplogin', implode('|', [$admin['id'], $keeptime, $expiretime, $key]), $keeptime); $data = [$this->id, $keeptime, $expiretime, $key];
Cookie::set('keeplogin', implode('|', $data), 86400 * 7);
return true; return true;
} }
return false; return false;
} }
/**
* 获取密码加密后的字符串
* @param string $password 密码
* @param string $salt 密码盐
* @return string
*/
public function getEncryptPassword($password, $salt = '')
{
return md5(md5($password) . $salt);
}
/**
* 获取密码加密后的自动登录码
* @param string $password 密码
* @param string $salt 密码盐
* @return string
*/
public function getEncryptKeeplogin($params, $keeptime)
{
$expiretime = time() + $keeptime;
$key = md5(md5($params['id']) . md5($keeptime) . md5($expiretime) . $params['token'] . config('token.key'));
return implode('|', [$this->id, $keeptime, $expiretime, $key]);
}
/**
* 获取自动登录Key
* @param $params
* @param $keeptime
* @param $expiretime
* @return string
*/
public function getKeeploginKey($params, $keeptime, $expiretime)
{
$key = md5(md5($params['id']) . md5($keeptime) . md5($expiretime) . $params['token'] . config('token.key'));
return $key;
}
/**
* 获取加密后的安全码
* @param $params
* @return string
*/
public function getEncryptSafecode($params)
{
return md5(md5($params['username']) . md5(substr($params['password'], 0, 6)) . config('token.key'));
}
public function check($name, $uid = '', $relation = 'or', $mode = 'url') public function check($name, $uid = '', $relation = 'or', $mode = 'url')
{ {
$uid = $uid ? $uid : $this->id; $uid = $uid ? $uid : $this->id;
@ -228,19 +179,13 @@ class Auth extends \fast\Auth
if (!$admin) { if (!$admin) {
return false; return false;
} }
$my = Admin::get($admin['id']);
if (!$my) {
return false;
}
//校验安全码,可用于判断关键信息发生了变更需要重新登录
if (!isset($admin['safecode']) || $this->getEncryptSafecode($my) !== $admin['safecode']) {
$this->logout();
return false;
}
//判断是否同一时间同一账号只能在一个地方登录 //判断是否同一时间同一账号只能在一个地方登录
if (Config::get('fastadmin.login_unique')) { if (Config::get('fastadmin.login_unique')) {
if ($my['token'] != $admin['token']) { $my = Admin::get($admin['id']);
$this->logout(); if (!$my || $my['token'] != $admin['token']) {
$this->logined = false; //重置登录状态
Session::delete("admin");
Cookie::delete("keeplogin");
return false; return false;
} }
} }
@ -339,7 +284,7 @@ class Auth extends \fast\Auth
} }
} }
// 取出所有分组 // 取出所有分组
$groupList = \app\admin\model\AuthGroup::where($this->isSuperAdmin() ? '1=1' : ['status' => 'normal'])->select(); $groupList = \app\admin\model\AuthGroup::where(['status' => 'normal'])->select();
$objList = []; $objList = [];
foreach ($groups as $k => $v) { foreach ($groups as $k => $v) {
if ($v['rules'] === '*') { if ($v['rules'] === '*') {
@ -371,7 +316,8 @@ class Auth extends \fast\Auth
$childrenAdminIds = []; $childrenAdminIds = [];
if (!$this->isSuperAdmin()) { if (!$this->isSuperAdmin()) {
$groupIds = $this->getChildrenGroupIds(false); $groupIds = $this->getChildrenGroupIds(false);
$authGroupList = \app\admin\model\AuthGroupAccess::field('uid,group_id') $authGroupList = \app\admin\model\AuthGroupAccess::
field('uid,group_id')
->where('group_id', 'in', $groupIds) ->where('group_id', 'in', $groupIds)
->select(); ->select();
foreach ($authGroupList as $k => $v) { foreach ($authGroupList as $k => $v) {
@ -417,6 +363,7 @@ class Auth extends \fast\Auth
$titleArr[$pathArr[$rule['name']]] = $rule['title']; $titleArr[$pathArr[$rule['name']]] = $rule['title'];
$menuArr[$pathArr[$rule['name']]] = $rule; $menuArr[$pathArr[$rule['name']]] = $rule;
} }
} }
ksort($menuArr); ksort($menuArr);
$this->breadcrumb = $menuArr; $this->breadcrumb = $menuArr;
@ -442,9 +389,9 @@ class Auth extends \fast\Auth
foreach ($params as $k => $v) { foreach ($params as $k => $v) {
$url = $k; $url = $k;
if (is_array($v)) { if (is_array($v)) {
$nums = $v[0] ?? 0; $nums = isset($v[0]) ? $v[0] : 0;
$color = $v[1] ?? $colorArr[(is_numeric($nums) ? $nums : strlen($nums)) % $colorNums]; $color = isset($v[1]) ? $v[1] : $colorArr[(is_numeric($nums) ? $nums : strlen($nums)) % $colorNums];
$class = $v[2] ?? 'label'; $class = isset($v[2]) ? $v[2] : 'label';
} else { } else {
$nums = $v; $nums = $v;
$color = $colorArr[(is_numeric($nums) ? $nums : strlen($nums)) % $colorNums]; $color = $colorArr[(is_numeric($nums) ? $nums : strlen($nums)) % $colorNums];
@ -472,7 +419,7 @@ class Auth extends \fast\Auth
->column('name,pid'); ->column('name,pid');
$pidArr = array_unique(array_filter(array_column($ruleList, 'pid'))); $pidArr = array_unique(array_filter(array_column($ruleList, 'pid')));
foreach ($ruleList as $k => &$v) { foreach ($ruleList as $k => &$v) {
if (!in_array(strtolower($v['name']), $userRule)) { if (!in_array($v['name'], $userRule)) {
unset($ruleList[$k]); unset($ruleList[$k]);
continue; continue;
} }
@ -483,7 +430,7 @@ class Auth extends \fast\Auth
} }
$v['icon'] = $v['icon'] . ' fa-fw'; $v['icon'] = $v['icon'] . ' fa-fw';
$v['url'] = isset($v['url']) && $v['url'] ? $v['url'] : '/' . $module . '/' . $v['name']; $v['url'] = isset($v['url']) && $v['url'] ? $v['url'] : '/' . $module . '/' . $v['name'];
$v['badge'] = $badgeList[$v['name']] ?? ''; $v['badge'] = isset($badgeList[$v['name']]) ? $badgeList[$v['name']] : '';
$v['title'] = __($v['title']); $v['title'] = __($v['title']);
$v['url'] = preg_match("/^((?:[a-z]+:)?\/\/|data:image\/)(.*)/i", $v['url']) ? $v['url'] : url($v['url']); $v['url'] = preg_match("/^((?:[a-z]+:)?\/\/|data:image\/)(.*)/i", $v['url']) ? $v['url'] : url($v['url']);
$v['menuclass'] = in_array($v['menutype'], ['dialog', 'ajax']) ? 'btn-' . $v['menutype'] : ''; $v['menuclass'] = in_array($v['menutype'], ['dialog', 'ajax']) ? 'btn-' . $v['menutype'] : '';
@ -504,7 +451,7 @@ class Auth extends \fast\Auth
$select_id = $referer ? $referer['id'] : ($selected ? $selected['id'] : 0); $select_id = $referer ? $referer['id'] : ($selected ? $selected['id'] : 0);
$menu = $nav = ''; $menu = $nav = '';
$showSubmenu = config('fastadmin.show_submenu'); $showSubmenu = (int)cookie('show_submenu');
if (Config::get('fastadmin.multiplenav')) { if (Config::get('fastadmin.multiplenav')) {
$topList = []; $topList = [];
foreach ($ruleList as $index => $item) { foreach ($ruleList as $index => $item) {
@ -529,7 +476,7 @@ class Auth extends \fast\Auth
); );
$current = in_array($item['id'], $selectParentIds); $current = in_array($item['id'], $selectParentIds);
$url = $childList ? 'javascript:;' : $item['url']; $url = $childList ? 'javascript:;' : $item['url'];
$addtabs = $childList || !$url ? "" : (stripos($url, "?") !== false ? "&" : "?") . "ref=" . ($item['menutype'] ? $item['menutype'] : 'addtabs'); $addtabs = $childList || !$url ? "" : (stripos($url, "?") !== false ? "&" : "?") . "ref=addtabs";
$childList = str_replace( $childList = str_replace(
'" pid="' . $item['id'] . '"', '" pid="' . $item['id'] . '"',
' ' . ($current ? '' : 'hidden') . '" pid="' . $item['id'] . '"', ' ' . ($current ? '' : 'hidden') . '" pid="' . $item['id'] . '"',

View File

@ -9,16 +9,12 @@ use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
use PhpOffice\PhpSpreadsheet\Reader\Xls; use PhpOffice\PhpSpreadsheet\Reader\Xls;
use PhpOffice\PhpSpreadsheet\Reader\Csv; use PhpOffice\PhpSpreadsheet\Reader\Csv;
use think\Db; use think\Db;
use think\db\exception\BindParamException;
use think\db\exception\DataNotFoundException;
use think\db\exception\ModelNotFoundException;
use think\exception\DbException;
use think\exception\PDOException; use think\exception\PDOException;
use think\exception\ValidateException; use think\exception\ValidateException;
use think\response\Json;
trait Backend trait Backend
{ {
/** /**
* 排除前台提交过来的字段 * 排除前台提交过来的字段
* @param $params * @param $params
@ -28,114 +24,115 @@ trait Backend
{ {
if (is_array($this->excludeFields)) { if (is_array($this->excludeFields)) {
foreach ($this->excludeFields as $field) { foreach ($this->excludeFields as $field) {
if (array_key_exists($field, $params)) { if (key_exists($field, $params)) {
unset($params[$field]); unset($params[$field]);
} }
} }
} else if (array_key_exists($this->excludeFields, $params)) { } else {
unset($params[$this->excludeFields]); if (key_exists($this->excludeFields, $params)) {
unset($params[$this->excludeFields]);
}
} }
return $params; return $params;
} }
/** /**
* 查看 * 查看
*
* @return string|Json
* @throws \think\Exception
* @throws DbException
*/ */
public function index() public function index()
{ {
//设置过滤方法 //设置过滤方法
$this->request->filter(['strip_tags', 'trim']); $this->request->filter(['strip_tags', 'trim']);
if (false === $this->request->isAjax()) { if ($this->request->isAjax()) {
return $this->view->fetch(); //如果发送的来源是Selectpage则转发到Selectpage
if ($this->request->request('keyField')) {
return $this->selectpage();
}
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$list = $this->model
->where($where)
->order($sort, $order)
->paginate($limit);
$result = array("total" => $list->total(), "rows" => $list->items());
return json($result);
} }
//如果发送的来源是 Selectpage则转发到 Selectpage return $this->view->fetch();
if ($this->request->request('keyField')) {
return $this->selectpage();
}
[$where, $sort, $order, $offset, $limit] = $this->buildparams();
$list = $this->model
->where($where)
->order($sort, $order)
->paginate($limit);
$result = ['total' => $list->total(), 'rows' => $list->items()];
return json($result);
} }
/** /**
* 回收站 * 回收站
*
* @return string|Json
* @throws \think\Exception
*/ */
public function recyclebin() public function recyclebin()
{ {
//设置过滤方法 //设置过滤方法
$this->request->filter(['strip_tags', 'trim']); $this->request->filter(['strip_tags', 'trim']);
if (false === $this->request->isAjax()) { if ($this->request->isAjax()) {
return $this->view->fetch(); list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$list = $this->model
->onlyTrashed()
->where($where)
->order($sort, $order)
->paginate($limit);
$result = array("total" => $list->total(), "rows" => $list->items());
return json($result);
} }
[$where, $sort, $order, $offset, $limit] = $this->buildparams(); return $this->view->fetch();
$list = $this->model
->onlyTrashed()
->where($where)
->order($sort, $order)
->paginate($limit);
$result = ['total' => $list->total(), 'rows' => $list->items()];
return json($result);
} }
/** /**
* 添加 * 添加
*
* @return string
* @throws \think\Exception
*/ */
public function add() public function add()
{ {
if (false === $this->request->isPost()) { if ($this->request->isPost()) {
return $this->view->fetch(); $params = $this->request->post("row/a");
} if ($params) {
$params = $this->request->post('row/a'); $params = $this->preExcludeFields($params);
if (empty($params)) {
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
$params[$this->dataLimitField] = $this->auth->id;
}
$result = false;
Db::startTrans();
try {
//是否采用模型验证
if ($this->modelValidate) {
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
$this->model->validateFailException(true)->validate($validate);
}
$result = $this->model->allowField(true)->save($params);
Db::commit();
} catch (ValidateException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (PDOException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if ($result !== false) {
$this->success();
} else {
$this->error(__('No rows were inserted'));
}
}
$this->error(__('Parameter %s can not be empty', '')); $this->error(__('Parameter %s can not be empty', ''));
} }
$params = $this->preExcludeFields($params); return $this->view->fetch();
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
$params[$this->dataLimitField] = $this->auth->id;
}
$result = false;
Db::startTrans();
try {
//是否采用模型验证
if ($this->modelValidate) {
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
$this->model->validateFailException()->validate($validate);
}
$result = $this->model->allowField(true)->save($params);
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if ($result === false) {
$this->error(__('No rows were inserted'));
}
$this->success();
} }
/** /**
* 编辑 * 编辑
*
* @param $ids
* @return string
* @throws DbException
* @throws \think\Exception
*/ */
public function edit($ids = null) public function edit($ids = null)
{ {
@ -144,93 +141,97 @@ trait Backend
$this->error(__('No Results were found')); $this->error(__('No Results were found'));
} }
$adminIds = $this->getDataLimitAdminIds(); $adminIds = $this->getDataLimitAdminIds();
if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) { if (is_array($adminIds)) {
$this->error(__('You have no permission')); if (!in_array($row[$this->dataLimitField], $adminIds)) {
$this->error(__('You have no permission'));
}
} }
if (false === $this->request->isPost()) { if ($this->request->isPost()) {
$this->view->assign('row', $row); $params = $this->request->post("row/a");
return $this->view->fetch(); if ($params) {
} $params = $this->preExcludeFields($params);
$params = $this->request->post('row/a'); $result = false;
if (empty($params)) { Db::startTrans();
try {
//是否采用模型验证
if ($this->modelValidate) {
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
$row->validateFailException(true)->validate($validate);
}
$result = $row->allowField(true)->save($params);
Db::commit();
} catch (ValidateException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (PDOException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if ($result !== false) {
$this->success();
} else {
$this->error(__('No rows were updated'));
}
}
$this->error(__('Parameter %s can not be empty', '')); $this->error(__('Parameter %s can not be empty', ''));
} }
$params = $this->preExcludeFields($params); $this->view->assign("row", $row);
$result = false; return $this->view->fetch();
Db::startTrans();
try {
//是否采用模型验证
if ($this->modelValidate) {
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
$row->validateFailException()->validate($validate);
}
$result = $row->allowField(true)->save($params);
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if (false === $result) {
$this->error(__('No rows were updated'));
}
$this->success();
} }
/** /**
* 删除 * 删除
*
* @param $ids
* @return void
* @throws DbException
* @throws DataNotFoundException
* @throws ModelNotFoundException
*/ */
public function del($ids = null) public function del($ids = "")
{ {
if (false === $this->request->isPost()) { if (!$this->request->isPost()) {
$this->error(__("Invalid parameters")); $this->error(__("Invalid parameters"));
} }
$ids = $ids ?: $this->request->post("ids"); $ids = $ids ? $ids : $this->request->post("ids");
if (empty($ids)) { if ($ids) {
$this->error(__('Parameter %s can not be empty', 'ids')); $pk = $this->model->getPk();
} $adminIds = $this->getDataLimitAdminIds();
$pk = $this->model->getPk(); if (is_array($adminIds)) {
$adminIds = $this->getDataLimitAdminIds(); $this->model->where($this->dataLimitField, 'in', $adminIds);
if (is_array($adminIds)) { }
$this->model->where($this->dataLimitField, 'in', $adminIds); $list = $this->model->where($pk, 'in', $ids)->select();
}
$list = $this->model->where($pk, 'in', $ids)->select(); $count = 0;
Db::startTrans();
$count = 0; try {
Db::startTrans(); foreach ($list as $k => $v) {
try { $count += $v->delete();
foreach ($list as $item) { }
$count += $item->delete(); Db::commit();
} catch (PDOException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if ($count) {
$this->success();
} else {
$this->error(__('No rows were deleted'));
} }
Db::commit();
} catch (PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
} }
if ($count) { $this->error(__('Parameter %s can not be empty', 'ids'));
$this->success();
}
$this->error(__('No rows were deleted'));
} }
/** /**
* 真实删除 * 真实删除
*
* @param $ids
* @return void
*/ */
public function destroy($ids = null) public function destroy($ids = "")
{ {
if (false === $this->request->isPost()) { if (!$this->request->isPost()) {
$this->error(__("Invalid parameters")); $this->error(__("Invalid parameters"));
} }
$ids = $ids ?: $this->request->post('ids'); $ids = $ids ? $ids : $this->request->post("ids");
$pk = $this->model->getPk(); $pk = $this->model->getPk();
$adminIds = $this->getDataLimitAdminIds(); $adminIds = $this->getDataLimitAdminIds();
if (is_array($adminIds)) { if (is_array($adminIds)) {
@ -243,32 +244,34 @@ trait Backend
Db::startTrans(); Db::startTrans();
try { try {
$list = $this->model->onlyTrashed()->select(); $list = $this->model->onlyTrashed()->select();
foreach ($list as $item) { foreach ($list as $k => $v) {
$count += $item->delete(true); $count += $v->delete(true);
} }
Db::commit(); Db::commit();
} catch (PDOException|Exception $e) { } catch (PDOException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (Exception $e) {
Db::rollback(); Db::rollback();
$this->error($e->getMessage()); $this->error($e->getMessage());
} }
if ($count) { if ($count) {
$this->success(); $this->success();
} else {
$this->error(__('No rows were deleted'));
} }
$this->error(__('No rows were deleted')); $this->error(__('Parameter %s can not be empty', 'ids'));
} }
/** /**
* 还原 * 还原
*
* @param $ids
* @return void
*/ */
public function restore($ids = null) public function restore($ids = "")
{ {
if (false === $this->request->isPost()) { if (!$this->request->isPost()) {
$this->error(__('Invalid parameters')); $this->error(__("Invalid parameters"));
} }
$ids = $ids ?: $this->request->post('ids'); $ids = $ids ? $ids : $this->request->post("ids");
$pk = $this->model->getPk(); $pk = $this->model->getPk();
$adminIds = $this->getDataLimitAdminIds(); $adminIds = $this->getDataLimitAdminIds();
if (is_array($adminIds)) { if (is_array($adminIds)) {
@ -281,11 +284,14 @@ trait Backend
Db::startTrans(); Db::startTrans();
try { try {
$list = $this->model->onlyTrashed()->select(); $list = $this->model->onlyTrashed()->select();
foreach ($list as $item) { foreach ($list as $index => $item) {
$count += $item->restore(); $count += $item->restore();
} }
Db::commit(); Db::commit();
} catch (PDOException|Exception $e) { } catch (PDOException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (Exception $e) {
Db::rollback(); Db::rollback();
$this->error($e->getMessage()); $this->error($e->getMessage());
} }
@ -297,56 +303,52 @@ trait Backend
/** /**
* 批量更新 * 批量更新
*
* @param $ids
* @return void
*/ */
public function multi($ids = null) public function multi($ids = "")
{ {
if (false === $this->request->isPost()) { if (!$this->request->isPost()) {
$this->error(__('Invalid parameters')); $this->error(__("Invalid parameters"));
} }
$ids = $ids ?: $this->request->post('ids'); $ids = $ids ? $ids : $this->request->post("ids");
if (empty($ids)) { if ($ids) {
$this->error(__('Parameter %s can not be empty', 'ids')); if ($this->request->has('params')) {
} parse_str($this->request->post("params"), $values);
$values = $this->auth->isSuperAdmin() ? $values : array_intersect_key($values, array_flip(is_array($this->multiFields) ? $this->multiFields : explode(',', $this->multiFields)));
if (false === $this->request->has('params')) { if ($values) {
$this->error(__('No rows were updated')); $adminIds = $this->getDataLimitAdminIds();
} if (is_array($adminIds)) {
parse_str($this->request->post('params'), $values); $this->model->where($this->dataLimitField, 'in', $adminIds);
$values = $this->auth->isSuperAdmin() ? $values : array_intersect_key($values, array_flip(is_array($this->multiFields) ? $this->multiFields : explode(',', $this->multiFields))); }
if (empty($values)) { $count = 0;
$this->error(__('You have no permission')); Db::startTrans();
} try {
$adminIds = $this->getDataLimitAdminIds(); $list = $this->model->where($this->model->getPk(), 'in', $ids)->select();
if (is_array($adminIds)) { foreach ($list as $index => $item) {
$this->model->where($this->dataLimitField, 'in', $adminIds); $count += $item->allowField(true)->isUpdate(true)->save($values);
} }
$count = 0; Db::commit();
Db::startTrans(); } catch (PDOException $e) {
try { Db::rollback();
$list = $this->model->where($this->model->getPk(), 'in', $ids)->select(); $this->error($e->getMessage());
foreach ($list as $item) { } catch (Exception $e) {
$count += $item->allowField(true)->isUpdate(true)->save($values); Db::rollback();
$this->error($e->getMessage());
}
if ($count) {
$this->success();
} else {
$this->error(__('No rows were updated'));
}
} else {
$this->error(__('You have no permission'));
}
} }
Db::commit();
} catch (PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
} }
if ($count) { $this->error(__('Parameter %s can not be empty', 'ids'));
$this->success();
}
$this->error(__('No rows were updated'));
} }
/** /**
* 导入 * 导入
*
* @return void
* @throws PDOException
* @throws BindParamException
*/ */
protected function import() protected function import()
{ {
@ -366,12 +368,12 @@ trait Backend
if ($ext === 'csv') { if ($ext === 'csv') {
$file = fopen($filePath, 'r'); $file = fopen($filePath, 'r');
$filePath = tempnam(sys_get_temp_dir(), 'import_csv'); $filePath = tempnam(sys_get_temp_dir(), 'import_csv');
$fp = fopen($filePath, 'w'); $fp = fopen($filePath, "w");
$n = 0; $n = 0;
while ($line = fgets($file)) { while ($line = fgets($file)) {
$line = rtrim($line, "\n\r\0"); $line = rtrim($line, "\n\r\0");
$encoding = mb_detect_encoding($line, ['utf-8', 'gbk', 'latin1', 'big5']); $encoding = mb_detect_encoding($line, ['utf-8', 'gbk', 'latin1', 'big5']);
if ($encoding !== 'utf-8') { if ($encoding != 'utf-8') {
$line = mb_convert_encoding($line, 'utf-8', $encoding); $line = mb_convert_encoding($line, 'utf-8', $encoding);
} }
if ($n == 0 || preg_match('/^".*"$/', $line)) { if ($n == 0 || preg_match('/^".*"$/', $line)) {
@ -399,7 +401,6 @@ trait Backend
$list = db()->query("SELECT COLUMN_NAME,COLUMN_COMMENT FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = ? AND TABLE_SCHEMA = ?", [$table, $database]); $list = db()->query("SELECT COLUMN_NAME,COLUMN_COMMENT FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = ? AND TABLE_SCHEMA = ?", [$table, $database]);
foreach ($list as $k => $v) { foreach ($list as $k => $v) {
if ($importHeadType == 'comment') { if ($importHeadType == 'comment') {
$v['COLUMN_COMMENT'] = explode(':', $v['COLUMN_COMMENT'])[0]; //字段备注有:时截取
$fieldArr[$v['COLUMN_COMMENT']] = $v['COLUMN_NAME']; $fieldArr[$v['COLUMN_COMMENT']] = $v['COLUMN_NAME'];
} else { } else {
$fieldArr[$v['COLUMN_NAME']] = $v['COLUMN_NAME']; $fieldArr[$v['COLUMN_NAME']] = $v['COLUMN_NAME'];
@ -460,7 +461,7 @@ trait Backend
if ($has_admin_id) { if ($has_admin_id) {
$auth = Auth::instance(); $auth = Auth::instance();
foreach ($insert as &$val) { foreach ($insert as &$val) {
if (empty($val['admin_id'])) { if (!isset($val['admin_id']) || empty($val['admin_id'])) {
$val['admin_id'] = $auth->isLogin() ? $auth->id : 0; $val['admin_id'] = $auth->isLogin() ? $auth->id : 0;
} }
} }

View File

@ -13,20 +13,22 @@ class Admin extends Model
// 定义时间戳字段名 // 定义时间戳字段名
protected $createTime = 'createtime'; protected $createTime = 'createtime';
protected $updateTime = 'updatetime'; protected $updateTime = 'updatetime';
protected $hidden = [
'password',
'salt'
];
public static function init() /**
* 重置用户密码
* @author baiyouwen
*/
public function resetPassword($uid, $NewPassword)
{ {
self::beforeWrite(function ($row) { $passwd = $this->encryptPassword($NewPassword);
$changed = $row->getChangedData(); $ret = $this->where(['id' => $uid])->update(['password' => $passwd]);
//如果修改了用户或或密码则需要重新登录 return $ret;
if (isset($changed['username']) || isset($changed['password']) || isset($changed['salt'])) { }
$row->token = '';
} // 密码加密
}); protected function encryptPassword($password, $salt = '', $encrypt = 'md5')
{
return $encrypt($password . $salt);
} }
} }

View File

@ -41,8 +41,8 @@ class AdminLog extends Model
/** /**
* 记录日志 * 记录日志
* @param string $title 日志标题 * @param string $title
* @param string $content 日志内容 * @param string $content
*/ */
public static function record($title = '', $content = '') public static function record($title = '', $content = '')
{ {
@ -50,9 +50,6 @@ class AdminLog extends Model
$admin_id = $auth->isLogin() ? $auth->id : 0; $admin_id = $auth->isLogin() ? $auth->id : 0;
$username = $auth->isLogin() ? $auth->username : __('Unknown'); $username = $auth->isLogin() ? $auth->username : __('Unknown');
// 设置过滤函数
request()->filter('trim,strip_tags,htmlspecialchars');
$controllername = Loader::parseName(request()->controller()); $controllername = Loader::parseName(request()->controller());
$actionname = strtolower(request()->action()); $actionname = strtolower(request()->action());
$path = str_replace('.', '/', $controllername) . '/' . $actionname; $path = str_replace('.', '/', $controllername) . '/' . $actionname;
@ -63,12 +60,12 @@ class AdminLog extends Model
} }
} }
} }
$content = $content ?: self::$content; $content = $content ? $content : self::$content;
if (!$content) { if (!$content) {
$content = request()->param('') ?: file_get_contents("php://input"); $content = request()->param('', null, 'trim,strip_tags,htmlspecialchars');
$content = self::getPureContent($content); $content = self::getPureContent($content);
} }
$title = $title ?: self::$title; $title = $title ? $title : self::$title;
if (!$title) { if (!$title) {
$title = []; $title = [];
$breadcrumb = Auth::instance()->getBreadcrumb($path); $breadcrumb = Auth::instance()->getBreadcrumb($path);
@ -80,18 +77,18 @@ class AdminLog extends Model
self::create([ self::create([
'title' => $title, 'title' => $title,
'content' => !is_scalar($content) ? json_encode($content, JSON_UNESCAPED_UNICODE) : $content, 'content' => !is_scalar($content) ? json_encode($content, JSON_UNESCAPED_UNICODE) : $content,
'url' => substr(xss_clean(strip_tags(request()->url())), 0, 1500), 'url' => substr(request()->url(), 0, 1500),
'admin_id' => $admin_id, 'admin_id' => $admin_id,
'username' => $username, 'username' => $username,
'useragent' => substr(request()->server('HTTP_USER_AGENT'), 0, 255), 'useragent' => substr(request()->server('HTTP_USER_AGENT'), 0, 255),
'ip' => xss_clean(strip_tags(request()->ip())) 'ip' => request()->ip()
]); ]);
} }
/** /**
* 获取已屏蔽关键信息的数据 * 获取已屏蔽关键信息的数据
* @param $content * @param $content
* @return array * @return false|string
*/ */
protected static function getPureContent($content) protected static function getPureContent($content)
{ {

View File

@ -28,7 +28,7 @@ class UserGroup extends Model
{ {
$value = $value ? $value : $data['status']; $value = $value ? $value : $data['status'];
$list = $this->getStatusList(); $list = $this->getStatusList();
return $list[$value] ?? ''; return isset($list[$value]) ? $list[$value] : '';
} }
} }

View File

@ -23,18 +23,11 @@ class UserRule extends Model
protected static function init() protected static function init()
{ {
self::afterInsert(function ($row) { self::afterInsert(function ($row) {
if (!$row['weigh']) { $pk = $row->getPk();
$pk = $row->getPk(); $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]);
$row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]);
}
}); });
} }
public function getTitleAttr($value, $data)
{
return __($value);
}
public function getStatusList() public function getStatusList()
{ {
return ['normal' => __('Normal'), 'hidden' => __('Hidden')]; return ['normal' => __('Normal'), 'hidden' => __('Hidden')];
@ -44,7 +37,7 @@ class UserRule extends Model
{ {
$value = $value ? $value : $data['status']; $value = $value ? $value : $data['status'];
$list = $this->getStatusList(); $list = $this->getStatusList();
return $list[$value] ?? ''; return isset($list[$value]) ? $list[$value] : '';
} }
public static function getTreeList($selected = []) public static function getTreeList($selected = [])

View File

@ -15,7 +15,6 @@ class Admin extends Validate
'nickname' => 'require', 'nickname' => 'require',
'password' => 'require|regex:\S{32}', 'password' => 'require|regex:\S{32}',
'email' => 'require|email|unique:admin,email', 'email' => 'require|email|unique:admin,email',
'mobile' => 'regex:1[3-9]\d{9}|unique:admin,mobile',
]; ];
/** /**
@ -34,8 +33,8 @@ class Admin extends Validate
* 验证场景 * 验证场景
*/ */
protected $scene = [ protected $scene = [
'add' => ['username', 'email', 'nickname', 'password', 'mobile'], 'add' => ['username', 'email', 'nickname', 'password'],
'edit' => ['username', 'email', 'nickname', 'password', 'mobile'], 'edit' => ['username', 'email', 'nickname', 'password'],
]; ];
public function __construct(array $rules = [], $message = [], $field = []) public function __construct(array $rules = [], $message = [], $field = [])
@ -45,7 +44,6 @@ class Admin extends Validate
'nickname' => __('Nickname'), 'nickname' => __('Nickname'),
'password' => __('Password'), 'password' => __('Password'),
'email' => __('Email'), 'email' => __('Email'),
'mobile' => __('Mobile'),
]; ];
$this->message = array_merge($this->message, [ $this->message = array_merge($this->message, [
'username.regex' => __('Please input correct username'), 'username.regex' => __('Please input correct username'),

View File

@ -1,142 +1,118 @@
<form id="config-form" class="edit-form form-horizontal" role="form" data-toggle="validator" method="POST" action=""> <form id="config-form" class="edit-form form-horizontal" role="form" data-toggle="validator" method="POST" action="">
{if $addon.tips && $addon.tips.value} {if $addon.tips}
<div class="alert {$addon.tips.extend|default='alert-info-light'}" style="margin-bottom:10px;"> <div class="alert {$addon.tips.extend|default='alert-info-light'}" style="margin-bottom:10px;">
{if $addon.tips.title}
<b>{$addon.tips.title}</b><br> <b>{$addon.tips.title}</b><br>
{/if}
{$addon.tips.value} {$addon.tips.value}
</div> </div>
{/if} {/if}
<table class="table table-striped">
<div class="panel panel-default panel-intro"> <thead>
{if count($groupList)>1} <tr>
<div class="panel-heading mb-3"> <th width="15%">{:__('Title')}</th>
<ul class="nav nav-tabs nav-group"> <th width="85%">{:__('Value')}</th>
<li class="active"><a href="#all" data-toggle="tab">全部</a></li> </tr>
{foreach name="groupList" id="tab"} </thead>
<li><a href="#tab-{$key}" title="{$tab}" data-toggle="tab">{$tab}</a></li> <tbody>
{/foreach} {foreach $addon.config as $item}
</ul> <tr>
</div> <td>{$item.title}</td>
{/if} <td>
<div class="row">
<div class="panel-body no-padding"> <div class="col-sm-8 col-xs-12">
<div id="myTabContent" class="tab-content"> {switch $item.type}
{foreach name="groupList" id="group" key="groupName"} {case string}
<div class="tab-pane fade active in" id="tab-{$groupName}"> <input {$item.extend} type="text" name="row[{$item.name}]" value="{$item.value|htmlentities}" class="form-control" data-rule="{$item.rule}" data-tip="{$item.tip}"/>
{/case}
<table class="table table-striped table-config mb-0"> {case password}
<tbody> <input {$item.extend} type="password" name="row[{$item.name}]" value="{$item.value|htmlentities}" class="form-control" data-rule="{$item.rule}" data-tip="{$item.tip}"/>
{foreach name="$addon.config" id="item"} {/case}
{if ((!isset($item['group']) || $item['group']=='') && $groupName=='other') || (isset($item['group']) && $item['group']==$group)} {case text}
<tr data-favisible="{$item.visible|default=''|htmlentities}" data-name="{$item.name}" class="{if $item.visible??''}hidden{/if}"> <textarea {$item.extend} name="row[{$item.name}]" class="form-control" data-rule="{$item.rule}" rows="5" data-tip="{$item.tip}">{$item.value|htmlentities}</textarea>
<td width="15%">{$item.title}</td> {/case}
<td> {case array}
<div class="row"> <dl class="fieldlist" data-name="row[{$item.name}]">
<div class="col-sm-8 col-xs-12"> <dd>
{switch $item.type} <ins>{:__('Array key')}</ins>
{case string} <ins>{:__('Array value')}</ins>
<input {$item.extend} type="text" name="row[{$item.name}]" value="{$item.value|htmlentities}" class="form-control" data-rule="{$item.rule}" data-tip="{$item.tip}"/> </dd>
{/case} <dd><a href="javascript:;" class="btn btn-sm btn-success btn-append"><i class="fa fa-plus"></i> {:__('Append')}</a></dd>
{case password} <textarea name="row[{$item.name}]" cols="30" rows="5" class="hide">{$item.value|json_encode|htmlentities}</textarea>
<input {$item.extend} type="password" name="row[{$item.name}]" value="{$item.value|htmlentities}" class="form-control" data-rule="{$item.rule}" data-tip="{$item.tip}"/> </dl>
{/case} {/case}
{case text} {case date}
<textarea {$item.extend} name="row[{$item.name}]" class="form-control" data-rule="{$item.rule}" rows="5" data-tip="{$item.tip}">{$item.value|htmlentities}</textarea> <input {$item.extend} type="text" name="row[{$item.name}]" value="{$item.value|htmlentities}" class="form-control datetimepicker" data-date-format="YYYY-MM-DD" data-tip="{$item.tip}" data-rule="{$item.rule}"/>
{/case} {/case}
{case array} {case time}
<dl class="fieldlist" data-name="row[{$item.name}]"> <input {$item.extend} type="text" name="row[{$item.name}]" value="{$item.value|htmlentities}" class="form-control datetimepicker" data-date-format="HH:mm:ss" data-tip="{$item.tip}" data-rule="{$item.rule}"/>
<dd> {/case}
<ins>{:__('Array key')}</ins> {case datetime}
<ins>{:__('Array value')}</ins> <input {$item.extend} type="text" name="row[{$item.name}]" value="{$item.value|htmlentities}" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-tip="{$item.tip}" data-rule="{$item.rule}"/>
</dd> {/case}
<dd><a href="javascript:;" class="btn btn-sm btn-success btn-append"><i class="fa fa-plus"></i> {:__('Append')}</a></dd> {case number}
<textarea name="row[{$item.name}]" cols="30" rows="5" class="hide">{$item.value|json_encode|htmlentities}</textarea> <input {$item.extend} type="number" name="row[{$item.name}]" value="{$item.value|htmlentities}" class="form-control" data-tip="{$item.tip}" data-rule="{$item.rule}"/>
</dl> {/case}
{/case} {case checkbox}
{case date} {foreach name="item.content" item="vo"}
<input {$item.extend} type="text" name="row[{$item.name}]" value="{$item.value|htmlentities}" class="form-control datetimepicker" data-date-format="YYYY-MM-DD" data-tip="{$item.tip}" data-rule="{$item.rule}"/> <label for="row[{$item.name}][]-{$key}"><input id="row[{$item.name}][]-{$key}" name="row[{$item.name}][]" type="checkbox" value="{$key}" data-tip="{$item.tip}" {in name="key" value="$item.value" }checked{/in} /> {$vo}</label>
{/case}
{case time}
<input {$item.extend} type="text" name="row[{$item.name}]" value="{$item.value|htmlentities}" class="form-control datetimepicker" data-date-format="HH:mm:ss" data-tip="{$item.tip}" data-rule="{$item.rule}"/>
{/case}
{case datetime}
<input {$item.extend} type="text" name="row[{$item.name}]" value="{$item.value|htmlentities}" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-tip="{$item.tip}" data-rule="{$item.rule}"/>
{/case}
{case number}
<input {$item.extend} type="number" name="row[{$item.name}]" value="{$item.value|htmlentities}" class="form-control" data-tip="{$item.tip}" data-rule="{$item.rule}"/>
{/case}
{case checkbox}
{foreach name="item.content" item="vo"}
<label for="row[{$item.name}][]-{$key}"><input id="row[{$item.name}][]-{$key}" name="row[{$item.name}][]" type="checkbox" value="{$key}" data-tip="{$item.tip}" {in name="key" value="$item.value" }checked{/in} /> {$vo}</label>
{/foreach}
<span class="msg-box n-right" for="row[{$item.name}]"></span>
{/case}
{case radio}
{foreach name="item.content" item="vo"}
<label for="row[{$item.name}]-{$key}"><input id="row[{$item.name}]-{$key}" name="row[{$item.name}]" type="radio" value="{$key}" data-tip="{$item.tip}" {in name="key" value="$item.value" }checked{/in} /> {$vo}</label>
{/foreach}
<span class="msg-box n-right" for="row[{$item.name}]"></span>
{/case}
{case value="select" break="0"}{/case}
{case value="selects"}
<select {$item.extend} name="row[{$item.name}]{$item.type=='selects'?'[]':''}" class="form-control selectpicker" data-tip="{$item.tip}" {$item.type=='selects'?'multiple':''}>
{foreach name="item.content" item="vo"}
<option value="{$key}" {in name="key" value="$item.value" }selected{/in}>{$vo}</option>
{/foreach}
</select>
{/case}
{case value="image" break="0"}{/case}
{case value="images"}
<div class="form-inline">
<input id="c-{$item.name}" class="form-control" size="28" name="row[{$item.name}]" type="text" value="{$item.value|htmlentities}" data-tip="{$item.tip}">
<span><button type="button" id="plupload-{$item.name}" class="btn btn-danger plupload" data-input-id="c-{$item.name}" data-mimetype="image/*" data-multiple="{$item.type=='image'?'false':'true'}" data-preview-id="p-{$item.name}"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-{$item.name}" class="btn btn-primary fachoose" data-input-id="c-{$item.name}" data-mimetype="image/*" data-multiple="{$item.type=='image'?'false':'true'}"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
<ul class="row list-inline plupload-preview" id="p-{$item.name}"></ul>
<span class="msg-box n-right" for="c-{$item.name}"></span>
</div>
{/case}
{case value="file" break="0"}{/case}
{case value="files"}
<div class="form-inline">
<input id="c-{$item.name}" class="form-control" size="28" name="row[{$item.name}]" type="text" value="{$item.value|htmlentities}" data-tip="{$item.tip}">
<span><button type="button" id="plupload-{$item.name}" class="btn btn-danger plupload" data-input-id="c-{$item.name}" data-multiple="{$item.type=='file'?'false':'true'}"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-{$item.name}" class="btn btn-primary fachoose" data-input-id="c-{$item.name}" data-multiple="{$item.type=='file'?'false':'true'}"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
<span class="msg-box n-right" for="c-{$item.name}"></span>
</div>
{/case}
{case switch}
<input id="c-{$item.name}" name="row[{$item.name}]" type="hidden" value="{:$item.value?1:0}">
<a href="javascript:;" data-toggle="switcher" class="btn-switcher" data-input-id="c-{$item.name}" data-yes="1" data-no="0">
<i class="fa fa-toggle-on text-success {if !$item.value}fa-flip-horizontal text-gray{/if} fa-2x"></i>
</a>
{/case}
{case bool}
<label for="row[{$item.name}]-yes"><input id="row[{$item.name}]-yes" name="row[{$item.name}]" type="radio" value="1" {$item.value?'checked':''} data-tip="{$item.tip}" /> {:__('Yes')}</label>
<label for="row[{$item.name}]-no"><input id="row[{$item.name}]-no" name="row[{$item.name}]" type="radio" value="0" {$item.value?'':'checked'} data-tip="{$item.tip}" /> {:__('No')}</label>
{/case}
{default /}{$item.value}
{/switch}
</div>
<div class="col-sm-4"></div>
</div>
</td>
</tr>
{/if}
{/foreach} {/foreach}
</tbody> {/case}
</table> {case radio}
</div> {foreach name="item.content" item="vo"}
{/foreach} <label for="row[{$item.name}]-{$key}"><input id="row[{$item.name}]-{$key}" name="row[{$item.name}]" type="radio" value="{$key}" data-tip="{$item.tip}" {in name="key" value="$item.value" }checked{/in} /> {$vo}</label>
<div class="form-group layer-footer"> {/foreach}
<label class="control-label col-xs-12 col-sm-2" style="width:15%;"></label> {/case}
<div class="col-xs-12 col-sm-8"> {case value="select" break="0"}{/case}
<button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button> {case value="selects"}
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button> <select {$item.extend} name="row[{$item.name}]{$item.type=='selects'?'[]':''}" class="form-control selectpicker" data-tip="{$item.tip}" {$item.type=='selects'?'multiple':''}>
{foreach name="item.content" item="vo"}
<option value="{$key}" {in name="key" value="$item.value" }selected{/in}>{$vo}</option>
{/foreach}
</select>
{/case}
{case value="image" break="0"}{/case}
{case value="images"}
<div class="input-group">
<input {$item.extend} id="c-{$item.name}" class="form-control" size="50" name="row[{$item.name}]" type="text" value="{$item.value|htmlentities}" data-tip="{$item.tip}" data-rule="{$item.rule}">
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="faupload-{$item.name}" class="btn btn-danger faupload" data-input-id="c-{$item.name}" data-mimetype="image/*" data-multiple="{$item.type=='image'?'false':'true'}" data-preview-id="p-{$item.name}"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-{$item.name}" class="btn btn-primary fachoose" data-input-id="c-{$item.name}" data-mimetype="image/*" data-multiple="{$item.type=='image'?'false':'true'}"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
</div>
<span class="msg-box n-right" for="c-{$item.name}"></span>
</div>
<ul class="row list-inline faupload-preview" id="p-{$item.name}"></ul>
{/case}
{case value="file" break="0"}{/case}
{case value="files"}
<div class="input-group">
<input {$item.extend} id="c-{$item.name}" class="form-control" size="50" name="row[{$item.name}]" type="text" value="{$item.value|htmlentities}" data-tip="{$item.tip}" data-rule="{$item.rule}">
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="faupload-{$item.name}" class="btn btn-danger faupload" data-input-id="c-{$item.name}" data-multiple="{$item.type=='file'?'false':'true'}" data-preview-id="p-{$item.name}"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-{$item.name}" class="btn btn-primary fachoose" data-input-id="c-{$item.name}" data-multiple="{$item.type=='file'?'false':'true'}"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
</div>
<span class="msg-box n-right" for="c-{$item.name}"></span>
</div>
<ul class="row list-inline faupload-preview" id="p-{$item.name}"></ul>
{/case}
{case bool}
<label for="row[{$item.name}]-yes"><input id="row[{$item.name}]-yes" name="row[{$item.name}]" type="radio" value="1" {$item.value?'checked':''} data-tip="{$item.tip}" /> {:__('Yes')}</label>
<label for="row[{$item.name}]-no"><input id="row[{$item.name}]-no" name="row[{$item.name}]" type="radio" value="0" {$item.value?'':'checked'} data-tip="{$item.tip}" /> {:__('No')}</label>
{/case}
{default /}{$item.value}
{/switch}
</div> </div>
<div class="col-sm-4"></div>
</div> </div>
</div>
</td>
</tr>
{/foreach}
</tbody>
</table>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div> </div>
</div> </div>
</form> </form>

View File

@ -62,10 +62,6 @@
padding: 0; padding: 0;
} }
.operate .dropup .dropdown-menu, .navbar-fixed-bottom .dropdown .dropdown-menu {
bottom: inherit;
}
</style> </style>
<div class="panel panel-default panel-intro"> <div class="panel panel-default panel-intro">
<div class="panel-heading"> <div class="panel-heading">
@ -156,22 +152,60 @@
</div> </div>
</form> </form>
</script> </script>
<script id="logintpl" type="text/html">
<div>
<form class="form-horizontal">
<fieldset>
<div class="alert alert-dismissable alert-danger">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>{:__('Warning')}</strong><br/>{:__('Login tips')}
</div>
<div class="form-group">
<div class="col-lg-12">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-user"></i></span>
<input type="text" class="form-control" id="inputAccount" value=""
placeholder="{:__('Your username or email')}">
</div>
</div>
</div>
<div class="form-group">
<div class="col-lg-12">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-lock"></i></span>
<input type="password" class="form-control" id="inputPassword" value=""
placeholder="{:__('Your password')}">
</div>
</div>
</div>
</fieldset>
</form>
</div>
</script>
<script id="userinfotpl" type="text/html">
<div>
<form class="form-horizontal form-userinfo">
<fieldset>
<div class="alert alert-dismissable alert-info-light">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>{:__('Warning')}</strong><br/>{:__('Logined tips', '<%=username%>')}
</div>
</fieldset>
<div class="breadcrumb"><a href="https://www.fastadmin.net/user/myaddon.html" target="_blank"><i class="fa fa-cube"></i> {:__('My addons')}</a></div>
</form>
</div>
</script>
<script id="uninstalltpl" type="text/html"> <script id="uninstalltpl" type="text/html">
<div class=""> <div class="">
<div class=""><%=#__("Are you sure you want to unstall %s?", addon['title'])%> <div class=""><%=#__("Are you sure you want to unstall %s?", addon['title'])%>
<p class="text-danger">{:__('Delete all the addon file and cannot be recovered!')} </p> <p class="text-danger">{:__('Delete all the addon file and cannot be recovered!')} </p>
{if config('app_debug')} {if config('app_debug')}
<p class="text-danger"><input type="checkbox" name="droptables" id="droptables" data-name="<%=addon['name']%>"/> {:__('Delete all the addon database and cannot be recovered!')} </p> <p class="text-danger"><input type="checkbox" name="droptables" id="droptables" data-name="<%=addon['name']%>"/> {:__('Delete all the addon database and cannot be recovered!')} </p>
{/if} {/if}
<p class="text-danger">{:__('Please backup important data manually before uninstall!')}</p> <p class="text-danger">{:__('Please backup important data manually before uninstall!')}</p>
</div> </div>
</div> </div>
</script> </script>
<script id="upgradetpl" type="text/html">
<div class="">
<div class=""><%=#__("Upgrade tips", addon['title'])%></div>
</div>
</script>
<script id="conflicttpl" type="text/html"> <script id="conflicttpl" type="text/html">
<div class="alert alert-dismissable alert-danger"> <div class="alert alert-dismissable alert-danger">
<button type="button" class="close" data-dismiss="alert">×</button> <button type="button" class="close" data-dismiss="alert">×</button>
@ -205,7 +239,7 @@
<% if(typeof item.releaselist !="undefined" && item.releaselist.length>1){%> <% if(typeof item.releaselist !="undefined" && item.releaselist.length>1){%>
<span class="btn-group"> <span class="btn-group">
<a href="javascript:;" class="btn btn-xs btn-primary btn-success btn-install" <a href="javascript:;" class="btn btn-xs btn-primary btn-success btn-install"
data-type="<%=item.price<=0?'free':'price';%>" data-type="<%=item.price<=0?'free':'price';%>" data-donateimage="<%=item.donateimage%>"
data-version="<%=item.version%>"><i class="fa fa-cloud-download"></i> {:__('Install')}</a> data-version="<%=item.version%>"><i class="fa fa-cloud-download"></i> {:__('Install')}</a>
<a class="btn btn-xs btn-success dropdown-toggle" data-toggle="dropdown" href="javascript:;"> <a class="btn btn-xs btn-success dropdown-toggle" data-toggle="dropdown" href="javascript:;">
<span class="fa fa-caret-down"></span> <span class="fa fa-caret-down"></span>
@ -213,13 +247,14 @@
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<% for(var j=0;j< item.releaselist.length;j++){ %> <% for(var j=0;j< item.releaselist.length;j++){ %>
<li><a href="javascript:;" class="btn-install" data-type="<%=item.price<=0?'free':'price';%>" <li><a href="javascript:;" class="btn-install" data-type="<%=item.price<=0?'free':'price';%>"
data-donateimage="<%=item.donateimage%>"
data-version="<%=item.releaselist[j].version%>"><%=item.releaselist[j].version%></a></li> data-version="<%=item.releaselist[j].version%>"><%=item.releaselist[j].version%></a></li>
<% } %> <% } %>
</ul> </ul>
</span> </span>
<% }else if(typeof item.releaselist !="undefined" && item.releaselist.length>0){%> <% }else if(typeof item.releaselist !="undefined" && item.releaselist.length>0){%>
<a href="javascript:;" class="btn btn-xs btn-primary btn-success btn-install" <a href="javascript:;" class="btn btn-xs btn-primary btn-success btn-install"
data-type="<%=item.price<=0?'free':'price';%>" data-type="<%=item.price<=0?'free':'price';%>" data-donateimage="<%=item.donateimage%>"
data-version="<%=item.version%>"><i class="fa fa-cloud-download"></i> {:__('Install')}</a> data-version="<%=item.version%>"><i class="fa fa-cloud-download"></i> {:__('Install')}</a>
<% } %> <% } %>

View File

@ -18,12 +18,6 @@
<input type="email" class="form-control" id="email" name="row[email]" value="" data-rule="required;email" /> <input type="email" class="form-control" id="email" name="row[email]" value="" data-rule="required;email" />
</div> </div>
</div> </div>
<div class="form-group">
<label for="mobile" class="control-label col-xs-12 col-sm-2">{:__('Mobile')}:</label>
<div class="col-xs-12 col-sm-8">
<input type="text" class="form-control" id="mobile" name="row[mobile]" value="" data-rule="mobile" />
</div>
</div>
<div class="form-group"> <div class="form-group">
<label for="nickname" class="control-label col-xs-12 col-sm-2">{:__('Nickname')}:</label> <label for="nickname" class="control-label col-xs-12 col-sm-2">{:__('Nickname')}:</label>
<div class="col-xs-12 col-sm-8"> <div class="col-xs-12 col-sm-8">

View File

@ -18,12 +18,6 @@
<input type="email" class="form-control" id="email" name="row[email]" value="{$row.email|htmlentities}" data-rule="required;email" /> <input type="email" class="form-control" id="email" name="row[email]" value="{$row.email|htmlentities}" data-rule="required;email" />
</div> </div>
</div> </div>
<div class="form-group">
<label for="mobile" class="control-label col-xs-12 col-sm-2">{:__('Mobile')}:</label>
<div class="col-xs-12 col-sm-8">
<input type="text" class="form-control" id="mobile" name="row[mobile]" value="{$row.mobile|default=''|htmlentities}" data-rule="mobile" />
</div>
</div>
<div class="form-group"> <div class="form-group">
<label for="nickname" class="control-label col-xs-12 col-sm-2">{:__('Nickname')}:</label> <label for="nickname" class="control-label col-xs-12 col-sm-2">{:__('Nickname')}:</label>
<div class="col-xs-12 col-sm-8"> <div class="col-xs-12 col-sm-8">
@ -39,7 +33,7 @@
<div class="form-group"> <div class="form-group">
<label for="loginfailure" class="control-label col-xs-12 col-sm-2">{:__('Loginfailure')}:</label> <label for="loginfailure" class="control-label col-xs-12 col-sm-2">{:__('Loginfailure')}:</label>
<div class="col-xs-12 col-sm-8"> <div class="col-xs-12 col-sm-8">
<input type="number" class="form-control" id="loginfailure" name="row[loginfailure]" value="{$row.loginfailure|htmlentities}" data-rule="required" /> <input type="number" class="form-control" id="loginfailure" name="row[loginfailure]" value="{$row.loginfailure}" data-rule="required" />
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">

View File

@ -8,7 +8,7 @@
<div id="toolbar" class="toolbar"> <div id="toolbar" class="toolbar">
{:build_toolbar('refresh,add,delete')} {:build_toolbar('refresh,add,delete')}
</div> </div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap" <table id="table" class="table table-striped table-bordered table-hover"
data-operate-edit="{:$auth->check('auth/admin/edit')}" data-operate-edit="{:$auth->check('auth/admin/edit')}"
data-operate-del="{:$auth->check('auth/admin/del')}" data-operate-del="{:$auth->check('auth/admin/del')}"
width="100%"> width="100%">

View File

@ -8,7 +8,7 @@
<div id="toolbar" class="toolbar"> <div id="toolbar" class="toolbar">
{:build_toolbar('refresh,delete')} {:build_toolbar('refresh,delete')}
</div> </div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap" <table id="table" class="table table-striped table-bordered table-hover"
data-operate-detail="{:$auth->check('auth/adminlog/index')}" data-operate-detail="{:$auth->check('auth/adminlog/index')}"
data-operate-del="{:$auth->check('auth/adminlog/del')}" data-operate-del="{:$auth->check('auth/adminlog/del')}"
width="100%"> width="100%">

View File

@ -8,7 +8,7 @@
<div id="toolbar" class="toolbar"> <div id="toolbar" class="toolbar">
{:build_toolbar('refresh,add,delete')} {:build_toolbar('refresh,add,delete')}
</div> </div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap" <table id="table" class="table table-striped table-bordered table-hover"
data-operate-edit="{:$auth->check('auth/group/edit')}" data-operate-edit="{:$auth->check('auth/group/edit')}"
data-operate-del="{:$auth->check('auth/group/del')}" data-operate-del="{:$auth->check('auth/group/del')}"
width="100%"> width="100%">

View File

@ -34,8 +34,8 @@
<label for="icon" class="control-label col-xs-12 col-sm-2">{:__('Icon')}:</label> <label for="icon" class="control-label col-xs-12 col-sm-2">{:__('Icon')}:</label>
<div class="col-xs-12 col-sm-8"> <div class="col-xs-12 col-sm-8">
<div class="input-group input-groupp-md"> <div class="input-group input-groupp-md">
<span class="input-group-addon"><i class="{$row.icon|htmlentities}" id="icon-style"></i></span> <span class="input-group-addon"><i class="{$row.icon}" id="icon-style"></i></span>
<input type="text" class="form-control" id="icon" name="row[icon]" value="{$row.icon|htmlentities}" /> <input type="text" class="form-control" id="icon" name="row[icon]" value="{$row.icon}" />
<a href="javascript:;" class="btn-search-icon input-group-addon">{:__('Search icon')}</a> <a href="javascript:;" class="btn-search-icon input-group-addon">{:__('Search icon')}</a>
</div> </div>
</div> </div>
@ -67,7 +67,7 @@
<div class="form-group"> <div class="form-group">
<label for="weigh" class="control-label col-xs-12 col-sm-2">{:__('Weigh')}:</label> <label for="weigh" class="control-label col-xs-12 col-sm-2">{:__('Weigh')}:</label>
<div class="col-xs-12 col-sm-8"> <div class="col-xs-12 col-sm-8">
<input type="text" class="form-control" id="weigh" name="row[weigh]" value="{$row.weigh|htmlentities}" data-rule="required" /> <input type="text" class="form-control" id="weigh" name="row[weigh]" value="{$row.weigh}" data-rule="required" />
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">

View File

@ -52,7 +52,7 @@
<label for="c-image" class="control-label col-xs-12 col-sm-2">{:__('Image')}:</label> <label for="c-image" class="control-label col-xs-12 col-sm-2">{:__('Image')}:</label>
<div class="col-xs-12 col-sm-8"> <div class="col-xs-12 col-sm-8">
<div class="input-group"> <div class="input-group">
<input id="c-image" class="form-control" size="35" name="row[image]" type="text" value="{$row.image|htmlentities}"> <input id="c-image" class="form-control" size="35" name="row[image]" type="text" value="{$row.image}">
<div class="input-group-addon no-border no-padding"> <div class="input-group-addon no-border no-padding">
<span><button type="button" id="faupload-image" class="btn btn-danger faupload" data-input-id="c-image" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-image"><i class="fa fa-upload"></i> {:__('Upload')}</button></span> <span><button type="button" id="faupload-image" class="btn btn-danger faupload" data-input-id="c-image" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-image"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-image" class="btn btn-primary fachoose" data-input-id="c-image" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span> <span><button type="button" id="fachoose-image" class="btn btn-primary fachoose" data-input-id="c-image" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
@ -77,7 +77,7 @@
<div class="form-group"> <div class="form-group">
<label for="c-weigh" class="control-label col-xs-12 col-sm-2">{:__('Weigh')}:</label> <label for="c-weigh" class="control-label col-xs-12 col-sm-2">{:__('Weigh')}:</label>
<div class="col-xs-12 col-sm-8"> <div class="col-xs-12 col-sm-8">
<input id="c-weigh" class="form-control" name="row[weigh]" type="number" value="{$row.weigh|htmlentities}"> <input id="c-weigh" class="form-control" name="row[weigh]" type="number" value="{$row.weigh}">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">

View File

@ -23,7 +23,7 @@
</ul> </ul>
</div> </div>
</div> </div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap" <table id="table" class="table table-striped table-bordered table-hover"
data-operate-edit="{:$auth->check('category/edit')}" data-operate-edit="{:$auth->check('category/edit')}"
data-operate-del="{:$auth->check('category/del')}" data-operate-del="{:$auth->check('category/del')}"
width="100%"> width="100%">

View File

@ -30,7 +30,7 @@
</div> </div>
<!-- 左侧菜单栏 --> <!-- 左侧菜单栏 -->
<ul class="sidebar-menu {if $Think.config.fastadmin.show_submenu}show-submenu{/if}"> <ul class="sidebar-menu {if $Think.cookie.show_submenu}show-submenu{/if}">
<!-- 菜单可以在 后台管理->权限管理->菜单规则 中进行增删改排序 --> <!-- 菜单可以在 后台管理->权限管理->菜单规则 中进行增删改排序 -->
{$menulist} {$menulist}

View File

@ -194,8 +194,8 @@
<div class="sm-st clearfix"> <div class="sm-st clearfix">
<span class="sm-st-icon st-blue"><i class="fa fa-leaf"></i></span> <span class="sm-st-icon st-blue"><i class="fa fa-leaf"></i></span>
<div class="sm-st-info"> <div class="sm-st-info">
<span>{$attachmentnums}</span> <span>{$totalcategory}</span>
{:__('Total attachment')} {:__('Total category')}
</div> </div>
</div> </div>
</div> </div>
@ -293,14 +293,14 @@
<div class="panel-body"> <div class="panel-body">
<div class="panel-title"> <div class="panel-title">
<span class="label label-primary pull-right">{:__('Real time')}</span> <span class="label label-primary pull-right">{:__('Real time')}</span>
<h5>{:__('Working addon count')}</h5> <h5>{:__('Category count')}</h5>
</div> </div>
<div class="panel-content"> <div class="panel-content">
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<h1 class="no-margins">{$totalworkingaddon}</h1> <h1 class="no-margins">{$totalcategory}</h1>
<div class="font-bold"><i class="fa fa-magic"></i> <div class="font-bold"><i class="fa fa-magic"></i>
<small>{:__('Working addon count tips')}</small> <small>{:__('Category count tips')}</small>
</div> </div>
</div> </div>
</div> </div>

View File

@ -22,13 +22,13 @@
<div class="form-group"> <div class="form-group">
<label for="c-imagewidth" class="control-label col-xs-12 col-sm-2">{:__('Imagewidth')}:</label> <label for="c-imagewidth" class="control-label col-xs-12 col-sm-2">{:__('Imagewidth')}:</label>
<div class="col-xs-12 col-sm-8"> <div class="col-xs-12 col-sm-8">
<input type="text" name="row[imagewidth]" value="{$row.imagewidth|htmlentities}" id="c-imagewidth" class="form-control" required /> <input type="text" name="row[imagewidth]" value="{$row.imagewidth}" id="c-imagewidth" class="form-control" required />
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="c-imageheight" class="control-label col-xs-12 col-sm-2">{:__('Imageheight')}:</label> <label for="c-imageheight" class="control-label col-xs-12 col-sm-2">{:__('Imageheight')}:</label>
<div class="col-xs-12 col-sm-8"> <div class="col-xs-12 col-sm-8">
<input type="text" name="row[imageheight]" value="{$row.imageheight|htmlentities}" id="c-imageheight" class="form-control" required /> <input type="text" name="row[imageheight]" value="{$row.imageheight}" id="c-imageheight" class="form-control" required />
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -40,7 +40,7 @@
<div class="form-group"> <div class="form-group">
<label for="c-imageframes" class="control-label col-xs-12 col-sm-2">{:__('Imageframes')}:</label> <label for="c-imageframes" class="control-label col-xs-12 col-sm-2">{:__('Imageframes')}:</label>
<div class="col-xs-12 col-sm-8"> <div class="col-xs-12 col-sm-8">
<input type="number" name="row[imageframes]" value="{$row.imageframes|htmlentities}" id="c-imageframes" class="form-control" /> <input type="number" name="row[imageframes]" value="{$row.imageframes}" id="c-imageframes" class="form-control" />
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -52,7 +52,7 @@
<div class="form-group"> <div class="form-group">
<label for="c-filesize" class="control-label col-xs-12 col-sm-2">{:__('Filesize')}:</label> <label for="c-filesize" class="control-label col-xs-12 col-sm-2">{:__('Filesize')}:</label>
<div class="col-xs-12 col-sm-8"> <div class="col-xs-12 col-sm-8">
<input type="number" name="row[filesize]" value="{$row.filesize|htmlentities}" id="c-filesize" class="form-control" /> <input type="number" name="row[filesize]" value="{$row.filesize}" id="c-filesize" class="form-control" />
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -76,7 +76,7 @@
<div class="form-group"> <div class="form-group">
<label for="c-storage" class="control-label col-xs-12 col-sm-2">{:__('Storage')}:</label> <label for="c-storage" class="control-label col-xs-12 col-sm-2">{:__('Storage')}:</label>
<div class="col-xs-12 col-sm-8"> <div class="col-xs-12 col-sm-8">
<input type="text" name="row[storage]" value="{$row.storage|htmlentities}" id="c-storage" class="form-control" /> <input type="text" name="row[storage]" value="{$row.storage}" id="c-storage" class="form-control" />
</div> </div>
</div> </div>
<div class="form-group hide layer-footer"> <div class="form-group hide layer-footer">

View File

@ -36,7 +36,7 @@
<a class="btn btn-danger btn-choose-multi"><i class="fa fa-check"></i> {:__('Choose')}</a> <a class="btn btn-danger btn-choose-multi"><i class="fa fa-check"></i> {:__('Choose')}</a>
{/if} {/if}
</div> </div>
<table id="table" class="table table-bordered table-hover table-nowrap" width="100%"> <table id="table" class="table table-bordered table-hover" width="100%">
</table> </table>
</div> </div>

View File

@ -21,13 +21,22 @@
visibility: visible; visibility: visible;
} }
@media (max-width: 767px) {
.edit-form table tr th:nth-last-child(-n + 2), .edit-form table tr td:nth-last-child(-n + 2) {
display: none;
}
.edit-form table tr td .msg-box {
display: none;
}
}
</style> </style>
<div class="panel panel-default panel-intro"> <div class="panel panel-default panel-intro">
<div class="panel-heading"> <div class="panel-heading">
{:build_heading(null, false)} {:build_heading(null, false)}
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
{foreach $siteList as $index=>$vo} {foreach $siteList as $index=>$vo}
<li class="{$vo.active?'active':''}"><a href="#tab-{$vo.name}" data-toggle="tab">{:__($vo.title)}</a></li> <li class="{$vo.active?'active':''}"><a href="#{$vo.name}" data-toggle="tab">{:__($vo.title)}</a></li>
{/foreach} {/foreach}
{if $Think.config.app_debug} {if $Think.config.app_debug}
<li data-toggle="tooltip" title="{:__('Add new config')}"> <li data-toggle="tooltip" title="{:__('Add new config')}">
@ -41,7 +50,7 @@
<div id="myTabContent" class="tab-content"> <div id="myTabContent" class="tab-content">
<!--@formatter:off--> <!--@formatter:off-->
{foreach $siteList as $index=>$vo} {foreach $siteList as $index=>$vo}
<div class="tab-pane fade {$vo.active ? 'active in' : ''}" id="tab-{$vo.name}"> <div class="tab-pane fade {$vo.active ? 'active in' : ''}" id="{$vo.name}">
<div class="widget-body no-padding"> <div class="widget-body no-padding">
<form id="{$vo.name}-form" class="edit-form form-horizontal" role="form" data-toggle="validator" method="POST" action="{:url('general.config/edit')}"> <form id="{$vo.name}-form" class="edit-form form-horizontal" role="form" data-toggle="validator" method="POST" action="{:url('general.config/edit')}">
{:token()} {:token()}
@ -58,7 +67,7 @@
</thead> </thead>
<tbody> <tbody>
{foreach $vo.list as $item} {foreach $vo.list as $item}
<tr data-favisible="{$item.visible|default=''|htmlentities}" data-name="{$item.name}" class="{if $item.visible??''}hidden{/if}"> <tr>
<td>{$item.title}</td> <td>{$item.title}</td>
<td> <td>
<div class="row"> <div class="row">
@ -314,12 +323,6 @@ value2|title2</textarea>
<span class="msg-box n-right" for="rule"></span> <span class="msg-box n-right" for="rule"></span>
</div> </div>
</div> </div>
<div class="form-group">
<label for="visible" class="control-label col-xs-12 col-sm-2">{:__('Visible condition')}:</label>
<div class="col-xs-12 col-sm-4">
<input type="text" class="form-control" id="visible" name="row[visible]" value="" data-rule=""/>
</div>
</div>
<div class="form-group"> <div class="form-group">
<label for="extend" class="control-label col-xs-12 col-sm-2">{:__('Extend')}:</label> <label for="extend" class="control-label col-xs-12 col-sm-2">{:__('Extend')}:</label>
<div class="col-xs-12 col-sm-4"> <div class="col-xs-12 col-sm-4">

View File

@ -56,16 +56,13 @@
<button type="button" id="faupload-avatar" class="faupload" data-input-id="c-avatar"><i class="fa fa-upload"></i> {:__('Upload')}</button> <button type="button" id="faupload-avatar" class="faupload" data-input-id="c-avatar"><i class="fa fa-upload"></i> {:__('Upload')}</button>
</div> </div>
<h3 class="profile-username text-center">{$admin.nickname|htmlentities}</h3> <h3 class="profile-username text-center">{$admin.username|htmlentities}</h3>
<p class="text-muted text-center">{$admin.email|htmlentities}</p>
<div class="form-group"> <div class="form-group">
<label for="username" class="control-label">{:__('Username')}:</label> <label for="username" class="control-label">{:__('Username')}:</label>
<input type="text" class="form-control" id="username" name="row[username]" value="{$admin.username|htmlentities}" disabled/> <input type="text" class="form-control" id="username" name="row[username]" value="{$admin.username|htmlentities}" disabled/>
</div> </div>
<div class="form-group">
<label for="mobile" class="control-label">{:__('Mobile')}:</label>
<input type="text" class="form-control" id="mobile" name="row[mobile]" value="{$admin.mobile|htmlentities}" disabled/>
</div>
<div class="form-group"> <div class="form-group">
<label for="email" class="control-label">{:__('Email')}:</label> <label for="email" class="control-label">{:__('Email')}:</label>
<input type="text" class="form-control" id="email" name="row[email]" value="{$admin.email|htmlentities}" data-rule="required;email"/> <input type="text" class="form-control" id="email" name="row[email]" value="{$admin.email|htmlentities}" data-rule="required;email"/>
@ -103,7 +100,7 @@
<div id="toolbar" class="toolbar"> <div id="toolbar" class="toolbar">
{:build_toolbar('refresh')} {:build_toolbar('refresh')}
</div> </div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap" width="100%"> <table id="table" class="table table-striped table-bordered table-hover" width="100%">
</table> </table>

View File

@ -1,5 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html lang="{$config.language}">
<head> <head>
<!-- 加载样式及META信息 --> <!-- 加载样式及META信息 -->
{include file="common/meta" /} {include file="common/meta" /}
@ -28,12 +28,12 @@
<div class="content-wrapper tab-content tab-addtabs"> <div class="content-wrapper tab-content tab-addtabs">
{if $fixedmenu} {if $fixedmenu}
<div role="tabpanel" class="tab-pane {:$referermenu?'':'active'}" id="con_{$fixedmenu.id}"> <div role="tabpanel" class="tab-pane {:$referermenu?'':'active'}" id="con_{$fixedmenu.id}">
<iframe src="{$fixedmenu.url}{:stripos($fixedmenu.url, '?') !== false ? '&' : '?'}addtabs=1" width="100%" height="100%" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling-x="no" scrolling-y="auto" allowtransparency="yes"></iframe> <iframe src="{$fixedmenu.url}?addtabs=1" width="100%" height="100%" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling-x="no" scrolling-y="auto" allowtransparency="yes"></iframe>
</div> </div>
{/if} {/if}
{if $referermenu} {if $referermenu}
<div role="tabpanel" class="tab-pane active" id="con_{$referermenu.id}"> <div role="tabpanel" class="tab-pane active" id="con_{$referermenu.id}">
<iframe src="{$referermenu.url}{:stripos($referermenu.url, '?') !== false ? '&' : '?'}addtabs=1" width="100%" height="100%" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling-x="no" scrolling-y="auto" allowtransparency="yes"></iframe> <iframe src="{$referermenu.url}?addtabs=1" width="100%" height="100%" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling-x="no" scrolling-y="auto" allowtransparency="yes"></iframe>
</div> </div>
{/if} {/if}
</div> </div>

View File

@ -1,5 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html lang="{$config.language}">
<head> <head>
{include file="common/meta" /} {include file="common/meta" /}
@ -28,7 +28,7 @@
box-shadow: 0 0 30px rgba(0, 0, 0, 0.1); box-shadow: 0 0 30px rgba(0, 0, 0, 0.1);
background: rgba(255, 255, 255, 1); background: rgba(255, 255, 255, 1);
border: none; border: none;
/*overflow: hidden;*/ overflow: hidden;
padding: 0; padding: 0;
} }
@ -55,7 +55,6 @@
.login-head { .login-head {
background: #899fe1; background: #899fe1;
border-radius: 3px 3px 0 0;
} }
.login-form { .login-form {
@ -100,7 +99,6 @@
<p id="profile-name" class="profile-name-card"></p> <p id="profile-name" class="profile-name-card"></p>
<form action="" method="post" id="login-form"> <form action="" method="post" id="login-form">
<!--@AdminLoginFormBegin-->
<div id="errtips" class="hide"></div> <div id="errtips" class="hide"></div>
{:token()} {:token()}
<div class="input-group"> <div class="input-group">
@ -112,29 +110,24 @@
<div class="input-group-addon"><span class="glyphicon glyphicon-lock" aria-hidden="true"></span></div> <div class="input-group-addon"><span class="glyphicon glyphicon-lock" aria-hidden="true"></span></div>
<input type="password" class="form-control" id="pd-form-password" placeholder="{:__('Password')}" name="password" autocomplete="off" value="" data-rule="{:__('Password')}:required;password"/> <input type="password" class="form-control" id="pd-form-password" placeholder="{:__('Password')}" name="password" autocomplete="off" value="" data-rule="{:__('Password')}:required;password"/>
</div> </div>
<!--@CaptchaBegin-->
{if $Think.config.fastadmin.login_captcha} {if $Think.config.fastadmin.login_captcha}
<div class="input-group"> <div class="input-group">
<div class="input-group-addon"><span class="glyphicon glyphicon-option-horizontal" aria-hidden="true"></span></div> <div class="input-group-addon"><span class="glyphicon glyphicon-option-horizontal" aria-hidden="true"></span></div>
<input type="text" name="captcha" class="form-control" placeholder="{:__('Captcha')}" data-rule="{:__('Captcha')}:required;length({$Think.config.captcha.length})" autocomplete="off"/> <input type="text" name="captcha" class="form-control" placeholder="{:__('Captcha')}" data-rule="{:__('Captcha')}:required;length({$Think.config.captcha.length})" autocomplete="off"/>
<span class="input-group-addon" style="padding:0;border:none;cursor:pointer;"> <span class="input-group-addon" style="padding:0;border:none;cursor:pointer;">
<img src="{:rtrim('__PUBLIC__', '/')}/index.php?s=/captcha" width="100" height="30" onclick="this.src = '{:rtrim('__PUBLIC__', '/')}/index.php?s=/captcha&r=' + Math.random();"/> <img src="{:rtrim('__PUBLIC__', '/')}/index.php?s=/captcha" width="100" height="30" onclick="this.src = '{:rtrim('__PUBLIC__', '/')}/index.php?s=/captcha&r=' + Math.random();"/>
</span> </span>
</div> </div>
{/if} {/if}
<!--@CaptchaEnd-->
{if $keeyloginhours>0}
<div class="form-group checkbox"> <div class="form-group checkbox">
<label class="inline" for="keeplogin" data-toggle="tooltip" title="{:__('The duration of the session is %s hours', $keeyloginhours)}"> <label class="inline" for="keeplogin">
<input type="checkbox" name="keeplogin" id="keeplogin" value="1"/> <input type="checkbox" name="keeplogin" id="keeplogin" value="1"/>
{:__('Keep login')} {:__('Keep login')}
</label> </label>
</div> </div>
{/if}
<div class="form-group"> <div class="form-group">
<button type="submit" class="btn btn-success btn-lg btn-block" style="background:#708eea;">{:__('Sign in')}</button> <button type="submit" class="btn btn-success btn-lg btn-block" style="background:#708eea;">{:__('Sign in')}</button>
</div> </div>
<!--@AdminLoginFormEnd-->
</form> </form>
</div> </div>
</div> </div>

View File

@ -1,5 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html lang="{$config.language}">
<head> <head>
{include file="common/meta" /} {include file="common/meta" /}
</head> </head>

View File

@ -1,6 +1,6 @@
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action=""> <form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
{:token()} {:token()}
<input type="hidden" name="row[rules]" value="{$row.rules|htmlentities}" /> <input type="hidden" name="row[rules]" value="{$row.rules}" />
<div class="form-group"> <div class="form-group">
<label for="c-name" class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label> <label for="c-name" class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
<div class="col-xs-12 col-sm-8"> <div class="col-xs-12 col-sm-8">

View File

@ -15,7 +15,7 @@
</ul> </ul>
</div> </div>
</div> </div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap" <table id="table" class="table table-striped table-bordered table-hover"
data-operate-edit="{:$auth->check('user/group/edit')}" data-operate-edit="{:$auth->check('user/group/edit')}"
data-operate-del="{:$auth->check('user/group/del')}" data-operate-del="{:$auth->check('user/group/del')}"
width="100%"> width="100%">

View File

@ -33,7 +33,7 @@
<div class="form-group"> <div class="form-group">
<label for="c-weigh" class="control-label col-xs-12 col-sm-2">{:__('Weigh')}:</label> <label for="c-weigh" class="control-label col-xs-12 col-sm-2">{:__('Weigh')}:</label>
<div class="col-xs-12 col-sm-8"> <div class="col-xs-12 col-sm-8">
<input id="c-weigh" class="form-control" name="row[weigh]" type="number" value="{$row.weigh|htmlentities}"> <input id="c-weigh" class="form-control" name="row[weigh]" type="number" value="{$row.weigh}">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">

View File

@ -14,9 +14,8 @@
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li> <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
</ul> </ul>
</div> </div>
<a href="javascript:;" class="btn btn-danger btn-toggle-all"><i class="fa fa-plus"></i> {:__('Toggle all')}</a>
</div> </div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap" <table id="table" class="table table-striped table-bordered table-hover"
data-operate-edit="{:$auth->check('user/rule/edit')}" data-operate-edit="{:$auth->check('user/rule/edit')}"
data-operate-del="{:$auth->check('user/rule/del')}" data-operate-del="{:$auth->check('user/rule/del')}"
width="100%"> width="100%">

View File

@ -1,8 +1,8 @@
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action=""> <form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
{:token()} {:token()}
<input type="hidden" name="row[id]" value="{$row.id|htmlentities}"> <input type="hidden" name="row[id]" value="{$row.id}">
<div class="form-group"> <div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Group')}:</label> <label for="c-group_id" class="control-label col-xs-12 col-sm-2">{:__('Group')}:</label>
<div class="col-xs-12 col-sm-4"> <div class="col-xs-12 col-sm-4">
{$groupList} {$groupList}
</div> </div>
@ -28,20 +28,20 @@
<div class="form-group"> <div class="form-group">
<label for="c-email" class="control-label col-xs-12 col-sm-2">{:__('Email')}:</label> <label for="c-email" class="control-label col-xs-12 col-sm-2">{:__('Email')}:</label>
<div class="col-xs-12 col-sm-4"> <div class="col-xs-12 col-sm-4">
<input id="c-email" data-rule="email" class="form-control" name="row[email]" type="text" value="{$row.email|htmlentities}"> <input id="c-email" data-rule="" class="form-control" name="row[email]" type="text" value="{$row.email|htmlentities}">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="c-mobile" class="control-label col-xs-12 col-sm-2">{:__('Mobile')}:</label> <label for="c-mobile" class="control-label col-xs-12 col-sm-2">{:__('Mobile')}:</label>
<div class="col-xs-12 col-sm-4"> <div class="col-xs-12 col-sm-4">
<input id="c-mobile" data-rule="mobile" class="form-control" name="row[mobile]" type="text" value="{$row.mobile|htmlentities}"> <input id="c-mobile" data-rule="" class="form-control" name="row[mobile]" type="text" value="{$row.mobile|htmlentities}">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="c-avatar" class="control-label col-xs-12 col-sm-2">{:__('Avatar')}:</label> <label for="c-avatar" class="control-label col-xs-12 col-sm-2">{:__('Avatar')}:</label>
<div class="col-xs-12 col-sm-8"> <div class="col-xs-12 col-sm-8">
<div class="input-group"> <div class="input-group">
<input id="c-avatar" data-rule="" class="form-control" size="50" name="row[avatar]" type="text" value="{$row.avatar|htmlentities}"> <input id="c-avatar" data-rule="" class="form-control" size="50" name="row[avatar]" type="text" value="{$row.avatar}">
<div class="input-group-addon no-border no-padding"> <div class="input-group-addon no-border no-padding">
<span><button type="button" id="faupload-avatar" class="btn btn-danger faupload" data-input-id="c-avatar" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-avatar"><i class="fa fa-upload"></i> {:__('Upload')}</button></span> <span><button type="button" id="faupload-avatar" class="btn btn-danger faupload" data-input-id="c-avatar" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-avatar"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-avatar" class="btn btn-primary fachoose" data-input-id="c-avatar" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span> <span><button type="button" id="fachoose-avatar" class="btn btn-primary fachoose" data-input-id="c-avatar" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
@ -54,11 +54,11 @@
<div class="form-group"> <div class="form-group">
<label for="c-level" class="control-label col-xs-12 col-sm-2">{:__('Level')}:</label> <label for="c-level" class="control-label col-xs-12 col-sm-2">{:__('Level')}:</label>
<div class="col-xs-12 col-sm-4"> <div class="col-xs-12 col-sm-4">
<input id="c-level" data-rule="required" class="form-control" name="row[level]" type="number" value="{$row.level|htmlentities}"> <input id="c-level" data-rule="required" class="form-control" name="row[level]" type="number" value="{$row.level}">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Gender')}:</label> <label for="c-gender" class="control-label col-xs-12 col-sm-2">{:__('Gender')}:</label>
<div class="col-xs-12 col-sm-8"> <div class="col-xs-12 col-sm-8">
{:build_radios('row[gender]', ['1'=>__('Male'), '0'=>__('Female')], $row['gender'])} {:build_radios('row[gender]', ['1'=>__('Male'), '0'=>__('Female')], $row['gender'])}
</div> </div>
@ -66,7 +66,7 @@
<div class="form-group"> <div class="form-group">
<label for="c-birthday" class="control-label col-xs-12 col-sm-2">{:__('Birthday')}:</label> <label for="c-birthday" class="control-label col-xs-12 col-sm-2">{:__('Birthday')}:</label>
<div class="col-xs-12 col-sm-4"> <div class="col-xs-12 col-sm-4">
<input id="c-birthday" data-rule="" class="form-control datetimepicker" data-date-format="YYYY-MM-DD" data-use-current="true" name="row[birthday]" type="text" value="{$row.birthday|htmlentities}"> <input id="c-birthday" data-rule="" class="form-control datetimepicker" data-date-format="YYYY-MM-DD" data-use-current="true" name="row[birthday]" type="text" value="{$row.birthday}">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -78,25 +78,25 @@
<div class="form-group"> <div class="form-group">
<label for="c-money" class="control-label col-xs-12 col-sm-2">{:__('Money')}:</label> <label for="c-money" class="control-label col-xs-12 col-sm-2">{:__('Money')}:</label>
<div class="col-xs-12 col-sm-4"> <div class="col-xs-12 col-sm-4">
<input id="c-money" data-rule="required" class="form-control" name="row[money]" type="number" value="{$row.money|htmlentities}"> <input id="c-money" data-rule="required" class="form-control" name="row[money]" type="number" value="{$row.money}">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="c-score" class="control-label col-xs-12 col-sm-2">{:__('Score')}:</label> <label for="c-score" class="control-label col-xs-12 col-sm-2">{:__('Score')}:</label>
<div class="col-xs-12 col-sm-4"> <div class="col-xs-12 col-sm-4">
<input id="c-score" data-rule="required" class="form-control" name="row[score]" type="number" value="{$row.score|htmlentities}"> <input id="c-score" data-rule="required" class="form-control" name="row[score]" type="number" value="{$row.score}">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="c-successions" class="control-label col-xs-12 col-sm-2">{:__('Successions')}:</label> <label for="c-successions" class="control-label col-xs-12 col-sm-2">{:__('Successions')}:</label>
<div class="col-xs-12 col-sm-4"> <div class="col-xs-12 col-sm-4">
<input id="c-successions" data-rule="required" class="form-control" name="row[successions]" type="number" value="{$row.successions|htmlentities}"> <input id="c-successions" data-rule="required" class="form-control" name="row[successions]" type="number" value="{$row.successions}">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="c-maxsuccessions" class="control-label col-xs-12 col-sm-2">{:__('Maxsuccessions')}:</label> <label for="c-maxsuccessions" class="control-label col-xs-12 col-sm-2">{:__('Maxsuccessions')}:</label>
<div class="col-xs-12 col-sm-4"> <div class="col-xs-12 col-sm-4">
<input id="c-maxsuccessions" data-rule="required" class="form-control" name="row[maxsuccessions]" type="number" value="{$row.maxsuccessions|htmlentities}"> <input id="c-maxsuccessions" data-rule="required" class="form-control" name="row[maxsuccessions]" type="number" value="{$row.maxsuccessions}">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -114,19 +114,19 @@
<div class="form-group"> <div class="form-group">
<label for="c-loginip" class="control-label col-xs-12 col-sm-2">{:__('Loginip')}:</label> <label for="c-loginip" class="control-label col-xs-12 col-sm-2">{:__('Loginip')}:</label>
<div class="col-xs-12 col-sm-4"> <div class="col-xs-12 col-sm-4">
<input id="c-loginip" data-rule="required" class="form-control" name="row[loginip]" type="text" value="{$row.loginip|htmlentities}"> <input id="c-loginip" data-rule="required" class="form-control" name="row[loginip]" type="text" value="{$row.loginip}">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="c-loginfailure" class="control-label col-xs-12 col-sm-2">{:__('Loginfailure')}:</label> <label for="c-loginfailure" class="control-label col-xs-12 col-sm-2">{:__('Loginfailure')}:</label>
<div class="col-xs-12 col-sm-4"> <div class="col-xs-12 col-sm-4">
<input id="c-loginfailure" data-rule="required" class="form-control" name="row[loginfailure]" type="number" value="{$row.loginfailure|htmlentities}"> <input id="c-loginfailure" data-rule="required" class="form-control" name="row[loginfailure]" type="number" value="{$row.loginfailure}">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="c-joinip" class="control-label col-xs-12 col-sm-2">{:__('Joinip')}:</label> <label for="c-joinip" class="control-label col-xs-12 col-sm-2">{:__('Joinip')}:</label>
<div class="col-xs-12 col-sm-4"> <div class="col-xs-12 col-sm-4">
<input id="c-joinip" data-rule="required" class="form-control" name="row[joinip]" type="text" value="{$row.joinip|htmlentities}"> <input id="c-joinip" data-rule="required" class="form-control" name="row[joinip]" type="text" value="{$row.joinip}">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -136,7 +136,7 @@
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label> <label for="content" class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
<div class="col-xs-12 col-sm-8"> <div class="col-xs-12 col-sm-8">
{:build_radios('row[status]', ['normal'=>__('Normal'), 'hidden'=>__('Hidden')], $row['status'])} {:build_radios('row[status]', ['normal'=>__('Normal'), 'hidden'=>__('Hidden')], $row['status'])}
</div> </div>

View File

@ -8,7 +8,6 @@ use app\common\library\Upload;
use app\common\model\Area; use app\common\model\Area;
use app\common\model\Version; use app\common\model\Version;
use fast\Random; use fast\Random;
use think\captcha\Captcha;
use think\Config; use think\Config;
use think\Hook; use think\Hook;
@ -17,30 +16,15 @@ use think\Hook;
*/ */
class Common extends Api class Common extends Api
{ {
protected $noNeedLogin = ['init', 'captcha']; protected $noNeedLogin = ['init'];
protected $noNeedRight = '*'; protected $noNeedRight = '*';
public function _initialize()
{
if (isset($_SERVER['HTTP_ORIGIN'])) {
header('Access-Control-Expose-Headers: __token__');//跨域让客户端获取到
}
//跨域检测
check_cors_request();
if (!isset($_COOKIE['PHPSESSID'])) {
Config::set('session.id', $this->request->server("HTTP_SID"));
}
parent::_initialize();
}
/** /**
* 加载初始化 * 加载初始化
* *
* @ApiParams (name="version", type="string", required=true, description="版本号") * @param string $version 版本号
* @ApiParams (name="lng", type="string", required=true, description="经度") * @param string $lng 经度
* @ApiParams (name="lat", type="string", required=true, description="纬度") * @param string $lat 纬度
*/ */
public function init() public function init()
{ {
@ -80,7 +64,7 @@ class Common extends Api
/** /**
* 上传文件 * 上传文件
* @ApiMethod (POST) * @ApiMethod (POST)
* @ApiParams (name="file", type="File", required=true, description="文件流") * @param File $file 文件流
*/ */
public function upload() public function upload()
{ {
@ -137,30 +121,10 @@ class Common extends Api
$attachment = $upload->upload(); $attachment = $upload->upload();
} catch (UploadException $e) { } catch (UploadException $e) {
$this->error($e->getMessage()); $this->error($e->getMessage());
} catch (\Exception $e) {
$this->error($e->getMessage());
} }
$this->success(__('Uploaded successful'), ['url' => $attachment->url, 'fullurl' => cdnurl($attachment->url, true)]); $this->success(__('Uploaded successful'), ['url' => $attachment->url, 'fullurl' => cdnurl($attachment->url, true)]);
} }
} }
/**
* 验证码
* @ApiParams (name="id", type="string", required=true, description="要生成验证码的标识")
* @return \think\Response
*/
public function captcha($id = "")
{
\think\Config::set([
'captcha' => array_merge(config('captcha'), [
'fontSize' => 44,
'imageH' => 150,
'imageW' => 350,
])
]);
$captcha = new Captcha((array)Config::get('captcha'));
return $captcha->entry($id);
}
} }

View File

@ -5,7 +5,6 @@ namespace app\api\controller;
use app\common\controller\Api; use app\common\controller\Api;
use app\common\library\Ems as Emslib; use app\common\library\Ems as Emslib;
use app\common\model\User; use app\common\model\User;
use think\Hook;
/** /**
* 邮箱验证码接口 * 邮箱验证码接口
@ -18,14 +17,23 @@ class Ems extends Api
public function _initialize() public function _initialize()
{ {
parent::_initialize(); parent::_initialize();
\think\Hook::add('ems_send', function ($params) {
$obj = \app\common\library\Email::instance();
$result = $obj
->to($params->email)
->subject('验证码')
->message("你的验证码是:" . $params->code)
->send();
return $result;
});
} }
/** /**
* 发送验证码 * 发送验证码
* *
* @ApiMethod (POST) * @ApiMethod (POST)
* @ApiParams (name="email", type="string", required=true, description="邮箱") * @param string $email 邮箱
* @ApiParams (name="event", type="string", required=true, description="事件名称") * @param string $event 事件名称
*/ */
public function send() public function send()
{ {
@ -33,35 +41,10 @@ class Ems extends Api
$event = $this->request->post("event"); $event = $this->request->post("event");
$event = $event ? $event : 'register'; $event = $event ? $event : 'register';
if (!$email || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
$this->error(__('邮箱格式错误'));
}
if (!preg_match("/^[a-z0-9_\-]{3,30}\$/i", $event)) {
$this->error(__('事件名称错误'));
}
//发送前验证码
if (config('fastadmin.user_api_captcha')) {
if (!preg_match("/^[a-z0-9]{4,6}\$/i", $captcha)) {
$this->error(__('验证码格式错误'));
}
if (!\think\Validate::is($captcha, 'captcha')) {
$this->error("验证码不正确");
}
}
$last = Emslib::get($email, $event); $last = Emslib::get($email, $event);
if ($last && time() - $last['createtime'] < 60) { if ($last && time() - $last['createtime'] < 60) {
$this->error(__('发送频繁')); $this->error(__('发送频繁'));
} }
$ipSendTotal = \app\common\model\Ems::where(['ip' => $this->request->ip()])->whereTime('createtime', '-1 hours')->count();
if ($ipSendTotal >= 5) {
$this->error(__('发送频繁'));
}
if ($event) { if ($event) {
$userinfo = User::getByEmail($email); $userinfo = User::getByEmail($email);
if ($event == 'register' && $userinfo) { if ($event == 'register' && $userinfo) {
@ -87,9 +70,9 @@ class Ems extends Api
* 检测验证码 * 检测验证码
* *
* @ApiMethod (POST) * @ApiMethod (POST)
* @ApiParams (name="email", type="string", required=true, description="邮箱") * @param string $email 邮箱
* @ApiParams (name="event", type="string", required=true, description="事件名称") * @param string $event 事件名称
* @ApiParams (name="captcha", type="string", required=true, description="验证码") * @param string $captcha 验证码
*/ */
public function check() public function check()
{ {
@ -98,17 +81,6 @@ class Ems extends Api
$event = $event ? $event : 'register'; $event = $event ? $event : 'register';
$captcha = $this->request->post("captcha"); $captcha = $this->request->post("captcha");
if (!$email || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
$this->error(__('邮箱格式错误'));
}
if (!preg_match("/^[a-z0-9_\-]{3,30}\$/i", $event)) {
$this->error(__('事件名称错误'));
}
if (!preg_match("/^[a-z0-9]{4,6}\$/i", $captcha)) {
$this->error(__('验证码格式错误'));
}
if ($event) { if ($event) {
$userinfo = User::getByEmail($email); $userinfo = User::getByEmail($email);
if ($event == 'register' && $userinfo) { if ($event == 'register' && $userinfo) {

View File

@ -19,8 +19,8 @@ class Sms extends Api
* 发送验证码 * 发送验证码
* *
* @ApiMethod (POST) * @ApiMethod (POST)
* @ApiParams (name="mobile", type="string", required=true, description="手机号") * @param string $mobile 手机号
* @ApiParams (name="event", type="string", required=true, description="事件名称") * @param string $event 事件名称
*/ */
public function send() public function send()
{ {
@ -67,9 +67,9 @@ class Sms extends Api
* 检测验证码 * 检测验证码
* *
* @ApiMethod (POST) * @ApiMethod (POST)
* @ApiParams (name="mobile", type="string", required=true, description="手机号") * @param string $mobile 手机号
* @ApiParams (name="event", type="string", required=true, description="事件名称") * @param string $event 事件名称
* @ApiParams (name="captcha", type="string", required=true, description="验证码") * @param string $captcha 验证码
*/ */
public function check() public function check()
{ {

View File

@ -39,8 +39,8 @@ class User extends Api
* 会员登录 * 会员登录
* *
* @ApiMethod (POST) * @ApiMethod (POST)
* @ApiParams (name="account", type="string", required=true, description="账号") * @param string $account 账号
* @ApiParams (name="password", type="string", required=true, description="密码") * @param string $password 密码
*/ */
public function login() public function login()
{ {
@ -62,8 +62,8 @@ class User extends Api
* 手机验证码登录 * 手机验证码登录
* *
* @ApiMethod (POST) * @ApiMethod (POST)
* @ApiParams (name="mobile", type="string", required=true, description="手机号") * @param string $mobile 手机号
* @ApiParams (name="captcha", type="string", required=true, description="验证码") * @param string $captcha 验证码
*/ */
public function mobilelogin() public function mobilelogin()
{ {
@ -101,11 +101,11 @@ class User extends Api
* 注册会员 * 注册会员
* *
* @ApiMethod (POST) * @ApiMethod (POST)
* @ApiParams (name="username", type="string", required=true, description="用户名") * @param string $username 用户名
* @ApiParams (name="password", type="string", required=true, description="密码") * @param string $password 密码
* @ApiParams (name="email", type="string", required=true, description="邮箱") * @param string $email 邮箱
* @ApiParams (name="mobile", type="string", required=true, description="手机号") * @param string $mobile 手机号
* @ApiParams (name="code", type="string", required=true, description="验证码") * @param string $code 验证码
*/ */
public function register() public function register()
{ {
@ -153,10 +153,10 @@ class User extends Api
* 修改会员个人信息 * 修改会员个人信息
* *
* @ApiMethod (POST) * @ApiMethod (POST)
* @ApiParams (name="avatar", type="string", required=true, description="头像地址") * @param string $avatar 头像地址
* @ApiParams (name="username", type="string", required=true, description="用户名") * @param string $username 用户名
* @ApiParams (name="nickname", type="string", required=true, description="昵称") * @param string $nickname 昵称
* @ApiParams (name="bio", type="string", required=true, description="个人简介") * @param string $bio 个人简介
*/ */
public function profile() public function profile()
{ {
@ -189,8 +189,8 @@ class User extends Api
* 修改邮箱 * 修改邮箱
* *
* @ApiMethod (POST) * @ApiMethod (POST)
* @ApiParams (name="email", type="string", required=true, description="邮箱") * @param string $email 邮箱
* @ApiParams (name="captcha", type="string", required=true, description="验证码") * @param string $captcha 验证码
*/ */
public function changeemail() public function changeemail()
{ {
@ -224,8 +224,8 @@ class User extends Api
* 修改手机号 * 修改手机号
* *
* @ApiMethod (POST) * @ApiMethod (POST)
* @ApiParams (name="mobile", type="string", required=true, description="手机号") * @param string $mobile 手机号
* @ApiParams (name="captcha", type="string", required=true, description="验证码") * @param string $captcha 验证码
*/ */
public function changemobile() public function changemobile()
{ {
@ -259,8 +259,8 @@ class User extends Api
* 第三方登录 * 第三方登录
* *
* @ApiMethod (POST) * @ApiMethod (POST)
* @ApiParams (name="platform", type="string", required=true, description="平台名称") * @param string $platform 平台名称
* @ApiParams (name="code", type="string", required=true, description="Code码") * @param string $code Code码
*/ */
public function third() public function third()
{ {
@ -291,13 +291,13 @@ class User extends Api
* 重置密码 * 重置密码
* *
* @ApiMethod (POST) * @ApiMethod (POST)
* @ApiParams (name="mobile", type="string", required=true, description="手机号") * @param string $mobile 手机号
* @ApiParams (name="newpassword", type="string", required=true, description="新密码") * @param string $newpassword 新密码
* @ApiParams (name="captcha", type="string", required=true, description="验证码") * @param string $captcha 验证码
*/ */
public function resetpwd() public function resetpwd()
{ {
$type = $this->request->post("type", "mobile"); $type = $this->request->post("type");
$mobile = $this->request->post("mobile"); $mobile = $this->request->post("mobile");
$email = $this->request->post("email"); $email = $this->request->post("email");
$newpassword = $this->request->post("newpassword"); $newpassword = $this->request->post("newpassword");

View File

@ -23,8 +23,8 @@ class Validate extends Api
* 检测邮箱 * 检测邮箱
* *
* @ApiMethod (POST) * @ApiMethod (POST)
* @ApiParams (name="email", type="string", required=true, description="邮箱") * @param string $email 邮箱
* @ApiParams (name="id", type="string", required=true, description="排除会员ID") * @param string $id 排除会员ID
*/ */
public function check_email_available() public function check_email_available()
{ {
@ -41,8 +41,8 @@ class Validate extends Api
* 检测用户名 * 检测用户名
* *
* @ApiMethod (POST) * @ApiMethod (POST)
* @ApiParams (name="username", type="string", required=true, description="用户名") * @param string $username 用户名
* @ApiParams (name="id", type="string", required=true, description="排除会员ID") * @param string $id 排除会员ID
*/ */
public function check_username_available() public function check_username_available()
{ {
@ -59,8 +59,8 @@ class Validate extends Api
* 检测昵称 * 检测昵称
* *
* @ApiMethod (POST) * @ApiMethod (POST)
* @ApiParams (name="nickname", type="string", required=true, description="昵称") * @param string $nickname 昵称
* @ApiParams (name="id", type="string", required=true, description="排除会员ID") * @param string $id 排除会员ID
*/ */
public function check_nickname_available() public function check_nickname_available()
{ {
@ -77,8 +77,8 @@ class Validate extends Api
* 检测手机 * 检测手机
* *
* @ApiMethod (POST) * @ApiMethod (POST)
* @ApiParams (name="mobile", type="string", required=true, description="手机号") * @param string $mobile 手机号
* @ApiParams (name="id", type="string", required=true, description="排除会员ID") * @param string $id 排除会员ID
*/ */
public function check_mobile_available() public function check_mobile_available()
{ {
@ -95,7 +95,7 @@ class Validate extends Api
* 检测手机 * 检测手机
* *
* @ApiMethod (POST) * @ApiMethod (POST)
* @ApiParams (name="mobile", type="string", required=true, description="手机号") * @param string $mobile 手机号
*/ */
public function check_mobile_exist() public function check_mobile_exist()
{ {
@ -111,7 +111,7 @@ class Validate extends Api
* 检测邮箱 * 检测邮箱
* *
* @ApiMethod (POST) * @ApiMethod (POST)
* @ApiParams (name="email", type="string", required=true, description="邮箱") * @param string $mobile 邮箱
*/ */
public function check_email_exist() public function check_email_exist()
{ {
@ -127,9 +127,9 @@ class Validate extends Api
* 检测手机验证码 * 检测手机验证码
* *
* @ApiMethod (POST) * @ApiMethod (POST)
* @ApiParams (name="mobile", type="string", required=true, description="手机号") * @param string $mobile 手机号
* @ApiParams (name="captcha", type="string", required=true, description="验证码") * @param string $captcha 验证码
* @ApiParams (name="event", type="string", required=true, description="事件") * @param string $event 事件
*/ */
public function check_sms_correct() public function check_sms_correct()
{ {
@ -146,9 +146,9 @@ class Validate extends Api
* 检测邮箱验证码 * 检测邮箱验证码
* *
* @ApiMethod (POST) * @ApiMethod (POST)
* @ApiParams (name="email", type="string", required=true, description="邮箱") * @param string $email 邮箱
* @ApiParams (name="captcha", type="string", required=true, description="验证码") * @param string $captcha 验证码
* @ApiParams (name="event", type="string", required=true, description="事件") * @param string $event 事件
*/ */
public function check_ems_correct() public function check_ems_correct()
{ {

View File

@ -86,7 +86,7 @@ return [
'You can only upload a maximum of %s files' => '你最多允许上传 %s 个文件', 'You can only upload a maximum of %s files' => '你最多允许上传 %s 个文件',
'You can\'t upload files of this type' => '不允许上传的文件类型', 'You can\'t upload files of this type' => '不允许上传的文件类型',
'Server responded with %s code' => '服务端响应(Code:%s)', 'Server responded with %s code' => '服务端响应(Code:%s)',
'File is too big (%sMiB), Max filesize: %sMiB.' => '当前上传(%sM),最大允许上传文件大小:%sM', 'File is too big (%sMiB), Max filesize: %sMiB' => '当前上传(%sM),最大允许上传文件大小:%sM',
'Redirect now' => '立即跳转', 'Redirect now' => '立即跳转',
'Operation completed' => '操作成功!', 'Operation completed' => '操作成功!',
'Operation failed' => '操作失败!', 'Operation failed' => '操作失败!',

View File

@ -7,7 +7,7 @@ return [
'Sign up successful' => '注册成功', 'Sign up successful' => '注册成功',
'Username can not be empty' => '用户名不能为空', 'Username can not be empty' => '用户名不能为空',
'Username must be 3 to 30 characters' => '用户名必须3-30个字符', 'Username must be 3 to 30 characters' => '用户名必须3-30个字符',
'Username must be 6 to 30 characters' => '用户名必须6-30个字符', 'Username must be 6 to 30 characters' => '用户名必须3-30个字符',
'Password can not be empty' => '密码不能为空', 'Password can not be empty' => '密码不能为空',
'Password must be 6 to 30 characters' => '密码必须6-30个字符', 'Password must be 6 to 30 characters' => '密码必须6-30个字符',
'Mobile is incorrect' => '手机格式不正确', 'Mobile is incorrect' => '手机格式不正确',

View File

@ -2,6 +2,7 @@
// 公共助手函数 // 公共助手函数
use Symfony\Component\VarExporter\VarExporter;
use think\exception\HttpResponseException; use think\exception\HttpResponseException;
use think\Response; use think\Response;
@ -10,7 +11,7 @@ if (!function_exists('__')) {
/** /**
* 获取语言变量值 * 获取语言变量值
* @param string $name 语言变量名 * @param string $name 语言变量名
* @param string | array $vars 动态变量值 * @param array $vars 动态变量值
* @param string $lang 语言 * @param string $lang 语言
* @return mixed * @return mixed
*/ */
@ -40,7 +41,7 @@ if (!function_exists('format_bytes')) {
function format_bytes($size, $delimiter = '', $precision = 2) function format_bytes($size, $delimiter = '', $precision = 2)
{ {
$units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB'); $units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB');
for ($i = 0; $size >= 1024 && $i < 5; $i++) { for ($i = 0; $size >= 1024 && $i < 6; $i++) {
$size /= 1024; $size /= 1024;
} }
return round($size, $precision) . $delimiter . $units[$i]; return round($size, $precision) . $delimiter . $units[$i];
@ -88,9 +89,7 @@ if (!function_exists('cdnurl')) {
{ {
$regex = "/^((?:[a-z]+:)?\/\/|data:image\/)(.*)/i"; $regex = "/^((?:[a-z]+:)?\/\/|data:image\/)(.*)/i";
$cdnurl = \think\Config::get('upload.cdnurl'); $cdnurl = \think\Config::get('upload.cdnurl');
if (is_bool($domain) || stripos($cdnurl, '/') === 0) { $url = preg_match($regex, $url) || ($cdnurl && stripos($url, $cdnurl) === 0) ? $url : $cdnurl . $url;
$url = preg_match($regex, $url) || ($cdnurl && stripos($url, $cdnurl) === 0) ? $url : $cdnurl . $url;
}
if ($domain && !preg_match($regex, $url)) { if ($domain && !preg_match($regex, $url)) {
$domain = is_bool($domain) ? request()->domain() : $domain; $domain = is_bool($domain) ? request()->domain() : $domain;
$url = $domain . $url; $url = $domain . $url;
@ -217,7 +216,7 @@ if (!function_exists('addtion')) {
} else { } else {
foreach ($fields as $k => $v) { foreach ($fields as $k => $v) {
if (is_array($v)) { if (is_array($v)) {
$v['field'] = $v['field'] ?? $k; $v['field'] = isset($v['field']) ? $v['field'] : $k;
} else { } else {
$v = ['field' => $v]; $v = ['field' => $v];
} }
@ -226,12 +225,12 @@ if (!function_exists('addtion')) {
} }
foreach ($fieldsArr as $k => &$v) { foreach ($fieldsArr as $k => &$v) {
$v = is_array($v) ? $v : ['field' => $v]; $v = is_array($v) ? $v : ['field' => $v];
$v['display'] = $v['display'] ?? str_replace(['_ids', '_id'], ['_names', '_name'], $v['field']); $v['display'] = isset($v['display']) ? $v['display'] : str_replace(['_ids', '_id'], ['_names', '_name'], $v['field']);
$v['primary'] = $v['primary'] ?? ''; $v['primary'] = isset($v['primary']) ? $v['primary'] : '';
$v['column'] = $v['column'] ?? 'name'; $v['column'] = isset($v['column']) ? $v['column'] : 'name';
$v['model'] = $v['model'] ?? ''; $v['model'] = isset($v['model']) ? $v['model'] : '';
$v['table'] = $v['table'] ?? ''; $v['table'] = isset($v['table']) ? $v['table'] : '';
$v['name'] = $v['name'] ?? str_replace(['_ids', '_id'], '', $v['field']); $v['name'] = isset($v['name']) ? $v['name'] : str_replace(['_ids', '_id'], '', $v['field']);
} }
unset($v); unset($v);
$ids = []; $ids = [];
@ -248,10 +247,9 @@ if (!function_exists('addtion')) {
if ($v['model']) { if ($v['model']) {
$model = new $v['model']; $model = new $v['model'];
} else { } else {
// 优先判断使用table的配置 $model = $v['name'] ? \think\Db::name($v['name']) : \think\Db::table($v['table']);
$model = $v['table'] ? \think\Db::table($v['table']) : \think\Db::name($v['name']);
} }
$primary = $v['primary'] ?: $model->getPk(); $primary = $v['primary'] ? $v['primary'] : $model->getPk();
$result[$v['field']] = isset($ids[$v['field']]) ? $model->where($primary, 'in', $ids[$v['field']])->column($v['column'], $primary) : []; $result[$v['field']] = isset($ids[$v['field']]) ? $model->where($primary, 'in', $ids[$v['field']])->column($v['column'], $primary) : [];
} }
@ -280,6 +278,60 @@ if (!function_exists('var_export_short')) {
function var_export_short($data, $return = true) function var_export_short($data, $return = true)
{ {
return var_export($data, $return); return var_export($data, $return);
$replaced = [];
$count = 0;
//判断是否是对象
if (is_resource($data) || is_object($data)) {
return var_export($data, $return);
}
//判断是否有特殊的键名
$specialKey = false;
array_walk_recursive($data, function (&$value, &$key) use (&$specialKey) {
if (is_string($key) && (stripos($key, "\n") !== false || stripos($key, "array (") !== false)) {
$specialKey = true;
}
});
if ($specialKey) {
return var_export($data, $return);
}
array_walk_recursive($data, function (&$value, &$key) use (&$replaced, &$count, &$stringcheck) {
if (is_object($value) || is_resource($value)) {
$replaced[$count] = var_export($value, true);
$value = "##<{$count}>##";
} else {
if (is_string($value) && (stripos($value, "\n") !== false || stripos($value, "array (") !== false)) {
$index = array_search($value, $replaced);
if ($index === false) {
$replaced[$count] = var_export($value, true);
$value = "##<{$count}>##";
} else {
$value = "##<{$index}>##";
}
}
}
$count++;
});
$dump = var_export($data, true);
$dump = preg_replace('#(?:\A|\n)([ ]*)array \(#i', '[', $dump); // Starts
$dump = preg_replace('#\n([ ]*)\),#', "\n$1],", $dump); // Ends
$dump = preg_replace('#=> \[\n\s+\],\n#', "=> [],\n", $dump); // Empties
$dump = preg_replace('#\)$#', "]", $dump); //End
if ($replaced) {
$dump = preg_replace_callback("/'##<(\d+)>##'/", function ($matches) use ($replaced) {
return isset($replaced[$matches[1]]) ? $replaced[$matches[1]] : "''";
}, $dump);
}
if ($return === true) {
return $dump;
} else {
echo $dump;
}
} }
} }
@ -375,7 +427,7 @@ if (!function_exists('check_cors_request')) {
*/ */
function check_cors_request() function check_cors_request()
{ {
if (isset($_SERVER['HTTP_ORIGIN']) && $_SERVER['HTTP_ORIGIN'] && config('fastadmin.cors_request_domain')) { if (isset($_SERVER['HTTP_ORIGIN']) && $_SERVER['HTTP_ORIGIN']) {
$info = parse_url($_SERVER['HTTP_ORIGIN']); $info = parse_url($_SERVER['HTTP_ORIGIN']);
$domainArr = explode(',', config('fastadmin.cors_request_domain')); $domainArr = explode(',', config('fastadmin.cors_request_domain'));
$domainArr[] = request()->host(true); $domainArr[] = request()->host(true);
@ -413,19 +465,6 @@ if (!function_exists('xss_clean')) {
} }
} }
if (!function_exists('url_clean')) {
/**
* 清理URL
*/
function url_clean($url)
{
if (!check_url_allowed($url)) {
return '';
}
return xss_clean($url);
}
}
if (!function_exists('check_ip_allowed')) { if (!function_exists('check_ip_allowed')) {
/** /**
* 检测IP是否允许 * 检测IP是否允许
@ -444,40 +483,6 @@ if (!function_exists('check_ip_allowed')) {
} }
} }
if (!function_exists('check_url_allowed')) {
/**
* 检测URL是否允许
* @param string $url URL
* @return bool
*/
function check_url_allowed($url = '')
{
//允许的主机列表
$allowedHostArr = [
strtolower(request()->host())
];
if (empty($url)) {
return true;
}
//如果是站内相对链接则允许
if (preg_match("/^[\/a-z][a-z0-9][a-z0-9\.\/]+((\?|#).*)?\$/i", $url) && substr($url, 0, 2) !== '//') {
return true;
}
//如果是站外链接则需要判断HOST是否允许
if (preg_match("/((http[s]?:\/\/)+((?>[a-z\-0-9]{2,}\.)+[a-z]{2,8}|((?>([0-9]{1,3}\.)){3}[0-9]{1,3}))(:[0-9]{1,5})?)(?:\s|\/)/i", $url)) {
$chkHost = parse_url(strtolower($url), PHP_URL_HOST);
if ($chkHost && in_array($chkHost, $allowedHostArr)) {
return true;
}
}
return false;
}
}
if (!function_exists('build_suffix_image')) { if (!function_exists('build_suffix_image')) {
/** /**
* 生成文件后缀图片 * 生成文件后缀图片

View File

@ -9,12 +9,6 @@ use think\Loader;
class Common class Common
{ {
public function appInit()
{
$allowLangList = Config::get('allow_lang_list') ?? ['zh-cn', 'en'];
Lang::setAllowLangList($allowLangList);
}
public function appDispatch(&$dispatch) public function appDispatch(&$dispatch)
{ {
$pathinfoArr = explode('/', request()->pathinfo()); $pathinfoArr = explode('/', request()->pathinfo());
@ -62,11 +56,8 @@ class Common
Config::set('app_trace', false); Config::set('app_trace', false);
} }
// 切换多语言 // 切换多语言
if (Config::get('lang_switch_on')) { if (Config::get('lang_switch_on') && $request->get('lang')) {
$lang = $request->get('lang', ''); \think\Cookie::set('think_var', $request->get('lang'));
if (preg_match("/^([a-zA-Z\-_]{2,10})\$/i", $lang)) {
\think\Cookie::set('think_var', $lang);
}
} }
// Form别名 // Form别名
if (!class_exists('Form')) { if (!class_exists('Form')) {
@ -77,10 +68,8 @@ class Common
public function addonBegin(&$request) public function addonBegin(&$request)
{ {
// 加载插件语言包 // 加载插件语言包
$lang = request()->langset();
$lang = preg_match("/^([a-zA-Z\-_]{2,10})\$/i", $lang) ? $lang : 'zh-cn';
Lang::load([ Lang::load([
APP_PATH . 'common' . DS . 'lang' . DS . $lang . DS . 'addon' . EXT, APP_PATH . 'common' . DS . 'lang' . DS . $request->langset() . DS . 'addon' . EXT,
]); ]);
$this->moduleInit($request); $this->moduleInit($request);
} }

View File

@ -153,10 +153,7 @@ class Api
protected function loadlang($name) protected function loadlang($name)
{ {
$name = Loader::parseName($name); $name = Loader::parseName($name);
$name = preg_match("/^([a-zA-Z0-9_\.\/]+)\$/i", $name) ? $name : 'index'; Lang::load(APP_PATH . $this->request->module() . '/lang/' . $this->request->langset() . '/' . str_replace('.', '/', $name) . '.php');
$lang = $this->request->langset();
$lang = preg_match("/^([a-zA-Z\-_]{2,10})\$/i", $lang) ? $lang : 'zh-cn';
Lang::load(APP_PATH . $this->request->module() . '/lang/' . $lang . '/' . str_replace('.', '/', $name) . '.php');
} }
/** /**
@ -204,8 +201,8 @@ class Api
'time' => Request::instance()->server('REQUEST_TIME'), 'time' => Request::instance()->server('REQUEST_TIME'),
'data' => $data, 'data' => $data,
]; ];
// 如果未设置类型则使用默认类型判断 // 如果未设置类型则自动判断
$type = $type ? : $this->responseType; $type = $type ? $type : ($this->request->param(config('var_jsonp_handler')) ? 'jsonp' : $this->responseType);
if (isset($header['statuscode'])) { if (isset($header['statuscode'])) {
$code = $header['statuscode']; $code = $header['statuscode'];

View File

@ -123,10 +123,10 @@ class Backend extends Controller
$path = str_replace('.', '/', $controllername) . '/' . $actionname; $path = str_replace('.', '/', $controllername) . '/' . $actionname;
// 定义是否Addtabs请求 // 定义是否Addtabs请求
!defined('IS_ADDTABS') && define('IS_ADDTABS', (bool)input("addtabs")); !defined('IS_ADDTABS') && define('IS_ADDTABS', input("addtabs") ? true : false);
// 定义是否Dialog请求 // 定义是否Dialog请求
!defined('IS_DIALOG') && define('IS_DIALOG', (bool)input("dialog")); !defined('IS_DIALOG') && define('IS_DIALOG', input("dialog") ? true : false);
// 定义是否AJAX请求 // 定义是否AJAX请求
!defined('IS_AJAX') && define('IS_AJAX', $this->request->isAjax()); !defined('IS_AJAX') && define('IS_AJAX', $this->request->isAjax());
@ -190,8 +190,7 @@ class Backend extends Controller
} }
// 语言检测 // 语言检测
$lang = $this->request->langset(); $lang = strip_tags($this->request->langset());
$lang = preg_match("/^([a-zA-Z\-_]{2,10})\$/i", $lang) ? $lang : 'zh-cn';
$site = Config::get("site"); $site = Config::get("site");
@ -237,10 +236,7 @@ class Backend extends Controller
protected function loadlang($name) protected function loadlang($name)
{ {
$name = Loader::parseName($name); $name = Loader::parseName($name);
$name = preg_match("/^([a-zA-Z0-9_\.\/]+)\$/i", $name) ? $name : 'index'; Lang::load(APP_PATH . $this->request->module() . '/lang/' . $this->request->langset() . '/' . str_replace('.', '/', $name) . '.php');
$lang = $this->request->langset();
$lang = preg_match("/^([a-zA-Z\-_]{2,10})\$/i", $lang) ? $lang : 'zh-cn';
Lang::load(APP_PATH . $this->request->module() . '/lang/' . $lang . '/' . str_replace('.', '/', $name) . '.php');
} }
/** /**
@ -268,13 +264,12 @@ class Backend extends Controller
$op = $this->request->get("op", '', 'trim'); $op = $this->request->get("op", '', 'trim');
$sort = $this->request->get("sort", !empty($this->model) && $this->model->getPk() ? $this->model->getPk() : 'id'); $sort = $this->request->get("sort", !empty($this->model) && $this->model->getPk() ? $this->model->getPk() : 'id');
$order = $this->request->get("order", "DESC"); $order = $this->request->get("order", "DESC");
$offset = max(0, $this->request->get("offset/d", 0)); $offset = $this->request->get("offset/d", 0);
$limit = max(0, $this->request->get("limit/d", 0)); $limit = $this->request->get("limit/d", 999999);
$limit = $limit ?: 999999;
//新增自动计算页码 //新增自动计算页码
$page = $limit ? intval($offset / $limit) + 1 : 1; $page = $limit ? intval($offset / $limit) + 1 : 1;
if ($this->request->has("page")) { if ($this->request->has("page")) {
$page = max(0, $this->request->get("page/d", 1)); $page = $this->request->get("page/d", 1);
} }
$this->request->get([config('paginate.var_page') => $page]); $this->request->get([config('paginate.var_page') => $page]);
$filter = (array)json_decode($filter, true); $filter = (array)json_decode($filter, true);
@ -285,7 +280,7 @@ class Backend extends Controller
$bind = []; $bind = [];
$name = ''; $name = '';
$aliasName = ''; $aliasName = '';
if (!empty($this->model) && $relationSearch) { if (!empty($this->model) && $this->relationSearch) {
$name = $this->model->getTable(); $name = $this->model->getTable();
$alias[$name] = Loader::parseName(basename(str_replace('\\', '/', get_class($this->model)))); $alias[$name] = Loader::parseName(basename(str_replace('\\', '/', get_class($this->model))));
$aliasName = $alias[$name] . '.'; $aliasName = $alias[$name] . '.';
@ -313,12 +308,12 @@ class Backend extends Controller
if (!preg_match('/^[a-zA-Z0-9_\-\.]+$/', $k)) { if (!preg_match('/^[a-zA-Z0-9_\-\.]+$/', $k)) {
continue; continue;
} }
$sym = $op[$k] ?? '='; $sym = isset($op[$k]) ? $op[$k] : '=';
if (stripos($k, ".") === false) { if (stripos($k, ".") === false) {
$k = $aliasName . $k; $k = $aliasName . $k;
} }
$v = !is_array($v) ? trim($v) : $v; $v = !is_array($v) ? trim($v) : $v;
$sym = strtoupper($op[$k] ?? $sym); $sym = strtoupper(isset($op[$k]) ? $op[$k] : $sym);
//null和空字符串特殊处理 //null和空字符串特殊处理
if (!is_array($v)) { if (!is_array($v)) {
if (in_array(strtoupper($v), ['NULL', 'NOT NULL'])) { if (in_array(strtoupper($v), ['NULL', 'NOT NULL'])) {
@ -367,7 +362,7 @@ class Backend extends Controller
case 'BETWEEN': case 'BETWEEN':
case 'NOT BETWEEN': case 'NOT BETWEEN':
$arr = array_slice(explode(',', $v), 0, 2); $arr = array_slice(explode(',', $v), 0, 2);
if (stripos($v, ',') === false || !array_filter($arr, function ($v) { if (stripos($v, ',') === false || !array_filter($arr, function($v){
return $v != '' && $v !== false && $v !== null; return $v != '' && $v !== false && $v !== null;
})) { })) {
continue 2; continue 2;
@ -398,8 +393,7 @@ class Backend extends Controller
$arr = $arr[0]; $arr = $arr[0];
} }
$tableArr = explode('.', $k); $tableArr = explode('.', $k);
if (count($tableArr) > 1 && $tableArr[0] != $name && !in_array($tableArr[0], $alias) if (count($tableArr) > 1 && $tableArr[0] != $name && !in_array($tableArr[0], $alias) && !empty($this->model)) {
&& !empty($this->model) && $this->relationSearch) {
//修复关联模型下时间无法搜索的BUG //修复关联模型下时间无法搜索的BUG
$relation = Loader::parseName($tableArr[0], 1, false); $relation = Loader::parseName($tableArr[0], 1, false);
$alias[$this->model->$relation()->getTable()] = $tableArr[0]; $alias[$this->model->$relation()->getTable()] = $tableArr[0];
@ -570,8 +564,8 @@ class Backend extends Controller
unset($item['password'], $item['salt']); unset($item['password'], $item['salt']);
if ($this->selectpageFields == '*') { if ($this->selectpageFields == '*') {
$result = [ $result = [
$primarykey => $item[$primarykey] ?? '', $primarykey => isset($item[$primarykey]) ? $item[$primarykey] : '',
$field => $item[$field] ?? '', $field => isset($item[$field]) ? $item[$field] : '',
]; ];
} else { } else {
$result = array_intersect_key(($item instanceof Model ? $item->toArray() : (array)$item), array_flip($fields)); $result = array_intersect_key(($item instanceof Model ? $item->toArray() : (array)$item), array_flip($fields));

View File

@ -88,8 +88,7 @@ class Frontend extends Controller
$this->view->assign('user', $this->auth->getUser()); $this->view->assign('user', $this->auth->getUser());
// 语言检测 // 语言检测
$lang = $this->request->langset(); $lang = strip_tags($this->request->langset());
$lang = preg_match("/^([a-zA-Z\-_]{2,10})\$/i", $lang) ? $lang : 'zh-cn';
$site = Config::get("site"); $site = Config::get("site");
@ -127,11 +126,8 @@ class Frontend extends Controller
*/ */
protected function loadlang($name) protected function loadlang($name)
{ {
$name = Loader::parseName($name); $name = Loader::parseName($name);
$name = preg_match("/^([a-zA-Z0-9_\.\/]+)\$/i", $name) ? $name : 'index'; Lang::load(APP_PATH . $this->request->module() . '/lang/' . $this->request->langset() . '/' . str_replace('.', '/', $name) . '.php');
$lang = $this->request->langset();
$lang = preg_match("/^([a-zA-Z\-_]{2,10})\$/i", $lang) ? $lang : 'zh-cn';
Lang::load(APP_PATH . $this->request->module() . '/lang/' . $lang . '/' . str_replace('.', '/', $name) . '.php');
} }
/** /**

View File

@ -164,7 +164,7 @@ class Auth
'avatar' => '', 'avatar' => '',
]; ];
$params = array_merge($data, [ $params = array_merge($data, [
'nickname' => preg_match("/^1[3-9]{1}\d{9}$/", $username) ? substr_replace($username, '****', 3, 4) : $username, 'nickname' => preg_match("/^1[3-9]{1}\d{9}$/",$username) ? substr_replace($username,'****',3,4) : $username,
'salt' => Random::alnum(), 'salt' => Random::alnum(),
'jointime' => $time, 'jointime' => $time,
'joinip' => $ip, 'joinip' => $ip,
@ -221,13 +221,7 @@ class Auth
$this->setError('Account is locked'); $this->setError('Account is locked');
return false; return false;
} }
if ($user->loginfailure >= 10 && time() - $user->loginfailuretime < 86400) {
$this->setError('Please try again after 1 day');
}
if ($user->password != $this->getEncryptPassword($password, $user->salt)) { if ($user->password != $this->getEncryptPassword($password, $user->salt)) {
$user->save(['loginfailure' => $user->loginfailure + 1, 'loginfailuretime' => time()]);
$this->setError('Password is incorrect'); $this->setError('Password is incorrect');
return false; return false;
} }
@ -362,7 +356,7 @@ class Auth
} }
$url = ($module ? $module : request()->module()) . '/' . (is_null($path) ? $this->getRequestUri() : $path); $url = ($module ? $module : request()->module()) . '/' . (is_null($path) ? $this->getRequestUri() : $path);
$url = strtolower(str_replace('.', '/', $url)); $url = strtolower(str_replace('.', '/', $url));
return in_array($url, $rules); return in_array($url, $rules) ? true : false;
} }
/** /**
@ -400,7 +394,7 @@ class Auth
/** /**
* 获取会员组别规则列表 * 获取会员组别规则列表
* @return array|bool|\PDOStatement|string|\think\Collection * @return array
*/ */
public function getRuleList() public function getRuleList()
{ {
@ -553,7 +547,7 @@ class Auth
} }
} }
foreach ($datalist as $k => &$v) { foreach ($datalist as $k => &$v) {
$v[$renderkey] = $list[$v[$fieldkey]] ?? null; $v[$renderkey] = isset($list[$v[$fieldkey]]) ? $list[$v[$fieldkey]] : null;
} }
unset($v); unset($v);
return $datalist; return $datalist;

View File

@ -60,7 +60,7 @@ class Email
} }
$this->options = array_merge($this->options, $options); $this->options = array_merge($this->options, $options);
$secureArr = [0 => '', 1 => 'tls', 2 => 'ssl']; $secureArr = [0 => '', 1 => 'tls', 2 => 'ssl'];
$secure = $secureArr[$this->options['mail_verify_type']] ?? ''; $secure = isset($secureArr[$this->options['mail_verify_type']]) ? $secureArr[$this->options['mail_verify_type']] : '';
$logger = isset($this->options['debug']) && $this->options['debug'] ? new Log : null; $logger = isset($this->options['debug']) && $this->options['debug'] ? new Log : null;
$this->mail = new Mailer($logger); $this->mail = new Mailer($logger);
@ -217,8 +217,8 @@ class Email
$this->setError($e->getCode() . $e->getMessage()); $this->setError($e->getCode() . $e->getMessage());
} catch (CodeException $e) { } catch (CodeException $e) {
preg_match_all("/Expected: (\d+)\, Got: (\d+)( \| (.*))?\$/i", $e->getMessage(), $matches); preg_match_all("/Expected: (\d+)\, Got: (\d+)( \| (.*))?\$/i", $e->getMessage(), $matches);
$code = $matches[2][0] ?? 0; $code = isset($matches[2][3]) ? $matches[2][3] : 0;
$message = isset($matches[2][0]) && isset($matches[4][0]) ? $matches[4][0] : $e->getMessage(); $message = isset($matches[2][0]) ? $matches[4][0] : $e->getMessage();
$message = mb_convert_encoding($message, 'UTF-8', 'GBK,GB2312,BIG5'); $message = mb_convert_encoding($message, 'UTF-8', 'GBK,GB2312,BIG5');
$this->setError($message); $this->setError($message);
} catch (\Exception $e) { } catch (\Exception $e) {

View File

@ -26,25 +26,26 @@ class Ems
/** /**
* 获取最后一次邮箱发送的数据 * 获取最后一次邮箱发送的数据
* *
* @param int $email 邮箱 * @param int $email 邮箱
* @param string $event 事件 * @param string $event 事件
* @return Ems|null * @return Ems
*/ */
public static function get($email, $event = 'default') public static function get($email, $event = 'default')
{ {
$ems = \app\common\model\Ems::where(['email' => $email, 'event' => $event]) $ems = \app\common\model\Ems::
where(['email' => $email, 'event' => $event])
->order('id', 'DESC') ->order('id', 'DESC')
->find(); ->find();
Hook::listen('ems_get', $ems, null, true); Hook::listen('ems_get', $ems, null, true);
return $ems ?: null; return $ems ? $ems : null;
} }
/** /**
* 发送验证码 * 发送验证码
* *
* @param int $email 邮箱 * @param int $email 邮箱
* @param int $code 验证码,为空时将自动生成4位数字 * @param int $code 验证码,为空时将自动生成4位数字
* @param string $event 事件 * @param string $event 事件
* @return boolean * @return boolean
*/ */
public static function send($email, $code = null, $event = 'default') public static function send($email, $code = null, $event = 'default')
@ -53,18 +54,6 @@ class Ems
$time = time(); $time = time();
$ip = request()->ip(); $ip = request()->ip();
$ems = \app\common\model\Ems::create(['event' => $event, 'email' => $email, 'code' => $code, 'ip' => $ip, 'createtime' => $time]); $ems = \app\common\model\Ems::create(['event' => $event, 'email' => $email, 'code' => $code, 'ip' => $ip, 'createtime' => $time]);
if (!Hook::get('ems_send')) {
//采用框架默认的邮件推送
Hook::add('ems_send', function ($params) {
$obj = new Email();
$result = $obj
->to($params->email)
->subject('请查收你的验证码!')
->message("你的验证码是:" . $params->code . "" . ceil(self::$expire / 60) . "分钟内有效。")
->send();
return $result;
});
}
$result = Hook::listen('ems_send', $ems, null, true); $result = Hook::listen('ems_send', $ems, null, true);
if (!$result) { if (!$result) {
$ems->delete(); $ems->delete();
@ -76,9 +65,9 @@ class Ems
/** /**
* 发送通知 * 发送通知
* *
* @param mixed $email 邮箱,多个以,分隔 * @param mixed $email 邮箱,多个以,分隔
* @param string $msg 消息内容 * @param string $msg 消息内容
* @param string $template 消息模板 * @param string $template 消息模板
* @return boolean * @return boolean
*/ */
public static function notice($email, $msg = '', $template = null) public static function notice($email, $msg = '', $template = null)
@ -88,29 +77,16 @@ class Ems
'msg' => $msg, 'msg' => $msg,
'template' => $template 'template' => $template
]; ];
if (!Hook::get('ems_notice')) {
//采用框架默认的邮件推送
Hook::add('ems_notice', function ($params) {
$subject = '你收到一封新的邮件!';
$content = $params['msg'];
$email = new Email();
$result = $email->to($params['email'])
->subject($subject)
->message($content)
->send();
return $result;
});
}
$result = Hook::listen('ems_notice', $params, null, true); $result = Hook::listen('ems_notice', $params, null, true);
return (bool)$result; return $result ? true : false;
} }
/** /**
* 校验验证码 * 校验验证码
* *
* @param int $email 邮箱 * @param int $email 邮箱
* @param int $code 验证码 * @param int $code 验证码
* @param string $event 事件 * @param string $event 事件
* @return boolean * @return boolean
*/ */
public static function check($email, $code, $event = 'default') public static function check($email, $code, $event = 'default')
@ -143,13 +119,14 @@ class Ems
/** /**
* 清空指定邮箱验证码 * 清空指定邮箱验证码
* *
* @param int $email 邮箱 * @param int $email 邮箱
* @param string $event 事件 * @param string $event 事件
* @return boolean * @return boolean
*/ */
public static function flush($email, $event = 'default') public static function flush($email, $event = 'default')
{ {
\app\common\model\Ems::where(['email' => $email, 'event' => $event]) \app\common\model\Ems::
where(['email' => $email, 'event' => $event])
->delete(); ->delete();
Hook::listen('ems_flush'); Hook::listen('ems_flush');
return true; return true;

View File

@ -14,9 +14,9 @@ class Log extends AbstractLogger
/** /**
* Logs with an arbitrary level. * Logs with an arbitrary level.
* *
* @param mixed $level * @param mixed $level
* @param string $message * @param string $message
* @param array $context * @param mixed[] $context
* *
* @return void * @return void
* *

View File

@ -100,7 +100,7 @@ class Menu
if ($ids) { if ($ids) {
//旧版本的菜单需要做删除处理 //旧版本的菜单需要做删除处理
$config = Service::config($name); $config = Service::config($name);
$menus = $config['menus'] ?? []; $menus = isset($config['menus']) ? $config['menus'] : [];
$where = ['id' => ['in', $ids]]; $where = ['id' => ['in', $ids]];
if ($menus) { if ($menus) {
//必须是旧版本中的菜单,可排除用户自主创建的菜单 //必须是旧版本中的菜单,可排除用户自主创建的菜单
@ -182,14 +182,14 @@ class Menu
} else { } else {
$pid = $parent; $pid = $parent;
} }
$allow = array_flip(['file', 'name', 'title', 'url', 'icon', 'condition', 'remark', 'ismenu', 'menutype', 'extend', 'weigh', 'status']); $allow = array_flip(['file', 'name', 'title', 'icon', 'condition', 'remark', 'ismenu', 'weigh']);
foreach ($newMenu as $k => $v) { foreach ($newMenu as $k => $v) {
$hasChild = isset($v['sublist']) && $v['sublist']; $hasChild = isset($v['sublist']) && $v['sublist'] ? true : false;
$data = array_intersect_key($v, $allow); $data = array_intersect_key($v, $allow);
$data['ismenu'] = $data['ismenu'] ?? ($hasChild ? 1 : 0); $data['ismenu'] = isset($data['ismenu']) ? $data['ismenu'] : ($hasChild ? 1 : 0);
$data['icon'] = $data['icon'] ?? ($hasChild ? 'fa fa-list' : 'fa fa-circle-o'); $data['icon'] = isset($data['icon']) ? $data['icon'] : ($hasChild ? 'fa fa-list' : 'fa fa-circle-o');
$data['pid'] = $pid; $data['pid'] = $pid;
$data['status'] = $data['status'] ?? 'normal'; $data['status'] = 'normal';
if (!isset($oldMenu[$data['name']])) { if (!isset($oldMenu[$data['name']])) {
$menu = AuthRule::create($data); $menu = AuthRule::create($data);
} else { } else {

View File

@ -16,6 +16,7 @@ use Exception;
*/ */
class Security class Security
{ {
protected static $instance = null; protected static $instance = null;
/** /**
@ -419,7 +420,7 @@ class Security
*/ */
public function get_random_bytes($length) public function get_random_bytes($length)
{ {
if (empty($length) or !ctype_digit((string)$length)) { if (empty($length) OR !ctype_digit((string)$length)) {
return false; return false;
} }
@ -484,8 +485,8 @@ class Security
static $_entities; static $_entities;
isset($charset) or $charset = $this->charset; isset($charset) OR $charset = $this->charset;
isset($_entities) or $_entities = array_map('strtolower', get_html_translation_table(HTML_ENTITIES, ENT_COMPAT | ENT_HTML5, $charset)); isset($_entities) OR $_entities = array_map('strtolower', get_html_translation_table(HTML_ENTITIES, ENT_COMPAT | ENT_HTML5, $charset));
do { do {
$str_compare = $str; $str_compare = $str;
@ -697,7 +698,7 @@ class Security
// Is it indeed an "evil" attribute? // Is it indeed an "evil" attribute?
preg_match($is_evil_pattern, $attribute['name'][0]) preg_match($is_evil_pattern, $attribute['name'][0])
// Or does it have an equals sign, but no value and not quoted? Strip that too! // Or does it have an equals sign, but no value and not quoted? Strip that too!
or (trim($attribute['value'][0]) === '') OR (trim($attribute['value'][0]) === '')
) { ) {
$attributes[] = 'xss=removed'; $attributes[] = 'xss=removed';
} else { } else {
@ -869,4 +870,5 @@ class Security
return $str; return $str;
} }
} }

View File

@ -32,11 +32,12 @@ class Sms
*/ */
public static function get($mobile, $event = 'default') public static function get($mobile, $event = 'default')
{ {
$sms = \app\common\model\Sms::where(['mobile' => $mobile, 'event' => $event]) $sms = \app\common\model\Sms::
where(['mobile' => $mobile, 'event' => $event])
->order('id', 'DESC') ->order('id', 'DESC')
->find(); ->find();
Hook::listen('sms_get', $sms, null, true); Hook::listen('sms_get', $sms, null, true);
return $sms ?: null; return $sms ? $sms : null;
} }
/** /**
@ -77,7 +78,7 @@ class Sms
'template' => $template 'template' => $template
]; ];
$result = Hook::listen('sms_notice', $params, null, true); $result = Hook::listen('sms_notice', $params, null, true);
return (bool)$result; return $result ? true : false;
} }
/** /**
@ -124,7 +125,8 @@ class Sms
*/ */
public static function flush($mobile, $event = 'default') public static function flush($mobile, $event = 'default')
{ {
\app\common\model\Sms::where(['mobile' => $mobile, 'event' => $event]) \app\common\model\Sms::
where(['mobile' => $mobile, 'event' => $event])
->delete(); ->delete();
Hook::listen('sms_flush'); Hook::listen('sms_flush');
return true; return true;

View File

@ -150,7 +150,7 @@ class Token
/** /**
* 清除Token * 清除Token
* @access public * @access public
* @param int $user_id 会员ID * @param int user_id 会员ID
* @return boolean * @return boolean
*/ */
public static function clear($user_id = null) public static function clear($user_id = null)

View File

@ -15,6 +15,7 @@ use think\Hook;
*/ */
class Upload class Upload
{ {
protected $merging = false; protected $merging = false;
protected $chunkDir = null; protected $chunkDir = null;
@ -129,8 +130,8 @@ class Upload
if (!$imgInfo || !isset($imgInfo[0]) || !isset($imgInfo[1])) { if (!$imgInfo || !isset($imgInfo[0]) || !isset($imgInfo[1])) {
throw new UploadException(__('Uploaded file is not a valid image')); throw new UploadException(__('Uploaded file is not a valid image'));
} }
$this->fileInfo['imagewidth'] = $imgInfo[0] ?? 0; $this->fileInfo['imagewidth'] = isset($imgInfo[0]) ? $imgInfo[0] : 0;
$this->fileInfo['imageheight'] = $imgInfo[1] ?? 0; $this->fileInfo['imageheight'] = isset($imgInfo[1]) ? $imgInfo[1] : 0;
return true; return true;
} else { } else {
return !$force; return !$force;
@ -147,13 +148,11 @@ class Upload
$size = $matches ? $matches[1] : $this->config['maxsize']; $size = $matches ? $matches[1] : $this->config['maxsize'];
$type = $matches ? strtolower($matches[2]) : 'b'; $type = $matches ? strtolower($matches[2]) : 'b';
$typeDict = ['b' => 0, 'k' => 1, 'kb' => 1, 'm' => 2, 'mb' => 2, 'gb' => 3, 'g' => 3]; $typeDict = ['b' => 0, 'k' => 1, 'kb' => 1, 'm' => 2, 'mb' => 2, 'gb' => 3, 'g' => 3];
$size = (int)($size * pow(1024, $typeDict[$type] ?? 0)); $size = (int)($size * pow(1024, isset($typeDict[$type]) ? $typeDict[$type] : 0));
if ($this->fileInfo['size'] > $size) { if ($this->fileInfo['size'] > $size) {
throw new UploadException(__( throw new UploadException(__('File is too big (%sMiB). Max filesize: %sMiB.',
'File is too big (%sMiB), Max filesize: %sMiB.',
round($this->fileInfo['size'] / pow(1024, 2), 2), round($this->fileInfo['size'] / pow(1024, 2), 2),
round($size / pow(1024, 2), 2) round($size / pow(1024, 2), 2)));
));
} }
} }
@ -168,41 +167,35 @@ class Upload
/** /**
* 获取存储的文件名 * 获取存储的文件名
* @param string $savekey 保存路径 * @param string $savekey
* @param string $filename 文件名 * @param string $filename
* @param string $md5 文件MD5 * @param string $md5
* @param string $category 分类
* @return mixed|null * @return mixed|null
*/ */
public function getSavekey($savekey = null, $filename = null, $md5 = null, $category = null) public function getSavekey($savekey = null, $filename = null, $md5 = null)
{ {
if ($filename) { if ($filename) {
$suffix = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); $suffix = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
$suffix = $suffix && preg_match("/^[a-zA-Z0-9]+$/", $suffix) ? $suffix : 'file';
} else { } else {
$suffix = $this->fileInfo['suffix'] ?? ''; $suffix = $this->fileInfo['suffix'];
} }
$suffix = $suffix && preg_match("/^[a-zA-Z0-9]+$/", $suffix) ? $suffix : 'file'; $filename = $filename ? $filename : ($suffix ? substr($this->fileInfo['name'], 0, strripos($this->fileInfo['name'], '.')) : $this->fileInfo['name']);
$filename = $filename ? $filename : ($this->fileInfo['name'] ?? 'unknown');
$filename = xss_clean(strip_tags(htmlspecialchars($filename))); $filename = xss_clean(strip_tags(htmlspecialchars($filename)));
$fileprefix = substr($filename, 0, strripos($filename, '.')); $md5 = $md5 ? $md5 : md5_file($this->fileInfo['tmp_name']);
$md5 = $md5 ? $md5 : (isset($this->fileInfo['tmp_name']) ? md5_file($this->fileInfo['tmp_name']) : '');
$category = $category ? $category : request()->post('category');
$category = $category ? xss_clean($category) : 'all';
$replaceArr = [ $replaceArr = [
'{year}' => date("Y"), '{year}' => date("Y"),
'{mon}' => date("m"), '{mon}' => date("m"),
'{day}' => date("d"), '{day}' => date("d"),
'{hour}' => date("H"), '{hour}' => date("H"),
'{min}' => date("i"), '{min}' => date("i"),
'{sec}' => date("s"), '{sec}' => date("s"),
'{random}' => Random::alnum(16), '{random}' => Random::alnum(16),
'{random32}' => Random::alnum(32), '{random32}' => Random::alnum(32),
'{category}' => $category ? $category : '', '{filename}' => substr($filename, 0, 100),
'{filename}' => substr($filename, 0, 100), '{suffix}' => $suffix,
'{fileprefix}' => substr($fileprefix, 0, 100), '{.suffix}' => $suffix ? '.' . $suffix : '',
'{suffix}' => $suffix, '{filemd5}' => $md5,
'{.suffix}' => $suffix ? '.' . $suffix : '',
'{filemd5}' => $md5,
]; ];
$savekey = $savekey ? $savekey : $this->config['savekey']; $savekey = $savekey ? $savekey : $this->config['savekey'];
$savekey = str_replace(array_keys($replaceArr), array_values($replaceArr), $savekey); $savekey = str_replace(array_keys($replaceArr), array_values($replaceArr), $savekey);
@ -305,7 +298,7 @@ class Upload
$attachment = $this->upload(); $attachment = $this->upload();
} catch (\Exception $e) { } catch (\Exception $e) {
@unlink($uploadPath); @unlink($destFile);
throw new UploadException($e->getMessage()); throw new UploadException($e->getMessage());
} }
return $attachment; return $attachment;
@ -317,6 +310,7 @@ class Upload
*/ */
public function chunk($chunkid, $chunkindex, $chunkcount, $chunkfilesize = null, $chunkfilename = null, $direct = false) public function chunk($chunkid, $chunkindex, $chunkcount, $chunkfilesize = null, $chunkfilename = null, $direct = false)
{ {
if ($this->fileInfo['type'] != 'application/octet-stream') { if ($this->fileInfo['type'] != 'application/octet-stream') {
throw new UploadException(__('Uploaded file format is limited')); throw new UploadException(__('Uploaded file format is limited'));
} }

View File

@ -76,7 +76,6 @@ abstract class Driver
protected function getEncryptedToken($token) protected function getEncryptedToken($token)
{ {
$config = \think\Config::get('token'); $config = \think\Config::get('token');
$token = $token ?? ''; // 为兼容 php8
return hash_hmac($config['hashalgo'], $token, $config['key']); return hash_hmac($config['hashalgo'], $token, $config['key']);
} }

View File

@ -60,7 +60,6 @@ class Redis extends Driver
protected function getEncryptedToken($token) protected function getEncryptedToken($token)
{ {
$config = \think\Config::get('token'); $config = \think\Config::get('token');
$token = $token ?? ''; // 为兼容 php8
return $this->options['tokenprefix'] . hash_hmac($config['hashalgo'], $token, $config['key']); return $this->options['tokenprefix'] . hash_hmac($config['hashalgo'], $token, $config['key']);
} }

View File

@ -22,8 +22,8 @@ class Area extends Model
{ {
$namearr = [1 => 'geo:province', 2 => 'geo:city', 3 => 'geo:district']; $namearr = [1 => 'geo:province', 2 => 'geo:city', 3 => 'geo:district'];
$rangearr = [1 => 15000, 2 => 1000, 3 => 200]; $rangearr = [1 => 15000, 2 => 1000, 3 => 200];
$geoname = $namearr[$level] ?? $namearr[3]; $geoname = isset($namearr[$level]) ? $namearr[$level] : $namearr[3];
$georange = $rangearr[$level] ?? $rangearr[3]; $georange = isset($rangearr[$level]) ? $rangearr[$level] : $rangearr[3];
// 读取范围内的ID // 读取范围内的ID
$redis = Cache::store('redis')->handler(); $redis = Cache::store('redis')->handler();
$georadiuslist = []; $georadiuslist = [];

View File

@ -24,9 +24,7 @@ class Category extends Model
protected static function init() protected static function init()
{ {
self::afterInsert(function ($row) { self::afterInsert(function ($row) {
if (!$row['weigh']) { $row->save(['weigh' => $row['id']]);
$row->save(['weigh' => $row['id']]);
}
}); });
} }
@ -52,7 +50,7 @@ class Category extends Model
{ {
$value = $value ? $value : $data['type']; $value = $value ? $value : $data['type'];
$list = $this->getTypeList(); $list = $this->getTypeList();
return $list[$value] ?? ''; return isset($list[$value]) ? $list[$value] : '';
} }
public function getFlagList() public function getFlagList()

View File

@ -115,8 +115,8 @@ class Config extends Model
$data = $result; $data = $result;
} }
$fieldarr = $valuearr = []; $fieldarr = $valuearr = [];
$field = $data['field'] ?? ($data['key'] ?? []); $field = isset($data['field']) ? $data['field'] : (isset($data['key']) ? $data['key'] : []);
$value = $data['value'] ?? []; $value = isset($data['value']) ? $data['value'] : [];
foreach ($field as $m => $n) { foreach ($field as $m => $n) {
if ($n != '') { if ($n != '') {
$fieldarr[] = $field[$m]; $fieldarr[] = $field[$m];
@ -175,7 +175,7 @@ class Config extends Model
if (!preg_match("/^((?:[a-z]+:)?\/\/)(.*)/i", $uploadurl) && substr($uploadurl, 0, 1) !== '/') { if (!preg_match("/^((?:[a-z]+:)?\/\/)(.*)/i", $uploadurl) && substr($uploadurl, 0, 1) !== '/') {
$uploadurl = url($uploadurl, '', false); $uploadurl = url($uploadurl, '', false);
} }
$uploadcfg['fullmode'] = isset($uploadcfg['fullmode']) && $uploadcfg['fullmode']; $uploadcfg['fullmode'] = isset($uploadcfg['fullmode']) && $uploadcfg['fullmode'] ? true : false;
$uploadcfg['thumbstyle'] = $uploadcfg['thumbstyle'] ?? ''; $uploadcfg['thumbstyle'] = $uploadcfg['thumbstyle'] ?? '';
$upload = [ $upload = [

Some files were not shown because too many files have changed in this diff Show More