pull/141/head
= 2022-02-27 07:59:03 +01:00
parent 4bb8f75cc7
commit 4ee5cfb70e
9 changed files with 174 additions and 63 deletions

2
.github/FUNDING.yml vendored
View File

@ -1 +1 @@
custom: ['https://png.cm/sponsor/index.html']
custom: ['https://png.cm/sponsor/images/wechat.jpg']

View File

@ -104,8 +104,9 @@ $HTTP["url"] =~ "^/(i|public)/" {
<details><summary><mark>点击查看2.0版更新日志</mark></summary>
* 2022-2-21 v2.5.4 Developing
- 增加回收图片
- 增加Token有效期
- 增加回收图片按钮
- 增加加密删除回收站
- 修复广场标题
* 2022-2-21 v2.5.3

View File

@ -138,9 +138,9 @@ if (isset($_POST['delDir'])) {
}
}
// 恢复图片
if (isset($_GET['reimg'])) {
$name = $_GET['reimg'];
// 监黄恢复图片
if (isset($_GET['suspic_reimg'])) {
$name = $_GET['suspic_reimg'];
if (re_checkImg($name)) {
echo "
<script>
@ -161,6 +161,29 @@ if (isset($_GET['reimg'])) {
";
}
}
// 回收站恢复图片
if (isset($_GET['recycle_reimg'])) {
$name = $_GET['recycle_reimg'];
if (re_checkImg($name, 'recycle/')) {
echo "
<script>
new $.zui.Messager('恢复成功', {
type: 'success', // 定义颜色主题
icon: 'ok'
}).show();
</script>
";
} else {
echo "
<script>
new $.zui.Messager('文件不存在!', {
type: 'danger', // 定义颜色主题
icon: 'warning-sign'
}).show();
</script>
";
}
}
?>
<div class="container">
<div class="row">
@ -180,11 +203,12 @@ if (isset($_GET['reimg'])) {
<li><a data-tab href="#Content1">网站设置</a></li>
<li><a data-tab href="#Content9">界面设置</a></li>
<li><a data-tab href="#Content2">上传设置</a></li>
<li><a data-tab href="#Content3">广告设置</a></li>
<li><a data-tab href="#Content5">API 设置</a></li>
<li><a data-tab href="#Content11">图片回收<span class="label label-badge label-success"><?php echo get_file_by_glob(APP_ROOT . $config['path'] . 'recycle', 'number'); ?></span></a></li>
<li><a data-tab href="#Content7">可疑图片<span class="label label-badge label-success"><?php echo get_file_by_glob(APP_ROOT . $config['path'] . 'suspic', 'number'); ?></span></a></li>
<li><a data-tab href="#Content4">文件操作</a></li>
<li><a data-tab href="#Content6">图片安全</a></li>
<li><a data-tab href="#Content4">压缩图片</a></li>
<li><a data-tab href="#Content3">广告设置</a></li>
<li><a data-tab href="#Content6">图床安全</a></li>
<li><a data-tab href="#Content10">账号密码</a></li>
<li><a data-tab href="#Content8">系统信息</a></li>
</ul>
@ -258,20 +282,6 @@ if (isset($_GET['reimg'])) {
</div>
<div class="tab-pane fade" id="Content2">
<form action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post">
<div class="form-group">
<div class="switch switch-inline">
<input type="hidden" name="mustLogin" value="0">
<input type="checkbox" name="mustLogin" value="1" <?php if ($config['mustLogin']) echo 'checked="checked"'; ?>>
<label style="font-weight: bold">登录上传</label>
</div>
</div>
<div class="form-group">
<div class="switch switch-inline">
<input type="hidden" name="apiStatus" value="0">
<input type="checkbox" name="apiStatus" value="1" <?php if ($config['apiStatus']) echo 'checked="checked"'; ?>>
<label style="font-weight: bold">API上传</label>
</div>
</div>
<div class="form-group">
<label data-toggle="tooltip" title="前后需加英文'/' 例: /i/">存储路径</label>
<input type="text" class="form-control" name="path" required="required" value="<?php echo $config['path']; ?>" onkeyup="this.value=this.value.replace(/\s/g,'')" title="可根据Apache/Nginx配置安全,参考: https://blog.png.cm/981.html 或 README.md">
@ -485,10 +495,6 @@ if (isset($_GET['reimg'])) {
<label>* 两种压缩均为不可逆,并且非常占用硬件资源. </label><br />
<button type="submit" class="btn btn-mini btn-success">开始压缩</button>
</form>
<form class="form-inline" action="<?php $_SERVER['SCRIPT_NAME']; ?>" method="post">
<hr>
<button type="submit" class="btn btn-primary" name="delDir" value="thumbnails/" data-toggle="tooltip" title="已缓存: <?php echo getFileNumber(APP_ROOT . $config['path'] . 'thumbnails/') . '文件 | 占用' . getDistUsed(getDirectorySize(APP_ROOT . $config['path'] . 'thumbnails/')); ?>" onClick="return confirm('确认要清理缓存?\n* 删除文件夹后将无法恢复! ');">清理缓存</button>
</form>
</div>
<div class="tab-pane fade " id="Content5">
<h5>外部KEY</h5>
@ -559,9 +565,14 @@ if (isset($_GET['reimg'])) {
</form>
</div>
<div class="tab-pane fade" id="Content6">
<form action="<?php $_SERVER['SCRIPT_NAME']; ?>" method="post">
<div class="form-group">
<button type="submit" class="btn btn-primary" name="delDir" value="thumbnails/" data-toggle="tooltip" title="已缓存: <?php echo getFileNumber(APP_ROOT . $config['path'] . 'thumbnails/') . '文件 | 占用' . getDistUsed(getDirectorySize(APP_ROOT . $config['path'] . 'thumbnails/')); ?>" onClick="return confirm('确认要清理缓存?\n* 删除文件夹后将无法恢复! ');">清理缓存</button>
</div>
</form>
<form action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post">
<div class="form-group">
<label data-toggle="tooltip" title="使用nsfwjs方式需要自行搭建或使用开源接口 据说准确率能达到93%">图片鉴黄方式</label>
<label data-toggle="tooltip" title="使用nsfwjs方式需要自行搭建或使用开源接口 据说准确率能达到93%">图片鉴黄</label>
<select class="chosen-select form-control" name="checkImg">
<option value="0" <?php if ($config['checkImg'] == 0) echo 'selected'; ?>>关闭</option>
<option value="1" <?php if ($config['checkImg'] == 1) echo 'selected'; ?>>moderatecontent | API 设置中填入Moderate Key</option>
@ -588,6 +599,41 @@ if (isset($_GET['reimg'])) {
<label class="radio-inline"><input type="radio" name="check_ip_model" value="0" <?php if ($config['check_ip_model'] == 0) echo 'checked'; ?>> 黑名单模式</label>
<label class="radio-inline"><input type="radio" name="check_ip_model" value="1" <?php if ($config['check_ip_model'] == 1) echo 'checked'; ?>> 白名单模式</label>
</div>
<div class="form-group">
<div class="switch switch-inline">
<input type="hidden" name="mustLogin" value="0">
<input type="checkbox" name="mustLogin" value="1" <?php if ($config['mustLogin']) echo 'checked="checked"'; ?>>
<label style="font-weight: bold">登录上传</label>
</div>
</div>
<div class="form-group">
<div class="switch switch-inline">
<input type="hidden" name="apiStatus" value="0">
<input type="checkbox" name="apiStatus" value="1" <?php if ($config['apiStatus']) echo 'checked="checked"'; ?>>
<label style="font-weight: bold">API 上传</label>
</div>
</div>
<div class="form-group">
<div class="switch switch-inline" data-toggle="tooltip" title="所有用户上传的图片使用加密链接删除后是否进入回收站">
<input type="hidden" name="image_recycl" value="0">
<input type="checkbox" name="image_recycl" value="1" <?php if ($config['image_recycl']) echo 'checked="checked"'; ?>>
<label style="font-weight: bold">图片回收</label>
</div>
</div>
<div class="form-group">
<div class="switch switch-inline" data-toggle="tooltip" title="PHP扩展 | 安全设置 | 鉴黄 | 版本 检测">
<input type="hidden" name="checkEnv" value="0">
<input type="checkbox" name="checkEnv" value="1" <?php if ($config['checkEnv']) echo 'checked="checked"'; ?>>
<label style="font-weight: bold">网站检测</label>
</div>
</div>
<div class="form-group">
<div class="switch switch-inline" data-toggle="tooltip" title="日志每月保存一个文件; 经测试二十万条数据并不影响速度!">
<input type="hidden" name="upload_logs" value="0">
<input type="checkbox" name="upload_logs" value="1" <?php if ($config['upload_logs']) echo 'checked="checked"'; ?>>
<label style="font-weight: bold">上传日志</label>
</div>
</div>
<div class="form-group">
<div class="switch switch-inline" data-toggle="tooltip" title="通过指定参数查询图床的开放数据 | 与缓存周期同步 | 使用方法见使用手册->公共查询">
<input type="hidden" name="public" value="0">
@ -627,28 +673,62 @@ if (isset($_GET['reimg'])) {
<input type="checkbox" name="public_list[]" value="month" id="month" <?php if (in_array('month', $config['public_list'])) echo 'checked'; ?>><label for="month">最近30日</label>
</label>
</div>
<div class="form-group">
<div class="switch switch-inline" data-toggle="tooltip" title="PHP扩展 | 安全设置 | 鉴黄 | 版本">
<input type="hidden" name="checkEnv" value="0">
<input type="checkbox" name="checkEnv" value="1" <?php if ($config['checkEnv']) echo 'checked="checked"'; ?>>
<label style="font-weight: bold">网站检测</label>
</div>
</div>
<div class="form-group">
<div class="switch switch-inline" data-toggle="tooltip" title="日志每月保存一个文件; 经测试二十万条数据并不影响速度!">
<input type="hidden" name="upload_logs" value="0">
<input type="checkbox" name="upload_logs" value="1" <?php if ($config['upload_logs']) echo 'checked="checked"'; ?>>
<label style="font-weight: bold">上传日志</label>
</div>
</div>
<div class="form-group">
<input type="hidden" class="form-control" name="update" value="<?php echo date("Y-m-d H:i:s"); ?>" placeholder="隐藏的保存">
</div>
<button type="submit" class="btn btn-primary">保存</button>
</form>
</div>
<div class="tab-pane fade" id="Content11">
<h5>用户上传后自行删除的会显示在这个页面</h5>
<p>为了访问速度,仅显示最近20张图片;图片回收需要在图床安全->图片回收中开启</p>
<div class="table-responsive">
<table class="table table-hover table-bordered table-condensed table-striped">
<thead>
<tr>
<th>序号</th>
<th>缩略图</th>
<th>文件名</th>
<th>文件大小</th>
<th>文件操作</th>
</tr>
</thead>
<tbody>
<?php
// 获取被隔离的文件
$cache_dir = APP_ROOT . $config['path'] . 'recycle/'; // cache目录
$cache_file = get_file_by_glob($cache_dir . '*.*'); // 获取所有文件
@$cache_num = count($cache_file); // 统计目录文件个数
for ($i = 0; $i < $cache_num and $i < 21; $i++) : // 循环输出文件
$file_cache_path = APP_ROOT . $config['path'] . 'recycle/' . $cache_file[$i]; // 图片绝对路径
$file_path = $config['path'] . 'recycle/' . $cache_file[$i]; // 图片相对路径
@$file_size = getDistUsed(filesize($file_cache_path)); // 图片大小
@$filen_name = $cache_file[$i]; // 图片名称
$url = $config['imgurl'] . $config['path'] . 'recycle/' . $cache_file[$i]; // 图片网络连接
$unlink_img = $config['domain'] . '/application/del.php?url=' . $url; // 图片删除连接
?>
<tr>
<td><?php echo $i; ?></td>
<td><img data-toggle="lightbox" src="<?php echo get_online_thumbnail($file_path); ?>" data-image="<?php echo $url; ?>" class="img-thumbnail"></td>
<td><?php echo $filen_name; ?></td>
<td><?php echo $file_size; ?></td>
<td>
<a class="btn btn-mini" href="<?php echo $url; ?>" target="_blank">新窗口</a>
<a class="btn btn-mini btn-success" href="?recycle_reimg=<?php echo $filen_name; ?>">恢复</a>
<a class="btn btn-mini btn-danger" href="<?php echo $unlink_img; ?>" target="_blank">删除</a>
</td>
</tr>
<?php endfor; ?>
</tbody>
</table>
</div>
<form class="form-inline" action="<?php $_SERVER['SCRIPT_NAME']; ?>" method="post">
<input class="form-control" type="hidden" name="delDir" value="/suspic/" readonly="">
<button class="btn btn-mini btn-danger"><?php echo $cache_num; ?>张 | 删除全部</button>
</form>
</div>
<div class="tab-pane fade" id="Content7">
<p>为了访问速度,仅显示最近20张图片;鉴黄需要在安全设置->图片鉴黄。</p>
<p>为了访问速度,仅显示最近20张图片;鉴黄需要在图床安全->图片鉴黄中开启</p>
<p>key申请地址: <a href="https://client.moderatecontent.com/" target="_blank">https://client.moderatecontent.com/</a></p>
<p>获得key后打开->API 设置->Moderate Key->填入 </p>
<div class="table-responsive">
@ -683,7 +763,7 @@ if (isset($_GET['reimg'])) {
<td><?php echo $file_size; ?></td>
<td>
<a class="btn btn-mini" href="<?php echo $url; ?>" target="_blank">新窗口</a>
<a class="btn btn-mini btn-success" href="?reimg=<?php echo $filen_name; ?>">恢复</a>
<a class="btn btn-mini btn-success" href="?suspic_reimg=<?php echo $filen_name; ?>">恢复</a>
<a class="btn btn-mini btn-danger" href="<?php echo $unlink_img; ?>" target="_blank">删除</a>
</td>
</tr>

View File

@ -28,7 +28,8 @@ if ($config['password'] === 'e6e061838856bf47e1de730719fb2609') {
echo '
<script>
new $.zui.Messager("请修改默认密码,否则会有泄露风险! ",{
type: "warning" // 定义颜色主题
type: "warning", // 定义颜色主题
time:7000
}).show();
</script>
';
@ -77,3 +78,15 @@ if ($configp['checkImg'] !== 0) {
}
}
}
// 检测是否存在.user.ini
if (file_exists(APP_ROOT . '/.user.ini')) {
echo '
<script>
new $.zui.Messager("请关闭防跨目录读写或删除.user.ini文件 ",{
type: "danger", // 定义颜色主题
time:10000
}).show();
</script>
';
}

View File

@ -39,7 +39,24 @@ if (empty($_REQUEST)) {
if (isset($_GET['hash'])) {
$delHash = $_GET['hash'];
$delHash = urlHash($delHash, 1);
getDel($delHash, 'hash');
// getDel($delHash, 'hash');
if ($config['image_recycl']) {
// 如果开启回收站则进入回收站
checkImg($delHash, 3, 'recycle/');
echo '
<script>
new $.zui.Messager("删除成功", {
type: "success", // 定义颜色主题
icon: "ok-sign" // 定义消息图标
}).show();
</script>
';
} else {
// 否则直接删除
getDel($delHash, 'url');
}
}
// 检查登录后再处理url删除请求

View File

@ -39,6 +39,9 @@ if ($config['ad_bot']) echo $config['ad_bot_info']; // 底部广告
?>
</p>
</footer>
<link href="<?php static_cdn(); ?>/public/static/nprogress/nprogress.min.css" rel="stylesheet">
<script src="<?php static_cdn(); ?>/public/static/nprogress/nprogress.min.js"></script>
<script src="<?php static_cdn(); ?>/public/static/qrcode/qrcode.min.js"></script>
<script>
// NProgress
NProgress.start();

View File

@ -658,7 +658,7 @@ function nsfwjs_json($url, $data = '')
* 检查图片是否违规
* @param $imageUrl string 图片url
*/
function checkImg($imageUrl, $type = 1)
function checkImg($imageUrl, $type = 1, $dir = 'suspic/')
{
global $config;
@ -723,14 +723,15 @@ function checkImg($imageUrl, $type = 1)
// 移入回收站
if ($type == 3) {
$bad_pic = true;
$dir = 'recycle/';
}
/** # 如果违规则移动图片到违规文件夹 */
if ($bad_pic == true) {
$old_path = APP_ROOT . str_replace($config['imgurl'], '', $imageUrl); // 提交网址中的文件路径 /i/2021/10/29/p8vypd.png
$name = date('Y_m_d') . '_' . basename($imageUrl); // 文件名 2021_10_30_p8vypd.png
$new_path = APP_ROOT . $config['path'] . 'suspic/' . $name; // 新路径含文件名
$suspic_dir = APP_ROOT . $config['path'] . 'suspic/'; // suspic路径
$new_path = APP_ROOT . $config['path'] . $dir . $name; // 新路径含文件名
$suspic_dir = APP_ROOT . $config['path'] . $dir; // suspic路径
if (!is_dir($suspic_dir)) { // 创建suspic目录并移动
mkdir($suspic_dir, 0777, true);
@ -743,15 +744,15 @@ function checkImg($imageUrl, $type = 1)
* 还原被审查的图片
* @param $name string 要还原的图片
*/
function re_checkImg($name)
function re_checkImg($name, $dir = 'suspic/')
{
global $config;
$fileToPath = str_replace('_', '/', $name); // 将图片名称还原为带路径的名称eg:2021_11_03_pbmn1a.jpg =>2021/11/03/pbmn1a.jpg
$now_path_file = APP_ROOT . $config['path'] . 'suspic/' . $name; // 当前图片绝对位置 */i/suspic/2021_10_30_p8vypd.png
$fileToPath = str_replace('_', '/', $name); // 将图片名称还原为带路径的名称eg:2021_11_03_pbmn1a.jpg =>2021/11/03/pbmn1a.jpg
$now_path_file = APP_ROOT . $config['path'] . $dir . $name; // 当前图片绝对位置 */i/suspic/2021_10_30_p8vypd.png
if (is_file($now_path_file)) {
$to_file = APP_ROOT . $config['path'] . $fileToPath; // 要还原图片的绝对位置 */i/2021/10/30/p8vypd.png
rename($now_path_file, $to_file); // 移动文件
$to_file = APP_ROOT . $config['path'] . $fileToPath; // 要还原图片的绝对位置 */i/2021/10/30/p8vypd.png
rename($now_path_file, $to_file); // 移动文件
return true;
}
}

View File

@ -13,17 +13,11 @@
<meta name="keywords" content="<?php echo $config['keywords']; ?>" />
<meta name="description" content="<?php echo $config['description']; ?>" />
<link rel="shortcut icon" href="<?php echo $config['domain']; ?>/favicon.ico" type="image/x-icon" />
<link rel="dns-prefetch" href="<?php echo $config['imgurl']; ?>" />
<link rel="dns-prefetch" href="<?php echo $config['static_cdn_url']; ?>" />
<link href="<?php static_cdn(); ?>/public/static/zui/css/zui.min.css" rel="stylesheet">
<link href="<?php static_cdn(); ?>/public/static/zui/theme/zui-theme-<?php echo $config['theme']; ?>.css" rel="stylesheet">
<link href="<?php static_cdn(); ?>/public/static/zui/lib/uploader/zui.uploader.min.css" rel="stylesheet">
<link href="<?php static_cdn(); ?>/public/static/nprogress/nprogress.min.css" rel="stylesheet">
<script src="<?php static_cdn(); ?>/public/static/zui/lib/jquery/jquery-3.6.0.min.js"></script>
<script src="<?php static_cdn(); ?>/public/static/zui/js/zui.min.js"></script>
<script src="<?php static_cdn(); ?>/public/static/qrcode/qrcode.min.js"></script>
<script src="<?php static_cdn(); ?>/public/static/zui/lib/clipboard/clipboard.min.js"></script>
<script src="<?php static_cdn(); ?>/public/static/nprogress/nprogress.min.js"></script>
<script src="<?php static_cdn(); ?>/public/static/zui/js/zui.min.js"></script>
<!--[if lt IE 9]>
<script src="<?php static_cdn(); ?>/public/static/zui/lib/ieonly/html5shiv.js"></script>
<script src="<?php static_cdn(); ?>/public/static/zui/lib/ieonly/respond.js"></script>

View File

@ -11,7 +11,7 @@ $config=Array
'imgurl'=>'http://127.0.0.1',
'user'=>'admin',
'password'=>'e6e061838856bf47e1de730719fb2609',
'mustLogin'=>0,
'mustLogin'=>1,
'apiStatus'=>1,
'path'=>'/i/',
'imgName'=>'default',
@ -96,8 +96,9 @@ var _hmt = _hmt || [];
9=>'month'
),
'language'=>0,
'image_recycl'=>1,
'version'=>'2.5.3',
'update'=>'2022-02-25 01:25:54',
'update'=>'2022-02-27 13:22:00',
'terms'=>'<div class="container">
<div class="row">
<div class="col-xs-3">
@ -181,5 +182,6 @@ var _hmt = _hmt || [];
</div>
</div>
</div>
</div>'
</div>',
'delDir'=>'thumbnails/'
);