作者 曹东东

文件初始化

要显示太多修改。

为保证性能只显示 41 of 41+ 个文件。

{
"directory": "public/assets/libs",
"ignoredDependencies": [
"es6-promise",
"file-saver",
"html2canvas",
"jspdf",
"jspdf-autotable"
]
}
\ No newline at end of file
... ...
/application/common/controller/Frontend.php
/nbproject/
/runtime/*
/public/uploads/*
.idea
*.log
*.css.map
!.gitkeep
.env
.svn
.vscode
/public/assets/layui/1.json
... ...
\ No newline at end of file
... ...
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>404</title>
<style>
body{
background-color:#444;
font-size:14px;
}
h3{
font-size:60px;
color:#eee;
text-align:center;
padding-top:30px;
font-weight:normal;
}
</style>
</head>
<body>
<h3>404,您请求的文件不存在!</h3>
</body>
</html>
... ...
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
... ...
FastAdmin是一款基于ThinkPHP5+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群: [636393962](https://jq.qq.com/?_wv=1027&k=487PNBb)(满) [708784003](https://jq.qq.com/?_wv=1027&k=5ObjtwM)(满) [964776039](https://jq.qq.com/?_wv=1027&k=59qjU2P)(3群) [749803490](https://jq.qq.com/?_wv=1027&k=5tczi88)(满) [767103006](https://jq.qq.com/?_wv=1027&k=5Z1U751)(满) [675115483](https://jq.qq.com/?_wv=1027&k=54I6mts)(6群)
Github: https://github.com/karsonzhang/fastadmin
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://layer.layui.com
DropzoneJS: https://www.dropzonejs.com
## 版权信息
FastAdmin遵循Apache2开源协议发布,并提供免费使用。
本项目包含的第三方源码和二进制文件之版权信息另行标注。
版权所有Copyright © 2017-2020 by FastAdmin (https://www.fastadmin.net)
All rights reserved。
... ...
--------2021-03-09 基地管理房间预约新加sql -----
DROP TABLE IF EXISTS `fa_project_building`;
CREATE TABLE `fa_project_building` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`school_id` int(11) NOT NULL COMMENT '所属学校ID',
`building_name` varchar(200) NOT NULL COMMENT '楼栋名称',
`building_no` varchar(30) DEFAULT NULL COMMENT '楼栋编号',
`building_desc` text NOT NULL COMMENT '楼栋介绍',
`createtime` int(11) DEFAULT NULL COMMENT '创建时间',
`updatetime` int(11) DEFAULT NULL COMMENT '更新时间',
`deletetime` int(11) DEFAULT NULL COMMENT '删除时间',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `building_no` (`building_no`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='楼栋管理表';
DROP TABLE IF EXISTS `fa_project_floor`;
CREATE TABLE `fa_project_floor` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`building_id` int(11) NOT NULL COMMENT '所属楼栋ID',
`school_id` int(11) NOT NULL COMMENT '所属学校ID',
`floor_name` varchar(200) NOT NULL COMMENT '楼层名称',
`floor_no` varchar(30) DEFAULT NULL COMMENT '楼栋编号',
`createtime` int(11) DEFAULT NULL COMMENT '创建时间',
`updatetime` int(11) DEFAULT NULL COMMENT '更新时间',
`deletetime` int(11) DEFAULT NULL COMMENT '删除时间',
PRIMARY KEY (`id`) USING BTREE,
KEY `building_id_2` (`building_id`) USING BTREE,
UNIQUE KEY `building_id` (`building_id`,`floor_no`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='楼层管理表';
DROP TABLE IF EXISTS `fa_project_room`;
CREATE TABLE `fa_project_room` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`building_id` int(11) NOT NULL COMMENT '所属楼栋ID',
`floor_id` int(11) NOT NULL COMMENT '所属楼层ID',
`school_id` int(11) NOT NULL COMMENT '所属学校ID',
`college_id` int(11) NOT NULL COMMENT '所属学院ID',
`specialty_id` int(11) NOT NULL COMMENT '所属学院ID',
`room_name` varchar(200) NOT NULL COMMENT '房间名称',
`room_no` varchar(30) NOT NULL COMMENT '房间编号',
`room_type` tinyint(2) NOT NULL COMMENT '【1:会议室;2:办公室;3:路演大厅;4:公共办公区;5:实验室;6:多媒体教室;】',
`room_status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '【0:不开放;1:开放;】',
`build_space` decimal(10,2) NOT NULL COMMENT '房间建筑面积',
`room_space` decimal(10,2) NOT NULL COMMENT '房间使用面积',
`count_people`int(11) NOT NULL COMMENT '容纳人数',
`room_desc` text NOT NULL COMMENT '房间介绍',
`createtime` int(11) DEFAULT NULL COMMENT '创建时间',
`updatetime` int(11) DEFAULT NULL COMMENT '更新时间',
`deletetime` int(11) DEFAULT NULL COMMENT '删除时间',
PRIMARY KEY (`id`) USING BTREE,
KEY `building_id` (`building_id`) USING BTREE,
KEY `floor_id` (`floor_id`) USING BTREE,
KEY `college_id` (`college_id`) USING BTREE,
KEY `specialty_id` (`specialty_id`) USING BTREE,
UNIQUE KEY `building_id_2` (`building_id`,`floor_id`,`room_no`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='房间管理表';
DROP TABLE IF EXISTS `fa_project_floor`;
CREATE TABLE `fa_project_floor` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`building_id` int(11) NOT NULL COMMENT '所属楼栋ID',
`school_id` int(11) NOT NULL COMMENT '所属学校ID',
`floor_name` varchar(200) NOT NULL COMMENT '楼层名称',
`floor_no` varchar(30) DEFAULT NULL COMMENT '楼栋编号',
`createtime` int(11) DEFAULT NULL COMMENT '创建时间',
`updatetime` int(11) DEFAULT NULL COMMENT '更新时间',
`deletetime` int(11) DEFAULT NULL COMMENT '删除时间',
PRIMARY KEY (`id`) USING BTREE,
KEY `building_id_2` (`building_id`) USING BTREE,
UNIQUE KEY `building_id` (`building_id`,`floor_no`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='楼层管理表';
DROP TABLE IF EXISTS `fa_project_room_order`;
CREATE TABLE `fa_project_room_order` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`room_id` int(11) NOT NULL COMMENT '房间ID',
`user_id` int(11) NOT NULL COMMENT '申请人ID',
`apply_date` date NOT NULL COMMENT '预约日期',
`start_time` int(11) NOT NULL COMMENT '预约开始时间',
`end_time` int(11) NOT NULL COMMENT '预约结束时间',
`use_count` int(4) NOT NULL COMMENT '使用人数',
`status` tinyint(2) NOT NULL default '1' COMMENT '【1:待审核;2:已通过;3:未通过;4:预约已取消】',
`apply_type` tinyint(1) NOT NULL DEFAULT '1' COMMENT '【1:个人;2:公司;】',
`apply_desc` text NOT NULL COMMENT '使用设备说明',
`createtime` int(11) DEFAULT NULL COMMENT '创建时间',
`updatetime` int(11) DEFAULT NULL COMMENT '更新时间',
`deletetime` int(11) DEFAULT NULL COMMENT '删除时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='基地预约申请表';
--------2021-03-10 sunshuai 项目双选 修改 fa_project_double 表 sql -----
ALTER TABLE `innovation`.`fa_project_double`
MODIFY COLUMN `project_des` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '双选项目描述' AFTER `project_type`,
MODIFY COLUMN `members_standard` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '成员要求' AFTER `project_des`,
MODIFY COLUMN `teachers_standard` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '指导教师要求' AFTER `members_standard`;
ALTER TABLE `innovation`.`fa_project_double`
ADD COLUMN `register_id` int(11) NULL DEFAULT 0 COMMENT 'register表id' AFTER `user_id`;
--------2021-03-12 sunshuai 项目双选 修改 fa_project_double 表 sql -----
ALTER TABLE `innovation`.`fa_project_double`
ADD COLUMN `school_id` int(11) NOT NULL DEFAULT 0 AFTER `project_container_id`;
--------2021-03-18 sunshuai 标签表 修改 fa_match_tags 表 sql -----
ALTER TABLE `innovation`.`fa_match_tags`
ADD COLUMN `default` tinyint(1) NULL DEFAULT 0 COMMENT '默认标签 1:是0否' AFTER `school_id`;
ALTER TABLE `innovation`.`fa_review_tags`
ADD COLUMN `default` tinyint(1) NULL DEFAULT 0 COMMENT '默认标签1是0否' AFTER `school_id`;
CREATE TABLE `innovation`.`fa_banner` (
`banner_id` int(11) NOT NULL AUTO_INCREMENT,
`image` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT 'banner地址',
`url` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '跳转地址',
`school_id` int(11) NULL DEFAULT 0 COMMENT '学校id',
`sort` int(11) NOT NULL DEFAULT 1 COMMENT '显示顺序',
`status` enum('normal','hidden') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'normal' COMMENT '状态',
`createtime` int(11) NOT NULL DEFAULT 0,
`updatetime` int(11) NOT NULL,
`deletetime` int(11) DEFAULT NULL,
PRIMARY KEY (`banner_id`)
);
ALTER TABLE `innovation`.`fa_banner` ENGINE = InnoDB;
\ No newline at end of file
... ...
{"license":"regular","licenseto":"11004","licensekey":"UnHqP5791arJzSlC RbYOIxfUlzOnp7apQN7cfg==","files":["public\\assets\\addons\\nkeditor\\css\\common.css","public\\assets\\addons\\nkeditor\\css\\richtext.css","public\\assets\\addons\\nkeditor\\img\\download.png","public\\assets\\addons\\nkeditor\\img\\downloading.png","public\\assets\\addons\\nkeditor\\js\\customplugin.js","public\\assets\\addons\\nkeditor\\lang\\ar.js","public\\assets\\addons\\nkeditor\\lang\\en.js","public\\assets\\addons\\nkeditor\\lang\\ja-JP.js","public\\assets\\addons\\nkeditor\\lang\\ko.js","public\\assets\\addons\\nkeditor\\lang\\ru.js","public\\assets\\addons\\nkeditor\\lang\\zh-CN.js","public\\assets\\addons\\nkeditor\\lang\\zh-TW.js","public\\assets\\addons\\nkeditor\\less\\richtext.less","public\\assets\\addons\\nkeditor\\nkeditor.js","public\\assets\\addons\\nkeditor\\nkeditor.min.js","public\\assets\\addons\\nkeditor\\plugins\\anchor\\anchor.js","public\\assets\\addons\\nkeditor\\plugins\\autoheight\\autoheight.js","public\\assets\\addons\\nkeditor\\plugins\\baidumap\\baidumap.js","public\\assets\\addons\\nkeditor\\plugins\\baidumap\\index.html","public\\assets\\addons\\nkeditor\\plugins\\baidumap\\map.html","public\\assets\\addons\\nkeditor\\plugins\\clearhtml\\clearhtml.js","public\\assets\\addons\\nkeditor\\plugins\\code\\code.js","public\\assets\\addons\\nkeditor\\plugins\\code\\pretty.js","public\\assets\\addons\\nkeditor\\plugins\\code\\prism.css","public\\assets\\addons\\nkeditor\\plugins\\code\\prism.js","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\emoticons.js","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\0.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\1.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\10.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\100.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\101.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\102.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\103.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\104.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\105.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\106.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\107.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\108.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\109.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\11.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\110.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\111.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\112.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\113.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\114.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\115.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\116.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\117.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\118.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\119.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\12.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\120.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\121.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\122.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\123.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\124.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\125.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\126.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\127.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\128.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\129.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\13.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\130.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\131.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\132.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\133.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\134.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\14.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\15.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\16.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\17.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\18.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\19.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\2.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\20.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\21.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\22.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\23.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\24.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\25.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\26.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\27.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\28.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\29.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\3.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\30.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\31.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\32.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\33.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\34.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\35.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\36.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\37.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\38.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\39.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\4.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\40.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\41.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\42.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\43.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\44.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\45.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\46.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\47.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\48.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\49.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\5.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\50.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\51.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\52.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\53.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\54.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\55.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\56.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\57.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\58.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\59.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\6.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\60.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\61.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\62.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\63.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\64.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\65.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\66.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\67.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\68.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\69.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\7.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\70.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\71.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\72.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\73.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\74.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\75.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\76.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\77.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\78.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\79.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\8.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\80.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\81.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\82.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\83.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\84.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\85.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\86.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\87.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\88.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\89.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\9.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\90.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\91.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\92.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\93.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\94.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\95.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\96.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\97.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\98.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\99.gif","public\\assets\\addons\\nkeditor\\plugins\\emoticons\\images\\static.gif","public\\assets\\addons\\nkeditor\\plugins\\filemanager\\css\\filemanager.min.css","public\\assets\\addons\\nkeditor\\plugins\\filemanager\\filemanager.js","public\\assets\\addons\\nkeditor\\plugins\\filemanager\\FManager.js","public\\assets\\addons\\nkeditor\\plugins\\filemanager\\FManager.min.js","public\\assets\\addons\\nkeditor\\plugins\\fixtoolbar\\fixtoolbar.js","public\\assets\\addons\\nkeditor\\plugins\\flash\\flash.js","public\\assets\\addons\\nkeditor\\plugins\\graft\\css\\images\\addimg.png","public\\assets\\addons\\nkeditor\\plugins\\graft\\css\\images\\blur.png","public\\assets\\addons\\nkeditor\\plugins\\graft\\css\\images\\brush.png","public\\assets\\addons\\nkeditor\\plugins\\graft\\css\\images\\delimg.png","public\\assets\\addons\\nkeditor\\plugins\\graft\\css\\images\\delimgH.png","public\\assets\\addons\\nkeditor\\plugins\\graft\\css\\images\\empty.png","public\\assets\\addons\\nkeditor\\plugins\\graft\\css\\images\\emptyH.png","public\\assets\\addons\\nkeditor\\plugins\\graft\\css\\images\\eraser.png","public\\assets\\addons\\nkeditor\\plugins\\graft\\css\\images\\init.png","public\\assets\\addons\\nkeditor\\plugins\\graft\\css\\images\\redo.png","public\\assets\\addons\\nkeditor\\plugins\\graft\\css\\images\\redoH.png","public\\assets\\addons\\nkeditor\\plugins\\graft\\css\\images\\save.png","public\\assets\\addons\\nkeditor\\plugins\\graft\\css\\images\\scale.png","public\\assets\\addons\\nkeditor\\plugins\\graft\\css\\images\\scaleH.png","public\\assets\\addons\\nkeditor\\plugins\\graft\\css\\images\\size.png","public\\assets\\addons\\nkeditor\\plugins\\graft\\css\\images\\undo.png","public\\assets\\addons\\nkeditor\\plugins\\graft\\css\\images\\undoH.png","public\\assets\\addons\\nkeditor\\plugins\\graft\\css\\scrawl.css","public\\assets\\addons\\nkeditor\\plugins\\graft\\css\\scrawl.css.map","public\\assets\\addons\\nkeditor\\plugins\\graft\\css\\scrawl.scss","public\\assets\\addons\\nkeditor\\plugins\\graft\\graft.js","public\\assets\\addons\\nkeditor\\plugins\\graft\\index.html","public\\assets\\addons\\nkeditor\\plugins\\graft\\scrawl.js","public\\assets\\addons\\nkeditor\\plugins\\image\\image.js","public\\assets\\addons\\nkeditor\\plugins\\image\\images\\align_left.gif","public\\assets\\addons\\nkeditor\\plugins\\image\\images\\align_right.gif","public\\assets\\addons\\nkeditor\\plugins\\image\\images\\align_top.gif","public\\assets\\addons\\nkeditor\\plugins\\image\\images\\refresh.png","public\\assets\\addons\\nkeditor\\plugins\\insertfile\\insertfile.js","public\\assets\\addons\\nkeditor\\plugins\\lineheight\\lineheight.js","public\\assets\\addons\\nkeditor\\plugins\\link\\link.js","public\\assets\\addons\\nkeditor\\plugins\\map\\map.html","public\\assets\\addons\\nkeditor\\plugins\\map\\map.js","public\\assets\\addons\\nkeditor\\plugins\\media\\media.js","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\BUpload.js","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\BUpload.min.js","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\aep.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\asp.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\avi.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\c.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\conf.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\css.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\default.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\doc.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\eml.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\eps.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\fla.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\htm.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\idn.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\ini.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\java.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\js.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\jsf.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\markdown.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\mdb.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\midi.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\mov.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\mp3.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\mpeg.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\pdf.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\php.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\ppt.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\psd.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\pst.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\pub.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\py.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\rb.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\rmvb.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\scss.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\sql.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\tif.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\txt.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\vsd.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\wav.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\wma.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\wmv.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\xls.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\xml.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\icons\\zip.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\images\\dialog-title-bg.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\images\\icons-all.gif","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\images\\icons.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\images\\image.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\images\\loader.gif","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\images\\progress.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\images\\success.png","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\upload.css","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\upload.css.map","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\upload.min.css","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\css\\upload.scss","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\multiimage.js","public\\assets\\addons\\nkeditor\\plugins\\multiimage\\template\\template.html","public\\assets\\addons\\nkeditor\\plugins\\pagebreak\\pagebreak.js","public\\assets\\addons\\nkeditor\\plugins\\plainpaste\\plainpaste.js","public\\assets\\addons\\nkeditor\\plugins\\preview\\preview.js","public\\assets\\addons\\nkeditor\\plugins\\quickformat\\quickformat.js","public\\assets\\addons\\nkeditor\\plugins\\quote\\quote.js","public\\assets\\addons\\nkeditor\\plugins\\table\\table.js","public\\assets\\addons\\nkeditor\\plugins\\template\\html\\1.html","public\\assets\\addons\\nkeditor\\plugins\\template\\html\\2.html","public\\assets\\addons\\nkeditor\\plugins\\template\\html\\3.html","public\\assets\\addons\\nkeditor\\plugins\\template\\template.js","public\\assets\\addons\\nkeditor\\plugins\\wordpaste\\wordpaste.js","public\\assets\\addons\\nkeditor\\themes\\app.css","public\\assets\\addons\\nkeditor\\themes\\black\\editor.css","public\\assets\\addons\\nkeditor\\themes\\black\\editor.css.map","public\\assets\\addons\\nkeditor\\themes\\black\\editor.min.css","public\\assets\\addons\\nkeditor\\themes\\black\\editor.scss","public\\assets\\addons\\nkeditor\\themes\\black\\images\\nkeditor.png","public\\assets\\addons\\nkeditor\\themes\\black\\images\\nkeditor.svg","public\\assets\\addons\\nkeditor\\themes\\blue\\editor.css","public\\assets\\addons\\nkeditor\\themes\\blue\\editor.css.map","public\\assets\\addons\\nkeditor\\themes\\blue\\editor.min.css","public\\assets\\addons\\nkeditor\\themes\\blue\\editor.scss","public\\assets\\addons\\nkeditor\\themes\\blue\\images\\nkeditor.png","public\\assets\\addons\\nkeditor\\themes\\blue\\images\\nkeditor.svg","public\\assets\\addons\\nkeditor\\themes\\common\\anchor.gif","public\\assets\\addons\\nkeditor\\themes\\common\\blank.gif","public\\assets\\addons\\nkeditor\\themes\\common\\common.css","public\\assets\\addons\\nkeditor\\themes\\common\\common.css.map","public\\assets\\addons\\nkeditor\\themes\\common\\common.scss","public\\assets\\addons\\nkeditor\\themes\\common\\dialog-title-bg.png","public\\assets\\addons\\nkeditor\\themes\\common\\flash.gif","public\\assets\\addons\\nkeditor\\themes\\common\\flash.png","public\\assets\\addons\\nkeditor\\themes\\common\\flash.svg","public\\assets\\addons\\nkeditor\\themes\\common\\icons-all.gif","public\\assets\\addons\\nkeditor\\themes\\common\\loading.gif","public\\assets\\addons\\nkeditor\\themes\\common\\media.gif","public\\assets\\addons\\nkeditor\\themes\\common\\play.png","public\\assets\\addons\\nkeditor\\themes\\common\\play.svg","public\\assets\\addons\\nkeditor\\themes\\common\\rm.gif","public\\assets\\addons\\nkeditor\\themes\\default\\editor.css","public\\assets\\addons\\nkeditor\\themes\\default\\editor.min.css","public\\assets\\addons\\nkeditor\\themes\\default\\images\\background.png","public\\assets\\addons\\nkeditor\\themes\\default\\images\\default.png","public\\assets\\addons\\nkeditor\\themes\\default\\images\\scrawl.png","public\\assets\\addons\\nkeditor\\themes\\grey\\editor.css","public\\assets\\addons\\nkeditor\\themes\\grey\\editor.css.map","public\\assets\\addons\\nkeditor\\themes\\grey\\editor.min.css","public\\assets\\addons\\nkeditor\\themes\\grey\\editor.scss","public\\assets\\addons\\nkeditor\\themes\\grey\\images\\nkeditor.png","public\\assets\\addons\\nkeditor\\themes\\grey\\images\\nkeditor.svg","public\\assets\\addons\\nkeditor\\themes\\primary\\editor.css","public\\assets\\addons\\nkeditor\\themes\\primary\\editor.css.map","public\\assets\\addons\\nkeditor\\themes\\primary\\editor.min.css","public\\assets\\addons\\nkeditor\\themes\\primary\\editor.scss","public\\assets\\addons\\nkeditor\\themes\\primary\\images\\nkeditor.png","public\\assets\\addons\\nkeditor\\themes\\primary\\images\\nkeditor.svg"]}
\ No newline at end of file
... ...
<?php
namespace addons\nkeditor;
use app\common\library\Menu;
use think\Addons;
/**
* 富文本编辑器插件
*/
class Nkeditor extends Addons
{
/**
* 插件安装方法
* @return bool
*/
public function install()
{
return true;
}
/**
* 插件卸载方法
* @return bool
*/
public function uninstall()
{
return true;
}
/**
* 插件启用方法
* @return bool
*/
public function enable()
{
return true;
}
/**
* 插件禁用方法
* @return bool
*/
public function disable()
{
return true;
}
/**
* @param $params
*/
public function configInit(&$params)
{
$config = $this->getConfig();
$params['nkeditor'] = ['theme' => $config['theme'], 'wordimageserver' => $config['wordimageserver']];
}
}
... ...
# NKeditor
NKedtior是基于 kindeditor 进行二次开发的项目
kindeditor 是一款优秀的开源在线编辑器。轻量级且功能强大,代码量却不到百度的ueditor编辑器的一半。可惜已经4年没有更新了,由于业务的需求我们在kindeditor的基础上开发了 NKeditor, 主要做了一下工作:
1. 调整编辑器和弹出 dialog 的样式,美化了UI
2. 重写图片上传和批量图片上传插件,使用 html5 上传代替了 flash,实现了待上传图片预览,优化用户体验
3. 修复一些已知的bug,如 ajax 提交无法获取内容等
4. 新增涂鸦等功能
再次感谢 kindeditor 的开发者,为我们提供了如此优秀的在线编辑器,让我们能在前人的基础上继续贡献自己的微薄之力。
# 开源说明
本插件基于Nkeditor进行二次开发,修改的核心文件已开源于 https://gitee.com/karson/kindeditor
# 特别感谢
[Kindeditor](https://gitee.com/luolonghao/kindeditor)
[Nkeditor](https://gitee.com/blackfox/kindeditor)
... ...
require.config({
paths: {
'nkeditor': '../addons/nkeditor/js/customplugin',
'nkeditor-core': '../addons/nkeditor/nkeditor.min',
'nkeditor-lang': '../addons/nkeditor/lang/zh-CN',
},
shim: {
'nkeditor': {
deps: [
'nkeditor-core',
'nkeditor-lang'
]
},
'nkeditor-core': {
deps: [
'css!../addons/nkeditor/themes/black/editor.min.css',
'css!../addons/nkeditor/css/common.css'
],
exports: 'window.KindEditor'
},
'nkeditor-lang': {
deps: [
'nkeditor-core'
]
}
}
});
require(['form'], function (Form) {
var _bindevent = Form.events.bindevent;
Form.events.bindevent = function (form) {
_bindevent.apply(this, [form]);
if ($(".editor", form).size() > 0) {
require(['nkeditor', 'upload'], function (Nkeditor, Upload) {
var getImageFromClipboard, getImageFromDrop, getFileFromBase64;
getImageFromClipboard = function (data) {
var i, item;
i = 0;
while (i < data.clipboardData.items.length) {
item = data.clipboardData.items[i];
if (item.type.indexOf("image") !== -1) {
return item.getAsFile() || false;
}
i++;
}
return false;
};
getImageFromDrop = function (data) {
var i, item, images;
i = 0;
images = [];
while (i < data.dataTransfer.files.length) {
item = data.dataTransfer.files[i];
if (item.type.indexOf("image") !== -1) {
images.push(item);
}
i++;
}
return images;
};
getFileFromBase64 = function (data, url) {
var arr = data.split(','), mime = arr[0].match(/:(.*?);/)[1],
bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
while (n--) {
u8arr[n] = bstr.charCodeAt(n);
}
var filename, suffix;
if (typeof url != 'undefined') {
var urlArr = url.split('.');
filename = url.substr(url.lastIndexOf('/') + 1);
suffix = urlArr.pop();
} else {
filename = Math.random().toString(36).substring(5, 15);
}
if (!suffix) {
suffix = data.substring("data:image/".length, data.indexOf(";base64"));
}
var exp = new RegExp("\\." + suffix + "$", "i");
filename = exp.test(filename) ? filename : filename + "." + suffix;
var file = new File([u8arr], filename, {type: mime});
return file;
};
var getImageFromUrl = function (url, callback, outputFormat) {
var canvas = document.createElement('CANVAS'),
ctx = canvas.getContext('2d'),
img = new Image;
img.crossOrigin = 'Anonymous';
img.onload = function () {
var urlArr = url.split('.');
var suffix = urlArr.pop();
suffix = suffix.match(/^(jpg|png|gif|bmp|jpeg)$/i) ? suffix : 'png';
try {
canvas.height = img.height;
canvas.width = img.width;
ctx.drawImage(img, 0, 0);
var dataURL = canvas.toDataURL(outputFormat || 'image/' + suffix);
var file = getFileFromBase64(dataURL, url);
} catch (e) {
callback.call(this, null);
}
callback.call(this, file);
canvas = null;
};
img.onerror = function (e) {
callback.call(this, null);
};
img.src = Fast.api.fixurl("/addons/nkeditor/index/download") + "?url=" + encodeURIComponent(url);
};
//上传Word图片
Nkeditor.uploadwordimage = function (index, image) {
var that = this;
(function () {
var file = getFileFromBase64(image);
var placeholder = new RegExp("##" + index + "##", "g");
Upload.api.send(file, function (data) {
that.html(that.html().replace(placeholder, Fast.api.cdnurl(data.url)));
}, function (data) {
that.html(that.html().replace(placeholder, ""));
});
}(index, image));
};
Nkeditor.lang({
remoteimage: '下载远程图片'
});
//远程下载图片
Nkeditor.plugin('remoteimage', function (K) {
var editor = this, name = 'remoteimage';
editor.plugin.remoteimage = {
download: function (e) {
var that = this;
var html = that.html();
var staging = {}, orgined = {}, index = 0, images = 0, completed = 0, failured = 0;
var checkrestore = function () {
if (completed + failured >= images) {
$.each(staging, function (i, j) {
that.html(that.html().replace("<code>" + i + "</code>", j));
});
}
};
html.replace(/<code>([\s\S]*?)<\/code>/g, function (code) {
staging[index] = code;
return "<code>" + index + "</code>";
}
);
html = html.replace(/<img([\s\S]*?)\ssrc\s*=\s*('|")((http(s?):)([\s\S]*?))('|")([\s\S]*?)[\/]?>/g, function () {
images++;
var url = arguments[3];
var placeholder = '<img src="' + Fast.api.cdnurl("/assets/addons/nkeditor/img/downloading.png") + '" data-index="' + index + '" />';
//如果是云存储的链接,则忽略
if (Config.upload.cdnurl && url.indexOf(Config.upload.cdnurl) > -1) {
completed++;
return arguments[0];
} else {
orgined[index] = arguments[0];
}
//下载远程图片
(function (index, url, placeholder) {
getImageFromUrl(url, function (file) {
if (!file) {
failured++;
that.html(that.html().replace(placeholder, orgined[index]));
checkrestore();
} else {
Upload.api.send(file, function (data) {
completed++;
that.html(that.html().replace(placeholder, '<img src="' + Fast.api.cdnurl(data.url) + '" />'));
checkrestore();
}, function (data) {
failured++;
that.html(that.html().replace(placeholder, orgined[index]));
checkrestore();
});
}
});
})(index, url, placeholder);
index++;
return placeholder;
});
if (index > 0) {
that.html(html);
} else {
Toastr.info("没有需要下载的远程图片");
}
}
};
// 点击图标时执行
editor.clickToolbar(name, editor.plugin.remoteimage.download);
});
$(".editor", form).each(function () {
var that = this;
Nkeditor.create(that, {
width: '100%',
filterMode: false,
wellFormatMode: false,
allowMediaUpload: true, //是否允许媒体上传
allowFileManager: true,
allowImageUpload: true,
fontSizeTable: ['9px', '10px', '12px', '14px', '16px', '18px', '21px', '24px', '32px'],
wordImageServer: typeof Config.nkeditor != 'undefined' && Config.nkeditor.wordimageserver ? "127.0.0.1:10101" : "", //word图片替换服务器的IP和端口
cssPath: Fast.api.cdnurl('/assets/addons/nkeditor/plugins/code/prism.css'),
cssData: "body {font-size: 13px}",
fillDescAfterUploadImage: false, //是否在上传后继续添加描述信息
themeType: typeof Config.nkeditor != 'undefined' ? Config.nkeditor.theme : 'black', //编辑器皮肤,这个值从后台获取
fileManagerJson: Fast.api.fixurl("/addons/nkeditor/index/attachment/module/" + Config.modulename),
items: [
'source', 'undo', 'redo', 'preview', 'print', 'template', 'code', 'quote', 'cut', 'copy', 'paste',
'plainpaste', 'wordpaste', 'justifyleft', 'justifycenter', 'justifyright',
'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
'superscript', 'clearhtml', 'quickformat', 'selectall',
'formatblock', 'fontname', 'fontsize', 'forecolor', 'hilitecolor', 'bold',
'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', 'image', 'multiimage', 'graft',
'flash', 'media', 'insertfile', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
'anchor', 'link', 'unlink', 'remoteimage', 'about', 'fullscreen'
],
afterCreate: function () {
var self = this;
//Ctrl+回车提交
Nkeditor.ctrl(document, 13, function () {
self.sync();
$(that).closest("form").submit();
});
Nkeditor.ctrl(self.edit.doc, 13, function () {
self.sync();
$(that).closest("form").submit();
});
//粘贴上传
$("body", self.edit.doc).bind('paste', function (event) {
var image, pasteEvent;
pasteEvent = event.originalEvent;
if (pasteEvent.clipboardData && pasteEvent.clipboardData.items) {
image = getImageFromClipboard(pasteEvent);
if (image) {
event.preventDefault();
Upload.api.send(image, function (data) {
self.exec("insertimage", Fast.api.cdnurl(data.url));
});
}
}
});
//挺拽上传
$("body", self.edit.doc).bind('drop', function (event) {
var image, pasteEvent;
pasteEvent = event.originalEvent;
if (pasteEvent.dataTransfer && pasteEvent.dataTransfer.files) {
images = getImageFromDrop(pasteEvent);
if (images.length > 0) {
event.preventDefault();
$.each(images, function (i, image) {
Upload.api.send(image, function (data) {
self.exec("insertimage", Fast.api.cdnurl(data.url));
});
});
}
}
});
},
//FastAdmin自定义处理
beforeUpload: function (callback, file) {
var file = file ? file : $("input.ke-upload-file", this.form).prop('files')[0];
Upload.api.send(file, function (data) {
var data = {code: '000', data: {url: Fast.api.cdnurl(data.url)}, title: '', width: '', height: '', border: '', align: ''};
callback(data);
});
},
//错误处理 handler
errorMsgHandler: function (message, type) {
try {
console.log(message, type);
} catch (Error) {
alert(message);
}
}
});
});
});
}
}
});
... ...
<?php
return [
[
//配置唯一标识
'name' => 'theme',
//显示的标题
'title' => '编辑器主题',
//类型
'type' => 'select',
//数据字典
'content' => [
'default' => '经典主题',
'black' => '雅黑主题',
'blue' => '淡蓝主题',
'grey' => '深灰主题',
'primary' => '深绿主题',
],
//值
'value' => 'black',
//验证规则
'rule' => 'required',
//错误消息
'msg' => '',
//提示消息
'tip' => '',
//成功消息
'ok' => '',
//扩展信息
'extend' => ''
],
[
'name' => 'wordimageserver',
'title' => '启用word图片替换服务器',
'type' => 'radio',
'content' => [
'1' => '是',
'0' => '否',
],
'value' => '0',
'rule' => 'required',
'msg' => '',
'tip' => '如果启用,请务必先运行word.exe',
'ok' => '',
'extend' => ''
],
[
'name' => 'attachmentmode_admin',
'title' => '管理员附件选择模式',
'type' => 'select',
'content' => [
'all' => '任何管理员均可以查看全部上传的文件',
'auth' => '仅可以查看自己及所有子管理员上传的文件',
'personal' => '仅可以查看选择自己上传的文件',
],
'value' => 'all',
'rule' => 'required',
'msg' => '',
'tip' => '',
'ok' => '',
'extend' => ''
],
[
'name' => 'attachmentmode_index',
'title' => '后台附件选择模式',
'type' => 'select',
'content' => [
'all' => '任何会员均可以查看全部上传的文件',
'personal' => '仅可以查看选择自己上传的文件',
],
'value' => 'all',
'rule' => 'required',
'msg' => '',
'tip' => '',
'ok' => '',
'extend' => ''
],
];
... ...
<?php
namespace addons\nkeditor\controller;
use app\common\model\Attachment;
use GuzzleHttp\Client;
use think\addons\Controller;
class Index extends Controller
{
public function index()
{
$this->error('该插件暂无前台页面');
}
/**
* 文件列表
*/
public function attachment()
{
$model = new Attachment;
$page = $this->request->request('page');
$fileType = $this->request->request('fileType');
$module = $this->request->param('module');
$pagesize = 15;
$config = get_addon_config('nkeditor');
$type = [];
$imageSuffix = ['png', 'jpg', 'jpeg', 'gif', 'bmp', 'webp'];
if ($fileType == 'image') {
$type = $imageSuffix;
} else if ($fileType == 'flash') {
$type = ['swf', 'flv'];
} else if ($fileType == 'media') {
$type = ['swf', 'flv', 'mp4', 'mpeg', 'mp3', 'wav', 'ogg', 'acc', 'webm'];
} else if ($fileType == 'file') {
}
if ($module == 'admin') {
$auth = \app\admin\library\Auth::instance();
if (!$auth->id) {
$this->error('请登录后再操作!');
} else {
$mode = $config['attachmentmode_admin'];
}
if ($mode == 'all') {
} else {
if (!$auth->isSuperAdmin()) {
$adminIds = $mode == 'auth' ? $auth->getChildrenAdminIds(true) : [$auth->id];
$model->where('admin_id', 'in', $adminIds);
}
}
} else {
if (!$this->auth->id) {
$this->error('请登录后再操作!');
} else {
$mode = $config['attachmentmode_index'];
}
if ($mode == 'all') {
} else {
$model->where('user_id', 'in', [$this->auth->id]);
}
}
if ($type) {
$model->where('imagetype', 'in', $type);
}
$list = $model
->order('id', 'desc')
->paginate($pagesize);
$items = $list->items();
$data = [];
foreach ($items as $k => &$v) {
$v['imagetype'] = strtolower($v['imagetype']);
$v['fullurl'] = cdnurl($v['url'], true);
$data[] = [
'width' => $v['imagewidth'],
'height' => $v['imageheight'],
'filesize' => $v['filesize'],
'oriURL' => $v['fullurl'],
'thumbURL' => !in_array($v['imagetype'], $imageSuffix) ? "https://tool.fastadmin.net/icon/{$v['imagetype']}.png" : $v['fullurl'],
];
}
$result = [
'code' => '000',
'count' => $list->total(),
'page' => $page,
'pagesize' => $pagesize,
'extra' => '',
'data' => $data
];
return json($result);
}
public function download()
{
$url = $this->request->request("url");
$client = new Client();
$response = $client->get($url, ['verify' => false]);
return $response->getBody();
}
}
... ...
name = nkeditor
title = 简洁强大的富文本编辑器
intro = 一款基于Kindeditor二次开发的编辑器
author = FastAdmin
website = https://www.fastadmin.net
version = 1.0.12
state = 1
url = /addons/nkeditor
license = regular
licenseto = 11004
... ...
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!
\ No newline at end of file
... ...
/**
* 代码来源:http://www.thinkphp.cn/topic/27567.html
* 如需编译请使用 pkg -t node12-win word.js 命令编译成word.exe文件
*/
var service = {
http: require('http'),
url: require('url'),
querystring: require('querystring'),
fs: require('fs'),
config: {
timeout: 60000,
charset: 'utf8',
port: 10101,
host: '127.0.0.1'
},
router: {
index: function (res, query) {
res.end('Server is running!');
},
check: function (res, query) {
var result = {status: 1, info: 'success'};
result = JSON.stringify(result);
if (typeof query.callback == 'string') {
result = query.callback + '(' + result + ')';
}
res.end(result);
},
word: function (res, query) {
var _this = service;
var result = {status: 0, info: 'error'};
if (typeof query.file == 'string') {
var img = query.file.match(/file:\/\/+(localhost)?(\S+\.(png|jpg|jpeg|gif|bmp))/i);
console.log(img);
if (img) {
var base64 = _this.base64_encode(img[2]);
result.status = 1;
result.index = query.index;
result.info = 'data:image/' + img[3] + ';base64,' + base64;
}
}
result = JSON.stringify(result);
if (typeof query.callback == 'string') {
result = query.callback + '(' + result + ')';
}
res.end(result);
}
},
start: function () {
var _this = this;
var Server = _this.http.createServer(function (req, res) {
var URL = _this.url.parse(req.url);
var receive = [];
var router = null;
switch (URL.pathname) {
case '/word':
router = _this.router.word;
break;
case '/check':
router = _this.router.check;
break;
default:
router = _this.router.index;
}
req.setEncoding(_this.config.charset);
req.addListener('data', function (data) {
receive.push(data);
});
res.writeHead(200, {'Content-Type': 'text/plain'});
res.on("close", function () {
console.log("res closed");
});
req.on("close", function () {
console.log("req closed");
});
req.addListener('end', function () {
router(res, _this.querystring.parse(URL.query));
});
});
Server.listen(_this.config.port, _this.config.host, 1024);
Server.setTimeout(_this.config.timeout, function (cli) {
cli.end('timeout\n');
});
console.log('Server running at http://' + _this.config.host + ':' + _this.config.port);
},
//base64
base64_encode: function (file) {
var bitmap = this.fs.readFileSync(file);
return new Buffer.from(bitmap).toString('base64');
}
};
service.start();
... ...
{"license":"regular","licenseto":"11004","licensekey":"GZKzguNmn4DxJVfQ 92slYxZ08YDsDsCXr\/i\/gA==","files":["public\\assets\\addons\\upyun\\js\\spark.js"]}
\ No newline at end of file
... ...
<?php
namespace addons\upyun;
use think\Addons;
use think\Loader;
use Upyun\Config;
use Upyun\Signature;
use Upyun\Upyun as UpyunClient;
use Upyun\Util;
/**
* 又拍云上传
*/
class Upyun extends Addons
{
/**
* 插件安装方法
* @return bool
*/
public function install()
{
return true;
}
/**
* 插件卸载方法
* @return bool
*/
public function uninstall()
{
return true;
}
/**
* 添加命名空间
*/
public function appInit()
{
if (!class_exists('\Upyun\Upyun')) {
//添加支付包的命名空间
Loader::addNamespace('Upyun', ADDON_PATH . 'upyun' . DS . 'library' . DS . 'Upyun' . DS);
}
}
/**
*
* @return mixed
*/
public function uploadConfigInit(&$upload)
{
$config = $this->getConfig('upyun');
$config = $config ? $config : [];
$config['bucket'] = isset($config['bucket']) ? $config['bucket'] : '';
$multiple = isset($config['multiple']) ? $config['multiple'] : false;
$params = [];
$params['save-key'] = isset($config['savekey']) ? $config['savekey'] : '';
$params['bucket'] = $config['bucket'];
$params['expiration'] = time() + (isset($config['expire']) ? $config['expire'] : 600);
$cfg = new Config($config['bucket'], $config['operator'], $config['password']);
$policy = Util::base64Json($params);
$signature = Signature::getBodySignature($cfg, 'POST', '/' . $params['bucket'], null, $policy);
$upyuntoken = base64_encode($signature) . ":" . $policy;
$multipart = [
'upyuntoken' => $upyuntoken,
];
$upload = array_merge($upload, [
'cdnurl' => $config['cdnurl'],
'uploadurl' => $config['uploadmode'] == 'client' ? $config['uploadurl'] : addon_url('upyun/index/upload'),
'uploadmode' => $config['uploadmode'],
'bucket' => $config['bucket'],
'maxsize' => $config['maxsize'],
'mimetype' => $config['mimetype'],
'savekey' => $config['savekey'],
'chunking' => (bool)($config['chunking'] ?? $upload['chunking']),
'chunksize' => (int)($config['chunksize'] ?? $upload['chunksize']),
'multipart' => ['upyuntoken' => $upyuntoken],
'storage' => $this->getName(),
'multiple' => $config['multiple'] ? true : false,
]);
}
/**
* 附件删除后
*/
public function uploadDelete($attachment)
{
$config = $this->getConfig();
if ($attachment['storage'] == 'upyun' && isset($config['syncdelete']) && $config['syncdelete']) {
$cfg = new \Upyun\Config($config['bucket'], $config['operator'], $config['password']);
$upyun = new UpyunClient($cfg);
//同步删除又拍云文件
$ret = $upyun->delete($attachment->url);
//如果是服务端中转,还需要删除本地文件
if ($config['uploadmode'] == 'server') {
$filePath = ROOT_PATH . 'public' . str_replace('/', DS, $attachment->url);
if ($filePath) {
@unlink($filePath);
}
}
}
return true;
}
}
... ...
//修改上传的接口调用
require(['upload', '../addons/upyun/js/spark'], function (Upload, SparkMD5) {
//获取文件MD5值
var getFileMd5 = function (file, cb) {
var blobSlice = File.prototype.slice || File.prototype.mozSlice || File.prototype.webkitSlice,
chunkSize = 2097152,
chunks = Math.ceil(file.size / chunkSize),
currentChunk = 0,
spark = new SparkMD5.ArrayBuffer(),
fileReader = new FileReader();
fileReader.onload = function (e) {
spark.append(e.target.result);
currentChunk++;
if (currentChunk < chunks) {
loadNext();
} else {
cb && cb(spark.end());
}
};
fileReader.onerror = function () {
console.warn('文件读取错误');
};
function loadNext() {
var start = currentChunk * chunkSize,
end = ((start + chunkSize) >= file.size) ? file.size : start + chunkSize;
fileReader.readAsArrayBuffer(blobSlice.call(file, start, end));
}
loadNext();
};
//初始化中完成判断
Upload.events.onInit = function () {
//如果上传接口不是七牛云,则不处理
if (this.options.url !== Config.upload.uploadurl) {
return;
}
var _success = this.options.success;
$.extend(this.options, {
//关闭自动处理队列功能
autoQueue: false,
chunkSuccess: function (chunk, file, response) {
this.etags = this.etags ? this.etags : [];
},
chunksUploaded: function (file, done) {
var that = this;
Fast.api.ajax({
url: "/addons/upyun/index/upload",
data: {
action: 'merge',
filesize: file.size,
filename: file.name,
chunkid: file.upload.uuid,
chunkcount: file.upload.totalChunkCount,
width: file.width || 0,
height: file.height || 0,
type: file.type,
upyuntoken: Config.upload.multipart.upyuntoken,
url: file.params.url,
uuid: file.params.uuid,
etags: this.etags
},
}, function (data, ret) {
done(JSON.stringify(ret));
return false;
}, function (data, ret) {
file.accepted = false;
that._errorProcessing([file], ret.msg);
return false;
});
},
});
this.on("addedfile", function (file) {
var that = this;
setTimeout(function () {
if (file.status === 'error') {
return;
}
var index = Layer.load();
getFileMd5(file, function (md5) {
var chunk = that.options.chunking && file.size > that.options.chunkSize ? 1 : 0;
Fast.api.ajax({
url: "/addons/upyun/index/params",
data: {method: 'POST', md5: md5, name: file.name, type: file.type, size: file.size, chunk: chunk, chunkSize: that.options.chunkSize, upyuntoken: Config.upload.multipart.upyuntoken},
}, function (data) {
Layer.close(index);
file.md5 = md5;
file.url = data.url;
file.headers = data.headers;
file.params = data;
that.options.chunkSize = data.chunkSize;
if (file.status != 'error') {
//开始上传
that.enqueueFile(file);
} else {
that.removeFile(file);
}
return false;
}, function () {
Layer.close(index);
});
});
}, 0);
});
//先移除已有的事件
this.off("success", _success).on("success", function (file, response) {
var ret = {code: 0, msg: response};
try {
ret = typeof response === 'string' ? (response ? JSON.parse(response) : {url: file.url}) : response;
if (file.xhr.status === 200) {
console.log("SUCCESS:", ret);
if (typeof ret.url !== 'undefined' && typeof ret.data === 'undefined') {
ret = {code: 1, msg: "", data: {url: ret.url}};
}
Fast.api.ajax({
url: "/addons/upyun/index/notify",
data: {name: file.name, url: ret.data.url, md5: file.md5, size: file.size, width: file.width || 0, height: file.height || 0, type: file.type, upyuntoken: Config.upload.multipart.upyuntoken}
}, function () {
return false;
}, function () {
return false;
});
}
} catch (e) {
console.error(e);
}
_success.call(this, file, ret);
});
this.options.params = function (files, xhr, chunk) {
var params = Config.upload.multipart;
if (chunk) {
return $.extend({}, params, {
filesize: chunk.file.size,
filename: chunk.file.name,
chunkid: chunk.file.upload.uuid,
chunkindex: chunk.index,
chunkcount: chunk.file.upload.totalChunkCount,
chunkfilesize: chunk.dataBlock.data.size,
chunksize: this.options.chunkSize,
width: chunk.file.width || 0,
height: chunk.file.height || 0,
type: chunk.file.type,
url: chunk.file.params.url || "",
uuid: chunk.file.params.uuid || "",
});
} else {
if (Config.upload.uploadmode === 'client') {
}
}
return params;
};
//如果是直传模式
if (Config.upload.uploadmode === 'client') {
var _url = this.options.url;
//分片上传时URL链接不同
this.options.url = function (files) {
if (files[0].upload.chunked) {
var chunk = null;
files[0].upload.chunks.forEach(function (item) {
if (item.status === 'uploading') {
chunk = item;
}
});
if (!chunk) {
return Config.upload.uploadurl + files[0].url + files[0].size;
} else {
this.options.headers = $.extend(this.options.headers, chunk.file.headers, {"Cache-Control": null, "User-agent": null, "X-Upyun-Part-Id": chunk.index + ""});
return Config.upload.uploadurl + files[0].url;
}
} else {
this.options.headers = $.extend(this.options.headers, files[0].headers, {"Cache-Control": null, "User-agent": null});
return Config.upload.uploadurl + files[0].url;
}
return _url;
};
var _method = this.options.method;
this.options.method = function (files) {
if (files[0].upload.chunked) {
var chunk = null;
files[0].upload.chunks.forEach(function (item) {
if (item.status === 'uploading') {
chunk = item;
}
});
if (!chunk) {
return "POST";
} else {
return "PUT";
}
} else {
return "PUT";
}
return _method;
};
//分片上传时需要变更提交的内容
this.on("sending", function (file, xhr, formData) {
if (true) {
var _send = xhr.send;
xhr.send = function () {
if (file.upload.chunked) {
var chunk = null;
file.upload.chunks.forEach(function (item) {
if (item.status == 'uploading') {
chunk = item;
}
});
if (chunk) {
_send.call(xhr, chunk.dataBlock.data);
}
} else {
_send.call(xhr, file);
}
};
}
});
}
};
});
... ...
<?php
return [
[
'name' => 'bucket',
'title' => 'bucket',
'type' => 'string',
'content' => [],
'value' => 'chuangxinchuangye',
'rule' => 'required',
'msg' => '',
'tip' => '服务名称',
'ok' => '',
'extend' => '',
],
[
'name' => 'cdnurl',
'title' => 'CDN地址',
'type' => 'string',
'content' => [],
'value' => 'http://chuangxinchuangye.posedu.com.cn/',
'rule' => 'required',
'msg' => '',
'tip' => '回事域名',
'ok' => '',
'extend' => '',
],
[
'name' => 'uploadurl',
'title' => '上传接口地址',
'type' => 'string',
'content' => [],
'value' => 'http://v0.api.upyun.com/chuangxinchuangye',
'rule' => 'required',
'msg' => '',
'tip' => '上传接口地址',
'ok' => '',
'extend' => '',
],
[
'name' => 'uploadmode',
'title' => '上传模式',
'type' => 'select',
'content' => [
'client' => '客户端直传(速度快,无备份)',
'server' => '服务器中转(占用服务器带宽,有备份)',
],
'value' => 'client',
'rule' => '',
'msg' => '',
'tip' => '启用服务器中转时务必配置操作员和密码',
'ok' => '',
'extend' => '',
],
[
'name' => 'savekey',
'title' => '保存文件名',
'type' => 'string',
'content' => [],
'value' => '/uploads/{year}{mon}{day}/{filemd5}{.suffix}',
'rule' => 'required',
'msg' => '',
'tip' => '',
'ok' => '',
'extend' => '',
],
[
'name' => 'expire',
'title' => '上传有效时长',
'type' => 'string',
'content' => [],
'value' => '7200',
'rule' => 'required',
'msg' => '',
'tip' => '',
'ok' => '',
'extend' => '',
],
[
'name' => 'maxsize',
'title' => '最大可上传',
'type' => 'string',
'content' => [],
'value' => '20M',
'rule' => 'required',
'msg' => '',
'tip' => '',
'ok' => '',
'extend' => '',
],
[
'name' => 'mimetype',
'title' => '可上传后缀格式',
'type' => 'string',
'content' => [],
'value' => 'jpg,png,bmp,jpeg,gif,zip,rar,xls,xlsx',
'rule' => 'required',
'msg' => '',
'tip' => '',
'ok' => '',
'extend' => '',
],
[
'name' => 'multiple',
'title' => '多文件上传',
'type' => 'radio',
'content' => [
'否',
'是',
],
'value' => '0',
'rule' => 'required',
'msg' => '',
'tip' => '',
'ok' => '',
'extend' => '',
],
[
'name' => 'thumbstyle',
'title' => '缩略图样式',
'type' => 'string',
'content' => [],
'value' => '!/fwfh/120x90',
'rule' => '',
'msg' => '',
'tip' => '用于附件管理缩略图样式,可使用:!/fwfh/120x90',
'ok' => '',
'extend' => '',
],
[
'name' => 'chunking',
'title' => '分片上传',
'type' => 'radio',
'content' => [
1 => '开启',
0 => '关闭',
],
'value' => '1',
'rule' => 'required',
'msg' => '',
'tip' => '',
'ok' => '',
'extend' => '',
],
[
'name' => 'chunksize',
'title' => '分片大小',
'type' => 'number',
'content' => [],
'value' => '4194304',
'rule' => 'required',
'msg' => '',
'tip' => '',
'ok' => '',
'extend' => '',
],
[
'name' => 'operator',
'title' => '操作员',
'type' => 'string',
'content' => [],
'value' => 'zhaoyang',
'rule' => '',
'msg' => '服务端上传和删除文件时间使用',
'tip' => '',
'ok' => '',
'extend' => '',
],
[
'name' => 'password',
'title' => '密码',
'type' => 'string',
'content' => [],
'value' => 'Lxq0ykCsvZ6q7abFfvzw51QmcxgOxr3B',
'rule' => '',
'msg' => '服务端上传和删除文件时间使用',
'tip' => '',
'ok' => '',
'extend' => '',
],
[
'name' => 'syncdelete',
'title' => '附件删除时是否同步删除文件',
'type' => 'bool',
'content' => [],
'value' => '0',
'rule' => 'required',
'msg' => '',
'tip' => '',
'ok' => '',
'extend' => '',
],
[
'name' => '__tips__',
'title' => '温馨提示',
'type' => '',
'content' => [],
'value' => '在使用之前请注册又拍云账号并进行认证和创建云储存,注册链接:<a href="https://console.upyun.com/register/?invite=SyAt3ehQZ" target="_blank">https://console.upyun.com/register/?invite=SyAt3ehQZ</a>',
'rule' => '',
'msg' => '',
'tip' => '',
'ok' => '',
'extend' => '48 104',
],
];
... ...
<?php
namespace addons\upyun\controller;
use app\common\exception\UploadException;
use app\common\library\Upload;
use app\common\model\Attachment;
use think\addons\Controller;
use think\Config;
use Upyun\Api\Rest;
use Upyun\Signature;
use Upyun\Upyun;
use Upyun\Util;
/**
* 又拍云云储存
*
*/
class Index extends Controller
{
/**
* @var \Upyun\Config
*/
protected $config = null;
public function _initialize()
{
//跨域检测
check_cors_request();
parent::_initialize();
Config::set('default_return_type', 'json');
$config = get_addon_config('upyun');
$this->config = new \Upyun\Config($config['bucket'], $config['operator'], $config['password']);
}
public function index()
{
Config::set('default_return_type', 'html');
$this->error("当前插件暂无前台页面");
}
/**
* 获取签名
*/
public function params()
{
$this->check();
$name = $this->request->post('name');
$md5 = $this->request->post('md5');
$chunk = $this->request->post('chunk');
$config = get_addon_config('upyun');
$upload = new Upload();
$url = $upload->getSavekey($config['savekey'], $name, $md5);
$signature = Signature::getHeaderSign($this->config, 'PUT', '/' . $config['bucket'] . $url);
$data = [];
$data['headers'] = $signature;
$data['url'] = $url;
if ($chunk) {
$type = $this->request->post('type');
$fileSize = $this->request->post('size');
$chunkSize = $this->request->post('chunkSize');
//如果分片大小不是整数,则进行变更
if (!is_int($chunkSize / 1024 / 1024)) {
$chunkSize = 1024 * 1024 * 2;
}
$req = new Rest($this->config);
$res = $req->request('PUT', $url)
->withHeaders(array(
'X-Upyun-Multi-Disorder' => 'true',
'X-Upyun-Multi-Stage' => 'initiate',
'X-Upyun-Multi-Length' => (string)$fileSize,
'X-Upyun-Multi-Type' => $type,
'X-Upyun-Multi-Part-Size' => $chunkSize,
))
->send();
if ($res->getStatusCode() !== 204) {
$this->error('初始化失败');
}
$init = Util::getHeaderParams($res->getHeaders());
$data['headers']['X-Upyun-Multi-Stage'] = 'upload';
$data['headers']['X-Upyun-Multi-Uuid'] = $init['x-upyun-multi-uuid'];
$data['uuid'] = $init['x-upyun-multi-uuid'];
$data['chunkSize'] = $chunkSize;
$this->success("", "", $data);
} else {
$this->success('', null, $data);
}
return;
}
/**
* 服务器中转上传文件
* 上传分片
* 合并分片
*/
public function upload()
{
$this->check();
$config = get_addon_config('upyun');
$chunkid = $this->request->post("chunkid");
if ($chunkid) {
$action = $this->request->post("action");
$chunkindex = $this->request->post("chunkindex/d");
$chunkcount = $this->request->post("chunkcount/d");
$filesize = $this->request->post("filesize");
$filename = $this->request->post("filename");
$url = $this->request->post("url");
$uuid = $this->request->post("uuid");
if ($action == 'merge') {
//合并分片
if ($config['uploadmode'] == 'server') {
$attachment = null;
//合并分片文件
try {
$upload = new Upload();
$attachment = $upload->merge($chunkid, $chunkcount, $filename);
} catch (UploadException $e) {
$this->error($e->getMessage());
}
}
try {
$req = new Rest($this->config);
$res = $req->request('PUT', $url)
->withHeaders(array(
'X-Upyun-Multi-Uuid' => $uuid,
'X-Upyun-Multi-Stage' => 'complete'
))
->send();
if ($res->getStatusCode() != 204 && $res->getStatusCode() != 201) {
throw new \Exception('end request failed when poinit upload!');
}
} catch (\Exception $e) {
$this->error($e->getMessage());
}
$this->success("上传成功", '', ['url' => $url, 'fullurl' => cdnurl($url, true)]);
} else {
//默认普通上传文件
$file = $this->request->file('file');
try {
$upload = new Upload($file);
$file = $upload->chunk($chunkid, $chunkindex, $chunkcount);
} catch (UploadException $e) {
$this->error($e->getMessage());
}
try {
//上传分片到OSS
$req = new Rest($this->config);
$req->request('PUT', $url)
->withHeaders(array(
'X-Upyun-Multi-Stage' => 'upload',
'X-Upyun-Multi-Uuid' => $uuid,
'X-Upyun-Part-Id' => $chunkindex
))
->withFile($file)
->send();
} catch (\Exception $e) {
$this->error($e->getMessage());
}
$this->success("上传成功", "", [], 3, ['url' => $url]);
}
} else {
$attachment = null;
//默认普通上传文件
$file = $this->request->file('file');
try {
$upload = new Upload($file);
$attachment = $upload->upload();
} catch (UploadException $e) {
$this->error($e->getMessage());
}
//文件绝对路径
$filePath = $upload->getFile()->getRealPath() ?: $upload->getFile()->getPathname();
try {
$upyun = new Upyun($this->config);
$ret = $upyun->write($attachment->url, $upload->getFile());
//成功不做任何操作
} catch (\Exception $e) {
$attachment->delete();
@unlink($filePath);
$this->error("上传失败");
}
$this->success("上传成功", '', ['url' => $attachment->url, 'fullurl' => cdnurl($attachment->url, true)]);
}
return;
}
/**
* 回调
*/
public function notify()
{
$this->check();
$size = $this->request->post('size');
$name = $this->request->post('name');
$md5 = $this->request->post('md5');
$type = $this->request->post('type');
$url = $this->request->post('url');
$suffix = substr($name, stripos($name, '.') + 1);
$attachment = Attachment::where('url', $url)->where('storage', 'upyun')->find();
if (!$attachment) {
$params = array(
'admin_id' => (int)session('admin.id'),
'user_id' => (int)cookie('uid'),
'filesize' => $size,
'filename' => $name,
'imagewidth' => 0,
'imageheight' => 0,
'imagetype' => $suffix,
'imageframes' => 0,
'mimetype' => $type,
'url' => $url,
'uploadtime' => time(),
'storage' => 'upyun',
'sha1' => $md5,
);
Attachment::create($params);
}
$this->success();
return;
}
/**
* 检查签名是否正确或过期
*/
protected function check()
{
$upyuntoken = $this->request->post('upyuntoken', '', 'trim');
if (!$upyuntoken) {
$this->error("参数不正确");
}
$config = get_addon_config('upyun');
list($sign, $data) = explode(':', $upyuntoken);
if (!$sign || !$data) {
$this->error("参数不正确");
}
$policy = $data;
if (base64_decode($sign) !== Signature::getBodySignature($this->config, 'POST', '/' . $config['bucket'], null, $policy)) {
$this->error("签名不正确");
}
$json = json_decode(base64_decode($data), true);
if ($json['expiration'] < time()) {
$this->error("请求已经超时");
}
}
}
... ...
name = upyun
title = 又拍云云储存
intro = 使用又拍云储存,支持直传、服务器中转、分片上传
author = FastAdmin
website = https://www.fastadmin.net
version = 1.1.1
state = 1
url = /addons/upyun
license = regular
licenseto = 11004
... ...
<?php
namespace Upyun\Api;
use Upyun\Signature;
use Upyun\Util;
use GuzzleHttp\Client;
class Form extends Rest
{
public function upload($path, $stream, $params)
{
$params['save-key'] = $path;
$params['service'] = $this->config->serviceName;
if (!isset($params['expiration'])) {
$params['expiration'] = time() + 30 * 60 * 60; // 30 分钟
}
$policy = Util::base64Json($params);
$method = 'POST';
$signature = Signature::getBodySignature($this->config, $method, '/' . $params['service'], null, $policy);
$client = new Client([
'timeout' => $this->config->timeout,
]);
$response = $client->request($method, $this->endpoint, array(
'multipart' => array(
array(
'name' => 'policy',
'contents' => $policy,
),
array(
'name' => 'authorization',
'contents' => $signature,
),
array(
'name' => 'file',
'contents' => $stream,
)
)
));
return $response->getStatusCode() === 200;
}
}
... ...
<?php
namespace Upyun\Api;
use GuzzleHttp\Client;
use Upyun\Config;
use Upyun\Signature;
use Upyun\Util;
class Pretreat
{
/**
* @var Config
*/
protected $config;
public function __construct(Config $config)
{
if (!$config->processNotifyUrl) {
throw new \Exception("should config prosessNotifyUrl first.");
}
$this->config = $config;
}
public function process($tasks, $optionalParams = array())
{
$encodedTasks = Util::base64Json($tasks);
$client = new Client([
'timeout' => $this->config->timeout,
]);
$params = array(
'service' => $this->config->serviceName,
'notify_url' => $this->config->processNotifyUrl,
'tasks' => $encodedTasks,
);
$params = array_merge($params, $optionalParams);
$path = '/pretreatment/';
$method = 'POST';
$signedHeaders = Signature::getHeaderSign($this->config, $method, $path);
$url = $this->config->getPretreatEndPoint() . $path;
$response = $client->request($method, $url, [
'headers' => $signedHeaders,
'form_params' => $params
]);
$body = $response->getBody()->getContents();
return json_decode($body, true);
}
public function query($taskIds, $path)
{
$client = new Client([
'timeout' => $this->config->timeout,
]);
$params = array(
'service' => $this->config->serviceName,
'task_ids' => implode(',', $taskIds)
);
$path = $path . '?' . http_build_query($params);
$method = 'GET';
$url = $this->config->getPretreatEndPoint() . $path;
$signedHeaders = Signature::getHeaderSign($this->config, $method, $path);
$response = $client->request($method, $url, [
'headers' => $signedHeaders
]);
if ($response->getStatusCode() === 200) {
$body = $response->getBody()->getContents();
$result = json_decode($body, true);
if (is_array($result)) {
return $result['tasks'];
}
}
return false;
}
}
... ...
<?php
namespace Upyun\Api;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7;
use Upyun\Config;
use Upyun\Signature;
use Upyun\Util;
class Rest
{
/**
* @var Config
*/
protected $config;
protected $endpoint;
protected $method;
protected $storagePath;
public $headers = [];
/**
* @var Psr7\Stream
*/
protected $file;
public function __construct(Config $config)
{
$this->config = $config;
$this->endpoint = $config->getProtocol() . Config::$restApiEndPoint . '/' . $config->serviceName;
}
public function request($method, $storagePath)
{
$this->method = strtoupper($method);
$this->storagePath = '/' . ltrim($storagePath, '/');
return $this;
}
/**
* @param string|resource $file
*
* @return $this
*/
public function withFile($file)
{
$stream = Psr7\stream_for($file);
$this->file = $stream;
return $this;
}
/**
* @return mixed|\Psr\Http\Message\ResponseInterface
*/
public function send()
{
$client = new Client([
'timeout' => $this->config->timeout,
]);
$url = $this->endpoint . $this->storagePath;
$body = null;
if ($this->file && $this->method === 'PUT') {
$body = $this->file;
}
$request = new Psr7\Request(
$this->method,
Util::encodeURI($url),
$this->headers,
$body
);
$authHeader = Signature::getHeaderSign($this->config,
$this->method,
$request->getUri()->getPath()
);
foreach ($authHeader as $head => $value) {
$request = $request->withHeader($head, $value);
}
$response = $client->send($request, [
'debug' => $this->config->debug
]);
return $response;
}
public function withHeader($header, $value)
{
$header = strtolower(trim($header));
$this->headers[$header] = $value;
return $this;
}
public function withHeaders($headers)
{
if (is_array($headers)) {
foreach ($headers as $header => $value) {
$this->withHeader($header, $value);
}
}
return $this;
}
public function toRequest()
{
$url = $this->endpoint . $this->storagePath;
$body = null;
if ($this->file && $this->method === 'PUT') {
$body = $this->file;
}
$request = new Psr7\Request(
$this->method,
Util::encodeURI($url),
$this->headers,
$body
);
$authHeader = Signature::getHeaderSign($this->config,
$this->method,
$request->getUri()->getPath()
);
foreach ($authHeader as $head => $value) {
$request = $request->withHeader($head, $value);
}
return $request;
}
}
... ...
<?php
/**
* 同步视频处理
*/
namespace Upyun\Api;
use GuzzleHttp\Client;
use Upyun\Config;
use Upyun\Signature;
class SyncVideo {
/**
* @var Config
*/
protected $config;
public function __construct(Config $config)
{
$this->config = $config;
}
public function process($params, $path) {
$client = new Client([
'timeout' => $this->config->timeout,
]);
$path = '/' . $this->config->serviceName . $path;
$method = 'POST';
$signedHeaders = Signature::getHeaderSign($this->config, $method, $path);
$url = $this->config->getSyncVideoEndPoint() . $path;
$response = $client->request($method, $url, [
'headers' => $signedHeaders,
'json' => $params
]);
$body = $response->getBody()->getContents();
return json_decode($body, true);
}
}
\ No newline at end of file
... ...
<?php
namespace Upyun;
/**
* Class Config
*
* @package Upyun
*/
class Config
{
/**
* @var string 服务名称,将会被弃用
*/
public $bucketName;
/**
* @var string 服务名称
*/
public $serviceName;
/**
* @var string 操作员名
*/
public $operatorName;
/**
* @var string 操作员密码 md5 hash 值
*/
public $operatorPassword;
/**
* @var bool 是否使用 https
*/
public $useSsl;
/**
* @var string 上传使用的接口类型,可以设置为 `REST`:使用 rest api 上传,`AUTO` 根据文件大小自动判断,`BLOCK` 使用串行式断点续传,`BLOCK_PARALLEL` 使用并行式断点续传
* 当上传小文件时,不推荐使用断点续传;上传时如果设置了异步预处理`withAsyncProcess=true`,将会使用表单 api 上传
*/
public $uploadType = 'AUTO';
/**
* @var int 上传的接口类型设置为 `AUTO` 时,文件大小的边界值:小于该值时,使用 rest api,否则使用断点续传。 默认 30M
*/
public $sizeBoundary = 31457280;
/**
* @var int 并行式断点续传的并发数
*/
public $concurrency = 5;
/**
* @var int request timeout seconds
*/
public $timeout = 60;
/**
* @var string 异步云处理的回调通知地址
*/
public $processNotifyUrl;
/**
* @var boolean curl debug
*/
public $debug = false;
private $version = '3.0.0';
/**
* @var string 表单 api 的秘钥
*/
private $formApiKey;
/**
* @var string rest api 和 form api 的接口地址
*/
public static $restApiEndPoint;
/**
* rest api 和 form api 接口请求地址,详见:http://docs.upyun.com/api/rest_api/
*/
const ED_AUTO = 'v0.api.upyun.com';
const ED_TELECOM = 'v1.api.upyun.com';
const ED_CNC = 'v2.api.upyun.com';
const ED_CTT = 'v3.api.upyun.com';
/**
* 异步云处理接口地址
*/
const ED_VIDEO = 'p0.api.upyun.com';
/**
* 刷新接口地址
*/
const ED_PURGE = 'http://purge.upyun.com/purge/';
/**
* 同步视频处理接口地址
*/
const ED_SYNC_VIDEO = 'p1.api.upyun.com';
public function __construct($serviceName, $operatorName, $operatorPassword)
{
$this->serviceName = $serviceName;
$this->bucketName = $serviceName;
$this->operatorName = $operatorName;
$this->setOperatorPassword($operatorPassword);
$this->useSsl = false;
self::$restApiEndPoint = self::ED_AUTO;
}
public function setOperatorPassword($operatorPassword)
{
$this->operatorPassword = md5($operatorPassword);
}
public function getFormApiKey()
{
if (! $this->formApiKey) {
throw new \Exception('form api key is empty.');
}
return $this->formApiKey;
}
public function setFormApiKey($key)
{
$this->formApiKey = $key;
}
public function getVersion()
{
return $this->version;
}
public function getPretreatEndPoint()
{
return $this->getProtocol() . self::ED_VIDEO;
}
public function getSyncVideoEndPoint()
{
return $this->getProtocol() . self::ED_SYNC_VIDEO;
}
public function getProtocol()
{
return $this->useSsl ? 'https://' : 'http://';
}
public function setUploadType($uploadType)
{
$this->uploadType = $uploadType;
}
public function setConcurrency($concurrency)
{
$this->concurrency = $concurrency;
}
}
... ...
<?php
namespace Upyun;
/**
* Class Signature
* @package Upyun
*/
class Signature
{
/**
* 获取分块上传接口的签名
*/
const SIGN_MULTIPART = 1;
/**
* 生成视频处理接口的签名
*/
const SIGN_VIDEO = 2;
/**
* 生成视频处理接口的签名(不需要操作员时使用)
*/
const SIGN_VIDEO_NO_OPERATOR = 3;
/**
* 获取 Header 签名需要的请求头
*
* @param Config $serviceConfig
* @param $method 请求方法
* @param $path 请求路径
* @param $contentMd5 文件内容 md5
*
* @return array
*/
public static function getHeaderSign($serviceConfig, $method, $path, $contentMd5 = null)
{
$gmtDate = gmdate('D, d M Y H:i:s \G\M\T');
$policy = null;
$sign = self::getBodySignature($serviceConfig, $method, $path, $gmtDate, $policy, $contentMd5);
$headers = array(
'Authorization' => $sign,
'X-Date' => $gmtDate,
'User-agent' => 'Php-Sdk/' . $serviceConfig->getVersion()
);
return $headers;
}
/**
* 获取请求缓存刷新接口需要的签名头
*
* @param Config $serviceConfig
* @param $urlString
*
* @return array
*/
public static function getPurgeSignHeader(Config $serviceConfig, $urlString)
{
$gmtDate = gmdate('D, d M Y H:i:s \G\M\T');
$sign = md5("$urlString&{$serviceConfig->serviceName}&$gmtDate&{$serviceConfig->operatorPassword}");
return array(
'Authorization' => "UpYun {$serviceConfig->serviceName}:{$serviceConfig->operatorName}:$sign",
'Date' => $gmtDate,
'User-agent' => 'Php-Sdk/' . $serviceConfig->getVersion() . ' (purge api)'
);
}
/**
* 获取表单 API 需要的签名,依据 body 签名规则计算
* @param Config $serviceConfig
* @param $method 请求方法
* @param $uri 请求路径
* @param $date 请求时间
* @param $policy
* @param $contentMd5 请求 body 的 md5
*
* @return array
*/
public static function getBodySignature(Config $serviceConfig, $method, $uri, $date = null, $policy = null, $contentMd5 = null)
{
$data = array(
$method,
$uri
);
if ($date) {
$data[] = $date;
}
if ($policy) {
$data[] = $policy;
}
if ($contentMd5) {
$data[] = $contentMd5;
}
$signature = base64_encode(hash_hmac('sha1', implode('&', $data), $serviceConfig->operatorPassword, true));
return 'UPYUN ' . $serviceConfig->operatorName . ':' . $signature;
}
}
... ...
<?php
namespace Upyun;
use Upyun\Api\Rest;
use Upyun\Api\Form;
use GuzzleHttp\Psr7;
use GuzzleHttp\Pool;
use GuzzleHttp\Client;
class Uploader
{
/**
* @var Config
*/
protected $config;
protected $useBlock = false;
public function __construct(Config $config)
{
$this->config = $config;
}
public function upload($path, $file, $params, $withAsyncProcess)
{
$stream = Psr7\stream_for($file);
$size = $stream->getSize();
$useBlock = $this->needUseBlock($size);
if ($withAsyncProcess) {
$req = new Form($this->config);
return $req->upload($path, $stream, $params);
}
if (! $useBlock) {
$req = new Rest($this->config);
return $req->request('PUT', $path)
->withHeaders($params)
->withFile($stream)
->send();
} elseif ($this->config->uploadType === 'BLOCK_PARALLEL') {
return $this->concurrentPointUpload($path, $stream, $params);
} else {
return $this->pointUpload($path, $stream, $params);
}
}
/**
* 串行式断点续传
* @param $path
* @param $stream
* @param $params
*
* @return mixed|\Psr\Http\Message\ResponseInterface
* @throws \Exception
*/
private function pointUpload($path, $stream, $params)
{
$req = new Rest($this->config);
$headers = array();
if (is_array($params)) {
foreach ($params as $key => $val) {
$headers['X-Upyun-Meta-' . $key] = $val;
}
}
$res = $req->request('PUT', $path)
->withHeaders(array_merge(array(
'X-Upyun-Multi-Stage' => 'initiate',
'X-Upyun-Multi-Type' => Psr7\mimetype_from_filename($path),
'X-Upyun-Multi-Length' => $stream->getSize(),
), $headers))
->send();
if ($res->getStatusCode() !== 204) {
throw new \Exception('init request failed when poinit upload!');
}
$init = Util::getHeaderParams($res->getHeaders());
$uuid = $init['x-upyun-multi-uuid'];
$blockSize = 1024 * 1024;
$partId = 0;
do {
$fileBlock = $stream->read($blockSize);
$res = $req->request('PUT', $path)
->withHeaders(array(
'X-Upyun-Multi-Stage' => 'upload',
'X-Upyun-Multi-Uuid' => $uuid,
'X-Upyun-Part-Id' => $partId
))
->withFile(Psr7\stream_for($fileBlock))
->send();
if ($res->getStatusCode() !== 204) {
throw new \Exception('upload request failed when poinit upload!');
}
$data = Util::getHeaderParams($res->getHeaders());
$partId = $data['x-upyun-next-part-id'];
} while ($partId != -1);
$res = $req->request('PUT', $path)
->withHeaders(array(
'X-Upyun-Multi-Uuid' => $uuid,
'X-Upyun-Multi-Stage' => 'complete'
))
->send();
if ($res->getStatusCode() != 204 && $res->getStatusCode() != 201) {
throw new \Exception('end request failed when poinit upload!');
}
return $res;
}
private function needUseBlock($fileSize)
{
if ($this->config->uploadType === 'BLOCK' ||
$this->config->uploadType === 'BLOCK_PARALLEL') {
return true;
} elseif ($this->config->uploadType === 'AUTO' &&
$fileSize >= $this->config->sizeBoundary) {
return true;
} else {
return false;
}
}
/**
* 并行式断点续传
* @param $path
* @param $stream
* @param $params
*
* @return mixed|\Psr\Http\Message\ResponseInterface
* @throws \Exception
*/
private function concurrentPointUpload($path, $stream, $params)
{
$req = new Rest($this->config);
$headers = array();
if (is_array($params)) {
foreach ($params as $key => $val) {
$headers['X-Upyun-Meta-' . $key] = $val;
}
}
$res = $req->request('PUT', $path)
->withHeaders(array_merge(array(
'X-Upyun-Multi-Disorder' => 'true',
'X-Upyun-Multi-Stage' => 'initiate',
'X-Upyun-Multi-Type' => Psr7\mimetype_from_filename($path),
'X-Upyun-Multi-Length' => $stream->getSize(),
), $headers))
->send();
if ($res->getStatusCode() !== 204) {
throw new \Exception('init request failed when poinit upload!');
}
$init = Util::getHeaderParams($res->getHeaders());
$uuid = $init['x-upyun-multi-uuid'];
$requests = function ($req, $path, $stream, $uuid) {
$blockSize = 1024 * 1024;
$total = ceil($stream->getSize() / $blockSize);
for ($i = 0; $i < $total; $i++) {
$fileBlock = $stream->read($blockSize);
yield $req->request('PUT', $path)
->withHeaders(array(
'X-Upyun-Multi-Stage' => 'upload',
'X-Upyun-Multi-Uuid' => $uuid,
'X-Upyun-Part-Id' => $i
))
->withFile(Psr7\stream_for($fileBlock))
->toRequest();
}
};
$client = new Client([
'timeout' => $this->config->timeout,
]);
$pool = new Pool($client, $requests($req, $path, $stream, $uuid), [
'concurrency' => $this->config->concurrency,
'fulfilled' => function ($res) {
print_r($res);
if ($res->getStatusCode() !== 204) {
throw new \Exception('upload request failed when poinit upload!');
}
},
'rejected' => function () {
throw new \Exception('upload request failed when poinit upload!');
},
]);
$promise = $pool->promise();
$promise->wait();
$res = $req->request('PUT', $path)
->withHeaders(array(
'X-Upyun-Multi-Uuid' => $uuid,
'X-Upyun-Multi-Stage' => 'complete'
))
->send();
if ($res->getStatusCode() != 204 && $res->getStatusCode() != 201) {
throw new \Exception('end request failed when poinit upload!');
}
return $res;
}
}
... ...
<?php
/**
* 又拍云 PHP-SDK
*/
namespace Upyun;
use Upyun\Api\Rest;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7;
use GuzzleHttp;
/**
* Class Upyun
*
* 又拍云云存储、云处理接口
*
* Upyun 类实现了又拍云云存储和云处理的所有接口,通过该类可以实现文件上传、下载;图片视频等多媒体资源云处理。
* 本文档中,提到的"服务"是指又拍云文件加速回又拍云源类型的服务(即原先的存储类空间)。
*
* @package Upyun
*/
class Upyun
{
/**
* @var Config: 服务配置
*/
protected $config;
// 异步云处理任务类型
/**
* @var string 异步音视频处理
*/
public static $PROCESS_TYPE_MEDIA = 'media';
/**
* @var string 文件压缩
*/
public static $PROCESS_TYPE_ZIP = 'zip-file';
/**
* @var string 解压缩
*/
public static $PROCESS_TYPE_UNZIP = 'unzip-file';
/**
* @var string 文件拉取
*/
public static $PROCESS_TYPE_SYNC_FILE = 'sync-remote-file-to-upyun';
/**
* @var string 文档转换
*/
public static $PROCESS_TYPE_CONVERT = 'document-type-convert';
/**
* @var string 异步图片拼接
*/
public static $PROCESS_TYPE_STITCH = 'picture-stitch';
/**
* Upyun constructor.
*
* @param Config $config 服务配置
*/
public function __construct(Config $config)
{
$this->setConfig($config);
}
/**
* 配置服务信息
*
* 当需要操作的新的服务时,使用该方法传入新的服务配置即可
*
* @param Config $config 服务配置
*
* @return $this
*/
public function setConfig(Config $config)
{
$this->config = $config;
return $this;
}
/**
* 上传一个文件到又拍云存储
*
* 上传的文件格式支持文件流或者字符串方式上传。除简单的文件上传外,针对多媒体资源(图片、音视频),还可以设置同步/异步预处理多媒体资源,例如:图片的裁剪缩放,音视频的转码截图等等众多又拍云强大的云处理功能
*
* @param string $path 被上传的文件在又拍云存储服务中保存的路径
* @param string|resource $content 被上传的文件内容(字符串),或者打开该文件获得的文件句柄(文件流)。当上传本地大文件时,推荐使用文件流的方式上传
* @param array $params 上传文件时,附加的自定义参数。支持 Content-MD5 Content-Type Content-Secret 等,详见 [上传参数](http://docs.upyun.com/api/rest_api/#_2),例如:
* - 设置文件[保护秘钥](http://docs.upyun.com/api/rest_api/#Content-Secret) `write($path, $content, array('Content-Secret' => 'my-secret'))`;
* - 添加[文件元信息](http://docs.upyun.com/api/rest_api/#metadata) `write($path, $content, array('X-Upyun-Meta-Foo' =>
* 'bar'))`
* - [图片同步预处理](http://docs.upyun.com/cloud/image/#_5) `write($path, $content, array('x-gmkerl-thumb' => '/format/png'))`
* @param bool $withAsyncProcess 默认为 `false`,当上传图片或者音视频资源时,可以设置该参数为 `true`,开启图片音视频的[异步处理功能](http://docs.upyun.com/api/form_api/#_6) ,例如:
*```
* // 以下参数会将新上传的图片,再异步生成另一份 png 格式的图片,原图不受影响
* write($path, $content, array(
* 'apps' => array(
* array(
* 'name' => 'thumb', //异步图片处理任务
* 'x-gmkerl-thumb' => '/format/png', // 格式化图片为 png 格式
* 'save_as': '/iamge/png/new.png', // 处理成功后的图片保存路径
* 'notify_url': 'http://your.notify.url' // 异步任务完成后的回调地址
* )
* )
* ), true);
*```
*
*
*
* @return array|bool 若文件是图片则返回图片基本信息,如:`array('x-upyun-width' => 123, 'x-upyun-height' => 50, 'x-upyun-frames'
* => 1, 'x-upyun-file-type' => 'JPEG')`,否则返回空数组。当使用异步预处理功能时,返回结果为布尔值,成功为 `true`。
*
* @throws \Exception 上传失败时,抛出异常
*/
public function write($path, $content, $params = array(), $withAsyncProcess = false)
{
if (!$content) {
throw new \Exception('write content can not be empty.');
}
$upload = new Uploader($this->config);
$response = $upload->upload($path, $content, $params, $withAsyncProcess);
if ($withAsyncProcess) {
return $response;
}
return Util::getHeaderParams($response->getHeaders());
}
/**
* 读取云存储文件/目录内容
*
* @param string $path 又拍云存储中的文件或者目录路径
* @param resource $saveHandler 文件内容写入本地文件流。例如 `$saveHandler = fopen('/local/file', 'w')
* `。当设置该参数时,将以文件流的方式,直接将又拍云中的文件写入本地的文件流,或其他可以写入的流
* @param array $params 可选参数,读取目录内容时,需要设置三个参数: `X-List-Iter` 分页开始位置(第一页不需要设置),`X-List-Limit` 获取的文件数量(默认 100,最大
* 10000),`X-List-Order` 结果以时间正序或者倒序
*
* @return mixed $return 当读取文件且没有设置 `$saveHandler` 参数时,返回一个字符串类型,表示文件内容;设置了 `$saveHandler` 参数时,返回布尔值
* `true`。当读取目录时,返回一个数组,表示目录下的文件列表。目录下文件内容过多时,需要通过判断返回数组中的 `is_end` 属性,进行分页读取内容
*
* @throws \Exception
*/
public function read($path, $saveHandler = null, $params = array())
{
$req = new Rest($this->config);
$response = $req->request('GET', $path)
->withHeaders($params)
->send();
$params = Util::getHeaderParams($response->getHeaders());
if (! isset($params['x-upyun-list-iter'])) {
if (is_resource($saveHandler)) {
Psr7\copy_to_stream($response->getBody(), Psr7\stream_for($saveHandler));
return true;
} else {
return $response->getBody()->getContents();
}
} else {
$files = Util::parseDir($response->getBody()->getContents());
return array('files' => $files, 'is_end' => $params['x-upyun-list-iter'] === 'g2gCZAAEbmV4dGQAA2VvZg', 'iter' => $params['x-upyun-list-iter']);
}
}
/**
* 判断文件是否存在于又拍云存储
*
* 注意: 对刚删除的文件, 立即调用该方法可能会返回 true, 因为服务端执行删除操作后可能会有很短暂的延迟.
*
* @param string $path 云存储的文件路径
*
* @return bool 存在时返回 `true`,否则返回 `false`
* @throws \Exception
*/
public function has($path)
{
$req = new Rest($this->config);
try {
$req->request('HEAD', $path)
->send();
} catch (GuzzleHttp\Exception\BadResponseException $e) {
$statusCode = $e->getResponse()->getStatusCode();
if ($statusCode === 404) {
return false;
} else {
throw $e;
}
}
return true;
}
/**
* 获取云存储文件/目录的基本信息
*
* @param string $path 云存储的文件路径
* @param array $otherHeaders 设置了后,方法将返回其他 http header 中的信息,默认为空
*
* @return array 返回一个数组,默认包含以下 key
* - `x-upyun-file-type` 当 $path 是目录时,值为 *folder*,当 $path 是文件时,值为 *file*,
* - `x-upyun-file-size` 文件大小
* - `x-upyun-file-date` 文件的创建时间
*/
public function info($path, $otherHeaders = array())
{
$req = new Rest($this->config);
$response = $req->request('HEAD', $path)
->send();
return Util::getHeaderParams($response->getHeaders(), $otherHeaders);
}
/**
* 获取文件的文档类型
* @param string $path 云存储文件路径
* @return string 文档类型,e.g: `appcation/json`,获取失败返回空字符串
*/
public function getMimetype($path)
{
$params = $this->info($path, array('content-type'));
if (isset($params['content-type'])) {
return explode(';', $params['content-type'])[0];
}
return '';
}
/**
* 删除文件或者目录
*
* @param string $path 文件或目录在又拍云存储的路径
* @param bool $async 是否异步删除,默认为 false,表示同步删除。当需要批量删除大量文件时,必须选择异步删除
*
* @return bool 删除成功返回 true,否则 false
* @throws \Exception 删除不存在的文件将会抛出异常
*/
public function delete($path, $async = false)
{
$req = new Rest($this->config);
$req->request('DELETE', $path);
if ($async) {
$req->withHeader('x-upyun-async', 'true');
}
$res = $req->send();
return $res->getStatusCode() === 200;
}
/**
* 创建目录
*
* @param string $path 需要在又拍云存储创建的目录路径
*
* @return bool 创建成功返回 true,否则返回 false
* @throws \Exception
*/
public function createDir($path)
{
$path = rtrim($path, '/') . '/';
$req = new Rest($this->config);
$res = $req->request('POST', $path)
->withHeader('folder', 'true')
->send();
return $res->getStatusCode() === 200;
}
/**
* 删除文件或者目录
*
* @param string $path 需要被删除的云存储文件或目录路径
*
* @return bool 成功返回 true,否则 false
* @throws \Exception
*/
public function deleteDir($path)
{
return $this->delete($path);
}
/**
* 获取目录下存储使用量
*
* @param string $path 云存储目录路径,默认为根目录,表示整个云存储服务使用的空间大小
* @return string 存储使用量,单位字节
* @throws \Exception
*/
public function usage($path = '/')
{
$path = rtrim($path, '/') . '/';
$req = new Rest($this->config);
$response = $req->request('GET', $path . '?usage')
->send();
return $response->getBody()->getContents();
}
/**
* 刷新缓存
*
* @param array|string $urls 需要刷新的文件 url 列表
*
* @return array 刷新失败的 url 列表,若全部刷新成功则为空数组
*/
public function purge($urls)
{
$urlString = $urls;
if (is_array($urls)) {
$urlString = implode("\n", $urls);
}
$client = new Client([
'timeout' => $this->config->timeout
]);
$response = $client->request('POST', Config::ED_PURGE, [
'headers' => Signature::getPurgeSignHeader($this->config, $urlString),
'form_params' => ['purge' => $urlString]
]);
$result = json_decode($response->getBody()->getContents(), true);
return $result['invalid_domain_of_url'];
}
/**
* 异步云处理
*
* 该方法是基于[又拍云云处理](http://docs.upyun.com/cloud/) 服务实现,可以实现音视频的转码、切片、剪辑;文件的压缩解压缩;文件拉取功能
*
* 注意:
* - 所有需要调用该方法处理的资源,必须已经上传到云存储服务
* - 使用 `process` 之前,必须配置 `config->processNotifyUrl`,否则会提交任务失败
*
* 例如视频转码:
* ```
* process(array(
* array(
* 'type' => 'video', // video 表示视频任务, audio 表示音频任务
* 'avopts' => '/s/240p(4:3)/as/1/r/30', // 处理参数,`s` 表示输出的分辨率,`r` 表示视频帧率,`as` 表示是否自动调整分辨率
* 'save_as' => '/video/240/new.mp4', // 新视频在又拍云存储的保存路径
* ),
* ... // 同时还可以添加其他任务
* ), Upyun::$PROCESS_TYPE_MEDIA, $source)
* ```
*
* @param array $tasks 需要处理的任务
* @param string $type 异步云处理任务类型,可选值:
* - `Upyun::$PROCESS_TYPE_MEDIA` 异步音视频处理
* - `Upyun::$PROCESS_TYPE_ZIP` 文件压缩
* - `Upyun::$PROCESS_TYPE_UNZIP` 文件解压
* - `Upyun::$PROCESS_TYPE_SYNC_FILE` 文件拉取
* - `Upyun::$PROCESS_TYPE_STITCH` 图片拼接
* @param string $source 可选参数,处理异步音视频任务时,需要传递该参数,表示需要处理的文件路径
*
* @return array 任务 ID,提交了多少任务,便会返回多少任务 ID,与提交任务的顺序保持一致。可以通过任务 ID 查询处理进度。格式如下:
* ```
* array(
* '35f0148d414a688a275bf915ba7cebb2',
* '98adbaa52b2f63d6d7f327a0ff223348',
* )
* ```
* @throws \Exception
*/
public function process($tasks, $type, $source = '')
{
$video = new Api\Pretreat($this->config);
$options = array();
switch($type) {
case self::$PROCESS_TYPE_MEDIA:
$options['accept'] = 'json';
$options['source'] = $source;
break;
case self::$PROCESS_TYPE_ZIP:
$options['app_name'] = 'compress';
break;
case self::$PROCESS_TYPE_UNZIP:
$options['app_name'] = 'depress';
break;
case self::$PROCESS_TYPE_SYNC_FILE:
$options['app_name'] = 'spiderman';
break;
case self::$PROCESS_TYPE_CONVERT:
$options['app_name'] = 'uconvert';
break;
case self::$PROCESS_TYPE_STITCH:
$options['app_name'] = 'jigsaw';
break;
default:
throw new \Exception('upyun - not support process type.');
}
return $video->process($tasks, $options);
}
/**
* 查询异步云处理任务进度
*
* 根据 `process` 方法返回的任务 ID,通过该访问查询处理进度
*
* @param array $taskIds 任务 ID
*
* @return bool|array 查询失败返回布尔值 `false`,否则返回每个任务的百分比进度信息,格式如下:
* ```
* array(
* '35f0148d414a688a275bf915ba7cebb2' => 100, // 100 表示任务完成
* 'c3103189fa906a5354d29bd807e8dc51' => 35,
* '98adbaa52b2f63d6d7f327a0ff223348' => null, // null 表示任务未开始,或异常
* )
* ```
*/
public function queryProcessStatus($taskIds)
{
$video = new Api\Pretreat($this->config);
return $video->query($taskIds, '/status/');
}
/**
* 查询异步云处理任务结果
*
* 根据 `process` 方法返回的任务 ID,通过该访问查询处理结果,会包含每个任务详细信息
* @param array $taskIds 任务 ID
*
* @return bool|mixed 查询失败返回 `false`,否则返回每个任务的处理结果,格式如下:
* ```
* array(
* '9d9c32b63a1034834e77672c6f51f661' => array(
* 'path' => array('/v2.mp4'),
* 'signature' => '4042c1f07f546d28',
* 'status_code' => 200,
* 'service_name' => 'your_storage_service',
* 'description' => 'OK',
* 'task_id' => '9d9c32b63a1034834e77672c6f51f661',
* 'timestamp' => 1472010684
* )
* )
* ```
*/
public function queryProcessResult($taskIds)
{
$video = new Api\Pretreat($this->config);
return $video->query($taskIds, '/result/');
}
/**
* 多个 m3u8 文件拼接
* @param array $files 保存在又拍云云存储中的多个 m3u8 文件路径
* @param string $saveAs 拼接生成的新 m3u8 文件保存路径
*
* @return array 见 [m3u8 拼接 - 响应](http://docs.upyun.com/cloud/sync_video/#_3)
*/
public function m3u8Concat($files, $saveAs)
{
$p = new Api\SyncVideo($this->config);
return $p->process([
'm3u8s' => $files,
'save_as' => $saveAs,
], '/m3u8er/concat');
}
/**
* 单个 m3u8 文件剪辑
* @param string $file 需要剪辑的又拍云云存储中的 m3u8 文件路径
* @param string $saveAs 剪辑完成后新的 m3u8 文件保存路径
* @param array $slice 需要被保留或删除的片段。
* @param bool $isInclude 默认为 `true` 表示 `$slice` 参数描述的片段被保留,否则表示 `$slice` 参数描述的片段被删除
* @param bool $index 指定 `$slice` 参数的格式,默认为 `false` 表示使用时间范围描述片段,单位秒:`[<开始时间>, <结束时间>]`;`true` 表示使用 `m3u8` 文件的分片序号,从 0 开始,这种方式可以一次对多个片段操作
*
* @return array 见 [m3u8 剪辑 - 响应](http://docs.upyun.com/cloud/sync_video/#_6)
*/
public function m3u8Clip($file, $saveAs, $slice = array(), $isInclude = true, $index = false)
{
$p = new Api\SyncVideo($this->config);
$params = [
'm3u8' => $file,
'save_as' => $saveAs,
'index' => $index,
];
if ($isInclude) {
$params['include'] = $slice;
} else {
$params['exclude'] = $slice;
}
return $p->process($params, '/m3u8er/clip');
}
/**
* 获取单个 m3u8 文件描述信息
* @param string $file 又拍云云存储的中的 m3u8 文件路径
*
* @return array 见 [获取 m3u8 信息 - 响应](http://docs.upyun.com/cloud/sync_video/#_6)
*/
public function m3u8Meta($file)
{
$p = new Api\SyncVideo($this->config);
return $p->process([
'm3u8' => $file,
], '/m3u8er/get_meta');
}
/**
* 视频截图,可以对 mp4、m3u8 等视频文件进行截图
* @param string $file 需要截图的又拍云云存储中的视频文件路径
* @param string $saveAs 截图保存路径
* @param string $point 截图时间点,`HH:MM:SS` 格式
* @param string $size 截图尺寸 `宽x高` 格式的字符串。默认和视频尺寸一致
* @param string $format 截图保存的格式,默认根据 `$saveAs` 参数的后缀生成,可以指定 `jpg | png | webp` 三种格式
*
* @return array 见 [视频截图 - 响应](http://docs.upyun.com/cloud/sync_video/#m3u8_2)
*/
public function snapshot($file, $saveAs, $point, $size = '', $format = '')
{
$p = new Api\SyncVideo($this->config);
$params = [
'source' => $file,
'save_as' => $saveAs,
'point' => $point,
];
if ($size) {
$params['size'] = $size;
}
if ($format) {
$params['format'] = $format;
}
return $p->process($params, '/snapshot');
}
/**
* 获取音视频文件元信息
* @param string $file 又拍云云存储的中的音视频文件路径
*
* @return array 见 [获取音视频文件信息 - 响应](http://docs.upyun.com/cloud/sync_video/#_16)
*/
public function avMeta($file)
{
$p = new Api\SyncVideo($this->config);
return $p->process([
'source' => $file,
], '/avmeta/get_meta');
}
}
... ...
<?php
namespace Upyun;
class Util
{
public static function trim($str)
{
if (is_array($str)) {
return array_map(array('Util', 'trim'), $str);
} else {
return trim($str);
}
}
public static function getHeaderParams($headers, $otherParams = array())
{
$params = [];
$otherParams = array_map('strtolower', $otherParams);
foreach ($headers as $header => $value) {
$header = strtolower($header);
if (strpos($header, 'x-upyun-') !== false) {
$params[$header] = $value[0];
} else if (in_array($header, $otherParams)) {
$params[$header] = $value[0];
}
}
return $params;
}
public static function parseDir($body)
{
$files = array();
if (!$body) {
return array();
}
$lines = explode("\n", $body);
foreach ($lines as $line) {
$file = [];
list($file['name'], $file['type'], $file['size'], $file['time']) = explode("\t", $line, 4);
$files[] = $file;
}
return $files;
}
public static function base64Json($params)
{
return base64_encode(json_encode($params, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
}
public static function stringifyHeaders($headers)
{
$return = array();
foreach ($headers as $key => $value) {
$return[] = "$key: $value";
}
return $return;
}
public static function md5Hash($resource)
{
rewind($resource);
$ctx = hash_init('md5');
hash_update_stream($ctx, $resource);
$md5 = hash_final($ctx);
return $md5;
}
/**
* GuzzleHttp\Psr\Uri use `parse_url`,not good for utf-8,
* So should `encodeURI` first, before `new Psr7\Request`
* @see http://stackoverflow.com/questions/4929584/encodeuri-in-php
*/
public static function encodeURI($url)
{
$unescaped = array(
'%2D'=>'-','%5F'=>'_','%2E'=>'.','%21'=>'!', '%7E'=>'~',
'%2A'=>'*', '%27'=>"'", '%28'=>'(', '%29'=>')'
);
$reserved = array(
'%3B'=>';','%2C'=>',','%2F'=>'/','%3F'=>'?','%3A'=>':',
'%40'=>'@','%26'=>'&','%3D'=>'=','%2B'=>'+','%24'=>'$'
);
$score = array(
'%23'=>'#'
);
return strtr(rawurlencode($url), array_merge($reserved, $unescaped, $score));
}
}
... ...
deny from all
\ No newline at end of file
... ...
<?php
namespace app\admin\behavior;
class AdminLog
{
public function run(&$params)
{
//只记录POST请求的日志
if (request()->isPost() && config('fastadmin.auto_record_log')) {
\app\admin\model\AdminLog::record();
}
}
}
... ...
<?php
namespace app\admin\command;
use think\addons\AddonException;
use think\addons\Service;
use think\Config;
use think\console\Command;
use think\console\Input;
use think\console\input\Option;
use think\console\Output;
use think\Db;
use think\Exception;
use think\exception\PDOException;
class Addon extends Command
{
protected function configure()
{
$this
->setName('addon')
->addOption('name', 'a', Option::VALUE_REQUIRED, 'addon name', null)
->addOption('action', 'c', Option::VALUE_REQUIRED, 'action(create/enable/disable/install/uninstall/refresh/upgrade/package/move)', 'create')
->addOption('force', 'f', Option::VALUE_OPTIONAL, 'force override', null)
->addOption('release', 'r', Option::VALUE_OPTIONAL, 'addon release version', null)
->addOption('uid', 'u', Option::VALUE_OPTIONAL, 'fastadmin uid', null)
->addOption('token', 't', Option::VALUE_OPTIONAL, 'fastadmin token', null)
->addOption('local', 'l', Option::VALUE_OPTIONAL, 'local package', null)
->setDescription('Addon manager');
}
protected function execute(Input $input, Output $output)
{
$name = $input->getOption('name') ?: '';
$action = $input->getOption('action') ?: '';
if (stripos($name, 'addons' . DS) !== false) {
$name = explode(DS, $name)[1];
}
//强制覆盖
$force = $input->getOption('force');
//版本
$release = $input->getOption('release') ?: '';
//uid
$uid = $input->getOption('uid') ?: '';
//token
$token = $input->getOption('token') ?: '';
include dirname(__DIR__) . DS . 'common.php';
if (!$name) {
throw new Exception('Addon name could not be empty');
}
if (!$action || !in_array($action, ['create', 'disable', 'enable', 'install', 'uninstall', 'refresh', 'upgrade', 'package', 'move'])) {
throw new Exception('Please input correct action name');
}
// 查询一次SQL,判断连接是否正常
Db::execute("SELECT 1");
$addonDir = ADDON_PATH . $name . DS;
switch ($action) {
case 'create':
//非覆盖模式时如果存在则报错
if (is_dir($addonDir) && !$force) {
throw new Exception("addon already exists!\nIf you need to create again, use the parameter --force=true ");
}
//如果存在先移除
if (is_dir($addonDir)) {
rmdirs($addonDir);
}
mkdir($addonDir, 0755, true);
mkdir($addonDir . DS . 'controller', 0755, true);
$menuList = \app\common\library\Menu::export($name);
$createMenu = $this->getCreateMenu($menuList);
$prefix = Config::get('database.prefix');
$createTableSql = '';
try {
$result = Db::query("SHOW CREATE TABLE `" . $prefix . $name . "`;");
if (isset($result[0]) && isset($result[0]['Create Table'])) {
$createTableSql = $result[0]['Create Table'];
}
} catch (PDOException $e) {
}
$data = [
'name' => $name,
'addon' => $name,
'addonClassName' => ucfirst($name),
'addonInstallMenu' => $createMenu ? "\$menu = " . var_export_short($createMenu) . ";\n\tMenu::create(\$menu);" : '',
'addonUninstallMenu' => $menuList ? 'Menu::delete("' . $name . '");' : '',
'addonEnableMenu' => $menuList ? 'Menu::enable("' . $name . '");' : '',
'addonDisableMenu' => $menuList ? 'Menu::disable("' . $name . '");' : '',
];
$this->writeToFile("addon", $data, $addonDir . ucfirst($name) . '.php');
$this->writeToFile("config", $data, $addonDir . 'config.php');
$this->writeToFile("info", $data, $addonDir . 'info.ini');
$this->writeToFile("controller", $data, $addonDir . 'controller' . DS . 'Index.php');
if ($createTableSql) {
$createTableSql = str_replace("`" . $prefix, '`__PREFIX__', $createTableSql);
file_put_contents($addonDir . 'install.sql', $createTableSql);
}
$output->info("Create Successed!");
break;
case 'disable':
case 'enable':
try {
//调用启用、禁用的方法
Service::$action($name, 0);
} catch (AddonException $e) {
if ($e->getCode() != -3) {
throw new Exception($e->getMessage());
}
if (!$force) {
//如果有冲突文件则提醒
$data = $e->getData();
foreach ($data['conflictlist'] as $k => $v) {
$output->warning($v);
}
$output->info("Are you sure you want to " . ($action == 'enable' ? 'override' : 'delete') . " all those files? Type 'yes' to continue: ");
$line = fgets(defined('STDIN') ? STDIN : fopen('php://stdin', 'r'));
if (trim($line) != 'yes') {
throw new Exception("Operation is aborted!");
}
}
//调用启用、禁用的方法
Service::$action($name, 1);
} catch (Exception $e) {
throw new Exception($e->getMessage());
}
$output->info(ucfirst($action) . " Successed!");
break;
case 'install':
//非覆盖模式时如果存在则报错
if (is_dir($addonDir) && !$force) {
throw new Exception("addon already exists!\nIf you need to install again, use the parameter --force=true ");
}
//如果存在先移除
if (is_dir($addonDir)) {
rmdirs($addonDir);
}
// 获取本地路径
$local = $input->getOption('local');
try {
Service::install($name, 0, ['version' => $release], $local);
} catch (AddonException $e) {
if ($e->getCode() != -3) {
throw new Exception($e->getMessage());
}
if (!$force) {
//如果有冲突文件则提醒
$data = $e->getData();
foreach ($data['conflictlist'] as $k => $v) {
$output->warning($v);
}
$output->info("Are you sure you want to override all those files? Type 'yes' to continue: ");
$line = fgets(defined('STDIN') ? STDIN : fopen('php://stdin', 'r'));
if (trim($line) != 'yes') {
throw new Exception("Operation is aborted!");
}
}
Service::install($name, 1, ['version' => $release, 'uid' => $uid, 'token' => $token], $local);
} catch (Exception $e) {
throw new Exception($e->getMessage());
}
$output->info("Install Successed!");
break;
case 'uninstall':
//非覆盖模式时如果存在则报错
if (!$force) {
throw new Exception("If you need to uninstall addon, use the parameter --force=true ");
}
try {
Service::uninstall($name, 0);
} catch (AddonException $e) {
if ($e->getCode() != -3) {
throw new Exception($e->getMessage());
}
if (!$force) {
//如果有冲突文件则提醒
$data = $e->getData();
foreach ($data['conflictlist'] as $k => $v) {
$output->warning($v);
}
$output->info("Are you sure you want to delete all those files? Type 'yes' to continue: ");
$line = fgets(defined('STDIN') ? STDIN : fopen('php://stdin', 'r'));
if (trim($line) != 'yes') {
throw new Exception("Operation is aborted!");
}
}
Service::uninstall($name, 1);
} catch (Exception $e) {
throw new Exception($e->getMessage());
}
$output->info("Uninstall Successed!");
break;
case 'refresh':
Service::refresh();
$output->info("Refresh Successed!");
break;
case 'upgrade':
Service::upgrade($name, ['version' => $release, 'uid' => $uid, 'token' => $token]);
$output->info("Upgrade Successed!");
break;
case 'package':
$infoFile = $addonDir . 'info.ini';
if (!is_file($infoFile)) {
throw new Exception(__('Addon info file was not found'));
}
$info = get_addon_info($name);
if (!$info) {
throw new Exception(__('Addon info file data incorrect'));
}
$infoname = isset($info['name']) ? $info['name'] : '';
if (!$infoname || !preg_match("/^[a-z]+$/i", $infoname) || $infoname != $name) {
throw new Exception(__('Addon info name incorrect'));
}
$infoversion = isset($info['version']) ? $info['version'] : '';
if (!$infoversion || !preg_match("/^\d+\.\d+\.\d+$/i", $infoversion)) {
throw new Exception(__('Addon info version incorrect'));
}
$addonTmpDir = RUNTIME_PATH . 'addons' . DS;
if (!is_dir($addonTmpDir)) {
@mkdir($addonTmpDir, 0755, true);
}
$addonFile = $addonTmpDir . $infoname . '-' . $infoversion . '.zip';
if (!class_exists('ZipArchive')) {
throw new Exception(__('ZinArchive not install'));
}
$zip = new \ZipArchive;
$zip->open($addonFile, \ZipArchive::CREATE | \ZipArchive::OVERWRITE);
$files = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator($addonDir), \RecursiveIteratorIterator::LEAVES_ONLY
);
foreach ($files as $name => $file) {
if (!$file->isDir()) {
$filePath = $file->getRealPath();
$relativePath = str_replace(DS, '/', substr($filePath, strlen($addonDir)));
if (!in_array($file->getFilename(), ['.git', '.DS_Store', 'Thumbs.db'])) {
$zip->addFile($filePath, $relativePath);
}
}
}
$zip->close();
$output->info("Package Successed!");
break;
case 'move':
$movePath = [
'adminOnlySelfDir' => ['admin/behavior', 'admin/controller', 'admin/library', 'admin/model', 'admin/validate', 'admin/view'],
'adminAllSubDir' => ['admin/lang'],
'publicDir' => ['public/assets/addons', 'public/assets/js/backend']
];
$paths = [];
$appPath = str_replace('/', DS, APP_PATH);
$rootPath = str_replace('/', DS, ROOT_PATH);
foreach ($movePath as $k => $items) {
switch ($k) {
case 'adminOnlySelfDir':
foreach ($items as $v) {
$v = str_replace('/', DS, $v);
$oldPath = $appPath . $v . DS . $name;
$newPath = $rootPath . "addons" . DS . $name . DS . "application" . DS . $v . DS . $name;
$paths[$oldPath] = $newPath;
}
break;
case 'adminAllSubDir':
foreach ($items as $v) {
$v = str_replace('/', DS, $v);
$vPath = $appPath . $v;
$list = scandir($vPath);
foreach ($list as $_v) {
if (!in_array($_v, ['.', '..']) && is_dir($vPath . DS . $_v)) {
$oldPath = $appPath . $v . DS . $_v . DS . $name;
$newPath = $rootPath . "addons" . DS . $name . DS . "application" . DS . $v . DS . $_v . DS . $name;
$paths[$oldPath] = $newPath;
}
}
}
break;
case 'publicDir':
foreach ($items as $v) {
$v = str_replace('/', DS, $v);
$oldPath = $rootPath . $v . DS . $name;
$newPath = $rootPath . 'addons' . DS . $name . DS . $v . DS . $name;
$paths[$oldPath] = $newPath;
}
break;
}
}
foreach ($paths as $oldPath => $newPath) {
if (is_dir($oldPath)) {
if ($force) {
if (is_dir($newPath)) {
$list = scandir($newPath);
foreach ($list as $_v) {
if (!in_array($_v, ['.', '..'])) {
$file = $newPath . DS . $_v;
@chmod($file, 0777);
@unlink($file);
}
}
@rmdir($newPath);
}
}
copydirs($oldPath, $newPath);
}
}
break;
default:
break;
}
}
/**
* 获取创建菜单的数组
* @param array $menu
* @return array
*/
protected function getCreateMenu($menu)
{
$result = [];
foreach ($menu as $k => & $v) {
$arr = [
'name' => $v['name'],
'title' => $v['title'],
];
if ($v['icon'] != 'fa fa-circle-o') {
$arr['icon'] = $v['icon'];
}
if ($v['ismenu']) {
$arr['ismenu'] = $v['ismenu'];
}
if (isset($v['childlist']) && $v['childlist']) {
$arr['sublist'] = $this->getCreateMenu($v['childlist']);
}
$result[] = $arr;
}
return $result;
}
/**
* 写入到文件
* @param string $name
* @param array $data
* @param string $pathname
* @return mixed
*/
protected function writeToFile($name, $data, $pathname)
{
$search = $replace = [];
foreach ($data as $k => $v) {
$search[] = "{%{$k}%}";
$replace[] = $v;
}
$stub = file_get_contents($this->getStub($name));
$content = str_replace($search, $replace, $stub);
if (!is_dir(dirname($pathname))) {
mkdir(strtolower(dirname($pathname)), 0755, true);
}
return file_put_contents($pathname, $content);
}
/**
* 获取基础模板
* @param string $name
* @return string
*/
protected function getStub($name)
{
return __DIR__ . '/Addon/stubs/' . $name . '.stub';
}
}
... ...
<?php
namespace addons\{%name%};
use app\common\library\Menu;
use think\Addons;
/**
* 插件
*/
class {%addonClassName%} extends Addons
{
/**
* 插件安装方法
* @return bool
*/
public function install()
{
{%addonInstallMenu%}
return true;
}
/**
* 插件卸载方法
* @return bool
*/
public function uninstall()
{
{%addonUninstallMenu%}
return true;
}
/**
* 插件启用方法
* @return bool
*/
public function enable()
{
{%addonEnableMenu%}
return true;
}
/**
* 插件禁用方法
* @return bool
*/
public function disable()
{
{%addonDisableMenu%}
return true;
}
/**
* 实现钩子方法
* @return mixed
*/
public function testhook($param)
{
// 调用钩子时候的参数信息
print_r($param);
// 当前插件的配置信息,配置信息存在当前目录的config.php文件中,见下方
print_r($this->getConfig());
// 可以返回模板,模板文件默认读取的为插件目录中的文件。模板名不能为空!
//return $this->fetch('view/info');
}
}
... ...
<?php
return [
[
//配置唯一标识
'name' => 'usernmae',
//显示的标题
'title' => '用户名',
//类型
'type' => 'string',
//数据字典
'content' => [
],
//值
'value' => '',
//验证规则
'rule' => 'required',
//错误消息
'msg' => '',
//提示消息
'tip' => '',
//成功消息
'ok' => '',
//扩展信息
'extend' => ''
],
[
'name' => 'password',
'title' => '密码',
'type' => 'string',
'content' => [
],
'value' => '',
'rule' => 'required',
'msg' => '',
'tip' => '',
'ok' => '',
'extend' => ''
],
];
... ...
<?php
namespace addons\{%addon%}\controller;
use think\addons\Controller;
class Index extends Controller
{
public function index()
{
$this->error("当前插件暂无前台页面");
}
}
... ...
name = {%name%}
title = 插件名称{%name%}
intro = FastAdmin插件
author = yourname
website = https://www.fastadmin.net
version = 1.0.0
state = 1
\ No newline at end of file
... ...
<?php
namespace app\admin\command;
use app\admin\command\Api\library\Builder;
use think\Config;
use think\console\Command;
use think\console\Input;
use think\console\input\Option;
use think\console\Output;
use think\Exception;
class Api extends Command
{
protected function configure()
{
$site = Config::get('site');
$this
->setName('api')
->addOption('url', 'u', Option::VALUE_OPTIONAL, 'default api url', '')
->addOption('module', 'm', Option::VALUE_OPTIONAL, 'module name(admin/index/api)', 'api')
->addOption('output', 'o', Option::VALUE_OPTIONAL, 'output index file name', 'api.html')
->addOption('template', 'e', Option::VALUE_OPTIONAL, '', 'index.html')
->addOption('force', 'f', Option::VALUE_OPTIONAL, 'force override general file', false)
->addOption('title', 't', Option::VALUE_OPTIONAL, 'document title', $site['name'])
->addOption('author', 'a', Option::VALUE_OPTIONAL, 'document author', $site['name'])
->addOption('class', 'c', Option::VALUE_OPTIONAL | Option::VALUE_IS_ARRAY, 'extend class', null)
->addOption('language', 'l', Option::VALUE_OPTIONAL, 'language', 'zh-cn')
->setDescription('Build Api document from controller');
}
protected function execute(Input $input, Output $output)
{
$apiDir = __DIR__ . DS . 'Api' . DS;
$force = $input->getOption('force');
$url = $input->getOption('url');
$language = $input->getOption('language');
$language = $language ? $language : 'zh-cn';
$langFile = $apiDir . 'lang' . DS . $language . '.php';
if (!is_file($langFile)) {
throw new Exception('language file not found');
}
$lang = include_once $langFile;
// 目标目录
$output_dir = ROOT_PATH . 'public' . DS;
$output_file = $output_dir . $input->getOption('output');
if (is_file($output_file) && !$force) {
throw new Exception("api index file already exists!\nIf you need to rebuild again, use the parameter --force=true ");
}
// 模板文件
$template_dir = $apiDir . 'template' . DS;
$template_file = $template_dir . $input->getOption('template');
if (!is_file($template_file)) {
throw new Exception('template file not found');
}
// 额外的类
$classes = $input->getOption('class');
// 标题
$title = $input->getOption('title');
// 作者
$author = $input->getOption('author');
// 模块
$module = $input->getOption('module');
$moduleDir = APP_PATH . $module . DS;
if (!is_dir($moduleDir)) {
throw new Exception('module not found');
}
if (version_compare(PHP_VERSION, '7.0.0', '<')) {
if (extension_loaded('Zend OPcache')) {
$configuration = opcache_get_configuration();
$directives = $configuration['directives'];
$configName = request()->isCli() ? 'opcache.enable_cli' : 'opcache.enable';
if (!$directives[$configName]) {
throw new Exception("Please make sure {$configName} is turned on, Get help:https://forum.fastadmin.net/d/1321");
}
} else {
throw new Exception("Please make sure opcache already enabled, Get help:https://forum.fastadmin.net/d/1321");
}
}
$controllerDir = $moduleDir . Config::get('url_controller_layer') . DS;
$files = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator($controllerDir),
\RecursiveIteratorIterator::LEAVES_ONLY
);
foreach ($files as $name => $file) {
if (!$file->isDir() && $file->getExtension() == 'php') {
$filePath = $file->getRealPath();
$classes[] = $this->get_class_from_file($filePath);
}
}
$classes = array_unique(array_filter($classes));
$config = [
'sitename' => config('site.name'),
'title' => $title,
'author' => $author,
'description' => '',
'apiurl' => $url,
'language' => $language,
];
$builder = new Builder($classes);
$content = $builder->render($template_file, ['config' => $config, 'lang' => $lang]);
if (!file_put_contents($output_file, $content)) {
throw new Exception('Cannot save the content to ' . $output_file);
}
$output->info("Build Successed!");
}
/**
* get full qualified class name
*
* @param string $path_to_file
* @return string
* @author JBYRNE http://jarretbyrne.com/2015/06/197/
*/
protected function get_class_from_file($path_to_file)
{
//Grab the contents of the file
$contents = file_get_contents($path_to_file);
//Start with a blank namespace and class
$namespace = $class = "";
//Set helper values to know that we have found the namespace/class token and need to collect the string values after them
$getting_namespace = $getting_class = false;
//Go through each token and evaluate it as necessary
foreach (token_get_all($contents) as $token) {
//If this token is the namespace declaring, then flag that the next tokens will be the namespace name
if (is_array($token) && $token[0] == T_NAMESPACE) {
$getting_namespace = true;
}
//If this token is the class declaring, then flag that the next tokens will be the class name
if (is_array($token) && $token[0] == T_CLASS) {
$getting_class = true;
}
//While we're grabbing the namespace name...
if ($getting_namespace === true) {
//If the token is a string or the namespace separator...
if (is_array($token) && in_array($token[0], [T_STRING, T_NS_SEPARATOR])) {
//Append the token's value to the name of the namespace
$namespace .= $token[1];
} elseif ($token === ';') {
//If the token is the semicolon, then we're done with the namespace declaration
$getting_namespace = false;
}
}
//While we're grabbing the class name...
if ($getting_class === true) {
//If the token is a string, it's the name of the class
if (is_array($token) && $token[0] == T_STRING) {
//Store the token's value as the class name
$class = $token[1];
//Got what we need, stope here
break;
}
}
}
//Build the fully-qualified class name and return it
return $namespace ? $namespace . '\\' . $class : $class;
}
}
... ...
<?php
return [
'Info' => '基础信息',
'Sandbox' => '在线测试',
'Sampleoutput' => '返回示例',
'Headers' => 'Headers',
'Parameters' => '参数',
'Body' => '正文',
'Name' => '名称',
'Type' => '类型',
'Required' => '必选',
'Description' => '描述',
'Send' => '提交',
'Reset' => '重置',
'Tokentips' => 'Token在会员注册或登录后都会返回,WEB端同时存在于Cookie中',
'Apiurltips' => 'API接口URL',
'Savetips' => '点击保存后Token和Api url都将保存在本地Localstorage中',
'ReturnHeaders' => '响应头',
'ReturnParameters' => '返回参数',
'Response' => '响应输出',
];
... ...
<?php
namespace app\admin\command\Api\library;
use think\Config;
/**
* @website https://github.com/calinrada/php-apidoc
* @author Calin Rada <rada.calin@gmail.com>
* @author Karson <karsonzhang@163.com>
*/
class Builder
{
/**
*
* @var \think\View
*/
public $view = null;
/**
* parse classes
* @var array
*/
protected $classes = [];
/**
*
* @param array $classes
*/
public function __construct($classes = [])
{
$this->classes = array_merge($this->classes, $classes);
$this->view = new \think\View(Config::get('template'), Config::get('view_replace_str'));
}
protected function extractAnnotations()
{
foreach ($this->classes as $class) {
$classAnnotation = Extractor::getClassAnnotations($class);
// 如果忽略
if (isset($classAnnotation['ApiInternal'])) {
continue;
}
Extractor::getClassMethodAnnotations($class);
}
$allClassAnnotation = Extractor::getAllClassAnnotations();
$allClassMethodAnnotation = Extractor::getAllClassMethodAnnotations();
// foreach ($allClassMethodAnnotation as $className => &$methods) {
// foreach ($methods as &$method) {
// //权重判断
// if ($method && !isset($method['ApiWeigh']) && isset($allClassAnnotation[$className]['ApiWeigh'])) {
// $method['ApiWeigh'] = $allClassAnnotation[$className]['ApiWeigh'];
// }
// }
// }
// unset($methods);
return [$allClassAnnotation, $allClassMethodAnnotation];
}
protected function generateHeadersTemplate($docs)
{
if (!isset($docs['ApiHeaders'])) {
return [];
}
$headerslist = array();
foreach ($docs['ApiHeaders'] as $params) {
$tr = array(
'name' => $params['name'],
'type' => $params['type'],
'sample' => isset($params['sample']) ? $params['sample'] : '',
'required' => isset($params['required']) ? $params['required'] : false,
'description' => isset($params['description']) ? $params['description'] : '',
);
$headerslist[] = $tr;
}
return $headerslist;
}
protected function generateParamsTemplate($docs)
{
if (!isset($docs['ApiParams'])) {
return [];
}
$paramslist = array();
foreach ($docs['ApiParams'] as $params) {
$tr = array(
'name' => $params['name'],
'type' => isset($params['type']) ? $params['type'] : 'string',
'sample' => isset($params['sample']) ? $params['sample'] : '',
'required' => isset($params['required']) ? $params['required'] : true,
'description' => isset($params['description']) ? $params['description'] : '',
);
$paramslist[] = $tr;
}
return $paramslist;
}
protected function generateReturnHeadersTemplate($docs)
{
if (!isset($docs['ApiReturnHeaders'])) {
return [];
}
$headerslist = array();
foreach ($docs['ApiReturnHeaders'] as $params) {
$tr = array(
'name' => $params['name'],
'type' => 'string',
'sample' => isset($params['sample']) ? $params['sample'] : '',
'required' => isset($params['required']) && $params['required'] ? 'Yes' : 'No',
'description' => isset($params['description']) ? $params['description'] : '',
);
$headerslist[] = $tr;
}
return $headerslist;
}
protected function generateReturnParamsTemplate($st_params)
{
if (!isset($st_params['ApiReturnParams'])) {
return [];
}
$paramslist = array();
foreach ($st_params['ApiReturnParams'] as $params) {
$tr = array(
'name' => $params['name'],
'type' => isset($params['type']) ? $params['type'] : 'string',
'sample' => isset($params['sample']) ? $params['sample'] : '',
'description' => isset($params['description']) ? $params['description'] : '',
);
$paramslist[] = $tr;
}
return $paramslist;
}
protected function generateBadgeForMethod($data)
{
$method = strtoupper(is_array($data['ApiMethod'][0]) ? $data['ApiMethod'][0]['data'] : $data['ApiMethod'][0]);
$labes = array(
'POST' => 'label-primary',
'GET' => 'label-success',
'PUT' => 'label-warning',
'DELETE' => 'label-danger',
'PATCH' => 'label-default',
'OPTIONS' => 'label-info'
);
return isset($labes[$method]) ? $labes[$method] : $labes['GET'];
}
public function parse()
{
list($allClassAnnotations, $allClassMethodAnnotations) = $this->extractAnnotations();
$sectorArr = [];
foreach ($allClassAnnotations as $index => $allClassAnnotation) {
$sector = isset($allClassAnnotation['ApiSector']) ? $allClassAnnotation['ApiSector'][0] : $allClassAnnotation['ApiTitle'][0];
$sectorArr[$sector] = isset($allClassAnnotation['ApiWeigh']) ? $allClassAnnotation['ApiWeigh'][0] : 0;
}
arsort($sectorArr);
$routes = include_once CONF_PATH . 'route.php';
$subdomain = false;
if (config('url_domain_deploy') && isset($routes['__domain__']) && isset($routes['__domain__']['api']) && $routes['__domain__']['api']) {
$subdomain = true;
}
$counter = 0;
$section = null;
$weigh = 0;
$docslist = [];
foreach ($allClassMethodAnnotations as $class => $methods) {
foreach ($methods as $name => $docs) {
if (isset($docs['ApiSector'][0])) {
$section = is_array($docs['ApiSector'][0]) ? $docs['ApiSector'][0]['data'] : $docs['ApiSector'][0];
} else {
$section = $class;
}
if (0 === count($docs)) {
continue;
}
$route = is_array($docs['ApiRoute'][0]) ? $docs['ApiRoute'][0]['data'] : $docs['ApiRoute'][0];
if ($subdomain) {
$route = substr($route, 4);
}
$docslist[$section][$class . $name] = [
'id' => $counter,
'method' => is_array($docs['ApiMethod'][0]) ? $docs['ApiMethod'][0]['data'] : $docs['ApiMethod'][0],
'method_label' => $this->generateBadgeForMethod($docs),
'section' => $section,
'route' => $route,
'title' => is_array($docs['ApiTitle'][0]) ? $docs['ApiTitle'][0]['data'] : $docs['ApiTitle'][0],
'summary' => is_array($docs['ApiSummary'][0]) ? $docs['ApiSummary'][0]['data'] : $docs['ApiSummary'][0],
'body' => isset($docs['ApiBody'][0]) ? is_array($docs['ApiBody'][0]) ? $docs['ApiBody'][0]['data'] : $docs['ApiBody'][0] : '',
'headerslist' => $this->generateHeadersTemplate($docs),
'paramslist' => $this->generateParamsTemplate($docs),
'returnheaderslist' => $this->generateReturnHeadersTemplate($docs),
'returnparamslist' => $this->generateReturnParamsTemplate($docs),
'weigh' => is_array($docs['ApiWeigh'][0]) ? $docs['ApiWeigh'][0]['data'] : $docs['ApiWeigh'][0],
'return' => isset($docs['ApiReturn']) ? is_array($docs['ApiReturn'][0]) ? $docs['ApiReturn'][0]['data'] : $docs['ApiReturn'][0] : '',
];
$counter++;
}
}
//重建排序
foreach ($docslist as $index => &$methods) {
$methodSectorArr = [];
foreach ($methods as $name => $method) {
$methodSectorArr[$name] = isset($method['weigh']) ? $method['weigh'] : 0;
}
arsort($methodSectorArr);
$methods = array_merge(array_flip(array_keys($methodSectorArr)), $methods);
}
$docslist = array_merge(array_flip(array_keys($sectorArr)), $docslist);
$docslist = array_filter($docslist , function($v) {return is_array($v) ; }) ;
return $docslist;
}
public function getView()
{
return $this->view;
}
/**
* 渲染
* @param string $template
* @param array $vars
* @return string
*/
public function render($template, $vars = [])
{
$docslist = $this->parse();
return $this->view->display(file_get_contents($template), array_merge($vars, ['docslist' => $docslist]));
}
}
... ...