diff --git a/404.html b/404.html new file mode 100644 index 0000000..c764cf0 --- /dev/null +++ b/404.html @@ -0,0 +1,29 @@ + + + + + + +404 + + + + +

404,您请求的文件不存在!

+ + + diff --git a/404.png b/404.png new file mode 100644 index 0000000..236d9af Binary files /dev/null and b/404.png differ diff --git a/LICENSE b/LICENSE index cfbc66d..77ed30f 100644 --- a/LICENSE +++ b/LICENSE @@ -1,165 +1,165 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - 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 that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU 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 as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + 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 that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU 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 as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the Library. \ No newline at end of file diff --git a/README.md b/README.md index bc5725b..c9af2d9 100644 --- a/README.md +++ b/README.md @@ -1,174 +1,175 @@ -![简单图床示例](https://i1.100024.xyz/public/data/2019/05/5ce6915f50a1a.png - "简单图床示例") -![简单图床示例](https://i1.100024.xyz/public/data/2019/05/5cecf12575f6e.png - "简单图床示例") - -## EasyImage 简单图床 -> 支持多文件上传,api上传,简单无数据库,返回图片url,markdown,bbscode,html的一款图床程序 -演示地址: [https://img.545141.com](https://img.545141.com"https://img.545141.com") -之前一直用的图床程序是:[PHP多图长传程序2.4.3](http://www.mycodes.net/48/4925.htm "PHP多图长传程序2.4.3") -由于版本过老并且使用falsh上传,在当前html5流行大势所趋下,遂利用基础知识新写了一个以html5为默认上传并且支持flash,向下兼容至IE9。 - -
- -#### 功能支持: - -- [x] 支持仅登录后上传 -- [x] 支持设置图片质量 -- [x] 支持上传图片转换为指定格式 -- [x] 支持设置图片指定宽/高 -- [x] 支持限制最低宽度/高度上传 -- [x] 支持静态文件CDN/本地切换 -- [x] 支持设置广告 -- [x] 支持开启/关闭api上传 -- [x] 在线管理图片(增、删、改、查) -- [x] 支持网站统计 请将统计代码放入:public/static/hm.js - -#### 一年未更新了,这次带来了全新版本2.0! -- 在继承上个版本(1.6.4)的基础上进行了全新优化 -- 修复上传经常失败的问题 -- 删除一些不常用但会增加功耗的过程 (删除的在下边会有标记) -- 全新的压缩 将文件继续缩小 -- 全新的目录系统,精简代码 -- 设置仅允许在config.php修改,注释更加明了,即使没有代码基础也可以操作 -- 增加新的文件管理系统 - - -#### 注意: - -1. 安装之前先使用浏览器访问check.php检查扩展是否都安装! -2. 使用前请注意先修改config.php中的domain域名。 -3. 请将所有文件必须赋予0777权限,执行用户设置www权限 -4. 安装正常后请修改登录管理密码! -5. 如果无法登陆管理界面或上传图片,请先打开check.php检查扩展或者使用phpinfo检查。 -6. 可以使用浏览器的 F12调试模式->console查看错误 -7. 如果对php不太熟悉的话,不要将图床程序放置于二级目录 -8. js不要设置分片上传大小,此会导致部分图片上传失败。 -9. 默认我会给你设置成最优方案,api上传默认关闭 -10. 下载源码后可以删除一些文件:README.md,check.php,LICENSE -11. 欢迎加群:[623688684](https://shang.qq.com/wpa/qunwpa?idkey=3feb4e8be8f1839f71e53bf2e876de36afc6889b2630c33c877d8df5a5583a6f) - -#### api上传示例: -参数: - -| 参数名称 | 类型 | 是否必须 | 说明 | -| :------------: | :------------: | :------------: | :------------: | -| file | file | 是 | 表单名称 | - -html form上传示例: -```html -
- - - -
-``` -api上传成功后返回json: -```json -{"result":"success","url":"https:\/\/img.545141.com\/public\/data\/2019\/05\/5ce64172d24fa.png"} -``` -如果关闭api上传,则什么都不显示。 - -#### 更新日志 - -* 2019-6-26 v2.0.2.0 -- 精简压缩代码,使得不再压缩后反而变大 -- 删除异域上传功能,不再支持异域上传 -- 修复开启登录后无法粘贴密码 -- 后台控制上传数量,上传格式 -- 其他一些优化 - -* 2019-6-14 v2.0.1.9 - -- 增加复制链接按钮 -- 增加暂停上传按钮 -- 增加QQ截图,剪切板上传 -- 增加文字/图片水印透明度 -- 恢复开启/关闭api上传 -- 恢复支持水印文字颜色 -- 恢复支持远程上传图片 -- 修复安装时候的权限 -- 修复管理无法多选的问题 -- 修复上传透明png背景变为纯黑的问题 -- 修复成功上传图片但前端无法获取链接 -- 修复在centos64 lnmp1.6 php7.1环境下的图片信息读取问题 -- 修改图片压缩方式,速度更快,相比之前提高5倍以上 -- 更改管理路径 -- 更改上传路径,文件名更短 -- 更改上传显示方式为缩略图 -- 关闭添加图片后自动上传 -- 纪念一下2019年,将版本号改为2.0.1.9 - -* 2019-5-23 v2.0 -- 在继承上个版本(1.6.4)的基础上进行了全新优化 -- 修复上传经常失败的问题 -- 删除一些不常用但会增加功耗的过程 -- 全新的压缩 将文件继续缩小 -- 全新的目录系统,精简代码 -- 设置仅允许在config.php修改,注释更加明了,即使没有代码基础也可以操作 -- 增加新的文件管理系统,感谢 tinyfilemanager -- ~~支持文字/图片水印 可自定义文字颜色~~ -- ~~支持文字水印背景颜色~~ -- ~~支持文字水印透明度~~ -- ~~支持删除远程上传文件~~ -> 不再支持删除远程文件 -- ~~(支持开启/关闭api自定义文字水印)~~ -- ~~支持删除自定义删除图片(仅管理员)~~ - -
- -* 2018-8-17 v1.6.4 -- 支持删除远程上传文件 -- 更改字体 -- 添加api/远程上传 标识 -* 2018-8-16 v1.6.3 -- 支持开启/关闭api上传(支持开启/关闭api自定义文字水印) -- 修复权限错误 -- 修复二级目录引入错误 - -* 2018-8-8 v1.5.3 -- 添加上传图片至远程主机 -- 修复逻辑 - -* 2018-8-6 v1.4.3 -- 添加网站统计 -- 添加删除上传文件 -- 调整config.php - -* 2018-8-5 v1.4.2 -- 添加仅登录后上传 -- 修复一处逻辑错误 -- 修复一个漏洞 - -* 2018-8-4 v1.3.2 -- 添加广告设置 -- 完善引入机制 - -* 2018-8-3 v1.2.2 -- [重要]修复水印图片不能添加 -- 添加随机浏览上传图片 可以设定浏览数量和关闭浏览 -- 优化代码,删除无用文件 -- 完善一键CDN静态文件 - -* 2018-08-02 v1.1.2 -- [重要] 修复gif上传添加水印成静态的问题 -- 修复文字水印背景色不显示问题 -- 修复在linux下的权限错误 -- 一些优化更改 - -* 2018-08-01 v1.0.1 -- 更改相关文件目录 -- 优化代码 - -* 2018-07-30 v1.0.0 -- 最初模型 - -#### 兼容性 -文件上传视图不支持IE9以下的浏览器,api不限制。建议php5.6及以上版本,需要服务器支持Fileinfo, iconv ,zip和mbstring扩展,如果缺失会导致无法访问管理面板以及上传图片。 - -文件上传视图提供文件列表管理和文件批量上传功能,允许拖拽(需要 HTML5 支持)来添加上传文件,支持上传大图片,优先使用 HTML5,旧的浏览器自动使用Flash和Silverlight的方式兼容。 -
- - - 感谢: [verot](https://www.verot.net "verot" )提供非常好用的class.upload.php上传类 - - 感谢: [ZUI](http://zui.sexy/ "ZUI" ) 提供css框架 - - 感谢:[tinyfilemanager](https://github.com/prasathmani/tinyfilemanager "tinyfilemanager" ) 提供的文件管理 +![简单图床示例](https://i1.100024.xyz/public/data/2019/05/5ce6915f50a1a.png + "简单图床示例") +![简单图床示例](https://i1.100024.xyz/public/data/2019/05/5cecf12575f6e.png + "简单图床示例") + +## EasyImage 简单图床 +> 支持多文件上传,api上传,简单无数据库,返回图片url,markdown,bbscode,html的一款图床程序 +演示地址: [https://img.545141.com](https://img.545141.com"https://img.545141.com") +之前一直用的图床程序是:[PHP多图长传程序2.4.3](http://www.mycodes.net/48/4925.htm "PHP多图长传程序2.4.3") +由于版本过老并且使用falsh上传,在当前html5流行大势所趋下,遂利用基础知识新写了一个以html5为默认上传并且支持flash,向下兼容至IE9。 + +
+ +#### 功能支持: + +- [x] 支持仅登录后上传 +- [x] 支持设置图片质量 +- [x] 支持上传图片转换为指定格式 +- [x] 支持文字/图片水印 颜色透明度 +- [x] 支持设置图片指定宽/高 +- [x] 支持限制最低宽度/高度上传 +- [x] 支持静态文件CDN/本地切换 +- [x] 支持设置广告 +- [x] 支持开启/关闭api上传 +- [x] 在线管理图片(增、删、改、查) +- [x] 支持网站统计 请将统计代码放入:public/static/hm.js + +#### 一年未更新了,这次带来了全新版本2.0! +- 在继承上个版本(1.6.4)的基础上进行了全新优化 +- 修复上传经常失败的问题 +- 删除一些不常用但会增加功耗的过程 (删除的在下边会有标记) +- 全新的压缩 将文件继续缩小 +- 全新的目录系统,精简代码 +- 设置仅允许在config.php修改,注释更加明了,即使没有代码基础也可以操作 +- 增加新的文件管理系统 + + +#### 注意: + +1. 安装之前先使用浏览器访问check.php检查扩展是否都安装! +2. 使用前请注意先修改config.php中的domain域名。 +3. 请将所有文件必须赋予0777权限,执行用户设置www权限 +4. 安装正常后请修改登录管理密码! +5. 如果无法登陆管理界面或上传图片,请先打开check.php检查扩展或者使用phpinfo检查。 +6. 可以使用浏览器的 F12调试模式->console查看错误 +7. 如果对php不太熟悉的话,不要将图床程序放置于二级目录 +8. js不要设置分片上传大小,此会导致部分图片上传失败。 +9. 默认我会给你设置成最优方案,api上传默认关闭 +10. 下载源码后可以删除一些文件:README.md,check.php,LICENSE +11. 欢迎加群:[623688684](https://shang.qq.com/wpa/qunwpa?idkey=3feb4e8be8f1839f71e53bf2e876de36afc6889b2630c33c877d8df5a5583a6f) + +#### api上传示例: +参数: + +| 参数名称 | 类型 | 是否必须 | 说明 | +| :------------: | :------------: | :------------: | :------------: | +| file | file | 是 | 表单名称 | + +html form上传示例: +```html +
+ + + +
+``` +api上传成功后返回json: +```json +{"result":"success","url":"https:\/\/img.545141.com\/public\/data\/2019\/05\/5ce64172d24fa.png"} +``` +如果关闭api上传,则什么都不显示。 + +#### 更新日志 + +* 2019-6-26 v2.0.2.0 +- 精简压缩代码,使得不再压缩后反而变大 +- 删除异域上传功能,不再支持异域上传 +- 修复开启登录后无法粘贴密码 +- 后台控制上传数量,上传格式 +- 其他一些优化 + +* 2019-6-14 v2.0.1.9 + +- 增加复制链接按钮 +- 增加暂停上传按钮 +- 增加QQ截图,剪切板上传 +- 增加文字/图片水印透明度 +- 恢复开启/关闭api上传 +- 恢复支持水印文字颜色 +- 恢复支持远程上传图片 +- 修复安装时候的权限 +- 修复管理无法多选的问题 +- 修复上传透明png背景变为纯黑的问题 +- 修复成功上传图片但前端无法获取链接 +- 修复在centos64 lnmp1.6 php7.1环境下的图片信息读取问题 +- 修改图片压缩方式,速度更快,相比之前提高5倍以上 +- 更改管理路径 +- 更改上传路径,文件名更短 +- 更改上传显示方式为缩略图 +- 关闭添加图片后自动上传 +- 纪念一下2019年,将版本号改为2.0.1.9 + +* 2019-5-23 v2.0 +- 在继承上个版本(1.6.4)的基础上进行了全新优化 +- 修复上传经常失败的问题 +- 删除一些不常用但会增加功耗的过程 +- 全新的压缩 将文件继续缩小 +- 全新的目录系统,精简代码 +- 设置仅允许在config.php修改,注释更加明了,即使没有代码基础也可以操作 +- 增加新的文件管理系统,感谢 tinyfilemanager +- ~~支持文字/图片水印 可自定义文字颜色~~ +- ~~支持文字水印背景颜色~~ +- ~~支持文字水印透明度~~ +- ~~支持删除远程上传文件~~ -> 不再支持删除远程文件 +- ~~(支持开启/关闭api自定义文字水印)~~ +- ~~支持删除自定义删除图片(仅管理员)~~ + +
+ +* 2018-8-17 v1.6.4 +- 支持删除远程上传文件 +- 更改字体 +- 添加api/远程上传 标识 +* 2018-8-16 v1.6.3 +- 支持开启/关闭api上传(支持开启/关闭api自定义文字水印) +- 修复权限错误 +- 修复二级目录引入错误 + +* 2018-8-8 v1.5.3 +- 添加上传图片至远程主机 +- 修复逻辑 + +* 2018-8-6 v1.4.3 +- 添加网站统计 +- 添加删除上传文件 +- 调整config.php + +* 2018-8-5 v1.4.2 +- 添加仅登录后上传 +- 修复一处逻辑错误 +- 修复一个漏洞 + +* 2018-8-4 v1.3.2 +- 添加广告设置 +- 完善引入机制 + +* 2018-8-3 v1.2.2 +- [重要]修复水印图片不能添加 +- 添加随机浏览上传图片 可以设定浏览数量和关闭浏览 +- 优化代码,删除无用文件 +- 完善一键CDN静态文件 + +* 2018-08-02 v1.1.2 +- [重要] 修复gif上传添加水印成静态的问题 +- 修复文字水印背景色不显示问题 +- 修复在linux下的权限错误 +- 一些优化更改 + +* 2018-08-01 v1.0.1 +- 更改相关文件目录 +- 优化代码 + +* 2018-07-30 v1.0.0 +- 最初模型 + +#### 兼容性 +文件上传视图不支持IE9以下的浏览器,api不限制。建议php5.6及以上版本,需要服务器支持Fileinfo, iconv ,zip和mbstring扩展,如果缺失会导致无法访问管理面板以及上传图片。 + +文件上传视图提供文件列表管理和文件批量上传功能,允许拖拽(需要 HTML5 支持)来添加上传文件,支持上传大图片,优先使用 HTML5,旧的浏览器自动使用Flash和Silverlight的方式兼容。 +
+ + - 感谢: [verot](https://www.verot.net "verot" )提供非常好用的class.upload.php上传类 + - 感谢: [ZUI](http://zui.sexy/ "ZUI" ) 提供css框架 + - 感谢:[tinyfilemanager](https://github.com/prasathmani/tinyfilemanager "tinyfilemanager" ) 提供的文件管理 - 本源码遵循 GNU Public License \ No newline at end of file diff --git a/config.php b/config.php index 647b424..5f3be1d 100644 --- a/config.php +++ b/config.php @@ -1,94 +1,94 @@ - '简单图床 - EasyImage', - // 网站关键字 - 'keywords' => '简单图床,easyimage,无数据库图床,PHP多图长传程序,自适应页面,HTML5,markdown,bbscode,一键复制', - // 网站描述 - 'description' => '简单图床EasyImage是一款支持多文件上传的无数据库图床,可以完美替代PHP多图上传程序,最新html5自适应页面兼容手机电脑,上传后返回图片直链,markdown图片,论坛贴图bbscode链接,简单方便支持一键复制,支持多域名,api上传。', - // 网站公告 - 'tips' => ' 单个文件限制5M,每次最多上传30张图片,本网站仅做演示用,不对图片负任何责任。', - // 图片直链域名 末尾不加"/" 如果你想上传域名是a.com但是我想上传之后返回域名是b.com 那就在这里填写b.com - 'domain' => 'https://img.545141.com', - // 存储路径 前后要加"/" 如更改此目录,需要同步修改tinyfilemanager.php中的$directories_users路径 - 'path' => '/i/', - // 最大上传限制 默认为 5242880Bytes = 5MB 请使用工具转换MB http://www.bejson.com/convert/filesize/ - 'maxSize' => 5242880, - // 每次最多上传图片数 - 'maxUploadFiles'=>30, - // 是否开启登录上传 开启:true 关闭false - 'mustLogin' => false, - // 是否开启管理 - 'tinyfilemanager' => true, - // 登录上传密码和管理密码 管理的管理员账号:admin 密码为下面密码 - 'password' => 'admin', - // 是否开启API上传 - 'apiStatus' => false, - // 是否开启水印:0关闭,1文字水印,2图片水印 动态gif不能添加水印 - 'watermark' => 0, - // 水印文字内容 - 'waterText' => '简单图床 img.545141.com', - /** - * 水印位置 - * 0:随机位置,在1~8之间随机选取一个位置 - * 1:顶部居左 2:顶部居中 3:顶部居右 4:左边居中 - * 5:图片中心 6:右边居中 7:底部居左 8:底部居中 9:底部居右 - */ - 'waterPosition' => 8, - // 水印文字颜色 rgba 末尾为透明度 范围:0-127 0为不透明 - 'textColor' => '47,79,79,0', - // 水印文字大小 - 'textSize' => 16, - // 字体路径 如果想改变字体 请选择支持中文的gb2312字体 否则中文水印会乱码 纯英文水印字体随便 - 'textFont' => APP_ROOT . '/public/static/hkxzy.ttf', - // 图片水印路径 支持GIF,JPG,BMP,PNG和PNG alpha - 'waterImg' => 'public/static/watermark.png', - // 允许上传的图片扩展名 - 'extensions'=>array('bmp','jpg','png','tif','gif','pcx','tga','svg','webp','jpeg','tga','svg','ico'), - // 转换图片为指定格式 可选:''|'png'|'jpeg'|'gif'|'bmp';默认值:'' - 'imgConvert' => '', - //最大宽度 - 'maxWidth' => 10240, - // 最大高度 - 'maxHeight' => 10240, - // 允许上传的最小宽度 - 'minWidth' => 5, - // 允许上传的最小高度 - 'minHeight' => 5, - // 等比例缩小图片 宽度和高度请设置 image_x image_y 开启true,关闭false 关闭下mage_x和image_y设置不生效 - 'imgRatio' => false, - // 缩减的最大高度 - 'image_x' => 1024, - // 缩减的最大宽度 - 'image_y' => 1024, - // 开启静态文件js css CDN 开启true 关闭false - 'static_cdn' => false, - // 开启顶部广告 如果想添加或修改广告修改 public/static/ad_top.html - 'ad_top' => false, - // 开启底部广告 如果想添加或修改广告修改 public/static/ad_bot.html - 'ad_bot' => false, - 'version' => '2.0.2.0', -); + '简单图床 - EasyImage', + // 网站关键字 + 'keywords' => '简单图床,easyimage,无数据库图床,PHP多图长传程序,自适应页面,HTML5,markdown,bbscode,一键复制', + // 网站描述 + 'description' => '简单图床EasyImage是一款支持多文件上传的无数据库图床,可以完美替代PHP多图上传程序,最新html5自适应页面兼容手机电脑,上传后返回图片直链,markdown图片,论坛贴图bbscode链接,简单方便支持一键复制,支持多域名,api上传。', + // 网站公告 + 'tips' => ' 单个文件限制5M,每次最多上传30张图片,本网站仅做演示用,不对图片负任何责任。', + // 图片直链域名 末尾不加"/" 如果你想上传域名是a.com但是我想上传之后返回域名是b.com 那就在这里填写b.com + 'domain' => 'https://img.545141.com', + // 存储路径 前后要加"/" 如更改此目录,需要同步修改tinyfilemanager.php中的$directories_users路径 + 'path' => '/i/', + // 最大上传限制 默认为 5242880Bytes = 5MB 请使用工具转换MB http://www.bejson.com/convert/filesize/ + 'maxSize' => 5242880, + // 每次最多上传图片数 + 'maxUploadFiles'=>30, + // 是否开启登录上传 开启:true 关闭false + 'mustLogin' => false, + // 是否开启管理 + 'tinyfilemanager' => true, + // 登录上传密码和管理密码 管理的管理员账号:admin 密码为下面密码 + 'password' => 'admin', + // 是否开启API上传 + 'apiStatus' => false, + // 是否开启水印:0关闭,1文字水印,2图片水印 动态gif不能添加水印 + 'watermark' => 0, + // 水印文字内容 + 'waterText' => '简单图床 img.545141.com', + /** + * 水印位置 + * 0:随机位置,在1~8之间随机选取一个位置 + * 1:顶部居左 2:顶部居中 3:顶部居右 4:左边居中 + * 5:图片中心 6:右边居中 7:底部居左 8:底部居中 9:底部居右 + */ + 'waterPosition' => 8, + // 水印文字颜色 rgba 末尾为透明度 范围:0-127 0为不透明 + 'textColor' => '47,79,79,0', + // 水印文字大小 + 'textSize' => 16, + // 字体路径 如果想改变字体 请选择支持中文的gb2312字体 否则中文水印会乱码 纯英文水印字体随便 + 'textFont' => APP_ROOT . '/public/static/hkxzy.ttf', + // 图片水印路径 支持GIF,JPG,BMP,PNG和PNG alpha + 'waterImg' => 'public/static/watermark.png', + // 允许上传的图片扩展名 + 'extensions'=>array('bmp','jpg','png','tif','gif','pcx','tga','svg','webp','jpeg','tga','svg','ico'), + // 转换图片为指定格式 可选:''|'png'|'jpeg'|'gif'|'bmp';默认值:'' + 'imgConvert' => '', + //最大宽度 + 'maxWidth' => 10240, + // 最大高度 + 'maxHeight' => 10240, + // 允许上传的最小宽度 + 'minWidth' => 5, + // 允许上传的最小高度 + 'minHeight' => 5, + // 等比例缩小图片 宽度和高度请设置 image_x image_y 开启true,关闭false 关闭下mage_x和image_y设置不生效 + 'imgRatio' => false, + // 缩减的最大高度 + 'image_x' => 1024, + // 缩减的最大宽度 + 'image_y' => 1024, + // 开启静态文件js css CDN 开启true 关闭false + 'static_cdn' => false, + // 开启顶部广告 如果想添加或修改广告修改 public/static/ad_top.html + 'ad_top' => false, + // 开启底部广告 如果想添加或修改广告修改 public/static/ad_bot.html + 'ad_bot' => false, + 'version' => '2.0.2.0', +); diff --git a/favicon.ico b/favicon.ico new file mode 100644 index 0000000..f197d1f Binary files /dev/null and b/favicon.ico differ diff --git a/file.php b/file.php index 330b426..1c06e7b 100644 --- a/file.php +++ b/file.php @@ -1,93 +1,93 @@ -uploaded) { - // 允许上传的mime类型 - $handle->allowed = array('image/*'); - // 文件命名 - $handle->file_new_name_body = imgName(); - // 最大上传限制 - $handle->file_max_sizes = $config['maxSize']; - // 最大宽度 - $handle->image_max_width = $config['maxWidth']; - // 最大高度 - $handle->image_max_height = $config['maxHeight']; - // 最小宽度 - $handle->image_min_width = $config['minWidth']; - // 最小高度 - $handle->image_min_height = $config['minHeight']; - // 转换图片为指定格式 - $handle->image_convert = $config['imgConvert']; - - //等比例缩减图片 - if ($config['imgRatio']) { - $handle->image_x = $config['image_x']; - } - // 存储图片路径:images/201807/ - $handle->process(APP_ROOT . config_path()); - - // 设置水印 - if ($config['watermark'] > 0) { - switch ($config['watermark']) { - case 1: // 文字水印 过滤gif - if (isAnimatedGif($handle->file_src_pathname) === 0) { - $arr = [ - # 水印图片路径(如果不存在将会被当成是字符串水印) - 'res' => $config['waterText'], - # 水印显示位置 - 'pos' => $config['waterPosition'], - # 不指定name(会覆盖原图,也就是保存成thumb.jpeg) - 'name' => $handle->file_dst_pathname, - 'font' => $config['textFont'], - 'fontSize' => $config['textSize'], - 'color' => $config['textColor'], - ]; - Imgs::setWater($handle->file_dst_pathname, $arr); - } - break; - case 2: // 图片水印 - if (isAnimatedGif($handle->file_src_pathname) === 0) { - $arr = [ - # 水印图片路径(如果不存在将会被当成是字符串水印) - 'res' => $config['waterImg'], - # 水印显示位置 - 'pos' => $config['waterPosition'], - # 不指定name(会覆盖原图,也就是保存成thumb.jpeg) - 'name' => $handle->file_dst_pathname, - ]; - Imgs::setWater($handle->file_dst_pathname, $arr); - } - break; - default: - echo $handle->error; - break; - } - } - - // 图片完整相对路径:images/201807/0ed7ccfd4dab9cbc.jpg - if ($handle->processed) { - header('Content-type:text/json'); - // 上传成功后返回json数据 - $reJson = array( - "result" => 'success', - "url" => $config['domain'] . config_path() . $handle->file_dst_name, - ); - echo json_encode($reJson); - $handle->clean(); - } else { - // 上传错误 返回错误信息 - $reJson = array( - "result" => 'failed', - "message" => $handle->error, - ); - echo json_encode($reJson,JSON_UNESCAPED_UNICODE); - } - unset($handle); +uploaded) { + // 允许上传的mime类型 + $handle->allowed = array('image/*'); + // 文件命名 + $handle->file_new_name_body = imgName(); + // 最大上传限制 + $handle->file_max_sizes = $config['maxSize']; + // 最大宽度 + $handle->image_max_width = $config['maxWidth']; + // 最大高度 + $handle->image_max_height = $config['maxHeight']; + // 最小宽度 + $handle->image_min_width = $config['minWidth']; + // 最小高度 + $handle->image_min_height = $config['minHeight']; + // 转换图片为指定格式 + $handle->image_convert = $config['imgConvert']; + + //等比例缩减图片 + if ($config['imgRatio']) { + $handle->image_x = $config['image_x']; + } + // 存储图片路径:images/201807/ + $handle->process(APP_ROOT . config_path()); + + // 设置水印 + if ($config['watermark'] > 0) { + switch ($config['watermark']) { + case 1: // 文字水印 过滤gif + if (isAnimatedGif($handle->file_src_pathname) === 0) { + $arr = [ + # 水印图片路径(如果不存在将会被当成是字符串水印) + 'res' => $config['waterText'], + # 水印显示位置 + 'pos' => $config['waterPosition'], + # 不指定name(会覆盖原图,也就是保存成thumb.jpeg) + 'name' => $handle->file_dst_pathname, + 'font' => $config['textFont'], + 'fontSize' => $config['textSize'], + 'color' => $config['textColor'], + ]; + Imgs::setWater($handle->file_dst_pathname, $arr); + } + break; + case 2: // 图片水印 + if (isAnimatedGif($handle->file_src_pathname) === 0) { + $arr = [ + # 水印图片路径(如果不存在将会被当成是字符串水印) + 'res' => $config['waterImg'], + # 水印显示位置 + 'pos' => $config['waterPosition'], + # 不指定name(会覆盖原图,也就是保存成thumb.jpeg) + 'name' => $handle->file_dst_pathname, + ]; + Imgs::setWater($handle->file_dst_pathname, $arr); + } + break; + default: + echo $handle->error; + break; + } + } + + // 图片完整相对路径:images/201807/0ed7ccfd4dab9cbc.jpg + if ($handle->processed) { + header('Content-type:text/json'); + // 上传成功后返回json数据 + $reJson = array( + "result" => 'success', + "url" => $config['domain'] . config_path() . $handle->file_dst_name, + ); + echo json_encode($reJson); + $handle->clean(); + } else { + // 上传错误 返回错误信息 + $reJson = array( + "result" => 'failed', + "message" => $handle->error, + ); + echo json_encode($reJson,JSON_UNESCAPED_UNICODE); + } + unset($handle); } \ No newline at end of file diff --git a/index.php b/index.php index 68c846e..01ef98f 100644 --- a/index.php +++ b/index.php @@ -63,6 +63,10 @@ if (@$_GET['e']==1){ + + diff --git a/public/static/ad.jpg b/public/static/ad.jpg new file mode 100644 index 0000000..c88991e Binary files /dev/null and b/public/static/ad.jpg differ diff --git a/public/static/ad.png b/public/static/ad.png index 494276d..5a388e4 100644 Binary files a/public/static/ad.png and b/public/static/ad.png differ diff --git a/public/static/ad_bot.html b/public/static/ad_bot.html index d3f2f82..af7f91e 100644 --- a/public/static/ad_bot.html +++ b/public/static/ad_bot.html @@ -1,4 +1,4 @@ \ No newline at end of file diff --git a/public/static/ad_top.html b/public/static/ad_top.html index 2497ce8..b0031ef 100644 --- a/public/static/ad_top.html +++ b/public/static/ad_top.html @@ -1,4 +1,4 @@ - - + + + +
+
+
+
+
+
+
+ + + ' . PHP_EOL; + } + ?> +

: , ', $copy_files) ?>

+

:
+ + / +

+

+

+   + +

+ +
+
+
+ +
+

Copying

+

+ Source path:
+ Destination folder: +

+

+ Copy   + Move   + Cancel +

+

Select folder

+ +
+ + +
+
+
+ + +
+
+
+ +
+ +
+ +
+
+ +
+ +
+
+ + +
+
+
+ +
+ +
+
+ + +
+
+
+ +
+
+ +
+
+ +
+
+
+
+ + +
+
+
+ + +
+
+ + +
+
+
+ +
+
+ +

""

+

+ Full path:
+ File + size: = 1000): ?> () +
+ MIME-type:
+ + Files in archive:
+ Total size:
+ Size in archive:
+ Compression: %
+ '; + } + // Text info + if ($is_text) { + $is_utf8 = fm_is_utf8($content); + if (function_exists('iconv')) { + if (!$is_utf8) { + $content = iconv(FM_ICONV_INPUT_ENC, 'UTF-8//IGNORE', $content); + } + } + echo 'Charset: ' . ($is_utf8 ? 'utf-8' : '8 bit') . '
'; + } + ?> +

+

+   + +   + +   + +   + + +   + +   + + +

+ '; + } else if($online_viewer == 'microsoft') { + echo ''; + } + } elseif ($is_zip) { + // ZIP content + if ($filenames !== false) { + echo ''; + foreach ($filenames as $fn) { + if ($fn['folder']) { + echo '' . fm_enc($fn['name']) . '
'; + } else { + echo $fn['name'] . ' (' . fm_get_filesize($fn['filesize']) . ')
'; + } + } + echo '
'; + } else { + echo '

Error while fetching archive info

'; + } + } elseif ($is_image) { + // Image content + if (in_array($ext, array('gif', 'jpg', 'jpeg', 'png', 'bmp', 'ico', 'svg'))) { + echo '

'; + } + } elseif ($is_audio) { + // Audio content + echo '

'; + } elseif ($is_video) { + // Video content + echo '
'; + } elseif ($is_text) { + if (FM_USE_HIGHLIGHTJS) { + // highlight + $hljs_classes = array( + 'shtml' => 'xml', + 'htaccess' => 'apache', + 'phtml' => 'php', + 'lock' => 'json', + 'svg' => 'xml', + ); + $hljs_class = isset($hljs_classes[$ext]) ? 'lang-' . $hljs_classes[$ext] : 'lang-' . $ext; + if (empty($ext) || in_array(strtolower($file), fm_get_text_names()) || preg_match('#\.min\.(css|js)$#i', $file)) { + $hljs_class = 'nohighlight'; + } + $content = '
' . fm_enc($content) . '
'; + } elseif (in_array($ext, array('php', 'php4', 'php5', 'phtml', 'phps'))) { + // php highlight + $content = highlight_string($content, true); + } else { + $content = '
' . fm_enc($content) . '
'; + } + echo $content; + } + ?> +
+
+ +
+
+
+ +
+
+ + + + + + + + + + + +
+
+ ' . htmlspecialchars($content) . ''; + } elseif ($is_text) { + echo '
' . htmlspecialchars($content) . '
'; + } else { + fm_set_msg('FILE EXTENSION HAS NOT SUPPORTED', 'error'); + } + ?> +
+ +
+
+
+ +
+
+

+ Full path:
+

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

+   + +

+
+
+
+
+ +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + '?'); + $group = array('name' => '?'); + } + ?> + + + + + + + + + + + + + '?'); + $group = array('name' => '?'); + } + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
..
+
+ +
+
+
+ ' . readlink($path . '/' . $f) . '' : '') ?>
+
+ + + + + + +
+
+ +
+
+
+
+ + + + + + + + + +
+ Full size: '.fm_get_filesize($all_files_size).'' ?> + '.$num_files.'' ?> + '.$num_folders.'' ?> + '.fm_get_filesize(@memory_get_usage(true)).'' ?> + '.fm_get_filesize(@disk_free_space($path)) .' free of '.fm_get_filesize(@disk_total_space($path)).''; ?> +
+
+ +
+ +
+ +
+ + + + +
+ +
+ += $time1 && $upd) { + return false; + } + } + $ok = copy($f1, $f2); + if ($ok) { + touch($f2, $time1); + } + return $ok; +} + +/** + * Get mime type + * @param string $file_path + * @return mixed|string + */ +function fm_get_mime_type($file_path) +{ + if (function_exists('finfo_open')) { + $finfo = finfo_open(FILEINFO_MIME_TYPE); + $mime = finfo_file($finfo, $file_path); + finfo_close($finfo); + return $mime; + } elseif (function_exists('mime_content_type')) { + return mime_content_type($file_path); + } elseif (!stristr(ini_get('disable_functions'), 'shell_exec')) { + $file = escapeshellarg($file_path); + $mime = shell_exec('file -bi ' . $file); + return $mime; + } else { + return '--'; + } +} + +/** + * HTTP Redirect + * @param string $url + * @param int $code + */ +function fm_redirect($url, $code = 302) +{ + header('Location: ' . $url, true, $code); + exit; +} + +/** + * Path traversal prevention and clean the url + * It replaces (consecutive) occurrences of / and \\ with whatever is in DIRECTORY_SEPARATOR, and processes /. and /.. fine. + * @param $path + * @return string + */ +function get_absolute_path($path) { + $path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path); + $parts = array_filter(explode(DIRECTORY_SEPARATOR, $path), 'strlen'); + $absolutes = array(); + foreach ($parts as $part) { + if ('.' == $part) continue; + if ('..' == $part) { + array_pop($absolutes); + } else { + $absolutes[] = $part; + } + } + return implode(DIRECTORY_SEPARATOR, $absolutes); +} + +/** + * Clean path + * @param string $path + * @return string + */ +function fm_clean_path($path) +{ + $path = trim($path); + $path = trim($path, '\\/'); + $path = str_replace(array('../', '..\\'), '', $path); + $path = get_absolute_path($path); + if ($path == '..') { + $path = ''; + } + return str_replace('\\', '/', $path); +} + +/** + * Get parent path + * @param string $path + * @return bool|string + */ +function fm_get_parent_path($path) +{ + $path = fm_clean_path($path); + if ($path != '') { + $array = explode('/', $path); + if (count($array) > 1) { + $array = array_slice($array, 0, -1); + return implode('/', $array); + } + return ''; + } + return false; +} + +/* + * get language translations from json file + * @param int $tr + * @return array + */ +function fm_get_translations($tr) { + try { + $content = @file_get_contents('public/static/translation.json'); + if($content !== FALSE) { + $lng = json_decode($content, TRUE); + global $lang_list; + foreach ($lng["language"] as $key => $value) + { + $code = $value["code"]; + $lang_list[$code] = $value["name"]; + if ($tr) + $tr[$code] = $value["translation"]; + } + return $tr; + } + + } + catch (Exception $e) { + echo $e; + } +} + +/** + * @param $file + * Recover all file sizes larger than > 2GB. + * Works on php 32bits and 64bits and supports linux + * @return int|string + */ +function fm_get_size($file) +{ + static $iswin; + if (!isset($iswin)) { + $iswin = (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN'); + } + + static $exec_works; + if (!isset($exec_works)) { + $exec_works = (function_exists('exec') && !ini_get('safe_mode') && @exec('echo EXEC') == 'EXEC'); + } + + // try a shell command + if ($exec_works) { + $cmd = ($iswin) ? "for %F in (\"$file\") do @echo %~zF" : "stat -c%s \"$file\""; + @exec($cmd, $output); + if (is_array($output) && ctype_digit($size = trim(implode("\n", $output)))) { + return $size; + } + } + + // try the Windows COM interface + if ($iswin && class_exists("COM")) { + try { + $fsobj = new COM('Scripting.FileSystemObject'); + $f = $fsobj->GetFile( realpath($file) ); + $size = $f->Size; + } catch (Exception $e) { + $size = null; + } + if (ctype_digit($size)) { + return $size; + } + } + + // if all else fails + return filesize($file); +} + +/** + * Get nice filesize + * @param int $size + * @return string + */ +function fm_get_filesize($size) +{ + if ($size < 1000) { + return sprintf('%s B', $size); + } elseif (($size / 1024) < 1000) { + return sprintf('%s KB', round(($size / 1024), 2)); + } elseif (($size / 1024 / 1024) < 1000) { + return sprintf('%s MB', round(($size / 1024 / 1024), 2)); + } elseif (($size / 1024 / 1024 / 1024) < 1000) { + return sprintf('%s GB', round(($size / 1024 / 1024 / 1024), 2)); + } else { + return sprintf('%s TB', round(($size / 1024 / 1024 / 1024 / 1024), 2)); + } +} + +/** + * Get info about zip archive + * @param string $path + * @return array|bool + */ +function fm_get_zif_info($path, $ext) { + if ($ext == 'zip' && function_exists('zip_open')) { + $arch = zip_open($path); + if ($arch) { + $filenames = array(); + while ($zip_entry = zip_read($arch)) { + $zip_name = zip_entry_name($zip_entry); + $zip_folder = substr($zip_name, -1) == '/'; + $filenames[] = array( + 'name' => $zip_name, + 'filesize' => zip_entry_filesize($zip_entry), + 'compressed_size' => zip_entry_compressedsize($zip_entry), + 'folder' => $zip_folder + //'compression_method' => zip_entry_compressionmethod($zip_entry), + ); + } + zip_close($arch); + return $filenames; + } + } elseif($ext == 'tar' && class_exists('PharData')) { + $archive = new PharData($path); + $filenames = array(); + foreach(new RecursiveIteratorIterator($archive) as $file) { + $parent_info = $file->getPathInfo(); + $zip_name = str_replace("phar://".$path, '', $file->getPathName()); + $zip_name = substr($zip_name, ($pos = strpos($zip_name, '/')) !== false ? $pos + 1 : 0); + $zip_folder = $parent_info->getFileName(); + $zip_info = new SplFileInfo($file); + $filenames[] = array( + 'name' => $zip_name, + 'filesize' => $zip_info->getSize(), + 'compressed_size' => $file->getCompressedSize(), + 'folder' => $zip_folder + ); + } + return $filenames; + } + return false; +} + +/** + * Encode html entities + * @param string $text + * @return string + */ +function fm_enc($text) +{ + return htmlspecialchars($text, ENT_QUOTES, 'UTF-8'); +} + +/** + * Save message in session + * @param string $msg + * @param string $status + */ +function fm_set_msg($msg, $status = 'ok') +{ + $_SESSION[FM_SESSION_ID]['message'] = $msg; + $_SESSION[FM_SESSION_ID]['status'] = $status; +} + +/** + * Check if string is in UTF-8 + * @param string $string + * @return int + */ +function fm_is_utf8($string) +{ + return preg_match('//u', $string); +} + +/** + * Convert file name to UTF-8 in Windows + * @param string $filename + * @return string + */ +function fm_convert_win($filename) +{ + if (FM_IS_WIN && function_exists('iconv')) { + $filename = iconv(FM_ICONV_INPUT_ENC, 'UTF-8//IGNORE', $filename); + } + return $filename; +} + +/** + * @param $obj + * @return array + */ +function fm_object_to_array($obj) +{ + if (!is_object($obj) && !is_array($obj)) { + return $obj; + } + if (is_object($obj)) { + $obj = get_object_vars($obj); + } + return array_map('fm_object_to_array', $obj); +} + +/** + * Get CSS classname for file + * @param string $path + * @return string + */ +function fm_get_file_icon_class($path) +{ + // get extension + $ext = strtolower(pathinfo($path, PATHINFO_EXTENSION)); + + switch ($ext) { + case 'ico': + case 'gif': + case 'jpg': + case 'jpeg': + case 'jpc': + case 'jp2': + case 'jpx': + case 'xbm': + case 'wbmp': + case 'png': + case 'bmp': + case 'tif': + case 'tiff': + case 'svg': + $img = 'fa fa-picture-o'; + break; + case 'passwd': + case 'ftpquota': + case 'sql': + case 'js': + case 'json': + case 'sh': + case 'config': + case 'twig': + case 'tpl': + case 'md': + case 'gitignore': + case 'c': + case 'cpp': + case 'cs': + case 'py': + case 'map': + case 'lock': + case 'dtd': + $img = 'fa fa-file-code-o'; + break; + case 'txt': + case 'ini': + case 'conf': + case 'log': + case 'htaccess': + $img = 'fa fa-file-text-o'; + break; + case 'css': + case 'less': + case 'sass': + case 'scss': + $img = 'fa fa-css3'; + break; + case 'zip': + case 'rar': + case 'gz': + case 'tar': + case '7z': + $img = 'fa fa-file-archive-o'; + break; + case 'php': + case 'php4': + case 'php5': + case 'phps': + case 'phtml': + $img = 'fa fa-code'; + break; + case 'htm': + case 'html': + case 'shtml': + case 'xhtml': + $img = 'fa fa-html5'; + break; + case 'xml': + case 'xsl': + $img = 'fa fa-file-excel-o'; + break; + case 'wav': + case 'mp3': + case 'mp2': + case 'm4a': + case 'aac': + case 'ogg': + case 'oga': + case 'wma': + case 'mka': + case 'flac': + case 'ac3': + case 'tds': + $img = 'fa fa-music'; + break; + case 'm3u': + case 'm3u8': + case 'pls': + case 'cue': + $img = 'fa fa-headphones'; + break; + case 'avi': + case 'mpg': + case 'mpeg': + case 'mp4': + case 'm4v': + case 'flv': + case 'f4v': + case 'ogm': + case 'ogv': + case 'mov': + case 'mkv': + case '3gp': + case 'asf': + case 'wmv': + $img = 'fa fa-file-video-o'; + break; + case 'eml': + case 'msg': + $img = 'fa fa-envelope-o'; + break; + case 'xls': + case 'xlsx': + $img = 'fa fa-file-excel-o'; + break; + case 'csv': + $img = 'fa fa-file-text-o'; + break; + case 'bak': + $img = 'fa fa-clipboard'; + break; + case 'doc': + case 'docx': + $img = 'fa fa-file-word-o'; + break; + case 'ppt': + case 'pptx': + $img = 'fa fa-file-powerpoint-o'; + break; + case 'ttf': + case 'ttc': + case 'otf': + case 'woff': + case 'woff2': + case 'eot': + case 'fon': + $img = 'fa fa-font'; + break; + case 'pdf': + $img = 'fa fa-file-pdf-o'; + break; + case 'psd': + case 'ai': + case 'eps': + case 'fla': + case 'swf': + $img = 'fa fa-file-image-o'; + break; + case 'exe': + case 'msi': + $img = 'fa fa-file-o'; + break; + case 'bat': + $img = 'fa fa-terminal'; + break; + default: + $img = 'fa fa-info-circle'; + } + + return $img; +} + +/** + * Get image files extensions + * @return array + */ +function fm_get_image_exts() +{ + return array('ico', 'gif', 'jpg', 'jpeg', 'jpc', 'jp2', 'jpx', 'xbm', 'wbmp', 'png', 'bmp', 'tif', 'tiff', 'psd', 'svg'); +} + +/** + * Get video files extensions + * @return array + */ +function fm_get_video_exts() +{ + return array('webm', 'mp4', 'm4v', 'ogm', 'ogv', 'mov', 'mkv'); +} + +/** + * Get audio files extensions + * @return array + */ +function fm_get_audio_exts() +{ + return array('wav', 'mp3', 'ogg', 'm4a'); +} + +/** + * Get text file extensions + * @return array + */ +function fm_get_text_exts() +{ + return array( + 'txt', 'css', 'ini', 'conf', 'log', 'htaccess', 'passwd', 'ftpquota', 'sql', 'js', 'json', 'sh', 'config', + 'php', 'php4', 'php5', 'phps', 'phtml', 'htm', 'html', 'shtml', 'xhtml', 'xml', 'xsl', 'm3u', 'm3u8', 'pls', 'cue', + 'eml', 'msg', 'csv', 'bat', 'twig', 'tpl', 'md', 'gitignore', 'less', 'sass', 'scss', 'c', 'cpp', 'cs', 'py', + 'map', 'lock', 'dtd', 'svg', + ); +} + +/** + * Get mime types of text files + * @return array + */ +function fm_get_text_mimes() +{ + return array( + 'application/xml', + 'application/javascript', + 'application/x-javascript', + 'image/svg+xml', + 'message/rfc822', + ); +} + +/** + * Get file names of text files w/o extensions + * @return array + */ +function fm_get_text_names() +{ + return array( + 'license', + 'readme', + 'authors', + 'contributors', + 'changelog', + ); +} + +/** + * Get online docs viewer supported files extensions + * @return array + */ +function fm_get_onlineViewer_exts() +{ + return array('doc', 'docx', 'xls', 'xlsx', 'pdf', 'ppt', 'pptx', 'ai', 'psd', 'dxf', 'xps', 'rar'); +} + +/** + * Class to work with zip files (using ZipArchive) + */ +class FM_Zipper +{ + private $zip; + + public function __construct() + { + $this->zip = new ZipArchive(); + } + + /** + * Create archive with name $filename and files $files (RELATIVE PATHS!) + * @param string $filename + * @param array|string $files + * @return bool + */ + public function create($filename, $files) + { + $res = $this->zip->open($filename, ZipArchive::CREATE); + if ($res !== true) { + return false; + } + if (is_array($files)) { + foreach ($files as $f) { + if (!$this->addFileOrDir($f)) { + $this->zip->close(); + return false; + } + } + $this->zip->close(); + return true; + } else { + if ($this->addFileOrDir($files)) { + $this->zip->close(); + return true; + } + return false; + } + } + + /** + * Extract archive $filename to folder $path (RELATIVE OR ABSOLUTE PATHS) + * @param string $filename + * @param string $path + * @return bool + */ + public function unzip($filename, $path) + { + $res = $this->zip->open($filename); + if ($res !== true) { + return false; + } + if ($this->zip->extractTo($path)) { + $this->zip->close(); + return true; + } + return false; + } + + /** + * Add file/folder to archive + * @param string $filename + * @return bool + */ + private function addFileOrDir($filename) + { + if (is_file($filename)) { + return $this->zip->addFile($filename); + } elseif (is_dir($filename)) { + return $this->addDir($filename); + } + return false; + } + + /** + * Add folder recursively + * @param string $path + * @return bool + */ + private function addDir($path) + { + if (!$this->zip->addEmptyDir($path)) { + return false; + } + $objects = scandir($path); + if (is_array($objects)) { + foreach ($objects as $file) { + if ($file != '.' && $file != '..') { + if (is_dir($path . '/' . $file)) { + if (!$this->addDir($path . '/' . $file)) { + return false; + } + } elseif (is_file($path . '/' . $file)) { + if (!$this->zip->addFile($path . '/' . $file)) { + return false; + } + } + } + } + return true; + } + return false; + } +} + +/** + * Class to work with Tar files (using PharData) + */ +class FM_Zipper_Tar +{ + private $tar; + + public function __construct() + { + $this->tar = null; + } + + /** + * Create archive with name $filename and files $files (RELATIVE PATHS!) + * @param string $filename + * @param array|string $files + * @return bool + */ + public function create($filename, $files) + { + $this->tar = new PharData($filename); + if (is_array($files)) { + foreach ($files as $f) { + if (!$this->addFileOrDir($f)) { + return false; + } + } + return true; + } else { + if ($this->addFileOrDir($files)) { + return true; + } + return false; + } + } + + /** + * Extract archive $filename to folder $path (RELATIVE OR ABSOLUTE PATHS) + * @param string $filename + * @param string $path + * @return bool + */ + public function unzip($filename, $path) + { + $res = $this->tar->open($filename); + if ($res !== true) { + return false; + } + if ($this->tar->extractTo($path)) { + return true; + } + return false; + } + + /** + * Add file/folder to archive + * @param string $filename + * @return bool + */ + private function addFileOrDir($filename) + { + if (is_file($filename)) { + return $this->tar->addFile($filename); + } elseif (is_dir($filename)) { + return $this->addDir($filename); + } + return false; + } + + /** + * Add folder recursively + * @param string $path + * @return bool + */ + private function addDir($path) + { + $objects = scandir($path); + if (is_array($objects)) { + foreach ($objects as $file) { + if ($file != '.' && $file != '..') { + if (is_dir($path . '/' . $file)) { + if (!$this->addDir($path . '/' . $file)) { + return false; + } + } elseif (is_file($path . '/' . $file)) { + try { + $this->tar->addFile($path . '/' . $file); + } catch (Exception $e) { + return false; + } + } + } + } + return true; + } + return false; + } +} + + + +/** + * Save Configuration + */ + class FM_Config +{ + var $data; + + function __construct() + { + global $root_path, $root_url, $CONFIG; + $fm_url = $root_url.$_SERVER["PHP_SELF"]; + $this->data = array( + 'lang' => 'en', + 'error_reporting' => true, + 'show_hidden' => true + ); + $data = false; + if (strlen($CONFIG)) { + $data = fm_object_to_array(json_decode($CONFIG)); + } else { + $msg = 'Tiny File Manager
Error: Cannot load configuration'; + if (substr($fm_url, -1) == '/') { + $fm_url = rtrim($fm_url, '/'); + $msg .= '
'; + $msg .= '
Seems like you have a trailing slash on the URL.'; + $msg .= '
Try this link: ' . $fm_url . ''; + } + die($msg); + } + if (is_array($data) && count($data)) $this->data = $data; + else $this->save(); + } + + function save() + { + global $root_path; + $fm_file = $root_path.$_SERVER["PHP_SELF"]; + $var_name = '$CONFIG'; + $var_value = var_export(json_encode($this->data), true); + $config_string = " + + ' . $_SESSION[FM_SESSION_ID]['message'] . '

'; + unset($_SESSION[FM_SESSION_ID]['message']); + unset($_SESSION[FM_SESSION_ID]['status']); + } +} + +/** + * Show page header in Login Form + */ +function fm_show_header_login() +{ +$sprites_ver = '20160315'; +header("Content-Type: text/html; charset=utf-8"); +header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); +header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0"); +header("Pragma: no-cache"); + +global $lang, $root_url, $favicon_path; +?> + + + + + + + + + + + <?php echo fm_enc(APP_TITLE) ?> + + + + +
+ + +
+ + + + + + + + + + + + + + + + + + <?php echo fm_enc(APP_TITLE) ?> + + + + + + + + + +
+ + + + + + + + +
+ + + + + + + + + + + + + + + + 'Qk04AgAAAAAAADYAAAAoAAAAEAAAABAAAAABABAAAAAAAAICAAASCwAAEgsAAAAAAAAAAAAAIQQhBCEEIQQhBCEEIQQhBCEEIQ + QhBCEEIQQhBCEEIQQhBCEEIQQhBHNO3n/ef95/vXetNSEEIQQhBCEEIQQhBCEEIQQhBCEEc07ef95/3n/ef95/1lohBCEEIQQhBCEEIQQhBCEEIQ + RzTt5/3n8hBDFG3n/efyEEIQQhBCEEIQQhBCEEIQQhBHNO3n/efyEEMUbef95/IQQhBCEEIQQhBCEEIQQhBCEErTVzTnNOIQQxRt5/3n8hBCEEIQ + QhBCEEIQQhBCEEIQQhBCEEIQQhBDFG3n/efyEEIQQhBCEEIQQhBCEEIQQhBCEEIQQxRt5/3n+cc2stIQQhBCEEIQQhBCEEIQQhBCEEIQQIIZxz3n + /ef5xzay0hBCEEIQQhBCEEIQQhBCEEIQQhBCEEIQQhBDFG3n/efyEEIQQhBCEEIQQhBCEEIQQhBK01c05zTiEEMUbef95/IQQhBCEEIQQhBCEEIQ + QhBCEEc07ef95/IQQxRt5/3n8hBCEEIQQhBCEEIQQhBCEEIQRzTt5/3n8hBDFG3n/efyEEIQQhBCEEIQQhBCEEIQQhBKUUOWfef95/3n/ef95/IQ + QhBCEEIQQhBCEEIQQhBCEEIQQhBJRW3n/ef95/3n8hBCEEIQQhBCEEIQQhBCEEIQQhBCEEIQQhBCEEIQQhBCEEIQQhBCEEIQQAAA==' + ); +} + +?>