TinyImg 2.0.0:更名、下线 SM.MS、新增后台 Token 设置页

基于 ImgURL 1.x 的二次开发版本,主要变更:

1. 更名
   - 项目定名为 TinyImg,源码中不再出现旧品牌字样(0 处)
   - static/imgurl.js -> static/tinyimg.js
   - db/imgurl-simple.db3 -> db/tinyimg-simple.db3

2. 移除 SM.MS 上传
   - 删除 embed.js 中的 upload.render / smshow / deletesm
   - miniup.html 去掉 SM.MS 选项卡;前台与后台导航移除入口
   - sm.php、functions/sm.php、admin/smadmin.php 改为下线说明页
   - admin/delete.php 移除 type=sm 分支;class.admin.php 删除 querysm()/deletesm()

3. 新增后台 Token 设置(admin/setting.php + functions/token.php)
   - 生成 / 自定义 / 启用 / 停用 / 清空,全部校验 Session CSRF
   - 存储于 db/tinyimg-token.php(首行 <?php exit; 守卫)
   - config.php 的 api_token 仅作兼容回退,保存一次后由文件接管
   - 完整 Token 不写入页面 HTML:默认只渲染掩码,点「显示/复制」时
     经 POST action=reveal(同源 + CSRF + 仅登录会话)按需取回

4. 上传端点鉴权
   - 统一使用 X-TinyImg-Token 请求头,hash_equals 比较,空配置 fail closed
   - 新增 ?ping=1 自检,返回版本、鉴权方式、管理员目录,供写作插件测试连接

5. 版本号
   - 统一为 v2.0.0(20261104),前后台页脚引用 functions/version.php

6. 兼容性修复
   - class.upload.php 中 $size{...} 花括号下标改为 $size[...](PHP 8 已移除该语法)

7. 仓库整理
   - .gitignore 排除 config.php / db/tinyimg-token.php / 运行时目录,
     保留 db/.htaccess 与空模板 db/tinyimg-simple.db3
   - .gitattributes 统一 LF
