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
+16
View File
@@ -0,0 +1,16 @@
# 统一按 LF 存储,避免 Windows 检出成 CRLF 后部署到 Linux 出问题
* text=auto eol=lf
# 二进制文件不做换行转换
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.ico binary
*.webp binary
*.db3 binary
*.woff binary
*.woff2 binary
*.ttf binary
*.eot binary
*.pem binary
+18
View File
@@ -0,0 +1,18 @@
# ---- 运行时目录(安装后产生,不入库) ----
/temp/
/upload/
/1808/
# ---- 安装时生成的配置:含管理员账号与密码,绝不入库 ----
/config.php
# ---- 运行时数据库与上传 Token ----
# 只保留空模板 tinyimg-simple.db3 与安全守卫 .htaccess
/db/*
!/db/.htaccess
!/db/tinyimg-simple.db3
# ---- 系统 / 编辑器杂物 ----
.DS_Store
Thumbs.db
*.log
+1
View File
@@ -0,0 +1 @@
ErrorDocument 404 /static/404.svg
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2017 J3n5en
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+195 -2
View File
@@ -1,3 +1,196 @@
# TinyImg
# TinyImg 2.0.0
TinyImg私人图床
TinyImg 是一款简单、纯粹的图床程序,使用 PHP + SQLite 3 开发,开箱即用。
2.0.0 是基于 1.40 的定制版:更名、去掉第三方图床上传、加入后台可视化 API Token 管理。
---
## 1. 本次变更一览
| # | 变更 | 说明 |
|---|---|---|
| 1 | 程序更名 | 全站品牌改为 **TinyImg**,源码里不再出现旧品牌字样(含变量名、数据库文件名、静态文件名、md5 盐、外部链接) |
| 2 | 版本号 | `v1.40(20181106)` → **`v2.0.0(20261104)`**,统一由 `functions/version.php` 提供 |
| 3 | SM.MS 下线 | 上传页选项卡、前台导航、后台菜单、JS 上传逻辑、回写接口、删除接口全部移除或 fail closed |
| 4 | Token 设置页 | 后台新增「Token 设置」:显示 / 隐藏 / 复制 / 重新生成 / 自定义 / 启停 / 清空,带 Session CSRF |
| 5 | Token 存储 | `db/tinyimg-token.php`,首行 `<?php exit;` 守卫,直接访问 URL 不会泄漏;兼容旧 `config.php` 的 `api_token` |
| 6 | 连接自检 | `functions/upload.php?ping=1`,只校验 Token 不接收文件,返回版本与管理员目录 |
| 7 | PHP 8 兼容 | 修复第三方 `class.upload.php` 的花括号字符串下标写法 |
| 8 | Cookie 盐 | `md5("tinyimg" + 密码)`;**升级后旧登录态失效,需重新登录** |
> 版本字符串只存在 `functions/version.txt` 一处;后台关于弹窗、页脚、上传自检都读它。
---
## 2. 破坏性变更(升级前必读)
| 项 | 旧版 | 2.0.0 | 影响 |
|---|---|---|---|
| 鉴权请求头 | `X-` 开头的旧头 | **`X-TinyImg-Token`** | 旧版 Typecho 插件必须同步升级,否则 Token 上传失败 |
| 管理员 Cookie 盐 | 旧盐 | `md5("tinyimg" + 密码)` | 已登录后台的浏览器 Cookie 失效,重新登录一次即可 |
| 数据库文件名 | 旧 `.db3` | `db/tinyimg.db3` | **不影响已有站点**:你服务器上的 `config.php` 仍指向旧文件,照常可用;全新安装才用新文件名 |
| `config.php` 的 `api_token` | 唯一来源 | 兼容回退 | 首次打开「Token 设置」并保存一次后,改由 `db/tinyimg-token.php` 接管 |
| SM.MS | 可用 | 已关闭 | 上传页不再有该入口,历史数据仍留在库中但不再读取 |
---
## 3. 部署 / 升级
### 3.1 从 1.40 / 打了补丁的旧版升级
1. **备份**:整个图床目录 + `config.php` + `db/*.db3`。
2. 把 `TinyImg-2.0.0.zip` 解压覆盖到站点目录(**不要删除 `config.php` 和 `db/` 里已有的 `.db3`**)。
3. 若你的旧 `config.php` 里已有 `api_token`,无需改动:新程序会自动接管。
4. 浏览器打开 `admin/login.php` 重新登录(Cookie 盐变了)。
5. 进入 **后台 → Token 设置**:确认显示旧 Token 或点「重新生成 Token」。
6. 同步更新 Typecho 插件设置里的 Token,并用插件的「测试连接」验证。
### 3.2 全新安装
1. 解压到站点根目录,访问 `check.php` 记录绝对路径。
2. 访问 `install.php` 完成安装向导(会自动生成 `config.php`,并把 `db/tinyimg-simple.db3` 复制为 `db/tinyimg.db3`)。
3. 安装完成后删除 `check.php`;`install.php` 会被自动改名为 `.bak`。
4. 登录后台 → Token 设置 → 生成 API Token。
### 3.3 Nginx 安全规则
Apache 的 `db/.htaccess` 已拒绝整个目录;Nginx 请补充:
```nginx
location ~* \.(db3|json)$ { deny all; }
location ~* ^/(temp|upload)/.*\.(php|php5)$ { deny all; }
```
Token 存储文件是 `.php` 且首行 `exit`,即使规则遗漏也不会通过 URL 泄漏内容。
---
## 4. API Token 管理
### 4.1 后台设置页
入口:后台顶部导航或左侧「系统设置 → Token 设置」,即 `admin/setting.php`。
| 能力 | 说明 |
|---|---|
| 显示当前 Token | **完整值不写入页面 HTML**,默认只渲染掩码(如 `Secret****cdef`)与长度;点「显示」/「复制」时才带 CSRF 向服务器取一次 |
| 重新生成 | 用 CSPRNG 生成 64 位十六进制串,旧 Token 立即失效 |
| 自定义 | 填入 16~128 位字母 / 数字 / `_` / `-`,保存并启用 |
| 启用 / 停用 | 停用后带 Token 的请求一律拒绝,但**网页正常上传不受影响** |
| 清空 | 删除 Token 并停用 |
| 状态信息 | 创建 / 更新时间、来源(存储文件 / 旧 `config.php` / 未配置)、版本号 |
所有写操作都校验 Session CSRF,且只有已登录后台的管理员可访问。
> 为什么默认不显示明文:设置页早期版本把 Token 直接写进 `input` 的 `value` 属性,
> 于是页面源码、浏览器缓存、录屏/截图里都会长期留着可用凭证。现在的做法是
> 默认只输出掩码,完整值由 `POST action=reveal` 按需返回(同源、带 CSRF、
> 仅当前登录会话)。这条约束由 `tests/setting_test.php` 断言,包含「错误 CSRF
> 必须拿不到 Token」的反证。
### 4.2 上传接口
```
POST /functions/upload.php
HEADER X-TinyImg-Token: <Token>
BODY multipart/form-data,文件字段名 file
```
| 情况 | 行为 |
|---|---|
| Token 校验通过 | 视为管理员上传:进 `admindir`(默认 `upload/`),跳过 `limitnum()` 每日配额,不要求 Referer / 登录 Cookie |
| Token 错误 / 未配置 / 已停用 | 立即返回 `{"code":0,"msg":"..."}`,**fail closed,绝不静默降级为游客上传** |
| 不带 Token | 完全保留原有逻辑:Referer 校验 + 登录 Cookie 判定 + 游客配额 |
成功返回:`{"code":1,"id":9,"url":"https://...","width":800,"height":600}`。
### 4.3 连接自检(给插件「测试连接」用)
```bash
curl -sS -X POST "https://你的域名/functions/upload.php?ping=1" \
-H "X-TinyImg-Token: 你的Token"
# {"code":1,"msg":"Token 有效","name":"TinyImg","version":"v2.0.0(20261104)","admin_dir":"upload",...}
```
`?ping=1` 不接收文件、不写数据库,只验证 Token 并返回版本与管理员目录。
缺少 Token、Token 无效、Token 已停用时都会返回 `code:0`。
### 4.4 手工验证真实上传
```bash
curl -sS -X POST "https://你的域名/functions/upload.php" \
-H "X-TinyImg-Token: 你的Token" \
-F "[email protected];type=image/png"
# 正确时 url 里应含 /upload/
```
---
## 5. SM.MS 功能屏蔽清单
| 位置 | 处理 |
|---|---|
| `miniup.html` | 删除 SM.MS 选项卡与文件输入,只保留本站上传 + 关于 |
| `tpl/user/header.php` | 删除 SM.MS 导航项,外链改为站内 |
| `tpl/admin/left.php` / `header.php` | 删除 SM.MS 菜单,新增 Token 设置入口 |
| `static/embed.js` | 删除指向第三方上传 API 的 `upload.render`,删除 `smshow` / `deletesm` |
| `sm.php` | 返回 HTTP 410 + 明确说明,不再渲染上传表单 |
| `functions/sm.php` | HTTP 410 + `{"code":0,...}`,不载入类、不写数据库 |
| `admin/smadmin.php` | 只显示下线说明,不再查询数据库 |
| `admin/delete.php` | `type=sm` 明确拒绝 |
| `functions/class/class.admin.php` | 移除 `querysm()` / `deletesm()` |
| `upgrade.php` | 不再创建 `sm` 表 |
历史 `sm` 表数据保留,不删除、不迁移。
---
## 6. 命名与版本
| 内容 | 新值 |
|---|---|
| 品牌 | `TinyImg` |
| 版本文件 | `functions/version.txt` → `v2.0.0(20261104)` |
| 版本常量 | `TINYIMG_NAME` / `TINYIMG_VERSION`(`functions/version.php`) |
| 数据库模板 | `db/tinyimg-simple.db3` → `db/tinyimg.db3` |
| 油猴脚本 | `static/tinyimg.js`(顶部 `TINYIMG_BASE` 改成你的站点地址) |
| Token 请求头 | `X-TinyImg-Token` |
| 登录 Cookie 盐 | `md5("tinyimg" + 密码)` |
---
## 7. 安全说明
1. Token 只被上传端点与 `?ping=1` 识别;后台管理仍只认登录 Cookie,Token 泄露**无法进入后台**。
2. 比较用 `hash_equals`;空配置、停用、空请求一律拒绝。
3. 全站请启用 HTTPS,避免 Token 在传输中泄露。
4. Token 可随时在后台轮换,不必改动管理员密码;轮换后记得同步 Typecho 插件。
5. `functions/api.php` 是保留的旧版兼容上传 API,带 `Access-Control-Allow-Origin: *`,仍走游客配额;如不需要可直接删除或加访问限制。
---
## 8. 验证命令
在 `TinyImgUploader/` 目录下执行(不需要 Typecho、不需要联网):
```bash
php tests/host_test.php # 更名 / 版本 / SM.MS 下线 / 设置页 / 静态资源
php tests/token_test.php # Token 纯函数 + 上传端点契约 + 错误实现反证
php tests/auth_test.php # Cookie 回退方案契约
php tests/util_test.php # 响应解析 / ping 地址
php tests/render_test.php # 插件侧栏与测试按钮渲染
php tests/setting_test.php # 设置页渲染:完整 Token 不入 HTML、reveal 必须校验 CSRF
# 命令行连通性自检(需要 PHP 的 curl 或 openssl 扩展)
php tools/probe.php --url=https://你的域名/functions/upload.php --token=你的Token --ping
php tools/probe.php --url=https://你的域名/functions/upload.php --token=你的Token --file=./test.png
```
---
## 9. 已知限制
- 上传大小仍硬编码 2 MB(`functions/upload.php` 的 `file_max_size`)。
- `db/tinyimg-token.php` 需要 `db/` 目录对 Web 用户可写;不可写时设置页会给出明确错误。
- 游客上传的每日配额、图片压缩、鉴黄等沿用原有逻辑,本次未改动。
- `?ping=1` 是一个 Token 有效性判据端点,请配合 HTTPS;若担心被探测,可在反向代理层限制该 URL 的访问来源。
+35
View File
@@ -0,0 +1,35 @@
<?php
require_once __DIR__ . "/functions/version.php";
$title = "关于 TinyImg " . TINYIMG_VERSION;
include_once("./tpl/user/header.php");
?>
<div class="layui-container">
<div class="layui-row">
<div class="layui-col-lg10 layui-col-md-offset1" id = "about">
<h1>TinyImg <small style="font-size:14px;color:#5FB878;"><?php echo htmlspecialchars(TINYIMG_VERSION, ENT_QUOTES, 'UTF-8'); ?></small></h1>
<p>TinyImg 是一款简洁、纯粹的图床程序,使用 PHP + SQLite 开发,开箱即用。</p>
<h3>功能与特色</h3>
<ul>
<li>拖拽上传、粘贴上传、实时预览</li>
<li>一键生成链接,一键复制</li>
<li>图片管理与 URL 批量上传</li>
<li>后台可视化管理 API Token</li>
<li>配合 Typecho 插件在撰写页一键插图</li>
</ul>
<h3>使用说明</h3>
<ul>
<li>单张图片最大 2 MB</li>
<li>游客每天上传数量由后台配置限制</li>
<li>第三方图床上传通道已在 2.0 中关闭,所有图片仅存本站</li>
<li>勿上传违规图片</li>
</ul>
<h3>致谢</h3>
<p>基于开源图床程序二次开发,保留原作者署名:<a href="https://www.xiaoz.me/" target = "_blank" rel = "nofollow">xiaoz.me</a>。</p>
</div>
</div>
</div>
<?php
include_once("./tpl/user/footer.php");
?>
+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");
?>
+34
View File
@@ -0,0 +1,34 @@
<?php
echo "<h1>请将以下信息填写到配置文件config.php</h1>";
//获取当前端口
$port = $_SERVER["SERVER_PORT"];
//对端口进行判断
switch ( $port )
{
case 80:
$protocol = "http://";
$port = '';
break;
case 443:
$protocol = "https://";
$port = '';
break;
default:
$protocol = "http://";
$port = ":".$port;
break;
}
//获取项目绝对路径
$thedir = __DIR__;
$thedir = str_replace("\\","/",$thedir).'/';
echo "项目绝对路径:".$thedir."<br />";
//或如URI
$uri = $_SERVER["REQUEST_URI"];
$uri = str_replace("check.php","",$uri);
//组合为完整的URL
$domain = $protocol.$_SERVER['SERVER_NAME'].$port.$uri;
echo "当前域名为:".$domain;
echo "<h1>配置完成后测试网站功能正常,请删除此文件。</h1>";
?>
+39
View File
@@ -0,0 +1,39 @@
<?php
//项目绝对路径
define("APP","homedir");
//载入数据库类
include_once(APP."functions/class/Medoo.php");
$config = array(
"domain" => "https://img.example.com/", //站点地址
"user" => "imguser", //管理员账号
"password" => "imgpass", //管理员密码
"api_token" => "", //兼容旧版:留空即可;TinyImg 2.0 请在后台「Token 设置」页生成/管理
"limit" => 5, //游客上传数量限制
"watermark" => "your.domain", //图片文字水印
"userdir" => "temp", //游客上传目录,一般不用做修改
"admindir" => "upload", //管理员上传目录,一般不用做修改
"datadir" => APP."db/tinyimg.db3" //数据库路径,一般不用做修改
);
// TinyPNG压缩图片
$tinypng = array(
"option" => false,
"key" => array(
"xxx", //TinyPNG API KEY,支持填写多行key
"xxx" //如果只有一个key,请删除此行
)
);
//ModerateContent 图片鉴黄(可选功能,默认关闭)
$ModerateContent = array(
"option" => false,
"key" => "xxx"
);
//初始化Medoo
use Medoo\Medoo;
$database = new medoo([
'database_type' => 'sqlite',
'database_file' => $config['datadir']
]);
?>
+2
View File
@@ -0,0 +1,2 @@
order allow,deny
deny from all
Binary file not shown.
+96
View File
@@ -0,0 +1,96 @@
<?php
error_reporting(E_ALL^E_NOTICE^E_WARNING^E_DEPRECATED);
//载入配置文件
include_once("./config.php");
//载入TinyPNG
require_once("functions/tinypng/Tinify/Exception.php");
require_once("functions/tinypng/Tinify/ResultMeta.php");
require_once("functions/tinypng/Tinify/Result.php");
require_once("functions/tinypng/Tinify/Source.php");
require_once("functions/tinypng/Tinify/Client.php");
require_once("functions/tinypng/Tinify.php");
//初始化值
$dispose['compress'] = 0;
$dispose['level'] = 0;
//获取ID
$id = $_GET['id'];
$id = (int)$id;
//获取tinypng key
$tinykey = array_rand($tinypng['key']); //取出数组键值
$tinykey = $tinypng['key'][$tinykey];
//获取ModerateContent key
$mckey = $ModerateContent['key'];
//如果ID不存在或为空
if((!isset($id)) || ($id == '')) {
echo 'ID错误!';
exit;
}
//查询对应信息
$info = $database->get("imginfo",[
"id",
"path",
"compress",
"level"
],[
"id" => $id
]);
//组合为完整的URL地址
$tinyimg = $config['domain'].$info['path'];
//获取压缩状态
$compress = $info['compress'];
//获取图片等级
$level = $info['level'];
//获取文件后缀名
$suffix = substr(strrchr($info['path'], '.'), 1);
//后缀变为小写
$suffix = strtolower($suffix);
if(($suffix == 'png') || ($suffix == 'jpg') || ($suffix == 'jpeg')) {
$iscompress = 1;
}
//对图片进行压缩
if(($tinypng['option'] == true) && ($iscompress == 1) && ($compress == 0)) {
//初始化
\Tinify\setKey($tinykey);
$source = \Tinify\fromUrl($tinyimg);
//覆盖原有图片
$source->toFile($info['path']);
//更新数据库
$database->update("imginfo",[
"compress" => 1
],[
"id" => $id
]);
$dispose['compress'] = 1;
}
//对图片进行鉴黄
if(($ModerateContent['option'] == true) && ($level == 0)) {
$apiurl = "https://www.moderatecontent.com/api/v2?key=".$mckey."&url=".$tinyimg;
$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.117 Safari/537.36");
curl_setopt($curl, CURLOPT_FAILONERROR, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
$html = curl_exec($curl);
curl_close($curl);
//更新数据库
$html = json_decode($html);
$level = $html->rating_index;
$database->update("imginfo",["level" => $level],["id" => $id]);
$dispose['level'] = $level;
}
//返回json数据
$dispose['code'] = 1;
$dispose = json_encode($dispose);
echo $dispose;
?>
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

+39
View File
@@ -0,0 +1,39 @@
<?php
$title = "探索发现 - TinyImg";
include_once("./tpl/user/header.php");
// 载入类
include_once("config.php");
//获取当前时间
$thetime = date('Y-m',time());
//初始化
$domain = $config['domain'];
$userdir = $config['userdir'];
//$sql = "SELECT `id`,`path` FROM `imginfo` WHERE (`dir` = '$userdir' AND `level` < 3 AND `date` LIKE '$thetime%') ORDER BY random() LIMIT 12";
$sql = "SELECT `id`,`path` FROM `imginfo` WHERE (`dir` = '$userdir' AND `level` < 3 AND `date` LIKE '$thetime%') ORDER BY `id` DESC";
$datas = $database->query($sql)->fetchAll();
?>
<div class="layui-container" style = "margin-bottom:6em;">
<div class="layui-row">
<div class="msg"><i class="layui-icon">&#xe645;</i> 此页面显示本月上传图片,如果不显示说明本月暂未上传图片。</div>
<div id = "found-img" class = "layui-col-space20">
<?php foreach ($datas as $img) {
$tinyimg = $domain.$img['path'];
$imgid = $img['id'];
?>
<div class="layui-col-lg4">
<!-- <a href="javascript:;" onclick = "userpreview('<?php echo $tinyimg ?>',<?php echo $imgid; ?>)"></a> -->
<img lay-src="<?php echo $tinyimg ?>" layer-src="<?php echo $tinyimg ?>" src = "./static/loading32.gif">
</div>
<?php } ?>
</div>
</div>
</div>
<?php
include_once("./tpl/user/footer.php");
?>
Binary file not shown.
+27
View File
@@ -0,0 +1,27 @@
<?php
// 控制器
// 载入类
include_once("class/class.user.php");
$type = $_GET['type'];
switch ($type) {
case 'login':
// 用户登录时输入的信息
$user = array(
"user" => $_POST['user'],
"password" => $_POST['password']
);
// 配置文件里面的用户信息
$admin = array(
"user" => $config['user'],
"password" => $config['password']
);
$basis->login($user,$admin);
break;
case 'check':
$basis->check($config);
break;
default:
# code...
break;
}
?>
+120
View File
@@ -0,0 +1,120 @@
<?php
/*
name:TinyImg 兼容上传 API
version:v2.0.0
update:2026-11-04
说明:保留旧版 API 通道;推荐使用 functions/upload.php + X-TinyImg-Token
*/
header('Access-Control-Allow-Origin:*');
//载入配置文件
include_once("./class/class.user.php");
@$type = $_GET['type'];
$type = strip_tags($type);
//如果没有post文件
if(!$_FILES['file']){
$basis->re_error('未选择文件!');
}
//检查用户是否登录
$status = $basis->check($config);
//检查用户是否登陆来判断上传目录
if($status == 'islogin') {
//设置上传路径
$updir = $config['admindir'];
}
else{
$updir = $config['userdir'];
//限制用户上传数量
$basis->limitnum();
}
//获取上传者信息
$ip = $basis->getip();
$ua = $_SERVER['HTTP_USER_AGENT'];
$date = date('Y-m-d',time());
//载入上传类
include('./class/class.upload.php');
//上传方法
$handle = new upload($_FILES['file']);
if ($handle->uploaded) {
$handle->file_new_name_body = 'image_resized';
//允许上传大小2m
$handle->file_max_size = '2097152';
//允许的MIME类型,仅运行上传图片
$handle->allowed = array('image/*');
// 当前月份
$current_time = date('ym',time());
//上传路径:目录 + 时间
$handle->process('../'.$updir.'/'.$current_time."/");
if ($handle->processed) {
//获取站点域名
$domain = $config['domain'];
//生成文件hash
$fhash = hash_file("md5",$handle->file_dst_pathname,FALSE);
$fhash = substr($fhash,8,16);
//新的文件名(../temp/1804/\d64c8036c0605175.jpg)
$new_img = $handle->file_dst_path.$fhash.'.'.$handle->file_dst_name_ext;
//图片URL地址
$tinyimg = $domain.$updir.'/'.$current_time.'/'.$fhash.'.'.$handle->file_dst_name_ext;
//图片路径(temp/1804/d64c8036c0605175.jpg)
$imgdir = $updir.'/'.$current_time.'/'.$fhash.'.'.$handle->file_dst_name_ext;
//判断文件是否已经存在
if(!is_file($new_img)) {
//对文件更名
rename($handle->file_dst_pathname,$new_img);
}
else{
//删除原始文件
unlink($handle->file_dst_pathname);
}
//检查某张图片是否已经上传过,如果已经上传了,直接返回数据并终止操作
$basis->isupload($imgdir);
//没有上传过的图片,继续写入数据库
$last_user_id = $database->insert("imginfo", [
"path" => $imgdir,
"ip" => $ip,
"ua" => $ua,
"date" => $date,
"dir" => $updir,
"compress" => 0,
"level" => 0
]);
//返回最后的ID
$account_id = $database->id();
//上传成功,返回json数据
$redata = array(
"code" => 1,
"id" => $account_id,
"url" => $tinyimg,
"width" => $handle->image_dst_x,
"height" => $handle->image_dst_y
);
//直接返回图片URL
if($type == 'url'){
echo $tinyimg;
}
else{
//返回json
echo $redata = json_encode($redata);
}
$handle->clean();
//继续请求鉴黄接口
$basis->curlZip($account_id,$config['domain']);
} else {
//上传出现错误,返回报错信息
$redata = array(
"code" => 0,
"msg" => $handle->error
);
echo json_encode($redata);
}
}
?>
File diff suppressed because it is too large Load Diff
+335
View File
@@ -0,0 +1,335 @@
<?php
error_reporting(E_ALL^E_NOTICE^E_WARNING^E_DEPRECATED);
// 载入配置文件
include_once("../config.php");
class Admin{
var $config;
var $database;
function __construct($config,$database) {
$this->config = $config;
$this->database = $database;
$user1 = $config['user'].md5("tinyimg".$config['password']);
// echo $user1;
//COOKIES里面的信息
$user2 = $_COOKIE['user'].$_COOKIE['password'];
//如果两者信息相符,说明已登录
if($user1 != $user2) {
echo '权限不足,请先登录!';
//清理cookie
setcookie("user", '', time()-3600,"/");
setcookie("password", '', time()-3600,"/");
header('Location:login.php');
exit;
}
}
//查询图片
function querypic($type,$page,$date = null){
//对时间进行拆分
if($date != null){
$date = explode("|",$date);
$starttime = $date[0];
$endttime = $date[1];
}
$config = $this->config;
$database = $this->database;
//分页计算
$start = ($page - 1) * 12;
//$end = $page * 12;
if(($page == '') || (!isset($page))) {
$page = 1;
}
//要查询的条数
$num = 12;
//判断类型
switch ($type) {
case 'user':
// echo 'dsd';
$datas = $database->select("imginfo", "*", [
"dir" => $config['userdir'],
"ORDER" => ["id" => "DESC"],
"LIMIT" => [$start,$num]
]);
// var_dump( $database->log() );
// exit;
return $datas;
break;
case 'admin':
$datas = $database->select("imginfo", "*", [
"dir" => $config['admindir'],
"ORDER" => ["id" => "DESC"],
"LIMIT" => [$start,$num]
]);
return $datas;
break;
case 'dubious':
$datas = $database->select("imginfo", "*", [
"level" => 3,
"ORDER" => ["id" => "DESC"],
"LIMIT" => [$start,$num]
]);
return $datas;
break;
case 'unidentification':
$datas = $database->select("imginfo", "*", [
"level" => null,
"ORDER" => ["id" => "DESC"],
"LIMIT" => [$start,$num]
]);
return $datas;
break;
default:
$sql = "SELECT * FROM imginfo WHERE date(date) BETWEEN '$starttime' AND '$endttime' ORDER BY `id` DESC LIMIT $num OFFSET $start";
$datas = $database->query($sql);
return $datas;
break;
}
}
//新版查询图片
function newquery($type,$date = null){
//echo $type;
//exit;
//获取当前时间
$thetime = date('Y-m',time());
//对时间进行拆分
if($date != null){
$date = explode("|",$date);
$starttime = $date[0];
$endttime = $date[1];
}
$config = $this->config;
$database = $this->database;
//判断类型
switch ($type) {
case 'user':
// echo 'dsd';
$datas = $database->select("imginfo", "*", [
"dir" => $config['userdir'],
"date[~]" => $thetime,
"ORDER" => ["id" => "DESC"]
]);
// var_dump( $database->log() );
// exit;
return $datas;
break;
case 'admin':
$datas = $database->select("imginfo", "*", [
"dir" => $config['admindir'],
"date[~]" => $thetime,
"ORDER" => ["id" => "DESC"]
]);
return $datas;
break;
default:
$sql = "SELECT * FROM imginfo WHERE date(date) BETWEEN '$starttime' AND '$endttime' ORDER BY `id` DESC";
$datas = $database->query($sql);
//var_dump($database->log());
return $datas;
break;
}
}
//删除一张图片
function delete($id){
$config = $this->config;
$database = $this->database;
//先查询数据库获取图片路径
$path = $database->get("imginfo","path",[
"id" => $id
]);
//完整的图片路径
$imgpath = APP.$path;
//如果图片删除成功,将再次删除数据库
//删除图片
unlink($imgpath);
//删除数据库
$del = $database->delete("imginfo", [
"AND" => [
"id" => $id
]
]);
echo 'ok';
}
//统计数据
function data() {
//获取当前月份
$themonth = date('Y-m',time());
//获取当天时间
$theday = date('Y-m-d',time());
//统计本月上传图片数量
$month = $this->database->count("imginfo",[
"date[~]" => $themonth
]);
$day = $this->database->count("imginfo",[
"date" => $theday
]);
//统计可疑图片
$level = $this->database->count("imginfo",[
"level" => 3
]);
//统计全部图片
$all = $this->database->count("imginfo");
//返回数据
$redata = array(
"month" => $month,
"day" => $day,
"level" => $level,
"all" => $all
);
return $redata;
}
//取消图片可疑状态
function cdubious($id){
$database = $this->database;
$database->update("imginfo",[
"level" => 1
],[
"id" => $id
]);
echo 'ok';
}
//对某张图片进行压缩,未开发完成
function compress($id,$tinypng){
$database = $this->database;
$config = $this->config;
if($tinypng['option'] != true){
$compress['code'] = 0;
$compress['msg'] = "未开启图片压缩功能!";
}
else{
$getdata = $database->get("imginfo","*",[
"id" => $id
]);
}
}
// TinyImg 2.0:SM.MS 记录的查询 / 删除方法已整体移除
//通过URL批量上传图片
function urlup($arr){
$config = $this->config;
//$arr参数为一个数组
$arr = explode("\n",$arr);
//计算URL个数
$urlnum = count($arr);
//不能超过10个
if($urlnum > 10){
$rejson = array(
"code" => 0,
"msg" => "URL链接不能超过10个!"
);
echo json_encode($rejson);
exit;
}
//遍历URL并下载图片
foreach( $arr as $url )
{
//去掉空格
$url = trim($url);
//判断是否是URL
if(!filter_var($url, FILTER_VALIDATE_URL)){
$rejson = array(
"code" => 0,
"msg" => $url."不是有效的地址,程序终止!"
);
echo json_encode($rejson);
exit;
}
//获取图片后缀
$suffix = explode(".",$url);
$suffix = end($suffix);
$suffix = strtolower($suffix);
//如果是图片后缀,使用curl进行抓取
if(($suffix == 'jpg') || ($suffix == 'jpeg') || ($suffix == 'png') || ($suffix == 'bmp') || ($suffix == 'gif')) {
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)");
curl_setopt($curl, CURLOPT_FAILONERROR, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
#设置超时时间,最小为1s(可选)
curl_setopt($curl , CURLOPT_TIMEOUT, 10);
$html = curl_exec($curl);
curl_close($curl);
//判断目录是否存在
$dir = APP.$config['admindir'].'/'.date('ym',time());
if(!is_dir($dir)){
mkdir($dir);
}
//生成文件名
$filenme = $dir.date('Y-m-d H:i:s',time()).$suffix;
$filenme = substr(md5($url.$filenme), 8, 16).'.'.$suffix;
$full = $dir.'/'.$filenme;
//写入文件
$myfile = fopen($full, "w") or die("Unable to open file!");
fwrite($myfile, $html);
fclose($myfile);
$datas = array(
"path" => $config['admindir'].'/'.date('ym',time()).'/'.$filenme,
"dir" => $config['admindir']
);
//写入数据库
$insert = $this->indb($datas);
}
else{
$rejson = array(
"code" => 0,
"msg" => "包含无效的图片地址,程序终止!"
);
echo json_encode($rejson);
exit;
}
}
$rejson = array(
"code" => 1,
"msg" => "成功上传".$urlnum."张图片!"
);
echo json_encode($rejson);
exit;
}
//图片写入数据库
function indb($datas){
$database = $this->database;
$date = date('Y-m-d',time());
$insert = $database->insert("imginfo",[
"path" => $datas['path'],
"ip" => "127.0.0.1",
"ua" => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36",
"date" => $date,
"dir" => $datas['dir'],
"compress" => 0,
"level" => 0
]);
return $insert;
}
}
$pic = new Admin($config,$database);
?>
+173
View File
@@ -0,0 +1,173 @@
<?php
class Install{
public $homedir;
public $domain;
//构造函数
public function __construct(){
//获取项目绝对路径
$thedir = __DIR__;
$homedir = str_replace("\\","/",$thedir);
$homedir = str_replace("functions/class","",$homedir);
$this->homedir = $homedir;
//获取当前域名
//获取当前端口
$port = $_SERVER["SERVER_PORT"];
//对端口进行判断
switch ( $port )
{
case 80:
$protocol = "http://";
$port = '';
break;
case 443:
$protocol = "https://";
$port = '';
break;
default:
$protocol = "http://";
$port = ":".$port;
break;
}
$uri = $_SERVER["REQUEST_URI"];
$uri = str_replace("check.php","",$uri);
//组合为完整的URL
$domain = $protocol.$_SERVER['SERVER_NAME'].$port.$uri;
$domain = str_replace("install.php?setup=2","",$domain);
$this->domain = $domain;
}
//检查环境是否符合条件
public function check(){
$homedir = $this->homedir;
//echo $homedir.'db';
//检查根目录是否可写,结果写入到一个数组
//echo $thedir;
$checkarr['home'] = is_writable($homedir);
if($checkarr['home']){
$statusarr['home'] = '通过';
}
else{
$statusarr['home'] = '<span style = "color:red;">目录不可写!</span>';
}
$checkarr['db'] = is_writable($homedir.'db');
if($checkarr['db']){
$statusarr['db'] = '通过';
}
else{
$statusarr['db'] = '<span style = "color:red;">目录不可写!</span>';
}
//检测组建是否支持
$ext = get_loaded_extensions();
if(array_search('pdo_sqlite',$ext)){
$statusarr['pdo'] = '支持';
}
else{
$statusarr['pdo'] = '<span style = "color:red;">不支持!</span>';
}
//return $checkarr;
return $statusarr;
}
//获取站点信息
public function info(){
$homedir = $this->homedir;
$info = array(
"homedir" => $this->homedir,
"domain" => $this->domain
);
return $info;
}
//验证函数
protected function verify($data,$type){
switch ($type) {
//检查用户名
case 'user':
$pattern = '/^[a-zA-Z0-9]+$/';
if($data == ''){
echo '请填写用户名!';
exit;
}
if(!preg_match($pattern,$data)){
echo '用户名格式有误!';
exit;
}
break;
case 'pass':
$pattern = '/^[a-zA-Z0-9!@#$%^&*.]+$/';
if(!preg_match($pattern,$data)){
echo '密码格式有误!';
exit;
}
break;
case 'pass2':
$pass1 = $data['pass1'];
$pass2 = $data['pass2'];
if($pass1 != $pass2){
echo '两次密码不一致!';
exit;
}
break;
case 'domain':
$domain = $data['domain'];
if(!filter_var($domain, FILTER_VALIDATE_URL)){
echo '域名格式有误!(需要包含https://)';
exit;
}
break;
default:
# code...
break;
}
}
//安装
public function setup($data){
$homedir = $this->homedir;
$dbpath = $this->homedir.'db/';
$user = $data['user'];
$pass1 = $data['pass1'];
$pass2 = $data['pass2'];
$this->verify($user,'user');
$this->verify($pass1,'pass');
$this->verify($data,'pass2');
$this->verify($data,'domain');
//复制一份数据库
copy($dbpath."tinyimg-simple.db3",$dbpath."tinyimg.db3");
//复制一份配置文件
if(copy($homedir."config-simple.php",$homedir."config.php")){
$configdir = $homedir."config.php";
$myfile = fopen($homedir."config.php", "r") or die("Unable to open file!");
$content = fread($myfile,filesize($configdir));
//执行替换
$content = str_replace("imguser",$user,$content);
$content = str_replace("imgpass",$pass2,$content);
$content = str_replace("homedir",$data['homedir'],$content);
$content = str_replace("https://img.example.com/",$data['domain'],$content);
//var_dump($content);
//写入文件
$myfile = fopen($homedir."config.php", "w+") or die("Unable to open file!");
fwrite($myfile, $content);
//关闭
fclose($myfile);
//更名安装文件
rename($homedir."install.php",$homedir."install.php.bak");
}
}
}
?>
+90
View File
@@ -0,0 +1,90 @@
<?php
error_reporting(E_ALL^E_NOTICE^E_WARNING^E_DEPRECATED);
/*
图像处理类
*/
include_once("../../config.php");
//载入TinyPNG
require_once(APP."functions/tinypng/Tinify/Exception.php");
require_once(APP."functions/tinypng/Tinify/ResultMeta.php");
require_once(APP."functions/tinypng/Tinify/Result.php");
require_once(APP."functions/tinypng/Tinify/Source.php");
require_once(APP."functions/tinypng/Tinify/Client.php");
require_once(APP."functions/tinypng/Tinify.php");
//初始化值
$dispose['compress'] = 0;
$dispose['level'] = 0;
//获取ID
$id = $_GET['id'];
$id = (int)$id;
//获取tinypng key
$tinykey = array_rand($tinypng['key']); //取出数组键值
$tinykey = $tinypng['key'][$tinykey];
$iscompress = 0;
//如果ID不存在或为空
if((!isset($id)) || ($id == '')) {
echo 'ID错误!';
exit;
}
//如果没有启用压缩
if($tinypng['option'] != true){
echo '未启用压缩功能!';
exit;
}
//查询对应信息
$info = $database->get("imginfo",[
"id",
"path",
"compress",
"level"
],[
"id" => $id
]);
//组合为完整的URL地址
$tinyimg = $config['domain'].$info['path'];
//获取压缩状态
$compress = $info['compress'];
//获取图片等级
$level = $info['level'];
//获取文件后缀名
$suffix = substr(strrchr($info['path'], '.'), 1);
//后缀改为小写
$suffix = strtolower($suffix);
if(($suffix == 'png') || ($suffix == 'jpg') || ($suffix == 'jpeg')) {
$iscompress = 1;
}
if($iscompress == 0){
echo '该后缀不支持压缩!';
exit;
}
if($compress == 1){
echo '该图片已经压缩!';
exit;
}
//对图片进行压缩
if(($tinypng['option'] == true) && ($iscompress == 1) && ($compress == 0)) {
//初始化
\Tinify\setKey($tinykey);
$source = \Tinify\fromUrl($tinyimg);
//覆盖原有图片
$source->toFile(APP.$info['path']);
//更新数据库
$database->update("imginfo",[
"compress" => 1
],[
"id" => $id
]);
$dispose['compress'] = 1;
echo '压缩成功!';
}
?>
View File
File diff suppressed because it is too large Load Diff
+180
View File
@@ -0,0 +1,180 @@
<?php
error_reporting(E_ALL^E_NOTICE^E_WARNING^E_DEPRECATED);
// 载入配置文件
include_once("../config.php");
class User{
var $config;
var $database;
//构造函数
public function __construct($config,$database){
$this->config = $config;
$this->database = $database;
}
// 用户登录,两个参数,一个是用户输入,一个是配置文件里面的用户信息
function login($user,$admin){
// 用户输入的信息进行md5加密和对比
$pw1 = md5($user['user'].$user['password']);
$pw2 = md5($admin['user'].$admin['password']);
// 判断用户名密码是否正确
if($pw1 != $pw2){
echo '用户名或密码不正确!';
setcookie("user", '', time()-3600,"/");
setcookie("password", '', time()-3600,"/");
exit;
}
else{
$password = md5("tinyimg".$admin['password']);
//生成cookie
setcookie("user", $user['user'], time()+3600 * 24 * 30,"/");
setcookie("password", $password, time()+3600 * 24 * 30,"/");
echo "<script>window.location.href = './index.php'</script>";
exit;
}
}
//判断用户状态
function check($userinfo){
//配置文件里面的用户信息
$user1 = $userinfo['user'].md5("tinyimg".$userinfo['password']);
// echo $user1;
//COOKIES里面的信息
$user2 = $_COOKIE['user'].$_COOKIE['password'];
//如果两者信息相符,说明已登录
if($user1 == $user2) {
return'islogin';
exit;
}
else{
return 'nologin';
setcookie("user", '', time()-3600,"/");
setcookie("password", '', time()-3600,"/");
exit;
}
}
//检查某张图片是否已经上传
function isupload($path){
$num = $this->database->count("imginfo",["path" => $path]);
//如果图片已经上传过,直接返回图片信息
if($num >=1) {
$info = $this->database->get("imginfo","*",["path" => $path]);
$tinyimg = $this->config['domain'].$path;
//返回json数据
$redata = array(
"code" => 1,
"id" => $info['id'],
"url" => $tinyimg,
"width" => 0,
"height" => 0
);
echo $redata = json_encode($redata);
exit;
}
}
//限制访客上传数量
function limitnum(){
//获取访客IP
$ip = $_SERVER['REMOTE_ADDR'];
//获取当前时间
$date = date('Y-m-d',time());
//获取配置文件限额
$limit = $this->config['limit'];
//获取用户上传目录
$dir = $this->config['userdir'];
//查询数据库统计数量
$database = $this->database;
$num = $database->count("imginfo",[
"date" => $date,
"ip" => $ip,
"dir" => $dir
]);
if($num >= $limit) {
$redata = array(
"code" => 0,
"msg" => "上传达到限制!"
);
echo $redata = json_encode($redata);
exit;
}
}
//获取访客真实IP
function getip(){
if (getenv('HTTP_CLIENT_IP')) {
$ip = getenv('HTTP_CLIENT_IP');
}
elseif (getenv('HTTP_X_FORWARDED_FOR')) {
$ip = getenv('HTTP_X_FORWARDED_FOR');
}
elseif (getenv('HTTP_X_FORWARDED')) {
$ip = getenv('HTTP_X_FORWARDED');
}
elseif (getenv('HTTP_FORWARDED_FOR')) {
$ip = getenv('HTTP_FORWARDED_FOR');
}
elseif (getenv('HTTP_FORWARDED')) {
$ip = getenv('HTTP_FORWARDED');
}
else {
$ip = $_SERVER['REMOTE_ADDR'];
}
return $ip;
}
//判断文件MIME类型
function mime($path){
$mime = mime_content_type($path);
switch ( $mime )
{
case 'image/gif':
case 'image/png':
case 'image/jpeg':
case 'image/bmp':
return true;
break;
default:
return false;
break;
}
}
//返回错误json
function re_error($msg){
$arr = array(
"code" => 0,
"msg" => $msg
);
$rejson = json_encode($arr);
echo $rejson;
exit;
}
//请求tipng和鉴黄接口
function curlZip($id,$domain){
//组合为完整的接口
$apiurl = $domain.'dispose.php?id='.$id;
//请求接口
$curl = curl_init($apiurl);
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36");
curl_setopt($curl, CURLOPT_FAILONERROR, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
#设置超时时间,最小为1s(可选)
curl_setopt($curl , CURLOPT_TIMEOUT, 2);
@curl_exec($curl);
curl_close($curl);
//var_dump($html);
}
}
//自动初始化完成一些基础操作
$basis = new User($config,$database);
?>
@@ -0,0 +1,86 @@
<?php
// +------------------------------------------------------------------------+
// | class.upload.zh_CN.php |
// +------------------------------------------------------------------------+
// | Copyright (c) caoshiwei 2008. All rights reserved. |
// | Version 0.25 |
// | Last modified 09/29/2008 |
// | Email [email protected] |
// | Web http://www.hfut.edu.cn |
// +------------------------------------------------------------------------+
// | This program is free software; you can redistribute it and/or modify |
// | it under the terms of the GNU General Public License version 2 as |
// | published by the Free Software Foundation. |
// | |
// | This program is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// | GNU General Public License for more details. |
// | |
// | You should have received a copy of the GNU General Public License |
// | along with this program; if not, write to the |
// | Free Software Foundation, Inc., 59 Temple Place, Suite 330, |
// | Boston, MA 02111-1307 USA |
// | |
// | Please give credit on sites that use class.upload and submit changes |
// | of the script so other people can use them as well. |
// | This script is free to use, don't abuse. |
// +------------------------------------------------------------------------+
/**
* Class upload Chinese translation
*
* @version 0.25
* @codepage gb-2312
* @author Shiwei Cao ([email protected])
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @copyright Shiwei Cao
* @package cmf
* @subpackage external
*/
$translation = array();
$translation['file_error'] = '�ļ������������ԡ�';
$translation['local_file_missing'] = '�����ļ������ڡ�';
$translation['local_file_not_readable'] = '�����ļ����ɶ��';
$translation['uploaded_too_big_ini'] = '�ļ��ϼ����� (�ϴ����ļ���С������php.ini��upload_max_filesize���õĴ�С)��';
$translation['uploaded_too_big_html'] = '�ļ��ϼ����� (�ϴ����ļ���С������HTML �����õĴ�С)��';
$translation['uploaded_partial'] = '�ļ��ϼ����� (�ϴ����ļ����ֶ�ʧ)��';
$translation['uploaded_missing'] = '�ļ��ϼ����� (�ϴ��ļ���ʧ)��';
$translation['uploaded_unknown'] = '�ļ��ϼ����� (δ֪����).';
$translation['try_again'] = '�ļ��ϼ����� �����ԡ�';
$translation['file_too_big'] = '�ļ�̫����';
$translation['no_mime'] = 'δ֪�ļ����͡�';
$translation['incorrect_file'] = '����ȷ���ļ���ʽ��';
$translation['image_too_wide'] = 'ͼƬ����̫����';
$translation['image_too_narrow'] = 'ͼƬ����̫С��';
$translation['image_too_high'] = 'ͼƬ�߶�̫����';
$translation['image_too_short'] = 'ͼƬ�߶�̫С��';
$translation['ratio_too_high'] = 'ͼƬ��/�߱���̫��(ͼƬ����̫��)��';
$translation['ratio_too_low'] = 'ͼƬ��/�߱���̫��(ͼƬ�߶�̫��).';
$translation['too_many_pixels'] = 'ͼƬλ��̫�ߡ�';
$translation['not_enough_pixels'] = 'ͼƬλ������';
$translation['file_not_uploaded'] = '�ļ�δ�ϴ������ܽ��д���';
$translation['already_exists'] = '%s �Ѿ����ڣ��������ļ�����';
$translation['temp_file_missing'] = '������(��ʱ)Դ�ļ�����ȷ�����ܽ��д���';
$translation['source_missing'] = '���ϴ����ļ���ʧ�����ܽ��д���';
$translation['destination_dir'] = 'Ŀ���ļ�Ŀ¼���ܱ����������ܽ��д���';
$translation['destination_dir_missing'] = 'Ŀ���ļ�Ŀ¼�����ڣ����ܽ��д���';
$translation['destination_path_not_dir'] = 'Ŀ¼·������һ����Ч��Ŀ¼�����ܽ��д���';
$translation['destination_dir_write'] = '������Ŀ���ļ�Ŀ¼����Ϊ��д�ģ����ܽ��д���';
$translation['destination_path_write'] = 'Ŀ¼·���Dz�����д�ģ����ܽ��д���';
$translation['temp_file'] = '���ܴ�����ʱ�ļ������ܽ��д���';
$translation['source_not_readable'] = 'Դ�ļ������Զ�����ܽ��д���';
$translation['no_create_support'] = '%s ��֧�ִ���';
$translation['create_error'] = '��Դ�ļ����� %s ͼƬ�����г���';
$translation['source_invalid'] = '�޷���ȡԭʼͼƬ��ȷ���Dz�����ȷ��ͼƬ�ļ���';
$translation['gd_missing'] = 'GD ���񲻿���ʹ�á�';
$translation['watermark_no_create_support'] = '%s ������֧��, ���ܶ�ȡˮӡ�ļ���';
$translation['watermark_create_error'] = '%s ��֧�ֶ�, ���ܴ���ˮӡ��';
$translation['watermark_invalid'] = 'δ֪�ļ���ʽ, �޷���ȡˮӡ�ļ���';
$translation['file_create'] = '%s ��֧�ִ�����';
$translation['no_conversion_type'] = 'δ����ת������';
$translation['copy_failed'] = '�ڷ������ϸ����ļ�ʱ���� copy() ����ʧ��.';
$translation['reading_failed'] = '��ȡ�����г���';
?>
@@ -0,0 +1,85 @@
<?php
// +------------------------------------------------------------------------+
// | class.upload.zh_CN.php |
// +------------------------------------------------------------------------+
// | Copyright (c) caoshiwei 2008. All rights reserved. |
// | Version 0.25 |
// | Last modified 09/29/2008 |
// | Email [email protected] |
// | Web http://www.hfut.edu.cn |
// +------------------------------------------------------------------------+
// | This program is free software; you can redistribute it and/or modify |
// | it under the terms of the GNU General Public License version 2 as |
// | published by the Free Software Foundation. |
// | |
// | This program is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// | GNU General Public License for more details. |
// | |
// | You should have received a copy of the GNU General Public License |
// | along with this program; if not, write to the |
// | Free Software Foundation, Inc., 59 Temple Place, Suite 330, |
// | Boston, MA 02111-1307 USA |
// | |
// | Please give credit on sites that use class.upload and submit changes |
// | of the script so other people can use them as well. |
// | This script is free to use, don't abuse. |
// +------------------------------------------------------------------------+
/**
* Class upload Chinese translation
*
* @version 0.25
* @author Shiwei Cao ([email protected])
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @copyright Shiwei Cao
* @package cmf
* @subpackage external
*/
$translation = array();
$translation['file_error'] = '文件错误,请重试。';
$translation['local_file_missing'] = '本地文件不存在。';
$translation['local_file_not_readable'] = '本地文件不可读。';
$translation['uploaded_too_big_ini'] = '文件上件出错 (上传的文件大小超过了php.ini中upload_max_filesize设置的大小)。';
$translation['uploaded_too_big_html'] = '文件上件出错 (上传的文件大小超过了HTML 表单设置的大小)。';
$translation['uploaded_partial'] = '文件上件出错 (上传的文件部分丢失)。';
$translation['uploaded_missing'] = '文件上件出错 (上传文件丢失)。';
$translation['uploaded_unknown'] = '文件上件出错 (未知错误).';
$translation['try_again'] = '文件上件出错。 请重试。';
$translation['file_too_big'] = '文件太大。';
$translation['no_mime'] = '未知文件类型。';
$translation['incorrect_file'] = '不正确的文件格式。';
$translation['image_too_wide'] = '图片宽度太大。';
$translation['image_too_narrow'] = '图片宽度太小。';
$translation['image_too_high'] = '图片高度太大。';
$translation['image_too_short'] = '图片高度太小。';
$translation['ratio_too_high'] = '图片宽/高比率太高(图片宽度太大)。';
$translation['ratio_too_low'] = '图片宽/高比率太低(图片高度太大).';
$translation['too_many_pixels'] = '图片位数太高。';
$translation['not_enough_pixels'] = '图片位数不够';
$translation['file_not_uploaded'] = '文件未上传,不能进行处理。';
$translation['already_exists'] = '%s 已经存在,请更换文件名。';
$translation['temp_file_missing'] = '处理的(临时)源文件不正确,不能进行处理。';
$translation['source_missing'] = '已上传的文件丢失,不能进行处理。';
$translation['destination_dir'] = '目标文件目录不能被创建,不能进行处理。';
$translation['destination_dir_missing'] = '目标文件目录不存在,不能进行处理。';
$translation['destination_path_not_dir'] = '目录路径不是一个有效的目录,不能进行处理。';
$translation['destination_dir_write'] = '不能让目标文件目录设置为可写的,不能进行处理。';
$translation['destination_path_write'] = '目录路径是不可以写的,不能进行处理。';
$translation['temp_file'] = '不能创建临时文件,不能进行处理。';
$translation['source_not_readable'] = '源文件不可以读,不能进行处理。';
$translation['no_create_support'] = '%s 不支持创建';
$translation['create_error'] = '从源文件创建 %s 图片过程中出错。';
$translation['source_invalid'] = '无法读取原始图片,确认是不是正确的图片文件?';
$translation['gd_missing'] = 'GD 好像不可以使用。';
$translation['watermark_no_create_support'] = '%s 创建不支持, 不能读取水印文件。';
$translation['watermark_create_error'] = '%s 不支持读, 不能创建水印。';
$translation['watermark_invalid'] = '未知文件格式, 无法读取水印文件。';
$translation['file_create'] = '%s 不支持创建。';
$translation['no_conversion_type'] = '未定义转换类型';
$translation['copy_failed'] = '在服务器上复制文件时出错。 copy() 操作失败.';
$translation['reading_failed'] = '读取过程中出错。';
?>
@@ -0,0 +1,87 @@
<?php
// +------------------------------------------------------------------------+
// | class.upload.zh_TW.php |
// +------------------------------------------------------------------------+
// | Copyright (c) Yang Chih-Wen 2009. All rights reserved. |
// | Version 0.28 |
// | Last modified 15/08/2009 |
// | Email [email protected] |
// | Web http://www.doubleservice.com/ |
// +------------------------------------------------------------------------+
// | This program is free software; you can redistribute it and/or modify |
// | it under the terms of the GNU General Public License version 2 as |
// | published by the Free Software Foundation. |
// | |
// | This program is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// | GNU General Public License for more details. |
// | |
// | You should have received a copy of the GNU General Public License |
// | along with this program; if not, write to the |
// | Free Software Foundation, Inc., 59 Temple Place, Suite 330, |
// | Boston, MA 02111-1307 USA |
// | |
// | Please give credit on sites that use class.upload and submit changes |
// | of the script so other people can use them as well. |
// | This script is free to use, don't abuse. |
// +------------------------------------------------------------------------+
/**
* Class upload Traditional Chinese translation
*
* @version 0.28
* @author Yang Chih-Wen ([email protected])
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @copyright Yang Chih-Wen
* @package cmf
* @subpackage external
*/
$translation = array();
$translation['file_error'] = '檔案錯誤,請重試。';
$translation['local_file_missing'] = '本地端的檔案不存在。';
$translation['local_file_not_readable'] = '本地端的檔案不可讀取。';
$translation['uploaded_too_big_ini'] = '檔案上傳出錯 (上傳的檔案超過了 php.ini 中 upload_max_filesize 指定的大小)。';
$translation['uploaded_too_big_html'] = '檔案上傳出錯 (上傳的檔案超過了 HTML 表單中 MAX_FILE_SIZE 指定的大小)。';
$translation['uploaded_partial'] = '檔案上傳出錯 (只有部份的檔案被上傳)。';
$translation['uploaded_missing'] = '檔案上傳出錯 (沒有檔案被上傳)。';
$translation['uploaded_no_tmp_dir'] = '檔案上傳出錯 (找不到暫存目錄)。';
$translation['uploaded_cant_write'] = '檔案上傳出錯 (檔案寫入失敗)。';
$translation['uploaded_err_extension'] = '檔案上傳出錯 (檔案上傳被 extension 中斷)。';
$translation['uploaded_unknown'] = '檔案上傳出錯 (未知的錯誤)。';
$translation['try_again'] = '檔案上傳出錯,請重試。';
$translation['file_too_big'] = '檔案太大了。';
$translation['no_mime'] = '未知的 MIME Type 檔案類型。';
$translation['incorrect_file'] = '不正確的 MIME Type 檔案類型。';
$translation['image_too_wide'] = '圖片寬度太大。';
$translation['image_too_narrow'] = '圖片寬度太小。';
$translation['image_too_high'] = '圖片高度太大。';
$translation['image_too_short'] = '圖片高度太小。';
$translation['ratio_too_high'] = '圖片寬高比率太大 (圖片寬度太大)。';
$translation['ratio_too_low'] = '圖片寬高比率太小 (圖片高度太大)。';
$translation['too_many_pixels'] = '圖片像素太多。';
$translation['not_enough_pixels'] = '圖片像素太少。';
$translation['file_not_uploaded'] = '檔案未上傳,無法繼續進行處理。';
$translation['already_exists'] = '%s 已經存在,請更改檔名。';
$translation['temp_file_missing'] = '暫存的原始檔案不正確,無法繼續進行處理。';
$translation['source_missing'] = '已上傳的原始檔案不正確,無法繼續進行處理。';
$translation['destination_dir'] = '無法創建目標目錄,無法繼續進行處理。';
$translation['destination_dir_missing'] = '目標目錄不存在,無法繼續進行處理。';
$translation['destination_path_not_dir'] = '目標路徑不是一個有效的目錄,無法繼續進行處理。';
$translation['destination_dir_write'] = '目標目錄不能設定為可寫入,無法繼續進行處理。';
$translation['destination_path_write'] = '目錄路徑不可寫入,無法繼續進行處理。';
$translation['temp_file'] = '不能創建暫存檔案,無法繼續進行處理。';
$translation['source_not_readable'] = '原始檔案不可讀取,無法繼續進行處理。';
$translation['no_create_support'] = '不支援 %s 創建功能。';
$translation['create_error'] = '從原始檔案創建 %s 圖片過程中出錯。';
$translation['source_invalid'] = '無法讀取原始圖片,請確認是否為正確的圖片檔?';
$translation['gd_missing'] = '無法使用 GD 函式庫。';
$translation['watermark_no_create_support'] = '不支援 %s 創建功能,無法讀取浮水印。';
$translation['watermark_create_error'] = '不支援 %s 讀取功能,無法創建浮水印。';
$translation['watermark_invalid'] = '未知的圖片格式,無法讀取浮水印。';
$translation['file_create'] = '不支援 %s 創建功能。';
$translation['no_conversion_type'] = '未定義的轉換類型。';
$translation['copy_failed'] = '在伺服端複製檔案時出錯,copy() 操作失敗。';
$translation['reading_failed'] = '讀檔過程中出錯。';
?>
+98
View File
@@ -0,0 +1,98 @@
<?php
//载入配置文件
include_once("./class/class.user.php");
//检查用户是否登录
$status = $basis->check($config);
//检查用户是否登陆来判断上传目录
if($status == 'islogin') {
//设置上传路径
$updir = $config['admindir'];
}
else{
$updir = $config['userdir'];
//限制用户上传数量
$basis->limitnum();
}
//获取上传者信息
$ip = $basis->getip();
$ua = $_SERVER['HTTP_USER_AGENT'];
$date = date('Y-m-d',time());
//根据IP、ua、时间生成一个唯一的md5值
$picname = md5($ip.$ua.date('Y-m-d H:i:s',time()));
//截取16个字符
$picname = substr($picname,8,16).'.png';
//本月图片路径
$monthdir = APP.$updir.'/'.date('ym',time());
$onepath = $updir.'/'.date('ym',time()).'/'.$picname;
//路径不存在,则创建路径
if(!file_exists($monthdir)){
mkdir($monthdir,0777);
}
//图片完整存储路径
$picpath = APP.$onepath;
//echo $picpath;
//替换一下,以免windows出现问题
$picpath = str_replace("\\","/",$picpath);
//echo $picpath;
//接接收ase64图片
$picfile = $_POST['content'];
$picfile = base64_decode($picfile);
//echo $picfile;
//存储图片
file_put_contents($picpath, $picfile);
//获取文件mime类型
//如果不是图片文件,终止执行
if(!$basis->mime($picpath)){
unlink($picpath);
$arr = array(
"code" => 0,
"msg" => '不允许的文件类型'
);
$json = json_encode($arr);
echo $json;
exit;
}
//继续执行并写入数据库
$last_user_id = $database->insert("imginfo", [
"path" => $onepath,
"ip" => $ip,
"ua" => $ua,
"date" => $date,
"dir" => $updir,
"compress" => 0,
"level" => 0
]);
//var_dump($database->log());
//返回最后的ID
$account_id = $database->id();
//写入数据库成功,返回json数据
if($last_user_id){
$url = $config['domain'].$onepath;
rejson(1,$url,$account_id);
}
//echo $picpath;
//var_dump($picfile);
?>
<?php
//返回json数据
function rejson($code,$url,$id = 0){
$arr = array(
"code" => $code,
"url" => $url,
"id" => $id
);
$json = json_encode($arr);
echo $json;
}
?>
+11
View File
@@ -0,0 +1,11 @@
<?php
// TinyImg 2.0:第三方 SM.MS 回写通道已关闭。
// 不载入任何类、不写数据库,直接 fail closed;即使有人手工构造 POST 也不会留下记录。
header('Content-Type: application/json; charset=utf-8');
http_response_code(410);
echo json_encode([
'code' => 0,
'msg' => '第三方 SM.MS 上传功能已关闭',
], JSON_UNESCAPED_UNICODE);
exit;
?>
+96
View File
@@ -0,0 +1,96 @@
<?php
namespace Tinify;
const VERSION = "1.5.2";
class Tinify {
private static $key = NULL;
private static $appIdentifier = NULL;
private static $proxy = NULL;
private static $compressionCount = NULL;
private static $client = NULL;
public static function setKey($key) {
self::$key = $key;
self::$client = NULL;
}
public static function setAppIdentifier($appIdentifier) {
self::$appIdentifier = $appIdentifier;
self::$client = NULL;
}
public static function setProxy($proxy) {
self::$proxy = $proxy;
self::$client = NULL;
}
public static function getCompressionCount() {
return self::$compressionCount;
}
public static function setCompressionCount($compressionCount) {
self::$compressionCount = $compressionCount;
}
public static function getClient() {
if (!self::$key) {
throw new AccountException("Provide an API key with Tinify\setKey(...)");
}
if (!self::$client) {
self::$client = new Client(self::$key, self::$appIdentifier, self::$proxy);
}
return self::$client;
}
public static function setClient($client) {
self::$client = $client;
}
}
function setKey($key) {
return Tinify::setKey($key);
}
function setAppIdentifier($appIdentifier) {
return Tinify::setAppIdentifier($appIdentifier);
}
function setProxy($proxy) {
return Tinify::setProxy($proxy);
}
function getCompressionCount() {
return Tinify::getCompressionCount();
}
function compressionCount() {
return Tinify::getCompressionCount();
}
function fromFile($path) {
return Source::fromFile($path);
}
function fromBuffer($string) {
return Source::fromBuffer($string);
}
function fromUrl($string) {
return Source::fromUrl($string);
}
function validate() {
try {
Tinify::getClient()->request("post", "/shrink");
} catch (AccountException $err) {
if ($err->status == 429) return true;
throw $err;
} catch (ClientException $err) {
return true;
}
}
+160
View File
@@ -0,0 +1,160 @@
<?php
namespace Tinify;
class Client {
const API_ENDPOINT = "https://api.tinify.com";
const RETRY_COUNT = 1;
const RETRY_DELAY = 500;
private $options;
public static function userAgent() {
$curl = curl_version();
return "Tinify/" . VERSION . " PHP/" . PHP_VERSION . " curl/" . $curl["version"];
}
private static function caBundle() {
return __DIR__ . "/../data/cacert.pem";
}
function __construct($key, $app_identifier = NULL, $proxy = NULL) {
$curl = curl_version();
if (!($curl["features"] & CURL_VERSION_SSL)) {
throw new ClientException("Your curl version does not support secure connections");
}
if ($curl["version_number"] < 0x071201) {
$version = $curl["version"];
throw new ClientException("Your curl version ${version} is outdated; please upgrade to 7.18.1 or higher");
}
$this->options = array(
CURLOPT_BINARYTRANSFER => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => true,
CURLOPT_USERPWD => "api:" . $key,
CURLOPT_CAINFO => self::caBundle(),
CURLOPT_SSL_VERIFYPEER => true,
CURLOPT_USERAGENT => join(" ", array_filter(array(self::userAgent(), $app_identifier))),
);
if ($proxy) {
$parts = parse_url($proxy);
if (isset($parts["host"])) {
$this->options[CURLOPT_PROXYTYPE] = CURLPROXY_HTTP;
$this->options[CURLOPT_PROXY] = $parts["host"];
} else {
throw new ConnectionException("Invalid proxy");
}
if (isset($parts["port"])) {
$this->options[CURLOPT_PROXYPORT] = $parts["port"];
}
$creds = "";
if (isset($parts["user"])) $creds .= $parts["user"];
if (isset($parts["pass"])) $creds .= ":" . $parts["pass"];
if ($creds) {
$this->options[CURLOPT_PROXYAUTH] = CURLAUTH_ANY;
$this->options[CURLOPT_PROXYUSERPWD] = $creds;
}
}
}
function request($method, $url, $body = NULL) {
$header = array();
if (is_array($body)) {
if (!empty($body)) {
$body = json_encode($body);
array_push($header, "Content-Type: application/json");
} else {
$body = NULL;
}
}
for ($retries = self::RETRY_COUNT; $retries >= 0; $retries--) {
if ($retries < self::RETRY_COUNT) {
usleep(self::RETRY_DELAY * 1000);
}
$request = curl_init();
if ($request === false || $request === null) {
throw new ConnectionException(
"Error while connecting: curl extension is not functional or disabled."
);
}
curl_setopt_array($request, $this->options);
$url = strtolower(substr($url, 0, 6)) == "https:" ? $url : self::API_ENDPOINT . $url;
curl_setopt($request, CURLOPT_URL, $url);
curl_setopt($request, CURLOPT_CUSTOMREQUEST, strtoupper($method));
if (count($header) > 0) {
curl_setopt($request, CURLOPT_HTTPHEADER, $header);
}
if ($body) {
curl_setopt($request, CURLOPT_POSTFIELDS, $body);
}
$response = curl_exec($request);
if (is_string($response)) {
$status = curl_getinfo($request, CURLINFO_HTTP_CODE);
$headerSize = curl_getinfo($request, CURLINFO_HEADER_SIZE);
curl_close($request);
$headers = self::parseHeaders(substr($response, 0, $headerSize));
$body = substr($response, $headerSize);
if (isset($headers["compression-count"])) {
Tinify::setCompressionCount(intval($headers["compression-count"]));
}
if ($status >= 200 && $status <= 299) {
return (object) array("body" => $body, "headers" => $headers);
}
$details = json_decode($body);
if (!$details) {
$message = sprintf("Error while parsing response: %s (#%d)",
PHP_VERSION_ID >= 50500 ? json_last_error_msg() : "Error",
json_last_error());
$details = (object) array(
"message" => $message,
"error" => "ParseError"
);
}
if ($retries > 0 && $status >= 500) continue;
throw Exception::create($details->message, $details->error, $status);
} else {
$message = sprintf("%s (#%d)", curl_error($request), curl_errno($request));
curl_close($request);
if ($retries > 0) continue;
throw new ConnectionException("Error while connecting: " . $message);
}
}
}
protected static function parseHeaders($headers) {
if (!is_array($headers)) {
$headers = explode("\r\n", $headers);
}
$res = array();
foreach ($headers as $header) {
if (empty($header)) continue;
$split = explode(":", $header, 2);
if (count($split) === 2) {
$res[strtolower($split[0])] = trim($split[1]);
}
}
return $res;
}
}
+36
View File
@@ -0,0 +1,36 @@
<?php
namespace Tinify;
class Exception extends \Exception {
public $status;
public static function create($message, $type, $status) {
if ($status == 401 || $status == 429) {
$klass = "Tinify\AccountException";
} else if($status >= 400 && $status <= 499) {
$klass = "Tinify\ClientException";
} else if($status >= 500 && $status <= 599) {
$klass = "Tinify\ServerException";
} else {
$klass = "Tinify\Exception";
}
if (empty($message)) $message = "No message was provided";
return new $klass($message, $type, $status);
}
function __construct($message, $type = NULL, $status = NULL) {
$this->status = $status;
if ($status) {
parent::__construct($message . " (HTTP " . $status . "/" . $type . ")");
} else {
parent::__construct($message);
}
}
}
class AccountException extends Exception {}
class ClientException extends Exception {}
class ServerException extends Exception {}
class ConnectionException extends Exception {}
+36
View File
@@ -0,0 +1,36 @@
<?php
namespace Tinify;
class Result extends ResultMeta {
protected $data;
public function __construct($meta, $data) {
$this->meta = $meta;
$this->data = $data;
}
public function data() {
return $this->data;
}
public function toBuffer() {
return $this->data;
}
public function toFile($path) {
return file_put_contents($path, $this->toBuffer());
}
public function size() {
return intval($this->meta["content-length"]);
}
public function mediaType() {
return $this->meta["content-type"];
}
public function contentType() {
return $this->mediaType();
}
}
+23
View File
@@ -0,0 +1,23 @@
<?php
namespace Tinify;
class ResultMeta {
protected $meta;
public function __construct($meta) {
$this->meta = $meta;
}
public function width() {
return intval($this->meta["image-width"]);
}
public function height() {
return intval($this->meta["image-height"]);
}
public function location() {
return isset($this->meta["location"]) ? $this->meta["location"] : null;
}
}
+69
View File
@@ -0,0 +1,69 @@
<?php
namespace Tinify;
class Source {
private $url, $commands;
public static function fromFile($path) {
return self::fromBuffer(file_get_contents($path));
}
public static function fromBuffer($string) {
$response = Tinify::getClient()->request("post", "/shrink", $string);
return new self($response->headers["location"]);
}
public static function fromUrl($url) {
$body = array("source" => array("url" => $url));
$response = Tinify::getClient()->request("post", "/shrink", $body);
return new self($response->headers["location"]);
}
public function __construct($url, $commands = array()) {
$this->url = $url;
$this->commands = $commands;
}
public function preserve() {
$options = $this->flatten(func_get_args());
$commands = array_merge($this->commands, array("preserve" => $options));
return new self($this->url, $commands);
}
public function resize($options) {
$commands = array_merge($this->commands, array("resize" => $options));
return new self($this->url, $commands);
}
public function store($options) {
$response = Tinify::getClient()->request("post", $this->url,
array_merge($this->commands, array("store" => $options)));
return new Result($response->headers, $response->body);
}
public function result() {
$response = Tinify::getClient()->request("get", $this->url, $this->commands);
return new Result($response->headers, $response->body);
}
public function toFile($path) {
return $this->result()->toFile($path);
}
public function toBuffer() {
return $this->result()->toBuffer();
}
private static function flatten($options) {
$flattened = array();
foreach ($options as $option) {
if (is_array($option)) {
$flattened = array_merge($flattened, $option);
} else {
array_push($flattened, $option);
}
}
return $flattened;
}
}
File diff suppressed because it is too large Load Diff
+201
View File
@@ -0,0 +1,201 @@
<?php
/**
* TinyImg API Token 存储与校验(不依赖 Web 环境,可单独被测试脚本加载)。
*
* 存储文件:db/tinyimg-token.php
* 首行是 PHP 守卫,直接通过 URL 访问时只会执行 exit,不会泄漏 Token;
* 第二行是 JSON。即使站点跑在 Nginx 且没有屏蔽 db 目录,也拿不到内容。
*
* 兼容策略:存储文件不存在时,回落到 config.php 的 api_token(旧版部署),
* 后台设置页第一次保存后即以存储文件为准。
*/
require_once __DIR__ . '/version.php';
/** Token 存储文件路径 */
function tinyimg_token_file()
{
if (defined('APP')) {
return rtrim(APP, "/\\") . '/db/tinyimg-token.php';
}
return dirname(__DIR__) . '/db/tinyimg-token.php';
}
/** 文件首行守卫:任何直接 HTTP 访问都会在这里终止 */
function tinyimg_token_guard()
{
return '<?php exit; /* TinyImg API Token store - DO NOT EDIT */ ?>';
}
/** 把状态数组序列化成文件正文(纯函数,便于测试) */
function tinyimg_token_encode(array $state)
{
$payload = [
'token' => isset($state['token']) ? (string) $state['token'] : '',
'enabled' => !empty($state['enabled']) ? 1 : 0,
'created_at' => isset($state['created_at']) ? (string) $state['created_at'] : '',
'updated_at' => isset($state['updated_at']) ? (string) $state['updated_at'] : '',
];
return tinyimg_token_guard() . "\n"
. json_encode($payload, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . "\n";
}
/** 解析文件正文,失败返回 null(纯函数) */
function tinyimg_token_decode($raw)
{
$raw = (string) $raw;
$pos = strpos($raw, '?>');
if ($pos === false) {
return null;
}
$json = trim(substr($raw, $pos + 2));
$data = json_decode($json, true);
if (!is_array($data) || !array_key_exists('token', $data)) {
return null;
}
return [
'token' => (string) $data['token'],
'enabled' => !empty($data['enabled']) ? 1 : 0,
'created_at' => isset($data['created_at']) ? (string) $data['created_at'] : '',
'updated_at' => isset($data['updated_at']) ? (string) $data['updated_at'] : '',
];
}
/** 无存储文件时的默认状态(兼容 config.php 的 api_token) */
function tinyimg_token_default($config = [])
{
$legacy = (is_array($config) && isset($config['api_token']))
? trim((string) $config['api_token'])
: '';
return [
'token' => $legacy,
'enabled' => $legacy === '' ? 0 : 1,
'created_at' => '',
'updated_at' => '',
'source' => $legacy === '' ? 'none' : 'config',
];
}
/** 读取当前状态;返回数组一定含 source 字段:file / config / none */
function tinyimg_token_load($config = [])
{
$fallback = tinyimg_token_default($config);
$file = tinyimg_token_file();
if (!is_file($file)) {
return $fallback;
}
$raw = @file_get_contents($file);
if ($raw === false) {
return $fallback;
}
$state = tinyimg_token_decode($raw);
if ($state === null) {
return $fallback;
}
$state['source'] = 'file';
return $state;
}
/** 生成随机 Token;优先 CSPRNG,最后才退化到弱随机 */
function tinyimg_token_generate($bytes = 32)
{
if (function_exists('random_bytes')) {
return bin2hex(random_bytes($bytes));
}
if (function_exists('openssl_random_pseudo_bytes')) {
return bin2hex(openssl_random_pseudo_bytes($bytes));
}
return md5(uniqid('', true) . mt_rand() . microtime(true))
. md5(uniqid('', true) . mt_rand());
}
/** 自定义 Token 的格式约束:16~128 位字母数字 / 下划线 / 短横线 */
function tinyimg_token_valid_format($token)
{
return (bool) preg_match('/^[A-Za-z0-9_-]{16,128}$/', (string) $token);
}
/** 恒定时间比较;未启用 / 空配置 / 空请求一律拒绝(fail closed) */
function tinyimg_token_verify($state, $provided)
{
$stored = is_array($state) && isset($state['token']) ? (string) $state['token'] : '';
$enabled = is_array($state) && !empty($state['enabled']);
$provided = (string) $provided;
if (!$enabled || $stored === '' || $provided === '') {
return false;
}
return function_exists('hash_equals')
? hash_equals($stored, $provided)
: $stored === $provided;
}
/** 脱敏显示:保留前 6 位与后 4 位 */
function tinyimg_token_mask($token)
{
$token = (string) $token;
if ($token === '') {
return '(未设置)';
}
if (strlen($token) <= 12) {
return str_repeat('*', strlen($token));
}
return substr($token, 0, 6) . str_repeat('*', 12) . substr($token, -4);
}
/** 原子写入存储文件;返回 [是否成功, 消息] */
function tinyimg_token_save($token, $enabled, $config = [])
{
$file = tinyimg_token_file();
$dir = dirname($file);
if (!is_dir($dir)) {
return [false, 'db 目录不存在'];
}
if (!is_writable($dir)) {
return [false, 'db 目录不可写,请给 Web 用户写权限'];
}
$previous = tinyimg_token_load($config);
$now = date('Y-m-d H:i:s');
$state = [
'token' => (string) $token,
'enabled' => $enabled ? 1 : 0,
'created_at' => $previous['created_at'] !== '' ? $previous['created_at'] : $now,
'updated_at' => $now,
];
$suffix = function_exists('random_bytes')
? bin2hex(random_bytes(4))
: md5(uniqid('', true));
$tmp = $file . '.tmp.' . $suffix;
if (@file_put_contents($tmp, tinyimg_token_encode($state), LOCK_EX) === false) {
@unlink($tmp);
return [false, '写入临时文件失败'];
}
@chmod($tmp, 0600);
if (!@rename($tmp, $file)) {
@unlink($tmp);
return [false, '无法覆盖 Token 存储文件'];
}
@chmod($file, 0600);
return [true, 'ok'];
}
?>
+158
View File
@@ -0,0 +1,158 @@
<?php
// TinyImg 2.0 上传端点
require_once __DIR__ . "/token.php"; // Token 存储 + TINYIMG_VERSION
//载入配置文件($config / $database / $basis)
include_once("./class/class.user.php");
// ==================================================================
// API Token 上传通道(后台「Token 设置」页管理)
//
// 带 X-TinyImg-Token 头(或 POST 字段 token)时:
// - 校验通过 -> 视为管理员上传(admindir + 跳过 limitnum),不依赖 Referer / Cookie
// - 校验失败 -> 直接返回错误,绝不静默退化成游客上传
// 不带 token 时,完全保留原有的 Referer + 登录 Cookie 逻辑(网页上传不受影响)。
// 该 token 只被本端点识别,后台管理(class.admin.php)仍只认登录 Cookie,
// 因此 token 泄露的影响范围仅限「上传图片」,可单独轮换而不动管理员密码。
//
// ?ping=1:只校验 Token、不接收文件,返回版本与管理员目录信息,
// 供 Typecho 插件设置页的「测试连接」按钮使用。
// ==================================================================
$tokenState = tinyimg_token_load($config);
$reqToken = '';
if (isset($_SERVER['HTTP_X_TINYIMG_TOKEN'])) {
$reqToken = (string) $_SERVER['HTTP_X_TINYIMG_TOKEN'];
} elseif (isset($_POST['token'])) {
$reqToken = (string) $_POST['token'];
}
$isPing = isset($_GET['ping']) && (string) $_GET['ping'] === '1';
if ($isPing && $reqToken === '') {
$basis->re_error('缺少 API Token(X-TinyImg-Token)');
}
if ($reqToken !== '') {
// tinyimg_token_verify 内部已做 fail closed:未启用 / 空配置 / 空请求一律 false
if (!tinyimg_token_verify($tokenState, $reqToken)) {
$basis->re_error($tokenState['token'] === ''
? 'API Token 未配置,请到后台「Token 设置」生成'
: (empty($tokenState['enabled'])
? 'API Token 上传已停用'
: 'API Token 无效!'));
}
if ($isPing) {
header('Content-Type: application/json; charset=utf-8');
echo json_encode([
'code' => 1,
'msg' => 'Token 有效',
'name' => TINYIMG_NAME,
'version' => TINYIMG_VERSION,
'auth' => 'token',
'admin_dir' => isset($config['admindir']) ? $config['admindir'] : 'upload',
'source' => $tokenState['source'],
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
exit;
}
$status = 'islogin';
} else {
//阻止用户直接访问
if( !isset($_SERVER['HTTP_REFERER']) || !strstr($_SERVER['HTTP_REFERER'],$config['domain']) )
{
$basis->re_error('非法请求!');
}
//检查用户是否登录
$status = $basis->check($config);
}
//检查用户是否登陆来判断上传目录
if($status == 'islogin') {
//设置上传路径
$updir = $config['admindir'];
}
else{
$updir = $config['userdir'];
//限制用户上传数量
$basis->limitnum();
}
//获取上传者信息
$ip = $basis->getip();
$ua = $_SERVER['HTTP_USER_AGENT'];
$date = date('Y-m-d',time());
//载入上传类
include('./class/class.upload.php');
//上传方法
$handle = new upload($_FILES['file']);
if ($handle->uploaded) {
$handle->file_new_name_body = 'image_resized';
//允许上传大小2m
$handle->file_max_size = '2097152';
//允许的MIME类型,仅运行上传图片
$handle->allowed = array('image/*');
// 当前月份
$current_time = date('ym',time());
//上传路径:目录 + 时间
$handle->process('../'.$updir.'/'.$current_time."/");
if ($handle->processed) {
//获取站点域名
$domain = $config['domain'];
//生成文件hash
$fhash = hash_file("md5",$handle->file_dst_pathname,FALSE);
$fhash = substr($fhash,8,16);
//新的文件名(../temp/1804/\d64c8036c0605175.jpg)
$new_img = $handle->file_dst_path.$fhash.'.'.$handle->file_dst_name_ext;
//图片URL地址
$tinyimg = $domain.$updir.'/'.$current_time.'/'.$fhash.'.'.$handle->file_dst_name_ext;
//图片路径(temp/1804/d64c8036c0605175.jpg)
$imgdir = $updir.'/'.$current_time.'/'.$fhash.'.'.$handle->file_dst_name_ext;
//判断文件是否已经存在
if(!is_file($new_img)) {
//对文件更名
rename($handle->file_dst_pathname,$new_img);
}
else{
//删除原始文件
unlink($handle->file_dst_pathname);
}
//检查某张图片是否已经上传过,如果已经上传了,直接返回数据并终止操作
$basis->isupload($imgdir);
//没有上传过的图片,继续写入数据库
$last_user_id = $database->insert("imginfo", [
"path" => $imgdir,
"ip" => $ip,
"ua" => $ua,
"date" => $date,
"dir" => $updir,
"compress" => 0,
"level" => 0
]);
//返回最后的ID
$account_id = $database->id();
//上传成功,返回json数据
$redata = array(
"code" => 1,
"id" => $account_id,
"url" => $tinyimg,
"width" => $handle->image_dst_x,
"height" => $handle->image_dst_y
);
echo $redata = json_encode($redata);
$handle->clean();
} else {
//上传出现错误,返回报错信息
$redata = array(
"code" => 0,
"msg" => $handle->error
);
echo json_encode($redata);
}
}
?>
+7
View File
@@ -0,0 +1,7 @@
<?php
include_once("class/class.admin.php");
@$arr = $_POST['arr'];
$pic->urlup($arr);
?>
+18
View File
@@ -0,0 +1,18 @@
<?php
/**
* TinyImg 版本信息:全站单一来源。
* functions/version.txt 存放可读的版本字符串,后台、上传接口自检、页脚都读这里。
*/
if (!defined('TINYIMG_NAME')) {
define('TINYIMG_NAME', 'TinyImg');
}
if (!defined('TINYIMG_VERSION')) {
$tinyimgVersionFile = __DIR__ . '/version.txt';
$tinyimgVersion = @file_get_contents($tinyimgVersionFile);
$tinyimgVersion = ($tinyimgVersion === false) ? '' : trim($tinyimgVersion);
define('TINYIMG_VERSION', $tinyimgVersion === '' ? 'v2.0.0' : $tinyimgVersion);
unset($tinyimgVersionFile, $tinyimgVersion);
}
?>
+1
View File
@@ -0,0 +1 @@
v2.0.0(20261104)
+127
View File
@@ -0,0 +1,127 @@
<?php
$title = "TinyImg - 简单、纯粹的图床程序。";
include_once("./tpl/user/header.php");
//判断程序是否已安装
$homedir = __DIR__;
$homedir = str_replace("\\","/",$homedir);
//$homedir = str_replace("tpl/user","",$homedir);
$lockfile = $homedir.'/config.php';
if(!file_exists($lockfile)){
header("location:./install.php?setup=1");
}
?>
<div class="layui-container">
<div class="layui-row">
<div class="layui-col-lg12 layui-col-xs12">
<div class="msg"><i class="layui-icon">&#xe645;</i> 注意:您上传的图片将会公开显示,勿上传隐私图片。游客限制每天10张,最大支持2M</div>
<!-- 上传图片表单 -->
<div class="layui-upload-drag" id="upimg">
<i class="layui-icon">&#xe67c;</i>
<p>将图片拖拽到此处,支持Ctrl + V粘贴上传</p>
</div>
<!-- 上传图片表单END -->
</div>
</div>
<div style = "clear:both;"></div>
<!-- 图片上传成功 -->
<div class="layui-row" id = "upok">
<div>
<div id="showpic" class = "layui-col-lg5"><a href="" target = "_blank"><img src="./static/loading32.gif"></a></div>
<div id="piclink" class = "layui-col-lg6 layui-col-md-offset1">
<table class="layui-table" lay-skin="nob">
<colgroup>
<col width="80">
<col width="400">
<col>
</colgroup>
<tbody>
<tr>
<td>URL</td>
<td><input type="text" class="layui-input" id = "url"></td>
<td><a href="javascript:;" class = "layui-btn layui-btn-sm" onclick = "copy('url')">复制</a></td>
</tr>
<tr>
<td>HTML</td>
<td><input type="text" class="layui-input" id = "html"></td>
<td><a href="javascript:;" class = "layui-btn layui-btn-sm" onclick = "copy('html')">复制</a></td>
</tr>
<tr>
<td>MarkDown</td>
<td><input type="text" class="layui-input" id = "markdown"></td>
<td><a href="javascript:;" class = "layui-btn layui-btn-sm" onclick = "copy('markdown')">复制</a></td>
</tr>
<tr>
<td>BBcode</td>
<td><input type="text" class="layui-input" id = "bbcode"></td>
<td><a href="javascript:;" class = "layui-btn layui-btn-sm" onclick = "copy('bbcode')">复制</a></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<!-- 图片上传成功END -->
</div>
<!--Ctrl + V粘贴上传-->
<script>
var load1 = document.querySelector("#upimg");
// 实例化即可
new ctrlVUtil({
uploadUrl: "functions/cvupload.php",
targetElement: load1,
isCompleteImg:false,
data:{
name:"alanzhang",
},
success:function(data){
//转为对象
var res = data;
//上传成功
if(res.code == 1){
layer.closeAll('loading');
$("#showpic a").attr('href',res.url);
$("#showpic img").attr('src',res.url);
$("#url").val(res.url);
$("#html").val("<img src = '" + res.url + "' />");
$("#markdown").val("![](" + res.url + ")");
$("#bbcode").val("[img]" + res.url + "[/img]");
$("#upok").show();
//请求接口处理图片
$.get("./dispose.php?id="+res.id,function(data,status){
var obj = eval('(' + data + ')');
if(obj.level == 3){
layer.open({
title: '温馨提示'
,content: '请勿上传违规图片!'
});
}
if(obj.level == null){
$.get("./dispose.php?id="+res.id,function(data,status){
var obj = eval('(' + data + ')');
if(obj.level == 3){
layer.open({
title: '温馨提示'
,content: '请勿上传违规图片!'
});
}
});
}
});
}
else{
layer.msg(res.msg);
}
},
error: function(error){
layer.closeAll('loading');
layer.msg('上传失败!');
}
});
</script>
<!--粘贴上传END-->
<?php
include_once("./tpl/user/footer.php");
?>
+41
View File
@@ -0,0 +1,41 @@
<?php
//载入类
//echo __DIR__."/functions/class/class.install.php";
include_once(__DIR__."/functions/class/class.install.php");
@$setup = (int)$_GET['setup'];
$install = new Install;
$statusarr = $install->check();
$info = $install->info();
switch ($setup) {
case 1:
//载入模板
include_once("./tpl/user/header.php");
include_once("./tpl/user/install1.php");
include_once("./tpl/user/footer.php");
break;
case 2:
include_once("./tpl/user/header.php");
include_once("./tpl/user/install2.php");
include_once("./tpl/user/footer.php");
break;
case 3:
//获取用户名
@$data['user'] = $_POST['user'];
//获取用户密码
@$data['pass1'] = $_POST['pass1'];
@$data['pass2'] = $_POST['pass2'];
@$data['domain'] = $_POST['domain'];
@$data['homedir'] = $_POST['homedir'];
$install->setup($data);
include_once("./tpl/user/header.php");
include_once("./tpl/user/install3.php");
include_once("./tpl/user/footer.php");
break;
default:
header("location:./install.php?setup=1");
break;
}
?>
+166
View File
@@ -0,0 +1,166 @@
<!DOCTYPE html>
<html lang="zh-cmn-Hans" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>TinyImg - 简单、纯粹的图床程序。</title>
<meta name="generator" content="TinyImg" />
<meta name="keywords" content="TinyImg,自建图床,图床程序,图片上传" />
<meta name="description" content="TinyImg 是一款简洁、纯粹的图床程序,使用 PHP + SQLite 开发,开箱即用。" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<link rel="Bookmark" href="favicon.ico" />
<link rel="stylesheet" href="./static/layui/css/layui.css">
<link rel="stylesheet" href="./static/style.css?v=2.0">
<script src = "https://libs.xiaoz.top/clipBoard.js/clipBoard.min.js"></script>
<style type="text/css" media="screen">
#imgbtn{
display: none;
}
</style>
</head>
<body>
<div class="layui-container">
<div class="layui-row">
<div class="layui-col-lg12 layui-col-xs12">
<div class="msg"><i class="layui-icon">&#xe645;</i> 注意:您上传的图片将会公开显示,勿上传隐私图片。</div>
<!--选项卡-->
<div class="layui-tab layui-tab-brief" lay-filter="uptab">
<ul class="layui-tab-title">
<li class="layui-this">上传图片</li>
<li>关于</li>
</ul>
<div class="layui-tab-content">
<div class="layui-tab-item layui-show">
<!-- 上传图片表单 -->
<div class="layui-upload-drag" id="upimg">
<i class="layui-icon">&#xe67c;</i>
<p>将图片拖拽到此处,或将鼠标移动到这里支持 Ctrl + V 上传</p>
</div>
<!-- 上传图片表单END -->
</div>
<div class="layui-tab-item">
<h1>TinyImg</h1>
<p>TinyImg 是一款简洁、纯粹的图床程序,使用 PHP + SQLite 开发,开箱即用。第三方图床上传通道已移除。</p>
<br /><h2>主要功能</h2><br />
<ul>
<li>拖拽上传、粘贴上传、实时预览</li>
<li>一键生成链接,一键复制</li>
<li>图片管理</li>
<li>API Token 上传(配合 Typecho 插件使用)</li>
</ul>
<br /><h2>使用说明</h2><br />
<ul>
<li>图片最大上传限制为 2 MB</li>
<li>游客每天上传数量受后台配置限制</li>
<li>勿上传违规图片</li>
<li>使用 TinyImg 即代表同意以上说明</li>
</ul>
</div>
</div>
</div>
<!--选项卡END-->
</div>
</div>
<div style = "clear:both;"></div>
<!-- 图片上传成功 -->
<div class="layui-row" id = "upok" style = "margin-top:1em;">
<div>
<div id="showpic" class = "layui-col-lg5"><a href="" target = "_blank"><img src=""></a></div>
<div id="piclink" class = "layui-col-lg6 layui-col-md-offset1">
<table class="layui-table" lay-skin="nob">
<colgroup>
<col width="80">
<col width="400">
<col>
</colgroup>
<tbody>
<tr>
<td>URL</td>
<td><input type="text" class="layui-input" id = "url"></td>
<td><a href="javascript:;" class = "layui-btn layui-btn-sm" onclick = "copy('url')">复制</a></td>
</tr>
<tr>
<td>HTML</td>
<td><input type="text" class="layui-input" id = "html"></td>
<td><a href="javascript:;" class = "layui-btn layui-btn-sm" onclick = "copy('html')">复制</a></td>
</tr>
<tr>
<td>MarkDown</td>
<td><input type="text" class="layui-input" id = "markdown"></td>
<td><a href="javascript:;" class = "layui-btn layui-btn-sm" onclick = "copy('markdown')">复制</a></td>
</tr>
<tr>
<td>BBcode</td>
<td><input type="text" class="layui-input" id = "bbcode"></td>
<td><a href="javascript:;" class = "layui-btn layui-btn-sm" onclick = "copy('bbcode')">复制</a></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<!-- 图片上传成功END -->
</div>
<div style = "clear:both;"></div>
<script src="https://cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
<script src = "./static/ctrv-upload.js"></script>
<script src="./static/layui/layui.js"></script>
<script src="./static/embed.js?v=2.0"></script>
<script>
layui.use(['element','layer'],function(){
layui.element;
});
var load1 = document.querySelector("body");
// 粘贴上传
new ctrlVUtil({
uploadUrl: "functions/cvupload.php",
targetElement: load1,
isCompleteImg:false,
data:{
name:"tinyimg",
},
success:function(data){
var res = data;
if(res.code == 1){
layer.closeAll('loading');
$("#showpic a").attr('href',res.url);
$("#showpic img").attr('src',res.url);
$("#url").val(res.url);
$("#html").val("<img src = '" + res.url + "' />");
$("#markdown").val("![](" + res.url + ")");
$("#bbcode").val("[img]" + res.url + "[/img]");
$("#upok").show();
$.get("./dispose.php?id="+res.id,function(data,status){
var obj = eval('(' + data + ')');
if(obj.level == 3){
layer.open({
title: '温馨提示'
,content: '请勿上传违规图片!'
});
}
if(obj.level == null){
$.get("./dispose.php?id="+res.id,function(data,status){
var obj = eval('(' + data + ')');
if(obj.level == 3){
layer.open({ title: '温馨提示', content: '请勿上传违规图片!' });
}
});
}
});
}
else{
layer.msg(res.msg);
}
},
error: function(error){
layer.closeAll('loading');
layer.msg('上传失败!');
}
});
</script>
</body>
</html>
+6
View File
@@ -0,0 +1,6 @@
User-Agent: *
Disallow: /admin/
Disallow: /db/
Disallow: /functions/
Disallow: /static/
Disallow: /tpl/
+22
View File
@@ -0,0 +1,22 @@
<?php
// TinyImg 2.0:第三方 SM.MS 上传通道已屏蔽。
// 保留本文件是为了让旧书签 / 爬虫得到一个明确答复,而不是 404 或继续执行上传。
http_response_code(410);
$title = "功能已关闭 - TinyImg";
include_once("./tpl/user/header.php");
?>
<div class="layui-container" style="margin-top:2em;">
<div class="layui-row">
<div class="layui-col-lg12">
<div class="msg"><i class="layui-icon">&#xe645;</i>
第三方 SM.MS 上传功能已在 TinyImg 2.0 中关闭,本页不再提供上传入口。
请返回<a href="./">首页</a>或<a href="miniup.html">极简上传</a>页面使用本站图床。
</div>
</div>
</div>
</div>
<?php
include_once("./tpl/user/footer.php");
?>
+1
View File
File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 9.5 KiB

+8
View File
@@ -0,0 +1,8 @@
/**
* clipboard.js
* width clipboard.js, you can copy cut and paste clipboard data
* the main methods ard execCommand for modern browser and clipboardData for ie
* @author ganzw@gmail.com
* @url https://github.com/baixuexiyang/clipBoard.js
*/
!function(t,e){"undefined"!=typeof module&&module.exports?module.exports=e():"function"==typeof define&&define.amd?define(e):this[t]=e()}("clipBoard",function(){"use strict";function t(t,e){this.options=e||{},this.tar=t[0]||t,this.options.copy&&this.copyd(),this.options.cut&&this.cut(),this.options.paste&&this.paste()}return t.prototype.copyd=function(t){if(this.options.beforeCopy&&this.options.beforeCopy(),t=t||this.tar.value||this.tar.innerText,this.options.copy&&(t=this.options.copy()),document.execCommand){var e=document.createElement("SPAN");if(e.textContent=t,document.body.appendChild(e),document.selection){var o=document.body.createTextRange();o.moveToElementText(e),o.select()}else if(window.getSelection){var o=document.createRange();o.selectNode(e),window.getSelection().removeAllRanges(),window.getSelection().addRange(o)}document.execCommand("copy"),e.remove?e.remove():e.removeNode(!0)}window.clipboardData&&window.clipboardData.setData("text",t),this.options.afterCopy&&this.options.afterCopy()},t.prototype.cut=function(){if("text"===this.tar.type||"textarea"===this.tar.type){if(this.options.beforeCut&&this.options.beforeCut(),document.execCommand){var t=this.tar;if(document.selection){var e=document.body.createTextRange();e.moveToElementText(t),e.select()}else window.getSelection&&t.select();document.execCommand("cut")}window.clipboardData&&(window.clipboardData.setData("text",this.tar.value),this.tar.value=""),this.options.afterCut&&this.options.afterCut()}},t.prototype.paste=function(){if("text"===this.tar.type||"textarea"===this.tar.type){if(this.options.beforePaste&&this.options.beforePaste(),document.execCommand){var t=this.tar;if(t.setSelectionRange)t.focus(),t.setSelectionRange(t.value.length,t.value.length);else if(t.createTextRange){var e=t.createTextRange();e.collapse(!0),e.moveEnd("character",t.value.length),e.moveStart("character",t.value.length),e.select()}document.execCommand("paste")}!document.execCommand&&window.clipboardData&&(this.tar.value+=window.clipboardData.getData("text")),this.options.afterPaste&&this.options.afterPaste()}},t});
+112
View File
@@ -0,0 +1,112 @@
'use strict';
(function(root, factory){
if (typeof define === 'function' && define.amd) {
define([], factory);
} else if (typeof exports === 'object') {
module.exports = factory();
} else {
root.ctrlVUtil = factory();
}
}(this, function(){
function ctrlVUtil(option){
this.targetElement = null;
this.uploadInput = null;
this.uploadUrl = "http://www.oa.com/screenshot/create-file";
this.isCompleteImg = false;
var that = this;
that.mixinConfig(option);
that.targetElement.addEventListener("mouseover", function() {
that.uploadInput.focus();
});
that.targetElement.addEventListener("click", function() {
that.uploadInput.focus();
});
that.targetElement.addEventListener("mouseleave", function() {
that.uploadInput.blur();
});
that.uploadInput.addEventListener('paste', function(e) {
that.handlePaste(e);
});
}
ctrlVUtil.prototype.mixinConfig = function(option){
this.targetElement = option.targetElement || document.querySelector(".js-upload");
this.uploadInput = this.createInputTarget();
this.isCompleteImg = "isCompleteImg" in option ? option.isCompleteImg : this.isCompleteImg;
this.uploadUrl = option.uploadUrl || this.uploadUrl;
this.data = option.data;
this.success = option.success || function(data) {
console.log(data);
};
this.error = option.error || function(error) {
console.log(error);
};
};
ctrlVUtil.prototype.createInputTarget = function() {
var imgContinaer = document.createElement("div");
imgContinaer.style.cssText = "border:none;margin:0;padding:0;font-size: 0;height:1px;width:1px;opacity:0;position:fixed;z-index:-1;";
imgContinaer.contentEditable = true;
imgContinaer.class = "ui-ctrlv-uploadInput";
this.targetElement.parentNode.insertBefore(imgContinaer, this.targetElement);
return imgContinaer;
};
ctrlVUtil.prototype.handlePaste = function(e){
var that = this;
if (e && e.clipboardData && e.clipboardData.items) {
var item = e.clipboardData.items[0],
that = this;
if (item.type.indexOf('image') != -1) {
var blob = item.getAsFile();
var fileReader = new FileReader();
fileReader.readAsDataURL(blob);
fileReader.addEventListener('load', function(e) {
var file = e.target.result;
that.send(file);
}, false);
} else {
layer.msg('请粘贴image类型!');
}
} else {
setTimeout(function() {
var $img = that.uploadInput.querySelector("img");
if ($img) {
that.send($img.src);
} else {
layer.msg('当前浏览器不支持剪贴板操作!');
return;
}
}, 200);
}
};
ctrlVUtil.prototype.send = function(imgcontent) {
layer.load();
var that = this;
that.uploadInput.innerHTML = "";
var data = that.data || {};
data.content = this.isCompleteImg ? imgcontent : imgcontent.split(';')[1].split(',')[1];
var xhr = new XMLHttpRequest();
xhr.open("post",that.uploadUrl,true);
xhr.onreadystatechange = function(e) {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
var ret = JSON.parse(xhr.responseText);
that.success && that.success(ret);
} else {
that.error && that.error(e, xhr);
}
}
};
xhr.onerror = function(e) {
that.error && that.error(e, xhr);
};
xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
var dataString = [];
for(var key in data){
dataString.push(key+"="+encodeURIComponent(data[key]));
}
xhr.send(dataString.join("&"));
};
ctrlVUtil.prototype.alertMsg = function(content){
alert(content);
}
return ctrlVUtil;
}));
+396
View File
@@ -0,0 +1,396 @@
//layui 根目录配置
layui.config({
base: '/static/layui/',
})
//载入layui组建
layui.use(['layer', 'form','element','upload','flow'], function(){
var form = layui.form;
var layer = layui.layer;
var element = layui.element;
var upload = layui.upload;
var flow = layui.flow;
//图片懒加载
flow.lazyimg({
elem:'#found-img img'
});
flow.lazyimg({
elem:'#adminpic img'
});
//图片查看器
layer.photos({
photos: '#adminpic'
,anim: 5 //0-6的选择,指定弹出图片动画类型,默认随机(请注意,3.0之前的版本用shift参数)
});
layer.photos({
photos: '#found-img'
,anim: 5 //0-6的选择,指定弹出图片动画类型,默认随机(请注意,3.0之前的版本用shift参数)
});
//首页拖拽上传
upload.render({
elem: '#upimg'
,url: 'functions/upload.php'
,size: 2048 //限制上传大小为2M
,before: function(obj){ //obj参数包含的信息,跟 choose回调完全一致,可参见上文。
layer.load(); //上传loading
}
,done: function(res){
//如果上传失败
if(res.code == 0){
layer.open({
title: '温馨提示'
,content: res.msg
});
layer.closeAll('loading');
}
else if(res.code == 1){
layer.closeAll('loading');
$("#showpic a").attr('href',res.url);
$("#showpic img").attr('src',res.url);
$("#url").val(res.url);
$("#html").val("<img src = '" + res.url + "' />");
$("#markdown").val("![](" + res.url + ")");
$("#bbcode").val("[img]" + res.url + "[/img]");
$("#upok").show();
//请求接口处理图片
$.get("./dispose.php?id="+res.id,function(data,status){
var obj = eval('(' + data + ')');
if(obj.level == 3){
layer.open({
title: '温馨提示'
,content: '请勿上传违规图片!'
});
}
if(obj.level == null){
$.get("./dispose.php?id="+res.id,function(data,status){
var obj = eval('(' + data + ')');
if(obj.level == 3){
layer.open({
title: '温馨提示'
,content: '请勿上传违规图片!'
});
}
});
}
});
}
}
});
// TinyImg 2.0:第三方 SM.MS 上传通道已移除,仅保留本站上传
});
//复制链接
function copy(info){
var copy = new clipBoard(document.getElementById('piclink'), {
beforeCopy: function() {
info = $("#" + info).val();
},
copy: function() {
return info;
},
afterCopy: function() {
}
});
layui.use('layer', function(){
var layer = layui.layer;
layer.msg('复制成功!', {time: 2000})
});
}
//后台复制URL
function copyurl(url){
var copy = new clipBoard(document.getElementById('adminpic'), {
beforeCopy: function() {
},
copy: function() {
return url;
},
afterCopy: function() {
}
});
layui.use('layer', function(){
var layer = layui.layer;
layer.msg('链接已复制!', {time: 2000})
});
}
//复制链接
function newcopy(info){
var copy = new clipBoard(document.getElementById('url'), {
beforeCopy: function() {
info = $("#" + info).val();
},
copy: function() {
return info;
},
afterCopy: function() {
}
});
layui.use('layer', function(){
var layer = layui.layer;
layer.msg('复制成功!', {time: 2000})
});
}
//用户登录方法
function login(){
// 获取用户提交的信息
var user = $("#user").val();
var password = $("#password").val();
if((user == '') || (password == '')){
layer.msg('用户名或密码不能为空!');
return false;
}
$.post("../functions/Controller.php?type=login",{user:user,password:password},function(data,status){
layer.msg(data,{time:2000});
});
}
//用户前台预览图片
function userpreview(tinyimg,id){
var showimg = "<center><img style = 'max-width:100%;max-height:100%;' src = '" + tinyimg + "' /></center>";
layui.use('layer', function(){
var layer = layui.layer;
layer.open({
type: 1,
title:"图片预览",
area: ['80%', '80%'],
content: showimg
});
});
}
//后台管理员查看图片
function adminshow(tinyimg,id){
$("#adminshow").show();
$("#url").val(tinyimg);
$("#html").val("<img src = '" + tinyimg + "' />");
$("#markdown").val("![](" + tinyimg + ")");
$("#bbcode").val("[img]" + tinyimg + "[/img]");
$("#copy").show();
$("#adminshow img").attr("src",tinyimg);
layui.use('layer', function(){
var layer = layui.layer;
layer.open({
type: 1,
title:false,
area: '720px',
content: $("#adminshow"),
btn: ['删除'],
cancel: function(index, layero){
$("#adminshow img").attr("src","");
$("#copy").hide();
},
yes: function(index, layero){
layer.confirm('确认删除?', {icon: 3, title:'温馨提示!'}, function(index){
$.get("./delete.php?id="+id,function(data,status){
if(data == 'ok') {
$("#imgid"+id).remove();
$("#adminshow img").attr("src","");
$("#copy").hide();
}
else{
alert(data);
}
});
layer.closeAll();
});
}
});
});
}
//删除某张图片
function deleteimg(id){
layer.confirm('确认删除?', {icon: 3, title:'温馨提示!'}, function(index){
$.get("./delete.php?id="+id,function(data,status){
if(data == 'ok') {
$("#imgid"+id).remove();
}
else{
alert(data);
}
});
layer.close(index);
});
}
//取消图片可疑状态
function cdubious(id){
layer.confirm('确认取消图片可疑状态?', {icon: 3, title:'温馨提示!'}, function(index){
$.get("./operation.php?type=cdubious&id="+id,function(data,status){
if(data == 'ok') {
$("#imgid"+id).remove();
}
else{
alert(data);
}
});
layer.close(index);
});
}
//图片压缩功能
function compress(id){
//layer.msg('该功能还在开发中!', {time: 2000})
layer.open({
type:3
,content: '处理中...'
});
$.get("../functions/class/class.pic.php?id=" + id,function(data,status){
if(status == 'success'){
layer.closeAll('loading');
}
layer.open({
title: '温馨提示:',
time:2000
,content: data
});
});
}
//IP查询
function ipquery(ip){
$.get("https://ip.awk.sh/api.php?data=addr&ip=" + ip,function(data,status){
if(status == 'success') {
layer.open({
title: 'IP查询结果:'
,content: data
,time:3000
});
}
});
}
//关于
function about(){
url = window.location.protocol + '//';
url = url + window.location.host + '/';
layer.open({
title: '关于',
type: 2,
area: ['240px', '100px'],
content: "./about.php"
});
}
//删除本页所有照片
function delall(){
layer.confirm('确认删除本页所有图片?', {icon: 3, title:'提示'}, function(index){
//do something
layer.close(index);
});
}
//预览图片
function previewimg(id,url){
var imgid = "img" + id;
var upid = id - 1;
var dnid = id + 1;
$("#show" + upid).hide();
$("#show" + dnid).hide();
$("#img" + id).attr('src',url);
$("#show" + id).show();
}
//隐藏图片
function hideimg(id){
var upid = id - 1;
var dnid = id + 1;
$("#show" + id).hide();
$("#show" + upid).hide();
$("#show" + dnid).hide();
}
//Ctrl + V上传图片
//$(document).keyup(function(){
// if(event.keyCode == 86){
// }
//});
//预览图片
function viewimg(id,tinyimg){
id = "viewimg" + id;
$("#" + id + " img").attr('src',tinyimg);
//显示图片
$("#" + id).show();
}
//隐藏图片
function hideimg(id){
id = "viewimg" + id;
$("#" + id).hide();
}
//URL上传
function urlup(){
layui.use('layer', function(){
var layer = layui.layer;
layer.open({
type:3
,content: '上传中,请等待...'
});
});
arr = $("#arrurl").val();
//如果地址为空
if(arr == ''){
layer.closeAll('loading');
layer.msg('地址不能为空!');
return false;
}
$.post("../functions/urlup.php",{arr:arr},function(data,status){
var re = eval('(' + data + ')');
if(re.code == 1){
//关闭加载层
layer.closeAll('loading');
layer.msg(re.msg);
}
else if(re.code == 0){
//关闭加载层
layer.closeAll('loading');
layer.msg(re.msg);
}
else{
layer.closeAll('loading');
layer.msg(re.msg);
}
});
}
//时间筛选
function screen(page){
var starttime = $("#starttime").val();
var endtime = $("#endtime").val();
if((starttime == '') || (endtime == '')){
layui.use('layer', function(){
var layer = layui.layer;
layer.msg('请选择时间!');
});
}
else{
window.location.href = page + "?page=1&date=" + starttime + '|' + endtime;
}
}
+228
View File
@@ -0,0 +1,228 @@
/*!
*
* @author: diandian & alanzhang
* @date: 2016/8/19
* @overview: [截屏后,按粘贴快捷键ctrl+v上传,]
* @兼容性说明: IE11,Firefox,chrome
*
*/
'use strict';
(function(root, factory){
if (typeof define === 'function' && define.amd) {
// AMD
define([], factory);
} else if (typeof exports === 'object') {
// Node, CommonJS-like
module.exports = factory();
} else {
// Browser globals (root is window)
root.ctrlVUtil = factory();
}
}(this, function(){
function ctrlVUtil(option){
// 鼠标在该元素上,使用ctrl+v键时上传
this.targetElement = null;
// 用于响应paste事件的元素,如果页面不传递,则创建该元素,并位于targetElement前面
this.uploadInput = null;
// 默认的上传地址
this.uploadUrl = "http://www.oa.com/screenshot/create-file";
// 对于读取的图片base64,前缀为data:image/jpg;base64,base64content
// isCompleteImg为false则去掉前缀直接上传内容部分,为true则上传完整的base64字符串
this.isCompleteImg = false;
var that = this;
// 合并参数
that.mixinConfig(option);
// 鼠标移入和点击时上传,移出时失焦
that.targetElement.addEventListener("mouseover", function() {
that.uploadInput.focus();
});
that.targetElement.addEventListener("click", function() {
that.uploadInput.focus();
});
// 移除鼠标则input失去交掉
that.targetElement.addEventListener("mouseleave", function() {
that.uploadInput.blur();
});
// 监听paste的事件
that.uploadInput.addEventListener('paste', function(e) {
that.handlePaste(e);
});
}
/**
* [mixinConfig 整合参数]
* @param {[type]} option [description]
* @return {[type]} [description]
*/
ctrlVUtil.prototype.mixinConfig = function(option){
this.targetElement = option.targetElement || document.querySelector(".js-upload");
this.uploadInput = this.createInputTarget();
this.isCompleteImg = "isCompleteImg" in option ? option.isCompleteImg : this.isCompleteImg;
// 上传地址
this.uploadUrl = option.uploadUrl || this.uploadUrl;
// 除了图片内容以外的其他数据
this.data = option.data;
// 上传成功时的回调函数
this.success = option.success || function(data) {
console.log(data);
};
// 上传失败时的回调函数
this.error = option.error || function(error) {
console.log(error);
};
};
/**
* [createInputTarget 创建div元素,用于响应paste事件]
* @return {Element} [description]
*/
ctrlVUtil.prototype.createInputTarget = function() {
var imgContinaer = document.createElement("div");
// 使其不可见
imgContinaer.style.cssText = "border:none;margin:0;padding:0;font-size: 0;height:1px;width:1px;opacity:0;position:fixed;z-index:-1;";
// 让其可编辑,能响应paste事件
imgContinaer.contentEditable = true;
imgContinaer.class = "ui-ctrlv-uploadInput";
// 插入targeElementn前面
this.targetElement.parentNode.insertBefore(imgContinaer, this.targetElement);
return imgContinaer;
};
/**
* [handlePaste 处理粘贴行为]
* @param {Event} e [粘贴事件]
* @return {[type]} [description]
*/
ctrlVUtil.prototype.handlePaste = function(e){
var that = this;
// webkit 内核支持items方法
if (e && e.clipboardData && e.clipboardData.items) {
// 获取item
var item = e.clipboardData.items[0],
that = this;
if (item.type.indexOf('image') != -1) {
var blob = item.getAsFile();
// 创建读取对象
var fileReader = new FileReader();
// 将文件读取为字符串
fileReader.readAsDataURL(blob);
fileReader.addEventListener('load', function(e) {
var file = e.target.result;
that.send(file);
}, false);
} else {
//that.alertMsg("请粘贴image类型");
layer.msg('请粘贴image类型!');
}
// firefox无法使用items方法,在粘贴时,图片会作为img标签插入targetElement中,
// 获取img标签的src内容进行上传
} else {
setTimeout(function() {
var $img = that.uploadInput.querySelector("img");
if ($img) {
that.send($img.src);
} else {
//that.alertMsg("浏览器不支持剪贴板操作");
layer.msg('当前浏览器不支持剪贴板操作!');
return;
}
}, 200);
}
};
/**
* [send 上传图片]
* @param {string} imgcontent [图片内容base64格式]
* @return {[type]} [description]
*/
ctrlVUtil.prototype.send = function(imgcontent) {
//自己添加的,显示上传加载
layer.load();
var that = this;
that.uploadInput.innerHTML = "";
var data = that.data || {};
// 根据sCompleteImg来决定上传的是整体的base64字符串还是仅仅为内容部分
data.content = this.isCompleteImg ? imgcontent : imgcontent.split(';')[1].split(',')[1];
var xhr = new XMLHttpRequest();
xhr.open("post",that.uploadUrl,true);
xhr.onreadystatechange = function(e) {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
var ret = JSON.parse(xhr.responseText);
that.success && that.success(ret);
} else {
that.error && that.error(e, xhr);
}
}
};
xhr.onerror = function(e) {
that.error && that.error(e, xhr);
};
xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
var dataString = [];
for(var key in data){
dataString.push(key+"="+encodeURIComponent(data[key]));
}
xhr.send(dataString.join("&"));
};
ctrlVUtil.prototype.alertMsg = function(content){
alert(content);
}
// 暴露构造函数
return ctrlVUtil;
}));
+4
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+2
View File
@@ -0,0 +1,2 @@
/** layui-v2.2.6 MIT License By https://www.layui.com */
html #layuicss-skincodecss{display:none;position:absolute;width:1989px}.layui-code-h3,.layui-code-view{position:relative;font-size:12px}.layui-code-view{display:block;margin:10px 0;padding:0;border:1px solid #e2e2e2;border-left-width:6px;background-color:#F2F2F2;color:#333;font-family:Courier New}.layui-code-h3{padding:0 10px;height:32px;line-height:32px;border-bottom:1px solid #e2e2e2}.layui-code-h3 a{position:absolute;right:10px;top:0;color:#999}.layui-code-view .layui-code-ol{position:relative;overflow:auto}.layui-code-view .layui-code-ol li{position:relative;margin-left:45px;line-height:20px;padding:0 5px;border-left:1px solid #e2e2e2;list-style-type:decimal-leading-zero;*list-style-type:decimal;background-color:#fff}.layui-code-view pre{margin:0}.layui-code-notepad{border:1px solid #0C0C0C;border-left-color:#3F3F3F;background-color:#0C0C0C;color:#C2BE9E}.layui-code-notepad .layui-code-h3{border-bottom:none}.layui-code-notepad .layui-code-ol li{background-color:#3F3F3F;border-left:none}
File diff suppressed because one or more lines are too long
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

File diff suppressed because one or more lines are too long
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 701 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.
File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 269 KiB

Binary file not shown.
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Some files were not shown because too many files have changed in this diff Show More