file manage change

This commit is contained in:
icret 2023-03-10 21:28:21 +08:00
parent 0a2e2d63b4
commit 700e001de1
4 changed files with 73 additions and 37 deletions

View File

@ -923,7 +923,7 @@ auto_delete(); //定时删除
</div> </div>
<form class="form-inline" action="<?php $_SERVER['SCRIPT_NAME']; ?>" method="post"> <form class="form-inline" action="<?php $_SERVER['SCRIPT_NAME']; ?>" method="post">
<input class="form-control" type="hidden" name="delDir" value="/suspic/" readonly=""> <input class="form-control" type="hidden" name="delDir" value="/suspic/" readonly="">
<a class="btn btn-mini btn-primary" href="../i/manag.php?path=suspic" target="_blank">管理可疑</a> <a class="btn btn-mini btn-primary" href="filer.php?path=<?php echo $config['path']; ?>suspic" target="_blank">管理可疑</a>
<button class="btn btn-mini btn-danger"><?php echo $cache_num; ?>张 | 删除全部</button> <button class="btn btn-mini btn-danger"><?php echo $cache_num; ?>张 | 删除全部</button>
</form> </form>
</div> </div>
@ -1271,7 +1271,7 @@ auto_delete(); //定时删除
</div> </div>
<form class="form-inline" action="<?php $_SERVER['SCRIPT_NAME']; ?>" method="post"> <form class="form-inline" action="<?php $_SERVER['SCRIPT_NAME']; ?>" method="post">
<input class="form-control" type="hidden" name="delDir" value="/recycle/" readonly=""> <input class="form-control" type="hidden" name="delDir" value="/recycle/" readonly="">
<a class="btn btn-mini btn-primary" href="../i/manag.php?path=recycle" target="_blank">管理回收</a> <a class="btn btn-mini btn-primary" href="filer.php?path=<?php echo $config['path']; ?>recycle" target="_blank">管理回收</a>
<button class="btn btn-mini btn-danger"><?php echo $cache_num; ?>张 | 删除全部</button> <button class="btn btn-mini btn-danger"><?php echo $cache_num; ?>张 | 删除全部</button>
</form> </form>
</div> </div>
@ -1383,7 +1383,7 @@ auto_delete(); //定时删除
<div class="tab-pane fade" id="Content14"> <div class="tab-pane fade" id="Content14">
<h5 class="header-dividing">文件管理 <small>由作者定制,非必要请勿替换</small></h5> <h5 class="header-dividing">文件管理 <small>由作者定制,非必要请勿替换</small></h5>
<a class="btn btn-mini btn-primary" href="/admin/manager.php?p=<?php echo date('Y/m/d'); ?> " target="_blank" data-toggle="tooltip" title="使用Tinyfilemanager管理文件"><i class="icon icon-folder-open"> 文件管理</i></a> <a class="btn btn-mini btn-primary" href="/admin/manager.php?p=<?php echo date('Y/m/d'); ?> " target="_blank" data-toggle="tooltip" title="使用Tinyfilemanager管理文件"><i class="icon icon-folder-open"> 文件管理</i></a>
<a class="btn btn-mini btn-primary" href="/i/manag.php?path=<?php echo date('Y/m/d'); ?> " target="_blank" data-toggle="tooltip" title="使用web-indexr管理文件"><i class="icon icon-folder-close"> 文件管理</i></a> <a class="btn btn-mini btn-primary" href="filer.php?path=<?php echo $config['path'] . date('Y/m/d'); ?> " target="_blank" data-toggle="tooltip" title="使用web-indexr管理文件"><i class="icon icon-folder-close"> 文件管理</i></a>
<h5 class="header-dividing">删除文件 <small>* 删除后不可恢复</small></h5> <h5 class="header-dividing">删除文件 <small>* 删除后不可恢复</small></h5>
<form class="form-inline" method="get" action="../app/del.php" id="form" name="delForm" target="_blank" style="margin-bottom: 5px;"> <form class="form-inline" method="get" action="../app/del.php" id="form" name="delForm" target="_blank" style="margin-bottom: 5px;">
<p id="delimgurl"></p> <p id="delimgurl"></p>

View File

