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
+23
View File
@@ -0,0 +1,23 @@
<?php
// 后台「关于」弹窗(iframe)内容,版本号统一由 functions/version.php 提供
include_once("../config.php");
require_once __DIR__ . "/../functions/version.php";
?><!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
<meta charset="utf-8">
<title>关于 TinyImg</title>
<style>
body { margin: 0; padding: 12px 14px; font: 14px/1.8 -apple-system, "Microsoft YaHei", sans-serif; color: #444; }
h1 { font-size: 18px; margin: 0 0 4px; }
p { margin: 2px 0; }
.ver { color: #5FB878; font-weight: 600; }
small { color: #999; }
</style>
</head>
<body>
<h1><?php echo htmlspecialchars(TINYIMG_NAME, ENT_QUOTES, 'UTF-8'); ?></h1>
<p>当前版本:<span class="ver"><?php echo htmlspecialchars(TINYIMG_VERSION, ENT_QUOTES, 'UTF-8'); ?></span></p>
<p><small>第三方图床上传通道已关闭;API Token 请到「Token 设置」管理。</small></p>
</body>
</html>
+20
View File
@@ -0,0 +1,20 @@
<?php
error_reporting(E_ALL^E_NOTICE^E_WARNING^E_DEPRECATED);
include_once("../functions/class/class.admin.php");
//获取图片ID
$id = $_GET['id'];
$id = (int) $id;
if((!isset($id) || ($id == ''))) {
echo 'ID错误';
exit;
}
// TinyImg 2.0:SM.MS 记录删除通道已关闭,type=sm 一律不再处理
$type = isset($_GET['type']) ? $_GET['type'] : '';
if ($type === 'sm') {
echo '该功能已关闭';
exit;
}
$pic->delete($id);
?>
+60
View File
@@ -0,0 +1,60 @@
<?php
$title = "后台管理 - TinyImg";
include_once("../functions/class/class.admin.php");
// 载入头部
include_once("../tpl/admin/header.php");
//获取统计数据
$data = $pic->data();
?>
<div class="layui-container" style = "margin-top:2em;">
<div class="layui-row">
<div class="layui-col-lg3">
<!-- 载入左侧导航栏 -->
<?php include_once("../tpl/admin/left.php"); ?>
</div>
<!-- 后台内容部分 -->
<div class="layui-col-lg9">
<h1 style = "margin-bottom:0.8em;color:#515151">数据统计:</h1>
<!-- 后台数据统计 -->
<div id="tongji" class="layui-row layui-col-space18">
<div class="layui-col-lg4">
<div class="item">
<p></p><h2>累计上传</h2><p></p>
<p><?php echo $data['all']; ?> 张</p>
</div>
</div>
<div class="layui-col-lg4">
<div class="item">
<p></p><h2><i class="fa fa-street-view fa-fw"></i> 本月上传</h2><p></p>
<p><?php echo $data['month']; ?> 张</p>
</div>
</div>
<div class="layui-col-lg4">
<div class="item">
<p></p><h2><i class="fa fa-exclamation-triangle fa-fw"></i> 当日上传</h2><p></p>
<p><?php echo $data['day']; ?> 张</p>
</div>
</div>
<div class="layui-col-lg4">
<div class="item">
<a href="./senioradmin.php?type=dubious&page=1">
<p></p><h2><i class="fa fa-exclamation-triangle fa-fw"></i> 可疑图片</h2><p></p>
<p><?php echo $data['level']; ?> 张</p>
</a>
</div>
</div>
</div>
<!-- 后台数据统计END -->
</div>
<!-- 后台内容部分END -->
</div>
</div>
<?php
// 载入页脚
// 载入头部
include_once("../tpl/admin/footer.php");
?>
+39
View File
@@ -0,0 +1,39 @@
<?php
$title = "登录 - TinyImg";
// 简单的判断用户是否登录
if(isset($_COOKIE['user'])) {
header('Location:index.php');
}
?>
<?php
// 载入头部
include_once("../tpl/admin/header.php");
?>
<!-- 内容部分 -->
<div id="container">
<div class="layui-container">
<div class="layui-row">
<div class="layui-col-lg4 layui-col-md-offset4">
<!-- 登录表单 -->
<div class="login">
<div class="layui-form-item">
<input id = "user" type="text" name="title" required lay-verify="required" placeholder="用户名" autocomplete="off" class="layui-input">
</div>
<div class="layui-form-item">
<input id = "password" type="password" name="password" required lay-verify="required" placeholder="密码" autocomplete="off" class="layui-input">
</div>
<div class="layui-form-item">
<button class="layui-btn" lay-submit lay-filter="formDemo" onclick = "login()">登录</button>
</div>
</div>
<!-- 登录表单END -->
</div>
</div>
</div>
</div>
<!-- 内容部分end -->
<?php
// 载入页脚
// 载入头部
include_once("../tpl/admin/footer.php");
?>
+7
View File
@@ -0,0 +1,7 @@
<?php
//清除COOKIE
setcookie("user", '', time()-3600,"/");
setcookie("password", '', time()-3600,"/");
echo "<script>window.location.href = './login.php'</script>";
?>
+26
View File
@@ -0,0 +1,26 @@
<?php
include_once("../functions/class/class.admin.php");
//获取操作类型
$type = $_GET['type'];
//获取图片ID
$id = $_GET['id'];
$id = (int) $id;
if((!isset($id) || ($id == ''))) {
echo 'ID错误';
exit;
}
//判断需要操作的类型
switch ($type) {
case 'cdubious':
//取消图片可疑状态
$pic->cdubious($id);
break;
default:
# code...
break;
}
?>
+82
View File
@@ -0,0 +1,82 @@
<?php
$title = "后台管理 - TinyImg";
include_once("../functions/class/class.admin.php");
// 载入头部
include_once("../tpl/admin/header.php");
// 获取类型
$type = $_GET['type'];
//获取时间
@$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 = '';
}
//获取页数
$page = $_GET['page'];
//查询图片
$imgs = $pic->newquery($type,$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 layui-col-space10" style="margin-bottom:6em;">
<!--时间筛选-->
<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('picadmin.php')">筛选</button></td>
</tr>
</tbody>
</table>
</div>
<!--时间筛选END-->
<?php foreach ($imgs as $img) {
$tinyimg = $config['domain'].$img['path'];
$id = $img['id'];
?>
<div class="layui-col-lg4 picadmin">
<!-- <a id = "imgid<?php echo $id; ?>" href="javascript:;" onclick = "adminshow('<?php echo $tinyimg ?>',<?php echo $id; ?>)"></a> -->
<img lay-src="<?php echo $tinyimg; ?>" layer-src="<?php echo $tinyimg; ?>" alt="图片ID: <?php echo $id; ?>" src = "../static/loading32.gif">
</div>
<?php } ?>
</div>
<!-- 翻页按钮 -->
<!-- 翻页按钮END -->
<!-- 后台内容部分END -->
</div>
</div>
<?php
// 载入页脚
// 载入头部
include_once("../tpl/admin/footer.php");
?>
+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");
?>
+309
View File
@@ -0,0 +1,309 @@
<?php
/**
* TinyImg 后台 —— API Token 设置页
*
* 权限:复用 class.admin.php 的登录校验(未登录直接跳登录页)。
* 防护:所有写操作校验 Session CSRF,Token 只在本页显示,不写进任何前端静态文件。
*/
session_start();
require_once __DIR__ . '/../functions/version.php';
require_once __DIR__ . '/../functions/token.php';
// 载入后台鉴权(同时带来 $config / $database / $pic)
include_once("../functions/class/class.admin.php");
if (empty($_SESSION['tinyimg_csrf'])) {
$_SESSION['tinyimg_csrf'] = tinyimg_token_generate(16);
}
$csrf = $_SESSION['tinyimg_csrf'];
$flash = isset($_SESSION['tinyimg_flash']) ? $_SESSION['tinyimg_flash'] : [];
unset($_SESSION['tinyimg_flash']);
if (strtoupper(isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : '') === 'POST') {
$ok = isset($_POST['csrf']) && is_string($_POST['csrf'])
&& hash_equals($csrf, $_POST['csrf']);
$action = isset($_POST['action']) ? (string) $_POST['action'] : '';
$state = tinyimg_token_load($config);
if (!$ok) {
$_SESSION['tinyimg_flash'] = ['error', '安全校验失败,请刷新页面后重试'];
} elseif ($action === 'regenerate') {
list($ok2, $msg) = tinyimg_token_save(tinyimg_token_generate(32), true, $config);
$_SESSION['tinyimg_flash'] = $ok2
? ['ok', '已生成新的 API Token,请同步更新 Typecho 插件设置']
: ['error', '保存失败:' . $msg];
} elseif ($action === 'save') {
$custom = isset($_POST['custom_token']) ? trim((string) $_POST['custom_token']) : '';
if (!tinyimg_token_valid_format($custom)) {
$_SESSION['tinyimg_flash'] = ['error',
'Token 格式不合法:只允许 16~128 位字母、数字、下划线、短横线'];
} else {
list($ok2, $msg) = tinyimg_token_save($custom, true, $config);
$_SESSION['tinyimg_flash'] = $ok2
? ['ok', '自定义 API Token 已保存并启用']
: ['error', '保存失败:' . $msg];
}
} elseif ($action === 'toggle') {
if ($state['token'] === '' && empty($state['enabled'])) {
$_SESSION['tinyimg_flash'] = ['error', '尚未设置 Token,请先生成或填入'];
} else {
$next = empty($state['enabled']) ? true : false;
list($ok2, $msg) = tinyimg_token_save($state['token'], $next, $config);
$_SESSION['tinyimg_flash'] = $ok2
? ['ok', $next ? 'Token 上传已启用' : 'Token 上传已停用(原有网页上传不受影响)']
: ['error', '保存失败:' . $msg];
}
} elseif ($action === 'reveal') {
// 完整 Token 不写进页面 HTML(避免留在源码 / 浏览器缓存 / 截图中)。
// 只有已登录且通过 CSRF 的会话,才能在点「显示 / 复制」时按需取一次。
header('Content-Type: application/json; charset=utf-8');
echo json_encode(['code' => 1, 'token' => $state['token']], JSON_UNESCAPED_UNICODE);
exit;
} elseif ($action === 'clear') {
list($ok2, $msg) = tinyimg_token_save('', false, $config);
$_SESSION['tinyimg_flash'] = $ok2
? ['ok', 'Token 已清空并停用']
: ['error', '保存失败:' . $msg];
} else {
$_SESSION['tinyimg_flash'] = ['error', '未知操作'];
}
header('Location: setting.php');
exit;
}
$state = tinyimg_token_load($config);
$title = "Token 设置 - TinyImg";
include_once("../tpl/admin/header.php");
$enabled = !empty($state['enabled']) && $state['token'] !== '';
$sourceText = $state['source'] === 'file'
? 'Token 存储文件(db/tinyimg-token.php)'
: ($state['source'] === 'config'
? 'config.php 的 api_token(兼容旧版,保存一次后自动接管)'
: '尚未配置');
$esc = function ($value) {
return htmlspecialchars((string) $value, ENT_QUOTES, 'UTF-8');
};
?>
<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 class="layui-col-lg9">
<h1 style="margin-bottom:.6em;color:#515151;font-size:22px;">API Token 设置</h1>
<?php if (!empty($flash)) { ?>
<div class="msg" style="border-left:4px solid <?php echo $flash[0] === 'ok' ? '#5FB878' : '#FF5722'; ?>;">
<?php echo $esc($flash[1]); ?>
</div>
<?php } ?>
<table class="layui-table" lay-skin="nob">
<tbody>
<tr>
<td style="width:130px;">当前状态</td>
<td>
<?php if ($enabled) { ?>
<span style="color:#5FB878;font-weight:600;">● 已启用</span>
<?php } elseif ($state['token'] !== '') { ?>
<span style="color:#FFB800;font-weight:600;">● 已停用</span>
<?php } else { ?>
<span style="color:#FF5722;font-weight:600;">● 未设置</span>
<?php } ?>
<span style="color:#999;margin-left:1em;"><?php echo $esc(TINYIMG_NAME . ' ' . TINYIMG_VERSION); ?></span>
</td>
</tr>
<tr>
<td>当前 Token</td>
<td>
<div style="display:flex;gap:8px;align-items:center;flex-wrap:wrap;">
<input type="password" id="ti-token" class="layui-input"
style="max-width:460px;font-family:monospace;"
value="<?php echo $esc($state['token'] === '' ? '' : tinyimg_token_mask($state['token'])); ?>"
data-masked="<?php echo $esc($state['token'] === '' ? '' : tinyimg_token_mask($state['token'])); ?>"
readonly>
<button type="button" class="layui-btn layui-btn-primary layui-btn-sm" id="ti-reveal"
<?php echo $state['token'] === '' ? 'disabled' : ''; ?>>显示</button>
<button type="button" class="layui-btn layui-btn-primary layui-btn-sm" id="ti-copy"
<?php echo $state['token'] === '' ? 'disabled' : ''; ?>>复制</button>
</div>
<p style="color:#999;margin-top:6px;">
脱敏视图:<?php echo $esc(tinyimg_token_mask($state['token'])); ?>
· 长度 <?php echo strlen($state['token']); ?> 位
· 完整值不写入页面,点「显示」时才向服务器取一次
</p>
</td>
</tr>
<tr>
<td>来源</td>
<td><?php echo $esc($sourceText); ?></td>
</tr>
<tr>
<td>创建 / 更新</td>
<td><?php echo $esc(($state['created_at'] ?: '—') . ' / ' . ($state['updated_at'] ?: '—')); ?></td>
</tr>
</tbody>
</table>
<div style="margin:1.4em 0 .6em;font-weight:600;">管理操作</div>
<div style="display:flex;gap:8px;flex-wrap:wrap;">
<form method="post" style="display:inline;">
<input type="hidden" name="csrf" value="<?php echo $esc($csrf); ?>">
<input type="hidden" name="action" value="regenerate">
<button type="submit" class="layui-btn layui-btn-normal"
onclick="return confirm('重新生成后旧 Token 立即失效,Typecho 插件需要同步更新。继续?');">
重新生成 Token
</button>
</form>
<form method="post" style="display:inline;">
<input type="hidden" name="csrf" value="<?php echo $esc($csrf); ?>">
<input type="hidden" name="action" value="toggle">
<button type="submit" class="layui-btn layui-btn-primary">
<?php echo $enabled ? '停用 Token 上传' : '启用 Token 上传'; ?>
</button>
</form>
<form method="post" style="display:inline;">
<input type="hidden" name="csrf" value="<?php echo $esc($csrf); ?>">
<input type="hidden" name="action" value="clear">
<button type="submit" class="layui-btn layui-btn-primary"
onclick="return confirm('确认清空 Token?清空后插件的 Token 上传会立即被拒绝。');">
清空
</button>
</form>
</div>
<div style="margin:1.6em 0 .6em;font-weight:600;">填入自定义 Token</div>
<form method="post" style="display:flex;gap:8px;flex-wrap:wrap;align-items:center;">
<input type="hidden" name="csrf" value="<?php echo $esc($csrf); ?>">
<input type="hidden" name="action" value="save">
<input type="text" name="custom_token" class="layui-input" style="max-width:460px;font-family:monospace;"
placeholder="16~128 位字母 / 数字 / _ / -" required>
<button type="submit" class="layui-btn">保存并启用</button>
</form>
<div style="margin:1.8em 0 .6em;font-weight:600;">给 Typecho 插件的连接信息</div>
<table class="layui-table" lay-skin="nob">
<tbody>
<tr><td style="width:130px;">上传接口</td><td><code>functions/upload.php</code>(与网页上传同一个文件)</td></tr>
<tr><td>鉴权请求头</td><td><code>X-TinyImg-Token: &lt;本页的 Token&gt;</code></td></tr>
<tr><td>身份</td><td>Token 校验通过即按管理员上传:进 <code>upload/</code>,跳过游客每日配额</td></tr>
<tr><td>连接自检</td><td><code>functions/upload.php?ping=1</code>,插件设置里的「测试连接」按钮会调用它</td></tr>
</tbody>
</table>
<pre style="background:#f7f7f7;padding:12px;border-radius:4px;overflow:auto;font-size:12px;">curl -sS -X POST "https://你的域名/functions/upload.php?ping=1" \
-H "X-TinyImg-Token: &lt;你的 Token&gt;"</pre>
<div class="msg" style="margin-top:1.2em;">
<i class="layui-icon">&#xe645;</i>
安全提示:Token 只被上传接口识别,泄露也只能上传图片,不影响后台登录;请务必使用 HTTPS,
不要提交到公开仓库。轮换后记得同步修改 Typecho 插件设置,并用「测试连接」验证。
存储文件已用 <code>&lt;?php exit;</code> 守卫,直接访问 URL 不会输出内容。
</div>
</div>
</div>
</div>
<script>
(function () {
var input = document.getElementById('ti-token');
var reveal = document.getElementById('ti-reveal');
var copy = document.getElementById('ti-copy');
if (!input) { return; }
// 完整 Token 不在页面里,按需向服务器取一次(带 CSRF,同源 POST)
var real = null;
var csrfEl = document.querySelector('input[name="csrf"]');
function fetchToken(cb) {
if (real !== null) { cb(real); return; }
if (!csrfEl) { cb(null); return; }
var body = new URLSearchParams();
body.set('csrf', csrfEl.value);
body.set('action', 'reveal');
fetch('setting.php', {
method: 'POST',
body: body,
credentials: 'same-origin',
headers: { 'X-Requested-With': 'XMLHttpRequest' }
}).then(function (res) { return res.json(); }).then(function (data) {
if (data && data.code === 1 && typeof data.token === 'string') {
real = data.token;
cb(real);
} else {
cb(null);
}
}).catch(function () { cb(null); });
}
function showMasked() {
input.type = 'password';
input.value = input.getAttribute('data-masked') || '';
if (reveal) { reveal.textContent = '显示'; }
}
if (reveal) {
reveal.onclick = function () {
if (input.type === 'text') { showMasked(); return; }
reveal.disabled = true;
fetchToken(function (token) {
reveal.disabled = false;
if (token === null) { reveal.textContent = '取回失败'; return; }
input.type = 'text';
input.value = token;
reveal.textContent = '隐藏';
});
};
}
if (copy) {
copy.onclick = function () {
copy.disabled = true;
fetchToken(function (token) {
copy.disabled = false;
if (token === null) { copy.textContent = '取回失败'; return; }
var done = function () {
copy.textContent = '已复制';
setTimeout(function () { copy.textContent = '复制'; }, 1500);
};
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(token).then(done, function () {
copyViaInput(token, done);
});
} else {
copyViaInput(token, done);
}
});
};
}
function copyViaInput(token, done) {
var prevValue = input.value;
var prevType = input.type;
input.type = 'text';
input.value = token;
input.select();
try {
document.execCommand('copy');
done();
} catch (e) {
copy.textContent = '请手动复制';
}
input.type = prevType;
input.value = prevValue;
}
})();
</script>
<?php
include_once("../tpl/admin/footer.php");
?>
+24
View File
@@ -0,0 +1,24 @@
<?php
// TinyImg 2.0:SM.MS 图片管理已下线,保留页面给出明确说明,不再查询数据库。
$title = "功能已关闭 - TinyImg";
include_once("../functions/class/class.admin.php");
include_once("../tpl/admin/header.php");
?>
<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 class="layui-col-lg9">
<div class="msg"><i class="layui-icon">&#xe645;</i>
第三方 SM.MS 图片的查看 / 删除功能已在 TinyImg 2.0 中关闭。
历史数据仍保留在数据库里,但程序不再读取或调用其删除接口。
</div>
</div>
</div>
</div>
<?php
include_once("../tpl/admin/footer.php");
?>
+30
View File
@@ -0,0 +1,30 @@
<?php
// TinyImg 2.0:本页只保留 URL 批量上传,不再查询 / 预览第三方图床记录
$title = "URL批量上传 - TinyImg";
include_once("../functions/class/class.admin.php");
include_once("../tpl/admin/header.php");
?>
<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">
<table class="layui-table">
<div class="msg" style = "margin-top:0;"><i class="layui-icon">&#xe645;</i> 请输入图片地址,一行一个,一次不超过10个</div>
<div class="urltext">
<textarea rows="10" id = "arrurl" name="desc" placeholder="请输入图片地址,一行一个" class="layui-textarea"></textarea>
</div>
<div style = "margin-top:1em;">
<a href="javascript:;" class="layui-btn" onclick = "urlup()">开始上传</a>
</div>
</table>
</div>
</div>
</div>
</div>
<?php
include_once("../tpl/admin/footer.php");
?>