This commit is contained in:
icret
2022-09-20 13:44:48 +08:00
parent c6cd45425c
commit 4fae3bd291
13 changed files with 167 additions and 136 deletions

View File

@@ -40,11 +40,9 @@ if ($config['notice_status'] == 1 && !empty($config['notice'])) : ?>
<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 /** 页脚信息 */ if (!empty($config['footer'])) echo $config['footer']; ?>
<p>
<a href="https://github.com/icret/EasyImages2.0" target="_blank" rel="nofollow" data-toggle="tooltip" title="开源地址">© 2018-<?php echo date("Y"); ?></a>
<a href="https://png.cm/" target="_blank" data-toggle="tooltip" title="<?php echo get_current_verson(); ?>"> EasyImage</a>
<a href="/admin/terms.php" target="_blank" data-toggle="tooltip" title="使用协议"> DMCA</a>
<!-- 页脚信息 -->
<?php if (!empty($config['footer'])) echo $config['footer']; ?>
<!-- 二维码按钮 -->
<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']) : ?>
@@ -193,8 +191,8 @@ if ($config['notice_status'] == 1 && !empty($config['notice'])) : ?>
});
// console
console.log("%cEasyImage2.0", "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;', '');
console.log("%cEasyImage<?php echo get_current_verson(); ?>", "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>

View File

@@ -210,6 +210,12 @@ function imgName($source = null)
return sprintf('%04X%04X-%04X-%04X-%04X-%04X%04X%04X', mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(16384, 20479), mt_rand(32768, 49151), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535));
}
function uuid() // 生成uuid
{
$chars = md5(uniqid(mt_rand(), true));
return substr($chars, 0, 8) . '-' . substr($chars, 8, 4) . '-' . substr($chars, 12, 4) . '-' . substr($chars, 16, 4) . '-' . substr($chars, 20, 12); // return $uuid;
}
switch ($config['imgName']) {
case "source":
@@ -247,7 +253,10 @@ function imgName($source = null)
break;
case "snowflake":
include __DIR__ . '/class.snowflake.php';
return SnowFlake::createOnlyId(); //分布式id
return SnowFlake::createOnlyId(); // 分布式id
break;
case "uuid":
return uuid(); // uuid
break;
default:
// 将上传时间+随机数转换为36进制 例vx77yu
@@ -912,12 +921,21 @@ function creat_thumbnail_images($imgName)
$old_img_path = APP_ROOT . config_path() . $imgName; // 获取要创建缩略图文件的绝对路径
$cache_path = APP_ROOT . $config['path'] . 'thumbnails/'; // cache目录的绝对路径
// 自定义缩略图长宽
$thumbnail_w = 258;
$thumbnail_h = 258;
if (!empty($config['thumbnail_w']) || !empty($config['thumbnail_h'])) {
$thumbnail_w = $config['thumbnail_w'];
$thumbnail_h = $config['thumbnail_h'];
}
if (!is_dir($cache_path)) { // 创建cache目录
mkdir($cache_path, 0777, true);
}
if (!isAnimatedGif($old_img_path)) { // 仅针对非gif创建图片缩略图
$new_imgName = APP_ROOT . $config['path'] . 'thumbnails/' . date('Y_m_d') . '_' . $imgName; // 缩略图缓存的绝对路径
Thumb::out($old_img_path, $new_imgName, 258, 258); // 保存缩略图
Thumb::out($old_img_path, $new_imgName, $thumbnail_w, $thumbnail_h); // 保存缩略图
}
}
@@ -1025,13 +1043,21 @@ function creat_thumbnail_by_list($imgUrl)
mkdir($cache_path, 0777, true);
}
// 自定义缩略图长宽
$thumbnail_w = 258;
$thumbnail_h = 258;
if (!empty($config['thumbnail_w']) || !empty($config['thumbnail_h'])) {
$thumbnail_w = $config['thumbnail_w'];
$thumbnail_h = $config['thumbnail_h'];
}
// 缩略图缓存的绝对路径
// $imgName 是不带/i/的相对路径
$new_imgName = $cache_path . $imgName;
// 创建并保存缩略图
Thumb::out($abPathName, $new_imgName, 258, 258);
Thumb::out($abPathName, $new_imgName, $thumbnail_w, $thumbnail_h);
// 输出缩略图
return $new_imgName;
@@ -1070,7 +1096,14 @@ function cache_write($filename, $values, $var = 'config', $format = false)
{
$cachefile = $filename;
$cachetext = "<?php\r\n" . '$' . $var . '=' . arrayeval($values, $format) . ";";
return writefile($cachefile, $cachetext);
$result = writefile($cachefile, $cachetext);
// 清除Opcache缓存
if (function_exists('opcache_reset')) {
opcache_reset();
}
return $result;
}
/**

View File

@@ -43,7 +43,7 @@ if ($config['ad_top']) echo $config['ad_top_info'];
<div class="col-md-6" style="text-align: center;">
<img data-toggle="lightbox" src="<?php echo $img_url; ?>" data-image="<?php echo $img_url; ?>" id="img1" class="img-rounded" height="234px" data-caption="<?php echo pathinfo($img_url, PATHINFO_FILENAME); ?>的详细信息" alt="<?php echo $img_url; ?>" />
</div>
<div class="col-md-6 table-responsive table-condensed">
<div class="col-md-6 table-responsive table-condensed" style="margin-top: 10px;">
<table class="table table-hover table-striped table-bordered">
<tbody>
<tr>
@@ -83,36 +83,6 @@ if ($config['ad_top']) echo $config['ad_top_info'];
</tbody>
</table>
<h4 class="with-padding hl-gray"><i class="icon icon-info-sign"> 此图片来自网友上传, 不代表<a href="/admin/terms.php" target="_blank">本站立场</a>, 若有侵权, 请举报或联系管理员!</i></h4>
<!--
<h4>图片名称: < ?php echo pathinfo($getIMG, PATHINFO_FILENAME); ?></h4>
<h4>图片大小: < ?php echo getDistUsed($imgSize); ?></h4>
<h4>图片类型: image/< ?php echo pathinfo($getIMG, PATHINFO_EXTENSION); ?></h4>
<h4>图片宽高: <span id="wh"></span>px</h4>
<h4>上传时间: < ?php echo date("Y-m-d H:i:s", $upTime); ?></h4>
<h4>文件操作:
<a class="btn btn-mini btn-primary" href="< ?php echo $img_url; ?>" target="_blank"><i class="icon icon-picture"> 查看</i></a>
< ?php if (is_who_login('admin')) : ?>
<a class="btn btn-mini btn-primary" href="/application/del.php?recycle_url=< ?php echo $getIMG; ?>" target="_blank"><i class="icon icon-undo"> 回收</i></a>
<a class="btn btn-mini btn-primary" href="/application/del.php?url=< ?php echo $del_url; ?>" target="_blank"><i class="icon icon-trash"> 删除</i></a>
< ?php endif; ?>
</h4>
<h4 class="with-padding hl-gray"><i class="icon icon-info-sign"> 此图片来自网友上传, 不代表<a href="/admin/terms.php" target="_blank">本站立场</a>, 若有侵权, 请联系管理员删除!</i></h4>
-->
<!-- 读取Exif信息
<h4>使用设备: <span id="makeAndModel"></span></h4>
<div class="col-md-12">
<p>
<button type="button" class="btn btn-primary btn-sm" data-toggle="collapse" data-target="#collapseExample">Exif 信息 <i class="icon icon-caret-down"></i></button>
<a class="btn btn-primary btn-sm" href="<php echo $img_url; ?>" target="_blank">查看图片 <i class="icon icon-picture"></i></a>
<php if (is_who_login('admin')) : ?>
<a class="btn btn-primary btn-sm" href="/application/del.php?url=<php echo $del_url; ?>" target="_blank">删除图片 <i class="icon icon-trash"></i></a>
<php endif; ?>
</p>
<div class="collapse" id="collapseExample">
<pre id="allMetaDataSpan"></pre>
</div>
</div>
-->
</div>
</div>
<div class="col-md-12" style="padding-bottom: 10px;">
@@ -177,7 +147,6 @@ if ($config['ad_top']) echo $config['ad_top_info'];
</div>
</div>
<?php endif; ?>
<!-- <script src="< php static_cdn(); ?>/public/static/exif/exif.js"></script> -->
<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>

View File

@@ -61,7 +61,7 @@ if ($config['ad_top']) echo $config['ad_top_info'];
$linkUrl = rand_imgurl() . $config_path . $value; // 图片复制与原图地址
?>
<div class="col-md-4 col-sm-6 col-lg-3">
<div class="card" id="card">
<div class="card">
<li><img src="../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>

View File

@@ -103,7 +103,7 @@ function write_log($filePath, $sourceName, $absolutePath, $fileSize, $from = "we
{
global $config;
$checkImg = $config['checkImg'] == true ? "Enabled" : "Disabled";
$checkImg = $config['checkImg'] == true ? "ON" : "OFF";
// $name = trim(basename($filePath), " \t\n\r\0\x0B"); // 当前图片名称
$log = array(basename($filePath) => array( // 以上传图片名称为Array

View File

@@ -45,11 +45,23 @@ Thumb::show($src, $w, $h);
*/
require_once __DIR__ . '/function.php';
// 自定义缩略图长宽
$thumbnail_w = 258;
$thumbnail_h = 258;
if (!empty($config['thumbnail_w']) || !empty($config['thumbnail_h'])) {
$thumbnail_w = $config['thumbnail_w'];
$thumbnail_h = $config['thumbnail_h'];
}
// 缓存时间
$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', 258);
define('DEFAULT_HEIGHT', 258);
define('DEFAULT_WIDTH', $thumbnail_w);
define('DEFAULT_HEIGHT', $thumbnail_h);
define('FILE_CACHE_PREFIX', 'EasyImage');
define('DEFAULT_ZC', 0);
@@ -59,10 +71,10 @@ define('FILE_CACHE_DIRECTORY', APP_ROOT . $config['path'] . 'thumbnails');
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', 86400); // 多久清理一次缓存
define('FILE_CACHE_MAX_FILE_AGE', 86400); // 文件必须从缓存中删除多长时间
define('BROWSER_CACHE_MAX_AGE', 864000); // 浏览器缓存时间
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(