diff --git a/README.md b/README.md index 0521b10..eb60b27 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ ImgURL普通版和捐赠版功能上没有任何区别,不过您可以请xiaoz #### 捐赠列表 * 2018-05-02 lackk.com 捐赠30元 +* 2018-05-04 zip30.com 捐赠30元 ### 鸣谢 ImgURL的诞生离不开以下开源项目。 diff --git a/admin/delete.php b/admin/delete.php index e986bdb..2328fe2 100644 --- a/admin/delete.php +++ b/admin/delete.php @@ -1,13 +1,27 @@ delete($id); + + // 判断类型 + switch ($type) { + case 'sm': + $pic->deletesm($id); + break; + + default: + //删除图片 + $pic->delete($id); + break; + } + ?> \ No newline at end of file diff --git a/admin/senioradmin.php b/admin/senioradmin.php index 6f93672..250d879 100644 --- a/admin/senioradmin.php +++ b/admin/senioradmin.php @@ -81,6 +81,7 @@ 压缩 + 复制 删除 diff --git a/admin/smadmin.php b/admin/smadmin.php new file mode 100644 index 0000000..4f1e6b0 --- /dev/null +++ b/admin/smadmin.php @@ -0,0 +1,97 @@ +querysm($page); + //var_dump($imgs); + + $up = (int)$page - 1; + if($up <= 0){ + $up = 1; + } + $down = (int)$page +1; +?> + +
+
+
+ + +
+ +
+
+ + +
+ +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ID图片路径(点击可查看)IP日期操作
+ 复制 + 删除 +
+ + +
+ +
+ +
+ + + +
+
+ \ No newline at end of file diff --git a/db/imgurl.db3 b/db/imgurl.db3 index 4b2de03..b0aa44c 100644 Binary files a/db/imgurl.db3 and b/db/imgurl.db3 differ diff --git a/dispose.php b/dispose.php index fa3a6e6..39b2122 100644 --- a/dispose.php +++ b/dispose.php @@ -1,4 +1,5 @@ update("imginfo",["level" => $level],["id" => $id]); $dispose['level'] = $level; } - //返回json数据 $dispose['code'] = 1; $dispose = json_encode($dispose); diff --git a/functions/class/class.admin.php b/functions/class/class.admin.php index ff41f31..e6e5cf8 100644 --- a/functions/class/class.admin.php +++ b/functions/class/class.admin.php @@ -155,6 +155,59 @@ } } + //查询SM.MS图片 + //查询图片 + function querysm($page){ + $config = $this->config; + $database = $this->database; + + //分页计算 + $start = ($page - 1) * 12; + //$end = $page * 12; + + if(($page == '') || (!isset($page))) { + $page = 1; + } + + //要查询的条数 + $num = 12; + + //判断类型 + $datas = $database->select("sm", "*", [ + "ORDER" => ["id" => "DESC"], + "LIMIT" => [$start,$num] + ]); + return $datas; + } + //删除SM.MS图片 + function deletesm($id){ + $config = $this->config; + $database = $this->database; + //先查询数据库 + $query = $database->get("sm","*",[ + "id" => $id + ]); + $delete = $database->delete("sm", [ + "AND" => [ + "id" => $id + ] + ]); + //请求接口删除图片 + $curl = curl_init($query['delete']); + + curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36"); + curl_setopt($curl, CURLOPT_FAILONERROR, true); + curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); + #设置超时时间,最小为1s(可选) + curl_setopt($curl , CURLOPT_TIMEOUT, 2); + + $html = curl_exec($curl); + curl_close($curl); + echo 'ok'; + } } $pic = new Admin($config,$database); diff --git a/functions/class/class.sm.php b/functions/class/class.sm.php new file mode 100644 index 0000000..e69de29 diff --git a/functions/class/class.user.php b/functions/class/class.user.php index 6eff2e2..c30d304 100644 --- a/functions/class/class.user.php +++ b/functions/class/class.user.php @@ -104,6 +104,29 @@ exit; } } + //获取访客真实IP + function getip(){ + if (getenv('HTTP_CLIENT_IP')) { + $ip = getenv('HTTP_CLIENT_IP'); + } + elseif (getenv('HTTP_X_FORWARDED_FOR')) { + $ip = getenv('HTTP_X_FORWARDED_FOR'); + } + elseif (getenv('HTTP_X_FORWARDED')) { + $ip = getenv('HTTP_X_FORWARDED'); + } + elseif (getenv('HTTP_FORWARDED_FOR')) { + $ip = getenv('HTTP_FORWARDED_FOR'); + + } + elseif (getenv('HTTP_FORWARDED')) { + $ip = getenv('HTTP_FORWARDED'); + } + else { + $ip = $_SERVER['REMOTE_ADDR']; + } + return $ip; + } } diff --git a/functions/sm.php b/functions/sm.php new file mode 100644 index 0000000..2be4abb --- /dev/null +++ b/functions/sm.php @@ -0,0 +1,59 @@ +getip(); + //获取访客UA + $sm['ua'] = $_SERVER['HTTP_USER_AGENT']; + //获取当前时间 + $sm['date'] = date('Y-m-d',time()); + //获取图片URL + $sm['url'] = $data['url']; + //获取删除链接 + $sm['delete'] = $data['delete']; + + //进行基本的判断 + if((!isset($data)) || ($data == '') || (!is_array($data))) { + echo '获取数据失败!'; + exit; + } + //再次判断地址是否合法 + if(!filter_var($sm['url'], FILTER_VALIDATE_URL)) { + echo '不是合法的地址!'; + exit; + } + if(!filter_var($sm['delete'], FILTER_VALIDATE_URL)) { + echo '不是合法的地址!'; + exit; + } + + //写入数据库 + $last_user_id = $database->insert("sm", [ + "ip" => $sm['ip'], + "ua" => $sm['ua'], + "date" => $sm['date'], + "url" => $sm['url'], + "delete"=> $sm['delete'] + ]); + //返回ID + $smid = $database->id(); + if($last_user_id) { + $redata = array( + "code" => 1, + "id" => $smid, + "msg" => "写入成功!" + ); + echo json_encode($redata); + exit; + } + else{ + $redata = array( + "code" => 0, + "id" => $smid, + "msg" => "该图片可能已经上传过!" + ); + echo json_encode($redata); + } +?> \ No newline at end of file diff --git a/functions/upload.php b/functions/upload.php index 316726b..c1ebc75 100644 --- a/functions/upload.php +++ b/functions/upload.php @@ -16,7 +16,7 @@ } //获取上传者信息 - $ip = $_SERVER['REMOTE_ADDR']; + $ip = $basis->getip(); $ua = $_SERVER['HTTP_USER_AGENT']; $date = date('Y-m-d',time()); //载入上传类 diff --git a/functions/version.txt b/functions/version.txt index 957918f..03298bf 100644 --- a/functions/version.txt +++ b/functions/version.txt @@ -1 +1 @@ -v1.0(20180502) \ No newline at end of file +v1.1(20180504) \ No newline at end of file diff --git a/index.php b/index.php index ae7ee15..73b540b 100644 --- a/index.php +++ b/index.php @@ -6,6 +6,7 @@
+
注意:您上传的图片将会公开显示,勿上传隐私图片。游客限制每天5张,最大支持2M
diff --git a/sm.php b/sm.php new file mode 100644 index 0000000..fe07fa5 --- /dev/null +++ b/sm.php @@ -0,0 +1,68 @@ + + +
+
+
+
该功能可以将图片上传至SM.MS图床。
+ + + +
+
+
+ +
+
+
+ +
+
+ +
+ + + \ No newline at end of file diff --git a/static/embed.js b/static/embed.js index 91ffc57..35b1a4b 100644 --- a/static/embed.js +++ b/static/embed.js @@ -1,3 +1,7 @@ +//layui 根目录配置 +layui.config({ + base: '/static/layui/', +}) //载入layui组建 layui.use(['layer', 'form','element','upload','flow'], function(){ var form = layui.form; @@ -10,10 +14,11 @@ layui.use(['layer', 'form','element','upload','flow'], function(){ // elem:'#found-img img' // }); - //拖拽上传 + //首页拖拽上传 upload.render({ elem: '#upimg' ,url: 'functions/upload.php' + ,size: 2048 //限制上传大小为2M ,before: function(obj){ //obj参数包含的信息,跟 choose回调完全一致,可参见上文。 layer.load(); //上传loading } @@ -48,6 +53,38 @@ layui.use(['layer', 'form','element','upload','flow'], function(){ } } }); + //上传到sm.ms + upload.render({ + elem: '#sm' + ,url: 'https://sm.ms/api/upload' + ,before: function(obj){ //obj参数包含的信息,跟 choose回调完全一致,可参见上文。 + layer.load(); //上传loading + } + ,done: function(res){ + //如果上传失败 + if(res.code == 'error'){ + layer.open({ + title: '温馨提示' + ,content: res.msg + }); + layer.closeAll('loading'); + } + else if(res.code == 'success'){ + layer.closeAll('loading'); + $("#showpic a").attr('href',res.data.url); + $("#showpic img").attr('src',res.data.url); + $("#url").val(res.data.url); + $("#html").val(""); + $("#markdown").val("![](" + res.data.url + ")"); + $("#bbcode").val("[img]" + res.data.url + "[/img]"); + $("#upok").show(); + $.post("./functions/sm.php",{data:res.data},function(data,status){ + + }); + } + } + }); + //上传到sm.ms end }); //复制链接 @@ -69,6 +106,25 @@ function copy(info){ layer.msg('复制成功!', {time: 2000}) }); } +//后台复制URL +function copyurl(url){ + var copy = new clipBoard(document.getElementById('adminpic'), { + beforeCopy: function() { + + }, + copy: function() { + return url; + }, + afterCopy: function() { + + } + }); + layui.use('layer', function(){ + var layer = layui.layer; + + layer.msg('链接已复制!', {time: 2000}) + }); +} //用户登录方法 function login(){ @@ -128,6 +184,39 @@ function adminshow(imgurl,id){ }); } +//后台管理员查看SM.MS图片 +function smshow(imgurl,id){ + var showimg = "
"; + layui.use('layer', function(){ + var layer = layui.layer; + layer.open({ + type: 1, + title:"图片预览", + area: ['80%', '80%'], + content: showimg, + btn: ['压缩', '删除'], + yes: function(index, layero){ + layer.msg('SM.MS图片不支持压缩!', {time: 2000}) + } + //删除按钮 + ,btn2: function(index, layero){ + layer.confirm('确认删除?', {icon: 3, title:'温馨提示!'}, function(index){ + $.get("./delete.php?type=sm&id="+id,function(data,status){ + if(data == 'ok') { + $("#imgid"+id).remove(); + } + else{ + alert(data); + } + }); + + layer.close(index); + }); + } + }); + }); +} + //删除某张图片 function deleteimg(id){ layer.confirm('确认删除?', {icon: 3, title:'温馨提示!'}, function(index){ @@ -143,6 +232,21 @@ function deleteimg(id){ layer.close(index); }); } +//删除SM.MS图片 +function deletesm(id){ + layer.confirm('确认删除?', {icon: 3, title:'温馨提示!'}, function(index){ + $.get("./delete.php?type=sm&id="+id,function(data,status){ + if(data == 'ok') { + $("#imgid"+id).remove(); + } + else{ + alert(data); + } + }); + + layer.close(index); + }); +} //取消图片可疑状态 function cdubious(id){ diff --git a/static/style.css b/static/style.css index 07a6efc..3f63e53 100644 --- a/static/style.css +++ b/static/style.css @@ -34,7 +34,7 @@ margin-left:auto; margin-right:auto; - margin-top:4em; + margin-top:2em; width:94.6%; left:0%; background-color:#F9F9F9; @@ -76,7 +76,7 @@ margin-right:auto; } .msg{ - width:100%; + /* width:100%; */ background-color:#f2f2f2; line-height: 1em; padding:12px; @@ -119,4 +119,43 @@ #about ul{ margin-top:1em; margin-bottom:1em; +} + +.smfile{ + width:100%; + height:188px; + border: 1px dashed #e2e2e2; + margin-top:2em; +} +.smfile .file { + position: relative; + display: inline-block; + /* background: #D0EEFF; */ + /* border: 1px solid #99D3F5; + border-radius: 4px; + padding: 4px 12px; */ + overflow: hidden; + color: #009688; + text-decoration: none; + text-indent: 0; + line-height: 188px; + display: block; + height: 100%; + text-align: center; + margin-left:auto; + margin-right:auto; + background-color: #F9F9F9; +} +.smfile .file input { + position: absolute; + font-size: 100px; + right: 0; + top: 0; + opacity: 0; +} +.smfile .file:hover { + /* background: #AADFFD; + border-color: #78C3F3; */ + color:#009688; + text-decoration: none; } \ No newline at end of file diff --git a/tpl/admin/footer.php b/tpl/admin/footer.php index 671961d..7807935 100644 --- a/tpl/admin/footer.php +++ b/tpl/admin/footer.php @@ -13,6 +13,6 @@ - + \ No newline at end of file diff --git a/tpl/admin/header.php b/tpl/admin/header.php index 4b244d8..02a7961 100644 --- a/tpl/admin/header.php +++ b/tpl/admin/header.php @@ -11,7 +11,7 @@ - + diff --git a/tpl/admin/left.php b/tpl/admin/left.php index aa72007..b29c758 100644 --- a/tpl/admin/left.php +++ b/tpl/admin/left.php @@ -17,6 +17,13 @@
可疑图片
+
  • + SM.MS管理 +
    +
    预览模式
    +
    管理模式
    +
    +
  • 系统设置
    diff --git a/tpl/user/footer.php b/tpl/user/footer.php index d40087d..6932df9 100644 --- a/tpl/user/footer.php +++ b/tpl/user/footer.php @@ -18,6 +18,6 @@ - + \ No newline at end of file diff --git a/tpl/user/header.php b/tpl/user/header.php index 6f85924..d9a0846 100644 --- a/tpl/user/header.php +++ b/tpl/user/header.php @@ -12,7 +12,7 @@ - + @@ -26,6 +26,7 @@