You've already forked EasyImages2.0
mirror of
https://github.com/icret/EasyImages2.0.git
synced 2025-12-16 11:53:58 +08:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
60d0192bbc | ||
|
|
7b000b0ebf | ||
|
|
395cee60e7 | ||
|
|
1383a71082 | ||
|
|
8bf246c6b1 | ||
|
|
e632634154 | ||
|
|
fae2b6effe |
18
README.md
18
README.md
@@ -18,7 +18,7 @@
|
||||
[](https://github.com/icret/EasyImages2.0)
|
||||
-->
|
||||
|
||||
>[演示](https://png.cm/) | [Chrome/Edge 插件](https://github.com/icret/EasyImage-Browser-Extension) | [使用手册](https://www.kancloud.cn/easyimage/easyimage/) | [Telegram](https://t.me/Easy_Image)
|
||||
>[演示](https://png.cm/) | [Chrome/Edge 插件](https://github.com/icret/EasyImage-Browser-Extension) | [使用手册](https://www.kancloud.cn/easyimage/easyimage/) | [社区讨论](https://github.com/icret/EasyImages2.0/discussions) | [Telegram](https://t.me/Easy_Image)
|
||||
>
|
||||
>本人善写bug 发现bug可提交 [issues](https://github.com/icret/EasyImages2.0/issues) 追求稳定请下载 [稳定版](https://github.com/icret/EasyImages2.0/releases)
|
||||
|
||||
@@ -230,10 +230,22 @@ $HTTP["url"] =~ "^/(i|public)/" {
|
||||
|
||||
<details><summary>点击查看2.0版更新日志</summary>
|
||||
|
||||
* 2023-02-01 v2.7.1 dev
|
||||
* 2023-02-05 v2.7.2
|
||||
- 修复设置中手动压缩失败!
|
||||
- 优化排版
|
||||
|
||||
* 2023-02-05 v2.7.2
|
||||
- 增加删除单条历史上传记录
|
||||
- 增加 [web-indexr](https://github.com/rehiy/web-indexr) 文件管理, 正在实验中
|
||||
- - 作为 [Tinyfilemanager](https://github.com/prasathmani/tinyfilemanager) 的替代品 更轻量化 简单化
|
||||
- 修复开启登录上传后,上传者账号上传失败 [#87](https://github.com/icret/EasyImages2.0/issues/87#issue-1569794639)
|
||||
- 修复检测登录状态错误
|
||||
- 优化排版和移动端显示
|
||||
|
||||
* 2023-02-01 v2.7.1
|
||||
- 更新版本号
|
||||
|
||||
* 2023-02-01 v2.7.0 dev
|
||||
* 2023-02-01 v2.7.0
|
||||
- 增加限制游客上传
|
||||
- 增加上传历史记录
|
||||
- 增加粘贴上传状态
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -14,7 +14,7 @@ if(!is_who_login('admin')){
|
||||
}
|
||||
|
||||
// 开启tinyfilemanager图片管理
|
||||
if (!$config['tinyfilemanager']) {
|
||||
if (!$config['file_manage']) {
|
||||
require_once APP_ROOT.'/application/header.php';
|
||||
echo '<div class="alert alert-danger">图片管理已关闭~~</div>';
|
||||
header("refresh:3;url=" . $_SERVER["HTTP_REFERER"] . '?manager-closed');
|
||||
|
||||
@@ -1 +1 @@
|
||||
2.7.1
|
||||
2.7.2
|
||||
@@ -32,7 +32,7 @@ if ($config['check_ip']) {
|
||||
}
|
||||
|
||||
// 根据IP限制游客每日上传数量
|
||||
if ($config['ip_upload_counts'] > 0 && !is_who_login(null)) {
|
||||
if ($config['ip_upload_counts'] > 0 && !is_who_login('status')) {
|
||||
$ipList = APP_ROOT . '/admin/logs/ipcounts/' . date('Ymd') . '.php';
|
||||
if (is_file($ipList)) {
|
||||
$ipList = file_get_contents($ipList);
|
||||
@@ -188,29 +188,29 @@ if ($handle->uploaded) {
|
||||
|
||||
/** 后续处理 */
|
||||
// 使用fastcgi_finish_request操作
|
||||
if (function_exists('fastcgi_finish_request')) {
|
||||
if (function_exists('fastcgi_finish_request')) { // fastcgi_finish_request 模式
|
||||
fastcgi_finish_request();
|
||||
// 记录同IP上传次数
|
||||
@ip_upload_counts();
|
||||
// 上传日志
|
||||
if ($config['upload_logs']) @write_log($pathIMG, $handle->file_src_name, $handle->file_dst_pathname, $handle->file_src_size, $tokenID);
|
||||
// 鉴黄
|
||||
@process_checkImg($processUrl);
|
||||
// 日志
|
||||
if ($config['upload_logs']) @write_log($pathIMG, $handle->file_src_name, $handle->file_dst_pathname, $handle->file_src_size, $tokenID);
|
||||
// 水印
|
||||
@water($handle->file_dst_pathname);
|
||||
// 压缩
|
||||
@compress($handle->file_dst_pathname);
|
||||
@process_compress($handle->file_dst_pathname);
|
||||
} else { // 普通模式
|
||||
// 记录同IP上传次数
|
||||
@ip_upload_counts();
|
||||
} else {
|
||||
// 上传日志
|
||||
if ($config['upload_logs']) write_log($pathIMG, $handle->file_src_name, $handle->file_dst_pathname, $handle->file_src_size, $tokenID);
|
||||
// 鉴黄
|
||||
@process_checkImg($processUrl);
|
||||
// 日志
|
||||
if ($config['upload_logs']) write_log($pathIMG, $handle->file_src_name, $handle->file_dst_pathname, $handle->file_src_size, $tokenID);
|
||||
// 水印
|
||||
@water($handle->file_dst_pathname);
|
||||
// 压缩
|
||||
@compress($handle->file_dst_pathname);
|
||||
// 记录同IP上传次数
|
||||
@ip_upload_counts();
|
||||
@process_compress($handle->file_dst_pathname);
|
||||
}
|
||||
|
||||
unset($handle);
|
||||
|
||||
@@ -65,8 +65,9 @@ if ($config['notice_status'] == 1 && !empty($config['notice'])) : ?>
|
||||
|
||||
// 导航状态
|
||||
$('.nav-pills').find('a').each(function() {
|
||||
if (this.href == document.location.href) {
|
||||
$(this).parent().addClass('active'); // this.className = 'active';
|
||||
// console.log(document.location);
|
||||
if (this.pathname == document.location.pathname) {
|
||||
$(this).parent().addClass('active');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -764,19 +764,15 @@ function getDel($url, $type)
|
||||
*/
|
||||
function is_who_login($user)
|
||||
{
|
||||
if (empty($user)) {
|
||||
if (checkLogin() == 205 || checkLogin() == 204) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// 将状态转码
|
||||
$status = json_decode(_login(), true);
|
||||
if ($user == 'admin') {
|
||||
if ($status['level'] == 1) return true;
|
||||
}
|
||||
// 查询是否登录
|
||||
if ($user == 'status') if ($status['level'] > 0) return true;
|
||||
// 是否管理员登录
|
||||
if ($user == 'admin') if ($status['level'] == 1) return true;
|
||||
// 是否上传者登录
|
||||
if ($user == 'guest') if ($status['level'] == 2) return true;
|
||||
|
||||
if ($user == 'guest') {
|
||||
if ($status['level'] == 2) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1506,7 +1502,7 @@ function rand_imgurl($text = null)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前版本号
|
||||
* 获取当前版本号 | 读取字符串
|
||||
* @param String $file 文件相对路径
|
||||
* @return String 内容信息
|
||||
*/
|
||||
@@ -1519,15 +1515,17 @@ function get_current_version($file = '/admin/version.php')
|
||||
return file_get_contents($file);
|
||||
}
|
||||
|
||||
return 'No Version File';
|
||||
return 'file does not exist';
|
||||
}
|
||||
|
||||
// 压缩图片与图片鉴黄
|
||||
function compress($absolutePath)
|
||||
/**
|
||||
* 压缩图片 process 模式
|
||||
* @param String $absolutePath 图片绝对路径
|
||||
*/
|
||||
function process_compress($absolutePath)
|
||||
{
|
||||
global $config;
|
||||
|
||||
// 压缩图片 后压缩模式,不影响前台输出速度
|
||||
if ($config['compress']) {
|
||||
if (!is_Gif_Webp_Animated($absolutePath)) {
|
||||
require_once __DIR__ . '/compress/Imagick/class.Imgcompress.php';
|
||||
@@ -1541,7 +1539,10 @@ function compress($absolutePath)
|
||||
}
|
||||
}
|
||||
|
||||
// 设置水印
|
||||
/**
|
||||
* 设置水印 process 模式
|
||||
* @param String $source 图片路径
|
||||
*/
|
||||
function water($source)
|
||||
{
|
||||
global $config;
|
||||
@@ -1581,11 +1582,14 @@ function water($source)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 图片违规检查 process
|
||||
* @param String $imgurl 图片链接
|
||||
*/
|
||||
function process_checkImg($imgurl)
|
||||
{
|
||||
global $config;
|
||||
// 图片违规检查
|
||||
|
||||
if ($config['checkImg'] == 1) {
|
||||
checkImg($imgurl, 1);
|
||||
}
|
||||
@@ -1670,6 +1674,7 @@ function write_log($filePath, $sourceName, $absolutePath, $fileSize, $from = "we
|
||||
|
||||
/**
|
||||
* IP地址查询
|
||||
* @param int $ip IP地址
|
||||
*/
|
||||
function ip2region(String $IP)
|
||||
{
|
||||
@@ -1709,7 +1714,7 @@ function ip2region(String $IP)
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录同IP每日上传次数
|
||||
* 记录同IP每日上传次数 process
|
||||
*/
|
||||
function ip_upload_counts()
|
||||
{
|
||||
|
||||
@@ -27,21 +27,34 @@
|
||||
|
||||
<body class="container">
|
||||
<div class="page-header">
|
||||
<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; ?>
|
||||
|
||||
</ul>
|
||||
<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 unserialize($_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 -->
|
||||
@@ -15,7 +15,7 @@ include_once __DIR__ . "/header.php";
|
||||
<div class="col-md-12 history_clear">
|
||||
</div>
|
||||
<script src="<?php static_cdn(); ?>/public/static/EasyImage.js"></script>
|
||||
<script type="application/javascript" src="<?php static_cdn(); ?>/public/static/lazyload/lazyload.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>
|
||||
@@ -25,13 +25,28 @@ include_once __DIR__ . "/header.php";
|
||||
console.log('url list: ' + value['url']) // 获取所有链接
|
||||
if (value['url'] !== undefined) {
|
||||
let v_url = parseURL(value['url']); // 获取链接路径 console.log(parseURL(value['url']).path);
|
||||
$('.listNum').append('<div class="col-md-4 col-sm-6 col-lg-3"><div class="card"><li><img src="../public/images/loading.svg" data-image="' + value['thumb'] + '" data-original="" alt="简单图床-EasyImage"></li><div class="bottom-bar"><a href="' + value['url'] + '" target="_blank"><i class="icon icon-picture" data-toggle="tooltip" title="打开" style="margin-left:10px;"></i></a><a href="#" class="copy" data-clipboard-text="' + value['url'] + '" data-toggle="tooltip" title="复制" style="margin-left:10px;"><i class="icon icon-copy"></i></a><a href="info.php?history=' + v_url.path + '" data-toggle="tooltip" title="信息" target="_blank" style="margin-left:10px;"><i class="icon icon-info-sign"></i></a><a href="down.php?dw=' + v_url.path + '" data-toggle="tooltip" title="下载" target="_blank" style="margin-left:10px;"><i class="icon icon-cloud-download"></i></a><a href="' + value['del'] + '" target="_blank"><i class="icon icon-trash" data-toggle="tooltip" title="删除" style="margin-left:10px;"></i></a><a href="#" data-toggle="tooltip" title="文件名" class="copy text-ellipsis" data-clipboard-text="' + value['srcName'] + '" style="margin-left:10px;">' + value['srcName'] + '</a></div></div></div>')
|
||||
$('.listNum').append('<div class="col-md-4 col-sm-6 col-lg-3"><div class="card"><li><img src="../public/images/loading.svg" data-image="' + value['thumb'] + '" data-original="" alt="简单图床-EasyImage"></li><div class="bottom-bar"><a href="' + value['url'] + '" target="_blank"><i class="icon icon-picture" data-toggle="tooltip" title="打开" style="margin-left:10px;"></i></a><a href="#" class="copy" data-clipboard-text="' + value['url'] + '" data-toggle="tooltip" title="复制链接" style="margin-left:10px;"><i class="icon icon-copy"></i></a><a href="info.php?img=' + v_url.path + '" data-toggle="tooltip" title="详细信息" target="_blank" style="margin-left:10px;"><i class="icon icon-info-sign"></i></a><a href="down.php?dw=' + v_url.path + '" data-toggle="tooltip" title="下载文件" target="_blank" style="margin-left:10px;"><i class="icon icon-cloud-download"></i></a><a href="#" data-toggle="tooltip" title="删除记录" class="Remove"id="' + value['srcName'] + '" style="margin-left:10px;"><i class="icon icon-remove-sign"></i></a></a><a href="' + value['del'] + '" target="_blank"><i class="icon icon-trash" data-toggle="tooltip" title="删除文件" style="margin-left:10px;"></i></a><a href="#" data-toggle="tooltip" title="源文件名" class="copy text-ellipsis" data-clipboard-text="' + value['srcName'] + '" style="margin-left:10px;">' + value['srcName'] + '</a></div></div></div>')
|
||||
}
|
||||
})
|
||||
$('.history_clear').append('<h3 class="header-dividing" style="text-align: center;" data-toggle="tooltip" title="非上传记录|清空缓存|浏览器版本低不显示<br/>点击清空历史上传记录"><button class="btn btn-mini btn-primary" type="button"><i class="icon icon-eye-open"></i> 历史上传记录</button></h3>');
|
||||
} else {
|
||||
$('.listNum').append('<h2 class="alert alert-danger">上传历史记录不存在~~ <br /><small>非上传记录 | 清空缓存 | 浏览器版本低不显示~!</small></h2>');
|
||||
};
|
||||
|
||||
// 删除指定存储条目
|
||||
$('.Remove').on('click', function() {
|
||||
|
||||
let Remove = $('.Remove').attr("id");
|
||||
$.zui.store.remove(Remove); // 删除指定存储条目
|
||||
|
||||
new $.zui.Messager('已删除 ' + Remove + ' 上传记录', {
|
||||
type: "success", // 定义颜色主题
|
||||
icon: "ok-sign" // 定义消息图标
|
||||
}).show();
|
||||
|
||||
setTimeout(location.reload.bind(location), 2000); // 延迟2秒刷新
|
||||
})
|
||||
|
||||
// 清空所有本地存储的条目
|
||||
$('button').on('click', function() {
|
||||
new $.zui.Messager('已清空' + $.zui.store.length() + "条历史记录", {
|
||||
@@ -43,12 +58,7 @@ include_once __DIR__ . "/header.php";
|
||||
setTimeout(location.reload.bind(location), 2000); // 延迟2秒刷新
|
||||
})
|
||||
|
||||
// viewjs
|
||||
new Viewer(document.getElementById('viewjs'), {
|
||||
url: 'data-original',
|
||||
});
|
||||
|
||||
// 复制url
|
||||
// 复制 文件名/URL
|
||||
var clipboard = new Clipboard('.copy');
|
||||
clipboard.on('success', function(e) {
|
||||
new $.zui.Messager("复制成功", {
|
||||
@@ -65,6 +75,11 @@ include_once __DIR__ . "/header.php";
|
||||
}).show();
|
||||
});
|
||||
|
||||
// viewjs
|
||||
new Viewer(document.getElementById('viewjs'), {
|
||||
url: 'data-original',
|
||||
});
|
||||
|
||||
//懒加载
|
||||
var lazy = new Lazy({
|
||||
onload: function(elem) {
|
||||
|
||||
@@ -285,6 +285,7 @@ if ($config['ad_top']) echo $config['ad_top_info'];
|
||||
});
|
||||
}
|
||||
*/
|
||||
|
||||
//禁用右键
|
||||
document.onkeydown = function() {
|
||||
var e = window.event || arguments[0];
|
||||
|
||||
BIN
application/ip2region/ip2region.xdb
Normal file
BIN
application/ip2region/ip2region.xdb
Normal file
Binary file not shown.
@@ -60,22 +60,22 @@ if ($config['ad_top']) echo $config['ad_top_info'];
|
||||
$imgUrl = $config['domain'] . $relative_path; // 图片地址
|
||||
$linkUrl = rand_imgurl() . $config_path . $value; // 图片复制与原图地址
|
||||
?>
|
||||
<div class="col-md-4 col-sm-6 col-lg-3">
|
||||
<div class="col-lg-3 col-md-4 col-sm-6 col-xs-12">
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
@@ -93,34 +93,33 @@ if ($config['ad_top']) echo $config['ad_top_info'];
|
||||
/** 底部广告 */
|
||||
if ($config['ad_bot']) echo $config['ad_bot_info']; ?>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<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 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 class="row">
|
||||
</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">
|
||||
@@ -136,26 +135,25 @@ if ($config['ad_top']) echo $config['ad_top_info'];
|
||||
</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 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>
|
||||
</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>
|
||||
</form>
|
||||
<!-- 返回顶部-->
|
||||
<div class="btn btn-mini btn-primary btn-back-to-top"><i class="icon icon-arrow-up"></i></div>
|
||||
</div>
|
||||
@@ -184,7 +182,7 @@ if ($config['ad_top']) echo $config['ad_top_info'];
|
||||
}
|
||||
</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.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>
|
||||
@@ -357,7 +355,7 @@ if ($config['ad_top']) echo $config['ad_top_info'];
|
||||
onload: function(elem) {
|
||||
console.log(elem)
|
||||
},
|
||||
delay: 300
|
||||
delay: 300,
|
||||
})
|
||||
|
||||
// 按日期浏览
|
||||
|
||||
@@ -74,6 +74,7 @@ $ALLOWED_SITES = array(
|
||||
$config['imgurl'],
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* 修复无法生成生成webp动态图片的缩略图bug
|
||||
*/
|
||||
@@ -81,6 +82,15 @@ 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'];
|
||||
// 获取文件后缀
|
||||
|
||||
@@ -7,7 +7,7 @@ require __DIR__ . '/class.upload.php';
|
||||
|
||||
// 检查登录
|
||||
if ($config['mustLogin']) {
|
||||
if (is_who_login(null)) {
|
||||
if (!is_who_login('status')) {
|
||||
exit(json_encode(array(
|
||||
"result" => "failed",
|
||||
"code" => 401,
|
||||
@@ -40,7 +40,7 @@ if ($config['check_ip']) {
|
||||
}
|
||||
|
||||
// 根据IP限制游客每日上传数量
|
||||
if ($config['ip_upload_counts'] > 0 && !is_who_login(null)) {
|
||||
if ($config['ip_upload_counts'] > 0 && !is_who_login('status')) {
|
||||
$ipList = APP_ROOT . '/admin/logs/ipcounts/' . date('Ymd') . '.php';
|
||||
if (is_file($ipList)) {
|
||||
$ipList = file_get_contents($ipList);
|
||||
@@ -208,29 +208,31 @@ if ($handle->uploaded) {
|
||||
|
||||
/** 后续处理 */
|
||||
// 使用fastcgi_finish_request操作
|
||||
if (function_exists('fastcgi_finish_request')) {
|
||||
if (function_exists('fastcgi_finish_request')) { // fastcgi_finish_request 模式
|
||||
fastcgi_finish_request();
|
||||
// 普通模式鉴黄
|
||||
// 同IP上传日志
|
||||
@ip_upload_counts();
|
||||
// 日志
|
||||
if ($config['upload_logs']) @write_log($pathIMG, $handle->file_src_name, $handle->file_dst_pathname, $handle->file_src_size);
|
||||
// 鉴黄
|
||||
@process_checkImg($processUrl);
|
||||
// 日志
|
||||
if ($config['upload_logs']) @write_log($pathIMG, $handle->file_src_name, $handle->file_dst_pathname, $handle->file_src_size);
|
||||
// 水印
|
||||
@water($handle->file_dst_pathname);
|
||||
// 压缩
|
||||
@compress($handle->file_dst_pathname);
|
||||
// 记录同IP上传次数
|
||||
@ip_upload_counts();
|
||||
} else {
|
||||
// 普通模式鉴黄
|
||||
@process_checkImg($processUrl);
|
||||
// 日志
|
||||
if ($config['upload_logs']) write_log($pathIMG, $handle->file_src_name, $handle->file_dst_pathname, $handle->file_src_size);
|
||||
// 水印
|
||||
@water($handle->file_dst_pathname);
|
||||
// 压缩
|
||||
@compress($handle->file_dst_pathname);
|
||||
@ip_upload_counts();
|
||||
} else { // 普通模式
|
||||
// 记录同IP上传次数
|
||||
@ip_upload_counts();
|
||||
// 日志
|
||||
if ($config['upload_logs']) @write_log($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);
|
||||
}
|
||||
|
||||
unset($handle);
|
||||
|
||||
@@ -15,11 +15,12 @@ $config=Array
|
||||
<h5>目录保存以 年/月/日/ 递进,非必要请勿修改! 否则会导致部分操作不可用;</h5>
|
||||
<h5>本人仅为程序开源创作,如遇非法网站使用与本人无关,请勿用于商业用途;</h5>
|
||||
<h5>作为开发者你可以对相应的后台功能进行扩展(增删改相应代码),但请保留代码中源作者信息。</h5>
|
||||
<a href="https://png.cm/?admin.inc" target="_blank"><button type="button" class="btn btn-mini"><i class="icon icon-external-link"></i> 演示网站</button></a>
|
||||
<a href="https://www.kancloud.cn/easyimage/easyimage/content" target="_blank"><button type="button" class="btn btn-mini"><i class="icon icon-hand-right"></i> 使用手册</button></a>
|
||||
<a href="https://png.cm/?admin.inc" target="_blank"><button type="button" class="btn btn-mini"><i class="icon icon-external-link"></i> 演示</button></a>
|
||||
<a href="https://www.kancloud.cn/easyimage/easyimage/content" target="_blank"><button type="button" class="btn btn-mini"><i class="icon icon-book"></i> 手册</button></a>
|
||||
<a href="https://github.com/icret/EasyImages2.0/discussions" target="_blank"><button type="button" class="btn btn-mini"><i class="icon icon-comments-alt"></i> 社区</button></a>
|
||||
<a href="https://t.me/Easy_Image" target="_blank" data-toggle="tooltip" title="EasyImage Telegram Group"><button type="button" class="btn btn-mini"><i class="icon icon-plane"></i> Telegram</button></a>
|
||||
<a href="https://s2.loli.net/2023/01/20/laTuceHD3qjpd82.jpg" title="您的赞美是我开发的动力!" data-toggle="lightbox" class="btn btn-mini" style="color:#329d38;"><i class="icon icon-wechat"></i> 打赏作者</a>
|
||||
<a href="https://s2.loli.net/2023/01/20/rREU1dJk9HMxDFA.jpg" title="您的赞美是我开发的动力!" data-toggle="lightbox" class="btn btn-mini hidden-xs inline-block" style="color:#1970fc;"><i class="icon icon-zhifubao"></i> 打赏作者</a>
|
||||
<a href="../public/images/wechat.jpg" title="您的赞美是我开发的动力!" data-toggle="lightbox" class="btn btn-mini" style="color:#329d38;"><i class="icon icon-wechat"></i> 打赏</a>
|
||||
<a href="../public/images/alipay.jpg" title="您的赞美是我开发的动力!" data-toggle="lightbox" class="btn btn-mini hidden-xs inline-block" style="color:#1970fc;"><i class="icon icon-zhifubao"></i> 打赏</a>
|
||||
</div>',
|
||||
'domain'=>'http://127.0.0.1',
|
||||
'imgurl'=>'http://127.0.0.1',
|
||||
@@ -41,7 +42,7 @@ $config=Array
|
||||
'textSize'=>50,
|
||||
'textFont'=>'/public/static/pang_men_zheng_dao_biao_ti_ti_3.0.ttf',
|
||||
'waterImg'=>'/public/images/watermark.png',
|
||||
'extensions'=>'gif,jpeg,png,tif,bmp,tif,svg,webp,jpg,tga,ico',
|
||||
'extensions'=>'gif,jpeg,png,tif,bmp,svg,webp,jpg,tga,ico',
|
||||
'compress'=>0,
|
||||
'compress_ratio'=>80,
|
||||
'thumbnail'=>1,
|
||||
@@ -63,7 +64,7 @@ $config=Array
|
||||
'static_cdn_url'=>'https://fastly.jsdelivr.net/gh/icret/EasyImages2.0',
|
||||
'TinyPng_key'=>'',
|
||||
'checkImg'=>0,
|
||||
'checkImg_value'=>50,
|
||||
'checkImg_value'=>80,
|
||||
'moderatecontent_key'=>'',
|
||||
'nsfwjs_url'=>'',
|
||||
'showSwitch'=>1,
|
||||
@@ -105,6 +106,7 @@ $config=Array
|
||||
'report'=>'',
|
||||
'image_recycl'=>1,
|
||||
'tinyfilemanager'=>1,
|
||||
'file_manage'=>1,
|
||||
'delDir'=>'cache/',
|
||||
'hide'=>0,
|
||||
'hide_key'=>'EasyImage2.0',
|
||||
@@ -113,7 +115,7 @@ $config=Array
|
||||
'guest_path_status'=>0,
|
||||
'token_path_status'=>0,
|
||||
'admin_path'=>'u',
|
||||
'update'=>'2023-02-01 22:12:10',
|
||||
'update'=>'2023-02-05 02:23:46',
|
||||
'footer'=>'<a href="https://github.com/icret/EasyImages2.0" target="_blank" rel="nofollow" data-toggle="tooltip" title="Since 2018 - Github">© Since 2018</a>
|
||||
<a href="https://png.cm/" target="_blank" data-toggle="tooltip" title="EasyImage 简单图床">EasyImage</a>
|
||||
<a href="/admin/terms.php" target="_blank" data-toggle="tooltip" title="使用协议">DMCA</a>
|
||||
|
||||
1087
i/manag.php
Normal file
1087
i/manag.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -21,10 +21,11 @@ mustLogin();
|
||||
</div>
|
||||
<div class="uploader-files file-list file-list-lg file-rename-by-click" data-drag-placeholder="选择文件/Ctrl+V粘贴/拖拽至此处" style="min-height: 188px; border-style: dashed;"></div>
|
||||
<div class="uploader-actions">
|
||||
<div class="uploader-status pull-right text-muted"></div>
|
||||
<button type="button" class="btn btn-link uploader-btn-browse"><i class="icon icon-plus"></i> 选择文件</button>
|
||||
<button type="button" class="btn btn-link uploader-btn-start"><i class="icon icon-cloud-upload"></i> 开始上传</button>
|
||||
<button type="button" class="btn btn-link uploader-btn-stop"><i class="icon icon-pause"></i> 暂停上传</button>
|
||||
<div class="uploader-status pull-right text-muted hidden-xs"></div>
|
||||
<div class="uploader-status pull-right text-muted col-xs-12 text-ellipsis visible-xs"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12 clo-xs-12">
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
|
||||
(function(){var root=(typeof self=='object'&&self.self==self&&self)||(typeof global=='object'&&global.global==global&&global)||this||{};Function.prototype.bind=Function.prototype.bind||function(context){if(typeof this!=="function"){throw new Error("Function.prototype.bind - what is trying to be bound is not callable");}
|
||||
var self=this;var args=Array.prototype.slice.call(arguments,1);var fNOP=function(){};var fBound=function(){var bindArgs=Array.prototype.slice.call(arguments);self.apply(this instanceof fNOP?this:context,args.concat(bindArgs));}
|
||||
fNOP.prototype=this.prototype;fBound.prototype=new fNOP();return fBound;}
|
||||
var util={extend:function(target){for(var i=1,len=arguments.length;i<len;i++){for(var prop in arguments[i]){if(arguments[i].hasOwnProperty(prop)){target[prop]=arguments[i][prop]}}}
|
||||
return target},addEvent:function(elem,type,fn){if(document.addEventListener){elem.addEventListener(type,fn,false);return fn;}else if(document.attachEvent){var bound=function(){return fn.apply(elem,arguments)}
|
||||
elem.attachEvent('on'+type,bound);return bound;}},removeEvent:function(elem,type,fn){if(document.removeEventListener){elem.removeEventListener(type,fn,false)}
|
||||
else{elem.detachEvent("on"+type,fn)}}}
|
||||
function Lazy(opts){this.opts=util.extend({},this.constructor.defaultOpts,opts)
|
||||
this.init();}
|
||||
Lazy.VERSION='1.0.0';Lazy.defaultOpts={delay:250,useDebounce:false}
|
||||
var proto=Lazy.prototype;proto.init=function(){this.calulateView();this.bindScrollEvent();};proto.calulateView=function(){this.view={top:0-(parseInt(this.opts.top,10)||0),bottom:(root.innerHeight||document.documentElement.clientHeight)+(parseInt(this.opts.bottom,10)||0),left:0-(parseInt(this.opts.left,10)||0),right:(root.innerWidth||document.documentElement.clientWidth)+(parseInt(this.opts.right,10)||0)}};proto.bindScrollEvent=function(){var scrollEvent=util.addEvent(root,'scroll',this.handleLazyLoad.bind(this))
|
||||
var loadEvent=util.addEvent(root,'load',this.handleLazyLoad.bind(this))
|
||||
this.event={scrollEvent:scrollEvent,loadEvent:loadEvent}};var timer=null;proto.handleLazyLoad=function(){var self=this;if(!this.opts.useDebounce&&!!timer){return;}
|
||||
clearTimeout(timer);timer=setTimeout(function(){timer=null;self.render()},this.opts.delay);};proto.isHidden=function(element){return(element.offsetParent===null);};proto.checkInView=function(element){if(this.isHidden(element)){return false;}
|
||||
var rect=element.getBoundingClientRect();return(rect.right>=this.view.left&&rect.bottom>=this.view.top&&rect.left<=this.view.right&&rect.top<=this.view.bottom);};proto.render=function(){var nodes=document.querySelectorAll('[data-image], [data-lazy-background]');var length=nodes.length;for(var i=0;i<length;i++){elem=nodes[i];if(this.checkInView(elem)){if(elem.getAttribute('data-lazy-background')!==null){elem.style.backgroundImage='url('+elem.getAttribute('data-lazy-background')+')';}else if(elem.src!==(src=elem.getAttribute('data-image'))){elem.src=src;}
|
||||
elem.removeAttribute('data-image');elem.removeAttribute('data-lazy-background');if(this.opts.onload&&typeof this.opts.onload==='function'){this.opts.onload(elem);}}}
|
||||
if(!length){this.unbindScrollEvent();}};proto.unbindScrollEvent=function(){util.removeEvent(root,'scroll',this.event.scrollEvent)
|
||||
util.removeEvent(root,'load',this.event.loadEvent)};if(typeof exports!='undefined'&&!exports.nodeType){if(typeof module!='undefined'&&!module.nodeType&&module.exports){exports=module.exports=Lazy;}
|
||||
exports.Lazy=Lazy;}else{root.Lazy=Lazy;}}());
|
||||
5
public/static/lazyload/lazyload.min.js
vendored
Normal file
5
public/static/lazyload/lazyload.min.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/*!
|
||||
* 懒加载 - 因兼容问题将 data-lazy-src 替换为data-image
|
||||
* https://github.com/mqyqingfeng/LazyLoad
|
||||
*/
|
||||
!function(){function t(t){this.opts=n.extend({},this.constructor.defaultOpts,t),this.init()}var e="object"==typeof self&&self.self==self&&self||"object"==typeof global&&global.global==global&&global||this||{};Function.prototype.bind=Function.prototype.bind||function(t){if("function"!=typeof this)throw new Error("Function.prototype.bind - what is trying to be bound is not callable");var e=this,n=Array.prototype.slice.call(arguments,1),o=function(){},i=function(){var i=Array.prototype.slice.call(arguments);e.apply(this instanceof o?this:t,n.concat(i))};return o.prototype=this.prototype,i.prototype=new o,i};var n={extend:function(t){for(var e=1,n=arguments.length;e<n;e++)for(var o in arguments[e])arguments[e].hasOwnProperty(o)&&(t[o]=arguments[e][o]);return t},addEvent:function(t,e,n){if(document.addEventListener)return t.addEventListener(e,n,!1),n;if(document.attachEvent){var o=function(){return n.apply(t,arguments)};return t.attachEvent("on"+e,o),o}},removeEvent:function(t,e,n){document.removeEventListener?t.removeEventListener(e,n,!1):t.detachEvent("on"+e,n)}};t.VERSION="1.0.0",t.defaultOpts={delay:250,useDebounce:!1};var o=t.prototype;o.init=function(){this.calulateView(),this.bindScrollEvent()},o.calulateView=function(){this.view={top:0-(parseInt(this.opts.top,10)||0),bottom:(e.innerHeight||document.documentElement.clientHeight)+(parseInt(this.opts.bottom,10)||0),left:0-(parseInt(this.opts.left,10)||0),right:(e.innerWidth||document.documentElement.clientWidth)+(parseInt(this.opts.right,10)||0)}},o.bindScrollEvent=function(){var t=n.addEvent(e,"scroll",this.handleLazyLoad.bind(this)),o=n.addEvent(e,"load",this.handleLazyLoad.bind(this));this.event={scrollEvent:t,loadEvent:o}};var i=null;o.handleLazyLoad=function(){var t=this;!this.opts.useDebounce&&i||(clearTimeout(i),i=setTimeout(function(){i=null,t.render()},this.opts.delay))},o.isHidden=function(t){return null===t.offsetParent},o.checkInView=function(t){if(this.isHidden(t))return!1;var e=t.getBoundingClientRect();return e.right>=this.view.left&&e.bottom>=this.view.top&&e.left<=this.view.right&&e.top<=this.view.bottom},o.render=function(){for(var t=document.querySelectorAll("[data-image], [data-lazy-background]"),e=t.length,n=0;n<e;n++)elem=t[n],this.checkInView(elem)&&(null!==elem.getAttribute("data-lazy-background")?elem.style.backgroundImage="url("+elem.getAttribute("data-lazy-background")+")":elem.src!==(src=elem.getAttribute("data-image"))&&(elem.src=src),elem.removeAttribute("data-image"),elem.removeAttribute("data-lazy-background"),this.opts.onload&&"function"==typeof this.opts.onload&&this.opts.onload(elem));e||this.unbindScrollEvent()},o.unbindScrollEvent=function(){n.removeEvent(e,"scroll",this.event.scrollEvent),n.removeEvent(e,"load",this.event.loadEvent)},"undefined"==typeof exports||exports.nodeType?e.Lazy=t:("undefined"!=typeof module&&!module.nodeType&&module.exports&&(exports=module.exports=t),exports.Lazy=t)}();
|
||||
Reference in New Issue
Block a user