diff --git a/README.md b/README.md index 9ecf554..db016b1 100755 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ [![Code size](https://img.shields.io/github/languages/code-size/icret/EasyImages2.0?color=blueviolet)](https://github.com/icret/EasyImages2.0) --> ->[演示](https://png.cm/) | [Chrome/Edge 插件](https://github.com/icret/EasyImage-Browser-Extension) | [使用手册](https://www.kancloud.cn/easyimage/easyimage/) | [Telegram](https://t.me/Easy_Image) +>[演示](https://png.cm/) | [Chrome/Edge 插件](https://github.com/icret/EasyImage-Browser-Extension) | [使用手册](https://www.kancloud.cn/easyimage/easyimage/) | [社区讨论](https://github.com/icret/EasyImages2.0/discussions) | [Telegram](https://t.me/Easy_Image) > >本人善写bug 发现bug可提交 [issues](https://github.com/icret/EasyImages2.0/issues) 追求稳定请下载 [稳定版](https://github.com/icret/EasyImages2.0/releases) @@ -230,7 +230,12 @@ $HTTP["url"] =~ "^/(i|public)/" {
点击查看2.0版更新日志 -* 2023-02-01 v2.7.1 dev +* 2023-02-03 v2.7.2 dev +- 增加 [web-indexr](https://github.com/rehiy/web-indexr) 文件管理 +- - web-indexr处于实验中,作为Tinyfilemanager的替代 +- 优化排版 + +* 2023-02-01 v2.7.1 - 更新版本号 * 2023-02-01 v2.7.0 dev diff --git a/admin/admin.inc.php b/admin/admin.inc.php index 832a3dd..f15338d 100755 --- a/admin/admin.inc.php +++ b/admin/admin.inc.php @@ -3,9 +3,9 @@ * 简单图床设置页面 * 2022-1-24 05:57:35 */ -require_once __DIR__ . '/../application/header.php'; +require_once __DIR__ . '/../application/header.php'; require_once APP_ROOT . '/config/api_key.php'; -require_once APP_ROOT . '/config/config.guest.php'; +require_once APP_ROOT . '/config/config.guest.php'; // 检查登录 if (!is_who_login('admin')) { @@ -31,14 +31,14 @@ if (isset($_POST['update'])) { type: "primary", // 定义颜色主题 icon: "ok-sign" // 定义消息图标 }).show(); - + '; header("refresh:1;"); } /** * 添加token - * $_POST['add_token'] 生成的Token + * $_POST['add_token'] 生成的Token * $_POST['add_token_id'] Token的ID * $_POST['add_token_expired'] 过期时间 */ @@ -57,14 +57,14 @@ if (isset($_POST['add_token_id'])) { type: "primary", // 定义颜色主题 icon: "ok-sign" // 定义消息图标 }).show(); - + '; header("refresh:1;"); } // 禁用Token if (isset($_GET['stop_token'])) { - $stop_token = $_GET['stop_token']; + $stop_token = $_GET['stop_token']; $postArr = array( $stop_token => array( 'id' => 0, @@ -81,7 +81,7 @@ if (isset($_GET['stop_token'])) { type: "primary", // 定义颜色主题 icon: "ok-sign" // 定义消息图标 }).show(); - + '; header("refresh:1;url=/admin/admin.inc.php"); } @@ -97,14 +97,14 @@ if (isset($_GET['delete_token'])) { type: "primary", // 定义颜色主题 icon: "ok-sign" // 定义消息图标 }).show(); - + '; header("refresh:1;url=/admin/admin.inc.php"); } // 禁用用户 if (isset($_GET['stop_guest'])) { - $stop_guest = $_GET['stop_guest']; + $stop_guest = $_GET['stop_guest']; $postArr = array( $stop_guest => array( 'password' => $guestConfig[$stop_guest]['password'], @@ -336,6 +336,7 @@ if (isset($_POST['del_version_file'])) {
+
@@ -414,6 +415,7 @@ if (isset($_POST['del_version_file'])) {
+
@@ -506,68 +508,76 @@ if (isset($_POST['del_version_file'])) {
-
上传日志 需要开启上传日志
-
-
- - - +
+
+
上传日志 需要开启上传日志
+ +
+ + + +
+ +
- - -
-
-
-
- -
- id="thumbnail0"> +
+
清理缓存 已缓存:
+ + + +
+
+
+
缩略图
+
+
+
+ +
+ 生成模式 + +
-
- id="thumbnail1"> -
-
- id="thumbnail2"> +
+ +
+ + + px + + + px +
-
- -
- - - px - - - - px +
+ + +
+
+
+ + > +
+
-
-
- - -
-
-
- - > - +
+
+ + > + +
+ + +
- -
-
-
- - > - -
- - - -
-
-
高级设置 网站域名与图片域名相同,锁定隐藏' . $config['path'] . '目录开关'; ?>
+
高级设置 网站域名与图片域名相同,锁定隐藏' . $config['path'] . '目录开关'; ?>
@@ -689,94 +699,94 @@ if (isset($_POST['del_version_file'])) {
-
-
-
- - > - +
+
+ + > + +
+
+
+
+ + + + + + + + + + +
+
+
-
-
+
+
- - - - - - - - - - + + + +
+
+
+
+ + +
-
-
-
-
- - - +
+
+
+
+ 游客上传限制 + + +
+
-
-
-
- - - -
-
-
-
-
-
-
- 游客上传限制 - - +
+
+
+ 图片鉴黄 + +
-
-
-
- 图片鉴黄 - -
-
+
+ " placeholder="隐藏的保存">
-
-
- " placeholder="隐藏的保存"> -
- - + + +
可疑图片 鉴黄查到的可疑图片
@@ -797,16 +807,16 @@ if (isset($_POST['del_version_file'])) { @@ -835,7 +845,7 @@ if (isset($_POST['del_version_file'])) {

服务系统: ' . php_uname() . ''; ?>

Web服务:

-

服务器IP:

+

服务器IP:

系统时间:

占用内存:

占用磁盘:

@@ -860,7 +870,16 @@ if (isset($_POST['del_version_file'])) { Chrome ShareX PicGo -
图床依赖
+
开发支持
+

+ demo + manual + discussions + Telegram + + +

+
程序依赖

ZUI Verot @@ -879,7 +898,7 @@ if (isset($_POST['del_version_file'])) { GPL-2.0

-

EasyImage2.0简单图床构建于众多优秀的开源项目之上,非常感谢这些项目!

+

EasyImage2.0简单图床构建于众多优秀的开源项目之上, 非常感谢这些项目!

@@ -1246,10 +1265,7 @@ if (isset($_POST['del_version_file'])) {
文件管理 由作者定制,非必要请勿替换
文件管理 -
清理缓存 已缓存:
-
- -
+ 文件管理
删除文件 * 删除后不可恢复

diff --git a/admin/version.php b/admin/version.php index 5588ae8..1b1a316 100644 --- a/admin/version.php +++ b/admin/version.php @@ -1 +1 @@ -2.7.1 \ No newline at end of file +2.7.2 dev \ No newline at end of file diff --git a/application/history.php b/application/history.php index a664647..57efa4e 100644 --- a/application/history.php +++ b/application/history.php @@ -15,7 +15,7 @@ include_once __DIR__ . "/header.php";
- + - + @@ -357,7 +357,7 @@ if ($config['ad_top']) echo $config['ad_top_info']; onload: function(elem) { console.log(elem) }, - delay: 300 + delay: 300, }) // 按日期浏览 diff --git a/application/thumb.php b/application/thumb.php index 6a605f7..4304016 100755 --- a/application/thumb.php +++ b/application/thumb.php @@ -74,6 +74,7 @@ $ALLOWED_SITES = array( $config['imgurl'], ); + /** * 修复无法生成生成webp动态图片的缩略图bug */ @@ -81,6 +82,15 @@ if (isset($_GET['img'])) { // 引入文件 require_once __DIR__ . '/TimThumb.php'; + $src = $_GET['img']; + + // 重定向不包含存储路径的缩略图地址 + if (!stristr($src, $config['path'])) { + $src = $config['path'] . $src; + header("Location:thumb.php?img=$src"); + exit(); + } + // 图片绝对路径 $src = APP_ROOT . $_GET['img']; // 获取文件后缀 diff --git a/config/config.php b/config/config.php index 1ea8fb3..6f2e35a 100755 --- a/config/config.php +++ b/config/config.php @@ -15,11 +15,12 @@ $config=Array
目录保存以 年/月/日/ 递进,非必要请勿修改! 否则会导致部分操作不可用;
本人仅为程序开源创作,如遇非法网站使用与本人无关,请勿用于商业用途;
作为开发者你可以对相应的后台功能进行扩展(增删改相应代码),但请保留代码中源作者信息。
- - + + + - 打赏作者 - + 打赏 +
', 'domain'=>'http://127.0.0.1', 'imgurl'=>'http://127.0.0.1', @@ -41,7 +42,7 @@ $config=Array 'textSize'=>50, 'textFont'=>'/public/static/pang_men_zheng_dao_biao_ti_ti_3.0.ttf', 'waterImg'=>'/public/images/watermark.png', - 'extensions'=>'gif,jpeg,png,tif,bmp,tif,svg,webp,jpg,tga,ico', + 'extensions'=>'gif,jpeg,png,tif,bmp,svg,webp,jpg,tga,ico', 'compress'=>0, 'compress_ratio'=>80, 'thumbnail'=>1, @@ -113,7 +114,7 @@ $config=Array 'guest_path_status'=>0, 'token_path_status'=>0, 'admin_path'=>'u', - 'update'=>'2023-02-01 22:12:10', + 'update'=>'2023-02-03 16:44:22', 'footer'=>'© Since 2018 EasyImage DMCA diff --git a/i/manag.php b/i/manag.php new file mode 100644 index 0000000..aa873c6 --- /dev/null +++ b/i/manag.php @@ -0,0 +1,1079 @@ + array('password' => $config['password']), +); + + +/**结束 - 自定义修改 */ +?> + + + + + + + + + + + + 文件管理 - <?php echo $config['title']; ?> + + + + + + + + + + + '; + RExplorer::body_breadcrumb($path); + RExplorer::index($path, $view); + echo '
'; + } + } + // 未登录 + else { + if ($action == 'login') { + RexAction::action($path, $action); + } else { + RExplorer::view_login($path); + } + } + ?> + + + + + +路径不存在或无权限访问!'; + } + + /** + * 用户登录视图 + * @param string $path 路径 + */ + static function view_login($path) + { + echo ' + '; + } + + /** + * 目录内容视图 + * @param string $path 路径 + */ + static function view_list($path) + { + $sapath = RexHelper::path_rtoa($path); + $fslist = iterator_to_array(new FilesystemIterator($sapath, 256)); + ksort($fslist, SORT_NATURAL); + usort($fslist, function ($a, $b) { + if ($a->isDir() && !$b->isDir()) { + return -1; + } + if (!$a->isDir() && $b->isDir()) { + return 1; + } + return 0; + }); + echo ' +
+ + + + + + + + + + + + + '; + foreach ($fslist as $item) { + $suffix = $item->isDir() ? '/' : ''; + $srpath = RexHelper::path_ator($item->getRealPath()); + + echo ''; + if (RexHelper::file_catetory($srpath) == 'image') { + echo ' + '; + } else { + echo ' + '; + } + echo ' + + + + + + '; + } + echo ' + +
名称大小权限所有者创建时间操作
+ 查看原图 + + ' . $item->getFileName() . $suffix . ' + ' . ($item->isFile() ? RexHelper::format_bytes($item->getSize()) : '-') . '' . substr(sprintf('%o', $item->getPerms()), -4) . '' . $item->getOwner() . ':' . $item->getGroup() . '' . date('Y-m-d H:i', $item->getCTime()) . '查看|改名|权限|删除
+
+ '; + } + + /** + * 新增目录视图 + * @param string $path 路径 + */ + static function view_newdir($path) + { + echo ' +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+
+ '; + } + + /** + * 新增文件视图 + * @param string $path 路径 + */ + static function view_newfile($path) + { + echo ' +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+
+ '; + } + + /** + * 编辑文件内容视图 + * @param string $path 路径 + */ + static function view_edit($path) + { + $sapath = RexHelper::path_rtoa($path); + $category = RexHelper::file_catetory($sapath); + switch ($category) { + case 'text': + $c = htmlspecialchars(file_get_contents($sapath)); + echo ' +
+
+
+ +
+
+ '; + if (is_writable($sapath)) { + echo ''; + } else { + echo ''; + } + echo ' +
+
+
+ '; + return; + case 'image': + echo ' + + + '; + return; + default: + echo ' +
+ +
+ '; + return; + } + } + + /** + * 上传文件视图 + * @param string $path 路径 + */ + static function view_upload($path) + { + echo ' +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+
+ '; + } + + /** + * 重命名文件视图 + * @param string $path 路径 + */ + static function view_rename($path) + { + echo ' +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+
+ '; + } + + /** + * 编辑权限视图 + * @param string $path 路径 + */ + static function view_chmod($path) + { + $sapath = RexHelper::path_rtoa($path); + $perms = substr(sprintf("%o", fileperms($sapath)), -4); + echo ' +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+
+ '; + } + + /** + * 压缩文件视图 + * @param string $path 路径 + */ + static function view_zip($path) + { + echo ' +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ +
+ '; + } + + /** + * 解压缩文件视图 + * @param string $path 路径 + */ + static function view_unzip($path) + { + echo ' +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ '; + } + + /** + * 全局操作菜单 + * @param string $path 路径 + * @param string $view 视图 + */ + static function body_navbar($path, $view) + { + $pdir = $path; + if (!is_dir(RexHelper::path_rtoa($path))) { + $pdir = dirname($path); + } + $member = RexAction::user_info(); + echo ' + '; + } + + /** + * 路径转为导航 + * @param string $path 路径 + */ + static function body_breadcrumb($path) + { + echo ' + + '; + } + + /** + * URL重定向 + * @param string $url 重定向的URL地址 + * @param integer $sec 重定向的等待时间(秒) + * @param string $msg 重定向前的提示信息 + * @return void + */ + static function url_redirect($url, $sec, $msg = '') + { + $url = str_replace(array("\n", "\r"), '', $url); + $msg = $sec == 1 ? '操作成功!' : '操作失败!'; + $cat = $sec == 1 ? 'success' : 'danger'; + echo ' +
+ +
+ + '; + exit(''); + } +} + +/** + * 回调方法类 + */ +class RexAction +{ + static function action($path, $action) + { + $method = 'act_' . $action; + if (!method_exists('RexAction', $method)) { + RExplorer::url_redirect('?r=fail', 2, '接口不存在!'); + } + self::$method($path); + } + + /** + * 用户信息 + * @return array | null + */ + static function user_info() + { + if (isset($_SESSION[RexHelper::$ssid])) { + return $_SESSION[RexHelper::$ssid]; + } + } + + /** + * 用户登录操作 + */ + static function act_login() + { + $uname = G('username'); + if (empty(RexHelper::$users[$uname])) { + RExplorer::url_redirect('?r=fail', 2, '用户不存在!'); + } + if (RexHelper::$users[$uname]['password'] != md5(G('password'))) { + RExplorer::url_redirect('?r=fail', 2, '密码错误!'); + } + $_SESSION[RexHelper::$ssid] = array( + 'username' => $uname, + ); + RExplorer::url_redirect('?r=ok', 1); + } + + /** + * 用户登出操作 + */ + static function act_logout() + { + unset($_SESSION[RexHelper::$ssid]); + RExplorer::url_redirect('?r=ok', 1); + } + + /** + * 保存新目录 + * @param string $path 路径 + */ + static function act_newdir($path) + { + $filename = G('filename'); + if (!$filename) { + RExplorer::url_redirect('?path=' . $path, 2, '目录名称无效!'); + } + $mode = intval(G('mode'), 8); + $sapath = RexHelper::path_rtoa($path); + $target = $sapath . DIRECTORY_SEPARATOR . $filename; + if (file_exists($target)) { + RExplorer::url_redirect('?path=' . $path, 2, ' 目标已存在!'); + } + if (@mkdir($target, $mode)) { + RExplorer::url_redirect('?path=' . $path, 1); + } + RExplorer::url_redirect('?path=' . $path, 2); + } + + /** + * 新建文件 + * @param string $path 路径 + */ + static function act_newfile($path) + { + $filename = G('filename'); + if (!$filename || strpos($filename, '.') === false) { + RExplorer::url_redirect('?path=' . $path, 2, '文件名或扩展名无效!'); + } + $content = G('content'); + $sapath = RexHelper::path_rtoa($path); + is_dir($sapath) || $sapath = dirname($sapath); // 降级 + $target = $sapath . DIRECTORY_SEPARATOR . $filename; + if (file_put_contents($target, $content) !== false) { + RExplorer::url_redirect('?path=' . $path, 1); + } + RExplorer::url_redirect('?path=' . $path, 2); + } + + /** + * 修改文件 + * @param string $path 路径 + */ + static function act_edit($path) + { + $content = G('content'); + $sapath = RexHelper::path_rtoa($path); + if (file_put_contents($sapath, $content) !== false) { + RExplorer::url_redirect('?path=' . $path, 1); + } + RExplorer::url_redirect('?path=' . $path, 2); + } + + /** + * 删除路径(文件或目录) + * @param string $path 路径 + */ + static function act_delete($path) + { + $sapath = RexHelper::path_rtoa($path); + if (is_file($sapath)) { + if (@unlink($sapath)) { + RExplorer::url_redirect('?path=' . dirname($path), 1); + } + RExplorer::url_redirect('?path=' . dirname($path), 2); + } + if (is_dir($sapath)) { + if (@rmdir($sapath)) { + RExplorer::url_redirect('?path=' . dirname($path), 1); + } + RExplorer::url_redirect('?path=' . $path, 2, '非空或权限不足!'); + } + RExplorer::url_redirect('?path=' . $path, 2, '不是有效文件或目录!'); + } + + /** + * 上传文件 + * @param string $path 路径 + */ + static function act_upload($path) + { + $sapath = RexHelper::path_rtoa($path); + // 从远程获取 + if ($fileurl = G('url')) { + if ($data = file_get_contents($fileurl)) { + $target = $sapath . DIRECTORY_SEPARATOR . basename($fileurl); + if (file_put_contents($target, $data)) { + RExplorer::url_redirect('?path=' . $path, 1); + } + RExplorer::url_redirect('?path=' . $path, 2, '保存文件失败'); + } + RExplorer::url_redirect('?path=' . $path, 2, '获取源文件失败'); + } + // 从本地上传 + if (!empty($_FILES['file'])) { + if ($_FILES['file']['error']) { + $msg = '错误代码 ' . $_FILES['file']['error']; + RExplorer::url_redirect('?path=' . $path, 2, $msg); + } + $target = $sapath . DIRECTORY_SEPARATOR . $_FILES['file']['name']; + if (file_exists($target)) { + $msg = $_FILES['file']['name'] . ' 文件已存在!'; + RExplorer::url_redirect('?path=' . $path, 2, $msg); + } + if (@move_uploaded_file($_FILES['file']['tmp_name'], $target)) { + RExplorer::url_redirect('?path=' . $path, 1); + } + RExplorer::url_redirect('?path=' . $path, 2); + } + // 参数错误 + RExplorer::url_redirect('?path=' . $path, 2, '参数错误'); + } + + /** + * 重命名路径 + * @param string $path 路径 + */ + static function act_rename($path) + { + $filename = G('filename'); + if (!$filename) { + RExplorer::url_redirect('?view=rename&path=' . $path, 2, '名称不能为空!'); + } + $sapath = RexHelper::path_rtoa($path); + if (is_file($sapath) && strpos($filename, '.') === false) { + RExplorer::url_redirect('?view=rename&path=' . $path, 2, '文件扩展名无效!'); + } + $target = dirname($sapath) . DIRECTORY_SEPARATOR . $filename; + if (@rename($sapath, $target)) { + RExplorer::url_redirect('?path=' . dirname($path), 1); + } + RExplorer::url_redirect('?path=' . dirname($path), 2); + } + + /** + * 编辑权限 + * @param string $path 路径 + */ + static function act_chmod($path) + { + $mode = intval(G('mode'), 8); + if (!$mode) { + RExplorer::url_redirect('?view=chmod&path=' . $path, 2, '权限模式无效!'); + } + $sapath = RexHelper::path_rtoa($path); + if (@chmod($sapath, $mode)) { + RExplorer::url_redirect('?path=' . dirname($path), 1); + } + RExplorer::url_redirect('?path=' . dirname($path), 2); + } + + /** + * 压缩操作 + * @param string $path 路径 + */ + static function act_zip($path) + { + $filename = G('filename'); + if (!$filename || !strpos($filename, '.')) { + RExplorer::url_redirect('?path=' . $path, 2, '压缩文件名无效!'); + } + $filename = RexHelper::path_rtoa($filename); + if (file_exists($filename)) { + RExplorer::url_redirect('?path=' . $path, 2, '压缩文件已存在!'); + } + $content = G('content'); + if (!$content) { + RExplorer::url_redirect('?path=' . $path, 2, '压缩内容无效!'); + } + $include = array(); + $exclude = array(); + $items = explode(PHP_EOL, $content); + foreach ($items as $item) { + if (strpos($item, 'exclude ') === 0) { + $exclude[] = RexHelper::path_rtoa(trim(substr($item, 8))); + } else { + $include[] = RexHelper::path_rtoa($item); + } + } + if (empty($include)) { + RExplorer::url_redirect('?path=' . $path, 2, '压缩内容无效!'); + } + $zip = new ZipHelper(); + $trimpath = RexHelper::path_rtoa(G('trimpath')); + if ($zip->zip($filename, $msg, $include, $exclude, $trimpath)) { + RExplorer::url_redirect('?path=' . $path, 1, $msg); + } + RExplorer::url_redirect('?path=' . $path, 2, $msg); + } + + /** + * 解压缩文件 + * @param string $path 路径 + */ + static function act_unzip($path) + { + $root = RexHelper::path_rtoa(G('root')); + $filename = RexHelper::path_rtoa(G('filename')); + if (!$filename) { + $msg = '压缩文件路径无效!'; + RExplorer::url_redirect('?path=' . $path, 2, $msg); + } + if (!$root) { + $msg = '解压缩路径无效!'; + RExplorer::url_redirect('?path=' . $path, 2, $msg); + } + $zip = new ZipHelper(); + if ($zip->unzip($filename, $root, $msg)) { + RExplorer::url_redirect('?path=' . $path, 1, $msg); + } + RExplorer::url_redirect('?path=' . $path, 2, $msg); + } + + /** + * 清空OPCache + * @param string $path 路径 + */ + static function act_opreset($path) + { + if (opcache_reset()) { + RExplorer::url_redirect('?path=' . $path, 1); + } + RExplorer::url_redirect('?path=' . $path, 2); + } +} + +class RexHelper +{ + static $root = __DIR__; + + static $version = '1.3'; + + static $ssid = 'rexplorer_sid'; + + static $users = array( + 'admin' => array('password' => 'e6e061838856bf47e1de730719fb2609'), + ); + + /** + * 优化容量显示 + * @param string $path 路径 + */ + static function format_bytes($size) + { + $units = array(' B', ' KB', ' MB', ' GB', ' TB'); + for ($i = 0; $size >= 1024 && $i < 4; $i++) $size /= 1024; + return round($size, 2) . $units[$i]; + } + + /** + * 绝对路径转相对路径 + * @param string $path 路径 + * @return string + */ + static function path_ator($path) + { + $path = substr($path, strlen(self::$root)); + if (DIRECTORY_SEPARATOR != '/') { + $path = str_replace(DIRECTORY_SEPARATOR, '/', $path); + } + return $path; + } + + /** + * 相对路径转绝对路径 + * @param string $path 路径 + * @return string + */ + static function path_rtoa($path) + { + $path = self::$root . DIRECTORY_SEPARATOR . trim($path, '/\\'); + if (DIRECTORY_SEPARATOR != '/') { + return str_replace('/', DIRECTORY_SEPARATOR, $path); + } + return $path; + } + + /** + * 获取文件扩展名类型 + * @param string $path 文件路径 + * @return string + */ + static function file_catetory($path) + { + if ($ext = pathinfo($path, PATHINFO_EXTENSION)) { + $text_types = array( + 'sql', 'tpl', 'php', 'htm', 'html', 'js', 'css', + 'sh', 'md', 'log', 'txt', 'json', 'env', 'ini', + ); + if (in_array($ext, $text_types)) { + return 'text'; + } + } + if (@getimagesize($path)) { + return 'image'; + } + return ''; + } +} + +/** + * 压缩类 + */ +class ZipHelper +{ + /** + * 解压缩之 + * @param string $filename 文件名 + * @param string $path 解压路径 + * @param string $msg 错误消息 + * @return boolean + */ + function unzip($filename, $path, &$msg = '') + { + if (!$filename) { + $msg = '压缩文件名无效!'; + return false; + } + $zip = new ZipArchive(); + $msg = $zip->open($filename); + if (true !== $msg) { + $msg = var_export($msg, true); + return false; + } + $zip->extractTo($path); + $zip->close(); + return true; + } + + /** + * 压缩之 + * @param string $filename 文件名 + * @param string $msg 错误消息 + * @param array $include 包含文件列表 + * @param array $exclude 排除文件列表 + * @param string $trimpath 删除根路径 + * @param string $comment 注释内容 + * @return boolean + */ + function zip($filename, &$msg = '', $include = array(), $exclude = array(), $trimpath = '', $comment = 'default') + { + if (!$filename) { + $msg = '压缩文件名无效!'; + return false; + } + if (empty($include)) { + $msg = '压缩内容无效!'; + return false; + } + if ('default' == $comment) { + $comment = basename($filename) . PHP_EOL . 'Generate at ' . date('Y-m-d H:i:s') . PHP_EOL . 'Powerd by RExplorer.'; + } + try { + $zip = new ZipArchive(); + $res = $zip->open($filename, ZipArchive::CREATE); + if ($res !== true) { + $msg = var_export($res, true); + return false; + } + if ($comment) { + $zip->setArchiveComment($comment); + } + if ($trimpath) { + $trimpath = rtrim($trimpath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; + } + $substart = strlen($trimpath); + foreach ($include as $source) { + $this->zip_dir($zip, $source, $exclude, $substart); + } + $zip->close(); + return true; + } catch (Exception $ex) { + $msg = $ex->getMessage(); + return false; + } + } + + /** + * 递归压缩整个目录 + * @param ZipArchive $zip Zip 实例 + * @param string $source 包含的路径 + * @param array $exclude 排除的路径 + * @param int $substart 开始截取的路径字符串(用于去除路径中的根目录路径) + */ + function zip_dir(&$zip, $source, $exclude, $substart = 0) + { + if (is_dir($source)) { + $source = rtrim($source, DIRECTORY_SEPARATOR); + if ($handle = opendir($source)) { + while (false !== ($f = readdir($handle))) { + if ('.' == $f || '..' == $f) { + continue; + } + $filename = $source . DIRECTORY_SEPARATOR . $f; + if (is_dir($filename)) { + if ($exclude && in_array($filename, $exclude)) { + continue; + } + $this->zip_dir($zip, $filename, $exclude, $substart); + } else { + if ($exclude && in_array($filename, $exclude)) { + continue; + } + $zip->addFile($filename, substr($filename, $substart)); + } + } + closedir($handle); + } + } else { + if ($exclude && in_array($source, $exclude)) { + return; + } + $zip->addFile($source); + } + } +} + +/** 环境检测 */ +if ($config['checkEnv']) require_once APP_ROOT . '/application/check.php'; +/** 底部广告 */ +if ($config['ad_bot']) echo $config['ad_bot_info']; +/** 引入底部 */ +require_once APP_ROOT . '/application/footer.php'; diff --git a/public/static/lazyload/lazyload.js b/public/static/lazyload/lazyload.js deleted file mode 100755 index 098c16a..0000000 --- a/public/static/lazyload/lazyload.js +++ /dev/null @@ -1,20 +0,0 @@ - -(function(){var root=(typeof self=='object'&&self.self==self&&self)||(typeof global=='object'&&global.global==global&&global)||this||{};Function.prototype.bind=Function.prototype.bind||function(context){if(typeof this!=="function"){throw new Error("Function.prototype.bind - what is trying to be bound is not callable");} -var self=this;var args=Array.prototype.slice.call(arguments,1);var fNOP=function(){};var fBound=function(){var bindArgs=Array.prototype.slice.call(arguments);self.apply(this instanceof fNOP?this:context,args.concat(bindArgs));} -fNOP.prototype=this.prototype;fBound.prototype=new fNOP();return fBound;} -var util={extend:function(target){for(var i=1,len=arguments.length;i=this.view.left&&rect.bottom>=this.view.top&&rect.left<=this.view.right&&rect.top<=this.view.bottom);};proto.render=function(){var nodes=document.querySelectorAll('[data-image], [data-lazy-background]');var length=nodes.length;for(var i=0;i=this.view.left&&e.bottom>=this.view.top&&e.left<=this.view.right&&e.top<=this.view.bottom},o.render=function(){for(var t=document.querySelectorAll("[data-image], [data-lazy-background]"),e=t.length,n=0;n