diff --git a/.bowerrc b/.bowerrc deleted file mode 100644 index 3f53a73..0000000 --- a/.bowerrc +++ /dev/null @@ -1,11 +0,0 @@ -{ - "directory": "public/assets/libs", - "ignoredDependencies": [ - "es6-promise", - "file-saver", - "html2canvas", - "jspdf", - "jspdf-autotable", - "pdfmake" - ] -} diff --git a/.env.sample b/.env.sample deleted file mode 100644 index ccd0f29..0000000 --- a/.env.sample +++ /dev/null @@ -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_ diff --git a/.gitignore b/.gitignore deleted file mode 100644 index fc40f52..0000000 --- a/.gitignore +++ /dev/null @@ -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/ diff --git a/.htaccess b/.htaccess deleted file mode 100644 index 0519ecb..0000000 --- a/.htaccess +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/.well-known/acme-challenge/7nvtXkz8sBXPvilf8pgCFT92nB8BMSqJGE7QumvssGw b/.well-known/acme-challenge/7nvtXkz8sBXPvilf8pgCFT92nB8BMSqJGE7QumvssGw deleted file mode 100644 index 23efaa7..0000000 --- a/.well-known/acme-challenge/7nvtXkz8sBXPvilf8pgCFT92nB8BMSqJGE7QumvssGw +++ /dev/null @@ -1 +0,0 @@ -7nvtXkz8sBXPvilf8pgCFT92nB8BMSqJGE7QumvssGw.Uv4gmVNscdEPWr0XgQ5XqT5eSKxtyUHB8YlcxmaP-2A \ No newline at end of file diff --git a/.well-known/pki-validation/fileauth.txt b/.well-known/pki-validation/fileauth.txt deleted file mode 100644 index b6330ab..0000000 --- a/.well-known/pki-validation/fileauth.txt +++ /dev/null @@ -1 +0,0 @@ -202502140336431i4wbaezjofs55ioi2gzn12k1o2j93etxgaopxrsuat4j51epd \ No newline at end of file diff --git a/404.html b/404.html deleted file mode 100644 index 6096254..0000000 --- a/404.html +++ /dev/null @@ -1,16 +0,0 @@ - - - - -404 Not Found - -

404 Not Found

