1
This commit is contained in:
parent
e8605149c0
commit
61b6d603cd
11
.bowerrc
11
.bowerrc
@ -1,11 +0,0 @@
|
||||
{
|
||||
"directory": "public/assets/libs",
|
||||
"ignoredDependencies": [
|
||||
"es6-promise",
|
||||
"file-saver",
|
||||
"html2canvas",
|
||||
"jspdf",
|
||||
"jspdf-autotable",
|
||||
"pdfmake"
|
||||
]
|
||||
}
|
||||
11
.env.sample
11
.env.sample
@ -1,11 +0,0 @@
|
||||
[app]
|
||||
debug = false
|
||||
trace = false
|
||||
|
||||
[database]
|
||||
hostname = 127.0.0.1
|
||||
database = fastadmin
|
||||
username = root
|
||||
password = root
|
||||
hostport = 3306
|
||||
prefix = fa_
|
||||
23
.gitignore
vendored
23
.gitignore
vendored
@ -1,23 +0,0 @@
|
||||
/nbproject/
|
||||
/thinkphp/
|
||||
/vendor/
|
||||
/runtime/*
|
||||
/addons/*
|
||||
/public/assets/libs/
|
||||
/public/assets/addons/*
|
||||
/public/uploads/*
|
||||
.idea
|
||||
composer.lock
|
||||
*.log
|
||||
*.css.map
|
||||
!.gitkeep
|
||||
.env
|
||||
.svn
|
||||
.vscode
|
||||
node_modules
|
||||
.user.ini
|
||||
|
||||
# Node.js 本地辅助脚本(不做 git 跟踪)
|
||||
/package.json
|
||||
/package-lock.json
|
||||
/scripts/
|
||||
@ -1 +0,0 @@
|
||||
7nvtXkz8sBXPvilf8pgCFT92nB8BMSqJGE7QumvssGw.Uv4gmVNscdEPWr0XgQ5XqT5eSKxtyUHB8YlcxmaP-2A
|
||||
@ -1 +0,0 @@
|
||||
202502140336431i4wbaezjofs55ioi2gzn12k1o2j93etxgaopxrsuat4j51epd
|
||||
16
404.html
16
404.html
@ -1,16 +0,0 @@
|
||||
<html>
|
||||
<style>
|
||||
.btlink {
|
||||
color: #20a53a;
|
||||
text-decoration: none;
|
||||
}
|
||||
</style>
|
||||
<meta charset="UTF-8">
|
||||
<html>
|
||||
<head><title>404 Not Found</title></head>
|
||||
<body>
|
||||
<center><h1>404 Not Found</h1></center>
|
||||
<hr>
|
||||
<div style="text-align: center;font-size: 15px" >Power by <a class="btlink" href="https://www.bt.cn/?from=404" target="_blank">堡塔 (免费,高效和安全的托管控制面板)</a></div>
|
||||
</body>
|
||||
</html>
|
||||
191
LICENSE
191
LICENSE
@ -1,191 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction, and
|
||||
distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by the copyright
|
||||
owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all other entities
|
||||
that control, are controlled by, or are under common control with that entity.
|
||||
For the purposes of this definition, "control" means (i) the power, direct or
|
||||
indirect, to cause the direction or management of such entity, whether by
|
||||
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
||||
permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications, including
|
||||
but not limited to software source code, documentation source, and configuration
|
||||
files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical transformation or
|
||||
translation of a Source form, including but not limited to compiled object code,
|
||||
generated documentation, and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or Object form, made
|
||||
available under the License, as indicated by a copyright notice that is included
|
||||
in or attached to the work (an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object form, that
|
||||
is based on (or derived from) the Work and for which the editorial revisions,
|
||||
annotations, elaborations, or other modifications represent, as a whole, an
|
||||
original work of authorship. For the purposes of this License, Derivative Works
|
||||
shall not include works that remain separable from, or merely link (or bind by
|
||||
name) to the interfaces of, the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including the original version
|
||||
of the Work and any modifications or additions to that Work or Derivative Works
|
||||
thereof, that is intentionally submitted to Licensor for inclusion in the Work
|
||||
by the copyright owner or by an individual or Legal Entity authorized to submit
|
||||
on behalf of the copyright owner. For the purposes of this definition,
|
||||
"submitted" means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems, and
|
||||
issue tracking systems that are managed by, or on behalf of, the Licensor for
|
||||
the purpose of discussing and improving the Work, but excluding communication
|
||||
that is conspicuously marked or otherwise designated in writing by the copyright
|
||||
owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
|
||||
of whom a Contribution has been received by Licensor and subsequently
|
||||
incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License.
|
||||
|
||||
Subject to the terms and conditions of this License, each Contributor hereby
|
||||
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
||||
irrevocable copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the Work and such
|
||||
Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License.
|
||||
|
||||
Subject to the terms and conditions of this License, each Contributor hereby
|
||||
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
||||
irrevocable (except as stated in this section) patent license to make, have
|
||||
made, use, offer to sell, sell, import, and otherwise transfer the Work, where
|
||||
such license applies only to those patent claims licensable by such Contributor
|
||||
that are necessarily infringed by their Contribution(s) alone or by combination
|
||||
of their Contribution(s) with the Work to which such Contribution(s) was
|
||||
submitted. If You institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work or a
|
||||
Contribution incorporated within the Work constitutes direct or contributory
|
||||
patent infringement, then any patent licenses granted to You under this License
|
||||
for that Work shall terminate as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution.
|
||||
|
||||
You may reproduce and distribute copies of the Work or Derivative Works thereof
|
||||
in any medium, with or without modifications, and in Source or Object form,
|
||||
provided that You meet the following conditions:
|
||||
|
||||
You must give any other recipients of the Work or Derivative Works a copy of
|
||||
this License; and
|
||||
You must cause any modified files to carry prominent notices stating that You
|
||||
changed the files; and
|
||||
You must retain, in the Source form of any Derivative Works that You distribute,
|
||||
all copyright, patent, trademark, and attribution notices from the Source form
|
||||
of the Work, excluding those notices that do not pertain to any part of the
|
||||
Derivative Works; and
|
||||
If the Work includes a "NOTICE" text file as part of its distribution, then any
|
||||
Derivative Works that You distribute must include a readable copy of the
|
||||
attribution notices contained within such NOTICE file, excluding those notices
|
||||
that do not pertain to any part of the Derivative Works, in at least one of the
|
||||
following places: within a NOTICE text file distributed as part of the
|
||||
Derivative Works; within the Source form or documentation, if provided along
|
||||
with the Derivative Works; or, within a display generated by the Derivative
|
||||
Works, if and wherever such third-party notices normally appear. The contents of
|
||||
the NOTICE file are for informational purposes only and do not modify the
|
||||
License. You may add Your own attribution notices within Derivative Works that
|
||||
You distribute, alongside or as an addendum to the NOTICE text from the Work,
|
||||
provided that such additional attribution notices cannot be construed as
|
||||
modifying the License.
|
||||
You may add Your own copyright statement to Your modifications and may provide
|
||||
additional or different license terms and conditions for use, reproduction, or
|
||||
distribution of Your modifications, or for any such Derivative Works as a whole,
|
||||
provided Your use, reproduction, and distribution of the Work otherwise complies
|
||||
with the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions.
|
||||
|
||||
Unless You explicitly state otherwise, any Contribution intentionally submitted
|
||||
for inclusion in the Work by You to the Licensor shall be under the terms and
|
||||
conditions of this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify the terms of
|
||||
any separate license agreement you may have executed with Licensor regarding
|
||||
such Contributions.
|
||||
|
||||
6. Trademarks.
|
||||
|
||||
This License does not grant permission to use the trade names, trademarks,
|
||||
service marks, or product names of the Licensor, except as required for
|
||||
reasonable and customary use in describing the origin of the Work and
|
||||
reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty.
|
||||
|
||||
Unless required by applicable law or agreed to in writing, Licensor provides the
|
||||
Work (and each Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
|
||||
including, without limitation, any warranties or conditions of TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
|
||||
solely responsible for determining the appropriateness of using or
|
||||
redistributing the Work and assume any risks associated with Your exercise of
|
||||
permissions under this License.
|
||||
|
||||
8. Limitation of Liability.
|
||||
|
||||
In no event and under no legal theory, whether in tort (including negligence),
|
||||
contract, or otherwise, unless required by applicable law (such as deliberate
|
||||
and grossly negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special, incidental,
|
||||
or consequential damages of any character arising as a result of this License or
|
||||
out of the use or inability to use the Work (including but not limited to
|
||||
damages for loss of goodwill, work stoppage, computer failure or malfunction, or
|
||||
any and all other commercial damages or losses), even if such Contributor has
|
||||
been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability.
|
||||
|
||||
While redistributing the Work or Derivative Works thereof, You may choose to
|
||||
offer, and charge a fee for, acceptance of support, warranty, indemnity, or
|
||||
other liability obligations and/or rights consistent with this License. However,
|
||||
in accepting such obligations, You may act only on Your own behalf and on Your
|
||||
sole responsibility, not on behalf of any other Contributor, and only if You
|
||||
agree to indemnify, defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason of your
|
||||
accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work
|
||||
|
||||
To apply the Apache License to your work, attach the following boilerplate
|
||||
notice, with the fields enclosed by brackets "{}" replaced with your own
|
||||
identifying information. (Don't include the brackets!) The text should be
|
||||
enclosed in the appropriate comment syntax for the file format. We also
|
||||
recommend that a file or class name and description of purpose be included on
|
||||
the same "printed page" as the copyright notice for easier identification within
|
||||
third-party archives.
|
||||
|
||||
Copyright 2017 Karson
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
97
README.md
97
README.md
@ -1,97 +0,0 @@
|
||||
FastAdmin是一款基于ThinkPHP+Bootstrap的极速后台开发框架。
|
||||
|
||||
|
||||
## 主要特性
|
||||
|
||||
* 基于`Auth`验证的权限管理系统
|
||||
* 支持无限级父子级权限继承,父级的管理员可任意增删改子级管理员及权限设置
|
||||
* 支持单管理员多角色
|
||||
* 支持管理子级数据或个人数据
|
||||
* 强大的一键生成功能
|
||||
* 一键生成CRUD,包括控制器、模型、视图、JS、语言包、菜单、回收站等
|
||||
* 一键压缩打包JS和CSS文件,一键CDN静态资源部署
|
||||
* 一键生成控制器菜单和规则
|
||||
* 一键生成API接口文档
|
||||
* 完善的前端功能组件开发
|
||||
* 基于`AdminLTE`二次开发
|
||||
* 基于`Bootstrap`开发,自适应手机、平板、PC
|
||||
* 基于`RequireJS`进行JS模块管理,按需加载
|
||||
* 基于`Less`进行样式开发
|
||||
* 强大的插件扩展功能,在线安装卸载升级插件
|
||||
* 通用的会员模块和API模块
|
||||
* 共用同一账号体系的Web端会员中心权限验证和API接口会员权限验证
|
||||
* 二级域名部署支持,同时域名支持绑定到应用插件
|
||||
* 多语言支持,服务端及客户端支持
|
||||
* 支持大文件分片上传、剪切板粘贴上传、拖拽上传,进度条显示,图片上传前压缩
|
||||
* 支持表格固定列、固定表头、跨页选择、Excel导出、模板渲染等功能
|
||||
* 强大的第三方应用模块支持([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、又拍云)功能,支持云储存分片上传
|
||||
* 第三方富文本编辑器支持(Summernote、Kindeditor、百度编辑器)
|
||||
* 第三方登录(QQ、微信、微博)整合
|
||||
* 第三方支付(微信、支付宝)无缝整合,微信支持PC端扫码支付
|
||||
* 丰富的插件应用市场
|
||||
|
||||
## 安装使用
|
||||
|
||||
https://doc.fastadmin.net
|
||||
|
||||
## 在线演示
|
||||
|
||||
https://demo.fastadmin.net
|
||||
|
||||
用户名:admin
|
||||
|
||||
密 码:123456
|
||||
|
||||
提 示:演示站数据无法进行修改,请下载源码安装体验全部功能
|
||||
|
||||
## 界面截图
|
||||

|
||||
|
||||
## 问题反馈
|
||||
|
||||
在使用中有任何问题,请使用以下联系方式联系我们
|
||||
|
||||
交流社区: https://ask.fastadmin.net
|
||||
|
||||
QQ 1 群(满)、QQ 2 群(满)、QQ 3 群(满)、QQ 4 群(满)、QQ 5 群(满)、QQ 6 群(满)、[QQ 7 群](https://www.fastadmin.net/goto/qun)。
|
||||
|
||||
Github: https://github.com/karsonzhang/fastadmin
|
||||
|
||||
Gitee: https://gitee.com/karson/fastadmin
|
||||
|
||||
## 特别鸣谢
|
||||
|
||||
感谢以下的项目,排名不分先后
|
||||
|
||||
ThinkPHP:http://www.thinkphp.cn
|
||||
|
||||
AdminLTE:https://adminlte.io
|
||||
|
||||
Bootstrap:http://getbootstrap.com
|
||||
|
||||
jQuery:http://jquery.com
|
||||
|
||||
Bootstrap-table:https://github.com/wenzhixin/bootstrap-table
|
||||
|
||||
Nice-validator: https://validator.niceue.com
|
||||
|
||||
SelectPage: https://github.com/TerryZ/SelectPage
|
||||
|
||||
Layer: https://layuion.com/layer/
|
||||
|
||||
DropzoneJS: https://www.dropzonejs.com
|
||||
|
||||
|
||||
## 版权信息
|
||||
|
||||
FastAdmin遵循Apache2开源协议发布,并提供免费使用。
|
||||
|
||||
本项目包含的第三方源码和二进制文件之版权信息另行标注。
|
||||
|
||||
版权所有Copyright © 2017-2022 by FastAdmin (https://www.fastadmin.net)
|
||||
|
||||
All rights reserved。
|
||||
@ -1 +0,0 @@
|
||||
|
||||
@ -1,349 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2016 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: liu21st <liu21st@gmail.com>
|
||||
// +----------------------------------------------------------------------
|
||||
use think\Env;
|
||||
|
||||
return [
|
||||
// +----------------------------------------------------------------------
|
||||
// | 应用设置
|
||||
// +----------------------------------------------------------------------
|
||||
// 应用命名空间
|
||||
'app_namespace' => 'app',
|
||||
// 应用调试模式
|
||||
'app_debug' => Env::get('app.debug', true),
|
||||
// 应用Trace
|
||||
'app_trace' => Env::get('app.trace', false),
|
||||
// 应用模式状态
|
||||
'app_status' => '',
|
||||
// 是否支持多模块
|
||||
'app_multi_module' => true,
|
||||
// 入口自动绑定模块
|
||||
'auto_bind_module' => false,
|
||||
// 注册的根命名空间
|
||||
'root_namespace' => [],
|
||||
// 扩展函数文件
|
||||
'extra_file_list' => [THINK_PATH . 'helper' . EXT],
|
||||
// 默认输出类型
|
||||
'default_return_type' => 'html',
|
||||
// 默认AJAX 数据返回格式,可选json xml ...
|
||||
'default_ajax_return' => 'json',
|
||||
// 默认JSONP格式返回的处理方法
|
||||
'default_jsonp_handler' => 'jsonpReturn',
|
||||
// 默认JSONP处理方法
|
||||
'var_jsonp_handler' => 'callback',
|
||||
// 默认时区
|
||||
'default_timezone' => 'PRC',
|
||||
// 是否开启多语言
|
||||
'lang_switch_on' => true,
|
||||
// 默认全局过滤方法 用逗号分隔多个
|
||||
'default_filter' => '',
|
||||
// 默认语言
|
||||
'default_lang' => 'zh-cn',
|
||||
// 允许的语言列表
|
||||
'allow_lang_list' => ['zh-cn', 'en'],
|
||||
// 应用类库后缀
|
||||
'class_suffix' => false,
|
||||
// 控制器类后缀
|
||||
'controller_suffix' => false,
|
||||
// 获取IP的变量
|
||||
'http_agent_ip' => 'REMOTE_ADDR',
|
||||
// +----------------------------------------------------------------------
|
||||
// | 模块设置
|
||||
// +----------------------------------------------------------------------
|
||||
// 默认模块名
|
||||
'default_module' => 'index',
|
||||
// 禁止访问模块
|
||||
'deny_module_list' => ['common', 'admin'],
|
||||
// 默认控制器名
|
||||
'default_controller' => 'Index',
|
||||
// 默认操作名
|
||||
'default_action' => 'index',
|
||||
// 默认验证器
|
||||
'default_validate' => '',
|
||||
// 默认的空控制器名
|
||||
'empty_controller' => 'Error',
|
||||
// 操作方法后缀
|
||||
'action_suffix' => '',
|
||||
// 自动搜索控制器
|
||||
'controller_auto_search' => true,
|
||||
// +----------------------------------------------------------------------
|
||||
// | URL设置
|
||||
// +----------------------------------------------------------------------
|
||||
// PATHINFO变量名 用于兼容模式
|
||||
'var_pathinfo' => 's',
|
||||
// 兼容PATH_INFO获取
|
||||
'pathinfo_fetch' => ['ORIG_PATH_INFO', 'REDIRECT_PATH_INFO', 'REDIRECT_URL'],
|
||||
// pathinfo分隔符
|
||||
'pathinfo_depr' => '/',
|
||||
// URL伪静态后缀
|
||||
'url_html_suffix' => 'html',
|
||||
// URL普通方式参数 用于自动生成
|
||||
'url_common_param' => false,
|
||||
// URL参数方式 0 按名称成对解析 1 按顺序解析
|
||||
'url_param_type' => 0,
|
||||
// 是否开启路由
|
||||
'url_route_on' => true,
|
||||
// 路由使用完整匹配
|
||||
'route_complete_match' => false,
|
||||
// 路由配置文件(支持配置多个)
|
||||
'route_config_file' => ['route'],
|
||||
// 是否强制使用路由
|
||||
'url_route_must' => false,
|
||||
// 域名部署
|
||||
'url_domain_deploy' => false,
|
||||
// 域名根,如thinkphp.cn
|
||||
'url_domain_root' => '',
|
||||
// 是否自动转换URL中的控制器和操作名
|
||||
'url_convert' => true,
|
||||
// 默认的访问控制器层
|
||||
'url_controller_layer' => 'controller',
|
||||
// 表单请求类型伪装变量
|
||||
'var_method' => '_method',
|
||||
// 表单ajax伪装变量
|
||||
'var_ajax' => '_ajax',
|
||||
// 表单pjax伪装变量
|
||||
'var_pjax' => '_pjax',
|
||||
// 是否开启请求缓存 true自动缓存 支持设置请求缓存规则
|
||||
'request_cache' => false,
|
||||
// 请求缓存有效期
|
||||
'request_cache_expire' => null,
|
||||
// +----------------------------------------------------------------------
|
||||
// | 模板设置
|
||||
// +----------------------------------------------------------------------
|
||||
'template' => [
|
||||
// 模板引擎类型 支持 php think 支持扩展
|
||||
'type' => 'Think',
|
||||
// 模板路径
|
||||
'view_path' => '',
|
||||
// 模板后缀
|
||||
'view_suffix' => 'html',
|
||||
// 模板文件名分隔符
|
||||
'view_depr' => DS,
|
||||
// 模板引擎普通标签开始标记
|
||||
'tpl_begin' => '{',
|
||||
// 模板引擎普通标签结束标记
|
||||
'tpl_end' => '}',
|
||||
// 标签库标签开始标记
|
||||
'taglib_begin' => '{',
|
||||
// 标签库标签结束标记
|
||||
'taglib_end' => '}',
|
||||
'tpl_cache' => true,
|
||||
],
|
||||
// 视图输出字符串内容替换,留空则会自动进行计算
|
||||
'view_replace_str' => [
|
||||
'__PUBLIC__' => '',
|
||||
'__ROOT__' => '',
|
||||
'__CDN__' => '',
|
||||
],
|
||||
// 默认跳转页面对应的模板文件
|
||||
'dispatch_success_tmpl' => APP_PATH . 'common' . DS . 'view' . DS . 'tpl' . DS . 'dispatch_jump.tpl',
|
||||
'dispatch_error_tmpl' => APP_PATH . 'common' . DS . 'view' . DS . 'tpl' . DS . 'dispatch_jump.tpl',
|
||||
// +----------------------------------------------------------------------
|
||||
// | 异常及错误设置
|
||||
// +----------------------------------------------------------------------
|
||||
// 异常页面的模板文件
|
||||
'exception_tmpl' => APP_PATH . 'common' . DS . 'view' . DS . 'tpl' . DS . 'think_exception.tpl',
|
||||
// 错误显示信息,非调试模式有效
|
||||
'error_message' => '你所浏览的页面暂时无法访问',
|
||||
// 显示错误信息
|
||||
'show_error_msg' => false,
|
||||
// 异常处理handle类 留空使用 \think\exception\Handle
|
||||
'exception_handle' => '',
|
||||
// +----------------------------------------------------------------------
|
||||
// | 日志设置
|
||||
// +----------------------------------------------------------------------
|
||||
'log' => [
|
||||
// 日志记录方式,内置 file socket 支持扩展
|
||||
'type' => 'File',
|
||||
// 日志保存目录
|
||||
'path' => LOG_PATH,
|
||||
// 日志记录级别
|
||||
'level' => ['error', 'sql', 'notice','info'],
|
||||
],
|
||||
// +----------------------------------------------------------------------
|
||||
// | Trace设置 开启 app_trace 后 有效
|
||||
// +----------------------------------------------------------------------
|
||||
'trace' => [
|
||||
// 内置Html Console 支持扩展
|
||||
'type' => 'Html',
|
||||
],
|
||||
// +----------------------------------------------------------------------
|
||||
// | 缓存设置
|
||||
// +----------------------------------------------------------------------
|
||||
'cache' => [
|
||||
// 驱动方式
|
||||
'type' => 'redis',
|
||||
// 缓存保存目录
|
||||
'path' => CACHE_PATH,
|
||||
// 缓存前缀
|
||||
'prefix' => 'site:system:',
|
||||
// 缓存有效期 0表示永久缓存
|
||||
'expire' => 0,
|
||||
'redis' => [
|
||||
// 驱动方式
|
||||
'type' => 'Redis',
|
||||
// 服务器地址
|
||||
'host' => '127.0.0.1',
|
||||
'port' => 6379,
|
||||
'password' => 'qwe2019@',
|
||||
'select' => 0,
|
||||
],
|
||||
],
|
||||
// +----------------------------------------------------------------------
|
||||
// | 会话设置
|
||||
// +----------------------------------------------------------------------
|
||||
'session' => [
|
||||
'id' => '',
|
||||
// SESSION_ID的提交变量,解决flash上传跨域
|
||||
'var_session_id' => '',
|
||||
// SESSION 前缀
|
||||
'prefix' => 'think',
|
||||
// 驱动方式 支持redis memcache memcached
|
||||
'type' => '',
|
||||
// 是否自动开启 SESSION
|
||||
'auto_start' => true,
|
||||
//'cache_limiter'=>''
|
||||
],
|
||||
// +----------------------------------------------------------------------
|
||||
// | Cookie设置
|
||||
// +----------------------------------------------------------------------
|
||||
'cookie' => [
|
||||
// cookie 名称前缀
|
||||
'prefix' => '',
|
||||
// cookie 保存时间
|
||||
'expire' => 0,
|
||||
// cookie 保存路径
|
||||
'path' => '/',
|
||||
// cookie 有效域名
|
||||
'domain' => '',
|
||||
// cookie 启用安全传输
|
||||
'secure' => false,
|
||||
// httponly设置
|
||||
'httponly' => '',
|
||||
// 是否使用 setcookie
|
||||
'setcookie' => true,
|
||||
],
|
||||
//分页配置
|
||||
'paginate' => [
|
||||
'type' => 'bootstrap',
|
||||
'var_page' => 'page',
|
||||
'list_rows' => 15,
|
||||
],
|
||||
//验证码配置
|
||||
'captcha' => [
|
||||
// 验证码字符集合
|
||||
'codeSet' => '2345678abcdefhijkmnpqrstuvwxyzABCDEFGHJKLMNPQRTUVWXY',
|
||||
// 验证码字体大小(px)
|
||||
'fontSize' => 18,
|
||||
// 是否画混淆曲线
|
||||
'useCurve' => false,
|
||||
//使用中文验证码
|
||||
'useZh' => false,
|
||||
// 验证码图片高度
|
||||
'imageH' => 40,
|
||||
// 验证码图片宽度
|
||||
'imageW' => 130,
|
||||
// 验证码位数
|
||||
'length' => 4,
|
||||
// 验证成功后是否重置
|
||||
'reset' => true
|
||||
],
|
||||
// +----------------------------------------------------------------------
|
||||
// | Token设置
|
||||
// +----------------------------------------------------------------------
|
||||
'token' => [
|
||||
// 驱动方式
|
||||
'type' => 'Mysql',
|
||||
// 缓存前缀
|
||||
'key' => 'OvnBYj9l6sEAHmWaRILgucVJd582GyKZ',
|
||||
// 加密方式
|
||||
'hashalgo' => 'ripemd160',
|
||||
// 缓存有效期 0表示永久缓存
|
||||
'expire' => 0,
|
||||
],
|
||||
//FastAdmin配置
|
||||
'fastadmin' => [
|
||||
//是否开启前台会员中心
|
||||
'usercenter' => true,
|
||||
//会员注册验证码类型email/mobile/wechat/text/false
|
||||
'user_register_captcha' => 'text',
|
||||
//登录验证码
|
||||
'login_captcha' => true,
|
||||
//登录失败超过10次则1天后重试
|
||||
'login_failure_retry' => true,
|
||||
//是否同一账号同一时间只能在一个地方登录
|
||||
'login_unique' => false,
|
||||
//是否开启IP变动检测
|
||||
'loginip_check' => false,
|
||||
//登录页默认背景图
|
||||
'login_background' => "",
|
||||
//是否启用多级菜单导航
|
||||
'multiplenav' => false,
|
||||
//是否开启多选项卡(仅在开启多级菜单时起作用)
|
||||
'multipletab' => true,
|
||||
//是否默认展示子菜单
|
||||
'show_submenu' => false,
|
||||
//后台皮肤,为空时表示使用skin-black-blue
|
||||
'adminskin' => '',
|
||||
//后台是否启用面包屑
|
||||
'breadcrumb' => false,
|
||||
//是否允许未知来源的插件压缩包
|
||||
'unknownsources' => false,
|
||||
//插件启用禁用时是否备份对应的全局文件
|
||||
'backup_global_files' => true,
|
||||
//是否开启后台自动日志记录
|
||||
'auto_record_log' => true,
|
||||
//插件纯净模式,插件启用后是否删除插件目录的application、public和assets文件夹
|
||||
'addon_pure_mode' => true,
|
||||
//允许跨域的域名,多个以,分隔
|
||||
'cors_request_domain' => 'http://127.0.0.1:8203,http://ye4s.com,http://42.194.235.215:8203',
|
||||
//版本号
|
||||
'version' => '1.3.5.20221214',
|
||||
//API接口地址
|
||||
'api_url' => 'https://api.fastadmin.net',
|
||||
],
|
||||
'db_wms' => [
|
||||
// 数据库类型
|
||||
'type' => Env::get('database.type', 'mysql'),
|
||||
// 服务器地址
|
||||
'hostname' => Env::get('database.hostname', 'ye4s.com'),
|
||||
// 数据库名
|
||||
'database' => Env::get('database.database', 'ye4s'),
|
||||
// 数据库用户名
|
||||
'username' => Env::get('database.username', 'xiaowuge'),
|
||||
// 数据库密码
|
||||
'password' => Env::get('database.password', 'Xiaowuge@123456'),
|
||||
// 端口
|
||||
'hostport' => Env::get('database.hostport', '3306'),
|
||||
// 数据库编码默认采用 utf8mb4
|
||||
'charset' => Env::get('database.charset', 'utf8mb4'),
|
||||
// 数据库表前缀
|
||||
'prefix' => Env::get('database.prefix', 'yj_'),
|
||||
],
|
||||
'db_wms_new' => [
|
||||
// 数据库类型
|
||||
'type' => Env::get('database.type', 'mysql'),
|
||||
// 服务器地址
|
||||
'hostname' => Env::get('database.hostname', '127.0.0.1'),
|
||||
// 数据库名
|
||||
'database' => Env::get('database.database', 'wms'),
|
||||
// 数据库用户名
|
||||
'username' => Env::get('database.username', 'wms'),
|
||||
// 数据库密码
|
||||
'password' => Env::get('database.password', 'P6j3YTHTpirepYWz'),
|
||||
// 端口
|
||||
'hostport' => Env::get('database.hostport', '3306'),
|
||||
// 数据库编码默认采用 utf8mb4
|
||||
'charset' => Env::get('database.charset', 'utf8mb4'),
|
||||
// 数据库表前缀
|
||||
'prefix' => Env::get('database.prefix', 'wms_'),
|
||||
],
|
||||
];
|
||||
@ -1,56 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2016 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: liu21st <liu21st@gmail.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
use think\Env;
|
||||
|
||||
return [
|
||||
// 数据库类型
|
||||
'type' => Env::get('database.type', 'mysql'),
|
||||
// 服务器地址
|
||||
'hostname' => Env::get('database.hostname', '127.0.0.1'),
|
||||
// 数据库名
|
||||
'database' => Env::get('database.database', 'ye4s'),
|
||||
// 用户名
|
||||
'username' => Env::get('database.username', 'ye4s'),
|
||||
// 密码
|
||||
'password' => Env::get('database.password', 'H@8h^QE4N$L.F_*'),
|
||||
// 端口
|
||||
'hostport' => Env::get('database.hostport', ''),
|
||||
// 连接dsn
|
||||
'dsn' => '',
|
||||
// 数据库连接参数
|
||||
'params' => [],
|
||||
// 数据库编码默认采用 utf8mb4
|
||||
'charset' => Env::get('database.charset', 'utf8mb4'),
|
||||
// 数据库表前缀
|
||||
'prefix' => Env::get('database.prefix', 'ye4s_'),
|
||||
// 数据库调试模式
|
||||
'debug' => Env::get('database.debug', false),
|
||||
// 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)
|
||||
'deploy' => 0,
|
||||
// 数据库读写是否分离 主从式有效
|
||||
'rw_separate' => false,
|
||||
// 读写分离后 主服务器数量
|
||||
'master_num' => 1,
|
||||
// 指定从服务器序号
|
||||
'slave_no' => '',
|
||||
// 是否严格检查字段是否存在
|
||||
'fields_strict' => true,
|
||||
// 数据集返回类型
|
||||
'resultset_type' => 'array',
|
||||
// 自动写入时间戳字段
|
||||
'auto_timestamp' => false,
|
||||
// 时间字段取出后的默认时间格式,默认为Y-m-d H:i:s
|
||||
'datetime_format' => false,
|
||||
// 是否需要进行SQL性能分析
|
||||
'sql_explain' => false,
|
||||
];
|
||||
@ -22,6 +22,7 @@ use app\index\library\zopsdk\ZopRequest;
|
||||
use app\index\controller\wms\Wms as WmsController;
|
||||
use fast\Http;
|
||||
use fast\Random;
|
||||
use app\index\library\chat\Forward;
|
||||
class Chat extends Frontend
|
||||
{
|
||||
protected $noNeedLogin = 'OnMessage,OnMessage2,Message,Notify,Notify5,trace_test,tihuotest,Notify2,Notify3,kdroomMessageExplpde2,test,checkOnline,getAllWechatRooms,noticeConfirmApplyStorage';
|
||||
@ -572,6 +573,18 @@ class Chat extends Frontend
|
||||
$msgid = $msg_log['id'];
|
||||
$postnums = $this->getPostNums($text);//获取快递号
|
||||
//消息格式化end
|
||||
|
||||
// ── 转发到 WMS 开放接口 ──
|
||||
// 如果 WMS 返回了处理结果,跳过本地关键词匹配直接返回
|
||||
$forward = new Forward();
|
||||
$forwardResult = $forward->handle($params, $this->SOURCE, $text);
|
||||
if ($forwardResult !== null) {
|
||||
if (!empty($forwardResult['msgs'])) {
|
||||
$msg_log->save(["result" => json_encode($forwardResult['msgs'])]);
|
||||
}
|
||||
return $forwardResult;
|
||||
}
|
||||
|
||||
switch($roomtype){
|
||||
case 1:
|
||||
//货主类型群聊
|
||||
|
||||
123
application/index/library/chat/Forward.php
Normal file
123
application/index/library/chat/Forward.php
Normal file
@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
namespace app\index\library\chat;
|
||||
|
||||
use fast\Http;
|
||||
|
||||
/**
|
||||
* 消息转发处理器
|
||||
*
|
||||
* 将群聊消息转发到 WMS 开放接口处理
|
||||
* 如果 WMS 返回了有效响应,则跳过 Chat::processMessage 的本地关键词匹配逻辑
|
||||
*
|
||||
* 调用方式:
|
||||
* $forward = new Forward();
|
||||
* $result = $forward->handle($params, $SOURCE, $text);
|
||||
* if ($result !== null) return $result; // 跳过本地处理
|
||||
*/
|
||||
class Forward
|
||||
{
|
||||
// ==================== WMS 开放接口配置 ====================
|
||||
const WMS_API_BASE_URL = 'https://wms.wms.gztbyc.com/warehouse'; // WMS 开放接口地址
|
||||
const WMS_APP_KEY = ''; // 应用 Key(待配置)
|
||||
const WMS_APP_SECRET = ''; // 应用 Secret(待配置)
|
||||
const WMS_API_TIMEOUT = 10; // 请求超时(秒)
|
||||
|
||||
/**
|
||||
* 处理消息转发
|
||||
*
|
||||
* @param array $params 统一消息结构(与 processMessage 入参一致)
|
||||
* @param string $source 消息来源: 'wx' | 'qiwe'
|
||||
* @param string $text 已提取的消息文本内容
|
||||
* @return array|null 返回 null 表示不处理(继续本地逻辑),
|
||||
* 返回 ["msgs" => ..., "info" => ...] 则跳过本地处理直接返回
|
||||
*/
|
||||
public function handle($params, $source, $text)
|
||||
{
|
||||
// ---- 配置未就绪时跳过 ----
|
||||
if (empty(static::WMS_APP_KEY) || empty(static::WMS_APP_SECRET)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// ---- 构建请求签名 ----
|
||||
$timestamp = (string) time();
|
||||
$nonce = $this->generateNonce(16);
|
||||
$sign = $this->buildSign($timestamp, $nonce);
|
||||
|
||||
// ---- 构建请求体 ----
|
||||
$postData = [
|
||||
'fromid' => $params['data']['fromid'] ?? '',
|
||||
'memid' => $params['data']['memid'] ?? '',
|
||||
'memname' => $params['data']['memname'] ?? '',
|
||||
'nickName' => $params['data']['nickName'] ?? '',
|
||||
'msg' => $text,
|
||||
'source' => $source,
|
||||
'type' => $params['type'] ?? 1,
|
||||
'msgId' => $params['data']['id'] ?? '',
|
||||
];
|
||||
|
||||
// ---- 发起请求 ----
|
||||
try {
|
||||
$response = Http::post(
|
||||
static::WMS_API_BASE_URL . '/chat/handle',
|
||||
json_encode($postData),
|
||||
[
|
||||
CURLOPT_HTTPHEADER => [
|
||||
'Content-Type: application/json',
|
||||
'X-App-Key: ' . static::WMS_APP_KEY,
|
||||
'X-Timestamp: ' . $timestamp,
|
||||
'X-Nonce: ' . $nonce,
|
||||
'X-Sign: ' . $sign,
|
||||
],
|
||||
CURLOPT_TIMEOUT => static::WMS_API_TIMEOUT,
|
||||
CURLOPT_CONNECTTIMEOUT => 5,
|
||||
]
|
||||
);
|
||||
|
||||
$result = json_decode($response, true);
|
||||
|
||||
// ---- 校验响应 ----
|
||||
if (!$result || empty($result['code'])) {
|
||||
\think\Log::error('[Forward] WMS 接口返回异常: ' . json_encode($response));
|
||||
return null; // 异常时降级到本地处理
|
||||
}
|
||||
|
||||
// code == 1 表示 WMS 已处理,返回给群聊
|
||||
if ((int) $result['code'] === 1 && !empty($result['data'])) {
|
||||
\think\Log::info('[Forward] WMS 已处理消息: ' . json_encode($result));
|
||||
return [
|
||||
'msgs' => $result['data']['msgs'] ?? [],
|
||||
'info' => $result['data']['info'] ?? '已转发WMS处理',
|
||||
];
|
||||
}
|
||||
|
||||
// code == 0 或 data 为空 → 走本地逻辑
|
||||
return null;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
\think\Log::error('[Forward] 请求异常: ' . $e->getMessage());
|
||||
return null; // 异常时降级到本地处理
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建请求签名
|
||||
*/
|
||||
private function buildSign($timestamp, $nonce)
|
||||
{
|
||||
return md5(static::WMS_APP_KEY . $timestamp . $nonce . static::WMS_APP_SECRET);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成随机 nonce
|
||||
*/
|
||||
private function generateNonce($length = 16)
|
||||
{
|
||||
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
||||
$nonce = '';
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$nonce .= $chars[random_int(0, strlen($chars) - 1)];
|
||||
}
|
||||
return $nonce;
|
||||
}
|
||||
}
|
||||
34
bower.json
34
bower.json
@ -1,34 +0,0 @@
|
||||
{
|
||||
"name": "fastadmin",
|
||||
"description": "the fastest admin framework",
|
||||
"main": "",
|
||||
"license": "Apache2.0",
|
||||
"homepage": "https://www.fastadmin.net",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"jquery": "^2.1.4",
|
||||
"bootstrap": "^3.3.7",
|
||||
"font-awesome": "^4.6.1",
|
||||
"bootstrap-table": "fastadmin-bootstraptable#~1.11.5",
|
||||
"jstree": "~3.3.2",
|
||||
"moment": "~2.29.0",
|
||||
"toastr": "~2.1.3",
|
||||
"eonasdan-bootstrap-datetimepicker": "~4.17.43",
|
||||
"bootstrap-select": "~1.13.18",
|
||||
"require-css": "~0.1.8",
|
||||
"tableExport.jquery.plugin": "~1.10.3",
|
||||
"jquery-slimscroll": "~1.3.8",
|
||||
"jquery.cookie": "~1.4.1",
|
||||
"Sortable": "~1.10.0",
|
||||
"nice-validator": "~1.1.1",
|
||||
"art-template": "~3.1.3",
|
||||
"bootstrap-daterangepicker": "~2.1.25",
|
||||
"fastadmin-citypicker": "~1.3.1",
|
||||
"fastadmin-cxselect": "~1.4.0",
|
||||
"fastadmin-dragsort": "~1.0.0",
|
||||
"fastadmin-addtabs": "~1.0.5",
|
||||
"fastadmin-selectpage": "~1.0.6",
|
||||
"fastadmin-layer": "~3.5.1",
|
||||
"bootstrap-slider": "*"
|
||||
}
|
||||
}
|
||||
@ -1,44 +0,0 @@
|
||||
{
|
||||
"name": "karsonzhang/fastadmin",
|
||||
"description": "the fastest admin framework",
|
||||
"type": "project",
|
||||
"keywords": [
|
||||
"fastadmin",
|
||||
"thinkphp"
|
||||
],
|
||||
"homepage": "https://www.fastadmin.net/",
|
||||
"license": "Apache-2.0",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Karson",
|
||||
"email": "karson@fastadmin.net"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=7.2.0",
|
||||
"topthink/framework": "dev-master",
|
||||
"topthink/think-captcha": "^1.0",
|
||||
"topthink/think-installer": "^1.0.14",
|
||||
"topthink/think-queue": "1.1.6",
|
||||
"topthink/think-helper": "^1.0.7",
|
||||
"karsonzhang/fastadmin-addons": "~1.3.2",
|
||||
"overtrue/pinyin": "^3.0",
|
||||
"phpoffice/phpspreadsheet": "1.19",
|
||||
"overtrue/wechat": "^4.6",
|
||||
"nelexa/zip": "^3.3",
|
||||
"ext-json": "*",
|
||||
"ext-curl": "*",
|
||||
"ext-pdo": "*",
|
||||
"ext-bcmath": "*",
|
||||
"txthinking/mailer": "^2.0"
|
||||
},
|
||||
"config": {
|
||||
"preferred-install": "dist"
|
||||
},
|
||||
"repositories": [
|
||||
{
|
||||
"type": "git",
|
||||
"url": "https://gitee.com/fastadminnet/framework.git"
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
deny from all
|
||||
@ -1,265 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2011 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: luofei614 <weibo.com/luofei614>
|
||||
// +----------------------------------------------------------------------
|
||||
// | 修改者: anuo (本权限类在原3.2.3的基础上修改过来的)
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace fast;
|
||||
|
||||
use think\Db;
|
||||
use think\Config;
|
||||
use think\Session;
|
||||
use think\Request;
|
||||
|
||||
/**
|
||||
* 权限认证类
|
||||
* 功能特性:
|
||||
* 1,是对规则进行认证,不是对节点进行认证。用户可以把节点当作规则名称实现对节点进行认证。
|
||||
* $auth=new Auth(); $auth->check('规则名称','用户id')
|
||||
* 2,可以同时对多条规则进行认证,并设置多条规则的关系(or或者and)
|
||||
* $auth=new Auth(); $auth->check('规则1,规则2','用户id','and')
|
||||
* 第三个参数为and时表示,用户需要同时具有规则1和规则2的权限。 当第三个参数为or时,表示用户值需要具备其中一个条件即可。默认为or
|
||||
* 3,一个用户可以属于多个用户组(think_auth_group_access表 定义了用户所属用户组)。我们需要设置每个用户组拥有哪些规则(think_auth_group 定义了用户组权限)
|
||||
* 4,支持规则表达式。
|
||||
* 在think_auth_rule 表中定义一条规则,condition字段就可以定义规则表达式。 如定义{score}>5 and {score}<100
|
||||
* 表示用户的分数在5-100之间时这条规则才会通过。
|
||||
*/
|
||||
class Auth
|
||||
{
|
||||
|
||||
/**
|
||||
* @var object 对象实例
|
||||
*/
|
||||
protected static $instance;
|
||||
protected $rules = [];
|
||||
|
||||
/**
|
||||
* 当前请求实例
|
||||
* @var Request
|
||||
*/
|
||||
protected $request;
|
||||
//默认配置
|
||||
protected $config = [
|
||||
'auth_on' => 1, // 权限开关
|
||||
'auth_type' => 1, // 认证方式,1为实时认证;2为登录认证。
|
||||
'auth_group' => 'auth_group', // 用户组数据表名
|
||||
'auth_group_access' => 'auth_group_access', // 用户-用户组关系表
|
||||
'auth_rule' => 'auth_rule', // 权限规则表
|
||||
'auth_user' => 'user', // 用户信息表
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
if ($auth = Config::get('auth')) {
|
||||
$this->config = array_merge($this->config, $auth);
|
||||
}
|
||||
// 初始化request
|
||||
$this->request = Request::instance();
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
* @access public
|
||||
* @param array $options 参数
|
||||
* @return Auth
|
||||
*/
|
||||
public static function instance($options = [])
|
||||
{
|
||||
if (is_null(self::$instance)) {
|
||||
self::$instance = new static($options);
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查权限
|
||||
* @param string|array $name 需要验证的规则列表,支持逗号分隔的权限规则或索引数组
|
||||
* @param int $uid 认证用户的id
|
||||
* @param string $relation 如果为 'or' 表示满足任一条规则即通过验证;如果为 'and'则表示需满足所有规则才能通过验证
|
||||
* @param string $mode 执行验证的模式,可分为url,normal
|
||||
* @return bool 通过验证返回true;失败返回false
|
||||
*/
|
||||
public function check($name, $uid, $relation = 'or', $mode = 'url')
|
||||
{
|
||||
if (!$this->config['auth_on']) {
|
||||
return true;
|
||||
}
|
||||
// 获取用户需要验证的所有有效规则列表
|
||||
$rulelist = $this->getRuleList($uid);
|
||||
if (in_array('*', $rulelist)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (is_string($name)) {
|
||||
$name = strtolower($name);
|
||||
if (strpos($name, ',') !== false) {
|
||||
$name = explode(',', $name);
|
||||
} else {
|
||||
$name = [$name];
|
||||
}
|
||||
}
|
||||
$list = []; //保存验证通过的规则名
|
||||
if ('url' == $mode) {
|
||||
$REQUEST = unserialize(strtolower(serialize($this->request->param())));
|
||||
}
|
||||
foreach ($rulelist as $rule) {
|
||||
$query = preg_replace('/^.+\?/U', '', $rule);
|
||||
if ('url' == $mode && $query != $rule) {
|
||||
parse_str($query, $param); //解析规则中的param
|
||||
$intersect = array_intersect_assoc($REQUEST, $param);
|
||||
$rule = preg_replace('/\?.*$/U', '', $rule);
|
||||
if (in_array($rule, $name) && $intersect == $param) {
|
||||
//如果节点相符且url参数满足
|
||||
$list[] = $rule;
|
||||
}
|
||||
} else {
|
||||
if (in_array($rule, $name)) {
|
||||
$list[] = $rule;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ('or' == $relation && !empty($list)) {
|
||||
return true;
|
||||
}
|
||||
$diff = array_diff($name, $list);
|
||||
if ('and' == $relation && empty($diff)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户id获取用户组,返回值为数组
|
||||
* @param int $uid 用户id
|
||||
* @return array 用户所属的用户组 array(
|
||||
* array('uid'=>'用户id','group_id'=>'用户组id','name'=>'用户组名称','rules'=>'用户组拥有的规则id,多个,号隔开'),
|
||||
* ...)
|
||||
*/
|
||||
public function getGroups($uid)
|
||||
{
|
||||
static $groups = [];
|
||||
if (isset($groups[$uid])) {
|
||||
return $groups[$uid];
|
||||
}
|
||||
|
||||
// 执行查询
|
||||
$user_groups = Db::name($this->config['auth_group_access'])
|
||||
->alias('aga')
|
||||
->join('__' . strtoupper($this->config['auth_group']) . '__ ag', 'aga.group_id = ag.id', 'LEFT')
|
||||
->field('aga.uid,aga.group_id,ag.id,ag.pid,ag.name,ag.rules')
|
||||
->where("aga.uid='{$uid}' and ag.status='normal'")
|
||||
->select();
|
||||
$groups[$uid] = $user_groups ?: [];
|
||||
return $groups[$uid];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得权限规则列表
|
||||
* @param int $uid 用户id
|
||||
* @return array
|
||||
*/
|
||||
public function getRuleList($uid)
|
||||
{
|
||||
static $_rulelist = []; //保存用户验证通过的权限列表
|
||||
if (isset($_rulelist[$uid])) {
|
||||
return $_rulelist[$uid];
|
||||
}
|
||||
if (2 == $this->config['auth_type'] && Session::has('_rule_list_' . $uid)) {
|
||||
return Session::get('_rule_list_' . $uid);
|
||||
}
|
||||
|
||||
// 读取用户规则节点
|
||||
$ids = $this->getRuleIds($uid);
|
||||
if (empty($ids)) {
|
||||
$_rulelist[$uid] = [];
|
||||
return [];
|
||||
}
|
||||
|
||||
// 筛选条件
|
||||
$where = [
|
||||
'status' => 'normal'
|
||||
];
|
||||
if (!in_array('*', $ids)) {
|
||||
$where['id'] = ['in', $ids];
|
||||
}
|
||||
//读取用户组所有权限规则
|
||||
$this->rules = Db::name($this->config['auth_rule'])->where($where)->field('id,pid,condition,icon,name,title,ismenu')->select();
|
||||
|
||||
//循环规则,判断结果。
|
||||
$rulelist = []; //
|
||||
if (in_array('*', $ids)) {
|
||||
$rulelist[] = "*";
|
||||
}
|
||||
foreach ($this->rules as $rule) {
|
||||
//超级管理员无需验证condition
|
||||
if (!empty($rule['condition']) && !in_array('*', $ids)) {
|
||||
//根据condition进行验证
|
||||
$user = $this->getUserInfo($uid); //获取用户信息,一维数组
|
||||
$nums = 0;
|
||||
$condition = str_replace(['&&', '||'], "\r\n", $rule['condition']);
|
||||
$condition = preg_replace('/\{(\w*?)\}/', '\\1', $condition);
|
||||
$conditionArr = explode("\r\n", $condition);
|
||||
foreach ($conditionArr as $index => $item) {
|
||||
preg_match("/^(\w+)\s?([\>\<\=]+)\s?(.*)$/", trim($item), $matches);
|
||||
if ($matches && isset($user[$matches[1]]) && version_compare($user[$matches[1]], $matches[3], $matches[2])) {
|
||||
$nums++;
|
||||
}
|
||||
}
|
||||
if ($conditionArr && ((stripos($rule['condition'], "||") !== false && $nums > 0) || count($conditionArr) == $nums)) {
|
||||
$rulelist[$rule['id']] = strtolower($rule['name']);
|
||||
}
|
||||
} else {
|
||||
//只要存在就记录
|
||||
$rulelist[$rule['id']] = strtolower($rule['name']);
|
||||
}
|
||||
}
|
||||
$_rulelist[$uid] = $rulelist;
|
||||
//登录验证则需要保存规则列表
|
||||
if (2 == $this->config['auth_type']) {
|
||||
//规则列表结果保存到session
|
||||
Session::set('_rule_list_' . $uid, $rulelist);
|
||||
}
|
||||
return array_unique($rulelist);
|
||||
}
|
||||
|
||||
public function getRuleIds($uid)
|
||||
{
|
||||
//读取用户所属用户组
|
||||
$groups = $this->getGroups($uid);
|
||||
$ids = []; //保存用户所属用户组设置的所有权限规则id
|
||||
foreach ($groups as $g) {
|
||||
$ids = array_merge($ids, explode(',', trim($g['rules'], ',')));
|
||||
}
|
||||
$ids = array_unique($ids);
|
||||
return $ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得用户资料
|
||||
* @param int $uid 用户id
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getUserInfo($uid)
|
||||
{
|
||||
static $user_info = [];
|
||||
|
||||
$user = Db::name($this->config['auth_user']);
|
||||
// 获取用户表主键
|
||||
$_pk = is_string($user->getPk()) ? $user->getPk() : 'uid';
|
||||
if (!isset($user_info[$uid])) {
|
||||
$user_info[$uid] = $user->where($_pk, $uid)->find();
|
||||
}
|
||||
|
||||
return $user_info[$uid];
|
||||
}
|
||||
}
|
||||
@ -1,226 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace fast;
|
||||
|
||||
use DateTime;
|
||||
use DateTimeZone;
|
||||
|
||||
/**
|
||||
* 日期时间处理类
|
||||
*/
|
||||
class Date
|
||||
{
|
||||
const YEAR = 31536000;
|
||||
const MONTH = 2592000;
|
||||
const WEEK = 604800;
|
||||
const DAY = 86400;
|
||||
const HOUR = 3600;
|
||||
const MINUTE = 60;
|
||||
|
||||
/**
|
||||
* 计算两个时区间相差的时长,单位为秒
|
||||
*
|
||||
* $seconds = self::offset('America/Chicago', 'GMT');
|
||||
*
|
||||
* [!!] A list of time zones that PHP supports can be found at
|
||||
* <http://php.net/timezones>.
|
||||
*
|
||||
* @param string $remote timezone that to find the offset of
|
||||
* @param string $local timezone used as the baseline
|
||||
* @param mixed $now UNIX timestamp or date string
|
||||
* @return integer
|
||||
*/
|
||||
public static function offset($remote, $local = null, $now = null)
|
||||
{
|
||||
if ($local === null) {
|
||||
// Use the default timezone
|
||||
$local = date_default_timezone_get();
|
||||
}
|
||||
if (is_int($now)) {
|
||||
// Convert the timestamp into a string
|
||||
$now = date(DateTime::RFC2822, $now);
|
||||
}
|
||||
// Create timezone objects
|
||||
$zone_remote = new DateTimeZone($remote);
|
||||
$zone_local = new DateTimeZone($local);
|
||||
// Create date objects from timezones
|
||||
$time_remote = new DateTime($now, $zone_remote);
|
||||
$time_local = new DateTime($now, $zone_local);
|
||||
// Find the offset
|
||||
$offset = $zone_remote->getOffset($time_remote) - $zone_local->getOffset($time_local);
|
||||
return $offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算两个时间戳之间相差的时间
|
||||
*
|
||||
* $span = self::span(60, 182, 'minutes,seconds'); // array('minutes' => 2, 'seconds' => 2)
|
||||
* $span = self::span(60, 182, 'minutes'); // 2
|
||||
*
|
||||
* @param int $remote timestamp to find the span of
|
||||
* @param int $local timestamp to use as the baseline
|
||||
* @param string $output formatting string
|
||||
* @return string when only a single output is requested
|
||||
* @return array associative list of all outputs requested
|
||||
* @from https://github.com/kohana/ohanzee-helpers/blob/master/src/Date.php
|
||||
*/
|
||||
public static function span($remote, $local = null, $output = 'years,months,weeks,days,hours,minutes,seconds')
|
||||
{
|
||||
// Normalize output
|
||||
$output = trim(strtolower((string)$output));
|
||||
if (!$output) {
|
||||
// Invalid output
|
||||
return false;
|
||||
}
|
||||
// Array with the output formats
|
||||
$output = preg_split('/[^a-z]+/', $output);
|
||||
// Convert the list of outputs to an associative array
|
||||
$output = array_combine($output, array_fill(0, count($output), 0));
|
||||
// Make the output values into keys
|
||||
extract(array_flip($output), EXTR_SKIP);
|
||||
if ($local === null) {
|
||||
// Calculate the span from the current time
|
||||
$local = time();
|
||||
}
|
||||
// Calculate timespan (seconds)
|
||||
$timespan = abs($remote - $local);
|
||||
if (isset($output['years'])) {
|
||||
$timespan -= self::YEAR * ($output['years'] = (int)floor($timespan / self::YEAR));
|
||||
}
|
||||
if (isset($output['months'])) {
|
||||
$timespan -= self::MONTH * ($output['months'] = (int)floor($timespan / self::MONTH));
|
||||
}
|
||||
if (isset($output['weeks'])) {
|
||||
$timespan -= self::WEEK * ($output['weeks'] = (int)floor($timespan / self::WEEK));
|
||||
}
|
||||
if (isset($output['days'])) {
|
||||
$timespan -= self::DAY * ($output['days'] = (int)floor($timespan / self::DAY));
|
||||
}
|
||||
if (isset($output['hours'])) {
|
||||
$timespan -= self::HOUR * ($output['hours'] = (int)floor($timespan / self::HOUR));
|
||||
}
|
||||
if (isset($output['minutes'])) {
|
||||
$timespan -= self::MINUTE * ($output['minutes'] = (int)floor($timespan / self::MINUTE));
|
||||
}
|
||||
// Seconds ago, 1
|
||||
if (isset($output['seconds'])) {
|
||||
$output['seconds'] = $timespan;
|
||||
}
|
||||
if (count($output) === 1) {
|
||||
// Only a single output was requested, return it
|
||||
return array_pop($output);
|
||||
}
|
||||
// Return array
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化 UNIX 时间戳为人易读的字符串
|
||||
*
|
||||
* @param int Unix 时间戳
|
||||
* @param mixed $local 本地时间
|
||||
*
|
||||
* @return string 格式化的日期字符串
|
||||
*/
|
||||
public static function human($remote, $local = null)
|
||||
{
|
||||
$time_diff = (is_null($local) || $local ? time() : $local) - $remote;
|
||||
$tense = $time_diff < 0 ? 'after' : 'ago';
|
||||
$time_diff = abs($time_diff);
|
||||
$chunks = [
|
||||
[60 * 60 * 24 * 365, 'year'],
|
||||
[60 * 60 * 24 * 30, 'month'],
|
||||
[60 * 60 * 24 * 7, 'week'],
|
||||
[60 * 60 * 24, 'day'],
|
||||
[60 * 60, 'hour'],
|
||||
[60, 'minute'],
|
||||
[1, 'second']
|
||||
];
|
||||
$name = 'second';
|
||||
$count = 0;
|
||||
|
||||
for ($i = 0, $j = count($chunks); $i < $j; $i++) {
|
||||
$seconds = $chunks[$i][0];
|
||||
$name = $chunks[$i][1];
|
||||
if (($count = floor($time_diff / $seconds)) != 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return __("%d $name%s $tense", $count, ($count > 1 ? 's' : ''));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一个基于时间偏移的Unix时间戳
|
||||
*
|
||||
* @param string $type 时间类型,默认为day,可选minute,hour,day,week,month,quarter,year
|
||||
* @param int $offset 时间偏移量 默认为0,正数表示当前type之后,负数表示当前type之前
|
||||
* @param string $position 时间的开始或结束,默认为begin,可选前(begin,start,first,front),end
|
||||
* @param int $year 基准年,默认为null,即以当前年为基准
|
||||
* @param int $month 基准月,默认为null,即以当前月为基准
|
||||
* @param int $day 基准天,默认为null,即以当前天为基准
|
||||
* @param int $hour 基准小时,默认为null,即以当前年小时基准
|
||||
* @param int $minute 基准分钟,默认为null,即以当前分钟为基准
|
||||
* @return int 处理后的Unix时间戳
|
||||
*/
|
||||
public static function unixtime($type = 'day', $offset = 0, $position = 'begin', $year = null, $month = null, $day = null, $hour = null, $minute = null)
|
||||
{
|
||||
$year = is_null($year) ? date('Y') : $year;
|
||||
$month = is_null($month) ? date('m') : $month;
|
||||
$day = is_null($day) ? date('d') : $day;
|
||||
$hour = is_null($hour) ? date('H') : $hour;
|
||||
$minute = is_null($minute) ? date('i') : $minute;
|
||||
$position = in_array($position, array('begin', 'start', 'first', 'front'));
|
||||
|
||||
$baseTime = mktime(0, 0, 0, $month, $day, $year);
|
||||
|
||||
switch ($type) {
|
||||
case 'minute':
|
||||
$time = $position ? mktime($hour, $minute + $offset, 0, $month, $day, $year) : mktime($hour, $minute + $offset, 59, $month, $day, $year);
|
||||
break;
|
||||
case 'hour':
|
||||
$time = $position ? mktime($hour + $offset, 0, 0, $month, $day, $year) : mktime($hour + $offset, 59, 59, $month, $day, $year);
|
||||
break;
|
||||
case 'day':
|
||||
$time = $position ? mktime(0, 0, 0, $month, $day + $offset, $year) : mktime(23, 59, 59, $month, $day + $offset, $year);
|
||||
break;
|
||||
case 'week':
|
||||
$weekIndex = date("w", $baseTime);
|
||||
$time = $position ?
|
||||
strtotime($offset . " weeks", strtotime(date('Y-m-d', strtotime("-" . ($weekIndex ? $weekIndex - 1 : 6) . " days", $baseTime)))) :
|
||||
strtotime($offset . " weeks", strtotime(date('Y-m-d 23:59:59', strtotime("+" . (6 - ($weekIndex ? $weekIndex - 1 : 6)) . " days", $baseTime))));
|
||||
break;
|
||||
case 'month':
|
||||
$_timestamp = mktime(0, 0, 0, $month + $offset, 1, $year);
|
||||
$time = $position ? $_timestamp : mktime(23, 59, 59, $month + $offset, self::days_in_month(date("m", $_timestamp), date("Y", $_timestamp)), $year);
|
||||
break;
|
||||
case 'quarter':
|
||||
$_month = date("m", mktime(0, 0, 0, (ceil(date('n', mktime(0, 0, 0, $month, $day, $year)) / 3) + $offset) * 3, $day, $year));
|
||||
$time = $position ?
|
||||
mktime(0, 0, 0, 1 + ((ceil(date('n', $baseTime) / 3) + $offset) - 1) * 3, 1, $year) :
|
||||
mktime(23, 59, 59, (ceil(date('n', $baseTime) / 3) + $offset) * 3, self::days_in_month((ceil(date('n', $baseTime) / 3) + $offset) * 3, $year), $year);
|
||||
break;
|
||||
case 'year':
|
||||
$time = $position ? mktime(0, 0, 0, 1, 1, $year + $offset) : mktime(23, 59, 59, 12, 31, $year + $offset);
|
||||
break;
|
||||
default:
|
||||
$time = mktime($hour, $minute, 0, $month, $day, $year);
|
||||
break;
|
||||
}
|
||||
return $time;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定年月拥有的天数
|
||||
* @param int $month
|
||||
* @param int $year
|
||||
* @return false|int|string
|
||||
*/
|
||||
public static function days_in_month($month, $year)
|
||||
{
|
||||
if (function_exists("cal_days_in_month")) {
|
||||
return cal_days_in_month(CAL_GREGORIAN, $month, $year);
|
||||
} else {
|
||||
return date('t', mktime(0, 0, 0, $month, 1, $year));
|
||||
}
|
||||
}
|
||||
}
|
||||
1289
extend/fast/Form.php
1289
extend/fast/Form.php
File diff suppressed because it is too large
Load Diff
@ -1,185 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace fast;
|
||||
|
||||
/**
|
||||
* Http 请求类
|
||||
*/
|
||||
class Http
|
||||
{
|
||||
|
||||
/**
|
||||
* 发送一个POST请求
|
||||
* @param string $url 请求URL
|
||||
* @param array $params 请求参数
|
||||
* @param array $options 扩展参数
|
||||
* @return mixed|string
|
||||
*/
|
||||
public static function post($url, $params = [], $options = [])
|
||||
{
|
||||
$req = self::sendRequest($url, $params, 'POST', $options);
|
||||
return $req['ret'] ? $req['msg'] : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送一个GET请求
|
||||
* @param string $url 请求URL
|
||||
* @param array $params 请求参数
|
||||
* @param array $options 扩展参数
|
||||
* @return mixed|string
|
||||
*/
|
||||
public static function get($url, $params = [], $options = [])
|
||||
{
|
||||
$req = self::sendRequest($url, $params, 'GET', $options);
|
||||
return $req['ret'] ? $req['msg'] : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* CURL发送Request请求,含POST和REQUEST
|
||||
* @param string $url 请求的链接
|
||||
* @param mixed $params 传递的参数
|
||||
* @param string $method 请求的方法
|
||||
* @param mixed $options CURL的参数
|
||||
* @return array
|
||||
*/
|
||||
public static function sendRequest($url, $params = [], $method = 'POST', $options = [])
|
||||
{
|
||||
$method = strtoupper($method);
|
||||
$protocol = substr($url, 0, 5);
|
||||
$query_string = is_array($params) ? http_build_query($params) : $params;
|
||||
|
||||
$ch = curl_init();
|
||||
$defaults = [];
|
||||
if ('GET' == $method) {
|
||||
$geturl = $query_string ? $url . (stripos($url, "?") !== false ? "&" : "?") . $query_string : $url;
|
||||
$defaults[CURLOPT_URL] = $geturl;
|
||||
} else {
|
||||
$defaults[CURLOPT_URL] = $url;
|
||||
if ($method == 'POST') {
|
||||
$defaults[CURLOPT_POST] = 1;
|
||||
} else {
|
||||
$defaults[CURLOPT_CUSTOMREQUEST] = $method;
|
||||
}
|
||||
$defaults[CURLOPT_POSTFIELDS] = $params;
|
||||
}
|
||||
|
||||
$defaults[CURLOPT_HEADER] = false;
|
||||
$defaults[CURLOPT_USERAGENT] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36";
|
||||
$defaults[CURLOPT_FOLLOWLOCATION] = true;
|
||||
$defaults[CURLOPT_RETURNTRANSFER] = true;
|
||||
$defaults[CURLOPT_CONNECTTIMEOUT] = 3;
|
||||
$defaults[CURLOPT_TIMEOUT] = 3;
|
||||
|
||||
// disable 100-continue
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
|
||||
|
||||
if ('https' == $protocol) {
|
||||
$defaults[CURLOPT_SSL_VERIFYPEER] = false;
|
||||
$defaults[CURLOPT_SSL_VERIFYHOST] = false;
|
||||
}
|
||||
|
||||
curl_setopt_array($ch, (array)$options + $defaults);
|
||||
|
||||
$ret = curl_exec($ch);
|
||||
$err = curl_error($ch);
|
||||
|
||||
if (false === $ret || !empty($err)) {
|
||||
$errno = curl_errno($ch);
|
||||
$info = curl_getinfo($ch);
|
||||
curl_close($ch);
|
||||
return [
|
||||
'ret' => false,
|
||||
'errno' => $errno,
|
||||
'msg' => $err,
|
||||
'info' => $info,
|
||||
];
|
||||
}
|
||||
curl_close($ch);
|
||||
return [
|
||||
'ret' => true,
|
||||
'msg' => $ret,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 异步发送一个请求
|
||||
* @param string $url 请求的链接
|
||||
* @param mixed $params 请求的参数
|
||||
* @param string $method 请求的方法
|
||||
* @return boolean TRUE
|
||||
*/
|
||||
public static function sendAsyncRequest($url, $params = [], $method = 'POST')
|
||||
{
|
||||
$method = strtoupper($method);
|
||||
$method = $method == 'POST' ? 'POST' : 'GET';
|
||||
//构造传递的参数
|
||||
if (is_array($params)) {
|
||||
$post_params = [];
|
||||
foreach ($params as $k => &$v) {
|
||||
if (is_array($v)) {
|
||||
$v = implode(',', $v);
|
||||
}
|
||||
$post_params[] = $k . '=' . urlencode($v);
|
||||
}
|
||||
$post_string = implode('&', $post_params);
|
||||
} else {
|
||||
$post_string = $params;
|
||||
}
|
||||
$parts = parse_url($url);
|
||||
//构造查询的参数
|
||||
if ($method == 'GET' && $post_string) {
|
||||
$parts['query'] = isset($parts['query']) ? $parts['query'] . '&' . $post_string : $post_string;
|
||||
$post_string = '';
|
||||
}
|
||||
$parts['query'] = isset($parts['query']) && $parts['query'] ? '?' . $parts['query'] : '';
|
||||
//发送socket请求,获得连接句柄
|
||||
$fp = fsockopen($parts['host'], isset($parts['port']) ? $parts['port'] : 80, $errno, $errstr, 3);
|
||||
if (!$fp) {
|
||||
return false;
|
||||
}
|
||||
//设置超时时间
|
||||
stream_set_timeout($fp, 3);
|
||||
$out = "{$method} {$parts['path']}{$parts['query']} HTTP/1.1\r\n";
|
||||
$out .= "Host: {$parts['host']}\r\n";
|
||||
$out .= "Content-Type: application/x-www-form-urlencoded\r\n";
|
||||
$out .= "Content-Length: " . strlen($post_string) . "\r\n";
|
||||
$out .= "Connection: Close\r\n\r\n";
|
||||
if ($post_string !== '') {
|
||||
$out .= $post_string;
|
||||
}
|
||||
fwrite($fp, $out);
|
||||
//不用关心服务器返回结果
|
||||
//echo fread($fp, 1024);
|
||||
fclose($fp);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送文件到客户端
|
||||
* @param string $file
|
||||
* @param bool $delaftersend
|
||||
* @param bool $exitaftersend
|
||||
*/
|
||||
public static function sendToBrowser($file, $delaftersend = true, $exitaftersend = true)
|
||||
{
|
||||
if (file_exists($file) && is_readable($file)) {
|
||||
header('Content-Description: File Transfer');
|
||||
header('Content-Type: application/octet-stream');
|
||||
header('Content-Disposition: attachment;filename = ' . basename($file));
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
header('Expires: 0');
|
||||
header('Cache-Control: must-revalidate, post-check = 0, pre-check = 0');
|
||||
header('Pragma: public');
|
||||
header('Content-Length: ' . filesize($file));
|
||||
ob_clean();
|
||||
flush();
|
||||
readfile($file);
|
||||
if ($delaftersend) {
|
||||
unlink($file);
|
||||
}
|
||||
if ($exitaftersend) {
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace fast;
|
||||
|
||||
/**
|
||||
* 中文转拼音类
|
||||
*/
|
||||
class Pinyin
|
||||
{
|
||||
|
||||
/**
|
||||
* 获取文字的拼音
|
||||
* @param string $chinese 中文汉字
|
||||
* @param boolean $onlyfirst 是否只返回拼音首字母
|
||||
* @param string $delimiter 分隔符
|
||||
* @param bool $ucfirst 是否首字母大写
|
||||
* @return string
|
||||
*/
|
||||
public static function get($chinese, $onlyfirst = false, $delimiter = '', $ucfirst = false)
|
||||
{
|
||||
|
||||
$pinyin = new \Overtrue\Pinyin\Pinyin();
|
||||
if ($onlyfirst) {
|
||||
$result = $pinyin->abbr($chinese, $delimiter);
|
||||
} else {
|
||||
$result = $pinyin->permalink($chinese, $delimiter);
|
||||
}
|
||||
if ($ucfirst) {
|
||||
$pinyinArr = explode($delimiter, $result);
|
||||
$result = implode($delimiter, array_map('ucfirst', $pinyinArr));
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,171 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace fast;
|
||||
|
||||
/**
|
||||
* 随机生成类
|
||||
*/
|
||||
class Random
|
||||
{
|
||||
|
||||
/**
|
||||
* 生成数字和字母
|
||||
*
|
||||
* @param int $len 长度
|
||||
* @return string
|
||||
*/
|
||||
public static function alnum($len = 6)
|
||||
{
|
||||
return self::build('alnum', $len);
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅生成字符
|
||||
*
|
||||
* @param int $len 长度
|
||||
* @return string
|
||||
*/
|
||||
public static function alpha($len = 6)
|
||||
{
|
||||
return self::build('alpha', $len);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成指定长度的随机数字
|
||||
*
|
||||
* @param int $len 长度
|
||||
* @return string
|
||||
*/
|
||||
public static function numeric($len = 4)
|
||||
{
|
||||
return self::build('numeric', $len);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成指定长度的无0随机数字
|
||||
*
|
||||
* @param int $len 长度
|
||||
* @return string
|
||||
*/
|
||||
public static function nozero($len = 4)
|
||||
{
|
||||
return self::build('nozero', $len);
|
||||
}
|
||||
|
||||
/**
|
||||
* 能用的随机数生成
|
||||
* @param string $type 类型 alpha/alnum/numeric/nozero/unique/md5/encrypt/sha1
|
||||
* @param int $len 长度
|
||||
* @return string
|
||||
*/
|
||||
public static function build($type = 'alnum', $len = 8)
|
||||
{
|
||||
switch ($type) {
|
||||
case 'alpha':
|
||||
case 'alnum':
|
||||
case 'numeric':
|
||||
case 'nozero':
|
||||
switch ($type) {
|
||||
case 'alpha':
|
||||
$pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
break;
|
||||
case 'alnum':
|
||||
$pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
break;
|
||||
case 'numeric':
|
||||
$pool = '0123456789';
|
||||
break;
|
||||
case 'nozero':
|
||||
$pool = '123456789';
|
||||
break;
|
||||
}
|
||||
return substr(str_shuffle(str_repeat($pool, ceil($len / strlen($pool)))), 0, $len);
|
||||
case 'unique':
|
||||
case 'md5':
|
||||
return md5(uniqid(mt_rand()));
|
||||
case 'encrypt':
|
||||
case 'sha1':
|
||||
return sha1(uniqid(mt_rand(), true));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据数组元素的概率获得键名
|
||||
*
|
||||
* @param array $ps array('p1'=>20, 'p2'=>30, 'p3'=>50);
|
||||
* @param int $num 默认为1,即随机出来的数量
|
||||
* @param bool $unique 默认为true,即当num>1时,随机出的数量是否唯一
|
||||
* @return mixed 当num为1时返回键名,反之返回一维数组
|
||||
*/
|
||||
public static function lottery($ps, $num = 1, $unique = true)
|
||||
{
|
||||
if (!$ps) {
|
||||
return $num == 1 ? '' : [];
|
||||
}
|
||||
if ($num >= count($ps) && $unique) {
|
||||
$res = array_keys($ps);
|
||||
return $num == 1 ? $res[0] : $res;
|
||||
}
|
||||
$max_exp = 0;
|
||||
$res = [];
|
||||
foreach ($ps as $key => $value) {
|
||||
$value = substr($value, 0, stripos($value, ".") + 6);
|
||||
$exp = strlen(strchr($value, '.')) - 1;
|
||||
if ($exp > $max_exp) {
|
||||
$max_exp = $exp;
|
||||
}
|
||||
}
|
||||
$pow_exp = pow(10, $max_exp);
|
||||
if ($pow_exp > 1) {
|
||||
reset($ps);
|
||||
foreach ($ps as $key => $value) {
|
||||
$ps[$key] = $value * $pow_exp;
|
||||
}
|
||||
}
|
||||
$pro_sum = array_sum($ps);
|
||||
if ($pro_sum < 1) {
|
||||
return $num == 1 ? '' : [];
|
||||
}
|
||||
for ($i = 0; $i < $num; $i++) {
|
||||
$rand_num = mt_rand(1, $pro_sum);
|
||||
reset($ps);
|
||||
foreach ($ps as $key => $value) {
|
||||
if ($rand_num <= $value) {
|
||||
break;
|
||||
} else {
|
||||
$rand_num -= $value;
|
||||
}
|
||||
}
|
||||
if ($num == 1) {
|
||||
$res = $key;
|
||||
break;
|
||||
} else {
|
||||
$res[$i] = $key;
|
||||
}
|
||||
if ($unique) {
|
||||
$pro_sum -= $value;
|
||||
unset($ps[$key]);
|
||||
}
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取全球唯一标识
|
||||
* @return string
|
||||
*/
|
||||
public static function uuid()
|
||||
{
|
||||
return sprintf(
|
||||
'%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
|
||||
mt_rand(0, 0xffff),
|
||||
mt_rand(0, 0xffff),
|
||||
mt_rand(0, 0xffff),
|
||||
mt_rand(0, 0x0fff) | 0x4000,
|
||||
mt_rand(0, 0x3fff) | 0x8000,
|
||||
mt_rand(0, 0xffff),
|
||||
mt_rand(0, 0xffff),
|
||||
mt_rand(0, 0xffff)
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,179 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace fast;
|
||||
|
||||
/**
|
||||
* RSA签名类
|
||||
*/
|
||||
class Rsa
|
||||
{
|
||||
public $publicKey = '';
|
||||
public $privateKey = '';
|
||||
private $_privKey;
|
||||
|
||||
/**
|
||||
* * private key
|
||||
*/
|
||||
private $_pubKey;
|
||||
|
||||
/**
|
||||
* * public key
|
||||
*/
|
||||
private $_keyPath;
|
||||
|
||||
/**
|
||||
* * the keys saving path
|
||||
*/
|
||||
|
||||
/**
|
||||
* * the construtor,the param $path is the keys saving path
|
||||
* @param string $publicKey 公钥
|
||||
* @param string $privateKey 私钥
|
||||
*/
|
||||
public function __construct($publicKey = null, $privateKey = null)
|
||||
{
|
||||
$this->setKey($publicKey, $privateKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置公钥和私钥
|
||||
* @param string $publicKey 公钥
|
||||
* @param string $privateKey 私钥
|
||||
*/
|
||||
public function setKey($publicKey = null, $privateKey = null)
|
||||
{
|
||||
if (!is_null($publicKey)) {
|
||||
$this->publicKey = $publicKey;
|
||||
}
|
||||
if (!is_null($privateKey)) {
|
||||
$this->privateKey = $privateKey;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* * setup the private key
|
||||
*/
|
||||
private function setupPrivKey()
|
||||
{
|
||||
if (is_resource($this->_privKey)) {
|
||||
return true;
|
||||
}
|
||||
$pem = chunk_split($this->privateKey, 64, "\n");
|
||||
$pem = "-----BEGIN PRIVATE KEY-----\n" . $pem . "-----END PRIVATE KEY-----\n";
|
||||
$this->_privKey = openssl_pkey_get_private($pem);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* * setup the public key
|
||||
*/
|
||||
private function setupPubKey()
|
||||
{
|
||||
if (is_resource($this->_pubKey)) {
|
||||
return true;
|
||||
}
|
||||
$pem = chunk_split($this->publicKey, 64, "\n");
|
||||
$pem = "-----BEGIN PUBLIC KEY-----\n" . $pem . "-----END PUBLIC KEY-----\n";
|
||||
$this->_pubKey = openssl_pkey_get_public($pem);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* * encrypt with the private key
|
||||
*/
|
||||
public function privEncrypt($data)
|
||||
{
|
||||
if (!is_string($data)) {
|
||||
return null;
|
||||
}
|
||||
$this->setupPrivKey();
|
||||
$r = openssl_private_encrypt($data, $encrypted, $this->_privKey);
|
||||
if ($r) {
|
||||
return base64_encode($encrypted);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* * decrypt with the private key
|
||||
*/
|
||||
public function privDecrypt($encrypted)
|
||||
{
|
||||
if (!is_string($encrypted)) {
|
||||
return null;
|
||||
}
|
||||
$this->setupPrivKey();
|
||||
$encrypted = base64_decode($encrypted);
|
||||
$r = openssl_private_decrypt($encrypted, $decrypted, $this->_privKey);
|
||||
if ($r) {
|
||||
return $decrypted;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* * encrypt with public key
|
||||
*/
|
||||
public function pubEncrypt($data)
|
||||
{
|
||||
if (!is_string($data)) {
|
||||
return null;
|
||||
}
|
||||
$this->setupPubKey();
|
||||
$r = openssl_public_encrypt($data, $encrypted, $this->_pubKey);
|
||||
if ($r) {
|
||||
return base64_encode($encrypted);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* * decrypt with the public key
|
||||
*/
|
||||
public function pubDecrypt($crypted)
|
||||
{
|
||||
if (!is_string($crypted)) {
|
||||
return null;
|
||||
}
|
||||
$this->setupPubKey();
|
||||
$crypted = base64_decode($crypted);
|
||||
$r = openssl_public_decrypt($crypted, $decrypted, $this->_pubKey);
|
||||
if ($r) {
|
||||
return $decrypted;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造签名
|
||||
* @param string $dataString 被签名数据
|
||||
* @return string
|
||||
*/
|
||||
public function sign($dataString)
|
||||
{
|
||||
$this->setupPrivKey();
|
||||
$signature = false;
|
||||
openssl_sign($dataString, $signature, $this->_privKey);
|
||||
return base64_encode($signature);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证签名
|
||||
* @param string $dataString 被签名数据
|
||||
* @param string $signString 已经签名的字符串
|
||||
* @return number 1签名正确 0签名错误
|
||||
*/
|
||||
public function verify($dataString, $signString)
|
||||
{
|
||||
$this->setupPubKey();
|
||||
$signature = base64_decode($signString);
|
||||
$flg = openssl_verify($dataString, $signature, $this->_pubKey);
|
||||
return $flg;
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
is_resource($this->_privKey) && @openssl_free_key($this->_privKey);
|
||||
is_resource($this->_pubKey) && @openssl_free_key($this->_pubKey);
|
||||
}
|
||||
}
|
||||
@ -1,438 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace fast;
|
||||
|
||||
use think\Config;
|
||||
|
||||
/**
|
||||
* 通用的树型类
|
||||
* @author XiaoYao <476552238li@gmail.com>
|
||||
*/
|
||||
class Tree
|
||||
{
|
||||
protected static $instance;
|
||||
//默认配置
|
||||
protected $config = [];
|
||||
public $options = [];
|
||||
|
||||
/**
|
||||
* 生成树型结构所需要的2维数组
|
||||
* @var array
|
||||
*/
|
||||
public $arr = [];
|
||||
|
||||
/**
|
||||
* 生成树型结构所需修饰符号,可以换成图片
|
||||
* @var array
|
||||
*/
|
||||
public $icon = array('│', '├', '└');
|
||||
public $nbsp = " ";
|
||||
public $pidname = 'pid';
|
||||
|
||||
public function __construct($options = [])
|
||||
{
|
||||
if ($config = Config::get('tree')) {
|
||||
$this->options = array_merge($this->config, $config);
|
||||
}
|
||||
$this->options = array_merge($this->config, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
* @access public
|
||||
* @param array $options 参数
|
||||
* @return Tree
|
||||
*/
|
||||
public static function instance($options = [])
|
||||
{
|
||||
if (is_null(self::$instance)) {
|
||||
self::$instance = new static($options);
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化方法
|
||||
* @param array $arr 2维数组,例如:
|
||||
* array(
|
||||
* 1 => array('id'=>'1','pid'=>0,'name'=>'一级栏目一'),
|
||||
* 2 => array('id'=>'2','pid'=>0,'name'=>'一级栏目二'),
|
||||
* 3 => array('id'=>'3','pid'=>1,'name'=>'二级栏目一'),
|
||||
* 4 => array('id'=>'4','pid'=>1,'name'=>'二级栏目二'),
|
||||
* 5 => array('id'=>'5','pid'=>2,'name'=>'二级栏目三'),
|
||||
* 6 => array('id'=>'6','pid'=>3,'name'=>'三级栏目一'),
|
||||
* 7 => array('id'=>'7','pid'=>3,'name'=>'三级栏目二')
|
||||
* )
|
||||
* @param string $pidname 父字段名称
|
||||
* @param string $nbsp 空格占位符
|
||||
* @return Tree
|
||||
*/
|
||||
public function init($arr = [], $pidname = null, $nbsp = null)
|
||||
{
|
||||
$this->arr = $arr;
|
||||
if (!is_null($pidname)) {
|
||||
$this->pidname = $pidname;
|
||||
}
|
||||
if (!is_null($nbsp)) {
|
||||
$this->nbsp = $nbsp;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到子级数组
|
||||
* @param int
|
||||
* @return array
|
||||
*/
|
||||
public function getChild($myid)
|
||||
{
|
||||
$newarr = [];
|
||||
foreach ($this->arr as $value) {
|
||||
if (!isset($value['id'])) {
|
||||
continue;
|
||||
}
|
||||
if ($value[$this->pidname] == $myid) {
|
||||
$newarr[$value['id']] = $value;
|
||||
}
|
||||
}
|
||||
return $newarr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取指定节点的所有孩子节点
|
||||
* @param int $myid 节点ID
|
||||
* @param boolean $withself 是否包含自身
|
||||
* @return array
|
||||
*/
|
||||
public function getChildren($myid, $withself = false)
|
||||
{
|
||||
$newarr = [];
|
||||
foreach ($this->arr as $value) {
|
||||
if (!isset($value['id'])) {
|
||||
continue;
|
||||
}
|
||||
if ((string)$value[$this->pidname] == (string)$myid) {
|
||||
$newarr[] = $value;
|
||||
$newarr = array_merge($newarr, $this->getChildren($value['id']));
|
||||
} elseif ($withself && (string)$value['id'] == (string)$myid) {
|
||||
$newarr[] = $value;
|
||||
}
|
||||
}
|
||||
return $newarr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取指定节点的所有孩子节点ID
|
||||
* @param int $myid 节点ID
|
||||
* @param boolean $withself 是否包含自身
|
||||
* @return array
|
||||
*/
|
||||
public function getChildrenIds($myid, $withself = false)
|
||||
{
|
||||
$childrenlist = $this->getChildren($myid, $withself);
|
||||
$childrenids = [];
|
||||
foreach ($childrenlist as $k => $v) {
|
||||
$childrenids[] = $v['id'];
|
||||
}
|
||||
return $childrenids;
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到当前位置父辈数组
|
||||
* @param int
|
||||
* @return array
|
||||
*/
|
||||
public function getParent($myid)
|
||||
{
|
||||
$pid = 0;
|
||||
$newarr = [];
|
||||
foreach ($this->arr as $value) {
|
||||
if (!isset($value['id'])) {
|
||||
continue;
|
||||
}
|
||||
if ($value['id'] == $myid) {
|
||||
$pid = $value[$this->pidname];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($pid) {
|
||||
foreach ($this->arr as $value) {
|
||||
if ($value['id'] == $pid) {
|
||||
$newarr[] = $value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $newarr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到当前位置所有父辈数组
|
||||
* @param int
|
||||
* @param bool $withself 是否包含自己
|
||||
* @return array
|
||||
*/
|
||||
public function getParents($myid, $withself = false)
|
||||
{
|
||||
$pid = 0;
|
||||
$newarr = [];
|
||||
foreach ($this->arr as $value) {
|
||||
if (!isset($value['id'])) {
|
||||
continue;
|
||||
}
|
||||
if ($value['id'] == $myid) {
|
||||
if ($withself) {
|
||||
$newarr[] = $value;
|
||||
}
|
||||
$pid = $value[$this->pidname];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($pid) {
|
||||
$arr = $this->getParents($pid, true);
|
||||
$newarr = array_merge($arr, $newarr);
|
||||
}
|
||||
return $newarr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取指定节点所有父类节点ID
|
||||
* @param int $myid
|
||||
* @param boolean $withself
|
||||
* @return array
|
||||
*/
|
||||
public function getParentsIds($myid, $withself = false)
|
||||
{
|
||||
$parentlist = $this->getParents($myid, $withself);
|
||||
$parentsids = [];
|
||||
foreach ($parentlist as $k => $v) {
|
||||
$parentsids[] = $v['id'];
|
||||
}
|
||||
return $parentsids;
|
||||
}
|
||||
|
||||
/**
|
||||
* 树型结构Option
|
||||
* @param int $myid 表示获得这个ID下的所有子级
|
||||
* @param string $itemtpl 条目模板 如:"<option value=@id @selected @disabled>@spacer@name</option>"
|
||||
* @param mixed $selectedids 被选中的ID,比如在做树型下拉框的时候需要用到
|
||||
* @param mixed $disabledids 被禁用的ID,比如在做树型下拉框的时候需要用到
|
||||
* @param string $itemprefix 每一项前缀
|
||||
* @param string $toptpl 顶级栏目的模板
|
||||
* @return string
|
||||
*/
|
||||
public function getTree($myid, $itemtpl = "<option value=@id @selected @disabled>@spacer@name</option>", $selectedids = '', $disabledids = '', $itemprefix = '', $toptpl = '')
|
||||
{
|
||||
$ret = '';
|
||||
$number = 1;
|
||||
$childs = $this->getChild($myid);
|
||||
if ($childs) {
|
||||
$total = count($childs);
|
||||
foreach ($childs as $value) {
|
||||
$id = $value['id'];
|
||||
$j = $k = '';
|
||||
if ($number == $total) {
|
||||
$j .= $this->icon[2];
|
||||
$k = $itemprefix ? $this->nbsp : '';
|
||||
} else {
|
||||
$j .= $this->icon[1];
|
||||
$k = $itemprefix ? $this->icon[0] : '';
|
||||
}
|
||||
$spacer = $itemprefix ? $itemprefix . $j : '';
|
||||
$selected = $selectedids && in_array($id, (is_array($selectedids) ? $selectedids : explode(',', $selectedids))) ? 'selected' : '';
|
||||
$disabled = $disabledids && in_array($id, (is_array($disabledids) ? $disabledids : explode(',', $disabledids))) ? 'disabled' : '';
|
||||
$value = array_merge($value, array('selected' => $selected, 'disabled' => $disabled, 'spacer' => $spacer));
|
||||
$value = array_combine(array_map(function ($k) {
|
||||
return '@' . $k;
|
||||
}, array_keys($value)), $value);
|
||||
$nstr = strtr((($value["@{$this->pidname}"] == 0 || $this->getChild($id)) && $toptpl ? $toptpl : $itemtpl), $value);
|
||||
$ret .= $nstr;
|
||||
$ret .= $this->getTree($id, $itemtpl, $selectedids, $disabledids, $itemprefix . $k . $this->nbsp, $toptpl);
|
||||
$number++;
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* 树型结构UL
|
||||
* @param int $myid 表示获得这个ID下的所有子级
|
||||
* @param string $itemtpl 条目模板 如:"<li value=@id @selected @disabled>@name @childlist</li>"
|
||||
* @param string $selectedids 选中的ID
|
||||
* @param string $disabledids 禁用的ID
|
||||
* @param string $wraptag 子列表包裹标签
|
||||
* @param string $wrapattr 子列表包裹属性
|
||||
* @return string
|
||||
*/
|
||||
public function getTreeUl($myid, $itemtpl, $selectedids = '', $disabledids = '', $wraptag = 'ul', $wrapattr = '')
|
||||
{
|
||||
$str = '';
|
||||
$childs = $this->getChild($myid);
|
||||
if ($childs) {
|
||||
foreach ($childs as $value) {
|
||||
$id = $value['id'];
|
||||
unset($value['child']);
|
||||
$selected = $selectedids && in_array($id, (is_array($selectedids) ? $selectedids : explode(',', $selectedids))) ? 'selected' : '';
|
||||
$disabled = $disabledids && in_array($id, (is_array($disabledids) ? $disabledids : explode(',', $disabledids))) ? 'disabled' : '';
|
||||
$value = array_merge($value, array('selected' => $selected, 'disabled' => $disabled));
|
||||
$value = array_combine(array_map(function ($k) {
|
||||
return '@' . $k;
|
||||
}, array_keys($value)), $value);
|
||||
$nstr = strtr($itemtpl, $value);
|
||||
$childdata = $this->getTreeUl($id, $itemtpl, $selectedids, $disabledids, $wraptag, $wrapattr);
|
||||
$childlist = $childdata ? "<{$wraptag} {$wrapattr}>" . $childdata . "</{$wraptag}>" : "";
|
||||
$str .= strtr($nstr, array('@childlist' => $childlist));
|
||||
}
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* 菜单数据
|
||||
* @param int $myid
|
||||
* @param string $itemtpl
|
||||
* @param mixed $selectedids
|
||||
* @param mixed $disabledids
|
||||
* @param string $wraptag
|
||||
* @param string $wrapattr
|
||||
* @param int $deeplevel
|
||||
* @return string
|
||||
*/
|
||||
public function getTreeMenu($myid, $itemtpl, $selectedids = '', $disabledids = '', $wraptag = 'ul', $wrapattr = '', $deeplevel = 0)
|
||||
{
|
||||
$str = '';
|
||||
$childs = $this->getChild($myid);
|
||||
if ($childs) {
|
||||
foreach ($childs as $value) {
|
||||
$id = $value['id'];
|
||||
unset($value['child']);
|
||||
$selected = in_array($id, (is_array($selectedids) ? $selectedids : explode(',', $selectedids))) ? 'selected' : '';
|
||||
$disabled = in_array($id, (is_array($disabledids) ? $disabledids : explode(',', $disabledids))) ? 'disabled' : '';
|
||||
$value = array_merge($value, array('selected' => $selected, 'disabled' => $disabled));
|
||||
$value = array_combine(array_map(function ($k) {
|
||||
return '@' . $k;
|
||||
}, array_keys($value)), $value);
|
||||
$bakvalue = array_intersect_key($value, array_flip(['@url', '@caret', '@class']));
|
||||
$value = array_diff_key($value, $bakvalue);
|
||||
$nstr = strtr($itemtpl, $value);
|
||||
$value = array_merge($value, $bakvalue);
|
||||
$childdata = $this->getTreeMenu($id, $itemtpl, $selectedids, $disabledids, $wraptag, $wrapattr, $deeplevel + 1);
|
||||
$childlist = $childdata ? "<{$wraptag} {$wrapattr}>" . $childdata . "</{$wraptag}>" : "";
|
||||
$childlist = strtr($childlist, array('@class' => $childdata ? 'last' : ''));
|
||||
$value = array(
|
||||
'@childlist' => $childlist,
|
||||
'@url' => $childdata || !isset($value['@url']) ? "javascript:;" : $value['@url'],
|
||||
'@addtabs' => $childdata || !isset($value['@url']) ? "" : (stripos($value['@url'], "?") !== false ? "&" : "?") . "ref=addtabs",
|
||||
'@caret' => ($childdata && (!isset($value['@badge']) || !$value['@badge']) ? '<i class="fa fa-angle-left"></i>' : ''),
|
||||
'@badge' => isset($value['@badge']) ? $value['@badge'] : '',
|
||||
'@class' => ($selected ? ' active' : '') . ($disabled ? ' disabled' : '') . ($childdata ? ' treeview' . (config('fastadmin.show_submenu') ? ' treeview-open' : '') : ''),
|
||||
);
|
||||
$str .= strtr($nstr, $value);
|
||||
}
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* 特殊
|
||||
* @param integer $myid 要查询的ID
|
||||
* @param string $itemtpl1 第一种HTML代码方式
|
||||
* @param string $itemtpl2 第二种HTML代码方式
|
||||
* @param mixed $selectedids 默认选中
|
||||
* @param mixed $disabledids 禁用
|
||||
* @param string $itemprefix 前缀
|
||||
* @return string
|
||||
*/
|
||||
public function getTreeSpecial($myid, $itemtpl1, $itemtpl2, $selectedids = 0, $disabledids = 0, $itemprefix = '')
|
||||
{
|
||||
$ret = '';
|
||||
$number = 1;
|
||||
$childs = $this->getChild($myid);
|
||||
if ($childs) {
|
||||
$total = count($childs);
|
||||
foreach ($childs as $id => $value) {
|
||||
$j = $k = '';
|
||||
if ($number == $total) {
|
||||
$j .= $this->icon[2];
|
||||
$k = $itemprefix ? $this->nbsp : '';
|
||||
} else {
|
||||
$j .= $this->icon[1];
|
||||
$k = $itemprefix ? $this->icon[0] : '';
|
||||
}
|
||||
$spacer = $itemprefix ? $itemprefix . $j : '';
|
||||
$selected = $selectedids && in_array($id, (is_array($selectedids) ? $selectedids : explode(',', $selectedids))) ? 'selected' : '';
|
||||
$disabled = $disabledids && in_array($id, (is_array($disabledids) ? $disabledids : explode(',', $disabledids))) ? 'disabled' : '';
|
||||
$value = array_merge($value, array('selected' => $selected, 'disabled' => $disabled, 'spacer' => $spacer));
|
||||
$value = array_combine(array_map(function ($k) {
|
||||
return '@' . $k;
|
||||
}, array_keys($value)), $value);
|
||||
$nstr = strtr(!isset($value['@disabled']) || !$value['@disabled'] ? $itemtpl1 : $itemtpl2, $value);
|
||||
|
||||
$ret .= $nstr;
|
||||
$ret .= $this->getTreeSpecial($id, $itemtpl1, $itemtpl2, $selectedids, $disabledids, $itemprefix . $k . $this->nbsp);
|
||||
$number++;
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 获取树状数组
|
||||
* @param string $myid 要查询的ID
|
||||
* @param string $itemprefix 前缀
|
||||
* @return array
|
||||
*/
|
||||
public function getTreeArray($myid, $itemprefix = '')
|
||||
{
|
||||
$childs = $this->getChild($myid);
|
||||
$n = 0;
|
||||
$data = [];
|
||||
$number = 1;
|
||||
if ($childs) {
|
||||
$total = count($childs);
|
||||
foreach ($childs as $id => $value) {
|
||||
$j = $k = '';
|
||||
if ($number == $total) {
|
||||
$j .= $this->icon[2];
|
||||
$k = $itemprefix ? $this->nbsp : '';
|
||||
} else {
|
||||
$j .= $this->icon[1];
|
||||
$k = $itemprefix ? $this->icon[0] : '';
|
||||
}
|
||||
$spacer = $itemprefix ? $itemprefix . $j : '';
|
||||
$value['spacer'] = $spacer;
|
||||
$data[$n] = $value;
|
||||
$data[$n]['childlist'] = $this->getTreeArray($id, $itemprefix . $k . $this->nbsp);
|
||||
$n++;
|
||||
$number++;
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将getTreeArray的结果返回为二维数组
|
||||
* @param array $data
|
||||
* @param string $field
|
||||
* @return array
|
||||
*/
|
||||
public function getTreeList($data = [], $field = 'name')
|
||||
{
|
||||
$arr = [];
|
||||
foreach ($data as $k => $v) {
|
||||
$childlist = isset($v['childlist']) ? $v['childlist'] : [];
|
||||
unset($v['childlist']);
|
||||
$v[$field] = $v['spacer'] . ' ' . $v[$field];
|
||||
$v['haschild'] = $childlist ? 1 : 0;
|
||||
if ($v['id']) {
|
||||
$arr[] = $v;
|
||||
}
|
||||
if ($childlist) {
|
||||
$arr = array_merge($arr, $this->getTreeList($childlist, $field));
|
||||
}
|
||||
}
|
||||
return $arr;
|
||||
}
|
||||
}
|
||||
@ -1,79 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace fast;
|
||||
|
||||
/**
|
||||
* 版本检测和对比
|
||||
*/
|
||||
class Version
|
||||
{
|
||||
|
||||
/**
|
||||
* 检测版本是否的版本要求的数据中
|
||||
*
|
||||
* @param string $version
|
||||
* @param array $data
|
||||
* @return bool
|
||||
*/
|
||||
public static function check($version, $data = [])
|
||||
{
|
||||
//版本号以.分隔
|
||||
$data = is_array($data) ? $data : [$data];
|
||||
if ($data) {
|
||||
if (in_array("*", $data) || in_array($version, $data)) {
|
||||
return true;
|
||||
}
|
||||
$ver = explode('.', $version);
|
||||
if ($ver) {
|
||||
$versize = count($ver);
|
||||
//验证允许的版本
|
||||
foreach ($data as $m) {
|
||||
$c = explode('.', $m);
|
||||
if (!$c || $versize != count($c)) {
|
||||
continue;
|
||||
}
|
||||
$i = 0;
|
||||
foreach ($c as $a => $k) {
|
||||
if (!self::compare($ver[$a], $k)) {
|
||||
continue 2;
|
||||
} else {
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
if ($i == $versize) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 比较两个版本号
|
||||
*
|
||||
* @param string $v1
|
||||
* @param string $v2
|
||||
* @return boolean
|
||||
*/
|
||||
public static function compare($v1, $v2)
|
||||
{
|
||||
if ($v2 == "*" || $v1 == $v2) {
|
||||
return true;
|
||||
} else {
|
||||
$values = [];
|
||||
$k = explode(',', $v2);
|
||||
foreach ($k as $v) {
|
||||
if (strpos($v, '-') !== false) {
|
||||
list($start, $stop) = explode('-', $v);
|
||||
for ($i = $start; $i <= $stop; $i++) {
|
||||
$values[] = $i;
|
||||
}
|
||||
} else {
|
||||
$values[] = $v;
|
||||
}
|
||||
}
|
||||
return in_array($v1, $values) ? true : false;
|
||||
}
|
||||
}
|
||||
}
|
||||
39
index.html
39
index.html
@ -1,39 +0,0 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>恭喜,站点创建成功!</title>
|
||||
<style>
|
||||
.container {
|
||||
width: 60%;
|
||||
margin: 10% auto 0;
|
||||
background-color: #f0f0f0;
|
||||
padding: 2% 5%;
|
||||
border-radius: 10px
|
||||
}
|
||||
|
||||
ul {
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
ul li {
|
||||
line-height: 2.3
|
||||
}
|
||||
|
||||
a {
|
||||
color: #20a53a
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>恭喜, 站点创建成功!</h1>
|
||||
<h3>这是默认index.html,本页面由系统自动生成</h3>
|
||||
<ul>
|
||||
<li>本页面在FTP根目录下的index.html</li>
|
||||
<li>您可以修改、删除或覆盖本页面</li>
|
||||
<li>FTP相关信息,请到“面板系统后台 > FTP” 查看</li>
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
17
think
17
think
@ -1,17 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: yunwuxin <448901948@qq.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
// 定义项目路径
|
||||
define('APP_PATH', __DIR__ . '/application/');
|
||||
|
||||
// 加载框架引导文件
|
||||
require __DIR__ . '/thinkphp/console.php';
|
||||
Loading…
x
Reference in New Issue
Block a user