v2.2.0
- 增加根目录静态属性 - 增加浏览页面懒加载 - 增加浏览页面启用选定日期查看图片 - 增加版本检测 ***每月10日06点和25日01点检测Github是否更新*** - 增加上传压缩 ***此压缩有可能使图片变大!特别是小图片 也有一定概率改变图片方向*** - 增加批量压缩目录 ***TinyImag或本机压缩,本机压缩出现的问题*** - 修复title - 修复二级目录安装 - 修复对PHP5.6的兼容 ***建议使用php7.0及以上!***pull/18/head
parent
fa9c9bdfd2
commit
2d7d5bfe66
16
README.md
16
README.md
|
@ -30,7 +30,8 @@
|
|||
1. 安装之前先使用浏览器访问check.php检查扩展是否都安装!
|
||||
2. 请将所有文件赋予0755权限或www权限
|
||||
3. 上传后必须修改config.php的位置:
|
||||
- domain 当前图片域名
|
||||
- domain 当前网站域名
|
||||
- imgurl 当前图片域名
|
||||
- password 登录管理密码!
|
||||
4. 如果无法登陆管理界面或上传图片,请先打开check.php检查扩展或者使用phpinfo检查。
|
||||
5. 可以使用浏览器的 F12调试模式->console查看错误
|
||||
|
@ -83,6 +84,18 @@ RewriteRule config/(.*).(php)$ – [F]
|
|||
|
||||
<details><summary><mark><font color=darkred>点击查看2.0版更新日志</font></mark></summary>
|
||||
|
||||
* 2021-5-8 v2.2.0
|
||||
- 增加根目录静态属性
|
||||
- 增加浏览页面懒加载
|
||||
- 增加浏览页面启用选定日期查看图片
|
||||
- 增加版本检测 ***每月10日06点和25日01点检测Github是否更新***
|
||||
- 增加上传压缩 ***此压缩有可能使图片变大!特别是小图片 也有一定概率改变图片方向***
|
||||
- 增加批量压缩目录 ***TinyImag或本机压缩,本机压缩出现的问题***
|
||||
- 修复title
|
||||
- 修复二级目录安装
|
||||
- 修复对PHP5.6的兼容 ***建议使用php7.0及以上!***
|
||||
|
||||
|
||||
* 2021-5-8 v2.1.1
|
||||
- 修复上传界面上传失败提示信息bug
|
||||
- 浏览页面重构
|
||||
|
@ -91,7 +104,6 @@ RewriteRule config/(.*).(php)$ – [F]
|
|||
- 将调整图片长宽放置前端,减小资源开销
|
||||
- 其他小调整
|
||||
|
||||
|
||||
* 2021-5-2 v2.1
|
||||
- 将tinyfilemanager配置文件简单翻译并集成到config.php
|
||||
- 增加底部自定义信息
|
||||
|
|
Binary file not shown.
|
@ -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>
|
233
api/api-web.php
233
api/api-web.php
|
@ -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';
|
||||
|
|
|
@ -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';
|
28
api/del.php
28
api/del.php
|
@ -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>
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* Token list 请在此填写需要配置Token的用户 前边编号有助于识别上传者ID
|
||||
* 格式: ID(数字,需要从0开始,顺序添加)=> Token(注意后边',')
|
||||
*/
|
||||
|
||||
$tokenList = array(
|
||||
0 => '8337effca0ddfcd9c5899f3509b23657',
|
||||
1 => '1c17b11693cb5ec63859b091c5b9c1b2',
|
||||
2 => '62485ede33bc898d38b9987eb3860ce5',
|
||||
);
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* 此文件用来存放各种key
|
||||
* 2021-5-8 22:04:55
|
||||
*/
|
||||
|
||||
$Api_Key = [
|
||||
// 填写 TinyImag Key 申请地址:https://tinypng.com/developers
|
||||
'TinyImag' => '****7pPVQc9P***4Jvd2zH*****'
|
||||
|
||||
];
|
||||
|
||||
/*
|
||||
* Token list 请在此填写需要配置Token的用户 前边编号有助于识别上传者ID
|
||||
* 格式: ID(数字,需要从0开始,顺序添加)=> Token(注意后边',')
|
||||
*/
|
||||
|
||||
$tokenList = array(
|
||||
0 => '8337effca0ddfcd9c5899f3509b23657',
|
||||
1 => '1c17b11693cb5ec63859b091c5b9c1b2',
|
||||
);
|
|
@ -29,6 +29,8 @@
|
|||
@date_default_timezone_set('Asia/Shanghai');
|
||||
// 修改内存限制 根据服务器配置选择,低于128M容易出现上传失败,你懂得图片挺占用内存的
|
||||
@ini_set('memory_limit', '512M');
|
||||
// 定义根目录
|
||||
@define('APP_ROOT', str_replace('\\', '/', realpath(dirname(__FILE__) . '/../')));
|
||||
|
||||
|
||||
/*---------------图床配置-------------------*/
|
||||
|
@ -42,8 +44,14 @@ $config = array(
|
|||
'description' => '简单图床EasyImage是一款支持多文件上传的无数据库图床,可以完美替代PHP多图上传程序,最新html5自适应页面兼容手机电脑,上传后返回图片直链,markdown图片,论坛贴图bbscode链接,简单方便支持一键复制,支持多域名,api上传。',
|
||||
// 网站公告
|
||||
'tips' => '本站仅做演示用,不定时清理图片,单文件≤5M,每次上传≤30张',
|
||||
// 当前域名,末尾不加"/" 图床域名与图片域名可以不同,比如A域名上传,可以返回B域名链接,A、B需绑定到同一空间下
|
||||
/**
|
||||
* 网站域名与图片链接域名可以不同,比如A域名上传,可以返回B域名图片链接,A、B需绑定到同一空间下
|
||||
* 如果不变的话,下边2个填写成一样的!
|
||||
*/
|
||||
// 网站域名,末尾不加"/"
|
||||
'domain' => 'http://192.168.1.15',
|
||||
// 图片链接域名,末尾不加"/"
|
||||
'imgurl' => 'http://192.168.1.15',
|
||||
/**
|
||||
* 存储路径 前后要加"/"
|
||||
* 可根据Apache/Nginx配置安全,参考:https://www.545141.com/981.html 或 README.md
|
||||
|
@ -54,13 +62,13 @@ $config = array(
|
|||
// 每次最多上传图片数
|
||||
'maxUploadFiles' => 30,
|
||||
// 是否开启登录上传 开启:true 关闭:false
|
||||
'mustLogin' => false,
|
||||
'mustLogin' => true,
|
||||
// 是否开启tinyfilemanager文件管理 开启:true 关闭:false
|
||||
'tinyfilemanager' => true,
|
||||
// 登录上传和后台管理密码,管理用户名为:admin
|
||||
'password' => 'admin@123',
|
||||
// 是否开启API上传 开启:true 关闭:false
|
||||
'apiStatus' => false,
|
||||
'apiStatus' => true,
|
||||
// 是否开启水印:0关闭,1文字水印,2图片水印 不能使用动态gif添加水印
|
||||
'watermark' => 0,
|
||||
// 水印文字内容
|
||||
|
@ -81,7 +89,9 @@ $config = array(
|
|||
// 图片水印路径 支持GIF,JPG,BMP,PNG和PNG alpha
|
||||
'waterImg' => 'public/images/watermark.png',
|
||||
// 允许上传的图片扩展名
|
||||
'extensions' => ['bmp', 'jpg', 'png', 'tif', 'gif', 'pcx', 'tga', 'svg', 'webp', 'jpeg', 'tga', 'svg', 'ico'],
|
||||
'extensions' => "'bmp,jpg,png,tif,gif,pcx,tga,svg,webp,jpeg,tga,svg,ico'",
|
||||
// 轻微有损压缩图片 开启:true 关闭:false * 此压缩有可能使图片变大!特别是小图片 也有一定概率改变图片方向
|
||||
'compress' => true,
|
||||
// 转换图片为指定格式 可选:''|'png'|'jpeg'|'gif'|'bmp';默认值:''
|
||||
'imgConvert' => '',
|
||||
// 最大上传宽度
|
||||
|
@ -127,10 +137,10 @@ $config = array(
|
|||
</a>
|
||||
-->
|
||||
',
|
||||
// 扩展与基本设置检测 开启:true 关闭:false
|
||||
// PHP插件检测-安全设置检测-版本检测 开启:true 关闭:false
|
||||
'checkEnv' => true,
|
||||
// 当前版本
|
||||
'version' => '2.1.1',
|
||||
'version' => '2.2.0',
|
||||
);
|
||||
|
||||
|
||||
|
|
38
file.php
38
file.php
|
@ -1,8 +1,8 @@
|
|||
|
||||
<?php
|
||||
require __DIR__ . '/libs/function.php';
|
||||
require __DIR__ . '/libs/class.upload.php';
|
||||
require __DIR__ . '/libs/WaterMask.php';
|
||||
|
||||
require APP_ROOT . '/libs/class.upload.php';
|
||||
require APP_ROOT . '/libs/WaterMask.php';
|
||||
|
||||
$handle = new Upload($_FILES['file'], 'zh_CN');
|
||||
|
||||
|
@ -23,17 +23,17 @@ if ($handle->uploaded) {
|
|||
$handle->image_min_height = $config['minHeight'];
|
||||
// 转换图片为指定格式
|
||||
$handle->image_convert = $config['imgConvert'];
|
||||
|
||||
/* 等比例缩减图片
|
||||
|
||||
/* 等比例缩减图片 放到前端了
|
||||
if ($config['imgRatio']) {
|
||||
$handle->image_resize = true;
|
||||
$handle->image_x = $config['image_x'];
|
||||
$handle->image_y = $config['image_y'];
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
// 存储图片路径:images/201807/
|
||||
$handle->process(__DIR__ . config_path());
|
||||
$handle->process(APP_ROOT . config_path());
|
||||
|
||||
// 设置水印
|
||||
if ($config['watermark'] > 0) {
|
||||
|
@ -72,12 +72,20 @@ if ($handle->uploaded) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 图片完整相对路径:/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;
|
||||
|
||||
// 判断PHP版本启用删除
|
||||
$ver = substr(PHP_VERSION, 0, 3);
|
||||
if ($ver >= '7.0') {
|
||||
$delUrl = $config['domain'] . '/api/del.php?hash=' . urlHash(config_path() . $handle->file_dst_name, 0);
|
||||
} else {
|
||||
$delUrl = 'PHP≥7.0 才能启用删除!';
|
||||
}
|
||||
|
||||
$reJson = array(
|
||||
"result" => 'success',
|
||||
|
@ -94,5 +102,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);
|
||||
}
|
||||
|
|
25
index.php
25
index.php
|
@ -1,11 +1,10 @@
|
|||
<?php
|
||||
require_once './libs/header.php';
|
||||
require_once 'libs/header.php';
|
||||
|
||||
// 公告
|
||||
if (isset($config['tips'])) {
|
||||
echo '<ul style="list-style: none;margin:1px 1px 30px 1px;"><li class="icon icon-dot-circle text-muted"> ' . $config['tips'] . '</li></ul>';
|
||||
}
|
||||
|
||||
// 检查登录
|
||||
mustLogin();
|
||||
?>
|
||||
|
@ -46,7 +45,7 @@ mustLogin();
|
|||
<a href="#" data-target="#tab2Content5" data-toggle="tab">删除</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="tab-content" align="right">
|
||||
<div class="tab-content" style="text-align:right">
|
||||
<div class="tab-pane fade active in" id="tab2Content1">
|
||||
<textarea class="form-control" style="text-align: center;min-height: 100px;" id="links" readonly></textarea>
|
||||
<button class="btn" style="margin-top:10px;" onclick="location.reload()"><i class="icon icon-repeat"></i> 刷新</button>
|
||||
|
@ -94,25 +93,19 @@ mustLogin();
|
|||
browseByClickList: true,
|
||||
// 上传格式过滤
|
||||
filters: { // 只允许上传图片或图标(.ico)
|
||||
mime_types: [{
|
||||
title: '图片',
|
||||
extensions: <?php echo "'";
|
||||
foreach ($config['extensions'] as $extensions) {
|
||||
echo $extensions . ',';
|
||||
}
|
||||
echo "'"; ?>,
|
||||
}, {
|
||||
title: '图标',
|
||||
extensions: 'ico'
|
||||
}],
|
||||
mime_types: [
|
||||
{title: '图片',extensions: <?php echo $config['extensions']; ?>},
|
||||
{title: '图标',extensions: 'ico'}
|
||||
],
|
||||
prevent_duplicates: true
|
||||
|
||||
},
|
||||
// 限制文件上传数目
|
||||
limitFilesCount: <?php echo $config['maxUploadFiles']; ?>,
|
||||
// 自动上传失败的文件
|
||||
autoResetFails: true,
|
||||
<?php imgRatio(); ?>
|
||||
responseHandler: function(responseObject, file) {
|
||||
responseHandler : function(responseObject, file) {
|
||||
var obj = JSON.parse(responseObject.response); //由JSON字符串转换为JSON对象
|
||||
console.log(responseObject.response); // 输出log
|
||||
if (obj.result === 'success') {
|
||||
|
@ -140,4 +133,4 @@ mustLogin();
|
|||
</script>
|
||||
<?php
|
||||
checkEnv($config['checkEnv']); // 环境检测
|
||||
require_once __DIR__ . '/libs/footer.php';
|
||||
require_once APP_ROOT . '/libs/footer.php';
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* 图片验证码 http://www.phpxs.com/code/1002990/
|
||||
*/
|
||||
|
||||
session_start();
|
||||
$num = 4; //验证码个数
|
||||
$width = 80; //验证码宽度
|
||||
$height = 20; //验证码高度
|
||||
$code = ' ';
|
||||
for ($i = 0; $i < $num; $i++) //生成验证码
|
||||
{
|
||||
switch (rand(0, 2)) {
|
||||
case 0:
|
||||
$code[$i] = chr(rand(48, 57));
|
||||
break; //数字
|
||||
case 1:
|
||||
$code[$i] = chr(rand(65, 90));
|
||||
break; //大写字母
|
||||
case 2:
|
||||
$code[$i] = chr(rand(97, 122));
|
||||
break; //小写字母
|
||||
}
|
||||
}
|
||||
$_SESSION["VerifyCode"] = $code;
|
||||
$image = imagecreate($width, $height);
|
||||
imagecolorallocate($image, 255, 255, 255);
|
||||
for ($i = 0; $i < 80; $i++) //生成干扰像素
|
||||
{
|
||||
$dis_color = imagecolorallocate($image, rand(0, 2555), rand(0, 255), rand(0, 255));
|
||||
imagesetpixel($image, rand(1, $width), rand(1, $height), $dis_color);
|
||||
}
|
||||
for ($i = 0; $i < $num; $i++) //打印字符到图像
|
||||
{
|
||||
$char_color = imagecolorallocate($image, rand(0, 2555), rand(0, 255), rand(0, 255));
|
||||
imagechar($image, 60, ($width / $num) * $i, rand(0, 5), $code[$i], $char_color);
|
||||
}
|
||||
header("Content-type:image/png");
|
||||
imagepng($image); //输出图像到浏览器
|
||||
imagedestroy($image);//释放资源
|
|
@ -59,8 +59,8 @@ class Imgs
|
|||
|
||||
# 创建画布
|
||||
$temp_img = imagecreatetruecolor($temp_w, $temp_h);
|
||||
@imagealphablending($temp_img,false);//这里很重要,意思是不合并颜色,直接用$img图像颜色替换,包括透明色;3-2
|
||||
@imagesavealpha($temp_img,true);//这里很重要,意思是不要丢了$thumb图像的透明色;3-3
|
||||
@imagealphablending($temp_img, false); //这里很重要,意思是不合并颜色,直接用$img图像颜色替换,包括透明色;3-2
|
||||
@imagesavealpha($temp_img, true); //这里很重要,意思是不要丢了$thumb图像的透明色;3-3
|
||||
switch ($info[2]) {
|
||||
case 1:
|
||||
$im = imagecreatefromgif($src);
|
||||
|
@ -74,7 +74,7 @@ class Imgs
|
|||
break;
|
||||
case 3:
|
||||
$im = imagecreatefrompng($src);
|
||||
imagesavealpha($im,true);//这里很重要;3-1
|
||||
imagesavealpha($im, true); //这里很重要;3-1
|
||||
imagecopyresampled($temp_img, $im, 0, 0, 0, 0, $temp_w, $temp_h, $width, $height);
|
||||
imagepng($temp_img, $savepath, 100);
|
||||
break;
|
||||
|
@ -117,7 +117,7 @@ class Imgs
|
|||
);
|
||||
$def = array_merge($def, $arr);
|
||||
/**
|
||||
判断$src是不是图片,不是就创建画布
|
||||
* 判断$src是不是图片,不是就创建画布
|
||||
*/
|
||||
if (!file_exists($src)) {
|
||||
if (empty($def['name'])) {
|
||||
|
@ -127,16 +127,18 @@ class Imgs
|
|||
# 计算画布宽高
|
||||
$obj = explode(',', $src);
|
||||
if (count($obj) != 2) {
|
||||
return array('code' => false,
|
||||
'msg' => '请给正确的宽高,或你给的不是一个有效的地址!');
|
||||
return array(
|
||||
'code' => false,
|
||||
'msg' => '请给正确的宽高,或你给的不是一个有效的地址!'
|
||||
);
|
||||
}
|
||||
|
||||
$srcImg_w = is_numeric($obj[0]) ? $obj[0] : 400;
|
||||
$srcImg_h = is_numeric($obj[1]) ? $obj[1] : 300;
|
||||
# 创建透明画布 一共3个步骤,在下边有标记
|
||||
$dst_img = @imagecreatetruecolor($srcImg_w, $srcImg_h);
|
||||
@imagealphablending($dst_img,false);//这里很重要,意思是不合并颜色,直接用$img图像颜色替换,包括透明色;3-2
|
||||
@imagesavealpha($dst_img,true);//这里很重要,意思是不要丢了$thumb图像的透明色;3-3
|
||||
@imagealphablending($dst_img, false); //这里很重要,意思是不合并颜色,直接用$img图像颜色替换,包括透明色;3-2
|
||||
@imagesavealpha($dst_img, true); //这里很重要,意思是不要丢了$thumb图像的透明色;3-3
|
||||
} else {
|
||||
# 获取图片信息
|
||||
$srcInfo = @getimagesize($src);
|
||||
|
@ -158,7 +160,7 @@ class Imgs
|
|||
|
||||
case 3:
|
||||
$dst_img = imagecreatefrompng($src);
|
||||
imagesavealpha($dst_img,true);//这里很重要;3-1
|
||||
imagesavealpha($dst_img, true); //这里很重要;3-1
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -167,7 +169,7 @@ class Imgs
|
|||
}
|
||||
}
|
||||
/**
|
||||
计算出水印宽高
|
||||
* 计算出水印宽高
|
||||
*/
|
||||
if (!file_exists($def['res'])) {
|
||||
if (!file_exists($def['font'])) {
|
||||
|
@ -207,7 +209,7 @@ class Imgs
|
|||
$logoh = $res_h;
|
||||
}
|
||||
/**
|
||||
计算水印显示位置
|
||||
* 计算水印显示位置
|
||||
*/
|
||||
if ($def['pos'] == 0) {
|
||||
$def['pos'] = rand(1, 9);
|
||||
|
@ -264,7 +266,7 @@ class Imgs
|
|||
exit;
|
||||
}
|
||||
/**
|
||||
把图片水印或文字水印,加到目标图片中
|
||||
* 把图片水印或文字水印,加到目标图片中
|
||||
*/
|
||||
if (file_exists($def['res'])) {
|
||||
imagecopy($dst_img, $markim, $x, $y, 0, 0, $logow, $logoh);
|
||||
|
@ -284,14 +286,22 @@ class Imgs
|
|||
}
|
||||
|
||||
$def['color'] = imagecolorallocatealpha($dst_img, $rgb[0], $rgb[1], $rgb[2], $rgb[3]);
|
||||
imagettftext($dst_img, $def['fontSize'], 0, $x,
|
||||
$y, $def['color'], $def['font'], $def['res']);
|
||||
imagettftext(
|
||||
$dst_img,
|
||||
$def['fontSize'],
|
||||
0,
|
||||
$x,
|
||||
$y,
|
||||
$def['color'],
|
||||
$def['font'],
|
||||
$def['res']
|
||||
);
|
||||
}
|
||||
/**
|
||||
保存处理过的图片(有水印了的图片)
|
||||
* 保存处理过的图片(有水印了的图片)
|
||||
*/
|
||||
$name = explode('.', $def['name']);
|
||||
$num = count($name)-1;
|
||||
$num = count($name) - 1;
|
||||
switch (strtolower($name[$num])) {
|
||||
case 'jpeg':
|
||||
imagejpeg($dst_img, $def['name']);
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @author Icret
|
||||
* 获取GitHub最新版本号
|
||||
* 简单图床 EasyImage2.0 2021-5-10 14:17:25
|
||||
*/
|
||||
|
||||
class getVerson
|
||||
{
|
||||
private $url;
|
||||
public function __construct($url)
|
||||
{
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
public function readJson()
|
||||
{
|
||||
if (file_exists(__DIR__ . '/verson.json')) {
|
||||
$file = fopen(__DIR__ . '/verson.json', 'r');
|
||||
$test = fread($file, filesize(__DIR__ . '/verson.json'));
|
||||
$verson = json_decode($test, true);
|
||||
return $verson['tag_name'];
|
||||
fclose($file);
|
||||
} else {
|
||||
$this->downJson();
|
||||
}
|
||||
}
|
||||
|
||||
public function downJson()
|
||||
{
|
||||
|
||||
$verson = $this->geturl($this->url);
|
||||
$verson = json_decode($verson, true);
|
||||
$file = fopen(__DIR__ . '/verson.json', 'w+');
|
||||
fwrite($file, $verson);
|
||||
fclose($file);
|
||||
}
|
||||
|
||||
public function geturl($url)
|
||||
{
|
||||
$headerArray = array("Content-type:application/json;", "Accept:application/json");
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headerArray);
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36');
|
||||
$output = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
$output = json_encode($output, true);
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
/////////// TEST /////////
|
||||
/*
|
||||
$url = "https://api.github.com/repositories/188228357/releases/latest";
|
||||
$test = new getVerson($url);
|
||||
echo $test->readJson();
|
||||
*/
|
|
@ -0,0 +1,123 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @param string $src 源图
|
||||
* @param float $percent 压缩比例
|
||||
* 简单图床修改版
|
||||
* 此类压缩单文件
|
||||
* https://www.cnblogs.com/jiji/p/12928028.html
|
||||
*/
|
||||
|
||||
|
||||
|
||||
class Imgcompress
|
||||
{
|
||||
private $src;
|
||||
private $image;
|
||||
private $imageinfo;
|
||||
private $percent = 0.5;
|
||||
|
||||
/**
|
||||
* 图片压缩
|
||||
* @param string $src 源图
|
||||
* @param float $percent 压缩比例
|
||||
*/
|
||||
public function __construct($src, $percent = 1)
|
||||
{
|
||||
$this->src = $src;
|
||||
$this->percent = $percent;
|
||||
}
|
||||
|
||||
/** 高清压缩图片
|
||||
* @param string $saveName 提供图片名(可不带扩展名,用源图扩展名)用于保存。或不提供文件名直接显示
|
||||
*/
|
||||
public function compressImg($saveName = '')
|
||||
{
|
||||
$this->_openImage();
|
||||
if (!empty($saveName)) $this->_saveImage($saveName); //保存
|
||||
else $this->_showImage();
|
||||
}
|
||||
|
||||
/**
|
||||
* 内部:打开图片
|
||||
*/
|
||||
private function _openImage()
|
||||
{
|
||||
list($width, $height, $type, $attr) = getimagesize($this->src);
|
||||
$this->imageinfo = array(
|
||||
'width' => $width,
|
||||
'height' => $height,
|
||||
'type' => image_type_to_extension($type, false),
|
||||
'attr' => $attr
|
||||
);
|
||||
$fun = "imagecreatefrom" . $this->imageinfo['type'];
|
||||
$this->image = $fun($this->src);
|
||||
$this->_thumpImage();
|
||||
}
|
||||
|
||||
/**
|
||||
* 内部:操作图片
|
||||
*/
|
||||
private function _thumpImage()
|
||||
{
|
||||
$new_width = $this->imageinfo['width'] * $this->percent;
|
||||
$new_height = $this->imageinfo['height'] * $this->percent;
|
||||
$image_thump = imagecreatetruecolor($new_width, $new_height);
|
||||
/**
|
||||
* 保留图片透明通道
|
||||
* 简单图床 EasyImage 2.0 2021-5-9 21:48:59
|
||||
* 参考: https://www.imooc.com/wenda/detail/581249
|
||||
*/
|
||||
imagealphablending($image_thump, false);
|
||||
imagesavealpha($image_thump, true);
|
||||
|
||||
//将原图复制带图片载体上面,并且按照一定比例压缩,极大的保持了清晰度
|
||||
imagecopyresampled($image_thump, $this->image, 0, 0, 0, 0, $new_width, $new_height, $this->imageinfo['width'], $this->imageinfo['height']);
|
||||
|
||||
imagedestroy($this->image);
|
||||
$this->image = $image_thump;
|
||||
}
|
||||
|
||||
/**
|
||||
* 输出图片:保存图片则用saveImage()
|
||||
*/
|
||||
private function _showImage()
|
||||
{
|
||||
header('Content-Type: image/' . $this->imageinfo['type']);
|
||||
$funcs = "image" . $this->imageinfo['type'];
|
||||
$funcs($this->image);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存图片到硬盘:
|
||||
* @param string $dstImgName 1、可指定字符串不带后缀的名称,使用源图扩展名 。2、直接指定目标图片名带扩展名。
|
||||
*/
|
||||
private function _saveImage($dstImgName)
|
||||
{
|
||||
if (empty($dstImgName)) return false;
|
||||
$allowImgs = array('.jpg', '.jpeg', '.png', '.bmp', '.wbmp', '.gif'); //如果目标图片名有后缀就用目标图片扩展名 后缀,如果没有,则用源图的扩展名
|
||||
$dstExt = strrchr($dstImgName, ".");
|
||||
$sourseExt = strrchr($this->src, ".");
|
||||
if (!empty($dstExt)) $dstExt = strtolower($dstExt);
|
||||
if (!empty($sourseExt)) $sourseExt = strtolower($sourseExt);
|
||||
|
||||
//有指定目标名扩展名
|
||||
if (!empty($dstExt) && in_array($dstExt, $allowImgs)) {
|
||||
$dstName = $dstImgName;
|
||||
} elseif (!empty($sourseExt) && in_array($sourseExt, $allowImgs)) {
|
||||
$dstName = $dstImgName . $sourseExt;
|
||||
} else {
|
||||
$dstName = $dstImgName . $this->imageinfo['type'];
|
||||
}
|
||||
$funcs = "image" . $this->imageinfo['type'];
|
||||
$funcs($this->image, $dstName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 销毁图片
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
imagedestroy($this->image);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Zhang He
|
||||
* Date: 2015/6/8
|
||||
* Time: 10:14
|
||||
* https://www.cnblogs.com/CheeseZH/p/4566068.html
|
||||
*/
|
||||
|
||||
class TinyImg
|
||||
{
|
||||
/*Compress all images in folder $inputFolder and save final images in folder $outputFolder*/
|
||||
public function compressImgsFolder($key, $inputFolder, $outputFolder)
|
||||
{
|
||||
$images = $this->getFiles($inputFolder);
|
||||
if (empty($images)) {
|
||||
return false;
|
||||
}
|
||||
foreach ($images as $image) {
|
||||
$input = $inputFolder . "\\" . $image;
|
||||
$output = $outputFolder . "\\" . $image;
|
||||
print($input . " => 源文件<br>");
|
||||
print($output . " => 成功文件<br>");
|
||||
$this->compressImg($key, $input, $output);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/*Compress one image $input and save as $output*/
|
||||
public function compressImg($key, $input, $output)
|
||||
{
|
||||
$url = "https://api.tinify.com/shrink";
|
||||
$options = array(
|
||||
"http" => array(
|
||||
"method" => "POST",
|
||||
"header" => array(
|
||||
"Content-type: image/png",
|
||||
"Authorization: Basic " . base64_encode("api:$key")
|
||||
),
|
||||
"content" => file_get_contents($input)
|
||||
),
|
||||
"ssl" => array(
|
||||
/* Uncomment below if you have trouble validating our SSL certificate.
|
||||
Download cacert.pem from: http://curl.haxx.se/ca/cacert.pem */
|
||||
"cafile" => __DIR__ . "/cacert.pem",
|
||||
"verify_peer" => true
|
||||
)
|
||||
);
|
||||
|
||||
$result = fopen($url, "r", false, stream_context_create($options));
|
||||
if ($result) {
|
||||
/* Compression was successful, retrieve output from Location header. */
|
||||
foreach ($http_response_header as $header) {
|
||||
if (strtolower(substr($header, 0, 10)) === "location: ") {
|
||||
file_put_contents($output, fopen(substr($header, 10), "rb", false));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* Something went wrong! */
|
||||
print("Compression failed<br>");
|
||||
}
|
||||
}
|
||||
//get all files' fullname in $filedir
|
||||
public function getFiles($filedir)
|
||||
{
|
||||
$files = [];
|
||||
$dir = @dir($filedir);
|
||||
while (($file = $dir->read()) != false) {
|
||||
if ($file != "." and $file != "..") {
|
||||
$files[] = $file;
|
||||
}
|
||||
}
|
||||
$dir->close();
|
||||
return $files;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* 压缩文件函数调用位置
|
||||
*/
|
||||
require_once __DIR__ . '/../function.php';
|
||||
require_once APP_ROOT . '/libs/compress/Imagick/class.Imgcompress.php';
|
||||
require_once APP_ROOT . '/libs/compress/TinyImg/TinyImg.php';
|
||||
require_once APP_ROOT . '/config/api_key.php';
|
||||
|
||||
/**
|
||||
* @param string $floder 文件夹
|
||||
* @param string 压缩方式Imgcompress / TinyImag
|
||||
*/
|
||||
function compress($floder, $type = 'Imgcompress', $source = '')
|
||||
{
|
||||
global $Api_Key;
|
||||
global $config;
|
||||
ini_set('max_execution_time', '0'); // 脚本运行的时间(以秒为单位)0不限制
|
||||
|
||||
if ($type == 'Imgcompress') {
|
||||
|
||||
$pic = getFile($floder); // 文件夹路径
|
||||
foreach ($pic as $value) {
|
||||
$boxImg = $floder . $value;
|
||||
// 跳过动态图片
|
||||
if (!isAnimatedGif($boxImg)) {
|
||||
$img = new Imgcompress($boxImg, 1);
|
||||
$img->compressImg($boxImg);
|
||||
echo '<pre>' . $boxImg . '</pre><br />';
|
||||
// 释放
|
||||
ob_flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($type == 'TinyImg') {
|
||||
if (empty($Api_Key['TinyImag'])) {
|
||||
exit('请先申请TinyImag key并保存再试!');
|
||||
}
|
||||
$folder = '..' . $config['path'] . $source;
|
||||
$tinyImg = new TinyImg();
|
||||
$key = $Api_Key['TinyImag'];
|
||||
$input = $folder; //这个文件夹下的文件会被压缩
|
||||
$output = $folder; //压缩的结果会被保存到这个文件夹中
|
||||
$tinyImg->compressImgsFolder($key, $input, $output);
|
||||
}
|
||||
}
|
||||
|
||||
/* Test
|
||||
$floder = 'D:/phpStudy/WWW/i/2021/05/09/';
|
||||
compress($floder, 'TinyImg');
|
||||
echo 666;
|
||||
*/
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* 压缩状态页面
|
||||
*/
|
||||
require_once 'header.php';
|
||||
require_once APP_ROOT . '/libs/compress/function.compress.php';
|
||||
|
||||
// 检测登录
|
||||
if (!is_online()) {
|
||||
checkLogin();
|
||||
}
|
||||
// 文件夹压缩
|
||||
if (isset($_POST['folder'])) {
|
||||
|
||||
$getFolder = urldecode($_POST['folder']);
|
||||
|
||||
$source = $_POST['folder'];
|
||||
|
||||
$type = $_POST['type'];
|
||||
|
||||
$folder = '..' . $config['path'] . $getFolder;
|
||||
|
||||
if (!is_dir($folder)) {
|
||||
exit($folder . '<script> new $.zui.Messager("没有这个文件夹!", {type: "danger" // 定义颜色主题
|
||||
}).show();</script>');
|
||||
}
|
||||
|
||||
// 压缩前
|
||||
$sizeBefor = getDirectorySize($folder);
|
||||
|
||||
compress($folder, $type, $source);
|
||||
|
||||
echo '
|
||||
<script> new $.zui.Messager("压缩完毕!", {type: "success" // 定义颜色主题
|
||||
}).show();</script>';
|
||||
}
|
||||
// 压缩后
|
||||
$sizeAfter = getDirectorySize($folder);
|
||||
|
||||
echo '
|
||||
<h2 style="text-align:center">压缩完毕</h2>
|
||||
<h4 style="text-align:center;">压缩前:<font color="red">' . getDistUsed($sizeBefor) . ' </font>压缩后:<font color="green">' . getDistUsed($sizeAfter) . '</font></h3>
|
||||
<pre><h4>
|
||||
无论使用哪种压缩均为不可逆操作,并且非常占用硬件资源。
|
||||
|
||||
如机器配置过低可能会导致CPU、内存飙升!
|
||||
|
||||
<font color="red">Imgcompress</font> 自带压缩为轻微有损压缩图片 此压缩有可能使图片变大,特别是小图片!也有一定概率改变图片方向。
|
||||
|
||||
<font color="red">Imgcompress</font> 对自身机器要求高,如图片过多会导致脚本崩溃或者超时(已经预处理超时和脚本崩溃处理,但是有概率重现)!
|
||||
|
||||
<font color="red">TinyImag</font> 是 https://tinify.cn/ 提供的API,需要自行申请,对服务器要求较低,但是对网络要求高!如在国内可能导致非常慢而超时崩溃(已预处理,但是有概率重现)。
|
||||
|
||||
获取TinyImag key https://tinify.cn/developers 并填入 <font color="red">/config/api_key.php</font> 文件。
|
||||
</h4></pre>
|
||||
';
|
||||
|
||||
include 'footer.php';
|
|
@ -48,7 +48,7 @@
|
|||
makeCode();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// NProgress
|
||||
$("body").show();
|
||||
$(".version").text(NProgress.version);
|
||||
|
@ -74,26 +74,29 @@
|
|||
<script src="../public/static/hm.js"></script>
|
||||
<footer class="text-muted small col-md-12" style="text-align: center;margin-bottom: 10px"><?php echo showAD('bot'); ?>
|
||||
<p><?php echo $config['customize']; ?></p>
|
||||
|
||||
|
||||
|
||||
|
||||
<hr>
|
||||
<p>请勿上传违反中国政策的图片<i class="icon icon-smile"></i> </p>
|
||||
<div>
|
||||
<!-- 对话框触发按钮 -->
|
||||
<a href="#" data-position="center" data-moveable="inside" data-moveable="true" data-toggle="modal" data-target="#myModal">
|
||||
<i class="icon icon-qrcode"></i>二维码 </a>
|
||||
<a href="/tinyfilemanager.php?p=<?php echo date('Y/m/d'); ?>" target="_blank" ><i class="icon icon-desktop"></i>管理 </a>
|
||||
<a href="/api/api-web.php" target="_blank"><i class="icon icon-key"></i>API </a>
|
||||
<a href="<?php echo $config['domain']; ?>/tinyfilemanager.php?p=<?php echo date('Y/m/d'); ?>" target="_blank"><i class="icon icon-desktop"></i>管理 </a>
|
||||
<a href="<?php echo $config['domain']; ?>/api/apiTest/" target="_blank"><i class="icon icon-key"></i>API </a>
|
||||
<?php
|
||||
if (is_online()) {
|
||||
echo '<a href="/libs/logout.php" ><i class="icon icon-signout"></i>退出 </a>';
|
||||
echo '
|
||||
<a href="' . $config['domain'] . '/api/api-web.php" target="_blank"><i class="icon icon-rocket"></i>API管理 </a>
|
||||
<a href="' . $config['domain'] . '/libs/logout.php" ><i class="icon icon-signout"></i>退出 </a>
|
||||
';
|
||||
} else {
|
||||
echo '<a href="/libs/login.php" ><i class="icon icon-user"></i>登录 </a>';
|
||||
echo '<a href="' . $config['domain'] . '/libs/login.php" ><i class="icon icon-user"></i>登录 </a>';
|
||||
} ?>
|
||||
</div>
|
||||
<?php echo 'Copyright © 2018-' . date('Y'); ?>
|
||||
<a href="https://img.545141.com/" target="_blank">EasyImage</a> By
|
||||
<a href="https://www.545141.com/902.html" target="_blank">Icret</a> Ver:<a href="https://github.com/icret/easyImages2.0" target="_blank"><?php echo $config['version']; ?> <i class="icon icon-github"></i></a>
|
||||
<a href="https://www.545141.com/902.html" target="_blank">Icret</a> Ver:<a href="https://github.com/icret/EasyImages2.0/releases" target="_blank"><?php echo $config['version']; ?> <i class="icon icon-github"></i><?php echo @getVersion(); ?></a>
|
||||
</footer>
|
||||
</body>
|
||||
|
||||
|
|
|
@ -61,7 +61,9 @@ function mustLogin()
|
|||
function config_path($path = null)
|
||||
{
|
||||
global $config;
|
||||
$path = $path ?? date('Y/m/d/');
|
||||
// php5.6 兼容写法:
|
||||
$path = isset($path) ? $path : date('Y/m/d/');
|
||||
// php7.0 $path = $path ?? date('Y/m/d/');
|
||||
$img_path = $config['path'] . $path;
|
||||
|
||||
if (!is_dir($img_path)) {
|
||||
|
@ -120,16 +122,16 @@ function static_cdn()
|
|||
<script src="//cdn.jsdelivr.net/gh/icret/EasyImages2.0@2.1.0/public/static/hm.js"></script>';
|
||||
} else {
|
||||
// 本地文件
|
||||
return '<link href="../public/static/zui/css/zui.min.css?v1.9.2" rel="stylesheet">
|
||||
<link href="../public/static/zui/lib/uploader/zui.uploader.min.css?v1.9.2" rel="stylesheet">
|
||||
<link href="../public/static/nprogress.min.css?v0.2.0" rel="stylesheet">
|
||||
<script src="../public/static/zui/lib/jquery/jquery-3.4.1.min.js?v3.4.1"></script>
|
||||
<script src="../public/static/zui/js/zui.min.js?v1.9.2"></script>
|
||||
<script src="../public/static/zui/lib/uploader/zui.uploader.min.js?v1.9.2"></script>
|
||||
<script src="../public/static/qrcode.min.js?v2.0"></script>
|
||||
<script src="../public/static/hm.js"></script>
|
||||
<script src="../public/static/zui/lib/clipboard/clipboard.min.js?vv1.5.5"></script>
|
||||
<script src="../public/static/nprogress.min.js"></script>';
|
||||
return '<link href="/public/static/zui/css/zui.min.css?v1.9.2" rel="stylesheet">
|
||||
<link href="/public/static/zui/lib/uploader/zui.uploader.min.css?v1.9.2" rel="stylesheet">
|
||||
<link href="/public/static/nprogress.min.css?v0.2.0" rel="stylesheet">
|
||||
<script src="/public/static/zui/lib/jquery/jquery-3.4.1.min.js?v3.4.1"></script>
|
||||
<script src="/public/static/zui/js/zui.min.js?v1.9.2"></script>
|
||||
<script src="/public/static/zui/lib/uploader/zui.uploader.min.js?v1.9.2"></script>
|
||||
<script src="/public/static/qrcode.min.js?v2.0"></script>
|
||||
<script src="/public/static/hm.js"></script>
|
||||
<script src="/public/static/zui/lib/clipboard/clipboard.min.js?vv1.5.5"></script>
|
||||
<script src="/public/static/nprogress.min.js"></script>';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,7 +144,7 @@ function tinyfilemanager()
|
|||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
// 获取允许上传的扩展名
|
||||
function getExtensions()
|
||||
{
|
||||
|
@ -153,7 +155,7 @@ function getExtensions()
|
|||
}
|
||||
return rtrim($mime, ',');
|
||||
}
|
||||
|
||||
*/
|
||||
// 获取目录大小 如果目录文件较多将很费时
|
||||
function getDirectorySize($path)
|
||||
{
|
||||
|
@ -317,12 +319,21 @@ function urlHash($data, $mode)
|
|||
}
|
||||
|
||||
// 删除指定文件
|
||||
function getDel($url)
|
||||
function getDel($url, $type)
|
||||
{
|
||||
// url本地化
|
||||
$url = htmlspecialchars(parse_url($url)['path']); // 过滤html 获取url path
|
||||
$url = urldecode(trim($url));
|
||||
$url = $_SERVER['DOCUMENT_ROOT'] . $url;
|
||||
if ($type == 'url') {
|
||||
// url本地化
|
||||
$url = htmlspecialchars(parse_url($url)['path']); // 过滤html 获取url path
|
||||
$url = urldecode(trim($url));
|
||||
$url = $_SERVER['DOCUMENT_ROOT'] . $url;
|
||||
}
|
||||
if ($type == 'hash') {
|
||||
// url本地化
|
||||
$url = htmlspecialchars(parse_url($url)['path']); // 过滤html 获取url path
|
||||
$url = urldecode(trim($url));
|
||||
$url = APP_ROOT . $url;
|
||||
}
|
||||
|
||||
|
||||
// 文件是否存在
|
||||
if (is_file($url)) {
|
||||
|
@ -373,9 +384,9 @@ function is_online()
|
|||
* 需检测的扩展:'fileinfo', 'iconv', 'gd', 'mbstring', 'openssl','zip',
|
||||
* zip 扩展不是必须的,但会影响tinyfilemanager文件压缩(本次不检测)。
|
||||
*
|
||||
* 检测是否修改默认密码
|
||||
*
|
||||
* 检测是否更改默认域名
|
||||
*
|
||||
* 检测是否修改默认密码
|
||||
*/
|
||||
function checkEnv($mode)
|
||||
{
|
||||
|
@ -394,6 +405,7 @@ function checkEnv($mode)
|
|||
';
|
||||
}
|
||||
}
|
||||
|
||||
// 检测是否更改默认域名
|
||||
$url = preg_replace('#^(http(s?))?(://)#', '', 'http://192.168.1.15');
|
||||
if (strstr($url, $_SERVER['HTTP_HOST'])) {
|
||||
|
@ -404,7 +416,7 @@ function checkEnv($mode)
|
|||
</script>
|
||||
';
|
||||
}
|
||||
// 检测是否更改默认密码
|
||||
// 检测是否修改默认密码
|
||||
if ($config['password'] === 'admin@123') {
|
||||
echo '
|
||||
<script>
|
||||
|
@ -434,3 +446,58 @@ function imgRatio()
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 定时获取GitHub 最新版本
|
||||
*/
|
||||
|
||||
function getVersion()
|
||||
{
|
||||
global $config;
|
||||
|
||||
if ($config['checkEnv']) {
|
||||
require_once APP_ROOT . '/libs/class.version.php';
|
||||
// 获取版本地址
|
||||
$url = "https://api.github.com/repositories/188228357/releases/latest";
|
||||
$getVersion = new getVerson($url);
|
||||
|
||||
$now = date('dH'); // 当前日期时间
|
||||
$get_ver_day = array('1006', '2501'); // 检测日期的时间
|
||||
|
||||
foreach ($get_ver_day as $day) {
|
||||
if (empty($getVersion->readJson())) { // 不存在就下载
|
||||
$getVersion->downJson();
|
||||
} else if ($day == $now) { // 是否在需要更新的日期
|
||||
$getVersion->downJson();
|
||||
} elseif ($config['version'] == $getVersion->readJson()) { // 版本相同不提示
|
||||
return null;
|
||||
} else { // 返回版本
|
||||
return ':' . $getVersion->readJson();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// 删除非空目录
|
||||
function deldir($dir)
|
||||
{
|
||||
if (file_exists($dir)) {
|
||||
$files = scandir($dir);
|
||||
foreach ($files as $file) {
|
||||
if ($file != '.' && $file != '..') {
|
||||
$path = $dir . '/' . $file;
|
||||
if (is_dir($path)) {
|
||||
deldir($path);
|
||||
} else {
|
||||
unlink($path);
|
||||
}
|
||||
}
|
||||
}
|
||||
rmdir($dir);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,52 +1,52 @@
|
|||
<?php
|
||||
require_once __DIR__ . '/function.php';
|
||||
echo '<!DOCTYPE html>
|
||||
<?php require_once __DIR__ . '/function.php'; ?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-cn">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>' . $config['title'] . '</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="keywords" content="' . $config['keywords'] . '" />
|
||||
<meta name="description" content="' . $config['description'] . '" />
|
||||
<link rel="shortcut icon" href="//' . $_SERVER['HTTP_HOST'] . '/favicon.ico" type="image/x-icon" />
|
||||
' . static_cdn() . '
|
||||
<style>
|
||||
.uploader-files{
|
||||
min-height:160px;
|
||||
border-style:dashed;
|
||||
}
|
||||
|
||||
@media screen and (min-width:960px){
|
||||
.listNum img {
|
||||
width:268px;
|
||||
height:268px;
|
||||
}
|
||||
<meta charset="utf-8">
|
||||
<title><?php echo $config['title']; ?></title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="keywords" content="<?php echo $config['keywords']; ?>" />
|
||||
<meta name="description" content="<?php echo $config['description']; ?>" />
|
||||
<link rel="shortcut icon" href="<?php echo $config['domain']; ?>/favicon.ico" type="image/x-icon" />
|
||||
<?php echo static_cdn(); ?>
|
||||
<style>
|
||||
.uploader-files {
|
||||
min-height: 160px;
|
||||
border-style: dashed;
|
||||
}
|
||||
</style>
|
||||
|
||||
@media screen and (min-width:960px) {
|
||||
.listNum img {
|
||||
width: 268px;
|
||||
height: 268px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body class="container">
|
||||
' . showAD('top') . '
|
||||
<div class="md-lg-12 header-dividing">
|
||||
<ul class="nav nav-pills">
|
||||
<li class="' . getActive('index') . '">
|
||||
<a href="//' . $_SERVER['HTTP_HOST'] . '/index.php">
|
||||
<i class="icon icon-home"> 首页</i>
|
||||
</a>
|
||||
</li>
|
||||
<li class="' . getActive('list') . '">
|
||||
<a href="//' . $_SERVER['HTTP_HOST'] . '/libs/list.php?date='. date('Y/m/d/').'&num='.$config['listNumber'].'">
|
||||
<i class="icon icon-list"> 广场</i>
|
||||
<span class="label label-badge label-success">
|
||||
' . getFileNumber(__DIR__ . '/../' . config_path()) . '</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="">
|
||||
<a href="https://github.com/icret/easyImages2.0" target="_blank">
|
||||
<i class="icon icon-github "> 源码下载</i>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<!-- 顶部导航栏END -->
|
||||
';
|
||||
<?php echo showAD('top'); ?>
|
||||
<div class="md-lg-12 header-dividing">
|
||||
<ul class="nav nav-pills">
|
||||
<li class="<?php echo getActive('index'); ?>">
|
||||
<a href="<?php echo $config['domain']; ?>/index.php">
|
||||
<i class="icon icon-home"> 首页</i>
|
||||
</a>
|
||||
</li>
|
||||
<li class="<?php echo getActive('list'); ?>">
|
||||
<a href="<?php echo $config['domain']; ?>/libs/list.php?date=<?php echo date('Y/m/d/') ?>&num=<?php echo $config['listNumber']; ?>">
|
||||
<i class="icon icon-list"> 广场</i>
|
||||
<span class="label label-badge label-success">
|
||||
<?php echo getFileNumber(APP_ROOT . config_path()); ?></span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="">
|
||||
<a href="https://github.com/icret/easyImages2.0" target="_blank">
|
||||
<i class="icon icon-github "> 源码下载</i>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<!-- 顶部导航栏END -->
|
140
libs/list.php
140
libs/list.php
|
@ -2,55 +2,135 @@
|
|||
require_once __DIR__ . '/header.php';
|
||||
|
||||
if ($config['showSwitch']) {
|
||||
$path = $_GET['date'] ?? date('Y/m/d/');
|
||||
$keyNum = $_GET['num'] ?? $config['listNumber'];
|
||||
$path = $_GET['date'] ?? date('Y/m/d/');
|
||||
$keyNum = $_GET['num'] ?? $config['listNumber'];
|
||||
|
||||
$fileArr = getFile('..' . config_path($path));
|
||||
$fileArr = getFile(APP_ROOT . config_path($path));
|
||||
|
||||
if ($fileArr[0]) {
|
||||
foreach ($fileArr as $key => $value) {
|
||||
if ($key < $keyNum) {
|
||||
$boxImg = $config['domain'] . config_path($path) . $value;
|
||||
echo '<div class="col-md-4 col-sm-6 col-lg-3"><div class="card listNum"><img data-toggle="lightbox" data-image="' . $boxImg . '" src="' . $boxImg . '"
|
||||
class="img-thumbnail" alt="简单图床-EasyImage" >
|
||||
if ($fileArr[0]) {
|
||||
foreach ($fileArr as $key => $value) {
|
||||
if ($key < $keyNum) {
|
||||
$boxImg = $config['domain'] . config_path($path) . $value;
|
||||
echo '<div class="col-md-4 col-sm-6 col-lg-3"><div class="card listNum">
|
||||
<img data-toggle="lightbox" data-image="' . $boxImg . '" src="../public/images/Eclipse-1s-200px.svg" class="img-thumbnail" alt="简单图床-EasyImage" >
|
||||
<a href="' . $boxImg . '" target="_blank">
|
||||
<div class="pull-left" style="margin-top:5px;">
|
||||
<span class="label label-success">打开原图</span>
|
||||
</div>
|
||||
</a>
|
||||
<a href="//' . $_SERVER['HTTP_HOST'] . '/api/del.php?url=' . $boxImg . '" target="_blank">
|
||||
<a href="' . $config['domain'] . '/api/del.php?url=' . $boxImg . '" target="_blank">
|
||||
<div class="pull-right" style="margin-top:5px;">
|
||||
<span class="label label-primary">删除图片</span>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
echo '<p class="text-danger" style="center">今天还没有上传的图片哟~~ <br />快来上传第一张吧~!</p>';
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
echo '<p class="text-danger" style="center">今天还没有上传的图片哟~~ <br />快来上传第一张吧~!</p>';
|
||||
}
|
||||
} else {
|
||||
echo '<p class="text-danger" style="center">管理员关闭了预览哦~~</p>';
|
||||
echo '<p class="text-danger" style="center">管理员关闭了预览哦~~</p>';
|
||||
}
|
||||
|
||||
$todayUpload = getFileNumber('../' . config_path()); // 今日上传数量
|
||||
$yesterday = date("Y/m/d/", strtotime("-1 day")); // 昨日日期
|
||||
$yesterdayUpload = getFileNumber('../' . $config['path'] . $yesterday); // 昨日上传数量
|
||||
|
||||
$todayUpload = getFileNumber(APP_ROOT . config_path()); // 今日上传数量
|
||||
$yesterdayUpload = getFileNumber(APP_ROOT . $config['path'] . $yesterday); // 昨日上传数量
|
||||
$spaceUsed = getDistUsed(disk_total_space(__DIR__) - disk_free_space(__DIR__)); // 占用空间
|
||||
|
||||
$httpUrl = array(
|
||||
'date' => $path,
|
||||
'num' => getFileNumber('..' . config_path($path)),
|
||||
);
|
||||
// 当前日期全部上传
|
||||
$allUploud = $_GET['date'] ?: date('Y/m/d/');
|
||||
$allUploud = getFileNumber(APP_ROOT . $config['path'] . $allUploud);
|
||||
|
||||
echo '
|
||||
$httpUrl = array(
|
||||
'date' => $path,
|
||||
'num' => getFileNumber(APP_ROOT . config_path($path)),
|
||||
);
|
||||
?>
|
||||
|
||||
<script src="../public/static/lazyload.js"></script>
|
||||
<link href="../public/static/zui/lib/datetimepicker/datetimepicker.min.css" rel="stylesheet">
|
||||
<script src="../public/static/zui/lib/datetimepicker/datetimepicker.min.js"></script>
|
||||
<div class="col-md-12">
|
||||
<a href="list.php" ><span class="label label-success label-outline"> 今日上传:' . $todayUpload . ' 张</span></a>
|
||||
<a href="list.php?date=' . $yesterday . '" ><span class="label label-warning label-outline"> 昨日上传:' . $yesterdayUpload . ' 张</span></a>
|
||||
<a href="list.php?' . http_build_query($httpUrl) . '" ><span class="label label-info label-outline"> 全部上传</span></a>
|
||||
<span class="label label-danger label-outline"> 存储占用:' . $spaceUsed . '</span>
|
||||
<div class="col-md-6">
|
||||
<a href="list.php"><span class="label label-success label-outline"> 今日上传:<?php echo $todayUpload; ?>张</span></a>
|
||||
<a href="list.php?date=<?php echo $yesterday; ?>"><span class="label label-warning label-outline"> 昨日上传:<?php echo $yesterdayUpload; ?>张</span></a>
|
||||
<a href="list.php?<?php echo http_build_query($httpUrl); ?>"><span class="label label-info label-outline"> 当前日期共上传:<?php echo $allUploud; ?>张</span></a>
|
||||
<span class="label label-danger label-outline"> 存储占用:<?php echo $spaceUsed; ?></span>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<form class="form-inline" action="list.php" method="get">
|
||||
<div class="form-group">
|
||||
<label for="exampleInputInviteCode3">按日期:</label>
|
||||
<input type="text" class="form-control form-date" value="2021/05/09/" name="date" readonly="">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">跳转</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
';
|
||||
require_once './footer.php';
|
||||
<!-- 返回顶部 -->
|
||||
<p id="back-top" style="display:none"><a href="#top"><span></span></a></p>
|
||||
<style>
|
||||
#back-top {
|
||||
position: fixed;
|
||||
bottom: 10px;
|
||||
right: 8px;
|
||||
z-index: 99;
|
||||
}
|
||||
|
||||
#back-top span {
|
||||
width: 70px;
|
||||
height: 140px;
|
||||
display: block;
|
||||
background: url(../public/images/top.png) no-repeat center center;
|
||||
}
|
||||
|
||||
#back-top a {
|
||||
outline: none
|
||||
}
|
||||
</style>
|
||||
|
||||
<script type="text/javascript">
|
||||
// 仅选择日期
|
||||
$(".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 $todayUpload; ?>张 昨日<?php echo $yesterdayUpload; ?>张 - <?php echo $config['title']; ?> "
|
||||
//懒加载
|
||||
var lazy = new Lazy({
|
||||
onload: function(elem) {
|
||||
console.log(elem)
|
||||
},
|
||||
delay: 2000
|
||||
})
|
||||
// 返回顶部
|
||||
$(function() {
|
||||
// hide #back-top first
|
||||
$("#back-top").hide();
|
||||
// fade in #back-top
|
||||
$(window).scroll(function() {
|
||||
if ($(this).scrollTop() > 400) {
|
||||
$('#back-top').fadeIn();
|
||||
} else {
|
||||
$('#back-top').fadeOut();
|
||||
}
|
||||
});
|
||||
// scroll body to 0px on click
|
||||
$('#back-top a').click(function() {
|
||||
$('body,html').animate({
|
||||
scrollTop: 0
|
||||
}, 500);
|
||||
return false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php require_once APP_ROOT . '/libs/footer.php';
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
/*
|
||||
* 登录页面
|
||||
*/
|
||||
require_once 'function.php';
|
||||
require_once APP_ROOT . '/libs/header.php';
|
||||
/*
|
||||
// 提交登录
|
||||
if (isset($_POST['password'])) {
|
||||
checkLogin();
|
||||
Header("Location:../");
|
||||
}
|
||||
*/
|
||||
/*
|
||||
if (isset($_POST['code'])) {
|
||||
session_start();
|
||||
if ((strtoupper($_POST["code"])) == strtoupper(($_SESSION["VerifyCode"]))) {
|
||||
if (isset($_POST['password'])) {
|
||||
checkLogin();
|
||||
Header("Location:../");
|
||||
}
|
||||
} else {
|
||||
echo '
|
||||
<script> new $.zui.Messager("验证码错误", {type: "danger" // 定义颜色主题
|
||||
}).show();</script>';
|
||||
header("refresh:1;"); // 1s后刷新当前页面
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
?>
|
||||
<center>
|
||||
<div class="center" style="margin: 40px;">
|
||||
<form class="form-inline" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" onsubmit="return md5_post()">
|
||||
<div class="form-group">
|
||||
<div class="has-success">
|
||||
<label for="password">密码:</label>
|
||||
<input type="password" name="password" id="password" class="form-control" placeholder="请输入登录密码">
|
||||
</div>
|
||||
<input type="hidden" name="password" id="md5_password">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="has-success">
|
||||
<label for="code">验证码:</label>
|
||||
<input type="text" class="form-control" name="code" id="textfield" />
|
||||
<img id="imgcode" src="<?php echo $config['domain'] . '/libs/VerifyCode.php';?>" onclick="this.src='VerifyCode.php?'+new Date().getTime();" alt="验证码" />
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">登录</button>
|
||||
</form>
|
||||
</div>
|
||||
</center>
|
||||
<script src="../public/static/md5.min.js"></script>
|
||||
<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>
|
||||
|
||||
<?php
|
||||
require_once APP_ROOT . '/libs/footer.php';
|
|
@ -3,7 +3,7 @@
|
|||
* 登录页面
|
||||
*/
|
||||
require_once 'function.php';
|
||||
require_once __DIR__ . '/header.php';
|
||||
require_once APP_ROOT . '/libs/header.php';
|
||||
// 提交登录
|
||||
if (isset($_POST['password'])) {
|
||||
checkLogin();
|
||||
|
@ -36,4 +36,4 @@ if (isset($_POST['password'])) {
|
|||
</script>
|
||||
|
||||
<?php
|
||||
include_once __DIR__ . '/footer.php';
|
||||
require_once APP_ROOT . '/libs/footer.php';
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
require_once './header.php';
|
||||
require_once 'header.php';
|
||||
|
||||
if (isset($_COOKIE['admin']) and $_COOKIE['admin'] == md5($config['password'])) {
|
||||
setcookie("admin", null, time() - 1, '/');
|
||||
|
@ -23,4 +23,4 @@ if (isset($_COOKIE['admin']) and $_COOKIE['admin'] == md5($config['password']))
|
|||
';
|
||||
}
|
||||
|
||||
require_once './footer.php';
|
||||
require_once 'footer.php';
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
"url": "https://api.github.com/repos/icret/EasyImages2.0/releases/42663696",
|
||||
"assets_url": "https://api.github.com/repos/icret/EasyImages2.0/releases/42663696/assets",
|
||||
"upload_url": "https://uploads.github.com/repos/icret/EasyImages2.0/releases/42663696/assets{?name,label}",
|
||||
"html_url": "https://github.com/icret/EasyImages2.0/releases/tag/2.1.1",
|
||||
"id": 42663696,
|
||||
"author": {
|
||||
"login": "icret",
|
||||
"id": 16373024,
|
||||
"node_id": "MDQ6VXNlcjE2MzczMDI0",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/16373024?v=4",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.github.com/users/icret",
|
||||
"html_url": "https://github.com/icret",
|
||||
"followers_url": "https://api.github.com/users/icret/followers",
|
||||
"following_url": "https://api.github.com/users/icret/following{/other_user}",
|
||||
"gists_url": "https://api.github.com/users/icret/gists{/gist_id}",
|
||||
"starred_url": "https://api.github.com/users/icret/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.github.com/users/icret/subscriptions",
|
||||
"organizations_url": "https://api.github.com/users/icret/orgs",
|
||||
"repos_url": "https://api.github.com/users/icret/repos",
|
||||
"events_url": "https://api.github.com/users/icret/events{/privacy}",
|
||||
"received_events_url": "https://api.github.com/users/icret/received_events",
|
||||
"type": "User",
|
||||
"site_admin": false
|
||||
},
|
||||
"node_id": "MDc6UmVsZWFzZTQyNjYzNjk2",
|
||||
"tag_name": "2.1.1",
|
||||
"target_commitish": "master",
|
||||
"name": "EasyImage2.0 简单图床 ver:2.1.1",
|
||||
"draft": false,
|
||||
"prerelease": false,
|
||||
"created_at": "2021-05-08T07:42:59Z",
|
||||
"published_at": "2021-05-09T12:13:59Z",
|
||||
"assets": [
|
||||
|
||||
],
|
||||
"tarball_url": "https://api.github.com/repos/icret/EasyImages2.0/tarball/2.1.1",
|
||||
"zipball_url": "https://api.github.com/repos/icret/EasyImages2.0/zipball/2.1.1",
|
||||
"body": "EasyImage2.0 简单图床\r\n版本:2.1.1"
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="margin: auto; background: rgb(241, 242, 243); display: block; shape-rendering: auto; animation-play-state: running; animation-delay: 0s;" width="200px" height="200px" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid">
|
||||
<path d="M10 50A40 40 0 0 0 90 50A40 42 0 0 1 10 50" fill="#5be1da" stroke="none" style="animation-play-state: running; animation-delay: 0s;">
|
||||
<animateTransform attributeName="transform" type="rotate" dur="1s" repeatCount="indefinite" keyTimes="0;1" values="0 50 51;360 50 51" style="animation-play-state: running; animation-delay: 0s;"></animateTransform>
|
||||
</path>
|
||||
<!-- [ldio] generated by https://loading.io/ --></svg>
|
After Width: | Height: | Size: 771 B |
Binary file not shown.
After Width: | Height: | Size: 2.9 KiB |
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
After Width: | Height: | Size: 434 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,179 @@
|
|||
(function () {
|
||||
var root = (typeof self == 'object' && self.self == self && self) ||
|
||||
(typeof global == 'object' && global.global == global && global) ||
|
||||
this || {};
|
||||
|
||||
// 修复 bind 函数
|
||||
Function.prototype.bind = Function.prototype.bind || function (context) {
|
||||
|
||||
if (typeof this !== "function") {
|
||||
throw new Error("Function.prototype.bind - what is trying to be bound is not callable");
|
||||
}
|
||||
|
||||
var self = this;
|
||||
var args = Array.prototype.slice.call(arguments, 1);
|
||||
|
||||
var fNOP = function () { };
|
||||
|
||||
var fBound = function () {
|
||||
var bindArgs = Array.prototype.slice.call(arguments);
|
||||
self.apply(this instanceof fNOP ? this : context, args.concat(bindArgs));
|
||||
}
|
||||
|
||||
fNOP.prototype = this.prototype;
|
||||
fBound.prototype = new fNOP();
|
||||
return fBound;
|
||||
}
|
||||
|
||||
var util = {
|
||||
extend: function (target) {
|
||||
for (var i = 1, len = arguments.length; i < len; i++) {
|
||||
for (var prop in arguments[i]) {
|
||||
if (arguments[i].hasOwnProperty(prop)) {
|
||||
target[prop] = arguments[i][prop]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return target
|
||||
},
|
||||
addEvent: function (elem, type, fn) {
|
||||
if (document.addEventListener) {
|
||||
elem.addEventListener(type, fn, false);
|
||||
return fn;
|
||||
} else if (document.attachEvent) {
|
||||
var bound = function () {
|
||||
return fn.apply(elem, arguments)
|
||||
}
|
||||
elem.attachEvent('on' + type, bound);
|
||||
return bound;
|
||||
}
|
||||
},
|
||||
removeEvent: function (elem, type, fn) {
|
||||
if (document.removeEventListener) {
|
||||
elem.removeEventListener(type, fn, false)
|
||||
}
|
||||
else {
|
||||
elem.detachEvent("on" + type, fn)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Lazy(opts) {
|
||||
|
||||
this.opts = util.extend({}, this.constructor.defaultOpts, opts)
|
||||
|
||||
this.init();
|
||||
}
|
||||
|
||||
Lazy.VERSION = '1.0.0';
|
||||
|
||||
Lazy.defaultOpts = {
|
||||
delay: 250,
|
||||
useDebounce: false
|
||||
}
|
||||
|
||||
var proto = Lazy.prototype;
|
||||
|
||||
proto.init = function () {
|
||||
|
||||
this.calulateView();
|
||||
|
||||
this.bindScrollEvent();
|
||||
|
||||
};
|
||||
|
||||
proto.calulateView = function () {
|
||||
|
||||
this.view = {
|
||||
top: 0 - (parseInt(this.opts.top, 10) || 0),
|
||||
bottom: (root.innerHeight || document.documentElement.clientHeight) + (parseInt(this.opts.bottom, 10) || 0),
|
||||
left: 0 - (parseInt(this.opts.left, 10) || 0),
|
||||
right: (root.innerWidth || document.documentElement.clientWidth) + (parseInt(this.opts.right, 10) || 0)
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
proto.bindScrollEvent = function () {
|
||||
var scrollEvent = util.addEvent(root, 'scroll', this.handleLazyLoad.bind(this))
|
||||
var loadEvent = util.addEvent(root, 'load', this.handleLazyLoad.bind(this))
|
||||
|
||||
this.event = {
|
||||
scrollEvent: scrollEvent,
|
||||
loadEvent: loadEvent
|
||||
}
|
||||
};
|
||||
|
||||
var timer = null;
|
||||
|
||||
proto.handleLazyLoad = function () {
|
||||
var self = this;
|
||||
|
||||
if (!this.opts.useDebounce && !!timer) {
|
||||
return;
|
||||
}
|
||||
|
||||
clearTimeout(timer);
|
||||
|
||||
timer = setTimeout(function () {
|
||||
timer = null;
|
||||
self.render()
|
||||
}, this.opts.delay);
|
||||
};
|
||||
|
||||
proto.isHidden = function (element) {
|
||||
return (element.offsetParent === null);
|
||||
};
|
||||
|
||||
proto.checkInView = function (element) {
|
||||
if (this.isHidden(element)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var rect = element.getBoundingClientRect();
|
||||
|
||||
return (rect.right >= this.view.left && rect.bottom >= this.view.top && rect.left <= this.view.right && rect.top <= this.view.bottom);
|
||||
};
|
||||
|
||||
proto.render = function () {
|
||||
var nodes = document.querySelectorAll('[data-image], [data-lazy-background]');
|
||||
var length = nodes.length;
|
||||
|
||||
for (var i = 0; i < length; i++) {
|
||||
elem = nodes[i];
|
||||
if (this.checkInView(elem)) {
|
||||
|
||||
if (elem.getAttribute('data-lazy-background') !== null) {
|
||||
elem.style.backgroundImage = 'url(' + elem.getAttribute('data-lazy-background') + ')';
|
||||
} else if (elem.src !== (src = elem.getAttribute('data-image'))) {
|
||||
elem.src = src;
|
||||
}
|
||||
|
||||
elem.removeAttribute('data-image');
|
||||
elem.removeAttribute('data-lazy-background');
|
||||
|
||||
if (this.opts.onload && typeof this.opts.onload === 'function') {
|
||||
this.opts.onload(elem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!length) {
|
||||
this.unbindScrollEvent();
|
||||
}
|
||||
};
|
||||
|
||||
proto.unbindScrollEvent = function () {
|
||||
util.removeEvent(root, 'scroll', this.event.scrollEvent)
|
||||
util.removeEvent(root, 'load', this.event.loadEvent)
|
||||
};
|
||||
|
||||
if (typeof exports != 'undefined' && !exports.nodeType) {
|
||||
if (typeof module != 'undefined' && !module.nodeType && module.exports) {
|
||||
exports = module.exports = Lazy;
|
||||
}
|
||||
exports.Lazy = Lazy;
|
||||
} else {
|
||||
root.Lazy = Lazy;
|
||||
}
|
||||
}());
|
|
@ -131,7 +131,7 @@ $ip_blacklist = array(
|
|||
);
|
||||
|
||||
// if User has the customized config file, try to use it to override the default config above
|
||||
$config_file = __DIR__.'/config/config.php';
|
||||
$config_file = APP_ROOT.'/config/config.php';
|
||||
if (is_readable($config_file)) {
|
||||
@include($config_file);
|
||||
}
|
||||
|
@ -4027,5 +4027,5 @@ function lng($txt) {
|
|||
* 添加函数
|
||||
行 4: require_once './libs/function.php'; tinyfilemanager();
|
||||
* 调用配置文件
|
||||
行 134: $config_file = __DIR__.'/config/config.php';
|
||||
行 134: $config_file = APP_ROOT. '/config/config.php';
|
||||
*/
|
Loading…
Reference in New Issue