@ -1,95 +0,0 @@
@@ -1,95 +0,0 @@
|
||||
<?php |
||||
/* |
||||
@name:万象优图API处理接口 |
||||
@author:xiaoz.me |
||||
*/ |
||||
error_reporting(E_ALL^E_NOTICE^E_WARNING^E_DEPRECATED); |
||||
//载入配置 |
||||
include_once('../config.php'); |
||||
|
||||
//载入万象优图SDK |
||||
require_once '../sdk/wxyt/index.php'; |
||||
use QcloudImage\CIClient; |
||||
$client = new CIClient($identify['APP_ID'], $identify['SECRET_ID'], $identify['SECRET_KEY'], $identify['BUCKET']); |
||||
$client->setTimeout(60); |
||||
|
||||
//获取图片地址 |
||||
$url = $_GET['url']; |
||||
//获取上级目录地址 |
||||
|
||||
//对URL进行替换 |
||||
$url = str_replace($config['domain'],'',$url); |
||||
$imgdir = explode('/',$url);//对目录进行分割 |
||||
|
||||
//如果链接是管理员目录则不鉴黄 |
||||
if($imgdir[0] == $config['admindir']) { |
||||
$re_data = array( |
||||
"code" => 0, |
||||
"result" => 0, |
||||
"confidence"=> 0 |
||||
); |
||||
|
||||
echo $re_data = json_encode($re_data); |
||||
exit; |
||||
} |
||||
//如果不是游客目录 |
||||
if($config['userdir'] != $imgdir[0]) { |
||||
//echo $imgdir[0]; |
||||
echo '非法请求'; |
||||
exit; |
||||
} |
||||
//重组完整图片 |
||||
$imgurl = $config['domain'].$url; |
||||
$imginfo = ($client->pornDetect(array('urls'=>array($imgurl)))); |
||||
|
||||
$imginfo = json_decode($imginfo); |
||||
|
||||
//获取状态码,0为成功 |
||||
//$code = $imginfo->http_code; |
||||
//转换为数组 |
||||
$imginfo = object2array($imginfo); |
||||
//状态码,0为成功 |
||||
$code = $imginfo['result_list']['0']->code; |
||||
$imginfo = object2array($imginfo['result_list']['0']->data); |
||||
//识别结果,0 正常,1 黄图,2 疑似图片 |
||||
$result = $imginfo['result']; |
||||
//识别评分,分数越高,越可能是黄图 |
||||
$confidence = $imginfo['confidence']; |
||||
|
||||
//重新返回json数据 |
||||
$re_data = array( |
||||
"code" => $code, |
||||
"result" => $result, |
||||
"confidence"=> $confidence |
||||
); |
||||
|
||||
//严格模式,如果是色情图片或疑似色情图片均放到回收站 |
||||
if(($re_data['result'] == 1) || ($re_data['result'] == 2)) { |
||||
//获取图片地址 |
||||
$url = dirname(dirname(__FILE__)).'/'.$url; |
||||
//回收站地址 |
||||
$recycle = dirname(dirname(__FILE__))."/recycle/".end($imgdir); |
||||
//移动到回收站 |
||||
if(copy($url,$recycle)){ |
||||
unlink($url); //删除图片 |
||||
} |
||||
} |
||||
|
||||
echo $re_data = json_encode($re_data); |
||||
exit; |
||||
?> |
||||
|
||||
<?php |
||||
//对象转数组 |
||||
function object2array($object) { |
||||
if (is_object($object)) { |
||||
foreach ($object as $key => $value) { |
||||
$array[$key] = $value; |
||||
} |
||||
} |
||||
else { |
||||
$array = $object; |
||||
} |
||||
return $array; |
||||
} |
||||
?> |
@ -1,90 +0,0 @@
@@ -1,90 +0,0 @@
|
||||
<?php |
||||
/* |
||||
@name:TinyPNG图片压缩接口 |
||||
@author:xiaoz.me |
||||
*/ |
||||
|
||||
//载入SDK |
||||
require_once("../sdk/tinypng/Tinify/Exception.php"); |
||||
require_once("../sdk/tinypng/Tinify/ResultMeta.php"); |
||||
require_once("../sdk/tinypng/Tinify/Result.php"); |
||||
require_once("../sdk/tinypng/Tinify/Source.php"); |
||||
require_once("../sdk/tinypng/Tinify/Client.php"); |
||||
require_once("../sdk/tinypng/Tinify.php"); |
||||
//载入配置文件 |
||||
require_once("../config.php"); |
||||
|
||||
//获取图片URL地址 |
||||
$imgurl = $_GET['url']; |
||||
//获取URI |
||||
$imguri = str_replace($config['domain'],"",$imgurl); |
||||
//echo $imguri; |
||||
//仅获取域名 |
||||
$domain = str_replace("http://","",$config['domain']); |
||||
$domain = str_replace("https://","",$domain); |
||||
$domain = explode("/",$domain); //最终的目的是取出域名 |
||||
|
||||
|
||||
//搜索域名是否匹配 |
||||
$sdomain = strpos($imgurl,$domain[0]); |
||||
|
||||
if($sdomain == false) { |
||||
echo '地址不合法'; |
||||
exit; |
||||
} |
||||
//合法的域名,那我们继续咯 |
||||
//在判断下目录是否合法 |
||||
$imgdir = explode("/",$imguri); |
||||
//如果目录不是访客目录也不是管理员目录,那就不处理咯 |
||||
if(($imgdir[0] != $config['userdir']) && ($imgdir[0] != $config['admindir'])) { |
||||
echo '地址不合法'; |
||||
exit; |
||||
} |
||||
//ok,上面都过了,判断下图片类型 |
||||
//使用exif_imagetype函数来判断文件类型 |
||||
$imguri = '../'.$imguri; |
||||
$file_type = exif_imagetype($imguri); |
||||
switch ( $file_type ) |
||||
{ |
||||
case IMAGETYPE_JPEG: |
||||
tinypng($config['tinypng'],$config['domain'],$imguri,$imgurl); |
||||
$redata = array("code" => 1,"type" => $file_type); |
||||
echo json_encode($redata); |
||||
break; |
||||
case IMAGETYPE_PNG: |
||||
tinypng($config['tinypng'],$config['domain'],$imguri,$imgurl); |
||||
$redata = array("code" => 1,"type" => $file_type); |
||||
echo json_encode($redata); |
||||
break; |
||||
default: |
||||
$redata = array("code" => 0,"type" => $file_type); |
||||
echo json_encode($redata); |
||||
break; |
||||
} |
||||
?> |
||||
|
||||
<?php |
||||
//压缩图片 |
||||
function tinypng($api,$host,$imgfile,$imgurl){ |
||||
if($api == '') { |
||||
echo '未开启TinyPNG'; |
||||
exit; |
||||
} |
||||
else{ |
||||
Tinify\setKey($api); |
||||
Tinify\fromFile($imgfile)->toFile($imgfile); |
||||
//获取主机名 |
||||
$host = $host."/api/"; |
||||
//对压缩后的图片鉴黄 |
||||
$ch = curl_init($host."identify.php?url=".$imgurl) ; |
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // https请求 不验证>证书和hosts |
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); |
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true) ; // 获取数据返回 |
||||
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true) ; // 在启用 CURLOPT_RETURNTRANSFER 时候将获取数据返回 |
||||
$output = curl_exec($ch) ; |
||||
curl_close($ch); |
||||
|
||||
return $imgfile; |
||||
} |
||||
} |
||||
?> |
@ -1,4 +0,0 @@
@@ -1,4 +0,0 @@
|
||||
//LayUI
|
||||
layui.use('element', function(){ |
||||
var element = layui.element; |
||||
}); |
Before Width: | Height: | Size: 24 KiB |
@ -1,83 +0,0 @@
@@ -1,83 +0,0 @@
|
||||
$(document).ready(function() |
||||
{ |
||||
$("#fileuploader").uploadFile({ |
||||
url:"./upload.php", |
||||
maxFileSize:"2097152", |
||||
allowedTypes:"jpg,jpeg,png,gif,bmp", |
||||
showStatusAfterSuccess:"false", |
||||
dragdropWidth:"100%", |
||||
|
||||
|
||||
//允许上传最大文件数量
|
||||
//showDone:"false"
|
||||
//showQueueDiv: "output"
|
||||
onSubmit:function(files) |
||||
{ |
||||
$("#loading").show(); |
||||
}, |
||||
onSuccess:function(files,data,xhr,pd) |
||||
{ |
||||
var eroticism = $("#eroticism").html(); //鉴黄状态
|
||||
var tinypng = $("#tinypng").html(); //压缩状态
|
||||
$("#loading").hide(); |
||||
$("#relink").show(); |
||||
//console.log(data);
|
||||
var imginfo = new Function("return" + data)(); |
||||
document.getElementById("linkurl").value = imginfo.linkurl; |
||||
document.getElementById("htmlurl").value = "<img src = '" + imginfo.linkurl + "' />"; |
||||
document.getElementById("mdurl").value = "![](" + imginfo.linkurl + ")"; |
||||
document.getElementById("bbcode").value = "[img]" + imginfo.linkurl + "[/img]"; |
||||
$("#show_img").attr('src',imginfo.linkurl); |
||||
$("#img-url").attr('href',imginfo.linkurl); |
||||
$("#img-box").show(); |
||||
//如果启用了鉴黄
|
||||
if(eroticism == 1) { |
||||
identify(imginfo.linkurl); |
||||
} |
||||
//如果启用了图片压缩
|
||||
if(tinypng == 1) { |
||||
compression(imginfo.linkurl); |
||||
} |
||||
} |
||||
}); |
||||
}); |
||||
|
||||
//复制按钮
|
||||
function copy(url) { |
||||
new clipBoard($("#url"),{ |
||||
copy: function() { |
||||
return $("#" + url).val(); |
||||
}, |
||||
afterCopy: function() { |
||||
$("#msg").show(); |
||||
$("#msg").fadeOut(1500); |
||||
} |
||||
}); |
||||
} |
||||
//鉴黄
|
||||
function identify(imgurl) { |
||||
$.get("./api/identify.php?url="+imgurl,function(data,status){ |
||||
var reinfo = new Function("return" + data)(); |
||||
if((reinfo.code == 0) && (reinfo.result >= 1)) { |
||||
alert('请勿上传违规图片!'); |
||||
return false; |
||||
} |
||||
//请求失败,重复执行
|
||||
while(reinfo.code == null) { |
||||
$.get("./api/identify.php?url="+imgurl,function(data,status){ |
||||
var reinfo = new Function("return" + data)(); |
||||
if((reinfo.code == 0) && (reinfo.result >= 1)) { |
||||
alert('请勿上传违规图片!'); |
||||
return false; |
||||
} |
||||
}); |
||||
} |
||||
}); |
||||
} |
||||
//图片压缩
|
||||
function compression(imgurl) { |
||||
$.get("./api/tinypng.php?url="+imgurl,function(data,status){ |
||||
return true; |
||||
}); |
||||
} |
||||
|
@ -1,2 +0,0 @@
@@ -1,2 +0,0 @@
|
||||
/** layui-v2.2.5 MIT License By https://www.layui.com */ |
||||
html #layuicss-skincodecss{display:none;position:absolute;width:1989px}.layui-code-h3,.layui-code-view{position:relative;font-size:12px}.layui-code-view{display:block;margin:10px 0;padding:0;border:1px solid #e2e2e2;border-left-width:6px;background-color:#F2F2F2;color:#333;font-family:Courier New}.layui-code-h3{padding:0 10px;height:32px;line-height:32px;border-bottom:1px solid #e2e2e2}.layui-code-h3 a{position:absolute;right:10px;top:0;color:#999}.layui-code-view .layui-code-ol{position:relative;overflow:auto}.layui-code-view .layui-code-ol li{position:relative;margin-left:45px;line-height:20px;padding:0 5px;border-left:1px solid #e2e2e2;list-style-type:decimal-leading-zero;*list-style-type:decimal;background-color:#fff}.layui-code-view pre{margin:0}.layui-code-notepad{border:1px solid #0C0C0C;border-left-color:#3F3F3F;background-color:#0C0C0C;color:#C2BE9E}.layui-code-notepad .layui-code-h3{border-bottom:none}.layui-code-notepad .layui-code-ol li{background-color:#3F3F3F;border-left:none} |
Before Width: | Height: | Size: 5.8 KiB |
Before Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 5.7 KiB |
Before Width: | Height: | Size: 701 B |
Before Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 231 KiB |
Before Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 5.4 KiB |
Before Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 4.0 KiB |
Before Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 7.3 KiB |
Before Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 5.0 KiB |
Before Width: | Height: | Size: 5.1 KiB |
Before Width: | Height: | Size: 9.6 KiB |
Before Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 7.9 KiB |
Before Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 3.9 KiB |
Before Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 5.6 KiB |
Before Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 5.2 KiB |
Before Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 4.0 KiB |
Before Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 5.7 KiB |
Before Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 777 B |
Before Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 5.7 KiB |
Before Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 5.2 KiB |
Before Width: | Height: | Size: 4.0 KiB |
Before Width: | Height: | Size: 4.1 KiB |
@ -1,2 +0,0 @@
@@ -1,2 +0,0 @@
|
||||
/** layui-v2.2.5 MIT License By https://www.layui.com */ |
||||
;layui.define("jquery",function(e){"use strict";var i=layui.$,n=(layui.hint(),layui.device(),{config:{},set:function(e){var n=this;return n.config=i.extend({},n.config,e),n},on:function(e,i){return layui.onevent.call(this,t,e,i)}}),t="carousel",a="layui-this",l=">*[carousel-item]>*",o="layui-carousel-left",r="layui-carousel-right",d="layui-carousel-prev",s="layui-carousel-next",u="layui-carousel-arrow",c="layui-carousel-ind",m=function(e){var t=this;t.config=i.extend({},t.config,n.config,e),t.render()};m.prototype.config={width:"600px",height:"280px",full:!1,arrow:"hover",indicator:"inside",autoplay:!0,interval:3e3,anim:"",trigger:"click",index:0},m.prototype.render=function(){var e=this,n=e.config;n.elem=i(n.elem),n.elem[0]&&(e.elemItem=n.elem.find(l),n.index<0&&(n.index=0),n.index>=e.elemItem.length&&(n.index=e.elemItem.length-1),n.interval<800&&(n.interval=800),n.full?n.elem.css({position:"fixed",width:"100%",height:"100%",zIndex:9999}):n.elem.css({width:n.width,height:n.height}),n.elem.attr("lay-anim",n.anim),e.elemItem.eq(n.index).addClass(a),e.elemItem.length<=1||(e.indicator(),e.arrow(),e.autoplay(),e.events()))},m.prototype.reload=function(e){var n=this;clearInterval(n.timer),n.config=i.extend({},n.config,e),n.render()},m.prototype.prevIndex=function(){var e=this,i=e.config,n=i.index-1;return n<0&&(n=e.elemItem.length-1),n},m.prototype.nextIndex=function(){var e=this,i=e.config,n=i.index+1;return n>=e.elemItem.length&&(n=0),n},m.prototype.addIndex=function(e){var i=this,n=i.config;e=e||1,n.index=n.index+e,n.index>=i.elemItem.length&&(n.index=0)},m.prototype.subIndex=function(e){var i=this,n=i.config;e=e||1,n.index=n.index-e,n.index<0&&(n.index=i.elemItem.length-1)},m.prototype.autoplay=function(){var e=this,i=e.config;i.autoplay&&(e.timer=setInterval(function(){e.slide()},i.interval))},m.prototype.arrow=function(){var e=this,n=e.config,t=i(['<button class="layui-icon '+u+'" lay-type="sub">'+("updown"===n.anim?"":"")+"</button>",'<button class="layui-icon '+u+'" lay-type="add">'+("updown"===n.anim?"":"")+"</button>"].join(""));n.elem.attr("lay-arrow",n.arrow),n.elem.find("."+u)[0]&&n.elem.find("."+u).remove(),n.elem.append(t),t.on("click",function(){var n=i(this),t=n.attr("lay-type");e.slide(t)})},m.prototype.indicator=function(){var e=this,n=e.config,t=e.elemInd=i(['<div class="'+c+'"><ul>',function(){var i=[];return layui.each(e.elemItem,function(e){i.push("<li"+(n.index===e?' class="layui-this"':"")+"></li>")}),i.join("")}(),"</ul></div>"].join(""));n.elem.attr("lay-indicator",n.indicator),n.elem.find("."+c)[0]&&n.elem.find("."+c).remove(),n.elem.append(t),"updown"===n.anim&&t.css("margin-top",-(t.height()/2)),t.find("li").on("hover"===n.trigger?"mouseover":n.trigger,function(){var t=i(this),a=t.index();a>n.index?e.slide("add",a-n.index):a<n.index&&e.slide("sub",n.index-a)})},m.prototype.slide=function(e,i){var n=this,l=n.elemItem,u=n.config,c=u.index,m=u.elem.attr("lay-filter");n.haveSlide||("sub"===e?(n.subIndex(i),l.eq(u.index).addClass(d),setTimeout(function(){l.eq(c).addClass(r),l.eq(u.index).addClass(r)},50)):(n.addIndex(i),l.eq(u.index).addClass(s),setTimeout(function(){l.eq(c).addClass(o),l.eq(u.index).addClass(o)},50)),setTimeout(function(){l.removeClass(a+" "+d+" "+s+" "+o+" "+r),l.eq(u.index).addClass(a),n.haveSlide=!1},300),n.elemInd.find("li").eq(u.index).addClass(a).siblings().removeClass(a),n.haveSlide=!0,layui.event.call(this,t,"change("+m+")",{index:u.index,prevIndex:c,item:l.eq(u.index)}))},m.prototype.events=function(){var e=this,i=e.config;i.elem.data("haveEvents")||(i.elem.on("mouseenter",function(){clearInterval(e.timer)}).on("mouseleave",function(){e.autoplay()}),i.elem.data("haveEvents",!0))},n.render=function(e){var i=new m(e);return i},e(t,n)}); |
@ -1,2 +0,0 @@
@@ -1,2 +0,0 @@
|
||||
/** layui-v2.2.5 MIT License By https://www.layui.com */ |
||||
;layui.define("jquery",function(e){"use strict";var a=layui.$,l="http://www.layui.com/doc/modules/code.html";e("code",function(e){var t=[];e=e||{},e.elem=a(e.elem||".layui-code"),e.about=!("about"in e)||e.about,e.elem.each(function(){t.push(this)}),layui.each(t.reverse(),function(t,i){var c=a(i),o=c.html();(c.attr("lay-encode")||e.encode)&&(o=o.replace(/&(?!#?[a-zA-Z0-9]+;)/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,""")),c.html('<ol class="layui-code-ol"><li>'+o.replace(/[\r\t\n]+/g,"</li><li>")+"</li></ol>"),c.find(">.layui-code-h3")[0]||c.prepend('<h3 class="layui-code-h3">'+(c.attr("lay-title")||e.title||"code")+(e.about?'<a href="'+l+'" target="_blank">layui.code</a>':"")+"</h3>");var d=c.find(">.layui-code-ol");c.addClass("layui-box layui-code-view"),(c.attr("lay-skin")||e.skin)&&c.addClass("layui-code-"+(c.attr("lay-skin")||e.skin)),(d.find("li").length/100|0)>0&&d.css("margin-left",(d.find("li").length/100|0)+"px"),(c.attr("lay-height")||e.height)&&d.css("max-height",c.attr("lay-height")||e.height)})})}).addcss("modules/code.css","skincodecss"); |
@ -1,2 +0,0 @@
@@ -1,2 +0,0 @@
|
||||
/** layui-v2.2.5 MIT License By https://www.layui.com */ |
||||
;layui.define("jquery",function(e){"use strict";var l=layui.$,o=function(e){},t='<i class="layui-anim layui-anim-rotate layui-anim-loop layui-icon "></i>';o.prototype.load=function(e){var o,i,n,r,a=this,c=0;e=e||{};var f=l(e.elem);if(f[0]){var m=l(e.scrollElem||document),u=e.mb||50,s=!("isAuto"in e)||e.isAuto,v=e.end||"没有更多了",y=e.scrollElem&&e.scrollElem!==document,d="<cite>加载更多</cite>",h=l('<div class="layui-flow-more"><a href="javascript:;">'+d+"</a></div>");f.find(".layui-flow-more")[0]||f.append(h);var p=function(e,t){e=l(e),h.before(e),t=0==t||null,t?h.html(v):h.find("a").html(d),i=t,o=null,n&&n()},g=function(){o=!0,h.find("a").html(t),"function"==typeof e.done&&e.done(++c,p)};if(g(),h.find("a").on("click",function(){l(this);i||o||g()}),e.isLazyimg)var n=a.lazyimg({elem:e.elem+" img",scrollElem:e.scrollElem});return s?(m.on("scroll",function(){var e=l(this),t=e.scrollTop();r&&clearTimeout(r),i||(r=setTimeout(function(){var i=y?e.height():l(window).height(),n=y?e.prop("scrollHeight"):document.documentElement.scrollHeight;n-t-i<=u&&(o||g())},100))}),a):a}},o.prototype.lazyimg=function(e){var o,t=this,i=0;e=e||{};var n=l(e.scrollElem||document),r=e.elem||"img",a=e.scrollElem&&e.scrollElem!==document,c=function(e,l){var o=n.scrollTop(),r=o+l,c=a?function(){return e.offset().top-n.offset().top+o}():e.offset().top;if(c>=o&&c<=r&&!e.attr("src")){var m=e.attr("lay-src");layui.img(m,function(){var l=t.lazyimg.elem.eq(i);e.attr("src",m).removeAttr("lay-src"),l[0]&&f(l),i++})}},f=function(e,o){var f=a?(o||n).height():l(window).height(),m=n.scrollTop(),u=m+f;if(t.lazyimg.elem=l(r),e)c(e,f);else for(var s=0;s<t.lazyimg.elem.length;s++){var v=t.lazyimg.elem.eq(s),y=a?function(){return v.offset().top-n.offset().top+m}():v.offset().top;if(c(v,f),i=s,y>u)break}};if(f(),!o){var m;n.on("scroll",function(){var e=l(this);m&&clearTimeout(m),m=setTimeout(function(){f(null,e)},50)}),o=!0}return f},e("flow",new o)}); |