-
-
Power by 堡塔 (免费,高效和安全的托管控制面板)
- - \ No newline at end of file diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 088bc3f..0000000 --- a/LICENSE +++ /dev/null @@ -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. \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index 655bade..0000000 --- a/README.md +++ /dev/null @@ -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://images.gitee.com/uploads/images/2020/0929/202947_8db2d281_10933.gif "控制台") - -## 问题反馈 - -在使用中有任何问题,请使用以下联系方式联系我们 - -交流社区: 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。 diff --git a/addons/.gitkeep b/addons/.gitkeep deleted file mode 100644 index 8b13789..0000000 --- a/addons/.gitkeep +++ /dev/null @@ -1 +0,0 @@ - diff --git a/application/config.php b/application/config.php deleted file mode 100644 index 4ba3b10..0000000 --- a/application/config.php +++ /dev/null @@ -1,349 +0,0 @@ - -// +---------------------------------------------------------------------- -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_'), - ], -]; diff --git a/application/database.php b/application/database.php deleted file mode 100644 index 8e3b645..0000000 --- a/application/database.php +++ /dev/null @@ -1,56 +0,0 @@ - -// +---------------------------------------------------------------------- - -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, -]; diff --git a/application/index/controller/wms/Chat.php b/application/index/controller/wms/Chat.php index d666e50..0de1c19 100644 --- a/application/index/controller/wms/Chat.php +++ b/application/index/controller/wms/Chat.php @@ -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: //货主类型群聊 diff --git a/application/index/library/chat/Forward.php b/application/index/library/chat/Forward.php new file mode 100644 index 0000000..4e208e8 --- /dev/null +++ b/application/index/library/chat/Forward.php @@ -0,0 +1,123 @@ +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; + } +} diff --git a/bower.json b/bower.json deleted file mode 100644 index 7850980..0000000 --- a/bower.json +++ /dev/null @@ -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": "*" - } -} diff --git a/composer.json b/composer.json deleted file mode 100644 index 5dbdbc3..0000000 --- a/composer.json +++ /dev/null @@ -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" - } - ] -} diff --git a/extend/.htaccess b/extend/.htaccess deleted file mode 100644 index 3418e55..0000000 --- a/extend/.htaccess +++ /dev/null @@ -1 +0,0 @@ -deny from all \ No newline at end of file diff --git a/extend/fast/Auth.php b/extend/fast/Auth.php deleted file mode 100644 index 81429ef..0000000 --- a/extend/fast/Auth.php +++ /dev/null @@ -1,265 +0,0 @@ - -// +---------------------------------------------------------------------- -// | 修改者: 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]; - } -} diff --git a/extend/fast/Date.php b/extend/fast/Date.php deleted file mode 100644 index 8491925..0000000 --- a/extend/fast/Date.php +++ /dev/null @@ -1,226 +0,0 @@ -. - * - * @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)); - } - } -} diff --git a/extend/fast/Form.php b/extend/fast/Form.php deleted file mode 100644 index 92f343d..0000000 --- a/extend/fast/Form.php +++ /dev/null @@ -1,1289 +0,0 @@ - '__token__'); - - /** - * 已创建的标签名称 - * - * @var array - */ - protected $labels = []; - - /** - * 跳过的填充value值的类型 - * - * @var array - */ - protected $skipValueTypes = array('file', 'password', 'checkbox', 'radio'); - - /** - * 转义HTML - * @var boolean - */ - protected $escapeHtml = true; - protected static $instance; - - /** - * 获取单例 - * @param array $options - * @return static - */ - public static function instance($options = []) - { - if (is_null(self::$instance)) { - self::$instance = new static($options); - } - - return self::$instance; - } - - /** - * 设置是否转义 - * @param boolean $escape - */ - public function setEscapeHtml($escape) - { - $this->escapeHtml = $escape; - } - - /** - * 获取转义编码后的值 - * @param string $value - * @return string - */ - public function escape($value) - { - if (!$this->escapeHtml) { - return $value; - } - if (is_array($value)) { - $value = json_encode($value, JSON_UNESCAPED_UNICODE); - } - return htmlspecialchars($value, ENT_QUOTES, 'UTF-8', false); - } - - /** - * 生成Token - * - * @param string $name - * @param string $type - * @return string - */ - public function token($name = '__token__', $type = 'md5') - { - if (function_exists('token')) { - return token($name, $type); - } - - return ''; - } - - /** - * 生成Label标签 - * - * @param string $name - * @param string $value - * @param array $options - * @return string - */ - public function label($name, $value = null, $options = []) - { - $this->labels[] = $name; - - $options = $this->attributes($options); - $value = $this->escape($this->formatLabel($name, $value)); - - return ''; - } - - /** - * Format the label value. - * - * @param string $name - * @param string|null $value - * @return string - */ - protected function formatLabel($name, $value) - { - return $value ?: ucwords(str_replace('_', ' ', $name)); - } - - /** - * 生成文本框(按类型) - * - * @param string $type - * @param string $name - * @param string $value - * @param array $options - * @return string - */ - public function input($type, $name, $value = null, $options = []) - { - if (!isset($options['name'])) { - $options['name'] = $name; - } - - $id = $this->getIdAttribute($name, $options); - - if (!in_array($type, $this->skipValueTypes)) { - $value = $this->getValueAttribute($name, $value); - $options['class'] = isset($options['class']) ? $options['class'] . (stripos($options['class'], 'form-control') !== false ? '' : ' form-control') : 'form-control'; - } - - $merge = compact('type', 'value', 'id'); - $options = array_merge($options, $merge); - - return 'attributes($options) . '>'; - } - - /** - * 生成普通文本框 - * - * @param string $name - * @param string $value - * @param array $options - * @return string - */ - public function text($name, $value = null, $options = []) - { - return $this->input('text', $name, $value, $options); - } - - /** - * 生成密码文本框 - * - * @param string $name - * @param array $options - * @return string - */ - public function password($name, $options = []) - { - return $this->input('password', $name, '', $options); - } - - /** - * 生成隐藏文本框 - * - * @param string $name - * @param string $value - * @param array $options - * @return string - */ - public function hidden($name, $value = null, $options = []) - { - return $this->input('hidden', $name, $value, $options); - } - - /** - * 生成Email文本框 - * - * @param string $name - * @param string $value - * @param array $options - * @return string - */ - public function email($name, $value = null, $options = []) - { - return $this->input('email', $name, $value, $options); - } - - /** - * 生成URL文本框 - * - * @param string $name - * @param string $value - * @param array $options - * @return string - */ - public function url($name, $value = null, $options = []) - { - return $this->input('url', $name, $value, $options); - } - - /** - * 生成上传文件组件 - * - * @param string $name - * @param array $options - * @return string - */ - public function file($name, $options = []) - { - return $this->input('file', $name, null, $options); - } - - /** - * 生成多行文本框 - * - * @param string $name - * @param string $value - * @param array $options - * @return string - */ - public function textarea($name, $value = null, $options = []) - { - if (!isset($options['name'])) { - $options['name'] = $name; - } - - $options = $this->setTextAreaSize($options); - $options['id'] = $this->getIdAttribute($name, $options); - $value = (string)$this->getValueAttribute($name, $value); - - unset($options['size']); - - $options['class'] = isset($options['class']) ? $options['class'] . (stripos($options['class'], 'form-control') !== false ? '' : ' form-control') : 'form-control'; - $options = $this->attributes($options); - - return '' . $this->escape($value) . ''; - } - - /** - * 生成富文本编辑器 - * - * @param string $name - * @param string $value - * @param array $options - * @return string - */ - public function editor($name, $value = null, $options = []) - { - $options['class'] = isset($options['class']) ? $options['class'] . ' editor' : 'editor'; - return $this->textarea($name, $value, $options); - } - - /** - * 设置默认的文本框行列数 - * - * @param array $options - * @return array - */ - protected function setTextAreaSize($options) - { - if (isset($options['size'])) { - return $this->setQuickTextAreaSize($options); - } - - $cols = array_get($options, 'cols', 50); - $rows = array_get($options, 'rows', 5); - - return array_merge($options, compact('cols', 'rows')); - } - - /** - * 根据size设置行数和列数 - * - * @param array $options - * @return array - */ - protected function setQuickTextAreaSize($options) - { - $segments = explode('x', $options['size']); - return array_merge($options, array('cols' => $segments[0], 'rows' => $segments[1])); - } - - /** - * 生成滑块 - * - * @param string $name - * @param string $min - * @param string $max - * @param string $step - * @param string $value - * @param array $options - * @return string - */ - public function slider($name, $min, $max, $step, $value = null, $options = []) - { - $options = array_merge($options, ['data-slider-min' => $min, 'data-slider-max' => $max, 'data-slider-step' => $step, 'data-slider-value' => $value ? $value : '']); - $options['class'] = isset($options['class']) ? $options['class'] . (stripos($options['class'], 'form-control') !== false ? '' : ' slider form-control') : 'slider form-control'; - return $this->input('text', $name, $value, $options); - } - - /** - * 生成下拉列表框 - * - * @param string $name - * @param array $list - * @param mixed $selected - * @param array $options - * @return string - */ - public function select($name, $list = [], $selected = null, $options = []) - { - $selected = $this->getValueAttribute($name, $selected); - - $options['id'] = $this->getIdAttribute($name, $options); - - if (!isset($options['name'])) { - $options['name'] = $name; - } - - $html = []; - foreach ($list as $value => $display) { - $html[] = $this->getSelectOption($display, $value, $selected); - } - $options['class'] = isset($options['class']) ? $options['class'] . (stripos($options['class'], 'form-control') !== false ? '' : ' form-control') : 'form-control'; - - $options = $this->attributes($options); - $list = implode('', $html); - - return "{$list}"; - } - - /** - * 下拉列表(多选) - * - * @param string $name - * @param array $list - * @param mixed $selected - * @param array $options - * @return string - */ - public function selects($name, $list = [], $selected = null, $options = []) - { - $options[] = 'multiple'; - return $this->select($name, $list, $selected, $options); - } - - /** - * 下拉列表(友好) - * - * @param string $name - * @param array $list - * @param mixed $selected - * @param array $options - * @return string - */ - public function selectpicker($name, $list = [], $selected = null, $options = []) - { - $options['class'] = isset($options['class']) ? $options['class'] . ' selectpicker' : 'selectpicker'; - return $this->select($name, $list, $selected, $options); - } - - /** - * 下拉列表(友好)(多选) - * - * @param string $name - * @param array $list - * @param mixed $selected - * @param array $options - * @return string - */ - public function selectpickers($name, $list = [], $selected = null, $options = []) - { - $options[] = 'multiple'; - return $this->selectpicker($name, $list, $selected, $options); - } - - /** - * 生成动态下拉列表 - * - * @param string $name 名称 - * @param mixed $value - * @param string $url 数据源地址 - * @param string $field 显示的字段名称,默认为name - * @param string $primaryKey 主键,数据库中保存的值,默认为id - * @param array $options - * @return string - */ - public function selectpage($name, $value, $url, $field = null, $primaryKey = null, $options = []) - { - $options = array_merge($options, ['data-source' => $url, 'data-field' => $field ? $field : 'name', 'data-primary-key' => $primaryKey ? $primaryKey : 'id']); - $options['class'] = isset($options['class']) ? $options['class'] . ' selectpage' : 'selectpage'; - return $this->text($name, $value, $options); - } - - - /** - * 生成动态下拉列表(复选) - * - * @param string $name 名称 - * @param mixed $value - * @param string $url 数据源地址 - * @param string $field 显示的字段名称,默认为name - * @param string $primaryKey 主键,数据库中保存的值,默认为id - * @param array $options - * @return string - */ - public function selectpages($name, $value, $url, $field = null, $primaryKey = null, $options = []) - { - $options['data-multiple'] = "true"; - return $this->selectpage($name, $value, $url, $field, $primaryKey, $options); - } - - /** - * 生成城市选择框 - * - * @param string $name - * @param mixed $value - * @param array $options - * @return string - */ - public function citypicker($name, $value, $options = []) - { - $options['data-toggle'] = 'city-picker'; - return "
" . $this->text($name, $value, $options) . "
"; - } - - /** - * 生成switch组件 - * - * @param string $name - * @param mixed $value - * @param array $options - * @return string - */ - public function switcher($name, $value, $options = []) - { - $domname = str_replace(['[', ']', '.'], '', $name); - $btn = $this->hidden($name, $value, ['id' => "c-{$domname}"]); - $yes = 1; - $no = 0; - if (isset($options['yes']) && isset($options['no'])) { - $yes = $options['yes']; - $no = $options['no']; - } - $selected = $no == $value ? "fa-flip-horizontal text-gray" : ""; - $disabled = (isset($options['disabled']) && $options['disabled']) || in_array('disabled', $options) ? "disabled" : ''; - $color = isset($options['color']) ? $options['color'] : 'success'; - unset($options['yes'], $options['no'], $options['color'], $options['disabled']); - $attr = $this->attributes($options); - $html = << -EOD; - return $html; - } - - /** - * 日期选择器 - * @param string $name - * @param mixed $value - * @param array $options - * @return string - */ - public function datepicker($name, $value, $options = []) - { - $defaults = [ - 'data-date-format' => "YYYY-MM-DD", - ]; - $options = array_merge($defaults, $options); - $value = is_numeric($value) ? date("Y-m-d", $value) : $value; - return $this->datetimepicker($name, $value, $options); - } - - /** - * 时间选择器 - * - * @param string $name - * @param mixed $value - * @param array $options - * @return string - */ - public function timepicker($name, $value, $options = []) - { - $defaults = [ - 'data-date-format' => "HH:mm:ss", - ]; - $options = array_merge($defaults, $options); - $value = is_numeric($value) ? date("H:i:s", $value) : $value; - return $this->datetimepicker($name, $value, $options); - } - - /** - * 日期时间选择器 - * - * @param string $name - * @param mixed $value - * @param array $options - * @return string - */ - public function datetimepicker($name, $value, $options = []) - { - $defaults = [ - 'data-date-format' => "YYYY-MM-DD HH:mm:ss", - 'data-use-current' => "true", - ]; - $value = is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; - $options = array_merge($defaults, $options); - $options['class'] = isset($options['class']) ? $options['class'] . ' datetimepicker' : 'datetimepicker'; - return $this->text($name, $value, $options); - } - - /** - * 日期区间 - * - * @param string $name - * @param string $value - * @param array $options - * @return string - */ - public function daterange($name, $value, $options = []) - { - $defaults = [ - 'data-locale' => [ - 'format' => 'YYYY-MM-DD' - ] - ]; - $options = array_merge($defaults, $options); - return $this->datetimerange($name, $value, $options); - } - - /** - * 时间区间 - * - * @param string $name - * @param string $value - * @param array $options - * @return string - */ - public function timerange($name, $value, $options = []) - { - $defaults = [ - 'data-locale' => [ - 'format' => 'HH:mm:ss' - ], - 'data-ranges' => [], - 'data-show-custom-range-label' => "false", - 'data-time-picker' => "true", - ]; - $options = array_merge($defaults, $options); - return $this->datetimerange($name, $value, $options); - } - - /** - * 日期时间区间 - * - * @param string $name - * @param string $value - * @param array $options - * @return string - */ - public function datetimerange($name, $value, $options = []) - { - $defaults = [ - 'data-locale' => [ - 'format' => 'YYYY-MM-DD HH:mm:ss' - ] - ]; - $options = array_merge($defaults, $options); - $options['class'] = isset($options['class']) ? $options['class'] . ' datetimerange' : 'datetimerange'; - return $this->text($name, $value, $options); - } - - /** - * 生成字段列表组件 - * - * @param string $name - * @param mixed $value - * @param array $title - * @param string $template - * @param array $options - * @return string - */ - public function fieldlist($name, $value, $title = null, $template = null, $options = []) - { - $append = __('Append'); - $template = $template ? 'data-template="' . $template . '"' : ''; - $attributes = $this->attributes($options); - if (is_null($title)) { - $title = [__('Key'), __('Value')]; - } - $ins = implode("\n", array_map(function ($value) { - return "{$value}"; - }, $title)); - $value = is_array($value) ? json_encode($value) : $value; - $html = << -
- {$ins} -
-
{$append}
- - -EOD; - return $html; - } - - /** - * 生成联动下拉列表 - * - * @param string $url 联动获取数据源的URL地址 - * @param array $names 联动字段名称 - * @param array $values 联动字段默认选中的值 - * @param array $options 扩展属性 - * @return string - */ - public function cxselect($url, $names = [], $values = [], $options = []) - { - $classes = []; - $cxselect = []; - $attributes = $this->attributes($options); - foreach ($names as $index => $value) { - $level = $index + 1; - $class = "cxselect-{$level}"; - $classes[] = $class; - $selectValue = isset($values[$value]) ? $values[$value] : (isset($values[$index]) ? $values[$index] : ''); - - $cxselect[] = << -EOD; - } - $cxselect = implode("\n", $cxselect); - $selects = implode(',', $classes); - $html = << -{$cxselect} - -EOD; - return $html; - } - - /** - * 创建一个下拉列表选择区间组件 - * - * @param string $name - * @param string $begin - * @param string $end - * @param string $selected - * @param array $options - * @return string - */ - public function selectRange($name, $begin, $end, $selected = null, $options = []) - { - $range = array_combine($range = range($begin, $end), $range); - return $this->select($name, $range, $selected, $options); - } - - /** - * 生成选择年组件 - * - * @param string $name - * @param string $begin - * @param string $end - * @param string $selected - * @param array $options - * @return string - */ - public function selectYear($name, $begin, $end, $selected, $options) - { - return call_user_func_array(array($this, 'selectRange'), func_get_args()); - } - - /** - * 生成选择月组件 - * - * @param string $name - * @param string $selected - * @param array $options - * @param string $format - * @return string - */ - public function selectMonth($name, $selected = null, $options = [], $format = '%m') - { - $months = []; - - foreach (range(1, 12) as $month) { - $months[$month] = strftime($format, mktime(0, 0, 0, $month, 1)); - } - - return $this->select($name, $months, $selected, $options); - } - - /** - * 根据传递的值生成option - * - * @param string $display - * @param string $value - * @param string $selected - * @return string - */ - public function getSelectOption($display, $value, $selected) - { - if (is_array($display)) { - return $this->optionGroup($display, $value, $selected); - } - - return $this->option($display, $value, $selected); - } - - /** - * 生成optionGroup - * - * @param array $list - * @param string $label - * @param string $selected - * @return string - */ - protected function optionGroup($list, $label, $selected) - { - $html = []; - - foreach ($list as $value => $display) { - $html[] = $this->option($display, $value, $selected); - } - - return '' . implode('', $html) . ''; - } - - /** - * 生成option选项 - * - * @param string $display - * @param string $value - * @param string $selected - * @return string - */ - protected function option($display, $value, $selected) - { - $selected = $this->getSelectedValue($value, $selected); - - $options = array('value' => $this->escape($value), 'selected' => $selected); - - return 'attributes($options) . '>' . $this->escape($display) . ''; - } - - /** - * 检测value是否选中 - * - * @param string $value - * @param string $selected - * @return string - */ - protected function getSelectedValue($value, $selected) - { - if (is_array($selected)) { - return in_array($value, $selected) ? 'selected' : null; - } - - return ((string)$value == (string)$selected) ? 'selected' : null; - } - - /** - * 生成复选按钮 - * - * @param string $name - * @param mixed $value - * @param bool $checked - * @param array $options - * @return string - */ - public function checkbox($name, $value = 1, $checked = null, $options = []) - { - if ($checked) { - $options['checked'] = 'checked'; - } - - return $this->input('checkbox', $name, $value, $options); - } - - /** - * 生成一组筛选框 - * - * @param string $name - * @param array $list - * @param mixed $checked - * @param array $options - * @return string - */ - public function checkboxs($name, $list, $checked, $options = []) - { - $html = []; - $checked = is_null($checked) ? [] : $checked; - $checked = is_array($checked) ? $checked : explode(',', $checked); - foreach ($list as $k => $v) { - $options['id'] = "{$name}-{$k}"; - $html[] = sprintf(Form::label("{$name}-{$k}", "%s {$v}"), Form::checkbox("{$name}[{$k}]", $k, in_array($k, $checked), $options)); - } - return '
' . implode(' ', $html) . '
'; - } - - /** - * 生成单选按钮 - * - * @param string $name - * @param mixed $value - * @param bool $checked - * @param array $options - * @return string - */ - public function radio($name, $value = null, $checked = null, $options = []) - { - if (is_null($value)) { - $value = $name; - } - - if ($checked) { - $options['checked'] = 'checked'; - } - - return $this->input('radio', $name, $value, $options); - } - - /** - * 生成一组单选框 - * - * @param string $name - * @param array $list - * @param mixed $checked - * @param array $options - * @return string - */ - public function radios($name, $list, $checked = null, $options = []) - { - $html = []; - $checked = is_null($checked) ? key($list) : $checked; - $checked = is_array($checked) ? $checked : explode(',', $checked); - foreach ($list as $k => $v) { - $options['id'] = "{$name}-{$k}"; - $html[] = sprintf(Form::label("{$name}-{$k}", "%s {$v}"), Form::radio($name, $k, in_array($k, $checked), $options)); - } - return '
' . implode(' ', $html) . '
'; - } - - /** - * 生成上传图片组件(单图) - * - * @param string $name - * @param string $value - * @param array $inputAttr - * @param array $uploadAttr - * @param array $chooseAttr - * @param array $previewAttr - * @return string - */ - public function image($name = null, $value = null, $inputAttr = [], $uploadAttr = [], $chooseAttr = [], $previewAttr = []) - { - $default = [ - 'data-mimetype' => 'image/gif,image/jpeg,image/png,image/jpg,image/bmp' - ]; - $uploadAttr = is_array($uploadAttr) ? array_merge($default, $uploadAttr) : $uploadAttr; - $chooseAttr = is_array($chooseAttr) ? array_merge($default, $chooseAttr) : $chooseAttr; - return $this->uploader($name, $value, $inputAttr, $uploadAttr, $chooseAttr, $previewAttr); - } - - /** - * 生成上传图片组件(多图) - * - * @param string $name - * @param string $value - * @param array $inputAttr - * @param array $uploadAttr - * @param array $chooseAttr - * @param array $previewAttr - * @return string - */ - public function images($name = null, $value = null, $inputAttr = [], $uploadAttr = [], $chooseAttr = [], $previewAttr = []) - { - $default = [ - 'data-multiple' => 'true', - 'data-mimetype' => 'image/gif,image/jpeg,image/png,image/jpg,image/bmp' - ]; - $uploadAttr = is_array($uploadAttr) ? array_merge($default, $uploadAttr) : $uploadAttr; - $chooseAttr = is_array($chooseAttr) ? array_merge($default, $chooseAttr) : $chooseAttr; - return $this->uploader($name, $value, $inputAttr, $uploadAttr, $chooseAttr, $previewAttr); - } - - /** - * 生成上传文件组件(单文件) - * - * @param string $name - * @param string $value - * @param array $inputAttr - * @param array $uploadAttr - * @param array $chooseAttr - * @param array $previewAttr - * @return string - */ - public function upload($name = null, $value = null, $inputAttr = [], $uploadAttr = [], $chooseAttr = [], $previewAttr = []) - { - return $this->uploader($name, $value, $inputAttr, $uploadAttr, $chooseAttr, $previewAttr); - } - - /** - * 生成上传文件组件(多文件) - * - * @param string $name - * @param string $value - * @param array $inputAttr - * @param array $uploadAttr - * @param array $chooseAttr - * @param array $previewAttr - * @return string - */ - public function uploads($name = null, $value = null, $inputAttr = [], $uploadAttr = [], $chooseAttr = [], $previewAttr = []) - { - $default = [ - 'data-multiple' => 'true', - ]; - $uploadAttr = is_array($uploadAttr) ? array_merge($default, $uploadAttr) : $uploadAttr; - $chooseAttr = is_array($chooseAttr) ? array_merge($default, $chooseAttr) : $chooseAttr; - return $this->uploader($name, $value, $inputAttr, $uploadAttr, $chooseAttr, $previewAttr); - } - - protected function uploader($name = null, $value = null, $inputAttr = [], $uploadAttr = [], $chooseAttr = [], $previewAttr = []) - { - $domname = str_replace(['[', ']', '.'], '', $name); - $options = [ - 'id' => "plupload-{$domname}", - 'class' => "btn btn-danger plupload", - 'data-input-id' => "c-{$domname}", - ]; - $upload = $uploadAttr === false ? false : true; - $choose = $chooseAttr === false ? false : true; - $preview = $previewAttr === false ? false : true; - if ($preview) { - $options['data-preview-id'] = "p-{$domname}"; - } - $uploadBtn = $upload ? $this->button(' ' . __('Upload'), array_merge($options, $uploadAttr)) : ''; - $options = [ - 'id' => "fachoose-{$domname}", - 'class' => "btn btn-danger fachoose", - 'data-input-id' => "c-{$domname}", - ]; - if ($preview) { - $options['data-preview-id'] = "p-{$domname}"; - } - $chooseBtn = $choose ? $this->button(' ' . __('Choose'), array_merge($options, $chooseAttr)) : ''; - $previewAttrHtml = $this->attributes($previewAttr); - $previewArea = $preview ? '
    ' : ''; - $input = $this->text($name, $value, array_merge(['size' => 50, 'id' => "c-{$domname}"], $inputAttr)); - $html = << - {$input} -
    - {$uploadBtn} - {$chooseBtn} -
    - - - {$previewArea} -EOD; - return $html; - } - - /** - * 生成一个按钮 - * - * @param string $value - * @param array $options - * @return string - */ - public function button($value = null, $options = []) - { - if (!array_key_exists('type', $options)) { - $options['type'] = 'button'; - } - - return 'attributes($options) . '>' . $value . ''; - } - - /** - * 获取ID属性值 - * - * @param string $name - * @param array $attributes - * @return string - */ - public function getIdAttribute($name, $attributes) - { - if (array_key_exists('id', $attributes)) { - return $attributes['id']; - } - - if (in_array($name, $this->labels)) { - return $name; - } - } - - /** - * 获取Value属性值 - * - * @param string $name - * @param string $value - * @return string - */ - public function getValueAttribute($name, $value = null) - { - if (is_null($name)) { - return $value; - } - - if (!is_null($value)) { - return $value; - } - } - - /** - * 数组转换成一个HTML属性字符串。 - * - * @param array $attributes - * @return string - */ - public function attributes($attributes) - { - $html = []; - // 假设我们的keys 和 value 是相同的, - // 拿HTML“required”属性来说,假设是['required']数组, - // 会已 required="required" 拼接起来,而不是用数字keys去拼接 - foreach ((array)$attributes as $key => $value) { - $element = $this->attributeElement($key, $value); - if (!is_null($element)) { - $html[] = $element; - } - } - return count($html) > 0 ? ' ' . implode(' ', $html) : ''; - } - - /** - * 拼接成一个属性。 - * - * @param string $key - * @param string $value - * @return string - */ - protected function attributeElement($key, $value) - { - if (is_numeric($key)) { - $key = $value; - } - if (!is_null($value)) { - if (is_array($value) || stripos($value, '"') !== false) { - $value = is_array($value) ? json_encode($value, JSON_UNESCAPED_UNICODE) : $value; - return $key . "='" . $value . "'"; - } else { - return $key . '="' . $value . '"'; - } - } - } -} - -class Arr -{ - - /** - * Determine whether the given value is array accessible. - * - * @param mixed $value - * @return bool - */ - public static function accessible($value) - { - return is_array($value) || $value instanceof ArrayAccess; - } - - /** - * Determine if the given key exists in the provided array. - * - * @param \ArrayAccess|array $array - * @param string|int $key - * @return bool - */ - public static function exists($array, $key) - { - if ($array instanceof ArrayAccess) { - return $array->offsetExists($key); - } - return array_key_exists($key, $array); - } - - /** - * Get an item from an array using "dot" notation. - * - * @param \ArrayAccess|array $array - * @param string $key - * @param mixed $default - * @return mixed - */ - public static function get($array, $key, $default = null) - { - if (!static::accessible($array)) { - return $default; - } - if (is_null($key)) { - return $array; - } - if (static::exists($array, $key)) { - return $array[$key]; - } - foreach (explode('.', $key) as $segment) { - if (static::accessible($array) && static::exists($array, $segment)) { - $array = $array[$segment]; - } else { - return $default; - } - } - return $array; - } - - /** - * Get all of the given array except for a specified array of items. - * - * @param array $array - * @param array|string $keys - * @return array - */ - public static function except($array, $keys) - { - static::forget($array, $keys); - return $array; - } - - /** - * Remove one or many array items from a given array using "dot" notation. - * - * @param array $array - * @param array|string $keys - * @return void - */ - public static function forget(&$array, $keys) - { - $original = &$array; - $keys = (array)$keys; - if (count($keys) === 0) { - return; - } - foreach ($keys as $key) { - // if the exact key exists in the top-level, remove it - if (static::exists($array, $key)) { - unset($array[$key]); - continue; - } - $parts = explode('.', $key); - // clean up before each pass - $array = &$original; - while (count($parts) > 1) { - $part = array_shift($parts); - if (isset($array[$part]) && is_array($array[$part])) { - $array = &$array[$part]; - } else { - continue 2; - } - } - unset($array[array_shift($parts)]); - } - } -} - -if (!function_exists('array_get')) { - - /** - * Get an item from an array using "dot" notation. - * - * @param \ArrayAccess|array $array - * @param string $key - * @param mixed $default - * @return mixed - */ - function array_get($array, $key, $default = null) - { - return Arr::get($array, $key, $default); - } -} -if (!function_exists('e')) { - - /** - * Escape HTML special characters in a string. - * - * - * @return string - */ - function e($value) - { - if (is_array($value)) { - $value = json_encode($value, JSON_UNESCAPED_UNICODE); - } - return htmlspecialchars($value, ENT_QUOTES, 'UTF-8', false); - } -} -if (!function_exists('array_except')) { - - /** - * Get all of the given array except for a specified array of items. - * - * @param array $array - * @param array|string $keys - * @return array - */ - function array_except($array, $keys) - { - return Arr::except($array, $keys); - } -} diff --git a/extend/fast/Http.php b/extend/fast/Http.php deleted file mode 100644 index 2262d49..0000000 --- a/extend/fast/Http.php +++ /dev/null @@ -1,185 +0,0 @@ - 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; - } - } - } -} diff --git a/extend/fast/Pinyin.php b/extend/fast/Pinyin.php deleted file mode 100644 index 7397c4f..0000000 --- a/extend/fast/Pinyin.php +++ /dev/null @@ -1,36 +0,0 @@ -abbr($chinese, $delimiter); - } else { - $result = $pinyin->permalink($chinese, $delimiter); - } - if ($ucfirst) { - $pinyinArr = explode($delimiter, $result); - $result = implode($delimiter, array_map('ucfirst', $pinyinArr)); - } - - return $result; - } - -} diff --git a/extend/fast/Random.php b/extend/fast/Random.php deleted file mode 100644 index 1e25a1d..0000000 --- a/extend/fast/Random.php +++ /dev/null @@ -1,171 +0,0 @@ -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) - ); - } -} diff --git a/extend/fast/Rsa.php b/extend/fast/Rsa.php deleted file mode 100644 index b64fe69..0000000 --- a/extend/fast/Rsa.php +++ /dev/null @@ -1,179 +0,0 @@ -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); - } -} diff --git a/extend/fast/Tree.php b/extend/fast/Tree.php deleted file mode 100644 index 2c1997c..0000000 --- a/extend/fast/Tree.php +++ /dev/null @@ -1,438 +0,0 @@ - - */ -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 条目模板 如:"" - * @param mixed $selectedids 被选中的ID,比如在做树型下拉框的时候需要用到 - * @param mixed $disabledids 被禁用的ID,比如在做树型下拉框的时候需要用到 - * @param string $itemprefix 每一项前缀 - * @param string $toptpl 顶级栏目的模板 - * @return string - */ - public function getTree($myid, $itemtpl = "", $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 条目模板 如:"
  • @name @childlist
  • " - * @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 . "" : ""; - $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 . "" : ""; - $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']) ? '' : ''), - '@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; - } -} diff --git a/extend/fast/Version.php b/extend/fast/Version.php deleted file mode 100644 index af180a6..0000000 --- a/extend/fast/Version.php +++ /dev/null @@ -1,79 +0,0 @@ - $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; - } - } -} diff --git a/index.html b/index.html deleted file mode 100644 index 86aeca2..0000000 --- a/index.html +++ /dev/null @@ -1,39 +0,0 @@ - - - - - 恭喜,站点创建成功! - - - -
    -

    恭喜, 站点创建成功!

    -

    这是默认index.html,本页面由系统自动生成

    -
      -
    • 本页面在FTP根目录下的index.html
    • -
    • 您可以修改、删除或覆盖本页面
    • -
    • FTP相关信息,请到“面板系统后台 > FTP” 查看
    • -
    -
    - - \ No newline at end of file diff --git a/think b/think deleted file mode 100644 index 8eeb81b..0000000 --- a/think +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env php - -// +---------------------------------------------------------------------- - -// 定义项目路径 -define('APP_PATH', __DIR__ . '/application/'); - -// 加载框架引导文件 -require __DIR__ . '/thinkphp/console.php'; \ No newline at end of file