pull/141/head
icret 2023-03-09 02:42:50 +08:00
parent ba4905122f
commit 74bc2f401d
57 changed files with 4735 additions and 4739 deletions

View File

@ -3,7 +3,7 @@
* 简单图床设置页面
* 2022-1-24 05:57:35
*/
require_once __DIR__ . '/../application/header.php';
require_once __DIR__ . '/../app/header.php';
require_once APP_ROOT . '/config/api_key.php';
require_once APP_ROOT . '/config/config.guest.php';
@ -15,7 +15,7 @@ if (!is_who_login('admin')) {
icon: "exclamation-sign" // 定义消息图标
}).show();</script>';
header("refresh:2;url=" . $config['domain'] . "/admin/index.php");
require_once APP_ROOT . '/application/footer.php';
require_once APP_ROOT . '/app/footer.php';
exit;
}
@ -499,7 +499,7 @@ auto_delete(); //定时删除
</form>
</div>
<div class="tab-pane fade " id="Content4">
<form action="../application/compressing.php" method="post" target="_blank">
<form action="../app/compressing.php" method="post" target="_blank">
<h5 class="header-dividing">压缩文件夹</h5>
<div class="col-md-12">
<div class="form-group col-md-4">
@ -568,7 +568,7 @@ auto_delete(); //定时删除
<div class="col-md-12">
<div class="col-md-4">
<h5 class="header-dividing">上传日志 <small>需要开启上传日志</small></h5>
<form class="form-inline" action="../application/viewlog.php" method="post" target="_blank">
<form class="form-inline" action="../app/viewlog.php" method="post" target="_blank">
<div class="form-group">
<label for="logDate" class="text-primary">月份: </label>
<input type="text" class="form-control logDate" id="logDate" name="logDate" value="<?php echo date('Y-m'); ?>" required="required" readonly>
@ -579,7 +579,7 @@ auto_delete(); //定时删除
</div>
<div class="col-md-2">
<h5 class="header-dividing">登录日志 <small>仅显示当月</small></h5>
<button type="button" class="btn btn-primary" data-toggle="modal" data-title="登录日志 - 仅显示当月" data-icon="book" data-moveable="true" data-width="60%" data-type="ajax" data-url="../application/viewlog.php?login_log&sign=<?php echo md5($config['password'] . date('ymdh')); ?>">查看</button>
<button type="button" class="btn btn-primary" data-toggle="modal" data-title="登录日志 - 仅显示当月" data-icon="book" data-moveable="true" data-width="60%" data-type="ajax" data-url="../app/viewlog.php?login_log&sign=<?php echo md5($config['password'] . date('ymdh')); ?>">查看</button>
</div>
<div class="col-md-3">
<h5 class="header-dividing" data-toggle="tooltip" title="仅限存储分类路径为 Y/m/d/ 格式<br/>且每天需要访问一次后台才执行<br/>先重命名要删除文件夹作为备份<br/>超过定时日期的2倍后再彻底删除重命名的文件夹<br/>超过定时日期前和开启分离的文件夹不删除">定时删除 <small>数值为<code>0</code>时关闭</small></h5>
@ -890,7 +890,7 @@ auto_delete(); //定时删除
$file_size = getDistUsed(filesize($file_cache_path)); // 大小
$filen_name = $cache_file[$i]; // 名称
$url = $config['domain'] . $file_path; // 网络连接
$unlink_img = $config['domain'] . '/application/del.php?url=' . $file_path; // 删除连接
$unlink_img = $config['domain'] . '/app/del.php?url=' . $file_path; // 删除连接
?>
<tr>
<td><?php echo $i; ?></td>
@ -899,7 +899,7 @@ auto_delete(); //定时删除
<td><?php echo $file_size; ?></td>
<td>
<a class="btn btn-mini" href="<?php echo $url; ?>" target="_blank">查看</a>
<a class="btn btn-mini" href="/application/info.php?img=<?php echo $file_path; ?>" target="_blank">信息</a>
<a class="btn btn-mini" href="/app/info.php?img=<?php echo $file_path; ?>" target="_blank">信息</a>
<a class="btn btn-mini btn-success" href="?suspic_reimg=<?php echo $filen_name; ?>">恢复</a>
<a class="btn btn-mini btn-danger" href="<?php echo $unlink_img; ?>" target="_blank">删除</a>
</td>
@ -984,7 +984,7 @@ auto_delete(); //定时删除
Ip2region (2.0 - xdb) 是一个离线 IP 数据管理框架和定位库,支持亿级别的数据段,10微秒级别的查询性能,提供了许多主流编程语言的 xdb 数据管理引擎的实现。
每个 ip 数据段的 region 信息都固定了格式:国家|区域|省份|城市|ISP, 只有中国的数据绝大部分精确到了城市, 其他国家部分数据只能定位到国家, 后前的选项全部是0。
</p>
<h6>* 下载 <a href="https://raw.githubusercontent.com/lionsoul2014/ip2region/master/data/ip2region.xdb" target="_blank">ip2region.xdb</a> IP数据库上传到 <small style="color: black;">/application/ip2region/</small> 文件夹, 如遇到下载失败可访问开源地址下载: [ <a href="https://github.com/lionsoul2014/ip2region" target="_blank"><small style="color: black;">Github</small></a> | <a href="https://gitee.com/lionsoul/ip2region" target="_blank"><small style="color: black;">Gitee</small></a> ] 更新方法与此相同。</h6>
<h6>* 下载 <a href="https://raw.githubusercontent.com/lionsoul2014/ip2region/master/data/ip2region.xdb" target="_blank">ip2region.xdb</a> IP数据库上传到 <small style="color: black;">/app/ip2region/</small> 文件夹, 如遇到下载失败可访问开源地址下载: [ <a href="https://github.com/lionsoul2014/ip2region" target="_blank"><small style="color: black;">Github</small></a> | <a href="https://gitee.com/lionsoul/ip2region" target="_blank"><small style="color: black;">Gitee</small></a> ] 更新方法与此相同。</h6>
</div>
</div>
<?php if (getVersion() !== get_current_version()) : ?>
@ -1135,7 +1135,7 @@ auto_delete(); //定时删除
<li>直接输入账号和密码即可完成修改</li>
<li>更改后会立即生效并重新登录,请务必牢记账号和密码! </li>
<li>如果忘记账号可以打开-><code>/config/config.php</code>文件->找到<code data-toggle="tooltip" title="'user'=><strong>admin</strong>'">user</code>对应的键值->填入</li>
<li>如果忘记密码请将密码->转换成SHA256-><a href="<?php echo $config['domain'] . '/application/reset_password.php'; ?>" target="_blank" class="text-purple">转换网址</a>->打开<code>/config/config.php</code>文件->找到<code data-toggle="tooltip" title="'password'=>'<strong>e6e0612609</strong>'">password</code>对应的键值->填入</li>
<li>如果忘记密码请将密码->转换成SHA256-><a href="<?php echo $config['domain'] . '/app/reset_password.php'; ?>" target="_blank" class="text-purple">转换网址</a>->打开<code>/config/config.php</code>文件->找到<code data-toggle="tooltip" title="'password'=>'<strong>e6e0612609</strong>'">password</code>对应的键值->填入</li>
</ul>
</div>
</div>
@ -1232,7 +1232,7 @@ auto_delete(); //定时删除
$file_size = getDistUsed(filesize($file_cache_path)); // 大小
$filen_name = $cache_file[$i]; // 名称
$url = $config['domain'] . $file_path; // 网络连接
$unlink_img = $config['domain'] . '/application/del.php?url=' . $file_path; // 删除连接
$unlink_img = $config['domain'] . '/app/del.php?url=' . $file_path; // 删除连接
?>
<tr>
<td><?php echo $i; ?></td>
@ -1241,7 +1241,7 @@ auto_delete(); //定时删除
<td><?php echo $file_size; ?></td>
<td>
<a class="btn btn-mini" href="<?php echo $url; ?>" target="_blank">查看</a>
<a class="btn btn-mini" href="/application/info.php?img=<?php echo $file_path; ?>" target="_blank">信息</a>
<a class="btn btn-mini" href="/app/info.php?img=<?php echo $file_path; ?>" target="_blank">信息</a>
<a class="btn btn-mini btn-success" href="?recycle_reimg=<?php echo $filen_name; ?>">恢复</a>
<a class="btn btn-mini btn-danger" href="<?php echo $unlink_img; ?>" target="_blank">删除</a>
</td>
@ -1365,7 +1365,7 @@ auto_delete(); //定时删除
<a class="btn btn-mini btn-primary" href="/admin/manager.php?p=<?php echo date('Y/m/d'); ?> " target="_blank" data-toggle="tooltip" title="使用Tinyfilemanager管理文件"><i class="icon icon-folder-open"> 文件管理</i></a>
<a class="btn btn-mini btn-primary" href="/i/manag.php?path=<?php echo date('Y/m/d'); ?> " target="_blank" data-toggle="tooltip" title="使用web-indexr管理文件"><i class="icon icon-folder-close"> 文件管理</i></a>
<h5 class="header-dividing">删除文件 <small>* 删除后不可恢复</small></h5>
<form class="form-inline" method="get" action="../application/del.php" id="form" name="delForm" target="_blank" style="margin-bottom: 5px;">
<form class="form-inline" method="get" action="../app/del.php" id="form" name="delForm" target="_blank" style="margin-bottom: 5px;">
<p id="delimgurl"></p>
<div class="form-group">
<label for="del" class="text-warning">删除单张图片文件: </label>
@ -1641,11 +1641,11 @@ auto_delete(); //定时删除
guestMyDataGrid.sortBy('add_time', 'desc');
/** 引入设置页面检测文件 */
<?php if ($config['checkEnv']) require_once APP_ROOT . '/application/check_admin.inc.php'; ?>
<?php if ($config['checkEnv']) require_once APP_ROOT . '/app/check_admin.inc.php'; ?>
// 更改网页标题
document.title = "图床设置 - <?php echo $config['title']; ?>"
</script>
<?php
/** 引入底部 */
require_once APP_ROOT . '/application/footer.php';
require_once APP_ROOT . '/app/footer.php';

View File