@ -4,36 +4,44 @@
* Powered by https://github.com/rehiy/web-indexr * Powered by https://github.com/rehiy/web-indexr
*/ */
session_start();
/**开始 - 自定义修改 */ /**开始 - 自定义修改 */
require_once __DIR__ . '/../app/function.php'; require_once __DIR__ . '/../app/function.php';
require_once APP_ROOT . '/config/config.php'; require_once __DIR__ . '/../config/config.php';
// 开启tinyfilemanager文件管理 // 开启tinyfilemanager文件管理
if (!$config['file_manage']) { if (!$config['file_manage']) {
require_once APP_ROOT . '/app/header.php'; require_once APP_ROOT . '/app/header.php';
echo '<h4 class="alert alert-danger">文件管理已关闭~~</h4>'; echo '<h4 class="alert alert-danger">文件管理已关闭~~</h4>';
header("refresh:3;url=" . $config['domain'] . '?manag-closed'); header("refresh:3;url=" . $config['domain'] . '?manag-closed');
require_once APP_ROOT . '/app/footer.php'; exit(require_once APP_ROOT . '/app/footer.php');
exit;
} }
/**结束 - 自定义修改 */
// 根路径 // 目录绝对路径,结尾不加 `/`
RexHelper::$root = APP_ROOT . $config['path']; // RexHelper::$root = $_SERVER['DOCUMENT_ROOT'];
RexHelper::$root = $_SERVER['DOCUMENT_ROOT'];
// 用户列表
RexHelper::$users = array( // 系统用户列表,密码类型 MD5
$config['user'] => array('password' => $config['password']), RexHelper::$users[$config['user']] = array(
'password' => $config['password']
); );
/**结束 - 自定义修改 */ // 可编辑文件后缀,开头不加 `.`
// RexHelper::$text_suff[] = "jsx";
// RexHelper::$text_suff[] = "php5";
// 文件排除规则,仅正则表达式
RexHelper::$ignore_list = array(
'/^\.git|.php|.htaccess|robots.txt|favicon.ico|README.md/', '/^admin|api|app|config|docs|install|public/'
);
session_start();
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<html> <html lang="zh-Hans-CN">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="renderer" content="webkit" /> <meta name="renderer" content="webkit" />
@ -158,7 +166,7 @@ class RExplorer
static function view_login($path) static function view_login($path)
{ {
echo ' echo '
<div class="login"> <div class="login"">
<form class="form-horizontal" method="post" action="?action=login"> <form class="form-horizontal" method="post" action="?action=login">
<h5 class="card-title text-center mb-5">文件管理 <small>v' . RexHelper::$version . '</small></h5> <h5 class="card-title text-center mb-5">文件管理 <small>v' . RexHelper::$version . '</small></h5>
<div class="form-group"> <div class="form-group">
@ -168,7 +176,7 @@ class RExplorer
<div class="form-group"> <div class="form-group">
<label for="exampleInputInviteCode3">密码</label> <label for="exampleInputInviteCode3">密码</label>
<input type="password" class="form-control" name="password" id="exampleInputInviteCode3" placeholder="登录密码"> <input type="password" class="form-control" name="password" id="exampleInputInviteCode3" placeholder="登录密码">
</div> </div>
<button type="submit" class="btn btn-primary">登录</button> <button type="submit" class="btn btn-primary">登录</button>
</form> </form>
</div>'; </div>';
@ -210,12 +218,15 @@ class RExplorer
foreach ($fslist as $item) { foreach ($fslist as $item) {
$suffix = $item->isDir() ? '/' : ''; $suffix = $item->isDir() ? '/' : '';
$srpath = RexHelper::path_ator($item->getRealPath()); $srpath = RexHelper::path_ator($item->getRealPath());
if (RexHelper::is_ignore($item->getFileName())) {
continue;
}
echo '<tr>'; echo '<tr>';
if (RexHelper::file_catetory($srpath) == 'image') { if (RexHelper::file_catetory($srpath) == 'image') {
echo ' echo '
<td> <td>
<img data-toggle="lightbox" src="/../app/thumb.php?img=', $srpath, '" data-image="' . $srpath . '" data-caption="查看原图" class="img-thumbnail" alt="查看原图" width="80"> <img data-toggle="lightbox" src="../app/thumb.php?img=', $srpath, '" data-image="' . $srpath . '" data-caption="查看原图" class="img-thumbnail" alt="查看原图" width="80">
</td>'; </td>';
} else { } else {
echo ' echo '
@ -234,7 +245,6 @@ class RExplorer
echo ' echo '
</tbody> </tbody>
</table> </table>
</div>
'; ';
} }
@ -328,10 +338,12 @@ class RExplorer
return; return;
case 'image': case 'image':
echo ' echo '
<img data-toggle="lightbox" src="/../app/thumb.php?img=', $path, '" data-image="' . $path . '" data-caption="小图看大图" class="img-thumbnail" alt="" width="200"> <div class="card view-image">
<img src="', $path, '" class="card-img-top">
<div class="card-body"> <div class="card-body">
<a href="', $path, '" target="_blank">查看原图</a> <a href="', $path, '" class="card-link">查看原图</a>
</div> </div>
</div>
'; ';
return; return;
default: default:
@ -447,7 +459,7 @@ class RExplorer
<div class="row mb-3"> <div class="row mb-3">
<label class="col-sm-2 col-form-label">压缩文件名</label> <label class="col-sm-2 col-form-label">压缩文件名</label>
<div class="col-sm-10"> <div class="col-sm-10">
<input type="text" class="form-control" name="filename" value="/EasyImage2.0.zip"> <input type="text" class="form-control" name="filename" value="/test.zip">
</div> </div>
</div> </div>
<div class="row mb-4"> <div class="row mb-4">
@ -488,7 +500,7 @@ class RExplorer
<div class="row mb-3"> <div class="row mb-3">
<label class="col-sm-2 col-form-label">压缩包路径</label> <label class="col-sm-2 col-form-label">压缩包路径</label>
<div class="col-sm-10"> <div class="col-sm-10">
<input type="text" class="form-control" name="filename" value="/EasyImage2.0.zip"> <input type="text" class="form-control" name="filename" value="/test.zip">
</div> </div>
</div> </div>
<div class="row mb-3"> <div class="row mb-3">
@ -892,14 +904,24 @@ class RexHelper
{ {
static $root = __DIR__; static $root = __DIR__;
static $version = '1.3'; static $version = '1.4';
static $ssid = 'rexplorer_sid'; static $ssid = 'rexplorer_sid';
static $users = array( static $users = array();
'admin' => array('password' => 'e6e061838856bf47e1de730719fb2609'),
static $text_suff = array(
'sql', 'tpl', 'php', 'htm', 'html', 'ts', 'js', 'css',
'bat', 'sh', 'md', 'log', 'txt', 'json', 'env', 'ini',
); );
static $img_suff = array(
'jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'ico', 'jfif',
'tif', 'tga', 'svg'
);
static $ignore_list = array();
/** /**
* 优化容量显示 * 优化容量显示
* @param string $path 路径 * @param string $path 路径
@ -947,19 +969,33 @@ class RexHelper
static function file_catetory($path) static function file_catetory($path)
{ {
if ($ext = pathinfo($path, PATHINFO_EXTENSION)) { if ($ext = pathinfo($path, PATHINFO_EXTENSION)) {
$text_types = array( if (in_array($ext, self::$text_suff)) {
'sql', 'tpl', 'php', 'htm', 'html', 'js', 'css',
'sh', 'md', 'log', 'txt', 'json', 'env', 'ini',
);
if (in_array($ext, $text_types)) {
return 'text'; return 'text';
} }
}
if (@getimagesize($path)) { if (in_array($ext, self::$img_suff)) {
return 'image'; return 'image';
}
} }
return ''; return '';
} }
/**
* 检测是否需要排除
* @param string $name 文件名称
* @return string
*/
static function is_ignore($name)
{
if (!empty(self::$ignore_list)) {
foreach (self::$ignore_list as $expr) {
if (preg_match($expr, $name)) {
return true;
}
}
}
return false;
}
} }
/** /**

View File

@ -28,7 +28,7 @@ if (empty($_FILES['file'])) {
} }
// sign // sign
if (empty($_REQUEST['sign']) || $_REQUEST['sign'] !== date('YmdH')) { if (empty($_POST['sign']) || $_POST['sign'] !== date('YmdH')) {
exit(json_encode(array( exit(json_encode(array(
"result" => "failed", "result" => "failed",
"code" => 403, "code" => 403,

File diff suppressed because one or more lines are too long