fram 6.0.2

This commit is contained in:
zhao 2020-02-12 17:20:07 +08:00
parent f575441479
commit d45856962e
32 changed files with 303 additions and 1137 deletions

201
LICENSE
View File

@ -1,201 +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:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) 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
(d) 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 [yyyy] [name of copyright owner]
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.

32
LICENSE.txt Normal file
View File

@ -0,0 +1,32 @@
ThinkPHP遵循Apache2开源协议发布并提供免费使用。
版权所有Copyright © 2006-2016 by ThinkPHP (http://thinkphp.cn)
All rights reserved。
ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。
Apache Licence是著名的非盈利开源组织Apache采用的协议。
该协议和BSD类似鼓励代码共享和尊重原作者的著作权
允许代码修改,再作为开源或商业软件发布。需要满足
的条件:
1 需要给代码的用户一份Apache Licence
2 如果你修改了代码,需要在被修改的文件中说明;
3 在延伸的代码中(修改和有源代码衍生的代码中)需要
带有原来代码中的协议,商标,专利声明和其他原来作者规
定需要包含的说明;
4 如果再发布的产品中包含一个Notice文件则在Notice文
件中需要带有本协议内容。你可以在Notice中增加自己的
许可但不可以表现为对Apache Licence构成更改。
具体的协议参考http://www.apache.org/licenses/LICENSE-2.0
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

View File

@ -1,67 +1,52 @@
# TaoLer
ThinkPHP 6.0
===============
版本TaoLer 1.0.0
日期2020.1.1
官网http://www.aieok.com
> 运行环境要求PHP7.1+。
#### 项目地址
## 主要新特性
gitee https://www.gitee.com/toogee/Taoler
github https://www.github.com/taoser/TaoLer
* 采用`PHP7`强类型(严格模式)
* 支持更多的`PSR`规范
* 原生多应用支持
* 更强大和易用的查询
* 全新的事件系统
* 模型事件和数据库事件统一纳入事件系统
* 模板引擎分离出核心
* 内部功能中间件化
* SESSION/Cookie机制改进
* 对Swoole以及协程支持改进
* 对IDE更加友好
* 统一和精简大量用法
#### 介绍
## 安装
1. 采用动态密码加密,相同密码在入库时具有唯一性,即使管理员也无法破解,用户信息安全牢固。
2. 系统采用最新版TinkPHP6框架开发底层安全可靠数据查询更快运行效率更高网站速度更快。
3. 自适应前端,桌面和移动端访问界面友好简洁,模块清晰。
4. 完善的后台系统管理便捷动态菜单和权限角色分配系统。支持3级菜单和无限极分类。
5. 双升级系统,可支持自动和手动升级。可在线检测并升级系统,保持网站的更新和安全。
6. 代码开源,不设暗门操作,更安全。
7. 项目会长期维护,优化更新。
~~~
composer create-project topthink/think tp 6.0.*
~~~
如果需要更新框架使用
~~~
composer update topthink/framework
~~~
#### 软件架构
## 文档
thinkphp6+layui+fly
ThinkPHP6核心框架
快速、简单的面向对象的轻量级PHP开发框架出色的性能和至简代码的更注重易用性。代码维护方便。
layui前端
极简、丰盈简单高效模块化UI框架体积轻盈组件丰盈。
Fly模板:
一款至简的社区模板,适合政府机构、教育机构、事业单位、商业企业、个人站长等众多行业领域。
[完全开发手册](https://www.kancloud.cn/manual/thinkphp6_0/content)
#### 安装教程
## 参与开发
1. git下载https://gitee.com/toogee/TaoLer
2. 官网下载http://www.aieok.com
3. 解压后项目绑定域名为public目录对外访问首次安装访问域名http://www.youdomain.com可自动跳转到/install.php/index进行引导安装重新安装需删除根目录下install.lock。
4. 安装前需要先创建mysql数据库(准备:数据库连接地址,数据库用户名,数据库密码,数据库端口,建好在数据库名)
5. 请牢记安装设置的管理员用户名和密码默认admin/123456。前后台的管理员密码一致。前后端管理员账户是独立的前端主要对文章内容的审查管理等操作。
请参阅 [ThinkPHP 核心框架包](https://github.com/top-think/framework)。
#### 使用说明
## 版权信息
1. 安装后本系统已配置默认演示数据,可以删除原数据或者进行数据的修改
2. 后台可设置分类cate,一定要设置英文别名
3. 首页有置顶模块,列表文章模块,右侧包含广告模块,回复展示模块
#### 文档
参考官网分享文章
#### 参与贡献
1. Fork 本仓库
2. 新建 Feat_xxx 分支
3. 提交代码
4. 新建 Pull Request
#### 版权信息
非商业可免费使用,没有功能限制,但不能更改版本信息,如需更改可购买授权。
ThinkPHP遵循Apache2开源协议发布并提供免费使用。
本项目包含的第三方源码和二进制文件之版权信息另行标注。
版权所有Copyright © 2020 by aieok.com (http://www.aieok.com)
版权所有Copyright © 2006-2020 by ThinkPHP (http://thinkphp.cn)
All rights reserved。
ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。
更多细节参阅 [LICENSE.txt](LICENSE.txt)

View File

@ -5,6 +5,7 @@ use PHPMailer\PHPMailer\Exception;
use think\facade\Request;
use think\facade\Db;
use think\facade\Session;
use taoser\think\Auth;
// 应用公共文件
function mailto($to,$title,$content)
{
@ -229,7 +230,7 @@ function getTree($data)
function checkRuleButton($rules_button)
{
$admin_id = Session::get('admin_id');
$auth = new xiaodi\Auth();
$auth = new Auth();
$res = $auth->check($rules_button,$admin_id );
if($res || $admin_id == 1){

View File

@ -13,7 +13,7 @@ use think\facade\Session;
use think\facade\Cache;
use think\facade\View;
use think\facade\Db;
use xiaodi\Auth;
use taoser\think\Auth;
/**
* 控制器基础类

View File

@ -44,9 +44,7 @@ CREATE TABLE `tao_article` (
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=29 DEFAULT CHARSET=utf8;
INSERT INTO `tao_article` VALUES ('1', 'Fly Template 社区模版', '[quote]\r\n 你们认为layui官方Fly Template 社区模版怎么样?\r\n[/quote]\r\nimg[https://cdn.layui.com/upload/2017_11/168_1512035128058_80242.jpg] \r\n你喜欢吗\r\n很多人都说比较喜欢我个人认为不错的这个板子非常喜欢我看到有一些人做了开发可惜的是都没有很好的维护有的漏洞比较多不完善很美好的一个板子但没有长久 的更新,非常的可惜。\r\n如果用别人的不好用那我就做一个出来吧。喜欢的人多关注适当时候放出来大家一起用。\r\n关于详情页的内容解析\r\n该模板自带一个特定语法的编辑器当你把内容存储到数据库后在页面读取后浏览会发现诸如“表情、代码、图片”等无法解析这是因为需要对该内容进行一次转义通常来说这是在服务端完成的但鉴于简单化你还可以直接在前端去解析在模板的detail.html中我们已经把相关的代码写好了你只需打开注释即可在代码的最下面。当然如果觉得编辑器无法满足你的需求你也可以把该编辑器换成别的HTML编辑器或MarkDown编辑器。', '1', '1', '1', '0', '0', '1', '13', '0', '1546698225', '1577772362', '0');
INSERT INTO `tao_article` VALUES ('2', 'PHP是什么', '[quote]\r\n PHP原始为Personal Home Page的缩写已经正式更名为 \"PHP: Hypertext Preprocessor\"。\r\n[/quote]\r\n\r\n自20世纪90年代国内互联网开始发展到现在互联网信息几乎覆盖了我们日常活动所有知识范畴并逐渐成为我们生活、学习、工作中必不可少的一部分。据统计从2003 年开始我国的网页规模基本保持了翻番的增长速度并且呈上升趋势。PHP 语言作为当今最热门的网站程序开发语言,它具有成本低、速度快、可移植性好、 内置丰富的函数库等优点因此被越来越多的企业应用于网站开发中。但随着互联网的不断更新换代PHP语言也出现了不少问题。 [1] \r\n根据动态网站要求PHP语言作为一种语言程序其专用性逐渐在应用过程中显现其技术水平的优劣与否将直接影响网站的运行效率。其特点是具有公开的源代码 在程序设计上与通用型语言如C语言相似性较高因此在操作过程中简单易懂可操作性强。同时PHP语言具有较高的数据传送处理水平和输出水平可以广泛应用在Windows系统及各类Web服务器中。如果数据量较大PHP语言还可以拓宽链接面与各种数据库相连缓解数据存储、检索及维护压力。随着技术的发展PHP 语言搜索引擎还可以量体裁衣,实行个性化服务,如根据客户的喜好进行分类收集储存,极大提高了数据运行效率。', '1', '3', '1', '0', '0', '1', '33', '0', '1546748103', '1578542674', '0');
DROP TABLE IF EXISTS `tao_auth_group`;
CREATE TABLE `tao_auth_group` (

View File

@ -3,7 +3,7 @@ declare(strict_types=1);
namespace app\middleware;
use xiaodi\Auth as UserAuth;
use taoser\think\Auth as UserAuth;
use think\facade\Session;
class Auth

View File

@ -13,12 +13,21 @@
{
"name": "liu21st",
"email": "liu21st@gmail.com"
}
},
{
"name": "yunwuxin",
"email": "448901948@qq.com"
}
],
"require": {
"php": ">=7.1.0",
"topthink/framework": "^6.0.0",
"topthink/think-orm": "^2.0"
"topthink/think-orm": "^2.0",
"phpmailer/phpmailer": "^6.1",
"taoser/think-auth": "^1.0",
"topthink/think-multi-app": "^1.0",
"topthink/think-captcha": "^3.0",
"topthink/think-view": "^1.0"
},
"require-dev": {
"symfony/var-dumper": "^4.2",

154
composer.lock generated
View File

@ -4,20 +4,20 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "5a265ecc15ad9efdc9addab19cbb739a",
"content-hash": "6ebd3a4578a0960080346336d4970bfd",
"packages": [
{
"name": "league/flysystem",
"version": "1.0.63",
"version": "1.0.64",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/flysystem.git",
"reference": "8132daec326565036bc8e8d1876f77ec183a7bd6"
"reference": "d13c43dbd4b791f815215959105a008515d1a2e0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/8132daec326565036bc8e8d1876f77ec183a7bd6",
"reference": "8132daec326565036bc8e8d1876f77ec183a7bd6",
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/d13c43dbd4b791f815215959105a008515d1a2e0",
"reference": "d13c43dbd4b791f815215959105a008515d1a2e0",
"shasum": "",
"mirrors": [
{
@ -35,7 +35,7 @@
},
"require-dev": {
"phpspec/phpspec": "^3.4",
"phpunit/phpunit": "^5.7.10"
"phpunit/phpunit": "^5.7.26"
},
"suggest": {
"ext-fileinfo": "Required for MimeType",
@ -94,7 +94,7 @@
"sftp",
"storage"
],
"time": "2020-01-04T16:30:31+00:00"
"time": "2020-02-05T18:14:17+00:00"
},
{
"name": "league/flysystem-cached-adapter",
@ -499,17 +499,72 @@
"time": "2017-10-23T01:57:42+00:00"
},
{
"name": "topthink/framework",
"version": "6.0.x-dev",
"name": "taoser/think-auth",
"version": "v1.0.0",
"source": {
"type": "git",
"url": "https://github.com/top-think/framework.git",
"reference": "dbe7e9d7159d767b37c05627069289a07138e13e"
"url": "https://github.com/taoser/think-auth.git",
"reference": "19bb04e4fb957a95ff3fdc142939922c19167b43"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/top-think/framework/zipball/dbe7e9d7159d767b37c05627069289a07138e13e",
"reference": "dbe7e9d7159d767b37c05627069289a07138e13e",
"url": "https://api.github.com/repos/taoser/think-auth/zipball/19bb04e4fb957a95ff3fdc142939922c19167b43",
"reference": "19bb04e4fb957a95ff3fdc142939922c19167b43",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=7.1.0",
"topthink/framework": "^6.0"
},
"type": "think-extend",
"extra": {
"think": {
"config": {
"auth": "src/config/auth.php"
}
}
},
"autoload": {
"psr-4": {
"taoser\\think\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache-2.0"
],
"authors": [
{
"name": "taoser",
"email": "changlin_zhao@qq.com"
}
],
"description": "The Auth package forThinkphp6,ThinkPHP6的Auth权限扩展",
"homepage": "https://github.com/taoser/think-auth",
"keywords": [
"think-auth",
"thinkphp6"
],
"time": "2020-02-11T06:16:10+00:00"
},
{
"name": "topthink/framework",
"version": "v6.0.2",
"source": {
"type": "git",
"url": "https://github.com/top-think/framework.git",
"reference": "1444cce94b40a836958380b160a5fb7bfc165daf"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/top-think/framework/zipball/1444cce94b40a836958380b160a5fb7bfc165daf",
"reference": "1444cce94b40a836958380b160a5fb7bfc165daf",
"shasum": "",
"mirrors": [
{
@ -564,7 +619,7 @@
"orm",
"thinkphp"
],
"time": "2020-01-14T12:45:58+00:00"
"time": "2020-01-13T05:48:05+00:00"
},
{
"name": "topthink/think-captcha",
@ -718,7 +773,7 @@
},
{
"name": "topthink/think-orm",
"version": "2.0.x-dev",
"version": "v2.0.31",
"source": {
"type": "git",
"url": "https://github.com/top-think/think-orm.git",
@ -812,16 +867,16 @@
},
{
"name": "topthink/think-view",
"version": "v1.0.13",
"version": "v1.0.14",
"source": {
"type": "git",
"url": "https://github.com/top-think/think-view.git",
"reference": "90803b73f781db5d42619082c4597afc58b2d4c5"
"reference": "edce0ae2c9551ab65f9e94a222604b0dead3576d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/top-think/think-view/zipball/90803b73f781db5d42619082c4597afc58b2d4c5",
"reference": "90803b73f781db5d42619082c4597afc58b2d4c5",
"url": "https://api.github.com/repos/top-think/think-view/zipball/edce0ae2c9551ab65f9e94a222604b0dead3576d",
"reference": "edce0ae2c9551ab65f9e94a222604b0dead3576d",
"shasum": "",
"mirrors": [
{
@ -851,51 +906,7 @@
}
],
"description": "thinkphp template driver",
"time": "2019-10-07T12:23:10+00:00"
},
{
"name": "xiaodi/think-auth",
"version": "3.0.0",
"source": {
"type": "git",
"url": "https://github.com/edenleung/think-auth.git",
"reference": "1ab2e2f8b85bfe55bd218578660c8ec9b90d751c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/edenleung/think-auth/zipball/1ab2e2f8b85bfe55bd218578660c8ec9b90d751c",
"reference": "1ab2e2f8b85bfe55bd218578660c8ec9b90d751c",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=7.1.0",
"topthink/framework": "6.0.*-dev"
},
"type": "library",
"autoload": {
"psr-4": {
"xiaodi\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache-2.0"
],
"authors": [
{
"name": "xiaodi",
"email": "758861884@qq.com"
}
],
"description": "Auth Package For ThinkPHP 6.0",
"homepage": "https://github.com/xiaodit/think-auth",
"time": "2019-04-24T09:54:42+00:00"
"time": "2019-11-06T11:40:13+00:00"
}
],
"packages-dev": [
@ -1027,16 +1038,16 @@
},
{
"name": "symfony/var-dumper",
"version": "v4.4.2",
"version": "v4.4.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/var-dumper.git",
"reference": "be330f919bdb395d1e0c3f2bfb8948512d6bdd99"
"reference": "46b53fd714568af343953c039ff47b67ce8af8d6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/be330f919bdb395d1e0c3f2bfb8948512d6bdd99",
"reference": "be330f919bdb395d1e0c3f2bfb8948512d6bdd99",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/46b53fd714568af343953c039ff47b67ce8af8d6",
"reference": "46b53fd714568af343953c039ff47b67ce8af8d6",
"shasum": "",
"mirrors": [
{
@ -1105,7 +1116,7 @@
"debug",
"dump"
],
"time": "2019-12-18T13:41:29+00:00"
"time": "2020-01-25T12:44:29+00:00"
},
{
"name": "topthink/think-trace",
@ -1163,10 +1174,7 @@
],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": {
"topthink/framework": 20,
"topthink/think-orm": 20
},
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": {

13
config/auth.php Normal file
View File

@ -0,0 +1,13 @@
<?php
// +----------------------------------------------------------------------
// | 权限设置
// +----------------------------------------------------------------------
return[
'auth_on' => true, // 认证开关
'auth_type' => 1, // 认证方式1为实时认证2为登录认证。
'auth_group' => 'auth_group', // 用户组数据表名
'auth_group_access' => 'auth_group_access', // 用户-用户组关系表
'auth_rule' => 'auth_rule', // 权限规则表
'auth_user' => 'admin' // 用户信息表
];

View File

@ -27,14 +27,15 @@ return [
//背景颜色
'bg' => [243, 251, 254],
// 验证码图片高度
'imageH' => 36,
'imageH' => 0,
// 验证码图片宽度
'imageW' => 0,
//算术验证码
'math' => true,
// 添加额外的验证码设置
verify => [
'length'=>'',
],
// verify => [
// 'length'=>4,
// ...
//],
];

View File

@ -4,5 +4,5 @@
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L]
</IfModule>

2
vendor/autoload.php vendored
View File

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderIniteedf9ef926b4b2eb1494379742fbf186::getLoader();
return ComposerAutoloaderInit9b80d9a7bd440d07cac42880e0942921::getLoader();

View File

@ -6,12 +6,12 @@ $vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'xiaodi\\' => array($vendorDir . '/xiaodi/think-auth/src'),
'think\\view\\driver\\' => array($vendorDir . '/topthink/think-view/src'),
'think\\trace\\' => array($vendorDir . '/topthink/think-trace/src'),
'think\\captcha\\' => array($vendorDir . '/topthink/think-captcha/src'),
'think\\app\\' => array($vendorDir . '/topthink/think-multi-app/src'),
'think\\' => array($vendorDir . '/topthink/framework/src/think', $vendorDir . '/topthink/think-helper/src', $vendorDir . '/topthink/think-orm/src', $vendorDir . '/topthink/think-template/src'),
'taoser\\think\\' => array($vendorDir . '/taoser/think-auth/src'),
'app\\' => array($baseDir . '/app'),
'Symfony\\Polyfill\\Php72\\' => array($vendorDir . '/symfony/polyfill-php72'),
'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderIniteedf9ef926b4b2eb1494379742fbf186
class ComposerAutoloaderInit9b80d9a7bd440d07cac42880e0942921
{
private static $loader;
@ -19,15 +19,15 @@ class ComposerAutoloaderIniteedf9ef926b4b2eb1494379742fbf186
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderIniteedf9ef926b4b2eb1494379742fbf186', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit9b80d9a7bd440d07cac42880e0942921', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderIniteedf9ef926b4b2eb1494379742fbf186', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit9b80d9a7bd440d07cac42880e0942921', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticIniteedf9ef926b4b2eb1494379742fbf186::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit9b80d9a7bd440d07cac42880e0942921::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
@ -48,19 +48,19 @@ class ComposerAutoloaderIniteedf9ef926b4b2eb1494379742fbf186
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticIniteedf9ef926b4b2eb1494379742fbf186::$files;
$includeFiles = Composer\Autoload\ComposerStaticInit9b80d9a7bd440d07cac42880e0942921::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequireeedf9ef926b4b2eb1494379742fbf186($fileIdentifier, $file);
composerRequire9b80d9a7bd440d07cac42880e0942921($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequireeedf9ef926b4b2eb1494379742fbf186($fileIdentifier, $file)
function composerRequire9b80d9a7bd440d07cac42880e0942921($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticIniteedf9ef926b4b2eb1494379742fbf186
class ComposerStaticInit9b80d9a7bd440d07cac42880e0942921
{
public static $files = array (
'9b552a3cc426e3287cc811caefa3cf53' => __DIR__ . '/..' . '/topthink/think-helper/src/helper.php',
@ -16,10 +16,6 @@ class ComposerStaticIniteedf9ef926b4b2eb1494379742fbf186
);
public static $prefixLengthsPsr4 = array (
'x' =>
array (
'xiaodi\\' => 7,
),
't' =>
array (
'think\\view\\driver\\' => 18,
@ -27,6 +23,7 @@ class ComposerStaticIniteedf9ef926b4b2eb1494379742fbf186
'think\\captcha\\' => 14,
'think\\app\\' => 10,
'think\\' => 6,
'taoser\\think\\' => 13,
),
'a' =>
array (
@ -58,10 +55,6 @@ class ComposerStaticIniteedf9ef926b4b2eb1494379742fbf186
);
public static $prefixDirsPsr4 = array (
'xiaodi\\' =>
array (
0 => __DIR__ . '/..' . '/xiaodi/think-auth/src',
),
'think\\view\\driver\\' =>
array (
0 => __DIR__ . '/..' . '/topthink/think-view/src',
@ -85,6 +78,10 @@ class ComposerStaticIniteedf9ef926b4b2eb1494379742fbf186
2 => __DIR__ . '/..' . '/topthink/think-orm/src',
3 => __DIR__ . '/..' . '/topthink/think-template/src',
),
'taoser\\think\\' =>
array (
0 => __DIR__ . '/..' . '/taoser/think-auth/src',
),
'app\\' =>
array (
0 => __DIR__ . '/../..' . '/app',
@ -142,9 +139,9 @@ class ComposerStaticIniteedf9ef926b4b2eb1494379742fbf186
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticIniteedf9ef926b4b2eb1494379742fbf186::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticIniteedf9ef926b4b2eb1494379742fbf186::$prefixDirsPsr4;
$loader->fallbackDirsPsr0 = ComposerStaticIniteedf9ef926b4b2eb1494379742fbf186::$fallbackDirsPsr0;
$loader->prefixLengthsPsr4 = ComposerStaticInit9b80d9a7bd440d07cac42880e0942921::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit9b80d9a7bd440d07cac42880e0942921::$prefixDirsPsr4;
$loader->fallbackDirsPsr0 = ComposerStaticInit9b80d9a7bd440d07cac42880e0942921::$fallbackDirsPsr0;
}, null, ClassLoader::class);
}

View File

@ -1,17 +1,17 @@
[
{
"name": "league/flysystem",
"version": "1.0.63",
"version_normalized": "1.0.63.0",
"version": "1.0.64",
"version_normalized": "1.0.64.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/flysystem.git",
"reference": "8132daec326565036bc8e8d1876f77ec183a7bd6"
"reference": "d13c43dbd4b791f815215959105a008515d1a2e0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/8132daec326565036bc8e8d1876f77ec183a7bd6",
"reference": "8132daec326565036bc8e8d1876f77ec183a7bd6",
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/d13c43dbd4b791f815215959105a008515d1a2e0",
"reference": "d13c43dbd4b791f815215959105a008515d1a2e0",
"shasum": "",
"mirrors": [
{
@ -29,7 +29,7 @@
},
"require-dev": {
"phpspec/phpspec": "^3.4",
"phpunit/phpunit": "^5.7.10"
"phpunit/phpunit": "^5.7.26"
},
"suggest": {
"ext-fileinfo": "Required for MimeType",
@ -47,7 +47,7 @@
"spatie/flysystem-dropbox": "Allows you to use Dropbox storage",
"srmklive/flysystem-dropbox-v2": "Allows you to use Dropbox storage for PHP 5 applications"
},
"time": "2020-01-04T16:30:31+00:00",
"time": "2020-02-05T18:14:17+00:00",
"type": "library",
"extra": {
"branch-alias": {
@ -639,17 +639,17 @@
},
{
"name": "symfony/var-dumper",
"version": "v4.4.2",
"version_normalized": "4.4.2.0",
"version": "v4.4.4",
"version_normalized": "4.4.4.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/var-dumper.git",
"reference": "be330f919bdb395d1e0c3f2bfb8948512d6bdd99"
"reference": "46b53fd714568af343953c039ff47b67ce8af8d6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/be330f919bdb395d1e0c3f2bfb8948512d6bdd99",
"reference": "be330f919bdb395d1e0c3f2bfb8948512d6bdd99",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/46b53fd714568af343953c039ff47b67ce8af8d6",
"reference": "46b53fd714568af343953c039ff47b67ce8af8d6",
"shasum": "",
"mirrors": [
{
@ -678,7 +678,7 @@
"ext-intl": "To show region name in time zone dump",
"symfony/console": "To use the ServerDumpCommand and/or the bin/var-dump-server script"
},
"time": "2019-12-18T13:41:29+00:00",
"time": "2020-01-25T12:44:29+00:00",
"bin": [
"Resources/bin/var-dump-server"
],
@ -722,18 +722,75 @@
]
},
{
"name": "topthink/framework",
"version": "6.0.x-dev",
"version_normalized": "6.0.9999999.9999999-dev",
"name": "taoser/think-auth",
"version": "v1.0.0",
"version_normalized": "1.0.0.0",
"source": {
"type": "git",
"url": "https://github.com/top-think/framework.git",
"reference": "dbe7e9d7159d767b37c05627069289a07138e13e"
"url": "https://github.com/taoser/think-auth.git",
"reference": "19bb04e4fb957a95ff3fdc142939922c19167b43"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/top-think/framework/zipball/dbe7e9d7159d767b37c05627069289a07138e13e",
"reference": "dbe7e9d7159d767b37c05627069289a07138e13e",
"url": "https://api.github.com/repos/taoser/think-auth/zipball/19bb04e4fb957a95ff3fdc142939922c19167b43",
"reference": "19bb04e4fb957a95ff3fdc142939922c19167b43",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=7.1.0",
"topthink/framework": "^6.0"
},
"time": "2020-02-11T06:16:10+00:00",
"type": "think-extend",
"extra": {
"think": {
"config": {
"auth": "src/config/auth.php"
}
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"taoser\\think\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache-2.0"
],
"authors": [
{
"name": "taoser",
"email": "changlin_zhao@qq.com"
}
],
"description": "The Auth package forThinkphp6,ThinkPHP6的Auth权限扩展",
"homepage": "https://github.com/taoser/think-auth",
"keywords": [
"think-auth",
"thinkphp6"
]
},
{
"name": "topthink/framework",
"version": "v6.0.2",
"version_normalized": "6.0.2.0",
"source": {
"type": "git",
"url": "https://github.com/top-think/framework.git",
"reference": "1444cce94b40a836958380b160a5fb7bfc165daf"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/top-think/framework/zipball/1444cce94b40a836958380b160a5fb7bfc165daf",
"reference": "1444cce94b40a836958380b160a5fb7bfc165daf",
"shasum": "",
"mirrors": [
{
@ -760,7 +817,7 @@
"mockery/mockery": "^1.2",
"phpunit/phpunit": "^7.0"
},
"time": "2020-01-14T12:45:58+00:00",
"time": "2020-01-13T05:48:05+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@ -949,8 +1006,8 @@
},
{
"name": "topthink/think-orm",
"version": "2.0.x-dev",
"version_normalized": "2.0.9999999.9999999-dev",
"version": "v2.0.31",
"version_normalized": "2.0.31.0",
"source": {
"type": "git",
"url": "https://github.com/top-think/think-orm.git",
@ -1102,17 +1159,17 @@
},
{
"name": "topthink/think-view",
"version": "v1.0.13",
"version_normalized": "1.0.13.0",
"version": "v1.0.14",
"version_normalized": "1.0.14.0",
"source": {
"type": "git",
"url": "https://github.com/top-think/think-view.git",
"reference": "90803b73f781db5d42619082c4597afc58b2d4c5"
"reference": "edce0ae2c9551ab65f9e94a222604b0dead3576d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/top-think/think-view/zipball/90803b73f781db5d42619082c4597afc58b2d4c5",
"reference": "90803b73f781db5d42619082c4597afc58b2d4c5",
"url": "https://api.github.com/repos/top-think/think-view/zipball/edce0ae2c9551ab65f9e94a222604b0dead3576d",
"reference": "edce0ae2c9551ab65f9e94a222604b0dead3576d",
"shasum": "",
"mirrors": [
{
@ -1125,7 +1182,7 @@
"php": ">=7.1.0",
"topthink/think-template": "^2.0"
},
"time": "2019-10-07T12:23:10+00:00",
"time": "2019-11-06T11:40:13+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@ -1144,51 +1201,5 @@
}
],
"description": "thinkphp template driver"
},
{
"name": "xiaodi/think-auth",
"version": "3.0.0",
"version_normalized": "3.0.0.0",
"source": {
"type": "git",
"url": "https://github.com/edenleung/think-auth.git",
"reference": "1ab2e2f8b85bfe55bd218578660c8ec9b90d751c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/edenleung/think-auth/zipball/1ab2e2f8b85bfe55bd218578660c8ec9b90d751c",
"reference": "1ab2e2f8b85bfe55bd218578660c8ec9b90d751c",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=7.1.0",
"topthink/framework": "6.0.*-dev"
},
"time": "2019-04-24T09:54:42+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"xiaodi\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache-2.0"
],
"authors": [
{
"name": "xiaodi",
"email": "758861884@qq.com"
}
],
"description": "Auth Package For ThinkPHP 6.0",
"homepage": "https://github.com/xiaodit/think-auth"
}
]

View File

@ -20,7 +20,7 @@
},
"require-dev": {
"phpspec/phpspec": "^3.4",
"phpunit/phpunit": "^5.7.10"
"phpunit/phpunit": "^5.7.26"
},
"autoload": {
"psr-4": {

View File

@ -558,7 +558,7 @@ abstract class AbstractFtpAdapter extends AbstractAdapter
protected function normalizePermissions($permissions)
{
if (is_numeric($permissions)) {
return $permissions & 0777;
return ((int) $permissions) & 0777;
}
// remove the type identifier

View File

@ -532,15 +532,8 @@ class Ftp extends AbstractFtpAdapter
*/
public function isConnected()
{
try {
return is_resource($this->connection) && ftp_rawlist($this->connection, $this->getRoot()) !== false;
} catch (ErrorException $e) {
if (strpos($e->getMessage(), 'ftp_rawlist') === false) {
throw new ConnectionErrorException($e->getMessage());
}
return false;
}
return is_resource($this->connection)
&& $this->getRawExecResponseCode('NOOP') === 200;
}
/**
@ -571,4 +564,11 @@ class Ftp extends AbstractFtpAdapter
return ftp_rawlist($connection, $options . ' ' . $path);
}
private function getRawExecResponseCode($command)
{
$response = @ftp_raw($this->connection, trim($command));
return (int) preg_replace('/\D/', '', implode(' ', $response));
}
}

2
vendor/services.php vendored
View File

@ -1,5 +1,5 @@
<?php
// This file is automatically generated at:2020-01-16 17:40:25
// This file is automatically generated at:2020-02-12 16:42:46
declare (strict_types = 1);
return array (
0 => 'think\\captcha\\CaptchaService',

View File

@ -56,7 +56,7 @@ class ClassStub extends ConstStub
}
if (false !== strpos($identifier, "class@anonymous\0")) {
$this->value = $identifier = preg_replace_callback('/class@anonymous\x00.*?\.php(?:0x?|:)[0-9a-fA-F]++/', function ($m) {
$this->value = $identifier = preg_replace_callback('/class@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)[0-9a-fA-F]++/', function ($m) {
return class_exists($m[0], false) ? get_parent_class($m[0]).'@anonymous' : $m[0];
}, $identifier);
}

View File

@ -283,7 +283,7 @@ class ExceptionCaster
unset($a[$xPrefix.'string'], $a[Caster::PREFIX_DYNAMIC.'xdebug_message'], $a[Caster::PREFIX_DYNAMIC.'__destructorException']);
if (isset($a[Caster::PREFIX_PROTECTED.'message']) && false !== strpos($a[Caster::PREFIX_PROTECTED.'message'], "class@anonymous\0")) {
$a[Caster::PREFIX_PROTECTED.'message'] = preg_replace_callback('/class@anonymous\x00.*?\.php(?:0x?|:)[0-9a-fA-F]++/', function ($m) {
$a[Caster::PREFIX_PROTECTED.'message'] = preg_replace_callback('/class@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)[0-9a-fA-F]++/', function ($m) {
return class_exists($m[0], false) ? get_parent_class($m[0]).'@anonymous' : $m[0];
}, $a[Caster::PREFIX_PROTECTED.'message']);
}

View File

@ -25,7 +25,7 @@ final class CliContextProvider implements ContextProviderInterface
}
return [
'command_line' => $commandLine = implode(' ', $_SERVER['argv']),
'command_line' => $commandLine = implode(' ', $_SERVER['argv'] ?? []),
'identifier' => hash('crc32b', $commandLine.$_SERVER['REQUEST_TIME_FLOAT']),
];
}

View File

@ -1,4 +1,4 @@
Copyright (c) 2014-2019 Fabien Potencier
Copyright (c) 2014-2020 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -175,7 +175,7 @@ class Handle
'POST Data' => $this->app->request->post(),
'Files' => $this->app->request->file(),
'Cookies' => $this->app->request->cookie(),
'Session' => $this->app->exists('session') ? $this->app->session->all() : [],
'Session' => $this->app->session->all(),
'Server/Request Data' => $this->app->request->server(),
'Environment Variables' => $this->app->request->env(),
'ThinkPHP Constants' => $this->getConst(),

View File

@ -146,10 +146,6 @@ class Think
throw new TemplateNotFoundException('template not exists:' . $template, $template);
}
// 记录视图信息
$this->app['log']
->record('[ VIEW ] ' . $template . ' [ ' . var_export(array_keys($data), true) . ' ]');
$this->template->fetch($template, $data);
}

View File

@ -1,6 +0,0 @@
.idea
.vscode
.DS_Store
vendor
composer.lock
.php_cs.cache

View File

@ -1,201 +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:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) 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
(d) 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 {yyyy} {name of copyright owner}
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.

View File

@ -1,150 +0,0 @@
# think-addons
The ThinkPHP6.0 Auth Package
## 安装
> composer require xiaodi/think-auth
## 配置
### 公共配置
```
// auth配置
'auth' => [
'auth_on' => 1, // 权限开关
'auth_type' => 1, // 认证方式1为实时认证2为登录认证。
'auth_group' => 'auth_group', // 用户组数据不带前缀表名
'auth_group_access' => 'auth_group_access', // 用户-用户组关系不带前缀表名
'auth_rule' => 'auth_rule', // 权限规则不带前缀表名
'auth_user' => 'member', // 用户信息不带前缀表名
],
```
### 导入数据表
> `think_` 为自定义的数据表前缀
```
------------------------------
-- think_auth_rule规则表
-- id:主键name规则唯一标识, title规则中文名称 status 状态为1正常为0禁用condition规则表达式为空表示存在就验证不为空表示按照条件验证
------------------------------
DROP TABLE IF EXISTS `think_auth_rule`;
CREATE TABLE `think_auth_rule` (
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`name` char(80) NOT NULL DEFAULT '',
`title` char(20) NOT NULL DEFAULT '',
`status` tinyint(1) NOT NULL DEFAULT '1',
`condition` char(100) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
------------------------------
-- think_auth_group 用户组表,
-- id主键 title:用户组中文名称, rules用户组拥有的规则id 多个规则","隔开status 状态为1正常为0禁用
------------------------------
DROP TABLE IF EXISTS `think_auth_group`;
CREATE TABLE `think_auth_group` (
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`title` char(100) NOT NULL DEFAULT '',
`status` tinyint(1) NOT NULL DEFAULT '1',
`rules` char(80) NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
------------------------------
-- think_auth_group_access 用户组明细表
-- uid:用户idgroup_id用户组id
------------------------------
DROP TABLE IF EXISTS `think_auth_group_access`;
CREATE TABLE `think_auth_group_access` (
`uid` mediumint(8) unsigned NOT NULL,
`group_id` mediumint(8) unsigned NOT NULL,
UNIQUE KEY `uid_group_id` (`uid`,`group_id`),
KEY `uid` (`uid`),
KEY `group_id` (`group_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
```
## 原理
Auth权限认证是按规则进行认证。
在数据库中我们有
- 规则表think_auth_rule
- 用户组表(think_auth_group)
- 用户组明显表think_auth_group_access
我们在规则表中定义权限规则, 在用户组表中定义每个用户组有哪些权限规则,在用户组明显表中定义用户所属的用户组。
下面举例说明:
我们要判断用户是否有显示一个操作按钮的权限, 首先定义一个规则, 在规则表中添加一个名为 show_button 的规则。 然后在用户组表添加一个用户组定义这个用户组有show_button 的权限规则think_auth_group表中rules字段存得时规则ID多个以逗号隔开 然后在用户组明细表定义 UID 为1 的用户 属于刚才这个的这个用户组。
## 使用
判断权限方法
```
// 引入类库
use think\auth\Auth;
// 获取auth实例
$auth = Auth::instance();
// 检测权限
if($auth->check('show_button',1)){// 第一个参数是规则名称,第二个参数是用户UID
//有显示操作按钮的权限
}else{
//没有显示操作按钮的权限
}
```
Auth类也可以对节点进行认证我们只要将规则名称定义为节点名称就行了。
可以在公共控制器Base中定义_initialize方法
```
<?php
use think\Controller;
use think\auth\Auth;
class Base extends Controller
{
public function _initialize()
{
$controller = request()->controller();
$action = request()->action();
$auth = new Auth();
if(!$auth->check($controller . '-' . $action, session('uid'))){
$this->error('你没有权限访问');
}
}
}
```
这时候我们可以在数据库中添加的节点规则, 格式为: “控制器名称-方法名称”
Auth 类 还可以多个规则一起认证 如:
```
$auth->check('rule1,rule2',uid);
```
表示 认证用户只要有rule1的权限或rule2的权限只要有一个规则的权限认证返回结果就为true 即认证通过。 默认多个权限的关系是 “or” 关系,也就是说多个权限中,只要有个权限通过则通过。 我们也可以定义为 “and” 关系
```
$auth->check('rule1,rule2',uid,'and');
```
第三个参数指定为"and" 表示多个规则以and关系进行认证 这时候多个规则同时通过认证才有权限。只要一个规则没有权限则就会返回false。
Auth认证一个用户可以属于多个用户组。 比如我们对 show_button这个规则进行认证 用户A 同时属于 用户组1 和用户组2 两个用户组 用户组1 没有show_button 规则权限, 但如果用户组2 有show_button 规则权限,则一样会权限认证通过。
```
$auth->getGroups(uid)
```
通过上面代码,可以获得用户所属的所有用户组,方便我们在网站上面显示。
Auth类还可以按用户属性进行判断权限 比如
按照用户积分进行判断, 假设我们的用户表 (think_members) 有字段 score 记录了用户积分。
我在规则表添加规则时定义规则表的condition 字段condition字段是规则条件默认为空 表示没有附加条件,用户组中只有规则 就通过认证。
如果定义了 condition字段用户组中有规则不一定能通过认证程序还会判断是否满足附加条件。
比如我们添加几条规则:
> `name`字段grade1 `condition`字段:{score}<100 <br/>
> `name`字段grade2 `condition`字段:{score}>100 and {score}<200<br/>
> `name`字段grade3 `condition`字段:{score}>200 and {score}<300
这里 `{score}` 表示 `think_members` 表 中字段 `score` 的值。
那么这时候
> $auth->check('grade1', uid) 是判断用户积分是不是0-100<br/>
> $auth->check('grade2', uid) 判断用户积分是不是在100-200<br/>
> $auth->check('grade3', uid) 判断用户积分是不是在200-300

View File

@ -1,26 +0,0 @@
{
"name": "xiaodi/think-auth",
"description": "Auth Package For ThinkPHP 6.0",
"homepage": "https://github.com/xiaodit/think-auth",
"license": "Apache-2.0",
"minimum-stability": "stable",
"version": "3.0.0",
"authors": [
{
"name": "xiaodi",
"email": "758861884@qq.com"
}
],
"support": {
"issues": "https://github.com/xiaodit/think-auth/issues"
},
"require": {
"php": ">=7.1.0",
"topthink/framework": "6.0.*-dev"
},
"autoload": {
"psr-4": {
"xiaodi\\": "src/"
}
}
}

View File

@ -1,301 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkPHP 6.0 [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2019 https://xioadim.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: xiaodi <758861884@qq.com>
// +----------------------------------------------------------------------
namespace xiaodi;
use think\facade\Db;
use think\facade\Config;
use think\facade\Session;
/**
* 权限认证类
* 功能特性:
* 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 表中定义一条规则时如果type为1 condition字段就可以定义规则表达式。 如定义{score}>5 and {score}<100 表示用户的分数在5-100之间时这条规则才会通过。
*/
//数据库
/*
-- ----------------------------
-- think_auth_rule规则表
-- id:主键name规则唯一标识, title规则中文名称 status 状态为1正常为0禁用condition规则表达式为空表示存在就验证不为空表示按照条件验证
-- ----------------------------
DROP TABLE IF EXISTS `think_auth_rule`;
CREATE TABLE `think_auth_rule` (
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`name` char(80) NOT NULL DEFAULT '',
`title` char(20) NOT NULL DEFAULT '',
`type` tinyint(1) NOT NULL DEFAULT '1',
`status` tinyint(1) NOT NULL DEFAULT '1',
`condition` char(100) NOT NULL DEFAULT '', # 规则附件条件,满足附加条件的规则,才认为是有效的规则
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- ----------------------------
-- think_auth_group 用户组表,
-- id主键 title:用户组中文名称, rules用户组拥有的规则id 多个规则","隔开status 状态为1正常为0禁用
-- ----------------------------
DROP TABLE IF EXISTS `think_auth_group`;
CREATE TABLE `think_auth_group` (
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`title` char(100) NOT NULL DEFAULT '',
`status` tinyint(1) NOT NULL DEFAULT '1',
`rules` char(80) NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- ----------------------------
-- think_auth_group_access 用户组明细表
-- uid:用户idgroup_id用户组id
-- ----------------------------
DROP TABLE IF EXISTS `think_auth_group_access`;
CREATE TABLE `think_auth_group_access` (
`uid` mediumint(8) unsigned NOT NULL,
`group_id` mediumint(8) unsigned NOT NULL,
UNIQUE KEY `uid_group_id` (`uid`,`group_id`),
KEY `uid` (`uid`),
KEY `group_id` (`group_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
*/
class Auth
{
/**
* @var object 对象实例
*/
protected static $instance;
/**
* 当前请求实例
* @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' => 'member', // 用户信息表
];
/**
* 类架构函数
* Auth constructor.
*/
public function __construct()
{
//可设置配置项 auth, 此配置项为数组。
if ($auth = Config::get('auth')) {
$this->config = array_merge($this->config, $auth);
}
// 初始化request
$this->request = request();
}
/**
* 初始化
* @access public
* @param array $options 参数
* @return \think\Request
*/
public static function instance($options = [])
{
if (is_null(self::$instance)) {
self::$instance = new static($options);
}
return self::$instance;
}
/**
* 检查权限
* @param $name string|array 需要验证的规则列表,支持逗号分隔的权限规则或索引数组
* @param $uid int 认证用户的id
* @param int $type 认证类型
* @param string $mode 执行check的模式
* @param string $relation 如果为 'or' 表示满足任一条规则即通过验证;如果为 'and'则表示需满足所有规则才能通过验证
* @return bool 通过验证返回true;失败返回false
*/
public function check($name, $uid, $type = 1, $mode = 'url', $relation = 'or')
{
if (!$this->config['auth_on']) {
return true;
}
// 获取用户需要验证的所有有效规则列表
$authList = $this->getAuthList($uid, $type);
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 ($authList as $auth) {
$query = preg_replace('/^.+\?/U', '', $auth);
if ('url' == $mode && $query != $auth) {
parse_str($query, $param); //解析规则中的param
$intersect = array_intersect_assoc($REQUEST, $param);
$auth = preg_replace('/\?.*$/U', '', $auth);
if (in_array($auth, $name) && $intersect == $param) {
//如果节点相符且url参数满足
$list[] = $auth;
}
} else {
if (in_array($auth, $name)) {
$list[] = $auth;
}
}
}
if ('or' == $relation && !empty($list)) {
return true;
}
$diff = array_diff($name, $list);
if ('and' == $relation && empty($diff)) {
return true;
}
return false;
}
/**
* 根据用户id获取用户组,返回值为数组
* @param $uid int 用户id
* @return array 用户所属的用户组 array(
* array('uid'=>'用户id','group_id'=>'用户组id','title'=>'用户组名称','rules'=>'用户组拥有的规则id,多个,号隔开'),
* ...)
*/
public function getGroups($uid)
{
static $groups = [];
if (isset($groups[$uid])) {
return $groups[$uid];
}
// 转换表名
$auth_group_access = $this->parseName($this->config['auth_group_access'], 1);
$auth_group = $this->parseName($this->config['auth_group'], 1);
// 执行查询
$user_groups = Db::view($auth_group_access, 'uid,group_id')
->view($auth_group, 'title,rules', "{$auth_group_access}.group_id={$auth_group}.id", 'LEFT')
->where("{$auth_group_access}.uid='{$uid}' and {$auth_group}.status='1'")
->select();
$groups[$uid] = $user_groups ?: [];
return $groups[$uid];
}
/**
* 获得权限列表
* @param integer $uid 用户id
* @param integer $type
* @return array
*/
protected function getAuthList($uid, $type)
{
static $_authList = []; //保存用户验证通过的权限列表
$t = implode(',', (array)$type);
if (isset($_authList[$uid . $t])) {
return $_authList[$uid . $t];
}
if (2 == $this->config['auth_type'] && Session::has('_auth_list_' . $uid . $t)) {
return Session::get('_auth_list_' . $uid . $t);
}
//读取用户所属用户组
$groups = $this->getGroups($uid);
$ids = []; //保存用户所属用户组设置的所有权限规则id
foreach ($groups as $g) {
$ids = array_merge($ids, explode(',', trim($g['rules'], ',')));
}
$ids = array_unique($ids);
if (empty($ids)) {
$_authList[$uid . $t] = [];
return [];
}
//读取用户组所有权限规则
$map[] = ['id', 'in', $ids];
$map[] = ['status', '=', 1];
$rules = Db::name($this->config['auth_rule'])->where($map)->field('condition,name')->select();
//循环规则,判断结果。
$authList = []; //
foreach ($rules as $rule) {
if (!empty($rule['condition'])) {
//根据condition进行验证
$user = $this->getUserInfo($uid); //获取用户信息,一维数组
$command = preg_replace('/\{(\w*?)\}/', '$user[\'\\1\']', $rule['condition']);
//dump($command); //debug
@(eval('$condition=(' . $command . ');'));
if ($condition) {
$authList[] = strtolower($rule['name']);
}
} else {
//只要存在就记录
$authList[] = strtolower($rule['name']);
}
}
$_authList[$uid . $t] = $authList;
if (2 == $this->config['auth_type']) {
//规则列表结果保存到session
Session::set('_auth_list_' . $uid . $t, $authList);
}
return array_unique($authList);
}
/**
* 获得用户资料,根据自己的情况读取数据库
*/
protected function getUserInfo($uid)
{
static $userinfo = [];
$user = Db::name($this->config['auth_user']);
// 获取用户表主键
$_pk = is_string($user->getPk()) ? $user->getPk() : 'uid';
if (!isset($userinfo[$uid])) {
$userinfo[$uid] = $user->where($_pk, $uid)->find();
}
return $userinfo[$uid];
}
/**
* 字符串命名风格转换
* type 0 将Java风格转换为C的风格 1 将C风格转换为Java的风格
* @access public
* @param string $name 字符串
* @param integer $type 转换类型
* @param bool $ucfirst 首字母是否大写(驼峰规则)
* @return string
*/
public function parseName($name, $type = 0, $ucfirst = true)
{
if ($type) {
$name = preg_replace_callback('/_([a-zA-Z])/', function ($match) {
return strtoupper($match[1]);
}, $name);
return $ucfirst ? ucfirst($name) : lcfirst($name);
}
return strtolower(trim(preg_replace("/[A-Z]/", "_\\0", $name), "_"));
}
}