@ -2,8 +2,8 @@
/*
* 统计中心
*/
require_once '../application/header.php';
require_once APP_ROOT . '/application/chart.php';
require_once '../app/header.php';
require_once APP_ROOT . '/app/chart.php';
// 检测登录和是否开启统计
if (!$config['chart_on'] && !is_who_login('admin')) exit(header('Location: ' . $config['domain'] . '?hart#closed'));
@ -320,4 +320,4 @@ if (is_array($char_data)) {
document.title = "图床统计信息 - <?php echo $config['title']; ?>"
</script>
<?php require_once APP_ROOT . '/application/footer.php';
<?php require_once APP_ROOT . '/app/footer.php';

View File

@ -2,8 +2,8 @@
/*
* 登录页面
*/
require_once __DIR__ . '/../application/function.php';
require_once APP_ROOT . '/application/header.php';
require_once __DIR__ . '/../app/function.php';
require_once APP_ROOT . '/app/header.php';
require_once APP_ROOT . '/config/config.guest.php';
// 退出
@ -36,7 +36,7 @@ if (isset($_GET['login'])) {
';
}
}
exit(require_once APP_ROOT . '/application/footer.php');
exit(require_once APP_ROOT . '/app/footer.php');
}
// 提交登录
@ -52,7 +52,7 @@ if (isset($_POST['password']) and isset($_POST['user'])) {
// 延时2s跳转
window.setTimeout("window.location=\'./index.php\'",2000);
</script>';
exit(require_once APP_ROOT . '/application/footer.php');
exit(require_once APP_ROOT . '/app/footer.php');
} else {
session_start();
if (strtolower($_REQUEST['code']) !== $_SESSION['code']) {
@ -63,7 +63,7 @@ if (isset($_POST['password']) and isset($_POST['user'])) {
// 延时2s跳转
window.setTimeout("window.location=\'./index.php\'",2000);
</script>';
exit(require_once APP_ROOT . '/application/footer.php');
exit(require_once APP_ROOT . '/app/footer.php');
}
}
}
@ -108,7 +108,7 @@ if (isset($_POST['password']) and isset($_POST['user'])) {
</div>
<div class="modal-body">
<p class="text-primary">忘记账号可以打开<code>/config/config.php</code>文件找到<code data-toggle="tooltip" title="'user'=><strong>admin</strong>'">user</code>对应的键值->填入</p>
<p class="text-success">忘记密码请将密码转换成SHA256(<a href="<?php echo $config['domain'] . '/application/reset_password.php'; ?>" target="_blank" class="text-purple">转换网址</a>)->打开<code>/config/config.php</code>文件->找到<code data-toggle="tooltip" title="'password'=>'<strong>e6e0612609</strong>'">password</code>对应的键值->填入</p>
<p class="text-success">忘记密码请将密码转换成SHA256(<a href="<?php echo $config['domain'] . '/app/reset_password.php'; ?>" target="_blank" class="text-purple">转换网址</a>)->打开<code>/config/config.php</code>文件->找到<code data-toggle="tooltip" title="'password'=>'<strong>e6e0612609</strong>'">password</code>对应的键值->填入</p>
<h4 class="text-danger">更改后会立即生效并重新登录,请务必牢记账号和密码! </h4>
</div>
<div class="modal-footer">
@ -134,7 +134,7 @@ if (isset($_POST['password']) and isset($_POST['user'])) {
<input class="form-control" type="text" name="code" value="" placeholder="请输入验证码" autocomplete="off" required="required" />
<div class="form-group">
<div class="col">
<label><img src="../application/captcha.php" width="185px" onClick="this.src='../application/captcha.php?nocache='+Math.random()" title="点击换一张" /></label>
<label><img src="../app/captcha.php" width="185px" onClick="this.src='../app/captcha.php?nocache='+Math.random()" title="点击换一张" /></label>
</div>
</div>
<?php endif; ?>
@ -176,4 +176,4 @@ if (isset($_POST['password']) and isset($_POST['user'])) {
container.classList.toggle('active');
}
</script>
<?php require_once APP_ROOT . '/application/footer.php';
<?php require_once APP_ROOT . '/app/footer.php';

View File

@ -2,23 +2,23 @@
//Default Configuration
$CONFIG = '{"lang":"zh-CN","error_reporting":false,"show_hidden":true,"hide_Cols":false,"calc_folder":true,"theme":"light"}';
require_once __DIR__ . '/../application/function.php';
require_once __DIR__ . '/../app/function.php';
// 是否管理员登录
if(!is_who_login('admin')){
require_once APP_ROOT.'/application/header.php';
require_once APP_ROOT.'/app/header.php';
echo '<div class="alert alert-danger">还没有登陆哦~~</div>';
header("refresh:3;url=" . $config['domain'] . "/admin/index.php");
require_once APP_ROOT.'/application/footer.php';
require_once APP_ROOT.'/app/footer.php';
exit;
}
// 开启tinyfilemanager图片管理
if (!$config['file_manage']) {
require_once APP_ROOT.'/application/header.php';
require_once APP_ROOT.'/app/header.php';
echo '<div class="alert alert-danger">图片管理已关闭~~</div>';
header("refresh:3;url=" . $_SERVER["HTTP_REFERER"] . '?manager-closed');
require_once APP_ROOT.'/application/footer.php';
require_once APP_ROOT.'/app/footer.php';
exit;
}
@ -2108,7 +2108,7 @@ $tableTheme = (FM_THEME == "dark") ? "text-white bg-dark table-dark" : "bg-white
if (in_array(strtolower(pathinfo($f, PATHINFO_EXTENSION)), array('gif', 'jpg', 'jpeg', 'png', 'bmp', 'ico', 'svg', 'webp', 'avif'))): ?>
<?php $imagePreview = fm_enc(FM_ROOT_URL . (FM_PATH != '' ? '/' . FM_PATH : '') . '/' . $f); ?>
<!-- 分组图片浏览 -->
<a href="<?php echo $imagePreview;?>" data-toggle="lightbox" data-group="manager-group"><img src="/application/thumb.php?img=<?php echo parse_url($imagePreview)['path'];?>" class="img-rounded" width="100px" height="100px" alt="<?php echo fm_enc($f);?>"></a>
<a href="<?php echo $imagePreview;?>" data-toggle="lightbox" data-group="manager-group"><img src="/app/thumb.php?img=<?php echo parse_url($imagePreview)['path'];?>" class="img-rounded" width="100px" height="100px" alt="<?php echo fm_enc($f);?>"></a>
<?php else: ?>
<a href="<?php echo $filelink ?>" title="<?php echo $f ?>">
<?php endif; ?>

View File

@ -2,7 +2,7 @@
/*
* 使用条款页面
*/
require_once __DIR__ . '/../application/header.php';
require_once __DIR__ . '/../app/header.php';
/** 顶部广告 */
if ($config['ad_top']) echo $config['ad_top_info'];
@ -25,4 +25,4 @@ if ($config['ad_bot']) echo $config['ad_bot_info'];
</script>
<?php
require_once __DIR__ . '/../application/footer.php';
require_once __DIR__ . '/../app/footer.php';

View File

@ -2,8 +2,8 @@
/*
* 统计中心
*/
require_once '../application/header.php';
require_once APP_ROOT . '/application/chart.php';
require_once '../app/header.php';
require_once APP_ROOT . '/app/chart.php';
// 检测是否开启统计
if (!$config['chart_on']) exit(header('Location: ' . $config['domain'] . '?chart#closed'));
@ -11,7 +11,7 @@ if (!$config['chart_on']) exit(header('Location: ' . $config['domain'] . '?chart
// 检测登录
if (!is_who_login('admin')) {
checkLogin();
exit(require_once APP_ROOT . '/application/footer.php');
exit(require_once APP_ROOT . '/app/footer.php');
}
// 删除统计文件
if (isset($_POST['del_total'])) {
@ -238,4 +238,4 @@ if (is_array($char_data)) {
document.title = "图床统计信息 - <?php echo $config['title']; ?>";
</script>
<?php require_once APP_ROOT . '/application/footer.php';
<?php require_once APP_ROOT . '/app/footer.php';

View File

@ -2,8 +2,8 @@
namespace Verot\Upload;
require_once __DIR__ . '/../application/function.php';
require_once APP_ROOT . '/application/class.upload.php';
require_once __DIR__ . '/../app/function.php';
require_once APP_ROOT . '/app/class.upload.php';
require_once APP_ROOT . '/config/api_key.php';
// 允许跨域 https://stackoverflow.com/questions/8719276/cross-origin-request-headerscors-with-php-headers
@ -141,18 +141,18 @@ if ($handle->uploaded) {
// 源图保护 key值是由crc32加密的hide_key
if ($config['hide'] == 1) {
$imageUrl = $config['domain'] . '/application/hide.php?key=' . urlHash($pathIMG, 0, crc32($config['hide_key']));
$imageUrl = $config['domain'] . '/app/hide.php?key=' . urlHash($pathIMG, 0, crc32($config['hide_key']));
}
// 删除文件链接
if ($config['show_user_hash_del']) {
$delUrl = $config['domain'] . '/application/del.php?hash=' . urlHash($pathIMG, 0);
$delUrl = $config['domain'] . '/app/del.php?hash=' . urlHash($pathIMG, 0);
} else {
$delUrl = "Admin closed user delete";
}
// 当设置访问生成缩略图时自动生成 2022-12-30 修正 2023-01-30
$handleThumb = $config['domain'] . '/application/thumb.php?img=' . $pathIMG;
$handleThumb = $config['domain'] . '/app/thumb.php?img=' . $pathIMG;
if ($config['thumbnail'] == 2) {
// 自定义缩略图长宽
$handle->image_resize = true;

View File

@ -5,8 +5,8 @@
* 2022年2月22日11:41:38
* @author Icret
*/
require_once '../application/function.php';
require_once '../application/chart.php';
require_once '../app/function.php';
require_once '../app/chart.php';
// 检查是否开启查询
if ($config['public'] == 0) die('开放数据接口已关闭!');

0
application/TimThumb.php → app/TimThumb.php Executable file → Normal file
View File

714
application/WaterMask.php → app/WaterMask.php Executable file → Normal file
View File

@ -1,357 +1,357 @@
<?php
// https://blog.csdn.net/MyDream229/article/details/80009012
class Imgs
{
/**
* 取得图片宽
* @param string $src 图片相对路径或绝对路径
*/
public static function get_width($src)
{
return imagesx($src);
}
/**
* 取得图片高
* @param string $src 图片相对路径或绝对路径
*/
public static function get_height($src)
{
return imagesy($src);
}
/**
* 图片缩放函数
* @param string $src 图片相对路径或绝对路径
* @param int $w 缩略图宽
* @param int $h 缩略图高
* @return array code状态。msg提示信息
**/
public static function thumb($src, $w = null, $h = null)
{
if (empty($src)) {
return array('code' => false, 'msg' => '请指定$src');
}
$temp = pathinfo($src);
# 文件名
$name = $temp["basename"];
# 文件所在的文件夹
$dir = $temp["dirname"];
# 文件扩展名
$extension = $temp["extension"];
# 缩略图保存路径,新的文件名为*.thumb.jpg
$savepath = "{$dir}/thumb_{$name}";
# 获取图片的基本信息
$info = getimagesize($src);
# 获取图片宽度
$width = $info[0];
# 获取图片高度
$height = $info[1];
if (!empty($w)) {
$temp_w = $w; # 计算原图缩放后的宽度
$temp_h = intval($height * ($w / $width)); # 计算原图缩放后的高度
} else {
$temp_w = intval($width * ($h / $height)); # 计算原图缩放后的宽度
$temp_h = $h; # 计算原图缩放后的高度
}
# 创建画布
$temp_img = imagecreatetruecolor($temp_w, $temp_h);
@imagealphablending($temp_img, false); //这里很重要,意思是不合并颜色,直接用$img图像颜色替换,包括透明色;3-2
@imagesavealpha($temp_img, true); //这里很重要,意思是不要丢了$thumb图像的透明色;3-3
switch ($info[2]) {
case 1:
$im = imagecreatefromgif($src);
imagecopyresampled($temp_img, $im, 0, 0, 0, 0, $temp_w, $temp_h, $width, $height);
imagegif($temp_img, $savepath, 100);
break;
case 2:
$im = imagecreatefromjpeg($src);
imagecopyresampled($temp_img, $im, 0, 0, 0, 0, $temp_w, $temp_h, $width, $height);
imagejpeg($temp_img, $savepath, 100);
break;
case 3:
$im = imagecreatefrompng($src);
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;
case 6:
$im = imagecreatefrombmp($src);
imagesavealpha($im, true); //这里很重要;3-1
imagecopyresampled($temp_img, $im, 0, 0, 0, 0, $temp_w, $temp_h, $width, $height);
imagebmp($temp_img, $savepath, 100);
break;
case 18:
$im = imagecreatefromwebp($src);
imagesavealpha($im, true); //这里很重要;3-1
imagecopyresampled($temp_img, $im, 0, 0, 0, 0, $temp_w, $temp_h, $width, $height);
imagewebp($temp_img, $savepath, 100);
break;
}
imagedestroy($im);
return $savepath;
}
/**
* 图片添加水印
* @param string $src 1、图片相对路径或绝对路径 2、以逗号隔开的宽高值('800,600'
* @param array 属性值:
* res水印资源1、图片相对路径或绝对路径2、字符串
* pos图片水印添加的位置取值范围0~9
* 0随机位置在1~8之间随机选取一个位置
* 1:顶部居左 2:顶部居中
* 3:顶部居右 4:左边居中
* 5:图片中心 6:右边居中
* 7:底部居左 8:底部居中
* 9:底部居右
* font 字体库(相对路径或绝对路径)
* fontSize文字大小
* color 水印文字的字体颜色255,255,255
* name 图片保存名称
* @return array code状态、 msg提示信息、 url:图片地址
**/
public static function setWater($src, $arr = array())
{
if (empty($src)) {
return array('code' => false, 'msg' => '请指定$src');
}
$def = array(
'res' => '小川编程',
'pos' => 7,
'font' => './1.ttf',
'fontSize' => 24,
'color' => '255,255,255,0',
'name' => null,
);
$def = array_merge($def, $arr);
/**
* 判断$src是不是图片不是就创建画布
*/
if (!file_exists($src)) {
if (empty($def['name'])) {
return array('code' => false, 'msg' => '请指定图片名称');
}
# 计算画布宽高
$obj = explode(',', $src);
if (count($obj) != 2) {
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
} else {
# 获取图片信息
$srcInfo = @getimagesize($src);
$srcImg_w = $srcInfo[0];
$srcImg_h = $srcInfo[1];
if (empty($def['name'])) {
$def['name'] = $src;
}
# 动态的把图片导入内存中
switch ($srcInfo[2]) {
case 1:
$dst_img = imagecreatefromgif($src);
break;
case 2:
$dst_img = imagecreatefromjpeg($src);
break;
case 3:
$dst_img = imagecreatefrompng($src);
imagesavealpha($dst_img, true); //这里很重要;3-1
break;
case 6:
$dst_img = imagecreatefrombmp($src);
imagesavealpha($dst_img, true); //这里很重要;3-1
break;
case 18:
$dst_img = imagecreatefromwebp($src);
imagesavealpha($dst_img, true); //这里很重要;3-1
break;
default:
return array('code' => false, 'msg' => '目标图片类型错误');
exit;
}
}
/**
* 计算出水印宽高
*/
if (!file_exists($def['res'])) {
if (!file_exists($def['font'])) {
return array('code' => false, 'msg' => '字体库不存在');
}
$box = @imagettfbbox($def['fontSize'], 0, $def['font'], $def['res']);
$logow = max($box[2], $box[4]) - min($box[0], $box[6]);
$logoh = max($box[1], $box[3]) - min($box[5], $box[7]);
} else {
$resInfo = @getimagesize($def['res']);
$res_w = $resInfo[0];
$res_h = $resInfo[1];
if ($srcImg_w < $res_w || $srcImg_h < $res_h) {
return array('code' => false, 'msg' => '水印图片过大');
}
# 动态的把图片导入内存中
switch ($resInfo[2]) {
case 1:
$markim = imagecreatefromgif($def['res']);
break;
case 2:
$markim = imagecreatefromjpeg($def['res']);
break;
case 3:
$markim = imagecreatefrompng($def['res']);
break;
case 6:
$markim = imagecreatefrombmp($def['res']);
break;
case 18:
$markim = imagecreatefromwebp($def['res']);
break;
default:
return array('code' => false, 'msg' => '水印图片类型错误');
exit;
}
$logow = $res_w;
$logoh = $res_h;
}
/**
* 计算水印显示位置
*/
if ($def['pos'] == 0) {
$def['pos'] = rand(1, 9);
}
switch ($def['pos']) {
case 1:
$x = +10;
$y = +10 + $def['fontSize'];
break;
case 2:
$x = ($srcImg_w - $logow) / 2;
$y = +10 + $def['fontSize'];
break;
case 3:
$x = $srcImg_w - $logow - 10;
$y = +10 + $def['fontSize'];
break;
case 4:
$x = +10;
$y = ($srcImg_h - $logoh) / 2 + $def['fontSize'];
break;
case 5:
$x = ($srcImg_w - $logow) / 2;
$y = ($srcImg_h - $logoh) / 2 + $def['fontSize'];
break;
case 6:
$x = $srcImg_w - $logow - 10;
$y = ($srcImg_h - $logoh) / 2 + $def['fontSize'];
break;
case 7:
$x = +10;
$y = $srcImg_h - $logoh + $def['fontSize'] - 10;
break;
case 8:
$x = ($srcImg_w - $logow) / 2;
$y = $srcImg_h - $logoh + $def['fontSize'] - 10;
break;
case 9:
$x = $srcImg_w - $logow - 10;
$y = $srcImg_h - $logoh + $def['fontSize'] - 10;
break;
default:
return array('code' => false, 'msg' => '水印位置不支持');
exit;
}
/**
* 把图片水印或文字水印,加到目标图片中
*/
if (file_exists($def['res'])) {
imagecopy($dst_img, $markim, $x, $y, 0, 0, $logow, $logoh);
imagedestroy($markim);
} else {
$rgb = explode(',', $def['color']);
if (count($rgb) != 4) {
return array('code' => false, 'msg' => '请给正确的字体颜色');
}
if (!is_numeric($rgb[0]) || !is_numeric($rgb[1]) || !is_numeric($rgb[2]) || !is_numeric($rgb[3])) {
return array('code' => false, 'msg' => '请给正确的字体颜色');
}
if ($rgb[0] > 255 || $rgb[1] > 255 || $rgb[2] > 255 || $rgb[3] > 127) {
return array('code' => false, 'msg' => '请给正确的字体颜色');
}
// ceil(127 - 127 * $rgb[3]) 将CSS中的Alpha 0-1 转换为PHP Alpha 127-0 并取整
$def['color'] = imagecolorallocatealpha($dst_img, $rgb[0], $rgb[1], $rgb[2], ceil(127 - 127 * $rgb[3]));
imagettftext(
$dst_img,
$def['fontSize'],
0,
$x,
$y,
$def['color'],
$def['font'],
$def['res']
);
}
/**
* 保存处理过的图片(有水印了的图片)
*/
$name = explode('.', $def['name']);
$num = count($name) - 1;
switch (strtolower($name[$num])) {
case 'jpeg':
imagejpeg($dst_img, $def['name']);
break;
case 'jpg':
imagejpeg($dst_img, $def['name']);
break;
case 'png':
imagepng($dst_img, $def['name']);
break;
case 'gif':
imagegif($dst_img, $def['name']);
break;
case 'bmp':
imagebmp($dst_img, $def['name']);
break;
case 'webp':
imagewebp($dst_img, $def['name']);
break;
default:
return array('code' => false, 'msg' => '保存图片类型有误');
break;
}
# 销毁图片内存资源
imagedestroy($dst_img);
return array('code' => true, 'msg' => '添加水印成功', 'url' => $def['name']);
}
}
<?php
// https://blog.csdn.net/MyDream229/article/details/80009012
class Imgs
{
/**
* 取得图片宽
* @param string $src 图片相对路径或绝对路径
*/
public static function get_width($src)
{
return imagesx($src);
}
/**
* 取得图片高
* @param string $src 图片相对路径或绝对路径
*/
public static function get_height($src)
{
return imagesy($src);
}
/**
* 图片缩放函数
* @param string $src 图片相对路径或绝对路径
* @param int $w 缩略图宽
* @param int $h 缩略图高
* @return array code状态。msg提示信息
**/
public static function thumb($src, $w = null, $h = null)
{
if (empty($src)) {
return array('code' => false, 'msg' => '请指定$src');
}
$temp = pathinfo($src);
# 文件名
$name = $temp["basename"];
# 文件所在的文件夹
$dir = $temp["dirname"];
# 文件扩展名
$extension = $temp["extension"];
# 缩略图保存路径,新的文件名为*.thumb.jpg
$savepath = "{$dir}/thumb_{$name}";
# 获取图片的基本信息
$info = getimagesize($src);
# 获取图片宽度
$width = $info[0];
# 获取图片高度
$height = $info[1];
if (!empty($w)) {
$temp_w = $w; # 计算原图缩放后的宽度
$temp_h = intval($height * ($w / $width)); # 计算原图缩放后的高度
} else {
$temp_w = intval($width * ($h / $height)); # 计算原图缩放后的宽度
$temp_h = $h; # 计算原图缩放后的高度
}
# 创建画布
$temp_img = imagecreatetruecolor($temp_w, $temp_h);
@imagealphablending($temp_img, false); //这里很重要,意思是不合并颜色,直接用$img图像颜色替换,包括透明色;3-2
@imagesavealpha($temp_img, true); //这里很重要,意思是不要丢了$thumb图像的透明色;3-3
switch ($info[2]) {
case 1:
$im = imagecreatefromgif($src);
imagecopyresampled($temp_img, $im, 0, 0, 0, 0, $temp_w, $temp_h, $width, $height);
imagegif($temp_img, $savepath, 100);
break;
case 2:
$im = imagecreatefromjpeg($src);
imagecopyresampled($temp_img, $im, 0, 0, 0, 0, $temp_w, $temp_h, $width, $height);
imagejpeg($temp_img, $savepath, 100);
break;
case 3:
$im = imagecreatefrompng($src);
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;
case 6:
$im = imagecreatefrombmp($src);
imagesavealpha($im, true); //这里很重要;3-1
imagecopyresampled($temp_img, $im, 0, 0, 0, 0, $temp_w, $temp_h, $width, $height);
imagebmp($temp_img, $savepath, 100);
break;
case 18:
$im = imagecreatefromwebp($src);
imagesavealpha($im, true); //这里很重要;3-1
imagecopyresampled($temp_img, $im, 0, 0, 0, 0, $temp_w, $temp_h, $width, $height);
imagewebp($temp_img, $savepath, 100);
break;
}
imagedestroy($im);
return $savepath;
}
/**
* 图片添加水印
* @param string $src 1、图片相对路径或绝对路径 2、以逗号隔开的宽高值('800,600'
* @param array 属性值:
* res水印资源1、图片相对路径或绝对路径2、字符串
* pos图片水印添加的位置取值范围0~9
* 0随机位置在1~8之间随机选取一个位置
* 1:顶部居左 2:顶部居中
* 3:顶部居右 4:左边居中
* 5:图片中心 6:右边居中
* 7:底部居左 8:底部居中
* 9:底部居右
* font 字体库(相对路径或绝对路径)
* fontSize文字大小
* color 水印文字的字体颜色255,255,255
* name 图片保存名称
* @return array code状态、 msg提示信息、 url:图片地址
**/
public static function setWater($src, $arr = array())
{
if (empty($src)) {
return array('code' => false, 'msg' => '请指定$src');
}
$def = array(
'res' => '小川编程',
'pos' => 7,
'font' => './1.ttf',
'fontSize' => 24,
'color' => '255,255,255,0',
'name' => null,
);
$def = array_merge($def, $arr);
/**
* 判断$src是不是图片不是就创建画布
*/
if (!file_exists($src)) {
if (empty($def['name'])) {
return array('code' => false, 'msg' => '请指定图片名称');
}
# 计算画布宽高
$obj = explode(',', $src);
if (count($obj) != 2) {
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
} else {
# 获取图片信息
$srcInfo = @getimagesize($src);
$srcImg_w = $srcInfo[0];
$srcImg_h = $srcInfo[1];
if (empty($def['name'])) {
$def['name'] = $src;
}
# 动态的把图片导入内存中
switch ($srcInfo[2]) {
case 1:
$dst_img = imagecreatefromgif($src);
break;
case 2:
$dst_img = imagecreatefromjpeg($src);
break;
case 3:
$dst_img = imagecreatefrompng($src);
imagesavealpha($dst_img, true); //这里很重要;3-1
break;
case 6:
$dst_img = imagecreatefrombmp($src);
imagesavealpha($dst_img, true); //这里很重要;3-1
break;
case 18:
$dst_img = imagecreatefromwebp($src);
imagesavealpha($dst_img, true); //这里很重要;3-1
break;
default:
return array('code' => false, 'msg' => '目标图片类型错误');
exit;
}
}
/**
* 计算出水印宽高
*/
if (!file_exists($def['res'])) {
if (!file_exists($def['font'])) {
return array('code' => false, 'msg' => '字体库不存在');
}
$box = @imagettfbbox($def['fontSize'], 0, $def['font'], $def['res']);
$logow = max($box[2], $box[4]) - min($box[0], $box[6]);
$logoh = max($box[1], $box[3]) - min($box[5], $box[7]);
} else {
$resInfo = @getimagesize($def['res']);
$res_w = $resInfo[0];
$res_h = $resInfo[1];
if ($srcImg_w < $res_w || $srcImg_h < $res_h) {
return array('code' => false, 'msg' => '水印图片过大');
}
# 动态的把图片导入内存中
switch ($resInfo[2]) {
case 1:
$markim = imagecreatefromgif($def['res']);
break;
case 2:
$markim = imagecreatefromjpeg($def['res']);
break;
case 3:
$markim = imagecreatefrompng($def['res']);
break;
case 6:
$markim = imagecreatefrombmp($def['res']);
break;
case 18:
$markim = imagecreatefromwebp($def['res']);
break;
default:
return array('code' => false, 'msg' => '水印图片类型错误');
exit;
}
$logow = $res_w;
$logoh = $res_h;
}
/**
* 计算水印显示位置
*/
if ($def['pos'] == 0) {
$def['pos'] = rand(1, 9);
}
switch ($def['pos']) {
case 1:
$x = +10;
$y = +10 + $def['fontSize'];
break;
case 2:
$x = ($srcImg_w - $logow) / 2;
$y = +10 + $def['fontSize'];
break;
case 3:
$x = $srcImg_w - $logow - 10;
$y = +10 + $def['fontSize'];
break;
case 4:
$x = +10;
$y = ($srcImg_h - $logoh) / 2 + $def['fontSize'];
break;
case 5:
$x = ($srcImg_w - $logow) / 2;
$y = ($srcImg_h - $logoh) / 2 + $def['fontSize'];
break;
case 6:
$x = $srcImg_w - $logow - 10;
$y = ($srcImg_h - $logoh) / 2 + $def['fontSize'];
break;
case 7:
$x = +10;
$y = $srcImg_h - $logoh + $def['fontSize'] - 10;
break;
case 8:
$x = ($srcImg_w - $logow) / 2;
$y = $srcImg_h - $logoh + $def['fontSize'] - 10;
break;
case 9:
$x = $srcImg_w - $logow - 10;
$y = $srcImg_h - $logoh + $def['fontSize'] - 10;
break;
default:
return array('code' => false, 'msg' => '水印位置不支持');
exit;
}
/**
* 把图片水印或文字水印,加到目标图片中
*/
if (file_exists($def['res'])) {
imagecopy($dst_img, $markim, $x, $y, 0, 0, $logow, $logoh);
imagedestroy($markim);
} else {
$rgb = explode(',', $def['color']);
if (count($rgb) != 4) {
return array('code' => false, 'msg' => '请给正确的字体颜色');
}
if (!is_numeric($rgb[0]) || !is_numeric($rgb[1]) || !is_numeric($rgb[2]) || !is_numeric($rgb[3])) {
return array('code' => false, 'msg' => '请给正确的字体颜色');
}
if ($rgb[0] > 255 || $rgb[1] > 255 || $rgb[2] > 255 || $rgb[3] > 127) {
return array('code' => false, 'msg' => '请给正确的字体颜色');
}
// ceil(127 - 127 * $rgb[3]) 将CSS中的Alpha 0-1 转换为PHP Alpha 127-0 并取整
$def['color'] = imagecolorallocatealpha($dst_img, $rgb[0], $rgb[1], $rgb[2], ceil(127 - 127 * $rgb[3]));
imagettftext(
$dst_img,
$def['fontSize'],
0,
$x,
$y,
$def['color'],
$def['font'],
$def['res']
);
}
/**
* 保存处理过的图片(有水印了的图片)
*/
$name = explode('.', $def['name']);
$num = count($name) - 1;
switch (strtolower($name[$num])) {
case 'jpeg':
imagejpeg($dst_img, $def['name']);
break;
case 'jpg':
imagejpeg($dst_img, $def['name']);
break;
case 'png':
imagepng($dst_img, $def['name']);
break;
case 'gif':
imagegif($dst_img, $def['name']);
break;
case 'bmp':
imagebmp($dst_img, $def['name']);
break;
case 'webp':
imagewebp($dst_img, $def['name']);
break;
default:
return array('code' => false, 'msg' => '保存图片类型有误');
break;
}
# 销毁图片内存资源
imagedestroy($dst_img);
return array('code' => true, 'msg' => '添加水印成功', 'url' => $def['name']);
}
}

View File

@ -5,12 +5,12 @@
* 作者mengkun (mkblog.cn)
* 日期2016/12/23
* 修改Icret
* 修改日期2023-01-30
* 修改日期2023-03-09
*/
include_once __DIR__ . '/function.php';
include_once APP_ROOT . '/config/config.php';
include_once '../config/config.php';
$path = '..' . $config['path'] . $config['delDir']; // 设置图片缓存文件夹
$path = APP_ROOT . $config['path'] . $config['delDir']; // 设置图片缓存文件夹
$filename = date("Ymd") . '.jpg'; // 用年月日来命名新的文件名
if (file_exists($path . $filename)) // 如果文件不存在,则说明今天还没有进行缓存
{

122
application/captcha.php → app/captcha.php Executable file → Normal file
View File

@ -1,61 +1,61 @@
<?php
session_start(); //设置session
require __DIR__ . "/function.php";
//创建背景画布
$img_w = 305;
/*宽*/
$img_h = 54;
$img = imagecreatetruecolor($img_w, $img_h);
$bg_color = imagecolorallocate($img, 0xcc, 0xcc, 0xcc);
imagefill($img, 0, 0, $bg_color);
//生成验证码
$count = 4;
$code = "";
/*生成的验证码内容范围*/
$charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
$str_len = strlen($charset) - 1;
/*for循环打印输出验证码*/
for ($i = 0; $i < $count; $i++) {
$code .= $charset[rand(0, $str_len)];
}
/*strtolower函数将输入的验证码自动转换为小写用户不需要特意区分大小写*/
$_SESSION['code'] = strtolower($code);
/*字体大小*/
$font_size = 24;
/*字体文件位置*/
$fontfile = APP_ROOT . $config['textFont'];
for ($i = 0; $i < $count; $i++) {
$font_color = imagecolorallocate($img, mt_rand(0, 100), mt_rand(0, 50), mt_rand(0, 255));
imagettftext(
$img,
$font_size,
mt_rand(0, 20) - mt_rand(0, 25),
($img_w * $i / 4) + mt_rand(0, 15),
mt_rand($img_h / 2, $img_h),
$font_color,
realpath($fontfile),
$code[$i]
);
}
/*背景干扰点点*/
for ($i = 0; $i < 300; $i++) {
$color = imagecolorallocate($img, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
imagesetpixel($img, mt_rand(0, $img_w), mt_rand(0, $img_h), $color);
}
/*干扰线条*/
for ($i = 0; $i < 5; $i++) {
$color = imagecolorallocate($img, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
imageline($img, mt_rand(0, $img_w), 0, mt_rand(0, $img_h), $img_h, $color);
imagesetpixel($img, mt_rand(0, $img_w), mt_rand(0, $img_h), $color);
}
// 因为有些浏览器访问的content-type会是文本型所以我们需要设置成图片的格式类型
header("content-type:image/png");
imagepng($img); //建立png函数
imagedestroy($image);
<?php
session_start(); //设置session
require __DIR__ . "/function.php";
//创建背景画布
$img_w = 305;
/*宽*/
$img_h = 54;
$img = imagecreatetruecolor($img_w, $img_h);
$bg_color = imagecolorallocate($img, 0xcc, 0xcc, 0xcc);
imagefill($img, 0, 0, $bg_color);
//生成验证码
$count = 4;
$code = "";
/*生成的验证码内容范围*/
$charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
$str_len = strlen($charset) - 1;
/*for循环打印输出验证码*/
for ($i = 0; $i < $count; $i++) {
$code .= $charset[rand(0, $str_len)];
}
/*strtolower函数将输入的验证码自动转换为小写用户不需要特意区分大小写*/
$_SESSION['code'] = strtolower($code);
/*字体大小*/
$font_size = 24;
/*字体文件位置*/
$fontfile = APP_ROOT . $config['textFont'];
for ($i = 0; $i < $count; $i++) {
$font_color = imagecolorallocate($img, mt_rand(0, 100), mt_rand(0, 50), mt_rand(0, 255));
imagettftext(
$img,
$font_size,
mt_rand(0, 20) - mt_rand(0, 25),
($img_w * $i / 4) + mt_rand(0, 15),
mt_rand($img_h / 2, $img_h),
$font_color,
realpath($fontfile),
$code[$i]
);
}
/*背景干扰点点*/
for ($i = 0; $i < 300; $i++) {
$color = imagecolorallocate($img, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
imagesetpixel($img, mt_rand(0, $img_w), mt_rand(0, $img_h), $color);
}
/*干扰线条*/
for ($i = 0; $i < 5; $i++) {
$color = imagecolorallocate($img, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
imageline($img, mt_rand(0, $img_w), 0, mt_rand(0, $img_h), $img_h, $color);
imagesetpixel($img, mt_rand(0, $img_w), mt_rand(0, $img_h), $color);
}
// 因为有些浏览器访问的content-type会是文本型所以我们需要设置成图片的格式类型
header("content-type:image/png");
imagepng($img); //建立png函数
imagedestroy($image);

200
application/chart.php → app/chart.php Executable file → Normal file
View File

@ -1,100 +1,100 @@
<?php
require_once __DIR__ . '/function.php';
require_once __DIR__ . '/total_files.php';
/** 统计最近一个月上传文件数与空间占用 */
// 获取最近一周,一个月,一年 https://www.cnblogs.com/-mrl/p/7680700.html
function getLatelyTime($type = '')
{
$now = time();
$result = [];
if ($type == 'week') {
//最近一周
for ($i = 0; $i < 7; $i++) {
$result[] = date('Y/m/d/', strtotime('-' . $i . ' day', $now));
}
} elseif ($type == 'month') {
//最近一个月
for ($i = 0; $i < 30; $i++) {
$result[] = date('Y/m/d/', strtotime('-' . $i . ' day', $now));
}
} elseif ($type == 'year') {
//最近一年
for ($i = 0; $i < 12; $i++) {
$result[] = date('Y/m/', strtotime('-' . $i . ' month', $now));
}
}
return $result;
}
$total_contents = APP_ROOT . $config['path']; // 获取用户自定义的上传目录
$chart_total_file_md5 = strval(md5_file(APP_ROOT . '/config/config.php')); // 以config.php文件的md5命名
$chart_total_file = APP_ROOT . "/admin/logs/counts/chart-$chart_total_file_md5.php"; // 文件绝对目录
function write_chart_total()
{
global $total_contents;
global $chart_total_file;
global $chart_total_file_md5;
$count_day = getLatelyTime('month');
$count_contents['filename'] = $chart_total_file_md5; // 文件名称
$count_contents['total_time'] = date('Y-m-d H:i:s'); // 统计时间
$count_contents['date'] = date('YmdH'); // 校对时间
for ($i = 0; $i < count($count_day); $i++) {
// 统计每日上传数量
$count_contents['chart_data'][] = [$count_day[$i] => getFileNumber($total_contents . $count_day[$i])];
}
for ($i = 0; $i < count($count_day); $i++) {
// 统计每日占用空间
$count_contents['chart_disk'][] = [$count_day[$i] => getDirectorySize($total_contents . $count_day[$i])];
}
if (!is_dir(APP_ROOT . '/admin/logs/counts/')) {
mkdir(APP_ROOT . '/admin/logs/counts/', 0755, true);
}
$count_contents = json_encode($count_contents, true);
file_put_contents($chart_total_file, $count_contents); // 存储文件
}
function read_chart_total()
{
global $chart_total_file;
global $config;
$cache_freq = $config['cache_freq'];
if (file_exists($chart_total_file)) {
$read_chart_file = file_get_contents($chart_total_file);
$read_chart_file = json_decode($read_chart_file, true);
} else {
write_chart_total();
$read_chart_file = file_get_contents($chart_total_file);
$read_chart_file = json_decode($read_chart_file, true);
}
if ((date('YmdH') - $read_chart_file['date']) > $cache_freq) {
write_chart_total();
$read_chart_file = file_get_contents($chart_total_file);
$read_chart_file = json_decode($read_chart_file, true);
}
for ($i = 0; $i < count($read_chart_file['chart_data']); $i++) {
// 读取每日上传数量
foreach ($read_chart_file['chart_data'][$i] as $key => $value) {
$chart_data_date[] = '"' . $key . '" ,';
$chart_data_num[] = '"' . $value . '" ,';
}
foreach ($read_chart_file['chart_disk'][$i] as $value) {
$value = round($value / 1024 / 1024, 2);
$chart_total_disk[] = '"' . $value . '" ,';
}
}
return array('filename' => $read_chart_file['filename'], 'date' => $chart_data_date, 'number' => $chart_data_num, 'disk' => $chart_total_disk, 'total_time' => $read_chart_file['total_time']);
}
<?php
require_once __DIR__ . '/function.php';
require_once __DIR__ . '/total_files.php';
/** 统计最近一个月上传文件数与空间占用 */
// 获取最近一周,一个月,一年 https://www.cnblogs.com/-mrl/p/7680700.html
function getLatelyTime($type = '')
{
$now = time();
$result = [];
if ($type == 'week') {
//最近一周
for ($i = 0; $i < 7; $i++) {
$result[] = date('Y/m/d/', strtotime('-' . $i . ' day', $now));
}
} elseif ($type == 'month') {
//最近一个月
for ($i = 0; $i < 30; $i++) {
$result[] = date('Y/m/d/', strtotime('-' . $i . ' day', $now));
}
} elseif ($type == 'year') {
//最近一年
for ($i = 0; $i < 12; $i++) {
$result[] = date('Y/m/', strtotime('-' . $i . ' month', $now));
}
}
return $result;
}
$total_contents = APP_ROOT . $config['path']; // 获取用户自定义的上传目录
$chart_total_file_md5 = strval(md5_file(APP_ROOT . '/config/config.php')); // 以config.php文件的md5命名
$chart_total_file = APP_ROOT . "/admin/logs/counts/chart-$chart_total_file_md5.php"; // 文件绝对目录
function write_chart_total()
{
global $total_contents;
global $chart_total_file;
global $chart_total_file_md5;
$count_day = getLatelyTime('month');
$count_contents['filename'] = $chart_total_file_md5; // 文件名称
$count_contents['total_time'] = date('Y-m-d H:i:s'); // 统计时间
$count_contents['date'] = date('YmdH'); // 校对时间
for ($i = 0; $i < count($count_day); $i++) {
// 统计每日上传数量
$count_contents['chart_data'][] = [$count_day[$i] => getFileNumber($total_contents . $count_day[$i])];
}
for ($i = 0; $i < count($count_day); $i++) {
// 统计每日占用空间
$count_contents['chart_disk'][] = [$count_day[$i] => getDirectorySize($total_contents . $count_day[$i])];
}
if (!is_dir(APP_ROOT . '/admin/logs/counts/')) {
mkdir(APP_ROOT . '/admin/logs/counts/', 0755, true);
}
$count_contents = json_encode($count_contents, true);
file_put_contents($chart_total_file, $count_contents); // 存储文件
}
function read_chart_total()
{
global $chart_total_file;
global $config;
$cache_freq = $config['cache_freq'];
if (file_exists($chart_total_file)) {
$read_chart_file = file_get_contents($chart_total_file);
$read_chart_file = json_decode($read_chart_file, true);
} else {
write_chart_total();
$read_chart_file = file_get_contents($chart_total_file);
$read_chart_file = json_decode($read_chart_file, true);
}
if ((date('YmdH') - $read_chart_file['date']) > $cache_freq) {
write_chart_total();
$read_chart_file = file_get_contents($chart_total_file);
$read_chart_file = json_decode($read_chart_file, true);
}
for ($i = 0; $i < count($read_chart_file['chart_data']); $i++) {
// 读取每日上传数量
foreach ($read_chart_file['chart_data'][$i] as $key => $value) {
$chart_data_date[] = '"' . $key . '" ,';
$chart_data_num[] = '"' . $value . '" ,';
}
foreach ($read_chart_file['chart_disk'][$i] as $value) {
$value = round($value / 1024 / 1024, 2);
$chart_total_disk[] = '"' . $value . '" ,';
}
}
return array('filename' => $read_chart_file['filename'], 'date' => $chart_data_date, 'number' => $chart_data_num, 'disk' => $chart_total_disk, 'total_time' => $read_chart_file['total_time']);
}

182
application/check.php → app/check.php Executable file → Normal file
View File

@ -1,92 +1,92 @@
<?php
require_once __DIR__ . '/function.php';
// 跳转安装
if (!is_file(APP_ROOT . '/config/install.lock') and is_file(APP_ROOT . '/install/install.php')) {
exit('<script type="text/javascript">window.location.href="' . get_whole_url('/') . '/install/index.php"</script>');
}
/** 检测弹窗 */
if (is_file(APP_ROOT . '/config/EasyIamge.lock')) return; // 查询锁定弹窗文件是否存在
file_put_contents(APP_ROOT . '/config/EasyIamge.lock', '安装环境检测锁定文件,如需再次展示请删除此文件!', FILE_APPEND | LOCK_EX);
?>
<div class="modal fade" id="myModal-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">
<i class="icon icon-heart"> </i><a href="https://github.com/icret/EasyImages2.0" target="_blank">简单图床-EasyImage2.0</a> 安装环境检测
</h4>
</div>
<div class="modal-body">
<h4>说明:</h4>
<h5>1. 建议使用<span class="text-red">PHP7.0</span>及以上版本;</h5>
<h5>2. 上传失败大部分是由于<span class="text-red">upload_max_filesize、post_max_size、文件权限</span>设置不正确;</h5>
<h5>3. 主要用到<span class="text-red">Fileinfo、GD、Openssl</span>扩展,如果缺失会导致无法访问管理面板以及上传/删除图片。</h5>
<hr />
<h4>EasyImage2.0 基础检测:</h4>
<p>当前PHP版本:<sapn class="text-green"><?php echo phpversion() ?></sapn>
</p>
<p>PHP最大上传: <sapn class="text-green"><?php echo ini_get('upload_max_filesize'); ?></sapn>
</p>
<p>POST最大上传: <sapn class="text-green"><?php echo ini_get('post_max_size'); ?></sapn>
</p>
<?php
// 扩展检测 取消检测imagick扩展
$expand = array('fileinfo', 'openssl', 'gd');
foreach ($expand as $val) {
if (extension_loaded($val)) {
echo "<p class='text-green'> $val - 已安装</p>";
} else {
echo "<script language='javascript'>alert($val - 未安装)</script>";
echo "<p class='text-red'> $val- 未安装</p>";
}
}
// 文件权限检测
$quanxian = substr(base_convert(fileperms(APP_ROOT . "/application/upload.php"), 10, 8), 3);
if (IS_WIN) {
echo '
<p class="text-green">upload.php 文件可执行</p>
<p class="text-green">' . $config['path'] . ' 目录可读写</p>
';
}
if (!IS_WIN) {
if ($quanxian !== '755' and !is_writable(APP_ROOT . $config['path'])) {
echo '
<p class="text-red">upload.php 文件不可执行</font>>
<p class="text-red">' . $config['path'] . ' 目录可读写</font>>
';
} else {
echo '
<p class="text-green">upload.php 文件可执行</p>
<p class="text-green">' . $config['path'] . ' 目录可读写</p>
';
}
}
echo '<p class="text-green">当前支持图片格式:';
foreach (gd_info() as $k => $v) {
$k = str_ireplace(array('Support', 'Create', 'Read', 'Linkage', 'GD Version', 'FreeType', 'Font', 'JIS-mapped', 'Japanese'), '', $k);
if ($v) {
printf("%s", $k);
} else {
printf("%s", $k);
}
}
echo '</p>';
?>
</div>
<div class="modal-footer" style="text-align:left">
<p class="text-primary">安装环境检测弹窗仅在第一次访问主页时展示,弹出后会在<code>config</code>目录下生成<code>EasyIamge.lock</code>文件,如需再次弹出请删除<code>EasyIamge.lock</code>文件。</p>
<p class="text-primary">刷新或<kbd>ESC</kbd>关闭安装环境检测弹窗。</p>
</div>
</div>
</div>
</div>
<script>
$("#myModal-1").modal({
keyboard: true,
moveable: true,
backdrop: "static", //点击空白处不关闭对话框
show: true
})
alert("初次打开会检测环境配置,请仔细看!!");
<?php
require_once __DIR__ . '/function.php';
// 跳转安装
if (!is_file(APP_ROOT . '/config/install.lock') and is_file(APP_ROOT . '/install/install.php')) {
exit('<script type="text/javascript">window.location.href="' . get_whole_url('/') . '/install/index.php"</script>');
}
/** 检测弹窗 */
if (is_file(APP_ROOT . '/config/EasyIamge.lock')) return; // 查询锁定弹窗文件是否存在
file_put_contents(APP_ROOT . '/config/EasyIamge.lock', '安装环境检测锁定文件,如需再次展示请删除此文件!', FILE_APPEND | LOCK_EX);
?>
<div class="modal fade" id="myModal-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">
<i class="icon icon-heart"> </i><a href="https://github.com/icret/EasyImages2.0" target="_blank">简单图床-EasyImage2.0</a> 安装环境检测
</h4>
</div>
<div class="modal-body">
<h4>说明:</h4>
<h5>1. 建议使用<span class="text-red">PHP7.0</span>及以上版本;</h5>
<h5>2. 上传失败大部分是由于<span class="text-red">upload_max_filesize、post_max_size、文件权限</span>设置不正确;</h5>
<h5>3. 主要用到<span class="text-red">Fileinfo、GD、Openssl</span>扩展,如果缺失会导致无法访问管理面板以及上传/删除图片。</h5>
<hr />
<h4>EasyImage2.0 基础检测:</h4>
<p>当前PHP版本:<sapn class="text-green"><?php echo phpversion() ?></sapn>
</p>
<p>PHP最大上传: <sapn class="text-green"><?php echo ini_get('upload_max_filesize'); ?></sapn>
</p>
<p>POST最大上传: <sapn class="text-green"><?php echo ini_get('post_max_size'); ?></sapn>
</p>
<?php
// 扩展检测 取消检测imagick扩展
$expand = array('fileinfo', 'openssl', 'gd');
foreach ($expand as $val) {
if (extension_loaded($val)) {
echo "<p class='text-green'> $val - 已安装</p>";
} else {
echo "<script language='javascript'>alert($val - 未安装)</script>";
echo "<p class='text-red'> $val- 未安装</p>";
}
}
// 文件权限检测
$quanxian = substr(base_convert(fileperms(APP_ROOT . "/app/upload.php"), 10, 8), 3);
if (IS_WIN) {
echo '
<p class="text-green">upload.php 文件可执行</p>
<p class="text-green">' . $config['path'] . ' 目录可读写</p>
';
}
if (!IS_WIN) {
if ($quanxian !== '755' and !is_writable(APP_ROOT . $config['path'])) {
echo '
<p class="text-red">upload.php 文件不可执行</font>>
<p class="text-red">' . $config['path'] . ' 目录可读写</font>>
';
} else {
echo '
<p class="text-green">upload.php 文件可执行</p>
<p class="text-green">' . $config['path'] . ' 目录可读写</p>
';
}
}
echo '<p class="text-green">当前支持图片格式:';
foreach (gd_info() as $k => $v) {
$k = str_ireplace(array('Support', 'Create', 'Read', 'Linkage', 'GD Version', 'FreeType', 'Font', 'JIS-mapped', 'Japanese'), '', $k);
if ($v) {
printf("%s", $k);
} else {
printf("%s", $k);
}
}
echo '</p>';
?>
</div>
<div class="modal-footer" style="text-align:left">
<p class="text-primary">安装环境检测弹窗仅在第一次访问主页时展示,弹出后会在<code>config</code>目录下生成<code>EasyIamge.lock</code>文件,如需再次弹出请删除<code>EasyIamge.lock</code>文件。</p>
<p class="text-primary">刷新或<kbd>ESC</kbd>关闭安装环境检测弹窗。</p>
</div>
</div>
</div>
</div>
<script>
$("#myModal-1").modal({
keyboard: true,
moveable: true,
backdrop: "static", //点击空白处不关闭对话框
show: true
})
alert("初次打开会检测环境配置,请仔细看!!");
</script>

View File

@ -1,154 +1,154 @@
<?php
/*
// 检查当前PHP版本是否大于7.0
if (PHP_VERSION < 7) {
echo '
new $.zui.Messager("当前PHP版本<7.0, 部分功能受限!",{
type: "primary", // 定义颜色主题
time:3000
}).show();
';
}
*/
// 扩展检测
$expand = array('fileinfo', 'iconv', 'gd', 'mbstring', 'openssl',);
foreach ($expand as $val) {
if (!extension_loaded($val)) {
echo '
new $.zui.Messager("扩展:' . $val . '- 未安装,可能导致图片上传失败! 请尽快修复。",{
type: "black", // 定义颜色主题
icon: "exclamation-sign", // 定义消息图标
time:3500
}).show();
';
}
}
// 检测是否修改默认密码
if ($config['password'] === 'e6e061838856bf47e1de730719fb2609') {
echo '
new $.zui.Messager("请修改默认密码,否则会有泄露风险! ",{
type: "warning", // 定义颜色主题
time:4000
}).show();
';
}
// 检测是否局域网访问
if (is_local($config['domain']) || is_local($config['imgurl'])) {
echo '
new $.zui.Messager("当前使用局域网,可能会导致外网访问异常!",{
type: "black", // 定义颜色主题
time:4500
}).show();
';
}
// 检测是否存在.user.ini
if (file_exists(APP_ROOT . '/.user.ini')) {
echo '
new $.zui.Messager("请关闭防跨目录读写或删除.user.ini文件",{
type: "danger", // 定义颜色主题
time:5000
}).show();
';
}
// 检测是否存在 IP数据库文件 ip2region.xdb
if (!file_exists(__DIR__ . '/ip2region/ip2region.xdb')) {
echo '
new $.zui.Messager("IP 数据库不存在, 请在系统信息中查看 Ip2region",{
type: "danger", // 定义颜色主题
time:5500
}).show();
';
}
// 检查当前版本与GitHub版本
if (getVersion() !== get_current_version()) {
echo '
new $.zui.Messager("当前版本与GitHub不一致,请检查当前是否最新版本!",{
type: "danger", // 定义颜色主题
time:6000
}).show();
';
}
// 检测是否开启登录上传
if ($config['mustLogin']) {
echo '
$.zui.browser.tip("请注意: 当前已开启登录上传,游客不能上传图片!");
';
}
// 检测水印图片是否存在
if (!is_file(APP_ROOT . $config['waterImg'])) {
echo '
new $.zui.Messager("水印图片不存在,请检测路径或者文件是否存在!",{
type: "danger", // 定义颜色主题
time:6500
}).show();
';
}
// 检测水印字体是否存在
if (!is_file(APP_ROOT . $config['textFont'])) {
echo '
new $.zui.Messager("水印字体不存在,请检测路径或者文件是否存在!",{
type: "danger", // 定义颜色主题
time:6500
}).show();
';
}
// 检测监黄接口是否可以访问
if ($config['checkImg'] !== 0) {
if ($config['checkImg'] == 1) {
if (!@IP_URL_Ping('api.moderatecontent.com', 80, 1)) {
echo '
new $.zui.Messager("moderatecontent 鉴黄接口无法ping通! ",{
type: "warning", // 定义颜色主题
time:7000
}).show();
';
}
}
if ($config['checkImg'] == 2) {
$ip = parse_url($config['nsfwjs_url'])['host'];
$port = parse_url($config['nsfwjs_url'])['port'];
if (filter_var($ip, FILTER_VALIDATE_IP)) {
if (!@IP_URL_Ping($ip, $port, 1)) {
echo '
new $.zui.Messager("' . $ip . $port . ' 鉴黄接口无法ping通! ",{
type: "warning", // 定义颜色主题
time:7000
}).show();
';
}
} else {
if (!@IP_URL_Ping($ip, 80, 1)) {
echo '
new $.zui.Messager("' . $ip . ' 鉴黄接口无法ping通! ",{
type: "warning", // 定义颜色主题
time:7000
}).show();
';
}
}
}
}
if (!function_exists('fastcgi_finish_request')) {
echo '
new $.zui.Messager("开启 fastcgi_finish_request 处理数据会更快喔!",{
type: "primary", // 定义颜色主题
time:7000
}).show();
';
}
<?php
/*
// 检查当前PHP版本是否大于7.0
if (PHP_VERSION < 7) {
echo '
new $.zui.Messager("当前PHP版本<7.0, 部分功能受限!",{
type: "primary", // 定义颜色主题
time:3000
}).show();
';
}
*/
// 扩展检测
$expand = array('fileinfo', 'iconv', 'gd', 'mbstring', 'openssl',);
foreach ($expand as $val) {
if (!extension_loaded($val)) {
echo '
new $.zui.Messager("扩展:' . $val . '- 未安装,可能导致图片上传失败! 请尽快修复。",{
type: "black", // 定义颜色主题
icon: "exclamation-sign", // 定义消息图标
time:3500
}).show();
';
}
}
// 检测是否修改默认密码
if ($config['password'] === 'e6e061838856bf47e1de730719fb2609') {
echo '
new $.zui.Messager("请修改默认密码,否则会有泄露风险! ",{
type: "warning", // 定义颜色主题
time:4000
}).show();
';
}
// 检测是否局域网访问
if (is_local($config['domain']) || is_local($config['imgurl'])) {
echo '
new $.zui.Messager("当前使用局域网,可能会导致外网访问异常!",{
type: "black", // 定义颜色主题
time:4500
}).show();
';
}
// 检测是否存在.user.ini
if (file_exists(APP_ROOT . '/.user.ini')) {
echo '
new $.zui.Messager("请关闭防跨目录读写或删除.user.ini文件",{
type: "danger", // 定义颜色主题
time:5000
}).show();
';
}
// 检测是否存在 IP数据库文件 ip2region.xdb
if (!file_exists(__DIR__ . '/ip2region/ip2region.xdb')) {
echo '
new $.zui.Messager("IP 数据库不存在, 请在系统信息中查看 Ip2region",{
type: "danger", // 定义颜色主题
time:5500
}).show();
';
}
// 检查当前版本与GitHub版本
if (getVersion() !== get_current_version()) {
echo '
new $.zui.Messager("当前版本与GitHub不一致,请检查当前是否最新版本!",{
type: "danger", // 定义颜色主题
time:6000
}).show();
';
}
// 检测是否开启登录上传
if ($config['mustLogin']) {
echo '
$.zui.browser.tip("请注意: 当前已开启登录上传,游客不能上传图片!");
';
}
// 检测水印图片是否存在
if (!is_file(APP_ROOT . $config['waterImg'])) {
echo '
new $.zui.Messager("水印图片不存在,请检测路径或者文件是否存在!",{
type: "danger", // 定义颜色主题
time:6500
}).show();
';
}
// 检测水印字体是否存在
if (!is_file(APP_ROOT . $config['textFont'])) {
echo '
new $.zui.Messager("水印字体不存在,请检测路径或者文件是否存在!",{
type: "danger", // 定义颜色主题
time:6500
}).show();
';
}
// 检测监黄接口是否可以访问
if ($config['checkImg'] !== 0) {
if ($config['checkImg'] == 1) {
if (!@IP_URL_Ping('api.moderatecontent.com', 80, 1)) {
echo '
new $.zui.Messager("moderatecontent 鉴黄接口无法ping通! ",{
type: "warning", // 定义颜色主题
time:7000
}).show();
';
}
}
if ($config['checkImg'] == 2) {
$ip = parse_url($config['nsfwjs_url'])['host'];
$port = parse_url($config['nsfwjs_url'])['port'];
if (filter_var($ip, FILTER_VALIDATE_IP)) {
if (!@IP_URL_Ping($ip, $port, 1)) {
echo '
new $.zui.Messager("' . $ip . $port . ' 鉴黄接口无法ping通! ",{
type: "warning", // 定义颜色主题
time:7000
}).show();
';
}
} else {
if (!@IP_URL_Ping($ip, 80, 1)) {
echo '
new $.zui.Messager("' . $ip . ' 鉴黄接口无法ping通! ",{
type: "warning", // 定义颜色主题
time:7000
}).show();
';
}
}
}
}
if (!function_exists('fastcgi_finish_request')) {
echo '
new $.zui.Messager("开启 fastcgi_finish_request 处理数据会更快喔!",{
type: "primary", // 定义颜色主题
time:7000
}).show();
';
}

View File

@ -1,45 +1,45 @@
<?php
/**
* 分布式 id 生成类 组成: <毫秒级时间戳+机器id+序列号>
* 默认情况下41bit的时间戳可以支持该算法使用到2082年10bit的工作机器id可以支持1023台机器序列号支持1毫秒产生4095个自增序列id
* @author zhangqi
* @link https://www.cnblogs.com/njccqx/p/13402169.html
*/
class SnowFlake
{
const EPOCH = 1479533469598; //开始时间,固定一个小于当前时间的毫秒数
const max12bit = 4095;
const max41bit = 1099511627775;
static $machineId = 1; // 机器id
public static function machineId($mId = 0)
{
self::$machineId = $mId;
}
public static function createOnlyId()
{
// 时间戳 42字节
$time = floor(microtime(true) * 1000);
// 当前时间 与 开始时间 差值
$time -= self::EPOCH;
// 二进制的 毫秒级时间戳
$base = decbin(self::max41bit + $time);
// 机器id 10 字节
if (!self::$machineId) {
$machineid = self::$machineId;
} else {
$machineid = str_pad(decbin(self::$machineId), 10, "0", STR_PAD_LEFT);
}
// 序列数 12字节
$random = str_pad(decbin(mt_rand(0, self::max12bit)), 12, "0", STR_PAD_LEFT);
// 拼接
$base = $base . $machineid . $random;
// 转化为 十进制 返回
return bindec($base);
}
}
// SnowFlake::machineId("1"); //机器编号
// echo SnowFlake::createOnlyId();//分布式id
<?php
/**
* 分布式 id 生成类 组成: <毫秒级时间戳+机器id+序列号>
* 默认情况下41bit的时间戳可以支持该算法使用到2082年10bit的工作机器id可以支持1023台机器序列号支持1毫秒产生4095个自增序列id
* @author zhangqi
* @link https://www.cnblogs.com/njccqx/p/13402169.html
*/
class SnowFlake
{
const EPOCH = 1479533469598; //开始时间,固定一个小于当前时间的毫秒数
const max12bit = 4095;
const max41bit = 1099511627775;
static $machineId = 1; // 机器id
public static function machineId($mId = 0)
{
self::$machineId = $mId;
}
public static function createOnlyId()
{
// 时间戳 42字节
$time = floor(microtime(true) * 1000);
// 当前时间 与 开始时间 差值
$time -= self::EPOCH;
// 二进制的 毫秒级时间戳
$base = decbin(self::max41bit + $time);
// 机器id 10 字节
if (!self::$machineId) {
$machineid = self::$machineId;
} else {
$machineid = str_pad(decbin(self::$machineId), 10, "0", STR_PAD_LEFT);
}
// 序列数 12字节
$random = str_pad(decbin(mt_rand(0, self::max12bit)), 12, "0", STR_PAD_LEFT);
// 拼接
$base = $base . $machineid . $random;
// 转化为 十进制 返回
return bindec($base);
}
}
// SnowFlake::machineId("1"); //机器编号
// echo SnowFlake::createOnlyId();//分布式id

0
application/class.thumb.php → app/class.thumb.php Executable file → Normal file
View File

0
application/class.upload.php → app/class.upload.php Executable file → Normal file
View File

172
application/class.version.php → app/class.version.php Executable file → Normal file
View File

@ -1,87 +1,87 @@
<?php
/**
* @author Icret
* 获取GitHub最新版本号
* EasyImage2.0 简单图床 创建时间: 2021-5-10 14:17:25
* 修改时间: 2023-02-10 11:23:30
* @param int 864000 10天的unix时间,既每隔十天获取一次版本
*/
error_reporting(0); // 关闭所有PHP错误报告
class getVersion
{
private $url;
private $dir; //文件所在文件夹
private $filePath; //文件绝对路径
private $fileName; //文件名称
private $fileModifiTime; // 文件最后修改时间
private $time; // 当前时间
public function __construct($url)
{
$this->url = $url;
$this->dir = __DIR__ . '/../admin/logs/version/';
$this->fileName = 'version.json';
$this->filePath = $this->dir . $this->fileName;
$this->fileModifiTime = filemtime($this->filePath);
$this->time = time();
}
public function readJson($name = 'tag_name')
{
if (is_file($this->filePath)) {
if ($this->time - $this->fileModifiTime > 864000) {
$this->downJson();
} else {
$file = fopen($this->filePath, 'r');
$test = fread($file, filesize($this->filePath));
$version = json_decode($test, true);
return $version[$name];
fclose($file);
}
} else {
$this->downJson();
}
}
public function downJson()
{
if (!is_dir($this->dir)) {
mkdir($this->dir, 0755, true);
}
$version = $this->geturl($this->url);
$version = json_decode($version, true);
$file = fopen($this->filePath, 'w+');
fwrite($file, $version);
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_TIMEOUT_MS, 666); // 超时时间
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 getVersion($url);
echo $test->readJson();
<?php
/**
* @author Icret
* 获取GitHub最新版本号
* EasyImage2.0 简单图床 创建时间: 2021-5-10 14:17:25
* 修改时间: 2023-02-10 11:23:30
* @param int 864000 10天的unix时间,既每隔十天获取一次版本
*/
error_reporting(0); // 关闭所有PHP错误报告
class getVersion
{
private $url;
private $dir; //文件所在文件夹
private $filePath; //文件绝对路径
private $fileName; //文件名称
private $fileModifiTime; // 文件最后修改时间
private $time; // 当前时间
public function __construct($url)
{
$this->url = $url;
$this->dir = __DIR__ . '/../admin/logs/version/';
$this->fileName = 'version.json';
$this->filePath = $this->dir . $this->fileName;
$this->fileModifiTime = filemtime($this->filePath);
$this->time = time();
}
public function readJson($name = 'tag_name')
{
if (is_file($this->filePath)) {
if ($this->time - $this->fileModifiTime > 864000) {
$this->downJson();
} else {
$file = fopen($this->filePath, 'r');
$test = fread($file, filesize($this->filePath));
$version = json_decode($test, true);
return $version[$name];
fclose($file);
}
} else {
$this->downJson();
}
}
public function downJson()
{
if (!is_dir($this->dir)) {
mkdir($this->dir, 0755, true);
}
$version = $this->geturl($this->url);
$version = json_decode($version, true);
$file = fopen($this->filePath, 'w+');
fwrite($file, $version);
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_TIMEOUT_MS, 666); // 超时时间
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 getVersion($url);
echo $test->readJson();
*/

View File

@ -1,123 +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','.webp'); // 如果目标图片名有后缀就用目标图片扩展名 后缀,如果没有,则用源图的扩展名
$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);
}
}
<?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','.webp'); // 如果目标图片名有后缀就用目标图片扩展名 后缀,如果没有,则用源图的扩展名
$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);
}
}

View File

@ -1,76 +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;
}
}
<?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;
}
}

View File

@ -1,54 +1,54 @@
<?php
/**
* 压缩文件函数调用位置
*/
require_once __DIR__ . '/../function.php';
require_once APP_ROOT . '/application/compress/Imagick/class.Imgcompress.php';
require_once APP_ROOT . '/application/compress/TinyImg/TinyImg.php';
require_once APP_ROOT . '/config/api_key.php';
/**
* @param string $floder 文件夹
* @param string 压缩方式Imgcompress / TinyPng
*/
function compress($floder, $type = 'Imgcompress', $source = '')
{
global $config;
ini_set('max_execution_time', '0'); // 脚本运行的时间以秒为单位0不限制
if ($type == 'Imgcompress') {
$pic = getFile($floder); // 文件夹路径
$percent = $config['compress_ratio'] / 100; // 压缩率
foreach ($pic as $value) {
$boxImg = $floder . $value;
// 跳过动态图片
if (!isGifAnimated($boxImg)) {
$img = new Imgcompress($boxImg, $percent);
$img->compressImg($boxImg);
echo '<pre>' . $boxImg . '</pre><br />';
// 释放
ob_flush();
}
}
}
if ($type == 'TinyPng') {
if (empty($config['TinyPng_key'])) {
exit('请先申请TinyPng key并保存再试!');
}
$folder = '..' . $config['path'] . $source;
$tinyImg = new TinyImg();
$key = $config['TinyPng_key'];
$input = $folder; //这个文件夹下的文件会被压缩
$output = $folder; //压缩的结果会被保存到这个文件夹中
$tinyImg->compressImgsFolder($key, $input, $output);
}
}
/* Test
$floder = 'D:/phpStudy/WWW/i/2021/05/09/';
compress($floder, 'TinyImg');
echo 666;
<?php
/**
* 压缩文件函数调用位置
*/
require_once __DIR__ . '/../function.php';
require_once APP_ROOT . '/app/compress/Imagick/class.Imgcompress.php';
require_once APP_ROOT . '/app/compress/TinyImg/TinyImg.php';
require_once APP_ROOT . '/config/api_key.php';
/**
* @param string $floder 文件夹
* @param string 压缩方式Imgcompress / TinyPng
*/
function compress($floder, $type = 'Imgcompress', $source = '')
{
global $config;
ini_set('max_execution_time', '0'); // 脚本运行的时间以秒为单位0不限制
if ($type == 'Imgcompress') {
$pic = getFile($floder); // 文件夹路径
$percent = $config['compress_ratio'] / 100; // 压缩率
foreach ($pic as $value) {
$boxImg = $floder . $value;
// 跳过动态图片
if (!isGifAnimated($boxImg)) {
$img = new Imgcompress($boxImg, $percent);
$img->compressImg($boxImg);
echo '<pre>' . $boxImg . '</pre><br />';
// 释放
ob_flush();
}
}
}
if ($type == 'TinyPng') {
if (empty($config['TinyPng_key'])) {
exit('请先申请TinyPng key并保存再试!');
}
$folder = '..' . $config['path'] . $source;
$tinyImg = new TinyImg();
$key = $config['TinyPng_key'];
$input = $folder; //这个文件夹下的文件会被压缩
$output = $folder; //压缩的结果会被保存到这个文件夹中
$tinyImg->compressImgsFolder($key, $input, $output);
}
}
/* Test
$floder = 'D:/phpStudy/WWW/i/2021/05/09/';
compress($floder, 'TinyImg');
echo 666;
*/

138
application/compressing.php → app/compressing.php Executable file → Normal file
View File

@ -1,69 +1,69 @@
<?php
/**
* 压缩状态页面
*/
require_once 'header.php';
require_once APP_ROOT . '/application/compress/function.compress.php';
// 检测登录
if (!is_who_login('admin')) {
checkLogin();
echo '<div class="alert alert-info">未登陆~~</div>';
exit(require_once APP_ROOT . '/application/footer.php');
}
// 文件夹压缩
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", // 定义颜色主题
icon: "exclamation-sign" // 定义消息图标
}).show();</script>');
}
// 压缩前
$sizeBefor = getDirectorySize($folder);
compress($folder, $type, $source);
echo '
<script> new $.zui.Messager("压缩完毕!", {
type: "success", // 定义颜色主题
icon: "ok-sign" // 定义消息图标
}).show();</script>';
} else {
$folder = 0;
$sizeBefor = 0;
}
// 压缩后
$sizeAfter = getDirectorySize($folder);
?>
<h2 style="text-align:center">压缩完毕</h2>
<h4 style="text-align:center;">压缩前:<font color="red"><?php echo getDistUsed($sizeBefor); ?></font>压缩后:<font color="green"><?php echo getDistUsed($sizeAfter); ?></font>
</h4>
<pre>
无论使用哪种压缩均为不可逆操作,并且非常占用硬件资源。
如机器配置过低可能会导致CPU、内存飙升!
<font color="red">Imgcompress</font> 自带压缩为轻微有损压缩图片 此压缩有可能使图片变大,特别是小图片!也有一定概率改变图片方向。
<font color="red">Imgcompress</font> 对自身机器要求高,如图片过多会导致脚本崩溃或者超时(已经预处理超时和脚本崩溃处理,但是有概率重现)!
<font color="red">TinyPng</font> https://tinify.cn/ 提供的API,需要自行申请,对服务器要求较低,但是对网络要求高!如在国内可能导致非常慢而超时崩溃(已预处理,但是有概率重现)
获取TinyPng key https://tinify.cn/developers 并填入 <font color="red">API 设置->TinyPng Key</font> 文件。
</pre>
<script>
// 更改网页标题
document.title = "图片压缩"
</script>
<?php
/** 底部广告 */
if ($config['ad_bot']) echo $config['ad_bot_info'];
/** 引入底部 */
include APP_ROOT . '/application/footer.php';
<?php
/**
* 压缩状态页面
*/
require_once 'header.php';
require_once APP_ROOT . '/app/compress/function.compress.php';
// 检测登录
if (!is_who_login('admin')) {
checkLogin();
echo '<div class="alert alert-info">未登陆~~</div>';
exit(require_once APP_ROOT . '/app/footer.php');
}
// 文件夹压缩
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", // 定义颜色主题
icon: "exclamation-sign" // 定义消息图标
}).show();</script>');
}
// 压缩前
$sizeBefor = getDirectorySize($folder);
compress($folder, $type, $source);
echo '
<script> new $.zui.Messager("压缩完毕!", {
type: "success", // 定义颜色主题
icon: "ok-sign" // 定义消息图标
}).show();</script>';
} else {
$folder = 0;
$sizeBefor = 0;
}
// 压缩后
$sizeAfter = getDirectorySize($folder);
?>
<h2 style="text-align:center">压缩完毕</h2>
<h4 style="text-align:center;">压缩前:<font color="red"><?php echo getDistUsed($sizeBefor); ?></font>压缩后:<font color="green"><?php echo getDistUsed($sizeAfter); ?></font>
</h4>
<pre>
无论使用哪种压缩均为不可逆操作,并且非常占用硬件资源。
如机器配置过低可能会导致CPU、内存飙升!
<font color="red">Imgcompress</font> 自带压缩为轻微有损压缩图片 此压缩有可能使图片变大,特别是小图片!也有一定概率改变图片方向。
<font color="red">Imgcompress</font> 对自身机器要求高,如图片过多会导致脚本崩溃或者超时(已经预处理超时和脚本崩溃处理,但是有概率重现)!
<font color="red">TinyPng</font> https://tinify.cn/ 提供的API,需要自行申请,对服务器要求较低,但是对网络要求高!如在国内可能导致非常慢而超时崩溃(已预处理,但是有概率重现)
获取TinyPng key https://tinify.cn/developers 并填入 <font color="red">API 设置->TinyPng Key</font> 文件。
</pre>
<script>
// 更改网页标题
document.title = "图片压缩"
</script>
<?php
/** 底部广告 */
if ($config['ad_bot']) echo $config['ad_bot_info'];
/** 引入底部 */
include APP_ROOT . '/app/footer.php';