This commit is contained in:
terry
2026-11-05 17:30:05 +08:00
parent 39e84a0fac
commit aac91aa9b6
180 changed files with 15976 additions and 2 deletions
+186
View File
@@ -0,0 +1,186 @@
<?php
$title = "后台管理 - TinyImg";
include_once("../functions/class/class.admin.php");
// 载入头部
include_once("../tpl/admin/header.php");
// 获取类型
$type = $_GET['type'];
//获取页数
$page = $_GET['page'];
//获取时间
@$date = $_GET['date'];
//如果时间不为空
if($date != ''){
$thedate = explode("|",$date);
$starttime = $thedate[0];
$endtime = $thedate[1];
//翻页选项
$thepage = '&date='.$date;
}
else{
$starttime = '';
//获取当前日期
$endtime = date("Y-m-d",time());
//翻页选项
$thepage = '';
}
//查询图片
$imgs = $pic->querypic($type,$page,$date);
$up = (int)$page - 1;
if($up <= 0){
$up = 1;
}
$down = (int)$page +1;
?>
<div class="layui-container" style = "margin-top:2em;">
<div class="layui-row layui-col-space20">
<div class="layui-col-lg3">
<!-- 载入左侧导航栏 -->
<?php include_once("../tpl/admin/left.php"); ?>
</div>
<!-- 后台内容部分 -->
<div id = "adminpic">
<div class="layui-col-lg9">
<!--时间筛选-->
<div id="date">
<table class="layui-table" lay-skin="nob">
<tbody>
<tr>
<td>按时间筛选:</td>
<td><input type="text" class="layui-input" id="starttime" value = "<?php echo $starttime; ?>"></td>
<td> - </td>
<td><input type="text" class="layui-input" id="endtime" value = "<?php echo $endtime; ?>"></td>
<td><button lay-submit class="layui-btn" onclick = "screen('senioradmin.php')">筛选</button></td>
</tr>
</tbody>
</table>
</div>
<!--时间筛选END-->
<!-- 表格 -->
<table class="layui-table">
<colgroup>
<col width="30">
<col width="280">
<col width="120">
<col width="120">
<col width="120">
<col>
</colgroup>
<thead>
<tr>
<th>ID</th>
<th>图片路径(点击可查看)</th>
<th>IP</th>
<th>日期</th>
<th>是否压缩</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<?php foreach ($imgs as $img) {
$tinyimg = $config['domain'].$img['path'];
$id = $img['id'];
$size = filesize('../'.$img['path']); //文件大小计算
$size = round($size / 1024)."kb";
if($img['compress'] == 0) {
$compress = array(
"css" => "layui-btn layui-btn-xs layui-btn-danger",
"content" => "否"
);
}
else{
$compress = array(
"css" => "layui-btn layui-btn-xs layui-btn-normal",
"content" => "是"
);
}
?>
<tr id = "imgid<?php echo $id; ?>">
<td><a href="javascript:;" onclick = "copyurl('<?php echo $tinyimg; ?>')"><?php echo $id; ?></a></td>
<td>
<a id = "imgid<?php echo $id; ?>" href="javascript:;" onclick = "adminshow('<?php echo $tinyimg ?>',<?php echo $id; ?>)" onmouseover = "viewimg('<?php echo $id; ?>','<?php echo $tinyimg; ?>')" onmouseout = "hideimg('<?php echo $id; ?>')">
<?php echo $img['path']; ?>
</a>
<div id="viewimg<?php echo $id; ?>" class = "viewimg">
<img src="" alt="">
</div>
</td>
<td><a href="javascript:;" onclick = "ipquery('<?php echo $img['ip']; ?>')"><?php echo $img['ip']; ?></a></td>
<td><?php echo $img['date']; ?></td>
<td>
<a href="javascript::" class = "<?php echo $compress['css']; ?>"><?php echo $compress['content']; ?></a>
<a href="javascript:;" class = "layui-btn layui-btn-xs layui-btn-disabled"><?php echo $size; ?></a>
</td>
<td>
<?php if($type == 'dubious'){ ?>
<a href="javascript:;" class="layui-btn layui-btn-xs layui-btn-normal" onclick = "cdubious(<?php echo $id; ?>)">非可疑</a>
<?php }else{ ?>
<a href="javascript:;" class="layui-btn layui-btn-xs layui-btn-normal" onclick = "compress(<?php echo $id; ?>)">压缩</a>
<?php } ?>
<!-- <a href="javascript:;" class="layui-btn layui-btn-xs layui-btn-normal" onclick = "copyurl('<?php echo $tinyimg; ?>')">复制</a> -->
<a href="javascript:;" class="layui-btn layui-btn-xs layui-btn-danger" onclick = "deleteimg(<?php echo $id; ?>)">删除</a>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<!-- 表格END -->
</div>
<!-- 翻页按钮 -->
<div class="layui-col-lg9 layui-col-md-offset3">
<div class="page">
<a href="?type=<?php echo $type; ?>&page=<?php echo $up.$thepage; ?>" class="layui-btn">上一页</a>
<a href="?type=<?php echo $type; ?>&page=<?php echo $down.$thepage; ?>" class="layui-btn">下一页</a>
</div>
</div>
<!-- 翻页按钮END -->
<!-- 后台内容部分END -->
</div>
</div>
<!--图片查看-->
<div id="adminshow">
<div style = "margin-top:2em;"><center><img src="" alt=""></center></div>
<div id = "copy">
<center>
<table class="layui-table" lay-skin="nob">
<colgroup>
<col width="80">
<col width="520">
<col>
</colgroup>
<tbody>
<tr>
<td>URL</td>
<td><input type="text" class="layui-input" id="url" data-cip-id="url"></td>
<td><a href="javascript:;" class="layui-btn layui-btn-sm" onclick="newcopy('url')">复制</a></td>
</tr>
<tr>
<td>HTML</td>
<td><input type="text" class="layui-input" id="html" data-cip-id="html"></td>
<td><a href="javascript:;" class="layui-btn layui-btn-sm" onclick="newcopy('html')">复制</a></td>
</tr>
<tr>
<td>MarkDown</td>
<td><input type="text" class="layui-input" id="markdown" data-cip-id="markdown"></td>
<td><a href="javascript:;" class="layui-btn layui-btn-sm" onclick="newcopy('markdown')">复制</a></td>
</tr>
<tr>
<td>BBcode</td>
<td><input type="text" class="layui-input" id="bbcode" data-cip-id="bbcode"></td>
<td><a href="javascript:;" class="layui-btn layui-btn-sm" onclick="newcopy('bbcode')">复制</a></td>
</tr>
</tbody>
</table>
</center>
</div>
</div>
<!--图片查看-->
<?php
// 载入页脚
include_once("../tpl/admin/footer.php");
?>