- 增加根目录静态属性
- 增加浏览页面懒加载
- 增加浏览页面启用选定日期查看图片
- 增加版本检测 ***每月10日06点和25日01点检测Github是否更新***
- 增加上传压缩 ***此压缩有可能使图片变大!特别是小图片 也有一定概率改变图片方向***
- 增加批量压缩目录 ***TinyImag或本机压缩,本机压缩出现的问题***
- 修复title
- 修复二级目录安装
- 修复对PHP5.6的兼容 ***建议使用php7.0及以上!***
This commit is contained in:
icret
2021-05-22 11:27:53 +08:00
parent fa9c9bdfd2
commit 2d7d5bfe66
40 changed files with 7166 additions and 319 deletions

View File

@@ -1,19 +0,0 @@
<html>
<head>
<meta charset="utf-8">
<title>API图片上传测试</title>
</head>
<body>
<form action="../index.php" method="post" enctype="multipart/form-data">
<input type="file" name="image" accept="image/*" >
<input type="text" name = "token" placeholder="在tokenList文件找到token并输入"/>
<input type="submit" />
</form>
<div id="divResult">
</div>
</body>
</html>

View File

@@ -2,11 +2,14 @@
/*
* API 页面管理
*/
require_once $_SERVER['DOCUMENT_ROOT'] . '/libs/header.php';
require_once 'libs/apiFunction.php';
require_once '../libs/function.php';
require_once '../libs/header.php';
require_once APP_ROOT . '/config/api_key.php';
require_once APP_ROOT . '/api/libs//apiFunction.php';
/*//////////////////////////////////////////////////////////*/
// 检测登录
if (!is_online()) {
checkLogin();
}
// 根据token查找用户ID
if (isset($_POST['token'])) {
@@ -21,48 +24,39 @@ if (isset($_POST['id'])) {
$getToken = null;
}
// 提交登
if (isset($_POST['password'])) {
checkLogin();
header("refresh:1;"); // 1s后刷新当前页面
// 删除非空目
if (isset($_POST['delDir'])) {
$delDir = APP_ROOT . $config['path'] . $_POST['delDir'];
if (deldir($delDir)) {
echo '
<script> new $.zui.Messager("删除成功!", {type: "success" // 定义颜色主题
}).show();</script>';
header("refresh:1;"); // 1s后刷新当前页面
} else {
echo '
<script> new $.zui.Messager("删除失败!", {type: "danger" // 定义颜色主题
}).show();</script>';
header("refresh:1;"); // 1s后刷新当前页面
}
}
?>
if (!is_online()) {
echo '
<script src="../public/static/md5.min.js"></script>
<center>
<div class="alert alert-success">需登录后才能查看全部信息</div>
<div class="center" style="margin: 40px;">
<form class="form-inline" action="' . $_SERVER['PHP_SELF'] . '" method="post" onsubmit="return md5_post()">
<div class="form-group">
<div class="has-success">
<input type="password" name="password" id="password" class="form-control" placeholder="请输入登录密码">
</div>
<input type="hidden" name="password" id="md5_password">
</div>
<button type="submit" class="btn btn-primary">登录</button>
</form>
</div>
</center>
<script>
function md5_post() {
var password = document.getElementById(\'password\');
var md5pwd = document.getElementById(\'md5_password\');
md5pwd.value = md5(password.value);
//可以校验判断表单内容true就是通过提交false阻止提交
return true;
}
</script>
';
} else {
echo '
<div class="row">
<div class="container">
</div class="row">
<div class="col-md-12">
<div class="alert alert-primary">
<h3 style="text-align:center">EasyImage2.0 快捷操作中心</h2>
<hr />
<h5>此页面为常用一键操作,目录保存以 年/月/日/ 递进,非必要请勿修改!否则会导致部分操作不可用。</h4>
</div>
</div>
<div class="col-md-12">
<div class="col-md-4">
<form class="form-condensed" action="' . $_SERVER['PHP_SELF'] . '" method="post">
<form class="form-condensed" action="<?php $_SERVER['PHP_SELF']; ?>" method="post">
<label for="exampleInputMoney1">
生成Token新Token需按要求填入
新Token需按要求填入
<code>
tokenList.php
/config/api_key.php
</code>
才生效
</label>
@@ -70,28 +64,27 @@ if (!is_online()) {
<span class="input-group-addon">
New Token
</span>
<input type="text" class="form-control" id="exampleInputMoney1" value="' . privateToken() . '">
<input type="text" class="form-control" id="exampleInputMoney1" value="<?php echo privateToken(); ?>">
</div>
<div class="form-group">
<label for="exampleInputMoney6">
根据Token查找用户ID
</label>
<input type="text" class="form-control" id="exampleInputMoney6" name="token"
placeholder="输入Token" value="' . $getID . '">
<input type="text" class="form-control" id="exampleInputMoney6" name="token" placeholder="输入Token" value="<?php echo $getID; ?>">
</div>
<button type="submit" class="btn btn-primary">
查找
</button>
</form>
</div>
</div>
<div class="col-md-4">
<div id="title" style="margin: 10px;"></div>
<form class="form-condensed" action="' . $_SERVER['PHP_SELF'] . '" method="post">
<div id="title" style="margin: 10px;"></div>
<form class="form-condensed" action="<?php $_SERVER['PHP_SELF']; ?>" method="post">
<div class="form-group">
<label>
根据ID查找用户Token
根据ID查找用户Token
</label>
<input type="text" name="id" class="form-control" placeholder="请输入用户ID" value="' . $getToken . '">
<input type="text" name="id" class="form-control" placeholder="请输入用户ID" value="<?php echo $getToken; ?>">
</div>
<button type="submit" class="btn btn-mini btn-primary">
查找
@@ -99,44 +92,99 @@ if (!is_online()) {
</form>
</div>
<div class="col-md-4">
<div id="title" style="margin: 10px;"></div>
<form class="form-condensed" method="get" action="del.php" id="form" name="delForm" onSubmit="getStr();">
<div id="title" style="margin: 10px;"></div>
<form class="form-condensed" method="get" action="del.php" id="form" name="delForm" onSubmit="getStr();" target="_blank">
<div class="form-group">
<label>
删除图片 - 格式:<br /><code>https://i1.100024.xyz/i/2021/05/04/10fn9ei.jpg</code>
</label>
<input type="url" name="url" class="form-control" id="del" placeholder="请输入图片链接" />
</div>
<input type="submit" class="btn btn-mini btn-primary" value="删除" />
</form>
</div>
</div>
<div class="col-md-12">
<div class="col-md-4">
<form class="form-condensed" action="index.php" method="post" enctype="multipart/form-data">
<div class="form-group">
<label>
API上传测试 - 选择图片
</label>
<div class="form-group">
<input type="file" name="image" class="form-control" accept="image/*">
</div>
<div class="form-group">
<label>
输入Token
</label>
<input type="text" name="token" class="form-control" placeholder="请输入Token" />
</div>
</div>
<button type="submit" class="btn btn-mini btn-primary">
删除
API上传
</button>
</form>
</div>
';
}
?>
<div class="col-md-4">
<form class="form-condensed" action="index.php" method="post" enctype="multipart/form-data">
<div class="form-group">
<label>
API上传测试 - 选择图片
</label>
<div class="col-md-4">
<form action="../libs/compressing.php" method="post" target="_blank">
<div class="form-group">
<input type="file" name="image" class="form-control" accept="image/*">
<label for="exampleInputInviteCode1">压缩文件夹内图片(格式2021/05/10/)</label>
<input type="text" class="form-control form-date" placeholder="" name="folder" value="2021/05/06/" readonly="">
</div>
<div class="form-group">
<div class="radio">
<label>
输入Token
<input type="radio" name="type" value="Imgcompress" checked="checked"> 使用本地压缩(默认上传已压缩,不需重复压缩)
</label>
<input type="text" name="token" class="form-control" placeholder="请输入Token" />
</div>
</div>
<button type="submit" class="btn btn-mini btn-primary">
API上传
</button>
</form>
<div class="radio">
<label>
<input type="radio" name="type" value="TinyImg"> 使用TinyImag压缩需要申请key)
</label>
</div>
<div>
<label>
* 如果页面长时间没有响应,表示正面正在压缩!
</label>
<label>
两种压缩均为不可逆,并且非常占用硬件资源。
</label>
</div>
<button type="submit" class="btn btn-mini btn-success">开始压缩</button>
</form>
</div>
<div class="col-md-4">
<table class="table table-hover table-bordered table-condensed table-responsive">
<thead>
<tr>
<th>当前可用Token列表</th>
</tr>
</thead>
<tbody>
<?php
foreach ($tokenList as $value) {
echo '<tr><td>' . $value . '</td></tr>';
}
?>
</tbody>
</table>
</div>
</div>
<div class="col-md-12">
<div class="col-md-4">
<form action="<?php $_SERVER['PHP_SELF']; ?>" method="post">
<div class="form-group">
<label for="exampleInputInviteCode1" style="color:red">删除所选日期文件夹(删除之后无法恢复!):</label>
<input type="text" class="form-control form-date" name="delDir" value="2021/05/22/" readonly="">
</div>
<button type="submit" class="btn btn-mini btn-danger">删除目录</button>
</form>
</div>
</div>
</div>
</div>
<link href="../public/static/zui/lib/datetimepicker/datetimepicker.min.css" rel="stylesheet">
<script src="../public/static/zui/lib/datetimepicker/datetimepicker.min.js"></script>
<script>
var oBtn = document.getElementById('del');
var oTi = document.getElementById('title');
@@ -149,33 +197,20 @@ if (!is_online()) {
function getWord() {
oTi.innerHTML = '<img src="' + oBtn.value + '" width="200" class="img-rounded" /><br />';
}
/**
// 动态修改请求地址
function getStr(string, str) {
string = oBtn.value;
str = 'images';
var str_before = string.split(str)[0];
document.delForm.action = str_before + 'del.php';
}
*/
</script>
<div class="col-md-4">
<table class="table table-hover table-bordered table-condensed table-responsive">
<thead>
<tr>
<th>当前Token列表</th>
</tr>
</thead>
<tbody>
<?php
if (is_online()) {
foreach ($tokenList as $value) {
echo '<tr><td>' . $value . '</td></tr>';
}
}
?>
</tbody>
</table>
</div>
<?php require_once './../libs/footer.php';
// 仅选择日期
$(".form-date").datetimepicker({
weekStart: 1,
todayBtn: 1,
autoclose: 1,
todayHighlight: 1,
startView: 2,
minView: 2,
forceParse: 0,
format: "yyyy/mm/dd/"
});
document.title = "管理中心 - <?php echo $config['title']; ?>";
</script>
<?php require_once APP_ROOT . '/libs/footer.php';

28
api/apiTest/index.php Normal file
View File

@@ -0,0 +1,28 @@
<?php
echo '<title> - EasyImage2.0</title>';
require_once '../../libs/function.php';
require_once APP_ROOT . '/libs/header.php';
require_once APP_ROOT . '/config/api_key.php';
?>
<div class="container">
</div class="row">
<div class="col-md-12">
<h4>测试Token<code><?php echo $tokenList['1']; ?></code></h4>
<form action="../index.php" method="post" enctype="multipart/form-data" class="form-inline" target="_blank">
<div class="form-group">
<input type="file" name="image" accept="image/*" class="form-control" />
</div>
<div class="form-group">
<input type="text" name="token" placeholder="请输入Token" class="form-control" />
</div>
<button type="submit" class="btn btn-primary">提交</button>
</form>
</div>
</div>
</div>
<script>
document.title = "API图片上传测试 - <?php echo $config['title']; ?>";
</script>
<?php require_once APP_ROOT . '/libs/footer.php';

View File

@@ -3,8 +3,8 @@
/**
* 删除文件页面
*/
require_once $_SERVER['DOCUMENT_ROOT'] . '/libs/header.php';
require_once '../libs/function.php';
require_once '../libs/header.php';
require_once APP_ROOT . '/libs/function.php';
echo '<div class="col-md-4 col-md-offset-4">
<div id="title" style="margin: 10px;"></div>
@@ -13,7 +13,7 @@ echo '<div class="col-md-4 col-md-offset-4">
<label for="exampleInputInviteCode3">删除图片-格式:</label>
<input type="text" class="form-control" id="exampleInputInviteCode3" name="url" placeholder="https://i1.100024.xyz/i/2021/05/04/10fn9ei.jpg">
</div>
<button type="submit" class="btn btn-primary">删除</button>
<button type="submit" class="btn btn-danger">删除</button>
</form>
</div>
';
@@ -37,15 +37,15 @@ if (empty($_REQUEST)) {
// 解密删除
if (isset($_GET['hash'])) {
$delFile = $_GET['hash'];
$delFile = urlHash($delFile, 1);
getDel($delFile);
$delHash = $_GET['hash'];
$delHash = urlHash($delHash, 1);
getDel($delHash, 'hash');
}
// 检查登录后再处理url删除请求
if (is_online()) {
if (isset($_GET['url'])) {
getDel($_GET['url']);
getDel($_GET['url'], 'url');
}
} else {
if (isset($_GET['url'])) {
@@ -60,9 +60,12 @@ if (is_online()) {
}
}
require_once '../libs/footer.php';
require_once APP_ROOT . '/libs/footer.php';
?>
<script>
// 修改网页标题
document.title = "删除图片 - <?php echo $config['title']; ?>";
var oBtn = document.getElementById('del');
var oTi = document.getElementById('title');
if ('oninput' in oBtn) {
@@ -74,13 +77,4 @@ require_once '../libs/footer.php';
function getWord() {
oTi.innerHTML = '<img src="' + oBtn.value + '" width="200" class="img-rounded" /><br />';
}
/**
// 动态修改请求地址
function getStr(string, str) {
string = oBtn.value;
str = 'images';
var str_before = string.split(str)[0];
document.delForm.action = str_before + 'del.php';
}
*/
</script>

View File

@@ -1,8 +1,8 @@
<?php
require __DIR__ . '/../libs/function.php';
require __DIR__ . '/../libs/class.upload.php';
require __DIR__ . '/../libs/WaterMask.php';
require __DIR__ . '/libs/apiFunction.php';
require_once __DIR__ . './../libs/function.php';
require_once APP_ROOT . '/api/libs/apiFunction.php';
require_once APP_ROOT . '/libs/class.upload.php';
require_once APP_ROOT . '/config/api_key.php';
// 检查是否开启api上传
if ($config['apiStatus']) {
@@ -15,8 +15,6 @@ if ($config['apiStatus']) {
checkToken($_POST['token']);
$token = $_POST['token'];
$handle = new Upload($_FILES['image'], 'zh_CN');
if ($handle->uploaded) {
@@ -87,11 +85,9 @@ if ($handle->uploaded) {
// 图片完整相对路径:/i/2021/05/03/k88e7p.jpg
if ($handle->processed) {
header('Content-type:text/json');
// 上传成功后返回json数据
$imageUrl = $config['domain'] . config_path() . $handle->file_dst_name;
$delUrl = $config['domain'] . '/api/del.php?hash=' . urlHash(config_path() . $handle->file_dst_name, 0);
$imageUrl = $config['imgurl'] . config_path() . $handle->file_dst_name;
$delUrl = $config['domain'] . '/api/del.php?hash=' . urlHash(config_path() . $handle->file_dst_name, 0);
$reJson = array(
"result" => 'success',
@@ -108,5 +104,17 @@ if ($handle->uploaded) {
);
echo json_encode($reJson, JSON_UNESCAPED_UNICODE);
}
// 压缩图片 后压缩模式,不影响前台输出速度
if (!isAnimatedGif($handle->file_dst_pathname))
if ($config['compress']) {
require '../libs/compress/Imagick/class.Imgcompress.php';
$img = new Imgcompress($handle->file_dst_pathname, 1);
$img->compressImg($handle->file_dst_pathname);
// 释放
ob_flush();
flush();
}
unset($handle);
}

View File

@@ -1,7 +1,7 @@
<?php
require_once __DIR__ . '/tokenList.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/config/config.php';
require_once './../config/api_key.php';
require_once './../config/config.php';
// Token 生成
function privateToken($length = 32)

View File

@@ -1,11 +0,0 @@
<?php
/*
* Token list 请在此填写需要配置Token的用户 前边编号有助于识别上传者ID
* 格式: ID数字需要从0开始,顺序添加)=> Token注意后边',')
*/
$tokenList = array(
0 => '8337effca0ddfcd9c5899f3509b23657',
1 => '1c17b11693cb5ec63859b091c5b9c1b2',
2 => '62485ede33bc898d38b9987eb3860ce5',
);