280
application/del.php → app/del.php Executable file → Normal file
View File

@ -1,142 +1,138 @@
<?php
/**
* 删除文件页面
*/
require_once './header.php';
if (empty($_REQUEST)) {
echo '
<script>
new $.zui.Messager("没有要删除的图片!", {
type: "danger", // 定义颜色主题
icon: "exclamation-sign" // 定义消息图标
}).show();
</script>
';
}
$img = rand_imgurl() . '/public/images/404.png';
if (isset($_GET['url'])) {
$img = strip_tags($_GET['url']);
}
// 解密删除
if (isset($_GET['hash'])) {
$delHash = strip_tags($_GET['hash']);
$delHash = urlHash($delHash, 1);
if ($config['image_recycl']) {
// 如果开启回收站则进入回收站
if (checkImg($delHash, 3, 'recycle/') == true) {
echo '
<script>
new $.zui.Messager("删除成功", {
type: "success", // 定义颜色主题
icon: "ok-sign" // 定义消息图标
}).show();
</script>
';
} else {
echo '
<script>
new $.zui.Messager("文件不存在!", {
type: "danger", // 定义颜色主题
icon: "exclamation-sign" // 定义消息图标
}).show();
</script>
';
}
} else {
// 否则直接删除
getDel($delHash, 'url');
}
// FTP
// any_upload($delHash, null, 'delete');
}
// 检查登录后再处理url删除请求
if (is_who_login('admin')) {
// 广场页面删除
if (isset($_GET['url'])) {
getDel(strip_tags($_GET['url']), 'url');
// FTP
// any_upload(parse_url($_GET['url'])['path'], null, 'delete');
}
// 从管理页面删除
if (isset($_GET['url_admin_inc'])) {
$del_url = strip_tags($_GET['url_admin_inc']);
if ($config['hide_path']) {
$del_url = $config['domain'] . $config['path'] . parse_url($del_url)['path'];
}
getDel($del_url, 'url');
// FTP
// any_upload(parse_url($del_url)['path'], null, 'delete');
}
// 回收
if (isset($_GET['recycle_url'])) {
$recycle_url = strip_tags($_GET['recycle_url']);
$recycle_url = parse_url($recycle_url)['path'];
if (file_exists(APP_ROOT . $recycle_url)) {
checkImg($recycle_url, 3);
echo '
<script>
new $.zui.Messager("已放入回收站!", {
type: "success", // 定义颜色主题
icon: "ok" // 定义消息图标
}).show();
</script>
';
} else {
echo '
<script>
new $.zui.Messager("文件不存在!", {
type: "danger", // 定义颜色主题
icon: "exclamation-sign" // 定义消息图标
}).show();
</script>
';
}
}
} else {
echo '
<script>
new $.zui.Messager("请使用管理员账号登录再删除!", {
type: "danger", // 定义颜色主题
icon: "exclamation-sign" // 定义消息图标
}).show();
// 延时2s跳转
window.setTimeout("window.location=\'/../admin/index.php \'",3000);
</script>
';
}
?>
<div class="col-md-4 col-md-offset-4">
<a href="<?php echo $img; ?>" target="_blank"><img src="<?php echo $img; ?>" alt="简单图床-EasyImage" class="img-thumbnail"></a>
<form class="form-inline" method="get" action="<?php $_SERVER['SCRIPT_NAME']; ?>" id="form" name="delForm" onSubmit="getStr();">
<div class="form-group">
<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-danger">删除</button>
</form>
</div>
<script>
// 修改网页标题
document.title = "删除图片 - <?php echo $config['title']; ?>";
var oBtn = document.getElementById('del');
var oTi = document.getElementById('title');
if ('oninput' in oBtn) {
oBtn.addEventListener("input", getWord, false);
} else {
oBtn.onpropertychange = getWord;
}
function getWord() {
oTi.innerHTML = '<img src="' + oBtn.value + '" width="200" class="img-rounded" /><br />';
}
</script>
<?php require_once APP_ROOT . '/application/footer.php';
<?php
/**
* 删除文件页面
*/
require_once __DIR__ . '/header.php';
if (empty($_REQUEST)) {
echo '
<script>
new $.zui.Messager("没有要删除的图片!", {
type: "danger", // 定义颜色主题
icon: "exclamation-sign" // 定义消息图标
}).show();
</script>
';
}
$img = rand_imgurl() . '/public/images/404.png';
if (isset($_GET['url'])) {
$img = strip_tags($_GET['url']);
}
// 解密删除
if (isset($_GET['hash'])) {
$delHash = $_GET['hash'];
$delHash = urlHash($delHash, 1);
if ($config['image_recycl']) {
// 如果开启回收站则进入回收站
if (checkImg($delHash, 3, 'recycle/') == true) {
echo '
<script>
new $.zui.Messager("删除成功", {
type: "success", // 定义颜色主题
icon: "ok-sign" // 定义消息图标
}).show();
</script>
';
} else {
echo '
<script>
new $.zui.Messager("文件不存在!", {
type: "danger", // 定义颜色主题
icon: "exclamation-sign" // 定义消息图标
}).show();
</script>
';
}
} else {
// 否则直接删除
getDel($delHash, 'url');
}
}
// 检查登录后再处理url删除请求
if (is_who_login('admin')) {
// 广场页面删除
if (isset($_GET['url'])) {
getDel($img, 'url');
}
// 从管理页面删除
if (isset($_GET['url_admin_inc'])) {
$del_url = $_GET['url_admin_inc'];
if ($config['hide_path']) {
$del_url = $config['domain'] . $config['path'] . parse_url($del_url)['path'];
}
getDel($del_url, 'url');
}
// 回收
if (isset($_GET['recycle_url'])) {
$recycle_url = $_GET['recycle_url'];
$recycle_url = parse_url($recycle_url)['path'];
if (file_exists(APP_ROOT . $recycle_url)) {
checkImg($recycle_url, 3);
echo '
<script>
new $.zui.Messager("已放入回收站!", {
type: "success", // 定义颜色主题
icon: "ok" // 定义消息图标
}).show();
</script>
';
} else {
echo '
<script>
new $.zui.Messager("文件不存在!", {
type: "danger", // 定义颜色主题
icon: "exclamation-sign" // 定义消息图标
}).show();
</script>
';
}
}
} else {
if (isset($_GET['url'])) {
echo '
<script>
new $.zui.Messager("请使用管理员账号登录再删除!", {
type: "danger", // 定义颜色主题
icon: "exclamation-sign" // 定义消息图标
}).show();
// 延时2s跳转
window.setTimeout("window.location=\'/../admin/index.php \'",3000);
</script>
';
}
}
?>
<div class="col-md-4 col-md-offset-4">
<a href="<?php echo $img; ?>" target="_blank"><img src="<?php echo $img; ?>" alt="简单图床-EasyImage" class="img-thumbnail"></a>
<form class="form-inline" method="get" action="<?php $_SERVER['SCRIPT_NAME']; ?>" id="form" name="delForm" onSubmit="getStr();">
<div class="form-group">
<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-danger">删除</button>
</form>
</div>
<script>
// 修改网页标题
document.title = "删除图片 - <?php echo $config['title']; ?>";
var oBtn = document.getElementById('del');
var oTi = document.getElementById('title');
if ('oninput' in oBtn) {
oBtn.addEventListener("input", getWord, false);
} else {
oBtn.onpropertychange = getWord;
}
function getWord() {
oTi.innerHTML = '<img src="' + oBtn.value + '" width="200" class="img-rounded" /><br />';
}
</script>
<?php require_once __DIR__ . '/footer.php';

106
application/down.php → app/down.php Executable file → Normal file
View File

@ -1,53 +1,53 @@
<?php
/**
* 下载文件
* https://www.php.cn/php-weizijiaocheng-394566.html
*/
//获取要下载的文件名
require_once __DIR__ . '/function.php';
// 空GET
if (empty($_GET)) {
exit('No file path');
}
// 获取下载路径
if (isset($_GET['dw'])) {
$dw = '../' . $_GET['dw'];
// 检查文件是否存在
if (!is_file($dw)) {
exit('No File');
}
}
// 历史上传记录的路径
if (isset(($_GET['history']))) {
$dw = '../' . $_GET['history'];
if ($config['hide_path']) {
$dw = '../' . $config['path'] . $_GET['history'];
}
}
// 检查文件是否存在
if (!is_file($dw)) {
exit('No File');
}
// 过滤下载非指定上传文件格式
$dw_extension = pathinfo($dw, PATHINFO_EXTENSION);
$filter_extensions = explode(',', $config['extensions']);
// 过滤下载其他格式
$filter_other = array('php', 'json', 'log', 'lock');
// 先过滤后下载
if (in_array($dw_extension, $filter_extensions) && !in_array($dw_extension, $filter_other)) {
//设置头信息
header('Content-Disposition:attachment;filename=' . basename($dw));
header('Content-Length:' . filesize($dw));
//读取文件并写入到输出缓冲
readfile($dw);
exit;
} else {
exit('Downfile Type Error');
}
<?php
/**
* 下载文件
* https://www.php.cn/php-weizijiaocheng-394566.html
*/
//获取要下载的文件名
require_once __DIR__ . '/function.php';
// 空GET
if (empty($_GET)) {
exit('No file path');
}
// 获取下载路径
if (isset($_GET['dw'])) {
$dw = '../' . $_GET['dw'];
// 检查文件是否存在
if (!is_file($dw)) {
exit('No File');
}
}
// 历史上传记录的路径
if (isset(($_GET['history']))) {
$dw = '../' . $_GET['history'];
if ($config['hide_path']) {
$dw = '../' . $config['path'] . $_GET['history'];
}
}
// 检查文件是否存在
if (!is_file($dw)) {
exit('No File');
}
// 过滤下载非指定上传文件格式
$dw_extension = pathinfo($dw, PATHINFO_EXTENSION);
$filter_extensions = explode(',', $config['extensions']);
// 过滤下载其他格式
$filter_other = array('php', 'json', 'log', 'lock');
// 先过滤后下载
if (in_array($dw_extension, $filter_extensions) && !in_array($dw_extension, $filter_other)) {
//设置头信息
header('Content-Disposition:attachment;filename=' . basename($dw));
header('Content-Length:' . filesize($dw));
//读取文件并写入到输出缓冲
readfile($dw);
exit;
} else {
exit('Downfile Type Error');
}

412
application/footer.php → app/footer.php Executable file → Normal file
View File

@ -1,207 +1,207 @@
<?php
/** 禁止直接访问 */
defined('APP_ROOT') ?: exit;
/** 弹窗公告 */
if ($config['notice_status'] > 0) : ?>
<div class="modal fade" id="notice">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
<span aria-hidden="true">x</span>
<span class="sr-only">关闭</span></button>
<p class="modal-title icon icon-bell" style="text-align: center"> 网站公告</p>
</div>
<div class="modal-body">
<?php echo $config['notice']; ?>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-mini btn-primary" data-dismiss="modal">了解</button>
</div>
</div>
</div>
<?php endif; ?>
<!-- 二维码 -->
<div class="modal fade" id="qr">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
<span aria-hidden="true">x</span>
<span class="sr-only">关闭</span></button>
<p class="modal-title icon icon-mobile" style="text-align: center">扫描二维码使用手机上传</p>
</div>
<div class="modal-body">
<p id="qrcode"></p>
</div>
</div>
</div>
</div>
<!-- 占位符 -->
<div class="col-md-12 clo-xs-12" style="margin-bottom: 108px;position:relative;"></div>
<footer class="container text-muted small navbar-fixed-bottom" style="text-align: center;background-color:rgba(255,255,255,0.7);z-index: 0;">
<hr>
<?php /** 页脚自定义代码 */ echo $config['footer']; ?>
<p>
<!-- 页脚信息 -->
<a href="https://github.com/icret/EasyImages2.0" target="_blank" rel="nofollow" data-toggle="tooltip" title="Github">© Since 2018</a>
<a href="https://png.cm/" target="_blank" data-toggle="tooltip" title="EasyImage2.0 简单图床">EasyImage</a>
<a href="/admin/terms.php" target="_blank" data-toggle="tooltip" title="使用协议">DMCA</a>
<!-- 二维码按钮 -->
<a data-toggle="modal" href="#qr"><i class="icon icon-qrcode hidden-xs inline-block" data-toggle="tooltip" title="二维码"></i></a>
<?php /** 暗黑模式 */ if ($config['dark-mode']) : ?>
<a id="dark" data-toggle="tooltip" title="暗黑模式"><i class="icon icon-lightbulb" id="dark_ico"></i></a>
<?php endif; ?>
<?php /**登录与退出 */ if (is_who_login('admin') || is_who_login('guest')) : ?>
<a href="<?php echo $config['domain']; ?>/admin/index.php?login=logout" data-toggle="tooltip" title="退出账号"><i class="icon icon-signout"></i></a>
<?php else : ?>
<a href="<?php echo $config['domain']; ?>/admin/index.php" data-toggle="tooltip" title="账号登录"><i class="icon icon-user"></i></a>
<?php endif; ?>
</p>
</footer>
<link href="<?php static_cdn(); ?>/public/static/nprogress/nprogress.min.css" rel="stylesheet">
<script src="<?php static_cdn(); ?>/public/static/nprogress/nprogress.min.js"></script>
<script src="<?php static_cdn(); ?>/public/static/qrcode/qrcode.min.js"></script>
<script>
// NProgress
NProgress.start();
NProgress.done();
// 导航状态
$('.nav-pills').find('a').each(function() {
// console.log(document.location);
if (this.pathname == document.location.pathname) {
$(this).parent().addClass('active');
}
});
// js 获取当前网址二维码
var qrcode = new QRCode(document.getElementById("qrcode"), {
text: window.location.href,
width: 265,
height: 256,
colorDark: "#353535",
colorLight: "#F1F1F1",
correctLevel: QRCode.CorrectLevel.H
});
// 二维码对话框属性
$('#qr').modal({
moveable: true,
moveable: "inside",
backdrop: true,
show: false,
})
<?php /** 弹窗公告控制 */ if ($config['notice_status'] == 1 && !empty($config['notice'])) : ?>
if (document.cookie.indexOf("noticed=") == -1) {
$('#notice').modal({
backdrop: false,
loadingIcon: "icon-spin",
scrollInside: true,
moveable: "inside",
rememberPos: true,
scrollInside: true
}).on('hidden.zui.modal', function() {
// 只有用户手动关闭才会存储cookie,避免不看公告直接刷新
document.cookie = "noticed = 1";
console.log('网站公告已显示完毕')
})
}
<?php endif; ?>
<?php /** 简繁转换 */ if ($config['language'] == 1) : ?>
$.getScript("<?php static_cdn(); ?>/public/static/i18n/jquery.s2t.js", function() { //加载成功后,并执行回调函数
$('*').s2t();
});
<?php endif; ?>
<?php /** 暗黑模式 */ if ($config['dark-mode']) : ?>
// cookie 操作封装 https://www.jb51.net/article/94456.htm
var cookieUtil = {
// 设置cookie
setItem: function(name, value, days) {
var date = new Date();
date.setDate(date.getDate() + days);
document.cookie = name + '=' + value + ';expires=' + date + ';path=' + '/';
},
// 获取cookie
getItem: function(name) {
var arr = document.cookie.replace(/\s/g, "").split(';');
for (var i = 0; i < arr.length; i++) {
var tempArr = arr[i].split('=');
if (tempArr[0] == name) {
return decodeURIComponent(tempArr[1]);
}
}
return '';
},
// 删除cookie
removeItem: function(name) {
this.setItem(name, '1', -1);
},
// 检查是否含有某cookie
hasItem: function(name) {
return (new RegExp("(?:^|;\\s*)" + encodeURIComponent(name).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=")).test(document.cookie);
},
// 获取全部的cookie列表
getAllItems: function() {
var cookieArr = document.cookie.replace(/((?:^|\s*;)[^\=]+)(?=;|$)|^\s*|\s*(?:\=[^;]*)?(?:\1|$)/g, "").split(/\s*(?:\=[^;]*)?;\s*/);
for (var nIdx = 0; nIdx < cookieArr.length; nIdx++) {
cookieArr[nIdx] = decodeURIComponent(cookieArr[nIdx]);
}
return cookieArr;
}
};
// 暗黑操作
let styleLabel = document.createElement('style');
document.getElementById('dark').onclick = function() {
if (cookieUtil.getItem('dark-mode') == null) {
const style = 'html{filter: invert(80%) hue-rotate(180deg);} img,video {filter: invert(100%) hue-rotate(180deg);}';
styleLabel.appendChild(document.createTextNode(style));
document.head.appendChild(styleLabel);
cookieUtil.setItem('dark-mode', 1, 1);
} else {
if (cookieUtil.getItem('dark-mode') == 1) {
document.head.removeChild(styleLabel);
cookieUtil.setItem('dark-mode', 0, 1);
} else {
const style = 'html{filter: invert(80%) hue-rotate(180deg);} img,video {filter: invert(100%) hue-rotate(180deg);}';
styleLabel.appendChild(document.createTextNode(style));
document.head.appendChild(styleLabel);
cookieUtil.setItem('dark-mode', 1, 1);
}
}
}
if (cookieUtil.getItem('dark-mode') == 1) {
const style = 'html{filter: invert(80%) hue-rotate(180deg);} img,video {filter: invert(100%) hue-rotate(180deg);}';
styleLabel.appendChild(document.createTextNode(style));
document.head.appendChild(styleLabel);
}
if (cookieUtil.getItem('dark-mode') == null) {
document.head.removeChild(styleLabel);
}
<?php endif; ?>
// tips提示
$('[data-toggle="tooltip"]').tooltip({
tipClass: 'tooltip',
placement: 'auto',
html: true,
delay: {
show: 50,
hide: 0.5
}
});
// console
console.log("%cEasyImage <?php echo get_current_version(); ?>", "background: rgba(252,234,187,1);background: -moz-linear-gradient(left, rgba(252,234,187,1) 0%, rgba(175,250,77,1) 12%, rgba(0,247,49,1) 28%, rgba(0,210,247,1) 39%,rgba(0,189,247,1) 51%, rgba(133,108,217,1) 64%, rgba(177,0,247,1) 78%, rgba(247,0,189,1) 87%, rgba(245,22,52,1) 0.5%);background: -webkit-gradient(left top, right top, color-stop(0%, rgba(252,234,187,1)), color-stop(12%, rgba(175,250,77,1)), color-stop(28%, rgba(0,247,49,1)), color-stop(39%, rgba(0,210,247,1)), color-stop(51%, rgba(0,189,247,1)), color-stop(64%, rgba(133,108,217,1)), color-stop(78%, rgba(177,0,247,1)), color-stop(87%, rgba(247,0,189,1)), color-stop(0.5%, rgba(245,22,52,1)));background: -webkit-linear-gradient(left, rgba(252,234,187,1) 0%, rgba(175,250,77,1) 12%, rgba(0,247,49,1) 28%, rgba(0,210,247,1) 39%, rgba(0,189,247,1) 51%, rgba(133,108,217,1) 64%, rgba(177,0,247,1) 78%, rgba(247,0,189,1) 87%, rgba(245,22,52,1) 0.5%);background: -o-linear-gradient(left, rgba(252,234,187,1) 0%, rgba(175,250,77,1) 12%, rgba(0,247,49,1) 28%, rgba(0,210,247,1) 39%, rgba(0,189,247,1) 51%, rgba(133,108,217,1) 64%, rgba(177,0,247,1) 78%, rgba(247,0,189,1) 87%, rgba(245,22,52,1) 0.5%);background: -ms-linear-gradient(left, rgba(252,234,187,1) 0%, rgba(175,250,77,1) 12%, rgba(0,247,49,1) 28%, rgba(0,210,247,1) 39%, rgba(0,189,247,1) 51%, rgba(133,108,217,1) 64%, rgba(177,0,247,1) 78%, rgba(247,0,189,1) 87%, rgba(245,22,52,1) 0.5%);background: linear-gradient(to right, rgba(252,234,187,1) 0%, rgba(175,250,77,1) 12%, rgba(0,247,49,1) 28%, rgba(0,210,247,1) 39%, rgba(0,189,247,1) 51%, rgba(133,108,217,1) 64%, rgba(177,0,247,1) 78%, rgba(247,0,189,1) 87%, rgba(245,22,52,1) 0.5%);filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fceabb', endColorstr='#f51634', GradientType=1 );font-size:2.34em;font-weight:bold")
console.log('%c图床作者及演示网站: https://png.cm\n作为开发者你可以对相应的后台功能进行扩展(增删改相应代码), 但请保留代码中相关来源信息(例如: 本人博客, 邮箱等);\n本程序由 Icret 独自开发并完全开源, 碰到收费发布的请不要轻易付款; 本人仅为程序开源创作, 如非法网站使用与本人无关, 请勿用于非法用途.%c ', 'color: #eaad1a; padding:5px 0; border:1px solid #448ef6; font-size:12px;', '');
</script>
</body>
<?php
/** 禁止直接访问 */
defined('APP_ROOT') ?: exit;
/** 弹窗公告 */
if ($config['notice_status'] > 0) : ?>
<div class="modal fade" id="notice">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
<span aria-hidden="true">x</span>
<span class="sr-only">关闭</span></button>
<p class="modal-title icon icon-bell" style="text-align: center"> 网站公告</p>
</div>
<div class="modal-body">
<?php echo $config['notice']; ?>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-mini btn-primary" data-dismiss="modal">了解</button>
</div>
</div>
</div>
<?php endif; ?>
<!-- 二维码 -->
<div class="modal fade" id="qr">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
<span aria-hidden="true">x</span>
<span class="sr-only">关闭</span></button>
<p class="modal-title icon icon-mobile" style="text-align: center">扫描二维码使用手机上传</p>
</div>
<div class="modal-body">
<p id="qrcode"></p>
</div>
</div>
</div>
</div>
<!-- 占位符 -->
<div class="col-md-12 clo-xs-12" style="margin-bottom: 108px;position:relative;"></div>
<footer class="container text-muted small navbar-fixed-bottom" style="text-align: center;background-color:rgba(255,255,255,0.7);z-index: 0;">
<hr>
<?php /** 页脚自定义代码 */ echo $config['footer']; ?>
<p>
<!-- 页脚信息 -->
<a href="https://github.com/icret/EasyImages2.0" target="_blank" rel="nofollow" data-toggle="tooltip" title="Github">© Since 2018</a>
<a href="https://png.cm/" target="_blank" data-toggle="tooltip" title="EasyImage2.0 简单图床">EasyImage</a>
<a href="/admin/terms.php" target="_blank" data-toggle="tooltip" title="使用协议">DMCA</a>
<!-- 二维码按钮 -->
<a data-toggle="modal" href="#qr"><i class="icon icon-qrcode hidden-xs inline-block" data-toggle="tooltip" title="二维码"></i></a>
<?php /** 暗黑模式 */ if ($config['dark-mode']) : ?>
<a id="dark" data-toggle="tooltip" title="暗黑模式"><i class="icon icon-lightbulb" id="dark_ico"></i></a>
<?php endif; ?>
<?php /**登录与退出 */ if (is_who_login('admin') || is_who_login('guest')) : ?>
<a href="<?php echo $config['domain']; ?>/admin/index.php?login=logout" data-toggle="tooltip" title="退出账号"><i class="icon icon-signout"></i></a>
<?php else : ?>
<a href="<?php echo $config['domain']; ?>/admin/index.php" data-toggle="tooltip" title="账号登录"><i class="icon icon-user"></i></a>
<?php endif; ?>
</p>
</footer>
<link href="<?php static_cdn(); ?>/public/static/nprogress/nprogress.min.css" rel="stylesheet">
<script src="<?php static_cdn(); ?>/public/static/nprogress/nprogress.min.js"></script>
<script src="<?php static_cdn(); ?>/public/static/qrcode/qrcode.min.js"></script>
<script>
// NProgress
NProgress.start();
NProgress.done();
// 导航状态
$('.nav-pills').find('a').each(function() {
// console.log(document.location);
if (this.pathname == document.location.pathname) {
$(this).parent().addClass('active');
}
});
// js 获取当前网址二维码
var qrcode = new QRCode(document.getElementById("qrcode"), {
text: window.location.href,
width: 265,
height: 256,
colorDark: "#353535",
colorLight: "#F1F1F1",
correctLevel: QRCode.CorrectLevel.H
});
// 二维码对话框属性
$('#qr').modal({
moveable: true,
moveable: "inside",
backdrop: true,
show: false,
})
<?php /** 弹窗公告控制 */ if ($config['notice_status'] == 1 && !empty($config['notice'])) : ?>
if (document.cookie.indexOf("noticed=") == -1) {
$('#notice').modal({
backdrop: false,
loadingIcon: "icon-spin",
scrollInside: true,
moveable: "inside",
rememberPos: true,
scrollInside: true
}).on('hidden.zui.modal', function() {
// 只有用户手动关闭才会存储cookie,避免不看公告直接刷新
document.cookie = "noticed = 1";
console.log('网站公告已显示完毕')
})
}
<?php endif; ?>
<?php /** 简繁转换 */ if ($config['language'] == 1) : ?>
$.getScript("<?php static_cdn(); ?>/public/static/i18n/jquery.s2t.js", function() { //加载成功后,并执行回调函数
$('*').s2t();
});
<?php endif; ?>
<?php /** 暗黑模式 */ if ($config['dark-mode']) : ?>
// cookie 操作封装 https://www.jb51.net/article/94456.htm
var cookieUtil = {
// 设置cookie
setItem: function(name, value, days) {
var date = new Date();
date.setDate(date.getDate() + days);
document.cookie = name + '=' + value + ';expires=' + date + ';path=' + '/';
},
// 获取cookie
getItem: function(name) {
var arr = document.cookie.replace(/\s/g, "").split(';');
for (var i = 0; i < arr.length; i++) {
var tempArr = arr[i].split('=');
if (tempArr[0] == name) {
return decodeURIComponent(tempArr[1]);
}
}
return '';
},
// 删除cookie
removeItem: function(name) {
this.setItem(name, '1', -1);
},
// 检查是否含有某cookie
hasItem: function(name) {
return (new RegExp("(?:^|;\\s*)" + encodeURIComponent(name).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=")).test(document.cookie);
},
// 获取全部的cookie列表
getAllItems: function() {
var cookieArr = document.cookie.replace(/((?:^|\s*;)[^\=]+)(?=;|$)|^\s*|\s*(?:\=[^;]*)?(?:\1|$)/g, "").split(/\s*(?:\=[^;]*)?;\s*/);
for (var nIdx = 0; nIdx < cookieArr.length; nIdx++) {
cookieArr[nIdx] = decodeURIComponent(cookieArr[nIdx]);
}
return cookieArr;
}
};
// 暗黑操作
let styleLabel = document.createElement('style');
document.getElementById('dark').onclick = function() {
if (cookieUtil.getItem('dark-mode') == null) {
const style = 'html{filter: invert(80%) hue-rotate(180deg);} img,video {filter: invert(100%) hue-rotate(180deg);}';
styleLabel.appendChild(document.createTextNode(style));
document.head.appendChild(styleLabel);
cookieUtil.setItem('dark-mode', 1, 1);
} else {
if (cookieUtil.getItem('dark-mode') == 1) {
document.head.removeChild(styleLabel);
cookieUtil.setItem('dark-mode', 0, 1);
} else {
const style = 'html{filter: invert(80%) hue-rotate(180deg);} img,video {filter: invert(100%) hue-rotate(180deg);}';
styleLabel.appendChild(document.createTextNode(style));
document.head.appendChild(styleLabel);
cookieUtil.setItem('dark-mode', 1, 1);
}
}
}
if (cookieUtil.getItem('dark-mode') == 1) {
const style = 'html{filter: invert(80%) hue-rotate(180deg);} img,video {filter: invert(100%) hue-rotate(180deg);}';
styleLabel.appendChild(document.createTextNode(style));
document.head.appendChild(styleLabel);
}
if (cookieUtil.getItem('dark-mode') == null) {
document.head.removeChild(styleLabel);
}
<?php endif; ?>
// tips提示
$('[data-toggle="tooltip"]').tooltip({
tipClass: 'tooltip',
placement: 'auto',
html: true,
delay: {
show: 50,
hide: 0.5
}
});
// console
console.log("%cEasyImage <?php echo get_current_version(); ?>", "background: rgba(252,234,187,1);background: -moz-linear-gradient(left, rgba(252,234,187,1) 0%, rgba(175,250,77,1) 12%, rgba(0,247,49,1) 28%, rgba(0,210,247,1) 39%,rgba(0,189,247,1) 51%, rgba(133,108,217,1) 64%, rgba(177,0,247,1) 78%, rgba(247,0,189,1) 87%, rgba(245,22,52,1) 0.5%);background: -webkit-gradient(left top, right top, color-stop(0%, rgba(252,234,187,1)), color-stop(12%, rgba(175,250,77,1)), color-stop(28%, rgba(0,247,49,1)), color-stop(39%, rgba(0,210,247,1)), color-stop(51%, rgba(0,189,247,1)), color-stop(64%, rgba(133,108,217,1)), color-stop(78%, rgba(177,0,247,1)), color-stop(87%, rgba(247,0,189,1)), color-stop(0.5%, rgba(245,22,52,1)));background: -webkit-linear-gradient(left, rgba(252,234,187,1) 0%, rgba(175,250,77,1) 12%, rgba(0,247,49,1) 28%, rgba(0,210,247,1) 39%, rgba(0,189,247,1) 51%, rgba(133,108,217,1) 64%, rgba(177,0,247,1) 78%, rgba(247,0,189,1) 87%, rgba(245,22,52,1) 0.5%);background: -o-linear-gradient(left, rgba(252,234,187,1) 0%, rgba(175,250,77,1) 12%, rgba(0,247,49,1) 28%, rgba(0,210,247,1) 39%, rgba(0,189,247,1) 51%, rgba(133,108,217,1) 64%, rgba(177,0,247,1) 78%, rgba(247,0,189,1) 87%, rgba(245,22,52,1) 0.5%);background: -ms-linear-gradient(left, rgba(252,234,187,1) 0%, rgba(175,250,77,1) 12%, rgba(0,247,49,1) 28%, rgba(0,210,247,1) 39%, rgba(0,189,247,1) 51%, rgba(133,108,217,1) 64%, rgba(177,0,247,1) 78%, rgba(247,0,189,1) 87%, rgba(245,22,52,1) 0.5%);background: linear-gradient(to right, rgba(252,234,187,1) 0%, rgba(175,250,77,1) 12%, rgba(0,247,49,1) 28%, rgba(0,210,247,1) 39%, rgba(0,189,247,1) 51%, rgba(133,108,217,1) 64%, rgba(177,0,247,1) 78%, rgba(247,0,189,1) 87%, rgba(245,22,52,1) 0.5%);filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fceabb', endColorstr='#f51634', GradientType=1 );font-size:2.34em;font-weight:bold")
console.log('%c图床作者及演示网站: https://png.cm\n作为开发者你可以对相应的后台功能进行扩展(增删改相应代码), 但请保留代码中相关来源信息(例如: 本人博客, 邮箱等);\n本程序由 Icret 独自开发并完全开源, 碰到收费发布的请不要轻易付款; 本人仅为程序开源创作, 如非法网站使用与本人无关, 请勿用于非法用途.%c ', 'color: #eaad1a; padding:5px 0; border:1px solid #448ef6; font-size:12px;', '');
</script>
</body>
</html>

3521
application/function.php → app/function.php Executable file → Normal file

File diff suppressed because it is too large Load Diff

116
application/header.php → app/header.php Executable file → Normal file
View File

@ -1,59 +1,59 @@
<!DOCTYPE html>
<html lang="zh-cn">
<?php require_once __DIR__ . '/function.php'; ?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="renderer" content="webkit" />
<meta name="force-rendering" content="webkit" />
<meta name="author" content="Icret EasyImage2.0">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?php echo $config['title']; ?></title>
<meta name="keywords" content="<?php echo $config['keywords']; ?>" />
<meta name="description" content="<?php echo $config['description']; ?>" />
<link rel="shortcut icon" href="<?php static_cdn(); ?>/favicon.ico" type="image/x-icon" />
<link href="<?php static_cdn(); ?>/public/static/zui/css/zui.min.css" rel="stylesheet">
<link href="<?php static_cdn(); ?>/public/static/zui/theme/zui-theme-<?php echo $config['theme']; ?>.css" rel="stylesheet">
<script src="<?php static_cdn(); ?>/public/static/zui/lib/jquery/jquery-3.6.0.min.js"></script>
<script src="<?php static_cdn(); ?>/public/static/zui/js/zui.min.js"></script>
<!--[if lt IE 9]>
<script src="<?php static_cdn(); ?>/public/static/zui/lib/ieonly/html5shiv.js"></script>
<script src="<?php static_cdn(); ?>/public/static/zui/lib/ieonly/respond.js"></script>
<script src="<?php static_cdn(); ?>/public/static/zui/lib/ieonly/excanvas.js"></script>
<![endif]-->
<?php /** 页头自定义代码 */ echo $config['customize']; ?>
</head>
<body class="container">
<div class="page-header">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse-EasyImage">
<span class="icon icon-bars"></span>
</button>
</div>
<div class="collapse navbar-collapse navbar-collapse-EasyImage">
<ul class="nav nav-pills">
<li><a href="<?php echo $config['domain']; ?>"><i class="icon icon-home"></i> 首页</a></li>
<?php /** 非管理或未开启不显示广场 */ if ($config['showSwitch'] || is_who_login('admin')) : ?>
<li><a href="<?php echo $config['domain']; ?>/application/list.php"><i class="icon icon-th"></i> 广场<span class="label label-badge label-primary"><?php echo get_file_by_glob(APP_ROOT . config_path(), 'number'); ?></span></a></li>
<?php endif; ?>
<?php /** 非管理或未开启不显示上传历史 */ if ($config['history'] || is_who_login('admin')) : ?>
<li><a href="<?php $config['domain']; ?>/application/history.php"><i class="icon icon-history"></i> 历史<span class="label label-badge label-primary"></span></a></li>
<?php endif; ?>
<?php /** 非管理不显示设置 */ if (is_who_login('admin')) : ?>
<li><a href="<?php echo $config['domain']; ?>/admin/admin.inc.php"><i class="icon icon-cogs"></i> 设置</a></li>
<?php endif; ?>
<?php /** 非管理或未开启不显示统计 */ if ($config['chart_on'] && is_who_login('admin')) : ?>
<li><a href="<?php echo $config['domain']; ?>/admin/chart.php"><i class="icon icon-pie-chart"></i> 统计</a></li>
<?php endif; ?>
<?php /** 账号登录 */ if (is_who_login('status')) : ?>
<!-- 右侧的导航项目 -->
<li class="nav navbar-nav navbar-right hidden-xs"><a href="<?php echo $config['domain']; ?>/admin/index.php?login=logout">您好:<?php echo json_decode($_COOKIE['auth'])[0]; ?> <i class="icon icon-signout"></i></a></li>
<?php else : ?>
<li class="nav navbar-nav navbar-right hidden-xs"><a href="<?php echo $config['domain']; ?>/admin/index.php"><i class="icon icon-user"> 登录</i></a></li>
<?php endif; ?>
</ul>
</div>
</div>
<!DOCTYPE html>
<html lang="zh-cn">
<?php require_once __DIR__ . '/function.php'; ?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="renderer" content="webkit" />
<meta name="force-rendering" content="webkit" />
<meta name="author" content="Icret EasyImage2.0">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?php echo $config['title']; ?></title>
<meta name="keywords" content="<?php echo $config['keywords']; ?>" />
<meta name="description" content="<?php echo $config['description']; ?>" />
<link rel="shortcut icon" href="<?php static_cdn(); ?>/favicon.ico" type="image/x-icon" />
<link href="<?php static_cdn(); ?>/public/static/zui/css/zui.min.css" rel="stylesheet">
<link href="<?php static_cdn(); ?>/public/static/zui/theme/zui-theme-<?php echo $config['theme']; ?>.css" rel="stylesheet">
<script src="<?php static_cdn(); ?>/public/static/zui/lib/jquery/jquery-3.6.0.min.js"></script>
<script src="<?php static_cdn(); ?>/public/static/zui/js/zui.min.js"></script>
<!--[if lt IE 9]>
<script src="<?php static_cdn(); ?>/public/static/zui/lib/ieonly/html5shiv.js"></script>
<script src="<?php static_cdn(); ?>/public/static/zui/lib/ieonly/respond.js"></script>
<script src="<?php static_cdn(); ?>/public/static/zui/lib/ieonly/excanvas.js"></script>
<![endif]-->
<?php /** 页头自定义代码 */ echo $config['customize']; ?>
</head>
<body class="container">
<div class="page-header">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse-EasyImage">
<span class="icon icon-bars"></span>
</button>
</div>
<div class="collapse navbar-collapse navbar-collapse-EasyImage">
<ul class="nav nav-pills">
<li><a href="<?php echo $config['domain']; ?>"><i class="icon icon-home"></i> 首页</a></li>
<?php /** 非管理或未开启不显示广场 */ if ($config['showSwitch'] || is_who_login('admin')) : ?>
<li><a href="<?php echo $config['domain']; ?>/app/list.php"><i class="icon icon-th"></i> 广场<span class="label label-badge label-primary"><?php echo get_file_by_glob(APP_ROOT . config_path(), 'number'); ?></span></a></li>
<?php endif; ?>
<?php /** 非管理或未开启不显示上传历史 */ if ($config['history'] || is_who_login('admin')) : ?>
<li><a href="<?php $config['domain']; ?>/app/history.php"><i class="icon icon-history"></i> 历史<span class="label label-badge label-primary"></span></a></li>
<?php endif; ?>
<?php /** 非管理不显示设置 */ if (is_who_login('admin')) : ?>
<li><a href="<?php echo $config['domain']; ?>/admin/admin.inc.php"><i class="icon icon-cogs"></i> 设置</a></li>
<?php endif; ?>
<?php /** 非管理或未开启不显示统计 */ if ($config['chart_on'] && is_who_login('admin')) : ?>
<li><a href="<?php echo $config['domain']; ?>/admin/chart.php"><i class="icon icon-pie-chart"></i> 统计</a></li>
<?php endif; ?>
<?php /** 账号登录 */ if (is_who_login('status')) : ?>
<!-- 右侧的导航项目 -->
<li class="nav navbar-nav navbar-right hidden-xs"><a href="<?php echo $config['domain']; ?>/admin/index.php?login=logout">您好:<?php echo json_decode($_COOKIE['auth'])[0]; ?> <i class="icon icon-signout"></i></a></li>
<?php else : ?>
<li class="nav navbar-nav navbar-right hidden-xs"><a href="<?php echo $config['domain']; ?>/admin/index.php"><i class="icon icon-user"> 登录</i></a></li>
<?php endif; ?>
</ul>
</div>
</div>
<!-- 顶部导航栏END -->

66
application/hide.php → app/hide.php Executable file → Normal file
View File

@ -1,33 +1,33 @@
<?php
/**
* Program: EasyImage2.0
* Author: Icret
* Date: 2022/3/13 20:11
* For: 源图保护解密
*/
require_once __DIR__ . '/function.php';
if (isset($_GET['key'])) {
$hide_original = $_GET['key'];
$real_path = APP_ROOT . urlHash($hide_original, 1, crc32($config['hide_key']));
} else {
$real_path = APP_ROOT . '/public/images/404.png';
}
// 文件不存在
if (!is_file($real_path)) {
$real_path = APP_ROOT . '/public/images/404.png';
}
// 获取文件后缀
$ex = pathinfo($real_path, PATHINFO_EXTENSION);
// 设置头
header("Content-Type: image/" . $ex . ";text/html; charset=utf-8");
//输出文件
echo file_get_contents($real_path);
exit;
<?php
/**
* Program: EasyImage2.0
* Author: Icret
* Date: 2022/3/13 20:11
* For: 源图保护解密
*/
require_once __DIR__ . '/function.php';
if (isset($_GET['key'])) {
$hide_original = $_GET['key'];
$real_path = APP_ROOT . urlHash($hide_original, 1, crc32($config['hide_key']));
} else {
$real_path = APP_ROOT . '/public/images/404.png';
}
// 文件不存在
if (!is_file($real_path)) {
$real_path = APP_ROOT . '/public/images/404.png';
}
// 获取文件后缀
$ex = pathinfo($real_path, PATHINFO_EXTENSION);
// 设置头
header("Content-Type: image/" . $ex . ";text/html; charset=utf-8");
//输出文件
echo file_get_contents($real_path);
exit;

View File

@ -93,4 +93,4 @@ include_once __DIR__ . "/header.php";
</script>
<?php
/** 引入底部 */
require_once APP_ROOT . '/application/footer.php';
require_once __DIR__ . '/footer.php';

650
application/info.php → app/info.php Executable file → Normal file
View File

@ -1,325 +1,325 @@
<?php
include_once __DIR__ . "/header.php";
if (!$config['show_exif_info'] && !is_who_login('admin')) exit(header('Location: ' . $config['domain'] . '?exif#closed'));
// 获取图片地址
if (isset($_GET['img'])) {
// 过滤特殊符号
$getIMG = strip_tags($_GET['img']);
$del_url = $config['domain'] . $getIMG;
} elseif (isset($_GET['history'])) {
// 过滤特殊符号
if ($config['hide_path']) {
$getIMG = $config['path'] . ltrim(strip_tags($_GET['history']), '/');
} else {
$getIMG = strip_tags($_GET['history']);
}
$del_url = $config['domain'] . $getIMG;
} else {
// 未获取到图片地址
$getIMG = "/public/images/404.png";
$del_url = "#";
}
// 开启隐藏上传目录
if ($config['hide_path']) {
$img_url = rand_imgurl() . str_replace($config['path'], '/', $getIMG);
// 获取当前图片日志文件
$logs = str_replace('/', '-', substr(parse_url($img_url, PHP_URL_PATH), 1, 7));
} else {
// 关闭隐藏上传目录
$img_url = rand_imgurl() . $getIMG;
// 获取当前图片日志文件
$logs = str_replace('/', '-', substr(str_replace($config['path'], '', parse_url($img_url, PHP_URL_PATH)), 0, 7));
}
// 导入日志文件
$logsName = basename($img_url);
if (is_file(APP_ROOT . '/admin/logs/upload/' . $logs . '.php')) {
include APP_ROOT . '/admin/logs/upload/' . $logs . '.php';
} else {
$logs = array($logsName => array('source' => '日志文件不存在, 请在图床安全中开启上传日志!', 'date' => '日志文件不存在, 请在图床安全中开启上传日志!', 'ip' => '0.0.0.0', 'port' => '0', 'user_agent' => '日志文件不存在, 请在图床安全中开启上传日志!', 'path' => '日志文件不存在, 请在图床安全中开启上传日志!', 'size' => '日志文件不存在, 请在图床安全中开启上传日志!', 'md5' => '日志文件不存在, 请在图床安全中开启上传日志!', 'checkImg' => '日志文件不存在, 请在图床安全中开启上传日志!', 'from' => '日志文件不存在, 请在图床安全中开启上传日志!'));
}
if (empty($logs[$logsName])) {
$logs = array($logsName => array('source' => '日志不存在', 'date' => '日志不存在', 'ip' => '0.0.0.0', 'port' => '0', 'user_agent' => '日志不存在', 'path' => '日志不存在', 'size' => '日志不存在', 'md5' => '日志不存在', 'checkImg' => '日志不存在', 'from' => '日志不存在'));
}
// 图片真实路径
$imgABPath = APP_ROOT . $getIMG;
// 图片是否存在
if (!is_file($imgABPath)) {
$imgABPath = APP_ROOT . "/public/images/404.png";
$img_url = $config['domain'] . "/public/images/404.png";
}
// 图片尺寸
$imgSize = filesize($imgABPath);
// 上传时间
$upTime = filemtime($imgABPath);
// 广告
if ($config['ad_top']) echo $config['ad_top_info'];
?>
<div class="col-md-12">
<div class="col-md-5" style="text-align: center;">
<img data-toggle="lightbox" src="<?php echo $img_url; ?>" id="img1" class="img-rounded" height="432px" data-caption="<?php echo pathinfo($img_url, PATHINFO_FILENAME); ?>的详细信息" alt="<?php echo $img_url; ?>" />
</div>
<div class="col-md-6 table-responsive table-condensed" style="margin-top: 10px;">
<table class="table table-hover table-striped table-bordered text-nowrap">
<tbody>
<tr>
<td>图片名称</td>
<td> <?php echo basename($getIMG); ?></td>
</tr>
<tr>
<td>图片大小</td>
<td><?php echo getDistUsed($imgSize); ?></td>
</tr>
<tr>
<td>图片类型</td>
<td>image/<?php echo pathinfo($getIMG, PATHINFO_EXTENSION); ?></td>
</tr>
<tr>
<td>图片宽高</td>
<td><span id="wh"></span>px</td>
</tr>
<tr>
<td>上传时间</td>
<td><?php echo $logs[$logsName]['date']; ?></td>
</tr>
<?php if (is_who_login('admin')) : ?>
<tr class="text-primary">
<td>原始名称</td>
<td><?php echo $logs[$logsName]['source']; ?></td>
</tr>
<tr class="text-primary">
<td>原始大小</td>
<td><?php echo $logs[$logsName]['size']; ?></td>
</tr>
<tr class="text-primary">
<td>上传者IP</td>
<td><?php echo $logs[$logsName]['ip'] . ':' . $logs[$logsName]['port']; ?></td>
</tr>
<tr class="text-primary">
<td>上传地址</td>
<td><?php echo Ip2Region($logs[$logsName]['ip']); ?></td>
</tr>
<tr class="text-primary">
<td>监黄状态</td>
<td><?php echo strstr('OFF', $logs[$logsName]['checkImg']) ? '未开启' : '已通过'; ?></td>
</tr>
<tr class="text-primary">
<td>上传方式</td>
<td><?php echo is_numeric($logs[$logsName]['from']) ? '通过API | Token ID: ' . $logs[$logsName]['from'] : "通过网页"; ?></td>
</tr>
<tr class="text-primary">
<td>文件路径</td>
<td><?php echo $logs[$logsName]['path']; ?></td>
</tr>
<tr class="text-primary">
<td>文件MD5</td>
<td><?php echo $logs[$logsName]['md5']; ?></td>
</tr>
<?php endif; ?>
<tr>
<td>文件操作</td>
<td>
<a class="btn btn-mini btn-primary" href="<?php echo $img_url; ?>" target="_blank"><i class="icon icon-picture"> 查看</i></a>
<a class="btn btn-mini btn-primary" href="" onclick="window.location.replace;"><i class="icon icon-spin icon-refresh"></i> 刷新</a>
<a class="btn btn-mini btn-primary" href="/application/down.php?dw=<?php echo $getIMG; ?>" target="_blank"><i class="icon icon-cloud-download"> 下载</i></a>
<?php if (!empty($config['report']) && !is_who_login('admin')) : ?>
<a class="btn btn-mini btn-warning" href="<?php echo $config['report'] . '?Website1=' . $img_url; ?>" target="_blank"><i class="icon icon-question-sign"> 举报</i></a>
<?php endif; ?>
<?php if (is_who_login('admin')) : ?>
<a class="btn btn-mini btn-warning" href="/application/del.php?recycle_url=<?php echo $getIMG; ?>" target="_blank"><i class="icon icon-undo"> 回收</i></a>
<a class="btn btn-mini btn-warning" href="/application/del.php?url=<?php echo $del_url; ?>" target="_blank"><i class="icon icon-trash"> 删除</i></a>
<?php endif; ?>
</td>
</tr>
</tbody>
</table>
<h4 class="with-padding hl-gray"><i class="icon icon-info-sign"> 此图片来自网友上传, 不代表<a href="/admin/terms.php" target="_blank">本站立场</a>, 若有侵权, 请举报或联系管理员!</i></h4>
</div>
</div>
<div class="col-md-12" style="padding-bottom: 10px;">
<div class="col-md-6" style="padding-bottom: 10px;">
<div class="input-group">
<span class="input-group-addon"><i class="icon icon-link"></i> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
<input type="text" class="form-control" id="links" onclick="copyText()" value="<?php echo $img_url; ?>">
<span class="input-group-btn"><button class="btn btn-default copyBtn1" type="button">复制</button></span>
</div>
</div>
<div class="col-md-6" style="padding-bottom: 10px;">
<div class="input-group">
<span class="input-group-addon"><i class="icon icon-chat"></i> 论坛代码&nbsp;&nbsp;&nbsp;</span>
<input type="text" class="form-control" id="bbscode" value="[img]<?php echo $img_url; ?>[/img]">
<span class="input-group-btn"><button class="btn btn-default copyBtn2" type="button">复制</button></span>
</div>
</div>
</div>
<div class="col-md-12" style="padding-bottom: 10px;">
<div class="col-md-6" style="padding-bottom: 10px;">
<div class="input-group">
<span class="input-group-addon"><i class="icon icon-code"></i> MarkDown</span>
<input type="text" class="form-control" id="markdown" value="![简单图床 - EasyImage](<?php echo $img_url; ?>)">
<span class="input-group-btn"><button class="btn btn-default copyBtn3" type="button">复制</button></span>
</div>
</div>
<div class="col-md-6" style="padding-bottom: 10px;">
<div class="input-group">
<span class="input-group-addon"><i class="icon icon-html5"></i> HTML&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
<input type="text" class="form-control" id="html" value='<img src="<?php echo $img_url; ?>" alt="简单图床 - EasyImage" />'>
<span class="input-group-btn"><button class="btn btn-default copyBtn4" type="button">复制</button></span>
</div>
</div>
</div>
<?php /** 底部广告 */ if ($config['ad_bot']) echo $config['ad_bot_info']; ?>
<!-- 随机图片 -->
<?php if ($config['info_rand_pic']) : ?>
<div class="col-md-12" style="padding-bottom: 10px;">
<h4 class="header-dividing">当月随机图片:</h4>
<div class="cards cards-borderless">
<?php if ($logs[$logsName]['port'] != 0) : for ($i = 0; $i <= 7; $i++) : $randName = array_rand($logs, 1) ?>
<div class="col-md-4 col-sm-6 col-lg-3">
<a class="card" href="?img=<?php echo $logs[$randName]['path']; ?>" target="_blank">
<img src="thumb.php?img=<?php echo $logs[$randName]['path']; ?>">
<div class="caption"><?php echo $logs[$randName]['source']; ?></div>
</a>
</div>
<?php endfor; ?>
<?php else : ?>
<h3 class="alert alert-danger">本月没有上传图片或上传日志不存在~~</h3>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
<script src="<?php static_cdn(); ?>/public/static/EasyImage.js"></script>
<script src="<?php static_cdn(); ?>/public/static/zui/lib/clipboard/clipboard.min.js"></script>
<script>
// 获取图片长宽 https://www.cnblogs.com/houxianzhou/p/14807983.html
var imgReady = (function() {
var list = [],
intervalId = null,
// 用来执行队列
tick = function() {
var i = 0;
for (; i < list.length; i++) {
list[i].end ? list.splice(i--, 1) : list[i]();
};
!list.length && stop();
},
// 停止所有定时器队列
stop = function() {
clearInterval(intervalId);
intervalId = null;
};
return function(url, ready, load, error) {
var onready, width, height, newWidth, newHeight,
img = new Image();
img.src = url;
// 如果图片被缓存,则直接返回缓存数据
if (img.complete) {
ready.call(img);
load && load.call(img);
return;
};
width = img.width;
height = img.height;
// 加载错误后的事件
img.onerror = function() {
error && error.call(img);
onready.end = true;
img = img.onload = img.onerror = null;
};
// 图片尺寸就绪
onready = function() {
newWidth = img.width;
newHeight = img.height;
if (newWidth !== width || newHeight !== height || newWidth * newHeight > 1024) {
// 如果图片已经在其他地方加载可使用面积检测
ready.call(img);
onready.end = true;
};
};
onready();
// 完全加载完毕的事件
img.onload = function() {
// onload在定时器时间差范围内可能比onready快
// 这里进行检查并保证onready优先执行
!onready.end && onready();
load && load.call(img);
// IE gif动画会循环执行onload置空onload即可
img = img.onload = img.onerror = null;
};
// 加入队列中定期执行
if (!onready.end) {
list.push(onready);
// 无论何时只允许出现一个定时器,减少浏览器性能损耗
if (intervalId === null) intervalId = setInterval(tick, 40);
};
};
})();
imgReady('<?php echo $img_url; ?>', function() {
// alert('size ready: width=' + this.width + '; height=' + this.height);
var hw = document.getElementById("wh");
hw.innerHTML = this.width + "x" + this.height
});
// Exif信息
/*
window.onload = getExif;
function getExif() {
var img1 = document.getElementById("img1");
EXIF.getData(img1, function() {
var make = EXIF.getTag(this, "Make");
var model = EXIF.getTag(this, "Model");
var makeAndModel = document.getElementById("makeAndModel");
makeAndModel.innerHTML = `${make} ${model}`;
});
var img2 = document.getElementById("img1");
EXIF.getData(img2, function() {
var allMetaData = EXIF.getAllTags(this);
var allMetaDataSpan = document.getElementById("allMetaDataSpan");
allMetaDataSpan.innerHTML = EXIF.pretty(this);;
});
}
*/
//禁用右键
document.onkeydown = function() {
var e = window.event || arguments[0];
if (e.keyCode == 123) {
// alert('禁止F12');
return false;
} else if ((e.ctrlKey) && (e.shiftKey) && (e.keyCode == 73)) {
// alert('禁止Ctrl+Shift+I');
return false;
} else if ((e.ctrlKey) && (e.keyCode == 85)) {
// alert('禁止Ctrl+u');
return false;
} else if ((e.ctrlKey) && (e.keyCode == 83)) {
// alert('禁止Ctrl+s');
return false;
}
}
// 屏蔽鼠标右键
document.oncontextmenu = function() {
new $.zui.Messager("正在查看图片详细信息", {
type: "success", // 定义颜色主题
icon: "exclamation-sign" // 定义消息图标
}).show();
return false;
}
// 更改网页标题
document.title = "图片<?php echo basename($getIMG); ?>的详细信息 - <?php echo $config['title']; ?>"
</script>
<?php
/** 引入底部 */
require_once APP_ROOT . '/application/footer.php';
<?php
include_once __DIR__ . "/header.php";
if (!$config['show_exif_info'] && !is_who_login('admin')) exit(header('Location: ' . $config['domain'] . '?exif#closed'));
// 获取图片地址
if (isset($_GET['img'])) {
// 过滤特殊符号
$getIMG = strip_tags($_GET['img']);
$del_url = $config['domain'] . $getIMG;
} elseif (isset($_GET['history'])) {
// 过滤特殊符号
if ($config['hide_path']) {
$getIMG = $config['path'] . ltrim(strip_tags($_GET['history']), '/');
} else {
$getIMG = strip_tags($_GET['history']);
}
$del_url = $config['domain'] . $getIMG;
} else {
// 未获取到图片地址
$getIMG = "/public/images/404.png";
$del_url = "#";
}
// 开启隐藏上传目录
if ($config['hide_path']) {
$img_url = rand_imgurl() . str_replace($config['path'], '/', $getIMG);
// 获取当前图片日志文件
$logs = str_replace('/', '-', substr(parse_url($img_url, PHP_URL_PATH), 1, 7));
} else {
// 关闭隐藏上传目录
$img_url = rand_imgurl() . $getIMG;
// 获取当前图片日志文件
$logs = str_replace('/', '-', substr(str_replace($config['path'], '', parse_url($img_url, PHP_URL_PATH)), 0, 7));
}
// 导入日志文件
$logsName = basename($img_url);
if (is_file(APP_ROOT . '/admin/logs/upload/' . $logs . '.php')) {
include APP_ROOT . '/admin/logs/upload/' . $logs . '.php';
} else {
$logs = array($logsName => array('source' => '请在图床安全中开启上传日志!', 'date' => '请在图床安全中开启上传日志!', 'ip' => '0.0.0.0', 'port' => '0', 'user_agent' => '请在图床安全中开启上传日志!', 'path' => '请在图床安全中开启上传日志!', 'size' => '请在图床安全中开启上传日志!', 'md5' => '请在图床安全中开启上传日志!', 'checkImg' => '请在图床安全中开启上传日志!', 'from' => '请在图床安全中开启上传日志!'));
}
if (empty($logs[$logsName])) {
$logs = array($logsName => array('source' => '日志不存在', 'date' => '日志不存在', 'ip' => '0.0.0.0', 'port' => '0', 'user_agent' => '日志不存在', 'path' => '日志不存在', 'size' => '日志不存在', 'md5' => '日志不存在', 'checkImg' => '日志不存在', 'from' => '日志不存在'));
}
// 图片真实路径
$imgABPath = APP_ROOT . $getIMG;
// 图片是否存在
if (!is_file($imgABPath)) {
$imgABPath = APP_ROOT . "/public/images/404.png";
$img_url = $config['domain'] . "/public/images/404.png";
}
// 图片尺寸
$imgSize = filesize($imgABPath);
// 上传时间
$upTime = filemtime($imgABPath);
// 广告
if ($config['ad_top']) echo $config['ad_top_info'];
?>
<div class="col-md-12">
<div class="col-md-5" style="text-align: center;">
<img data-toggle="lightbox" src="<?php echo $img_url; ?>" id="img1" class="img-rounded" height="432px" data-caption="<?php echo pathinfo($img_url, PATHINFO_FILENAME); ?>的详细信息" alt="<?php echo $img_url; ?>" />
</div>
<div class="col-md-6 table-responsive table-condensed" style="margin-top: 10px;">
<table class="table table-hover table-striped table-bordered text-nowrap">
<tbody>
<tr>
<td>图片名称</td>
<td> <?php echo basename($getIMG); ?></td>
</tr>
<tr>
<td>图片大小</td>
<td><?php echo getDistUsed($imgSize); ?></td>
</tr>
<tr>
<td>图片类型</td>
<td>image/<?php echo pathinfo($getIMG, PATHINFO_EXTENSION); ?></td>
</tr>
<tr>
<td>图片宽高</td>
<td><span id="wh"></span>px</td>
</tr>
<tr>
<td>上传时间</td>
<td><?php echo $logs[$logsName]['date']; ?></td>
</tr>
<?php if (is_who_login('admin')) : ?>
<tr class="text-primary">
<td>原始名称</td>
<td><?php echo $logs[$logsName]['source']; ?></td>
</tr>
<tr class="text-primary">
<td>原始大小</td>
<td><?php echo $logs[$logsName]['size']; ?></td>
</tr>
<tr class="text-primary">
<td>上传者IP</td>
<td><?php echo $logs[$logsName]['ip'] . ':' . $logs[$logsName]['port']; ?></td>
</tr>
<tr class="text-primary">
<td>上传地址</td>
<td><?php echo Ip2Region($logs[$logsName]['ip']); ?></td>
</tr>
<tr class="text-primary">
<td>监黄状态</td>
<td><?php echo strstr('OFF', $logs[$logsName]['checkImg']) ? '未开启' : '已通过'; ?></td>
</tr>
<tr class="text-primary">
<td>上传方式</td>
<td><?php echo is_numeric($logs[$logsName]['from']) ? '通过API | Token ID: ' . $logs[$logsName]['from'] : "通过网页"; ?></td>
</tr>
<tr class="text-primary">
<td>文件路径</td>
<td><?php echo $logs[$logsName]['path']; ?></td>
</tr>
<tr class="text-primary">
<td>文件MD5</td>
<td><?php echo $logs[$logsName]['md5']; ?></td>
</tr>
<?php endif; ?>
<tr>
<td>文件操作</td>
<td>
<a class="btn btn-mini btn-primary" href="<?php echo $img_url; ?>" target="_blank"><i class="icon icon-picture"> 查看</i></a>
<a class="btn btn-mini btn-primary" href="" onclick="window.location.replace;"><i class="icon icon-spin icon-refresh"></i> 刷新</a>
<a class="btn btn-mini btn-primary" href="/app/down.php?dw=<?php echo $getIMG; ?>" target="_blank"><i class="icon icon-cloud-download"> 下载</i></a>
<?php if (!empty($config['report']) && !is_who_login('admin')) : ?>
<a class="btn btn-mini btn-warning" href="<?php echo $config['report'] . '?Website1=' . $img_url; ?>" target="_blank"><i class="icon icon-question-sign"> 举报</i></a>
<?php endif; ?>
<?php if (is_who_login('admin')) : ?>
<a class="btn btn-mini btn-warning" href="/app/del.php?recycle_url=<?php echo $getIMG; ?>" target="_blank"><i class="icon icon-undo"> 回收</i></a>
<a class="btn btn-mini btn-warning" href="/app/del.php?url=<?php echo $del_url; ?>" target="_blank"><i class="icon icon-trash"> 删除</i></a>
<?php endif; ?>
</td>
</tr>
</tbody>
</table>
<h4 class="with-padding hl-gray"><i class="icon icon-info-sign"> 此图片来自网友上传, 不代表<a href="/admin/terms.php" target="_blank">本站立场</a>, 若有侵权, 请举报或联系管理员!</i></h4>
</div>
</div>
<div class="col-md-12" style="padding-bottom: 10px;">
<div class="col-md-6" style="padding-bottom: 10px;">
<div class="input-group">
<span class="input-group-addon"><i class="icon icon-link"></i> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
<input type="text" class="form-control" id="links" onclick="copyText()" value="<?php echo $img_url; ?>">
<span class="input-group-btn"><button class="btn btn-default copyBtn1" type="button">复制</button></span>
</div>
</div>
<div class="col-md-6" style="padding-bottom: 10px;">
<div class="input-group">
<span class="input-group-addon"><i class="icon icon-chat"></i> 论坛代码&nbsp;&nbsp;&nbsp;</span>
<input type="text" class="form-control" id="bbscode" value="[img]<?php echo $img_url; ?>[/img]">
<span class="input-group-btn"><button class="btn btn-default copyBtn2" type="button">复制</button></span>
</div>
</div>
</div>
<div class="col-md-12" style="padding-bottom: 10px;">
<div class="col-md-6" style="padding-bottom: 10px;">
<div class="input-group">
<span class="input-group-addon"><i class="icon icon-code"></i> MarkDown</span>
<input type="text" class="form-control" id="markdown" value="![简单图床 - EasyImage](<?php echo $img_url; ?>)">
<span class="input-group-btn"><button class="btn btn-default copyBtn3" type="button">复制</button></span>
</div>
</div>
<div class="col-md-6" style="padding-bottom: 10px;">
<div class="input-group">
<span class="input-group-addon"><i class="icon icon-html5"></i> HTML&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
<input type="text" class="form-control" id="html" value='<img src="<?php echo $img_url; ?>" alt="简单图床 - EasyImage" />'>
<span class="input-group-btn"><button class="btn btn-default copyBtn4" type="button">复制</button></span>
</div>
</div>
</div>
<?php /** 底部广告 */ if ($config['ad_bot']) echo $config['ad_bot_info']; ?>
<!-- 随机图片 -->
<?php if ($config['info_rand_pic']) : ?>
<div class="col-md-12" style="padding-bottom: 10px;">
<h4 class="header-dividing">当月随机图片:</h4>
<div class="cards cards-borderless">
<?php if ($logs[$logsName]['port'] != 0) : for ($i = 0; $i <= 7; $i++) : $randName = array_rand($logs, 1) ?>
<div class="col-md-4 col-sm-6 col-lg-3">
<a class="card" href="?img=<?php echo $logs[$randName]['path']; ?>" target="_blank">
<img src="thumb.php?img=<?php echo $logs[$randName]['path']; ?>">
<div class="caption"><?php echo $logs[$randName]['source']; ?></div>
</a>
</div>
<?php endfor; ?>
<?php else : ?>
<h3 class="alert alert-danger">本月没有上传图片或上传日志不存在~~</h3>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
<script src="<?php static_cdn(); ?>/public/static/EasyImage.js"></script>
<script src="<?php static_cdn(); ?>/public/static/zui/lib/clipboard/clipboard.min.js"></script>
<script>
// 获取图片长宽 https://www.cnblogs.com/houxianzhou/p/14807983.html
var imgReady = (function() {
var list = [],
intervalId = null,
// 用来执行队列
tick = function() {
var i = 0;
for (; i < list.length; i++) {
list[i].end ? list.splice(i--, 1) : list[i]();
};
!list.length && stop();
},
// 停止所有定时器队列
stop = function() {
clearInterval(intervalId);
intervalId = null;
};
return function(url, ready, load, error) {
var onready, width, height, newWidth, newHeight,
img = new Image();
img.src = url;
// 如果图片被缓存,则直接返回缓存数据
if (img.complete) {
ready.call(img);
load && load.call(img);
return;
};
width = img.width;
height = img.height;
// 加载错误后的事件
img.onerror = function() {
error && error.call(img);
onready.end = true;
img = img.onload = img.onerror = null;
};
// 图片尺寸就绪
onready = function() {
newWidth = img.width;
newHeight = img.height;
if (newWidth !== width || newHeight !== height || newWidth * newHeight > 1024) {
// 如果图片已经在其他地方加载可使用面积检测
ready.call(img);
onready.end = true;
};
};
onready();
// 完全加载完毕的事件
img.onload = function() {
// onload在定时器时间差范围内可能比onready快
// 这里进行检查并保证onready优先执行
!onready.end && onready();
load && load.call(img);
// IE gif动画会循环执行onload置空onload即可
img = img.onload = img.onerror = null;
};
// 加入队列中定期执行
if (!onready.end) {
list.push(onready);
// 无论何时只允许出现一个定时器,减少浏览器性能损耗
if (intervalId === null) intervalId = setInterval(tick, 40);
};
};
})();
imgReady('<?php echo $img_url; ?>', function() {
// alert('size ready: width=' + this.width + '; height=' + this.height);
var hw = document.getElementById("wh");
hw.innerHTML = this.width + "x" + this.height
});
// Exif信息
/*
window.onload = getExif;
function getExif() {
var img1 = document.getElementById("img1");
EXIF.getData(img1, function() {
var make = EXIF.getTag(this, "Make");
var model = EXIF.getTag(this, "Model");
var makeAndModel = document.getElementById("makeAndModel");
makeAndModel.innerHTML = `${make} ${model}`;
});
var img2 = document.getElementById("img1");
EXIF.getData(img2, function() {
var allMetaData = EXIF.getAllTags(this);
var allMetaDataSpan = document.getElementById("allMetaDataSpan");
allMetaDataSpan.innerHTML = EXIF.pretty(this);;
});
}
*/
//禁用右键
document.onkeydown = function() {
var e = window.event || arguments[0];
if (e.keyCode == 123) {
// alert('禁止F12');
return false;
} else if ((e.ctrlKey) && (e.shiftKey) && (e.keyCode == 73)) {
// alert('禁止Ctrl+Shift+I');
return false;
} else if ((e.ctrlKey) && (e.keyCode == 85)) {
// alert('禁止Ctrl+u');
return false;
} else if ((e.ctrlKey) && (e.keyCode == 83)) {
// alert('禁止Ctrl+s');
return false;
}
}
// 屏蔽鼠标右键
document.oncontextmenu = function() {
new $.zui.Messager("正在查看图片详细信息", {
type: "success", // 定义颜色主题
icon: "exclamation-sign" // 定义消息图标
}).show();
return false;
}
// 更改网页标题
document.title = "图片<?php echo basename($getIMG); ?>的详细信息 - <?php echo $config['title']; ?>"
</script>
<?php
/** 引入底部 */
require_once APP_ROOT . '/app/footer.php';

760
application/list.php → app/list.php Executable file → Normal file
View File

@ -1,380 +1,380 @@
<?php
/** 广场页面 */
require_once __DIR__ . '/header.php';
/** 顶部广告 */
if ($config['ad_top']) echo $config['ad_top_info'];
?>
<div class="row">
<div class="col-md-12">
<?php
if (!$config['showSwitch'] && !is_who_login('admin')) : ?>
<div class="alert alert-info">管理员关闭了预览哦~~</div>
<?php exit(require_once __DIR__ . '/footer.php'); ?>
<?php else :
// $path = isset($_GET['date']) ? $_GET['date'] : date('Y/m/d/'); // 获取指定目录
/* 限制GET浏览日期 有助于防止爬虫*/
$listDate = $config['listDate']; // 配置限制日期
$path = date('Y/m/d/'); // 当前日期
if (isset($_GET['date'])) {
if ($_GET['date'] < date('Y/m/d/', strtotime("- $listDate day"))) { // GET日期小于配置日期时返回当前日期
$path = date('Y/m/d/');
echo '
<script>
new $.zui.Messager("已超出浏览页数, 返回今日上传列表", {
type: "info", // 定义颜色主题
icon: "exclamation-sign" // 定义消息图标
}).show();
</script>';
} else {
$path = $_GET['date']; // 如果不小于则返回当前GET日期
}
}
$path = preg_replace("/^d{4}-d{2}-d{2} d{2}:d{2}:d{2}$/s", "", trim($path)); // 过滤非日期,删除空格
$keyNum = isset($_GET['num']) ? $_GET['num'] : $config['listNumber']; // 获取指定浏览数量
$keyNum = preg_replace("/[\W]/", "", trim($keyNum)); // 过滤非数字,删除空格
// $fileArr = getFile(APP_ROOT . config_path($path)); // 获取当日上传列表
$fileType = isset($_GET['search']) ? '*.' . preg_replace("/[\W]/", "", $_GET['search']) : '*.*'; // 按照图片格式
$fileArr = get_file_by_glob(APP_ROOT . config_path($path) . $fileType, 'list'); // 获取当日上传列表
$allUploud = isset($_GET['date']) ? $_GET['date'] : date('Y/m/d/');
$allUploud = get_file_by_glob(APP_ROOT . $config['path'] . $allUploud, 'number'); // 当前日期全部上传
$httpUrl = array('date' => $path, 'num' => getFileNumber(APP_ROOT . config_path($path))); // 组合url
// 隐藏path目录获取图片复制与原图地址
if ($config['hide_path']) {
$config_path = str_replace($config['path'], '/', config_path($path));
} else {
$config_path = config_path($path);
}
if (empty($fileArr[0])) : ?>
<div class="alert alert-danger">今天还没有上传的图片哟~~ <br />快来上传第一张吧~!</div>
<?php else : ?>
<ul id="viewjs">
<div class="cards listNum">
<?php foreach ($fileArr as $key => $value) {
if ($key < $keyNum) {
$relative_path = config_path($path) . $value; // 相对路径
$imgUrl = $config['domain'] . $relative_path; // 图片地址
$linkUrl = rand_imgurl() . $config_path . $value; // 图片复制与原图地址
?>
<div class="col-lg-3 col-md-4 col-sm-6 col-xs-12">
<div class="card">
<li><img src="<?php static_cdn(); ?>/public/images/loading.svg" data-image="<?php echo creat_thumbnail_by_list($imgUrl); ?>" data-original="<?php echo $imgUrl; ?>" alt="简单图床-EasyImage"></li>
<div class="bottom-bar">
<a href="<?php echo $linkUrl; ?>" target="_blank"><i class="icon icon-picture" data-toggle="tooltip" title="打开" style="margin-left:10px;"></i></a>
<a href="#" class="copy" data-clipboard-text="<?php echo $linkUrl; ?>" data-toggle="tooltip" title="复制链接" style="margin-left:10px;"><i class="icon icon-copy"></i></a>
<?php if ($config['show_exif_info'] || is_who_login('admin')) : ?>
<a href="/application/info.php?img=<?php echo $relative_path; ?>" data-toggle="tooltip" title="详细信息" target="_blank" style="margin-left:10px;"><i class="icon icon-info-sign"></i></a>
<?php endif; ?>
<a href="/application/down.php?dw=<?php echo $relative_path; ?>" data-toggle="tooltip" title="下载文件" target="_blank" style="margin-left:10px;"><i class="icon icon-cloud-download"></i></a>
<?php if (!empty($config['report'])) : ?>
<a href="<?php echo $config['report'] . '?Website1=' . $linkUrl; ?>" target="_blank"><i class="icon icon-question-sign" data-toggle="tooltip" title="举报文件" style="margin-left:10px;"></i></a>
<?php endif; ?>
<?php if (is_who_login('admin')) : ?>
<a href="/application/del.php?recycle_url=<?php echo $relative_path; ?>" target="_blank" data-toggle="tooltip" title="回收文件" style="margin-left:10px;"><i class="icon icon-undo"></i></a>
<a href="/application/del.php?url=<?php echo $relative_path; ?>" target="_blank" data-toggle="tooltip" title="删除文件" style="margin-left:10px;"><i class="icon icon-trash"></i></a>
<label class="text-primary"><input type="checkbox" id="url" name="checkbox" value="<?php echo $relative_path; ?>"> 选择</label>
<?php endif; ?>
</div>
</div>
</div>
<?php
}
}
?>
</div>
</ul>
<?php
endif;
endif;
/** 底部广告 */
if ($config['ad_bot']) echo $config['ad_bot_info']; ?>
</div>
<div class="col-md-12" style="margin-bottom: 5em;">
<hr />
<div class="col-md-8 col-xs-12" style="padding-bottom:5px">
<div class="btn-toolbar">
<div class="btn-group">
<a class="btn btn-danger btn-mini" href="?<?php echo http_build_query($httpUrl); ?>">当前<?php echo $allUploud; ?></a>
<a class="btn btn-primary btn-mini" href="list.php">今日<?php echo get_file_by_glob(APP_ROOT . config_path() . '*.*', 'number'); ?></a>
<a class="btn btn-mini" href="?date=<?php echo date("Y/m/d/", strtotime("-1 day")) ?>">昨日<?php echo get_file_by_glob(APP_ROOT . $config['path'] . date("Y/m/d/", strtotime("-1 day")), 'number'); ?></a>
<?php
// 倒推日期显示上传图片 @param $listDate 配置的倒退日期
for ($x = 2; $x <= $listDate; $x++)
echo '<a class="btn btn-mini hidden-xs inline-block" href="?date=' . date('Y/m/d/', strtotime("-$x day")) . '">' . date('j号', strtotime("-$x day")) . '</a>';
?>
</div>
<?php if (is_who_login('admin')) : ?>
<div class="btn-group">
<a class="btn btn-mini" onclick="opcheckboxed('checkbox', 'checkall')">全选</a>
<a class="btn btn-mini" onclick="opcheckboxed('checkbox', 'reversecheck')">反选</a>
<a class="btn btn-mini" onclick="opcheckboxed('checkbox', 'uncheckall')">取消</a>
<a class="btn btn-mini" onclick="recycle_img()">回收</a>
<a class="btn btn-mini" onclick="delete_img()">删除</a>
</div>
<?php endif; ?>
</div>
</div>
<!-- 按格式 -->
<!-- <div class="row">
<div class="col-md-2 col-xs-6">
<form action="<php echo '?' . http_build_query($httpUrl) . '&'; ?>" method="get">
<div class="input-group">
<select name="search" class="form-control input-sm">
<option value="jpg">JPG</option>
<option value="png">PNG</option>
<option value="gif">Gif</option>
<option value="webp">WEBP</option>
</select>
<span class="input-group-btn">
<input type="submit" value="按格式" class="btn btn-primary input-sm" />
</span>
</div>
</form>
</div> -->
<div class="col-md-2 col-xs-7">
<div class="btn-group">
<a class="btn btn-mini" href="<?php echo '?' . http_build_query($httpUrl) . '&search=jpg'; ?>">JPG</a>
<a class="btn btn-mini" href="<?php echo '?' . http_build_query($httpUrl) . '&search=png'; ?>">PNG</a>
<a class="btn btn-mini" href="<?php echo '?' . http_build_query($httpUrl) . '&search=gif'; ?>">GIF</a>
<a class="btn btn-mini" href="<?php echo '?' . http_build_query($httpUrl) . '&search=webp'; ?>">Webp</a>
</div>
</div>
<!-- 按日期-->
<div class="col-md-2 col-xs-5">
<form action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="get">
<div class="input-group">
<span class="input-group-addon fix-border fix-padding"></span>
<input type="text" class="form-control form-date input-sm" name="date" value="<?php echo date('Y/m/d/'); ?>" readonly="readonly">
<span class="input-group-btn">
<button type="submit" class="btn btn-primary input-sm">按日期</button>
</span>
</div>
</form>
<!-- 返回顶部-->
<div class="btn btn-mini btn-primary btn-back-to-top"><i class="icon icon-arrow-up"></i></div>
</div>
</div>
<link rel="stylesheet" href="<?php static_cdn(); ?>/public/static/EasyImage.css">
<link rel="stylesheet" href="<?php static_cdn(); ?>/public/static/viewjs/viewer.min.css">
<link rel="stylesheet" href="<?php static_cdn(); ?>/public/static/zui/lib/datetimepicker/datetimepicker.min.css">
<link rel="stylesheet" href="<?php static_cdn(); ?>/public/static/zui/lib/bootbox/bootbox.min.css">
<style>
/* 返回顶部 */
.btn-back-to-top {
padding: 0.5rem 1rem;
position: fixed;
right: 2rem;
bottom: 1rem;
z-index: 2;
-webkit-transition: -webkit-transform 0.2s ease;
transition: transform 0.2s ease;
-webkit-transform: translateY(200%);
transform: translateY(200%);
}
.btn-back-to-top.scrolled {
-webkit-transform: translateY(0);
transform: translateY(0);
}
</style>
<script type="application/javascript" src="<?php static_cdn(); ?>/public/static/zui/lib/bootbox/bootbox.min.js"></script>
<script type="application/javascript" src="<?php static_cdn(); ?>/public/static/lazyload/lazyload.min.js"></script>
<script type="application/javascript" src="<?php static_cdn(); ?>/public/static/viewjs/viewer.min.js"></script>
<script type="application/javascript" src="<?php static_cdn(); ?>/public/static/zui/lib/clipboard/clipboard.min.js"></script>
<script type="application/javascript" src="<?php static_cdn(); ?>/public/static/zui/lib/datetimepicker/datetimepicker.min.js"></script>
<script>
// viewjs
new Viewer(document.getElementById('viewjs'), {
url: 'data-original',
});
// 复制url
var clipboard = new Clipboard('.copy');
clipboard.on('success', function(e) {
new $.zui.Messager("复制直链成功", {
type: "success", // 定义颜色主题
icon: "ok-sign" // 定义消息图标
}).show();
});
clipboard.on('error', function(e) {
document.querySelector('.copy');
new $.zui.Messager("复制失败", {
type: "danger", // 定义颜色主题
icon: "exclamation-sign" // 定义消息图标
}).show();
});
// 取消/全选文件
function opcheckboxed(objName, type) {
var objNameList = document.getElementsByName(objName);
if (null != objNameList) {
for (var i = 0; i < objNameList.length; i++) {
if (objNameList[i].checked == true) {
if (type != 'checkall') { // 非全选
objNameList[i].checked = false;
}
} else {
if (type != 'uncheckall') { // 非取消全选
objNameList[i].checked = true;
}
}
}
}
}
// 回收图片
function recycle_img() {
bootbox.confirm({
message: "确认要放入回收站? <br /> 可在可疑图片中恢复!",
buttons: {
confirm: {
label: '确定',
className: 'btn-success'
},
cancel: {
label: '取消',
className: 'btn-danger'
}
},
callback: function(result) {
if (result == true) {
obj = document.getElementsByName("checkbox");
check_val = [];
for (k in obj) {
//判断复选框是否被选中
if (obj[k].checked)
//获取被选中的复选框的值
check_val.push(obj[k].value);
console.log(check_val);
}
$.post("./post_del.php", {
'recycle_url_array': check_val
}, );
new $.zui.Messager("放入回收站成功", {
type: "success", // 定义颜色主题
icon: "ok-sign" // 定义消息图标
}).show();
// 延时2秒刷新
window.setTimeout(function() {
window.location.reload();
}, 1500)
} else {
new $.zui.Messager("取消回收", {
type: "primary", // 定义颜色主题
icon: "info-sign" // 定义消息图标
}).show();
}
console.log('是否回收图片: ' + result);
}
});
}
// 删除图片
function delete_img() {
bootbox.confirm({
message: "确认要删除?<br />* 删除文件夹后将无法恢复!",
buttons: {
confirm: {
label: '确定',
className: 'btn-success'
},
cancel: {
label: '取消',
className: 'btn-danger'
}
},
callback: function(result) {
if (result == true) {
obj = document.getElementsByName("checkbox");
check_val = [];
for (k in obj) {
//判断复选框是否被选中
if (obj[k].checked)
//获取被选中的复选框的值
check_val.push(obj[k].value);
console.log(check_val);
}
$.post("./post_del.php", {
'del_url_array': check_val
},
function(data) {
if (data.search('success') > 0) {
new $.zui.Messager("删除成功", {
type: "success", // 定义颜色主题
icon: "ok-sign" // 定义消息图标
}).show();
// 延时2秒刷新
window.setTimeout(function() {
window.location.reload();
}, 1500)
} else {
new $.zui.Messager("删除失败 请登录后再删除!", {
type: "danger", // 定义颜色主题
icon: "exclamation-sign" // 定义消息图标
}).show();
// 延时2s跳转
window.setTimeout("window.location=\'/../admin/index.php \'", 2000);
}
});
} else {
new $.zui.Messager("取消删除", {
type: "primary", // 定义颜色主题
icon: "info-sign" // 定义消息图标
}).show();
}
console.log('是否删除图片: ' + result);
}
});
}
// 返回顶部
var back_to_top_button = jQuery('.btn-back-to-top');
jQuery(window).scroll(function() {
if (jQuery(this).scrollTop() > 100 && !back_to_top_button.hasClass('scrolled')) {
back_to_top_button.addClass('scrolled');
} else if (jQuery(this).scrollTop() < 100 && back_to_top_button.hasClass('scrolled')) {
back_to_top_button.removeClass('scrolled');
}
});
// 返回顶部
back_to_top_button.click(function() {
jQuery('html, body').animate({
scrollTop: 0
}, 800);
return false;
});
//懒加载
var lazy = new Lazy({
onload: function(elem) {
console.log(elem)
},
delay: 300,
})
// 按日期浏览
$(".form-date").datetimepicker({
weekStart: 1,
todayBtn: 1,
autoclose: 1,
todayHighlight: 1,
startView: 2,
minView: 2,
forceParse: 0,
pickerPosition: "top-right",
format: "yyyy/mm/dd/",
endDate: new Date() // 只能选当前日期之前
});
// 更改网页标题
document.title = "图床广场 - 今日上传<?php echo get_file_by_glob(APP_ROOT . config_path(), 'number'); ?>张 昨日<?php echo get_file_by_glob(APP_ROOT . $config['path'] . date("Y/m/d/", strtotime("-1 day")) . '*.*', 'number'); ?>张 - <?php echo $config['title']; ?>"
</script>
<?php
/** 引入底部 */
require_once APP_ROOT . '/application/footer.php';
<?php
/** 广场页面 */
require_once __DIR__ . '/header.php';
/** 顶部广告 */
if ($config['ad_top']) echo $config['ad_top_info'];
?>
<div class="row">
<div class="col-md-12">
<?php
if (!$config['showSwitch'] && !is_who_login('admin')) : ?>
<div class="alert alert-info">管理员关闭了预览哦~~</div>
<?php exit(require_once __DIR__ . '/footer.php'); ?>
<?php else :
// $path = isset($_GET['date']) ? $_GET['date'] : date('Y/m/d/'); // 获取指定目录
/* 限制GET浏览日期 有助于防止爬虫*/
$listDate = $config['listDate']; // 配置限制日期
$path = date('Y/m/d/'); // 当前日期
if (isset($_GET['date'])) {
if ($_GET['date'] < date('Y/m/d/', strtotime("- $listDate day"))) { // GET日期小于配置日期时返回当前日期
$path = date('Y/m/d/');
echo '
<script>
new $.zui.Messager("已超出浏览页数, 返回今日上传列表", {
type: "info", // 定义颜色主题
icon: "exclamation-sign" // 定义消息图标
}).show();
</script>';
} else {
$path = $_GET['date']; // 如果不小于则返回当前GET日期
}
}
$path = preg_replace("/^d{4}-d{2}-d{2} d{2}:d{2}:d{2}$/s", "", trim($path)); // 过滤非日期,删除空格
$keyNum = isset($_GET['num']) ? $_GET['num'] : $config['listNumber']; // 获取指定浏览数量
$keyNum = preg_replace("/[\W]/", "", trim($keyNum)); // 过滤非数字,删除空格
// $fileArr = getFile(APP_ROOT . config_path($path)); // 获取当日上传列表
$fileType = isset($_GET['search']) ? '*.' . preg_replace("/[\W]/", "", $_GET['search']) : '*.*'; // 按照图片格式
$fileArr = get_file_by_glob(APP_ROOT . config_path($path) . $fileType, 'list'); // 获取当日上传列表
$allUploud = isset($_GET['date']) ? $_GET['date'] : date('Y/m/d/');
$allUploud = get_file_by_glob(APP_ROOT . $config['path'] . $allUploud, 'number'); // 当前日期全部上传
$httpUrl = array('date' => $path, 'num' => getFileNumber(APP_ROOT . config_path($path))); // 组合url
// 隐藏path目录获取图片复制与原图地址
if ($config['hide_path']) {
$config_path = str_replace($config['path'], '/', config_path($path));
} else {
$config_path = config_path($path);
}
if (empty($fileArr[0])) : ?>
<div class="alert alert-danger">今天还没有上传的图片哟~~ <br />快来上传第一张吧~!</div>
<?php else : ?>
<ul id="viewjs">
<div class="cards listNum">
<?php foreach ($fileArr as $key => $value) {
if ($key < $keyNum) {
$relative_path = config_path($path) . $value; // 相对路径
$imgUrl = $config['domain'] . $relative_path; // 图片地址
$linkUrl = rand_imgurl() . $config_path . $value; // 图片复制与原图地址
?>
<div class="col-lg-3 col-md-4 col-sm-6 col-xs-12">
<div class="card">
<li><img src="<?php static_cdn(); ?>/public/images/loading.svg" data-image="<?php echo creat_thumbnail_by_list($imgUrl); ?>" data-original="<?php echo $imgUrl; ?>" alt="简单图床-EasyImage"></li>
<div class="bottom-bar">
<a href="<?php echo $linkUrl; ?>" target="_blank"><i class="icon icon-picture" data-toggle="tooltip" title="打开" style="margin-left:10px;"></i></a>
<a href="#" class="copy" data-clipboard-text="<?php echo $linkUrl; ?>" data-toggle="tooltip" title="复制链接" style="margin-left:10px;"><i class="icon icon-copy"></i></a>
<?php if ($config['show_exif_info'] || is_who_login('admin')) : ?>
<a href="/app/info.php?img=<?php echo $relative_path; ?>" data-toggle="tooltip" title="详细信息" target="_blank" style="margin-left:10px;"><i class="icon icon-info-sign"></i></a>
<?php endif; ?>
<a href="/app/down.php?dw=<?php echo $relative_path; ?>" data-toggle="tooltip" title="下载文件" target="_blank" style="margin-left:10px;"><i class="icon icon-cloud-download"></i></a>
<?php if (!empty($config['report'])) : ?>
<a href="<?php echo $config['report'] . '?Website1=' . $linkUrl; ?>" target="_blank"><i class="icon icon-question-sign" data-toggle="tooltip" title="举报文件" style="margin-left:10px;"></i></a>
<?php endif; ?>
<?php if (is_who_login('admin')) : ?>
<a href="/app/del.php?recycle_url=<?php echo $relative_path; ?>" target="_blank" data-toggle="tooltip" title="回收文件" style="margin-left:10px;"><i class="icon icon-undo"></i></a>
<a href="/app/del.php?url=<?php echo $relative_path; ?>" target="_blank" data-toggle="tooltip" title="删除文件" style="margin-left:10px;"><i class="icon icon-trash"></i></a>
<label class="text-primary"><input type="checkbox" id="url" name="checkbox" value="<?php echo $relative_path; ?>"> 选择</label>
<?php endif; ?>
</div>
</div>
</div>
<?php
}
}
?>
</div>
</ul>
<?php
endif;
endif;
/** 底部广告 */
if ($config['ad_bot']) echo $config['ad_bot_info']; ?>
</div>
<div class="col-md-12" style="margin-bottom: 5em;">
<hr />
<div class="col-md-8 col-xs-12" style="padding-bottom:5px">
<div class="btn-toolbar">
<div class="btn-group">
<a class="btn btn-danger btn-mini" href="?<?php echo http_build_query($httpUrl); ?>">当前<?php echo $allUploud; ?></a>
<a class="btn btn-primary btn-mini" href="list.php">今日<?php echo get_file_by_glob(APP_ROOT . config_path() . '*.*', 'number'); ?></a>
<a class="btn btn-mini" href="?date=<?php echo date("Y/m/d/", strtotime("-1 day")) ?>">昨日<?php echo get_file_by_glob(APP_ROOT . $config['path'] . date("Y/m/d/", strtotime("-1 day")), 'number'); ?></a>
<?php
// 倒推日期显示上传图片 @param $listDate 配置的倒退日期
for ($x = 2; $x <= $listDate; $x++)
echo '<a class="btn btn-mini hidden-xs inline-block" href="?date=' . date('Y/m/d/', strtotime("-$x day")) . '">' . date('j号', strtotime("-$x day")) . '</a>';
?>
</div>
<?php if (is_who_login('admin')) : ?>
<div class="btn-group">
<a class="btn btn-mini" onclick="opcheckboxed('checkbox', 'checkall')">全选</a>
<a class="btn btn-mini" onclick="opcheckboxed('checkbox', 'reversecheck')">反选</a>
<a class="btn btn-mini" onclick="opcheckboxed('checkbox', 'uncheckall')">取消</a>
<a class="btn btn-mini" onclick="recycle_img()">回收</a>
<a class="btn btn-mini" onclick="delete_img()">删除</a>
</div>
<?php endif; ?>
</div>
</div>
<!-- 按格式 -->
<!-- <div class="row">
<div class="col-md-2 col-xs-6">
<form action="<php echo '?' . http_build_query($httpUrl) . '&'; ?>" method="get">
<div class="input-group">
<select name="search" class="form-control input-sm">
<option value="jpg">JPG</option>
<option value="png">PNG</option>
<option value="gif">Gif</option>
<option value="webp">WEBP</option>
</select>
<span class="input-group-btn">
<input type="submit" value="按格式" class="btn btn-primary input-sm" />
</span>
</div>
</form>
</div> -->
<div class="col-md-2 col-xs-7">
<div class="btn-group">
<a class="btn btn-mini" href="<?php echo '?' . http_build_query($httpUrl) . '&search=jpg'; ?>">JPG</a>
<a class="btn btn-mini" href="<?php echo '?' . http_build_query($httpUrl) . '&search=png'; ?>">PNG</a>
<a class="btn btn-mini" href="<?php echo '?' . http_build_query($httpUrl) . '&search=gif'; ?>">GIF</a>
<a class="btn btn-mini" href="<?php echo '?' . http_build_query($httpUrl) . '&search=webp'; ?>">Webp</a>
</div>
</div>
<!-- 按日期-->
<div class="col-md-2 col-xs-5">
<form action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="get">
<div class="input-group">
<span class="input-group-addon fix-border fix-padding"></span>
<input type="text" class="form-control form-date input-sm" name="date" value="<?php echo date('Y/m/d/'); ?>" readonly="readonly">
<span class="input-group-btn">
<button type="submit" class="btn btn-primary input-sm">按日期</button>
</span>
</div>
</form>
<!-- 返回顶部-->
<div class="btn btn-mini btn-primary btn-back-to-top"><i class="icon icon-arrow-up"></i></div>
</div>
</div>
<link rel="stylesheet" href="<?php static_cdn(); ?>/public/static/EasyImage.css">
<link rel="stylesheet" href="<?php static_cdn(); ?>/public/static/viewjs/viewer.min.css">
<link rel="stylesheet" href="<?php static_cdn(); ?>/public/static/zui/lib/datetimepicker/datetimepicker.min.css">
<link rel="stylesheet" href="<?php static_cdn(); ?>/public/static/zui/lib/bootbox/bootbox.min.css">
<style>
/* 返回顶部 */
.btn-back-to-top {
padding: 0.5rem 1rem;
position: fixed;
right: 2rem;
bottom: 1rem;
z-index: 2;
-webkit-transition: -webkit-transform 0.2s ease;
transition: transform 0.2s ease;
-webkit-transform: translateY(200%);
transform: translateY(200%);
}
.btn-back-to-top.scrolled {
-webkit-transform: translateY(0);
transform: translateY(0);
}
</style>
<script type="application/javascript" src="<?php static_cdn(); ?>/public/static/zui/lib/bootbox/bootbox.min.js"></script>
<script type="application/javascript" src="<?php static_cdn(); ?>/public/static/lazyload/lazyload.min.js"></script>
<script type="application/javascript" src="<?php static_cdn(); ?>/public/static/viewjs/viewer.min.js"></script>
<script type="application/javascript" src="<?php static_cdn(); ?>/public/static/zui/lib/clipboard/clipboard.min.js"></script>
<script type="application/javascript" src="<?php static_cdn(); ?>/public/static/zui/lib/datetimepicker/datetimepicker.min.js"></script>
<script>
// viewjs
new Viewer(document.getElementById('viewjs'), {
url: 'data-original',
});
// 复制url
var clipboard = new Clipboard('.copy');
clipboard.on('success', function(e) {
new $.zui.Messager("复制直链成功", {
type: "success", // 定义颜色主题
icon: "ok-sign" // 定义消息图标
}).show();
});
clipboard.on('error', function(e) {
document.querySelector('.copy');
new $.zui.Messager("复制失败", {
type: "danger", // 定义颜色主题
icon: "exclamation-sign" // 定义消息图标
}).show();
});
// 取消/全选文件
function opcheckboxed(objName, type) {
var objNameList = document.getElementsByName(objName);
if (null != objNameList) {
for (var i = 0; i < objNameList.length; i++) {
if (objNameList[i].checked == true) {
if (type != 'checkall') { // 非全选
objNameList[i].checked = false;
}
} else {
if (type != 'uncheckall') { // 非取消全选
objNameList[i].checked = true;
}
}
}
}
}
// 回收图片
function recycle_img() {
bootbox.confirm({
message: "确认要放入回收站? <br /> 可在可疑图片中恢复!",
buttons: {
confirm: {
label: '确定',
className: 'btn-success'
},
cancel: {
label: '取消',
className: 'btn-danger'
}
},
callback: function(result) {
if (result == true) {
obj = document.getElementsByName("checkbox");
check_val = [];
for (k in obj) {
//判断复选框是否被选中
if (obj[k].checked)
//获取被选中的复选框的值
check_val.push(obj[k].value);
console.log(check_val);
}
$.post("./post_del.php", {
'recycle_url_array': check_val
}, );
new $.zui.Messager("放入回收站成功", {
type: "success", // 定义颜色主题
icon: "ok-sign" // 定义消息图标
}).show();
// 延时2秒刷新
window.setTimeout(function() {
window.location.reload();
}, 1500)
} else {
new $.zui.Messager("取消回收", {
type: "primary", // 定义颜色主题
icon: "info-sign" // 定义消息图标
}).show();
}
console.log('是否回收图片: ' + result);
}
});
}
// 删除图片
function delete_img() {
bootbox.confirm({
message: "确认要删除?<br />* 删除文件夹后将无法恢复!",
buttons: {
confirm: {
label: '确定',
className: 'btn-success'
},
cancel: {
label: '取消',
className: 'btn-danger'
}
},
callback: function(result) {
if (result == true) {
obj = document.getElementsByName("checkbox");
check_val = [];
for (k in obj) {
//判断复选框是否被选中
if (obj[k].checked)
//获取被选中的复选框的值
check_val.push(obj[k].value);
console.log(check_val);
}
$.post("./post_del.php", {
'del_url_array': check_val
},
function(data) {
if (data.search('success') > 0) {
new $.zui.Messager("删除成功", {
type: "success", // 定义颜色主题
icon: "ok-sign" // 定义消息图标
}).show();
// 延时2秒刷新
window.setTimeout(function() {
window.location.reload();
}, 1500)
} else {
new $.zui.Messager("删除失败 请登录后再删除!", {
type: "danger", // 定义颜色主题
icon: "exclamation-sign" // 定义消息图标
}).show();
// 延时2s跳转
window.setTimeout("window.location=\'/../admin/index.php \'", 2000);
}
});
} else {
new $.zui.Messager("取消删除", {
type: "primary", // 定义颜色主题
icon: "info-sign" // 定义消息图标
}).show();
}
console.log('是否删除图片: ' + result);
}
});
}
// 返回顶部
var back_to_top_button = jQuery('.btn-back-to-top');
jQuery(window).scroll(function() {
if (jQuery(this).scrollTop() > 100 && !back_to_top_button.hasClass('scrolled')) {
back_to_top_button.addClass('scrolled');
} else if (jQuery(this).scrollTop() < 100 && back_to_top_button.hasClass('scrolled')) {
back_to_top_button.removeClass('scrolled');
}
});
// 返回顶部
back_to_top_button.click(function() {
jQuery('html, body').animate({
scrollTop: 0
}, 800);
return false;
});
//懒加载
var lazy = new Lazy({
onload: function(elem) {
console.log(elem)
},
delay: 300,
})
// 按日期浏览
$(".form-date").datetimepicker({
weekStart: 1,
todayBtn: 1,
autoclose: 1,
todayHighlight: 1,
startView: 2,
minView: 2,
forceParse: 0,
pickerPosition: "top-right",
format: "yyyy/mm/dd/",
endDate: new Date() // 只能选当前日期之前
});
// 更改网页标题
document.title = "图床广场 - 今日上传<?php echo get_file_by_glob(APP_ROOT . config_path(), 'number'); ?>张 昨日<?php echo get_file_by_glob(APP_ROOT . $config['path'] . date("Y/m/d/", strtotime("-1 day")) . '*.*', 'number'); ?>张 - <?php echo $config['title']; ?>"
</script>
<?php
/** 引入底部 */
require_once __DIR__ . '/footer.php';

64
application/post_del.php → app/post_del.php Executable file → Normal file
View File

@ -1,32 +1,32 @@
<?php
/**
* 删除/回收文件页面
* @author Icret
* 2022-2-23 11:01:52
*/
require_once __DIR__ . '/function.php';
if (!is_who_login('admin')) {
exit('Not Logged!');
}
// 删除文件
if (isset($_POST['del_url_array'])) {
$del_url_array = $_POST['del_url_array'];
$del_num = count($del_url_array);
for ($i = 0; $i < $del_num; $i++) {
getDel($del_url_array[$i], 'url');
// FTP
// any_upload($del_url_array[$i], null, 'delete');
}
}
// 回收文件
if (isset($_POST['recycle_url_array'])) {
$recycle_url_array = $_POST['recycle_url_array'];
$del_num = count($recycle_url_array);
for ($i = 0; $i < $del_num; $i++) {
checkImg($recycle_url_array[$i], 3);
}
}
<?php
/**
* 删除/回收文件页面
* @author Icret
* 2022-2-23 11:01:52
*/
require_once __DIR__ . '/function.php';
if (!is_who_login('admin')) {
exit('Not Logged!');
}
// 删除文件
if (isset($_POST['del_url_array'])) {
$del_url_array = $_POST['del_url_array'];
$del_num = count($del_url_array);
for ($i = 0; $i < $del_num; $i++) {
getDel($del_url_array[$i], 'url');
// FTP
// any_upload($del_url_array[$i], null, 'delete');
}
}
// 回收文件
if (isset($_POST['recycle_url_array'])) {
$recycle_url_array = $_POST['recycle_url_array'];
$del_num = count($recycle_url_array);
for ($i = 0; $i < $del_num; $i++) {
checkImg($recycle_url_array[$i], 3);
}
}

View File

@ -10,7 +10,7 @@ if (isset($_POST['md5'])) {
<div class="row">
<div class="col-md-12">
<p class="text-primary">忘记账号可以打开<code>/config/config.php</code>文件找到<code data-toggle="tooltip" title="'user'=><strong>admin</strong>'">user</code>对应的键值->填入</p>
<p class="text-success">忘记密码请将密码转换成SHA256(<a href="<?php echo $config['domain'] . '/application/reset_password.php'; ?>" target="_blank" class="text-purple">转换网址</a>)->打开<code>/config/config.php</code>文件->找到<code data-toggle="tooltip" title="'password'=>'<strong>e6e0612609</strong>'">password</code>对应的键值->填入</p>
<p class="text-success">忘记密码请将密码转换成SHA256(<a href="<?php echo $config['domain'] . '/app/reset_password.php'; ?>" target="_blank" class="text-purple">转换网址</a>)->打开<code>/config/config.php</code>文件->找到<code data-toggle="tooltip" title="'password'=>'<strong>e6e0612609</strong>'">password</code>对应的键值->填入</p>
<h4 class="text-danger">更改后会立即生效并重新登录,请务必牢记账号和密码! </h4>
</div>
<div class="col-md-12">

266
application/thumb.php → app/thumb.php Executable file → Normal file
View File

@ -1,133 +1,133 @@
<?php
/*
// +----------------------------------------------------------------------
// | 把大图缩略到缩略图指定的范围内,不留白(原图会剪切掉不符合比例的右边和下边)
// | https://www.php.cn/php-ask-458473.html
// +----------------------------------------------------------------------
require_once __DIR__ . '/function.php';
require_once __DIR__ . '/class.thumb.php';
$src = isset($_GET['img']) ? APP_ROOT . $_GET['img'] : APP_ROOT . '/public/images/404.png'; // 原图路径
if (!file_exists($src)) {
exit('image does not exist');
}
$w = isset($_GET['width']) ? $_GET['width'] : 258; // 预生成缩略图的宽
$h = isset($_GET['height']) ? $_GET['height'] : 258; // 预生成缩略图的高
Thumb::show($src, $w, $h);
*/
/**
* 使用新的TimThumb.php生成缩略图
* TimThumb.php EasyImage修改版 by Icret
* form https://github.com/podipod/TimThumb
* 2022-1-30 06:35:08
*
* TimThumb参数指南
* 命令 作用 参数 描述
* src 图像URL 告诉TimThumb调整哪个图片
* w 宽度 宽度调整 调整输出图像的宽度
* h 高度 高度调整 调整输出图像的高度
* q 质量 0 - 100 压缩质量值越大质量越高。不建议高于95
* a 对齐 c, t, l, r, b, tl, tr, bl, br 图像对齐。 c = center, t = top, b = bottom, r = right, l = left。 可以创建对角位置
* zc 缩放/裁剪 0、1、2、3 0:根据传入的值进行缩放(不裁剪), 1:以最合适的比例裁剪和调整大小(裁剪), 2按比例调整大小并添加边框裁剪3按比例调整大小不添加边框裁剪
* f 过滤器 太多了 可以改变亮度/对比度;甚至模糊图像
* s 锐化 锐化 使得按比例缩小图片看起来有点;更清晰
* cc 画布上的颜色 十六进制的颜色值(# ffffff) 改变背景颜色。 大多数更改缩放和作物设置时使用,进而可以添加图像边界。
* ct 画布的透明度 true (1) 使用透明而忽略背景颜色
*/
require_once __DIR__ . '/function.php';
// 缓存时间
$cache_freq = $config['cache_freq'] * 60 * 60;
// 中文翻译 https://my.oschina.net/whrlmc/blog/81739
define('LOCAL_FILE_BASE_DIRECTORY', APP_ROOT);
define('MEMORY_LIMIT', '256M');
define('DEFAULT_WIDTH', $config['thumbnail_w']);
define('DEFAULT_HEIGHT', $config['thumbnail_h']);
define('FILE_CACHE_PREFIX', 'EasyImage');
define('DEFAULT_ZC', 0);
define('MAX_WIDTH', 10240);
define('MAX_HEIGHT', 10240);
define('FILE_CACHE_DIRECTORY', APP_ROOT . $config['path'] . 'cache/');
define('NOT_FOUND_IMAGE', $config['domain'] . '/public/images/404.png');
define('ERROR_IMAGE', $config['domain'] . '/public/images/404.png');
define('DISPLAY_ERROR_MESSAGES', false);
define('MAX_FILE_SIZE', $config['maxSize']); // 10 Megs 是 10485760。这是我们将处理的最大内部或外部文件大小。
define('FILE_CACHE_TIME_BETWEEN_CLEANS', $cache_freq); // 多久清理一次缓存
define('FILE_CACHE_MAX_FILE_AGE', $cache_freq); // 文件必须从缓存中删除多长时间
define('BROWSER_CACHE_MAX_AGE', $cache_freq); // 浏览器缓存时间
global $ALLOWED_SITES;
$ALLOWED_SITES = array(
$config['domain'],
$config['imgurl'],
);
/**
* 修复无法生成生成webp动态图片的缩略图bug
*/
if (isset($_GET['img'])) {
// 引入文件
require_once __DIR__ . '/TimThumb.php';
$src = $_GET['img'];
// 重定向不包含存储路径的缩略图地址
if (!stristr($src, $config['path'])) {
$src = $config['path'] . $src;
header("Location:thumb.php?img=$src");
exit();
}
// 图片绝对路径
$src = APP_ROOT . $_GET['img'];
// 获取文件后缀
$ext = pathinfo($src)['extension'];
// 404 文件
$i404 = APP_ROOT . '/public/images/404.png';
// 文件不存在
if (!is_file($src)) {
// 输出404
header("Content-type: image/png");
exit(file_get_contents($i404, true));
}
switch ($ext) {
case 'ico':
header("Content-type: image/jpeg");
exit(file_get_contents($src, true));
break;
case 'svg':
header('Content-Type:image/svg+xml');
exit(file_get_contents($src, true));
break;
case 'webp':
if (isWebpAnimated($src)) {
// 输出动态的webp
header("Content-type: image/webp");
exit(file_get_contents($src, true));
} else {
timthumb::start();
}
break;
default:
timthumb::start();
}
} else {
// 输出404
header("Content-type: image/png");
exit(file_get_contents($i404, true));
}
<?php
/*
// +----------------------------------------------------------------------
// | 把大图缩略到缩略图指定的范围内,不留白(原图会剪切掉不符合比例的右边和下边)
// | https://www.php.cn/php-ask-458473.html
// +----------------------------------------------------------------------
require_once __DIR__ . '/function.php';
require_once __DIR__ . '/class.thumb.php';
$src = isset($_GET['img']) ? APP_ROOT . $_GET['img'] : APP_ROOT . '/public/images/404.png'; // 原图路径
if (!file_exists($src)) {
exit('image does not exist');
}
$w = isset($_GET['width']) ? $_GET['width'] : 258; // 预生成缩略图的宽
$h = isset($_GET['height']) ? $_GET['height'] : 258; // 预生成缩略图的高
Thumb::show($src, $w, $h);
*/
/**
* 使用新的TimThumb.php生成缩略图
* TimThumb.php EasyImage修改版 by Icret
* form https://github.com/podipod/TimThumb
* 2022-1-30 06:35:08
*
* TimThumb参数指南
* 命令 作用 参数 描述
* src 图像URL 告诉TimThumb调整哪个图片
* w 宽度 宽度调整 调整输出图像的宽度
* h 高度 高度调整 调整输出图像的高度
* q 质量 0 - 100 压缩质量值越大质量越高。不建议高于95
* a 对齐 c, t, l, r, b, tl, tr, bl, br 图像对齐。 c = center, t = top, b = bottom, r = right, l = left。 可以创建对角位置
* zc 缩放/裁剪 0、1、2、3 0:根据传入的值进行缩放(不裁剪), 1:以最合适的比例裁剪和调整大小(裁剪), 2按比例调整大小并添加边框裁剪3按比例调整大小不添加边框裁剪
* f 过滤器 太多了 可以改变亮度/对比度;甚至模糊图像
* s 锐化 锐化 使得按比例缩小图片看起来有点;更清晰
* cc 画布上的颜色 十六进制的颜色值(# ffffff) 改变背景颜色。 大多数更改缩放和作物设置时使用,进而可以添加图像边界。
* ct 画布的透明度 true (1) 使用透明而忽略背景颜色
*/
require_once __DIR__ . '/function.php';
// 缓存时间
$cache_freq = $config['cache_freq'] * 60 * 60;
// 中文翻译 https://my.oschina.net/whrlmc/blog/81739
define('LOCAL_FILE_BASE_DIRECTORY', APP_ROOT);
define('MEMORY_LIMIT', '256M');
define('DEFAULT_WIDTH', $config['thumbnail_w']);
define('DEFAULT_HEIGHT', $config['thumbnail_h']);
define('FILE_CACHE_PREFIX', 'EasyImage');
define('DEFAULT_ZC', 0);
define('MAX_WIDTH', 10240);
define('MAX_HEIGHT', 10240);
define('FILE_CACHE_DIRECTORY', APP_ROOT . $config['path'] . 'cache/');
define('NOT_FOUND_IMAGE', $config['domain'] . '/public/images/404.png');
define('ERROR_IMAGE', $config['domain'] . '/public/images/404.png');
define('DISPLAY_ERROR_MESSAGES', false);
define('MAX_FILE_SIZE', $config['maxSize']); // 10 Megs 是 10485760。这是我们将处理的最大内部或外部文件大小。
define('FILE_CACHE_TIME_BETWEEN_CLEANS', $cache_freq); // 多久清理一次缓存
define('FILE_CACHE_MAX_FILE_AGE', $cache_freq); // 文件必须从缓存中删除多长时间
define('BROWSER_CACHE_MAX_AGE', $cache_freq); // 浏览器缓存时间
global $ALLOWED_SITES;
$ALLOWED_SITES = array(
$config['domain'],
$config['imgurl'],
);
/**
* 修复无法生成生成webp动态图片的缩略图bug
*/
if (isset($_GET['img'])) {
// 引入文件
require_once __DIR__ . '/TimThumb.php';
$src = $_GET['img'];
// 重定向不包含存储路径的缩略图地址
if (!stristr($src, $config['path'])) {
$src = $config['path'] . $src;
header("Location:thumb.php?img=$src");
exit();
}
// 图片绝对路径
$src = APP_ROOT . $_GET['img'];
// 获取文件后缀
$ext = pathinfo($src)['extension'];
// 404 文件
$i404 = APP_ROOT . '/public/images/404.png';
// 文件不存在
if (!is_file($src)) {
// 输出404
header("Content-type: image/png");
exit(file_get_contents($i404, true));
}
switch ($ext) {
case 'ico':
header("Content-type: image/jpeg");
exit(file_get_contents($src, true));
break;
case 'svg':
header('Content-Type:image/svg+xml');
exit(file_get_contents($src, true));
break;
case 'webp':
if (isWebpAnimated($src)) {
// 输出动态的webp
header("Content-type: image/webp");
exit(file_get_contents($src, true));
} else {
timthumb::start();
}
break;
default:
timthumb::start();
}
} else {
// 输出404
header("Content-type: image/png");
exit(file_get_contents($i404, true));
}

188
application/total_files.php → app/total_files.php Executable file → Normal file
View File

@ -1,94 +1,94 @@
<?php
/**
* 统计文件
*
* 递归函数实现遍历指定文件下的目录与文件数量
* $dirname=指定目录,$dirnum=目录总数,$filen=文件总数
*/
require_once __DIR__ . '/../config/config.php';
$dirn = 0; //目录数
$filen = 0; //文件数
//用来统计一个目录下的文件和目录的个数
function total_files($file)
{
global $dirn;
global $filen;
$dir = opendir($file);
while ($filename = readdir($dir)) {
if ($filename != "." && $filename != "..") {
$filename = $file . "/" . $filename;
if (is_dir($filename)) {
$dirn++;
total_files($filename); //递归,就可以查看所有子目录
} else {
$filen++;
}
}
}
closedir($dir);
}
$total_file_path = APP_ROOT . $config['path']; // 获取用户自定义的上传目录
$totalJsonMD5 = strval(md5_file(APP_ROOT . '/config/config.php')); // 以config.php文件的md5命名
$totalJsonName = APP_ROOT . "/admin/logs/counts/total-files-$totalJsonMD5.php"; // 文件绝对目录
function creat_json() // 创建json文件
{
global $dirn;
global $filen;
global $totalJsonName;
global $config;
global $total_file_path;
global $totalJsonMD5;
total_files($total_file_path);
$usage_space = getDistUsed(getDirectorySize(APP_ROOT . $config['path']));
$todayUpload = getFileNumber(APP_ROOT . config_path()); // 今日上传数量
$yestUpload = getFileNumber(APP_ROOT . $config['path'] . date("Y/m/d/", strtotime("-1 day"))); // 昨日上传数量
$totalJsonInfo = [
'filename' => $totalJsonMD5, // 统计文件名称
'date' => date('YmdH'), // 识别日期格式
'total_time' => date('Y-m-d H:i:s'), // 统计时间
'dirnum' => $dirn, // 文件夹数量
'filenum' => $filen, // 文件数量
'usage_space' => $usage_space, // 占用空间
'todayUpload' => $todayUpload, // 今日上传数量
'yestUpload' => $yestUpload // 昨日上传数量
];
$totalJsonInfo = json_encode($totalJsonInfo, true);
if (is_dir(APP_ROOT . '/admin/logs/counts/')) {
file_put_contents($totalJsonName, $totalJsonInfo);
} else {
mkdir(APP_ROOT . '/admin/logs/counts/', 0777, true); // 创建cache目录
file_put_contents($totalJsonName, $totalJsonInfo);
}
}
function read_total_json($total) // 读取json文件
{
global $totalJsonFile;
global $totalJsonName;
global $config;
$cache_freq = $config['cache_freq'];
if (file_exists($totalJsonName)) {
$totalJsonFile = file_get_contents($totalJsonName);
$totalJsonFile = json_decode($totalJsonFile, true);
} else {
creat_json();
$totalJsonFile = file_get_contents($totalJsonName);
$totalJsonFile = json_decode($totalJsonFile, true);
}
if ((date('YmdH') - $totalJsonFile['date']) > $cache_freq) {
creat_json();
$totalJsonFile = file_get_contents($totalJsonName);
$totalJsonFile = json_decode($totalJsonFile, true);
}
return $totalJsonFile[$total];
}
<?php
/**
* 统计文件
*
* 递归函数实现遍历指定文件下的目录与文件数量
* $dirname=指定目录,$dirnum=目录总数,$filen=文件总数
*/
require_once __DIR__ . '/../config/config.php';
$dirn = 0; //目录数
$filen = 0; //文件数
//用来统计一个目录下的文件和目录的个数
function total_files($file)
{
global $dirn;
global $filen;
$dir = opendir($file);
while ($filename = readdir($dir)) {
if ($filename != "." && $filename != "..") {
$filename = $file . "/" . $filename;
if (is_dir($filename)) {
$dirn++;
total_files($filename); //递归,就可以查看所有子目录
} else {
$filen++;
}
}
}
closedir($dir);
}
$total_file_path = APP_ROOT . $config['path']; // 获取用户自定义的上传目录
$totalJsonMD5 = strval(md5_file(APP_ROOT . '/config/config.php')); // 以config.php文件的md5命名
$totalJsonName = APP_ROOT . "/admin/logs/counts/total-files-$totalJsonMD5.php"; // 文件绝对目录
function creat_json() // 创建json文件
{
global $dirn;
global $filen;
global $totalJsonName;
global $config;
global $total_file_path;
global $totalJsonMD5;
total_files($total_file_path);
$usage_space = getDistUsed(getDirectorySize(APP_ROOT . $config['path']));
$todayUpload = getFileNumber(APP_ROOT . config_path()); // 今日上传数量
$yestUpload = getFileNumber(APP_ROOT . $config['path'] . date("Y/m/d/", strtotime("-1 day"))); // 昨日上传数量
$totalJsonInfo = [
'filename' => $totalJsonMD5, // 统计文件名称
'date' => date('YmdH'), // 识别日期格式
'total_time' => date('Y-m-d H:i:s'), // 统计时间
'dirnum' => $dirn, // 文件夹数量
'filenum' => $filen, // 文件数量
'usage_space' => $usage_space, // 占用空间
'todayUpload' => $todayUpload, // 今日上传数量
'yestUpload' => $yestUpload // 昨日上传数量
];
$totalJsonInfo = json_encode($totalJsonInfo, true);
if (is_dir(APP_ROOT . '/admin/logs/counts/')) {
file_put_contents($totalJsonName, $totalJsonInfo);
} else {
mkdir(APP_ROOT . '/admin/logs/counts/', 0777, true); // 创建cache目录
file_put_contents($totalJsonName, $totalJsonInfo);
}
}
function read_total_json($total) // 读取json文件
{
global $totalJsonFile;
global $totalJsonName;
global $config;
$cache_freq = $config['cache_freq'];
if (file_exists($totalJsonName)) {
$totalJsonFile = file_get_contents($totalJsonName);
$totalJsonFile = json_decode($totalJsonFile, true);
} else {
creat_json();
$totalJsonFile = file_get_contents($totalJsonName);
$totalJsonFile = json_decode($totalJsonFile, true);
}
if ((date('YmdH') - $totalJsonFile['date']) > $cache_freq) {
creat_json();
$totalJsonFile = file_get_contents($totalJsonName);
$totalJsonFile = json_decode($totalJsonFile, true);
}
return $totalJsonFile[$total];
}

470
application/upload.php → app/upload.php Executable file → Normal file
View File

@ -1,235 +1,235 @@
<?php
namespace Verot\Upload;
require __DIR__ . '/function.php';
require __DIR__ . '/class.upload.php';
// 检查登录
if ($config['mustLogin']) {
if (!is_who_login('status')) {
exit(json_encode(array(
"result" => "failed",
"code" => 401,
"message" => "本站已开启登陆上传,您尚未登陆",
)));
}
}
// 无文件
if (empty($_FILES['file'])) {
exit(json_encode(
array(
"result" => "failed",
"code" => 204,
"message" => "没有选择上传的文件",
)
));
}
// sign
if (empty($_REQUEST['sign']) || $_REQUEST['sign'] !== date('YmdH')) {
exit(json_encode(array(
"result" => "failed",
"code" => 403,
"message" => "签名错误,请刷新重试",
)));
}
// 黑/白IP名单上传
if ($config['check_ip']) {
if (checkIP(null, $config['check_ip_list'], $config['check_ip_model'])) {
// 上传错误 code:403 未授权IP
exit(json_encode(array(
"result" => "failed",
"code" => 403,
"message" => "黑名单内或白名单外用户不允许上传",
)));
}
}
// 根据IP限制游客每日上传数量
if ($config['ip_upload_counts'] > 0 && !is_who_login('status')) {
if (false == get_ip_upload_log_counts(real_ip())) {
exit(json_encode(
array(
"result" => "failed",
"code" => 403,
"message" => sprintf("游客限制每日上传 %d 张", $config['ip_upload_counts']),
)
));
}
}
$handle = new Upload($_FILES['file'], 'zh_CN');
if ($handle->uploaded) {
// 允许上传的mime类型
if ($config['allowed'] === 1) {
$handle->allowed = array('image/*');
}
// 检查svg是否存在script和a标签代码
if ($handle->file_src_name_ext === 'svg') {
$svg = file_get_contents($handle->file_src_pathname);
if (preg_match('/<script[\s\S]*?<\/script>/', $svg) || stripos($svg, 'href=')) {
exit(json_encode(
array(
"result" => "failed",
"code" => 205,
"message" => "请勿上传非法文件",
)
));
}
}
// 文件命名
$handle->file_new_name_body = imgName($handle->file_src_name_body);
// 最大上传限制
$handle->file_max_size = $config['maxSize'];
// 最大宽度
$handle->image_max_width = $config['maxWidth'];
// 最大高度
$handle->image_max_height = $config['maxHeight'];
// 最小宽度
$handle->image_min_width = $config['minWidth'];
// 最小高度
$handle->image_min_height = $config['minHeight'];
// 2023-01-06 转换图片为指定格式 只转换非webp格式和非动态图片
if ($handle->file_src_name_ext !== 'webp' && !isGifAnimated($handle->file_src_pathname)) {
$handle->image_convert = $config['imgConvert'];
}
// 2023-01-06 PNG 图像的压缩级别,介于 1快速但大文件和 9慢但较小文件之间
$handle->png_compression = 9 - round($config['compress_ratio'] / 11.2);
// WEBP 图像的压缩质量 1-100
$handle->webp_quality = $config['compress_ratio'];
// JPEG 图像的压缩质量 1-100
$handle->jpeg_quality = $config['compress_ratio'];
/* 等比例缩减图片 放到前端了*/
/*
if ($config['imgRatio']) {
$handle->image_resize = true;
$handle->image_x = $config['image_x'];
$handle->image_y = $config['image_y'];
// 如果调整后的图像大于原始图像,则取消调整大小,以防止放大
$handle->image_no_enlarging = true;
}
*/
/**
* 为管理员和登陆用户创建自定义上传目录
* 管理员上传目录为自定义目录
* 上传者目录为其用户名
* 2022年5月1日
*/
// 默认目录
$Img_path = config_path();
// 开启管理员自定义目录
if ($config['admin_path_status']) {
if (checkLogin() == 204) {
$Img_path = config_path($config['admin_path'] . date('/Y/m/d/'));
}
}
// 开启上传者单独目录
if ($config['guest_path_status']) {
if (checkLogin() == 205) {
$getCok = json_decode($_COOKIE['auth']);
$Img_path = config_path($getCok[0] . date('/Y/m/d/'));
}
}
// 存储图片路径:i/201807/
$handle->process(APP_ROOT . $Img_path);
// 图片完整相对路径:/i/2021/05/03/k88e7p.jpg
if ($handle->processed) {
header('Content-type:text/json');
// 图片相对路径
$pathIMG = $Img_path . $handle->file_dst_name;
// 图片访问网址
$imageUrl = rand_imgurl() . $pathIMG;
// 后续处理地址
$processUrl = $config['domain'] . $pathIMG;
// 隐藏config文件中的path目录,需要搭配网站设置
if ($config['hide_path'] == 1) {
$imageUrl = str_replace($config['path'], '/', $imageUrl);
}
// 源图保护 key值是由crc32加密的hide_key
// $hide_original = $config['hide'] == 1 ? $config['domain'] . '/application/hide.php?key=' . urlHash($pathIMG, 0, crc32($config['hide_key'])) : $imageUrl;
if ($config['hide'] == 1) {
$imageUrl = $config['domain'] . '/application/hide.php?key=' . urlHash($pathIMG, 0, crc32($config['hide_key']));
}
// 删除文件链接
if ($config['show_user_hash_del']) {
$delUrl = $config['domain'] . '/application/del.php?hash=' . urlHash($pathIMG, 0);
} else {
$delUrl = "Admin closed user delete";
}
// 当设置访问生成缩略图时自动生成 2022-12-30 修正 2023-01-30
$handleThumb = $config['domain'] . '/application/thumb.php?img=' . $pathIMG;
if ($config['thumbnail'] == 2) {
// 自定义缩略图长宽
$handle->image_resize = true;
$handle->image_x = $config['thumbnail_w'];
$handle->image_y = $config['thumbnail_h'];
// 如果调整后的图像大于原始图像,则取消调整大小,以防止放大
$handle->image_no_enlarging = true;
$handle->file_new_name_body = date('Y_m_d_') . $handle->file_dst_name_body;
$handle->process(APP_ROOT . $config['path'] . 'cache/');
$handleThumb = $config['domain'] . $config['path'] . 'cache/' . $handle->file_dst_name;
}
// 上传成功后返回json数据
$reJson = array(
"result" => "success",
"code" => 200,
"url" => $imageUrl,
"srcName" => $handle->file_src_name_body,
"thumb" => $handleThumb,
"del" => $delUrl,
// "memory" => getDistUsed(memory_get_peak_usage()), // 占用内存 2023-02-12
);
echo json_encode($reJson);
$handle->clean(); // 如果取消上传生成缩略图需要恢复此选项功能
} else {
// 上传错误 code:206 客户端文件有问题
$reJson = array(
"result" => "failed",
"code" => 206,
"message" => $handle->error,
"memory" => getDistUsed(memory_get_peak_usage()), // 占用内存 2023-02-12
// 'log' => $handle->log, // 仅用作调试用
);
unset($handle);
header('Content-Type:application/json; charset=utf-8');
exit(json_encode($reJson, JSON_UNESCAPED_UNICODE));
}
/** 后续处理 */
// 使用fastcgi_finish_request操作
if (function_exists('fastcgi_finish_request')) fastcgi_finish_request();
// 同IP上传日志
@write_ip_upload_count_logs();
// 日志
@write_upload_logs($pathIMG, $handle->file_src_name, $handle->file_dst_pathname, $handle->file_src_size);
// 鉴黄
@process_checkImg($processUrl);
// 水印
@water($handle->file_dst_pathname);
// 压缩
@process_compress($handle->file_dst_pathname);
// 上传至其他位置
// @any_upload($pathIMG, APP_ROOT . $pathIMG, 'upload');
unset($handle);
}
<?php
namespace Verot\Upload;
require __DIR__ . '/function.php';
require __DIR__ . '/class.upload.php';
// 检查登录
if ($config['mustLogin']) {
if (!is_who_login('status')) {
exit(json_encode(array(
"result" => "failed",
"code" => 401,
"message" => "本站已开启登陆上传,您尚未登陆",
)));
}
}
// 无文件
if (empty($_FILES['file'])) {
exit(json_encode(
array(
"result" => "failed",
"code" => 204,
"message" => "没有选择上传的文件",
)
));
}
// sign
if (empty($_REQUEST['sign']) || $_REQUEST['sign'] !== date('YmdH')) {
exit(json_encode(array(
"result" => "failed",
"code" => 403,
"message" => "签名错误,请刷新重试",
)));
}
// 黑/白IP名单上传
if ($config['check_ip']) {
if (checkIP(null, $config['check_ip_list'], $config['check_ip_model'])) {
// 上传错误 code:403 未授权IP
exit(json_encode(array(
"result" => "failed",
"code" => 403,
"message" => "黑名单内或白名单外用户不允许上传",
)));
}
}
// 根据IP限制游客每日上传数量
if ($config['ip_upload_counts'] > 0 && !is_who_login('status')) {
if (false == get_ip_upload_log_counts(real_ip())) {
exit(json_encode(
array(
"result" => "failed",
"code" => 403,
"message" => sprintf("游客限制每日上传 %d 张", $config['ip_upload_counts']),
)
));
}
}
$handle = new Upload($_FILES['file'], 'zh_CN');
if ($handle->uploaded) {
// 允许上传的mime类型
if ($config['allowed'] === 1) {
$handle->allowed = array('image/*');
}
// 检查svg是否存在script和a标签代码
if ($handle->file_src_name_ext === 'svg') {
$svg = file_get_contents($handle->file_src_pathname);
if (preg_match('/<script[\s\S]*?<\/script>/', $svg) || stripos($svg, 'href=')) {
exit(json_encode(
array(
"result" => "failed",
"code" => 205,
"message" => "请勿上传非法文件",
)
));
}
}
// 文件命名
$handle->file_new_name_body = imgName($handle->file_src_name_body);
// 最大上传限制
$handle->file_max_size = $config['maxSize'];
// 最大宽度
$handle->image_max_width = $config['maxWidth'];
// 最大高度
$handle->image_max_height = $config['maxHeight'];
// 最小宽度
$handle->image_min_width = $config['minWidth'];
// 最小高度
$handle->image_min_height = $config['minHeight'];
// 2023-01-06 转换图片为指定格式 只转换非webp格式和非动态图片
if ($handle->file_src_name_ext !== 'webp' && !isGifAnimated($handle->file_src_pathname)) {
$handle->image_convert = $config['imgConvert'];
}
// 2023-01-06 PNG 图像的压缩级别,介于 1快速但大文件和 9慢但较小文件之间
$handle->png_compression = 9 - round($config['compress_ratio'] / 11.2);
// WEBP 图像的压缩质量 1-100
$handle->webp_quality = $config['compress_ratio'];
// JPEG 图像的压缩质量 1-100
$handle->jpeg_quality = $config['compress_ratio'];
/* 等比例缩减图片 放到前端了*/
/*
if ($config['imgRatio']) {
$handle->image_resize = true;
$handle->image_x = $config['image_x'];
$handle->image_y = $config['image_y'];
// 如果调整后的图像大于原始图像,则取消调整大小,以防止放大
$handle->image_no_enlarging = true;
}
*/
/**
* 为管理员和登陆用户创建自定义上传目录
* 管理员上传目录为自定义目录
* 上传者目录为其用户名
* 2022年5月1日
*/
// 默认目录
$Img_path = config_path();
// 开启管理员自定义目录
if ($config['admin_path_status']) {
if (checkLogin() == 204) {
$Img_path = config_path($config['admin_path'] . date('/Y/m/d/'));
}
}
// 开启上传者单独目录
if ($config['guest_path_status']) {
if (checkLogin() == 205) {
$getCok = json_decode($_COOKIE['auth']);
$Img_path = config_path($getCok[0] . date('/Y/m/d/'));
}
}
// 存储图片路径:i/201807/
$handle->process(APP_ROOT . $Img_path);
// 图片完整相对路径:/i/2021/05/03/k88e7p.jpg
if ($handle->processed) {
header('Content-type:text/json');
// 图片相对路径
$pathIMG = $Img_path . $handle->file_dst_name;
// 图片访问网址
$imageUrl = rand_imgurl() . $pathIMG;
// 后续处理地址
$processUrl = $config['domain'] . $pathIMG;
// 隐藏config文件中的path目录,需要搭配网站设置
if ($config['hide_path'] == 1) {
$imageUrl = str_replace($config['path'], '/', $imageUrl);
}
// 源图保护 key值是由crc32加密的hide_key
// $hide_original = $config['hide'] == 1 ? $config['domain'] . '/app/hide.php?key=' . urlHash($pathIMG, 0, crc32($config['hide_key'])) : $imageUrl;
if ($config['hide'] == 1) {
$imageUrl = $config['domain'] . '/app/hide.php?key=' . urlHash($pathIMG, 0, crc32($config['hide_key']));
}
// 删除文件链接
if ($config['show_user_hash_del']) {
$delUrl = $config['domain'] . '/app/del.php?hash=' . urlHash($pathIMG, 0);
} else {
$delUrl = "Admin closed user delete";
}
// 当设置访问生成缩略图时自动生成 2022-12-30 修正 2023-01-30
$handleThumb = $config['domain'] . '/app/thumb.php?img=' . $pathIMG;
if ($config['thumbnail'] == 2) {
// 自定义缩略图长宽
$handle->image_resize = true;
$handle->image_x = $config['thumbnail_w'];
$handle->image_y = $config['thumbnail_h'];
// 如果调整后的图像大于原始图像,则取消调整大小,以防止放大
$handle->image_no_enlarging = true;
$handle->file_new_name_body = date('Y_m_d_') . $handle->file_dst_name_body;
$handle->process(APP_ROOT . $config['path'] . 'cache/');
$handleThumb = $config['domain'] . $config['path'] . 'cache/' . $handle->file_dst_name;
}
// 上传成功后返回json数据
$reJson = array(
"result" => "success",
"code" => 200,
"url" => $imageUrl,
"srcName" => $handle->file_src_name_body,
"thumb" => $handleThumb,
"del" => $delUrl,
// "memory" => getDistUsed(memory_get_peak_usage()), // 占用内存 2023-02-12
);
echo json_encode($reJson);
$handle->clean(); // 如果取消上传生成缩略图需要恢复此选项功能
} else {
// 上传错误 code:206 客户端文件有问题
$reJson = array(
"result" => "failed",
"code" => 206,
"message" => $handle->error,
"memory" => getDistUsed(memory_get_peak_usage()), // 占用内存 2023-02-12
// 'log' => $handle->log, // 仅用作调试用
);
unset($handle);
header('Content-Type:application/json; charset=utf-8');
exit(json_encode($reJson, JSON_UNESCAPED_UNICODE));
}
/** 后续处理 */
// 使用fastcgi_finish_request操作
if (function_exists('fastcgi_finish_request')) fastcgi_finish_request();
// 同IP上传日志
@write_ip_upload_count_logs();
// 日志
@write_upload_logs($pathIMG, $handle->file_src_name, $handle->file_dst_pathname, $handle->file_src_size);
// 鉴黄
@process_checkImg($processUrl);
// 水印
@water($handle->file_dst_pathname);
// 压缩
@process_compress($handle->file_dst_pathname);
// 上传至其他位置
// @any_upload($pathIMG, APP_ROOT . $pathIMG, 'upload');
unset($handle);
}

View File

@ -24,7 +24,7 @@ if (isset($_GET['login_log'])) {
}
// 上传日志
require_once APP_ROOT . '/application/header.php';
require_once APP_ROOT . '/app/header.php';
if (isset($_POST['logDate'])) {
$logFile = APP_ROOT . '/admin/logs/upload/' . $_POST['logDate'] . '.php';
@ -43,7 +43,7 @@ try {
}
} catch (Exception $e) {
echo $e->getMessage();
require_once APP_ROOT . '/application/footer.php';
require_once APP_ROOT . '/app/footer.php';
exit;
}
?>
@ -155,7 +155,7 @@ try {
size: '<?php echo $v['size']; ?>',
checkImg: '<?php echo strstr('OFF', $v['checkImg']) ? '' : ''; ?>',
from: '<?php echo is_string($v['from']) ? "网页" : 'API: ' . $v['from']; ?>',
manage: "<div class='btn-group'><a href='<?php echo $config['domain'] . $v['path']; ?>' target='_blank' class='btn btn-mini btn-success'>查看</a> <a href='/application/info.php?img=<?php echo $v['path']; ?>' target='_blank' class='btn btn-mini'>信息</a> <a href='/application/del.php?recycle_url=<?php echo $v['path']; ?>' target='_blank' class='btn btn-mini btn-info'>回收</a> <a href='/application/del.php?url=<?php echo $v['path']; ?>' target='_blank' class='btn btn-mini btn-danger'>删除</a></div>",
manage: "<div class='btn-group'><a href='<?php echo $config['domain'] . $v['path']; ?>' target='_blank' class='btn btn-mini btn-success'>查看</a> <a href='/app/info.php?img=<?php echo $v['path']; ?>' target='_blank' class='btn btn-mini'>信息</a> <a href='/app/del.php?recycle_url=<?php echo $v['path']; ?>' target='_blank' class='btn btn-mini btn-info'>回收</a> <a href='/app/del.php?url=<?php echo $v['path']; ?>' target='_blank' class='btn btn-mini btn-danger'>删除</a></div>",
},
<?php endforeach; ?>
]
@ -191,4 +191,4 @@ try {
document.title = "<?php echo pathinfo($logFile, PATHINFO_FILENAME); ?>月上传日志 - <?php echo $config['title']; ?>"
</script>
<?php
require_once APP_ROOT . '/application/footer.php';
require_once APP_ROOT . '/app/footer.php';

View File

@ -99,7 +99,7 @@ $config=Array
9=>'month'
),
'language'=>0,
'login_bg'=>'../application/bing.php',
'login_bg'=>'../app/bing.php',
'report'=>'',
'image_recycl'=>1,
'tinyfilemanager'=>1,

View File

@ -1,6 +1,7 @@
* 2023-03-06 v2.7.8
- 增加WEB端上传签名
- 修复一处漏洞
- 修改目录命名 `applicaton->app`
- 修复两处漏洞
* 2023-03-05 v2.7.7
- 增加登录日志

View File

@ -7,15 +7,15 @@
session_start();
/**开始 - 自定义修改 */
require_once __DIR__ . '/../application/function.php';
require_once __DIR__ . '/../app/function.php';
require_once APP_ROOT . '/config/config.php';
// 开启tinyfilemanager文件管理
if (!$config['file_manage']) {
require_once APP_ROOT . '/application/header.php';
require_once APP_ROOT . '/app/header.php';
echo '<h4 class="alert alert-danger">文件管理已关闭~~</h4>';
header("refresh:3;url=" . $config['domain'] . '?manag-closed');
require_once APP_ROOT . '/application/footer.php';
require_once APP_ROOT . '/app/footer.php';
exit;
}
@ -215,7 +215,7 @@ class RExplorer
if (RexHelper::file_catetory($srpath) == 'image') {
echo '
<td>
<img data-toggle="lightbox" src="/../application/thumb.php?img=', $srpath, '" data-image="' . $srpath . '" data-caption="查看原图" class="img-thumbnail" alt="查看原图" width="80">
<img data-toggle="lightbox" src="/../app/thumb.php?img=', $srpath, '" data-image="' . $srpath . '" data-caption="查看原图" class="img-thumbnail" alt="查看原图" width="80">
</td>';
} else {
echo '
@ -328,7 +328,7 @@ class RExplorer
return;
case 'image':
echo '
<img data-toggle="lightbox" src="/../application/thumb.php?img=', $path, '" data-image="' . $path . '" data-caption="小图看大图" class="img-thumbnail" alt="" width="200">
<img data-toggle="lightbox" src="/../app/thumb.php?img=', $path, '" data-image="' . $path . '" data-caption="小图看大图" class="img-thumbnail" alt="" width="200">
<div class="card-body">
<a href="', $path, '" target="_blank">查看原图</a>
</div>
@ -1080,8 +1080,8 @@ class ZipHelper
}
/** 环境检测 */
if ($config['checkEnv']) require_once APP_ROOT . '/application/check.php';
if ($config['checkEnv']) require_once APP_ROOT . '/app/check.php';
/** 底部广告 */
if ($config['ad_bot']) echo $config['ad_bot_info'];
/** 引入底部 */
require_once APP_ROOT . '/application/footer.php';
require_once APP_ROOT . '/app/footer.php';

View File

@ -1,5 +1,5 @@
<?php
require_once 'application/header.php';
require_once __DIR__ . '/app/header.php';
/** 顶部广告 */
if ($config['ad_top']) echo $config['ad_top_info'];
/** 检查登陆 */
@ -16,7 +16,7 @@ mustLogin();
</div>
</div>
<?php endif; ?>
<div id='upShowID' class="uploader col-md-12 clo-xs-12" data-ride="uploader" data-url="/application/upload.php">
<div id='upShowID' class="uploader col-md-12 clo-xs-12" data-ride="uploader" data-url="/app/upload.php">
<div class="uploader-message text-center">
<div class="content"></div>
<button type="button" class="close">x</button>
@ -117,7 +117,7 @@ mustLogin();
// 自动上传
autoUpload: false,
// 文件上传提交地址
url: './application/upload.php',
url: './app/upload.php',
// 最大支持的上传文件
max_file_size: <?php echo $config['maxSize']; ?>,
// 分片上传 0为不分片 分片容易使图片上传失败
@ -187,8 +187,8 @@ mustLogin();
</script>
<?php
/** 环境检测 */
if ($config['checkEnv']) require_once APP_ROOT . '/application/check.php';
if ($config['checkEnv']) require_once APP_ROOT . '/app/check.php';
/** 底部广告 */
if ($config['ad_bot']) echo $config['ad_bot_info'];
/** 引入底部 */
require_once APP_ROOT . '/application/footer.php';
require_once __DIR__ . '/app/footer.php';

View File

@ -1,5 +1,5 @@
<?php
require_once __DIR__ . '/../application/function.php';
require_once __DIR__ . '/../app/function.php';
if (file_exists(APP_ROOT . '/config/install.lock')) {
exit(header("Location:/../index.php"));

View File

@ -1,5 +1,5 @@
<?php
require_once __DIR__ . '/../application/function.php';
require_once __DIR__ . '/../app/function.php';
clearstatcache();
// 存在程序锁则跳转主页
if (file_exists(APP_ROOT . '/config/install.lock')) {
@ -10,7 +10,7 @@ $fileinfo = extension_loaded('fileinfo') ? true : false;
$gd = extension_loaded('gd') ? true : false;
$openssl = extension_loaded('openssl') ? true : false;
$file = substr(base_convert(fileperms(APP_ROOT . "/application/upload.php"), 10, 8), 3);
$file = substr(base_convert(fileperms(APP_ROOT . "/app/upload.php"), 10, 8), 3);
if (IS_WIN) {
$file_php = true;
$i_wjj = true;

View File

@ -1,5 +1,5 @@
<?php
require_once __DIR__ . '/../application/function.php';
require_once __DIR__ . '/../app/function.php';
// 存在程序锁则跳转主页
if (file_exists(APP_ROOT . '/config/install.lock')) {
exit(header("Location:/../index.php"));