diff --git a/admin/ajax_apply.php b/admin/ajax_apply.php new file mode 100644 index 0000000..a6a79fe --- /dev/null +++ b/admin/ajax_apply.php @@ -0,0 +1,54 @@ +window.location.href='./login.php';"); +header('Content-Type:application/json'); + +$set= isset($_GET['set']) ? $_GET['set'] : null; +switch($set) { + //修改分组 + case 'status': + $id = $_POST['id']; + $sw = $_POST['status']; + $sql = "UPDATE `lylme_apply` SET `apply_status` = '".$sw."' WHERE `lylme_apply`.`apply_id` = ".$id.";"; + if($sw==1) { + if ($DB->query($sql)) { + $applyres = $DB->get_row("SELECT * FROM `lylme_apply` WHERE `apply_id` = ".$id); + $name=strip_tags(daddslashes($applyres['apply_name'])); + $url=strip_tags(daddslashes($applyres['apply_url'])); + $icon=daddslashes($applyres['apply_icon']); + $group_id=strip_tags(daddslashes($applyres['apply_group'])); + $mail=strip_tags(daddslashes($applyres['apply_mail'])); + $link_order = $DB->count('select MAX(id) from `lylme_links`')+1; + $sql1 = "INSERT INTO `lylme_links` (`id`, `name`, `group_id`, `url`, `icon`, `PS`,`link_order`) VALUES (NULL, '" . $name . "', '" . $group_id . "', '" . $url . "', '" . $icon . "', '" . $mail . "的提交 ', '" . $link_order . "');"; + if($DB->query($sql1)) { + exit('{"code": "200","msg":"成功!网站已成功收录!"}'); + } else { + exit('{"code": "-1","操作失败!原因:\n'.$DB->error().'"}'); + } + } + } else if($sw==2){ + if ($DB->query($sql)) { + exit('{"code": "200","msg":"操作成功!"}'); + } + else{ + exit('{"code": "-1","操作失败!原因:\n'.$DB->error().'"}'); + } + } + else{ + exit('{"code": "-2","操作失败!-2"}'); + } + break; + case 'delete': + $id = $_POST['id']; + $delsql = 'DELETE FROM `lylme_apply` WHERE apply_id =' . $id; + if ($DB->query($delsql)) { + exit('{"code": "200","msg":"操作成功!"}'); + }else{ + exit('{"code": "-2","操作失败!-2"}'); + } + break; + default: + exit('error'); + break; +} \ No newline at end of file diff --git a/admin/ajax_link.php b/admin/ajax_link.php index 52994ac..41336ed 100644 --- a/admin/ajax_link.php +++ b/admin/ajax_link.php @@ -50,33 +50,12 @@ switch($submit) { //获取链接信息 case 'geturl': - function get_head($url) { - ini_set("user_agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36 Edg/101.0.1210.39 Lylme/11.24"); - $opts = array( - 'http'=>array( - 'method'=>"GET", - 'timeout'=>4 - ) - ); - $contents = @file_get_contents("compress.zlib://".$url, false, stream_context_create($opts)); - preg_match('/(.*?)<\/title>/is',$contents,$title); // 获取网站标题 - preg_match('/<link rel=".*?icon" * href="(.*?)".*?>/is', $contents,$icon); // 获取网站icon - preg_match('/<meta.+?charset=[^\w]?([-\w]+)/i', $contents,$charset); //获取网站编码 - $get_heads = array(); - $get_heads['charset']=$charset[1]; - $get_heads['title'] = str_replace("'","\"",preg_replace("/\s/","",$title[1])); - $get_heads['icon'] = get_urlpath(preg_replace("/\s/","",$icon[1]),$url); - if(strtolower($get_heads['charset'])!="uft-8"){ - // 将非UTF-8编码转换 - $get_heads['title'] = iconv($get_heads['charset'], "UTF-8",$get_heads['title']); - $get_heads['icon'] = iconv($get_heads['charset'], "UTF-8",$get_heads['icon']); - } - return $get_heads; - } - $head = get_head($_POST['url']); - if(empty($head['title'])&&empty($head['icon']))exit('Unable to access'); - header('Content-Type:application/json'); - exit('{"title": "'.$head['title'].'", "icon": "'.$head['icon'].'","charset": "'.$head['charset'].'"}'); + $url = $_GET['url']; + $head = get_head($url); + if(empty($head['title'])&&empty($head['icon']))exit('Unable to access'); + //download_img($url,head['icon']); + header('Content-Type:application/json'); + exit(json_encode($head,JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE)); //输出json break; //检测更新 case 'update': diff --git a/admin/apply.php b/admin/apply.php index 20ff3ed..eb154fd 100644 --- a/admin/apply.php +++ b/admin/apply.php @@ -113,43 +113,8 @@ elseif ($set == 'edit_submit') { $sql = "UPDATE `lylme_apply` SET `apply_name` = '" . $name . "', `apply_group` = '" . $group . "',`apply_icon` = '" . $icon . "',`apply_url` = '" . $url . "' WHERE `lylme_apply`.`apply_id` = '" . $id . "';"; if ($DB->query($sql)) echo '<script>alert("修改 ' . $name . ' 成功!");window.location.href="./apply.php";</script>'; else echo '<script>alert("' . $sql . '修改失败!原因:\n'.$DB->error().'");history.go(-1);</script>'; } -} elseif ($set == 'delete') { - $id = $_GET['id']; - $delsql = 'DELETE FROM `lylme_apply` WHERE apply_id =' . $id; - if ($DB->query($delsql)) echo '<script>alert("删除成功!");window.location.href="./apply.php";</script>'; else echo '<script>alert("删除失败!");history.go(-1);</script>'; } -elseif ($set == 'status') { - $id = $_GET['id']; - $sw = $_GET['sw']; - $sql = "UPDATE `lylme_apply` SET `apply_status` = '".$sw."' WHERE `lylme_apply`.`apply_id` = ".$id.";"; - if($sw==1) { - if ($DB->query($sql)) { - $applyres = $DB->get_row("SELECT * FROM `lylme_apply` WHERE `apply_id` = ".$id); - $name=strip_tags(daddslashes($applyres['apply_name'])); - $url=strip_tags(daddslashes($applyres['apply_url'])); - $icon=daddslashes($applyres['apply_icon']); - $group_id=strip_tags(daddslashes($applyres['apply_group'])); - $mail=strip_tags(daddslashes($applyres['apply_mail'])); - $link_order = $DB->count('select MAX(id) from `lylme_links`')+1; - $sql1 = "INSERT INTO `lylme_links` (`id`, `name`, `group_id`, `url`, `icon`, `PS`,`link_order`) VALUES (NULL, '" . $name . "', '" . $group_id . "', '" . $url . "', '" . $icon . "', '" . $mail . "的提交 ', '" . $link_order . "');"; - if($DB->query($sql1)) { - echo '<script>alert("成功!网站已成功收录!");window.location.href="./apply.php";</script>'; - } else { - echo '<script>alert("收录失败!错误原因:\n'.$DB->error().'");history.go(-1);</script>'; - } - } - } else if($sw==2){ - if ($DB->query($sql)) { - echo '<script>window.location.href="./apply.php";</script>'; - } - else{ - echo '<script>alert("审核失败!原因:\n'.$DB->error().'");history.go(-1);</script>'; - } - } - else{ - echo '<script>alert("审核失败!未知参数");history.go(-1);</script>'; - } -} else { + else { echo '<pre>'.$conf['apply_gg'].'<br><a href="./apply.php?set=conf">修改</a></pre>'; echo '<div class="alert alert-info"> 收录申请统计: <b>' . $applyrows . '</b> 次<br/> @@ -170,7 +135,7 @@ elseif ($set == 'status') { 申请收录地址:<code>'. siteurl().'/apply</code> <a href="'. siteurl().'/apply" target="_blank">访问</a><br><br><sub>已审核的图标会被隐藏,点击图标可重新加载<br>部分网站图标一直处于加载或无法显示,可能原因:无法访问或跨域问题,建议建将图标本地化</sub></div>'; ?> - <div class="table-responsive"> + <div class="table-responsive" id="applylist"> <table class="table table-striped"> <thead><tr><th>序号</th><th>图标</th><th>名称</th><th>链接</th><th>访问</th><th>分组</th><th>审核</th><th>操作</th><th>申请时间</th></tr></thead> <tbody> @@ -206,12 +171,12 @@ elseif ($set == 'status') { echo '<font color="#3c763d">已通过</font>'; } else { echo ' - <a href="./apply.php?set=status&id=' . $res['apply_id'] . '&sw=1" class="btn btn-primary btn-xs" onclick="return confirm(\'是否通过该条申请?\');">通过</a>  - <a href="./apply.php?set=status&id=' . $res['apply_id'] . '&sw=2" class="btn btn-cyan btn-xs" onclick="return confirm(\'是否拒绝该条申请 ?\');">拒绝</a>'; + <button class="btn btn-primary btn-xs" onclick="status(' . $res['apply_id'] . ',1)">通过</button>  + <button class="btn btn-cyan btn-xs" onclick="status(' . $res['apply_id'] . ',2)">拒绝</a>'; } echo '</td><td>'; if($res["apply_status"]==0) {echo '<a href="./apply.php?set=edit&id=' . $res['apply_id'] . '" class="btn btn-info btn-xs">编辑</a> ';} - echo '<a href="./apply.php?set=delete&id=' . $res['apply_id'] . '" class="btn btn-xs btn-danger" onclick="return confirm(\'确定删除 ' . $res['apply_name'] . ' 的记录吗?\');">删除</a> </td> + echo ' <button class="btn btn-xs btn-danger" onclick="deletes(' . $res['apply_id'] . ')">删除</button> </td> <td>'.$res['apply_time'].'</td> </tr>'; } @@ -230,7 +195,59 @@ elseif ($set == 'status') { include './footer.php'; ?> <script src="https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery.lazyload/1.9.1/jquery.lazyload.min.js" type="application/javascript"></script> +<script src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/layer/3.1.1/layer.min.js" type="application/javascript"></script> <script> +function status(id,status){ + $.ajax({ + url:"ajax_apply.php?set=status", + type:"POST", + dataType:"json", + data:{id:id,status:status}, + success:function(data){ + if(data.code == '200'){ + layer.msg(data.msg); + $("#applylist").load(location.href+" #applylist>*",""); + return true; + } + else{ + layer.msg(data.msg); + return false; + } + }, + error:function(data){ + layer.msg('服务器错误'); + return false; + } + }); + +} +function deletes(id){ + if(!confirm("确定删除?")){ + return false; + } + $.ajax({ + url:"ajax_apply.php?set=delete", + type:"POST", + dataType:"json", + data:{id:id}, + success:function(data){ + if(data.code == '200'){ + layer.msg(data.msg); + $("#applylist").load(location.href+" #applylist>*",""); + return true; + } + else{ + layer.msg(data.msg); + return false; + } + }, + error:function(data){ + layer.msg('服务器错误'); + return false; + } + }); + +} $("img.lazy").lazyload({ threshold : 100 }); diff --git a/admin/css/coloris.min.css b/admin/css/coloris.min.css new file mode 100644 index 0000000..fe3033d --- /dev/null +++ b/admin/css/coloris.min.css @@ -0,0 +1 @@ +.clr-picker{display:none;flex-wrap:wrap;position:absolute;width:200px;z-index:1000;border-radius:10px;background-color:#fff;justify-content:space-between;box-shadow:0 0 5px rgba(0,0,0,.05),0 5px 20px rgba(0,0,0,.1);-moz-user-select:none;-webkit-user-select:none;user-select:none}.clr-picker.clr-open{display:flex}.clr-dark{background-color:#444}.clr-gradient{position:relative;width:100%;height:100px;margin-bottom:15px;border-radius:3px 3px 0 0;background-image:linear-gradient(rgba(0,0,0,0),#000),linear-gradient(90deg,#fff,currentColor);cursor:pointer}.clr-marker{position:absolute;width:12px;height:12px;margin:-6px 0 0 -6px;border:1px solid #fff;border-radius:50%;background-color:currentColor;cursor:pointer}.clr-picker input[type=range]::-webkit-slider-runnable-track{width:100%;height:8px}.clr-picker input[type=range]::-webkit-slider-thumb{width:8px;height:8px;-webkit-appearance:none}.clr-picker input[type=range]::-moz-range-track{width:100%;height:8px;border:0}.clr-picker input[type=range]::-moz-range-thumb{width:8px;height:8px;border:0}.clr-hue{background-image:linear-gradient(to right,red 0,#ff0 16.66%,#0f0 33.33%,#0ff 50%,#00f 66.66%,#f0f 83.33%,red 100%)}.clr-alpha,.clr-hue{position:relative;width:calc(100% - 40px);height:8px;margin:5px 20px;border-radius:4px}.clr-alpha span{display:block;height:100%;width:100%;border-radius:inherit;background-image:linear-gradient(90deg,rgba(0,0,0,0),currentColor)}.clr-alpha input,.clr-hue input{position:absolute;width:calc(100% + 16px);height:16px;left:-8px;top:-4px;margin:0;background-color:transparent;opacity:0;cursor:pointer;appearance:none;-webkit-appearance:none}.clr-alpha div,.clr-hue div{position:absolute;width:16px;height:16px;left:0;top:0;margin:-4px 0 0 -8px;border:2px solid #fff;border-radius:50%;background-color:currentColor;box-shadow:0 0 1px #888;pointer-events:none}.clr-alpha div:before{content:'';position:absolute;height:100%;width:100%;left:0;top:0;border-radius:50%;background-color:currentColor}.clr-swatches{order:2;width:calc(100% - 40px);margin:0 20px}.clr-swatches div{display:flex;flex-wrap:wrap;padding-bottom:12px;justify-content:center}.clr-swatches button{position:relative;width:20px;height:20px;margin:0 8px 6px 0;border:0;border-radius:50%;color:inherit;text-indent:-1000px;white-space:nowrap;overflow:hidden;cursor:pointer}.clr-swatches button:last-child,.clr-swatches button:nth-child(6n){margin-right:0}.clr-swatches button:after{content:'';display:block;position:absolute;width:100%;height:100%;left:0;top:0;border-radius:inherit;background-color:currentColor;box-shadow:inset 0 0 0 1px rgba(0,0,0,.1)}.clr-dark .clr-swatches button:after{box-shadow:inset 0 0 0 1px rgba(255,255,255,.3)}input.clr-color{order:1;width:120px;height:32px;margin:15px 20px 15px 0;padding:0 15px;border:1px solid #ddd;border-radius:16px;color:#444;background-color:#fff;font-family:sans-serif;font-size:14px;text-align:left;box-shadow:none}.clr-dark input.clr-color{color:#fff;border-color:#777;background-color:#555}input.clr-color:focus{outline:0;border:1px solid #aaa}.clr-preview{position:relative;width:32px;height:32px;margin:15px 0 20px 20px;border:0;border-radius:50%;overflow:hidden;cursor:pointer}.clr-preview:after,.clr-preview:before{content:'';position:absolute;height:100%;width:100%;left:0;top:0;border:1px solid #fff;border-radius:50%}.clr-preview:after{border:0;background-color:currentColor;box-shadow:inset 0 0 0 1px rgba(0,0,0,.1)}.clr-dark .clr-preview:after{box-shadow:inset 0 0 0 1px rgba(255,255,255,.5)}.clr-alpha div,.clr-color,.clr-hue div,.clr-marker{box-sizing:border-box}.clr-field{display:inline-block;position:relative;color:#000}.clr-field button{position:absolute;width:30px;height:100%;right:0;top:50%;transform:translateY(-50%);border:0;color:inherit;text-indent:-1000px;white-space:nowrap;overflow:hidden;pointer-events:none}.clr-field button:after{content:'';display:block;position:absolute;width:100%;height:100%;left:0;top:0;border-radius:inherit;background-color:currentColor;box-shadow:inset 0 0 1px rgba(0,0,0,.5)}.clr-alpha,.clr-alpha div,.clr-field button,.clr-preview:before,.clr-swatches button{background-image:repeating-linear-gradient(45deg,#aaa 25%,transparent 25%,transparent 75%,#aaa 75%,#aaa),repeating-linear-gradient(45deg,#aaa 25%,#fff 25%,#fff 75%,#aaa 75%,#aaa);background-position:0 0,4px 4px;background-size:8px 8px}.clr-marker:focus{outline:0}.clr-keyboard-nav .clr-alpha input:focus+div,.clr-keyboard-nav .clr-hue input:focus+div,.clr-keyboard-nav .clr-marker:focus{outline:0;box-shadow:0 0 0 2px #1e90ff,0 0 2px 2px #fff} \ No newline at end of file diff --git a/admin/js/coloris.min.js b/admin/js/coloris.min.js new file mode 100644 index 0000000..4aa480b --- /dev/null +++ b/admin/js/coloris.min.js @@ -0,0 +1,6 @@ +/*! + * Copyright (c) 2021 Momo Bassit. + * Licensed under the MIT License (MIT) + * https://github.com/mdbassit/Coloris + */ +!function(u,d,s){var f,h,v,i,o,y,c,r,p,g,b,m,a=d.createElement("canvas").getContext("2d"),w={r:0,g:0,b:0,a:1},k={el:"[data-coloris]",parent:null,theme:"light",wrap:!0,margin:2,format:"hex",swatches:[],a11y:{open:"Open color picker",close:"Close color picker",marker:"Saturation: {s}. Brightness: {v}.",hueSlider:"Hue slider",alphaSlider:"Opacity slider",input:"Color value field",swatch:"Color swatch",instruction:"Saturation and brightness selector. Use up, down, left and right arrow keys to select."}};function n(e){if("object"==typeof e)for(var t in e)switch(t){case"el":x(e.el),!1!==e.wrap&&E(e.el);break;case"parent":k.parent=d.querySelector(e.parent),k.parent&&k.parent.appendChild(f);break;case"theme":f.setAttribute("class","clr-picker clr-"+e.theme);break;case"margin":e.margin*=1,k.margin=(isNaN(e.margin)?k:e).margin;break;case"wrap":e.el&&e.wrap&&E(e.el);break;case"format":k.format=e.format;break;case"swatches":Array.isArray(e.swatches)&&function(){var a=[];e.swatches.forEach(function(e,t){a.push('<button id="clr-swatch-'+t+'" aria-labelledby="clr-swatch-label clr-swatch-'+t+'" style="color: '+e+';">'+e+"</button>")}),a.length&&(N("clr-swatches").innerHTML="<div>"+a.join("")+"</div>")}();break;case"a11y":var a,r,l=e.a11y,n=!1;if("object"==typeof l)for(var i in l)l[i]&&k.a11y[i]&&(k.a11y[i]=l[i],n=!0);n&&(a=N("clr-open-label"),r=N("clr-swatch-label"),a.innerHTML=k.a11y.open,r.innerHTML=k.a11y.swatch,o.setAttribute("aria-label",k.a11y.close),c.setAttribute("aria-label",k.a11y.hueSlider),p.setAttribute("aria-label",k.a11y.alphaSlider),y.setAttribute("aria-label",k.a11y.input),h.setAttribute("aria-label",k.a11y.instruction))}}function x(e){D(d,"click",e,function(e){var t=k.parent,a=e.target.getBoundingClientRect(),r=u.scrollY,l={left:!1,top:!1},n={x:0,y:0},i=a.x,o=r+a.y+a.height+k.margin;b=e.target,m=b.value,f.classList.add("clr-open");var c,s=f.offsetWidth,p=f.offsetHeight;t?(c=u.getComputedStyle(t),e=parseFloat(c.marginTop),c=parseFloat(c.borderTopWidth),(n=t.getBoundingClientRect()).y+=c+r,i-=n.x,o-=n.y,i+s>t.clientWidth&&(i+=a.width-s,l.left=!0),o+p>t.clientHeight-e&&(o-=a.height+p+2*k.margin,l.top=!0),o+=t.scrollTop):(i+s>d.documentElement.clientWidth&&(i+=a.width-s,l.left=!0),o+p-r>d.documentElement.clientHeight&&(o=r+a.y-p-k.margin,l.top=!0)),f.style.left=i+"px",f.style.top=o+"px",v={width:h.offsetWidth,height:h.offsetHeight,x:f.offsetLeft+n.x,y:f.offsetTop+n.y},f.classList.toggle("clr-left",l.left),f.classList.toggle("clr-top",l.top),S(b.value),y.focus({preventScroll:!0})}),D(d,"input",e,function(e){var t=e.target.parentNode;t.classList.contains("clr-field")&&(t.style.color=e.target.value)})}function E(e){d.querySelectorAll(e).forEach(function(e){var t,a=e.parentNode;a.classList.contains("clr-field")||((t=d.createElement("div")).innerHTML='<button aria-labelledby="clr-open-label"></button>',a.insertBefore(t,e),t.setAttribute("class","clr-field"),t.style.color=e.value,t.appendChild(e))})}function L(e){b&&(e&&m!==b.value&&b.dispatchEvent(new Event("change",{bubbles:!0})),f.classList.remove("clr-open"),b.focus({preventScroll:!0}),b=null)}function S(e){var t=function(e){a.fillStyle="#000",a.fillStyle=e,e=(e=/^((rgba)|rgb)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i.exec(a.fillStyle))?{r:+e[3],g:+e[4],b:+e[5],a:+e[6]}:(e=a.fillStyle.replace("#","").match(/.{2}/g).map(function(e){return parseInt(e,16)}),{r:e[0],g:e[1],b:e[2],a:1});return e}(e),e=function(e){var t=e.r/255,a=e.g/255,r=e.b/255,l=s.max(t,a,r),n=s.min(t,a,r),i=l-n,o=l,c=0,n=0;i&&(l===t&&(c=(a-r)/i),l===a&&(c=2+(r-t)/i),l===r&&(c=4+(t-a)/i),l&&(n=i/l));return{h:(c=s.floor(60*c))<0?c+360:c,s:s.round(100*n),v:s.round(100*o),a:e.a}}(t);T(e.s,e.v),C(t),c.value=e.h,f.style.color="hsl("+e.h+", 100%, 50%)",r.style.left=e.h/360*100+"%",i.style.left=v.width*e.s/100+"px",i.style.top=100-v.height*e.v/100+"px",p.value=100*e.a,g.style.left=100*e.a+"%"}function l(){b&&(b.value=y.value,b.dispatchEvent(new Event("input",{bubbles:!0})))}function A(e,t){e={h:+c.value,s:e/v.width*100,v:100-t/v.height*100,a:p.value/100},t=function(e){var t=e.s/100,a=e.v/100,r=t*a,l=e.h/60,n=r*(1-s.abs(l%2-1)),i=a-r;r+=i,n+=i;t=s.floor(l)%6,a=[r,n,i,i,n,r][t],l=[n,r,r,n,i,i][t],t=[i,i,n,r,r,n][t];return{r:s.round(255*a),g:s.round(255*l),b:s.round(255*t),a:e.a}}(e);T(e.s,e.v),C(t),l()}function T(e,t){var a=k.a11y.marker;e=+e.toFixed(1),t=+t.toFixed(1),a=(a=a.replace("{s}",e)).replace("{v}",t),i.setAttribute("aria-label",a)}function t(e){var t={pageX:((a=e).changedTouches?a.changedTouches[0]:a).pageX,pageY:(a.changedTouches?a.changedTouches[0]:a).pageY},a=t.pageX-v.x,t=t.pageY-v.y;k.parent&&(t+=k.parent.scrollTop),a=a<0?0:a>v.width?v.width:a,t=t<0?0:t>v.height?v.height:t,i.style.left=a+"px",i.style.top=t+"px",A(a,t),e.preventDefault(),e.stopPropagation()}function C(e){for(var t in e)w[t]=e[t];var a,r=function(e){var t=e.r.toString(16),a=e.g.toString(16),r=e.b.toString(16),l="";e.r<16&&(t="0"+t);e.g<16&&(a="0"+a);e.b<16&&(r="0"+r);e.a<1&&(e=255*e.a|0,l=e.toString(16),e<16&&(l="0"+l));return"#"+t+a+r+l}(w),l=r.substring(0,7),n=1===(a=w).a?"rgb("+a.r+","+a.g+","+a.b+")":"rgba("+a.r+","+a.g+","+a.b+","+a.a+")";switch(i.style.color=l,g.parentNode.style.color=l,g.style.color=r,o.style.color=r,y.value=r,h.style.display="none",h.offsetHeight,h.style.display="",g.nextElementSibling.style.display="none",g.nextElementSibling.offsetHeight,g.nextElementSibling.style.display="",k.format){case"mixed":if(1===w.a)break;case"rgb":y.value=n}}function e(){var e=+c.value,t=+i.style.left.replace("px",""),a=+i.style.top.replace("px","");f.style.color="hsl("+e+", 100%, 50%)",r.style.left=e/360*100+"%",A(t,a)}function H(){var e=p.value/100;g.style.left=100*e+"%",C({a:e}),l()}function N(e){return d.getElementById(e)}function D(e,t,a,r){var l=Element.prototype.matches||Element.prototype.msMatchesSelector;"string"==typeof a?e.addEventListener(t,function(e){l.call(e.target,a)&&r.call(e.target,e)}):(r=a,e.addEventListener(t,r))}function M(e,t){t=void 0!==t?t:[],"loading"!==d.readyState?e.apply(void 0,t):d.addEventListener("DOMContentLoaded",function(){e.apply(void 0,t)})}void 0!==NodeList&&NodeList.prototype&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach),u.Coloris=function(){var l={set:n,wrap:E,close:L};function e(e){M(function(){e&&("string"==typeof e?x:n)(e)})}for(var t in l)!function(r){e[r]=function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];M(l[r],t)}}(t);return e}(),M(function(){(f=d.createElement("div")).setAttribute("id","clr-picker"),f.setAttribute("class","clr-picker clr-"+k.theme),f.innerHTML='<input id="clr-color-value" class="clr-color" type="text" value="" aria-label="'+k.a11y.input+'"><div id="clr-color-area" class="clr-gradient" role="application" aria-label="'+k.a11y.instruction+'"><div id="clr-color-marker" class="clr-marker" tabindex="0"></div></div><div class="clr-hue"><input id="clr-hue-slider" type="range" min="0" max="360" step="1" aria-label="'+k.a11y.hueSlider+'"><div id="clr-hue-marker"></div></div><div class="clr-alpha"><input id="clr-alpha-slider" type="range" min="0" max="100" step="1" aria-label="'+k.a11y.alphaSlider+'"><div id="clr-alpha-marker"></div><span></span></div><div id="clr-swatches" class="clr-swatches"></div><button id="clr-color-preview" class="clr-preview" aria-label="'+k.a11y.close+'"></button><span id="clr-open-label" hidden>'+k.a11y.open+'</span><span id="clr-swatch-label" hidden>'+k.a11y.swatch+"</span>",d.body.appendChild(f),h=N("clr-color-area"),i=N("clr-color-marker"),o=N("clr-color-preview"),y=N("clr-color-value"),c=N("clr-hue-slider"),r=N("clr-hue-marker"),p=N("clr-alpha-slider"),g=N("clr-alpha-marker"),x(k.el),E(k.el),D(f,"mousedown",function(e){f.classList.remove("clr-keyboard-nav"),e.stopPropagation()}),D(h,"mousedown",function(e){D(d,"mousemove",t)}),D(h,"touchstart",function(e){d.addEventListener("touchmove",t,{passive:!1})}),D(i,"mousedown",function(e){D(d,"mousemove",t)}),D(i,"touchstart",function(e){d.addEventListener("touchmove",t,{passive:!1})}),D(y,"change",function(e){S(y.value),l()}),D(o,"click",function(e){L(!0)}),D(f,"click",".clr-swatches button",function(e){S(e.target.style.color),l()}),D(d,"mouseup",function(e){d.removeEventListener("mousemove",t)}),D(d,"touchend",function(e){d.removeEventListener("touchmove",t)}),D(d,"mousedown",function(e){f.classList.remove("clr-keyboard-nav"),L(!0)}),D(d,"keydown",function(e){"Escape"===e.key?L(!0):"Tab"===e.key&&f.classList.add("clr-keyboard-nav")}),D(d,"click",".clr-field button",function(e){e.target.nextElementSibling.dispatchEvent(new Event("click",{bubbles:!0}))}),D(i,"keydown",function(e){var t={ArrowUp:[0,-1],ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0]};-1!==Object.keys(t).indexOf(e.key)&&(!function(e,t){e=+i.style.left.replace("px","")+e,t=+i.style.top.replace("px","")+t,i.style.left=e+"px",i.style.top=t+"px",A(e,t)}.apply(void 0,t[e.key]),e.preventDefault())}),D(h,"click",t),D(c,"input",e),D(p,"input",H)})}(window,document,Math); \ No newline at end of file diff --git a/admin/js/link.js b/admin/js/link.js index dee28ba..ebfd5cd 100644 --- a/admin/js/link.js +++ b/admin/js/link.js @@ -100,34 +100,91 @@ function geturl(){ layer.msg('链接地址不能为空'); return false; } - lightyear.loading("show"); + $('#loading').css("display","flex"); if (!/^http[s]?:\/\/+/.test(url)&&url!="") { var url = "http://"+url; $("input[name=\'url\']").val(url); } + $.ajax({ url:"ajax_link.php?submit=geturl", - type:"post", + type:"GET", dataType:"json", data:{url:url}, success:function(data){ - lightyear.loading("hide"); - var head = eval(data); - $("input[name=\'name\']").val(head.title); - if(!head.icon){ + $("input[name=\'name\']").val(data.title); + if(!data.title && !data.icon){ + layer.msg('获取失败,请手动填写'); + } + else if(!data.icon){ layer.msg('未获取到网站图标'); } - $("textarea[name=\'icon\']").val(head.icon); + layer.msg('正则抓取目标网站图标...'); + downloadimg(data.icon,url); + $('#loading').css("display","none"); return true; }, error:function(data){ - lightyear.loading('hide'); - layer.msg('获取失败,网站无法访问或防火墙限制!'); + layer.msg('获取失败,目标网站无法访问或防火墙限制!'); + $('#loading').css("display","none"); return false; } }); -} - +} +//抓取网站图标 +function downloadimg(url,referer){ + $.ajax({ + url:"/include/file.php", + type:"POST", + dataType:"json", + data:{url:url,referer:referer}, + success:function(data){ + if(data.code == '200'){ + layer.msg(data.msg); + $("textarea[name=\'icon\']").val(data.url); + return true; + } + else{ + layer.msg(data.msg); + return false; + } + }, + error:function(data){ + layer.msg('服务器错误'); + return false; + } + }); +} +//上传图标 +function uploadimg(e) { + var formData = new FormData(); + formData.append("file", $("#file")[0].files[0]); + $.ajax({ + method: 'POST', + url: '/include/file.php', + data: formData, + timeout: 20000, + cache: false, + processData: false, + contentType: false, + dataType:"JSON", + success:function(data){ + if(data.code == '200'){ + layer.msg(data.msg); + $("textarea[name=\'icon\']").val(data.url); + return true; + } + else{ + layer.msg(data.msg); + return false; + } + }, + error:function(data){ + layer.msg('服务器错误'); + return false; + } + }); +} //多选删除 function del_link(id){ var link_id = []; diff --git a/admin/link.php b/admin/link.php index d40cca0..a904a73 100644 --- a/admin/link.php +++ b/admin/link.php @@ -5,9 +5,7 @@ $grouplists = $DB->query("SELECT * FROM `lylme_groups`"); $pwd_lists = $DB->query("SELECT * FROM `lylme_pwd`"); ?> <main class="lyear-layout-content"> - <div class="container-fluid"> - <div class="row"> <div class="col-lg-12"> <div class="card"> @@ -15,7 +13,7 @@ $pwd_lists = $DB->query("SELECT * FROM `lylme_pwd`"); <?php $set = isset($_GET['set']) ? $_GET['set'] : null; if ($set == 'add') { - echo '<h4>新增链接</h4> + echo '<h4>新增链接</h4> <div class="panel-body"> <form action="./link.php?set=add_submit" method="POST"> <div class="form-group"> @@ -26,38 +24,46 @@ if ($set == 'add') { <button class="btn btn-default" onclick="geturl()" type="button">获取</button> </span> </div></div> + <div class="form-group"> <label>*网站名称:</label><br> <input type="text" class="form-control" placeholder="网站名称" name="name" value="" required> +<input type="text" class="coloris form-control" onchange="select_color()" placeholder="链接颜色" name="color" value="" /> </div> -<div class="form-group"> +<div class="input-group"> <label>链接图标:</label><br> <textarea type="text" class="form-control" name="icon" placeholder="网站图标"></textarea> -<small class="help-block">方式1:填写图标的<code>URL</code>地址,如<code>/img/logo.png</code>或<code>http://www.xxx.com/img/logo.png</code><br> -方式2:粘贴图标的<code>SVG</code>代码,<a href="./help.php?doc=icon" target="_blank">查看教程</a><br>方式3:留空使用默认图标</small> +<span class="input-group-btn"> + <input type="file" id="file" onchange="uploadimg()" accept="image/png, image/jpeg,image/gif,image/x-icon" style="display: none" /> + <button class="btn btn-default" id="uploadImage" onclick="$("#file").click();" type="button">选择</button> +</span> +</div> +<small class="help-block"><b>可选方案:</b><br>1. 填写图标的<code>URL</code>地址,如<code>/img/logo.png</code>或<code>http://www.xxx.com/img/logo.png</code><br> +2. 粘贴图标的<code>SVG</code>代码,<a href="./help.php?doc=icon" target="_blank">查看教程</a><br>3. 留空使用默认图标<br>4. 从本地上传</small> </div> <div class="form-group"> <label>*分组:</label><br> <select class="form-control" name="group_id">'; - while ($grouplist = $DB->fetch($grouplists)) { - if ($grouplist["group_id"] == $row['group_id']) { - $select = 'selected="selected"'; - } else { - $select = ''; - } - echo '<option value="' . $grouplist["group_id"] . '">' . $grouplist["group_id"] . ' - ' . $grouplist["group_name"] . '</option>'; - } - echo '</select></div> + while ($grouplist = $DB->fetch($grouplists)) { + if ($grouplist["group_id"] == $row['group_id']) { + $select = 'selected="selected"'; + } else { + $select = ''; + } + echo '<option value="' . $grouplist["group_id"] . '">' . $grouplist["group_id"] . ' - ' . $grouplist["group_name"] . '</option>'; + } + echo '</select></div> <div class="form-group"> <input type="submit" class="btn btn-primary btn-block" value="添加"></form> </div> <br/><a href="./link.php"><<返回</a> </div></div>'; } elseif ($set == 'edit') { - $id = $_GET['id']; - $row2 = $DB->query("select * from lylme_links where id='$id' limit 1"); - $row = $DB->fetch($row2); - echo '<h4>修改链接信息</h4> + $id = $_GET['id']; + $row2 = $DB->query("select * from lylme_links where id='$id' limit 1"); + $row = $DB->fetch($row2); + preg_match_all('/<font color=[\"|\']+(.*?)[\"|\']>/i',$row['name'],$color); + echo '<h4>修改链接信息</h4> <div class="panel-body"> <form action="./link.php?set=edit_submit&id=' . $id . '" method="POST"> <div class="form-group"> @@ -70,38 +76,47 @@ if ($set == 'add') { </div></div> <div class="form-group"> <label>*网站名称:</label><br> -<input type="text" class="form-control" name="name" value="' . $row['name'] . '" required> +<input type="text" class="form-control" name="name" id="urlname" value="' . strip_tags($row['name']) . '" required> +<input type="text" class="coloris form-control" onchange="select_color()" placeholder="留空默认" name="color" value="'.$color[1][0].'" /> </div> -<div class="form-group"> +<div class="input-group"> <label>链接图标:</label><br> <textarea type="text" class="form-control" name="icon" >' . $row['icon'] . '</textarea> -<small class="help-block">方式1:填写图标的<code>URL</code>地址,如<code>/img/logo.png</code>或<code>http://www.xxx.com/img/logo.png</code><br> -方式2:粘贴图标的<code>SVG</code>代码,<a href="./help.php?doc=icon" target="_blank">查看教程</a><br>方式3:留空使用默认图标</small> +<span class="input-group-btn"> + <input type="file" id="file" onchange="uploadimg()" accept="image/png, image/jpeg,image/gif,image/x-icon" style="display: none" /> + <button class="btn btn-default" id="uploadImage" onclick="$("#file").click();" type="button">选择</button> +</span> +</div> +<small class="help-block"><b>可选方案:</b><br>1. 填写图标的<code>URL</code>地址,如<code>/img/logo.png</code>或<code>http://www.xxx.com/img/logo.png</code><br> +2. 粘贴图标的<code>SVG</code>代码,<a href="./help.php?doc=icon" target="_blank">查看教程</a><br>2. 留空使用默认图标<br>4. 从本地上传</small> </div> - <div class="form-group"> <label>*分组:</label><br> <select class="form-control" name="group_id">'; - while ($grouplist = $DB->fetch($grouplists)) { - if ($grouplist["group_id"] == $row['group_id']) { - $select = 'selected="selected"'; - } else { - $select = ''; - } - echo '<option value="' . $grouplist["group_id"] . '" ' . $select . '>' . $grouplist["group_id"] . ' - ' . $grouplist["group_name"] . '</option>'; - } - echo '</select> + while ($grouplist = $DB->fetch($grouplists)) { + if ($grouplist["group_id"] == $row['group_id']) { + $select = 'selected="selected"'; + } else { + $select = ''; + } + echo '<option value="' . $grouplist["group_id"] . '" ' . $select . '>' . $grouplist["group_id"] . ' - ' . $grouplist["group_name"] . '</option>'; + } + echo '</select> </div> <div class="form-group"> <label>链接加密:</label><br> <select class="form-control" required name="link_pwd">'; -$pwd_lists = $DB->query("SELECT * FROM `lylme_pwd`"); -while ($pwd_list = $DB->fetch($pwd_lists)) { - if($row['link_pwd']==$pwd_list["pwd_id"]){$sel = 'selected="selected"';}else{ $sel ='';} - echo '<option value="' . $pwd_list["pwd_id"] . '" '.$sel.' >' . $pwd_list["pwd_id"] . ' - ' . $pwd_list["pwd_name"] . ' | 密码['. $pwd_list["pwd_key"].']</option>'; -} -if(empty($row['link_pwd'])) $sele = 'selected="selected"'; -echo ' + $pwd_lists = $DB->query("SELECT * FROM `lylme_pwd`"); + while ($pwd_list = $DB->fetch($pwd_lists)) { + if($row['link_pwd']==$pwd_list["pwd_id"]) { + $sel = 'selected="selected"'; + } else { + $sel =''; + } + echo '<option value="' . $pwd_list["pwd_id"] . '" '.$sel.' >' . $pwd_list["pwd_id"] . ' - ' . $pwd_list["pwd_name"] . ' | 密码['. $pwd_list["pwd_key"].']</option>'; + } + if(empty($row['link_pwd'])) $sele = 'selected="selected"'; + echo ' <option value="0" '.$sele.'>0 - 不加密</option></select> <small class="help-block"><code>注意:对链接所在的分组加密后,单独设置的链接加密将会失效</code><br> 加密后只能通过输入密码访问,使用该功能先配置加密组 @@ -111,46 +126,58 @@ echo ' <input type="submit" class="btn btn-primary btn-block" value="修改"></form> </div> <br/><a href="./link.php"><<返回</a> -</div></div>'; +</div></div> +'; } elseif ($set == 'add_submit') { - $name = $_POST['name']; - $url = $_POST['url']; - $icon = $_POST['icon']; - $group_id = $_POST['group_id']; - $link_order = $linksrows + 1; - if ($name == NULL or $url == NULL) { - echo '<script>alert("保存错误,请确保带星号的都不为空!");history.go(-1);</script>'; - } else { - $sql = "INSERT INTO `lylme_links` (`id`, `name`, `group_id`, `url`, `icon`, `PS`,`link_order`) VALUES (NULL, '" . $name . "', '" . $group_id . "', '" . $url . "', '" . $icon . "', '" . $name . "', '" . $link_order . "');"; - if ($DB->query($sql)) { - echo '<script>alert("添加链接 ' . $name . ' 成功!");window.location.href="./link.php";</script>'; - } else echo '<script>alert("添加链接失败!");history.go(-1);</script>'; - } + $color = $_POST['color']; + $name = $_POST['name']; + if(empty($color)) { + $name1 = $name; + } else { + $name1 = '<font color="'.$color.'">'.$name.'</font>'; + } + $url = $_POST['url']; + $icon = $_POST['icon']; + $group_id = $_POST['group_id']; + $link_order = $linksrows + 1; + if ($name == NULL or $url == NULL) { + echo '<script>alert("保存错误,请确保带星号的都不为空!");history.go(-1);</script>'; + } else { + $sql = "INSERT INTO `lylme_links` (`id`, `name`, `group_id`, `url`, `icon`, `PS`,`link_order`) VALUES (NULL, '" . $name1 . "', '" . $group_id . "', '" . $url . "', '" . $icon . "', '" . $name . "', '" . $link_order . "');"; + if ($DB->query($sql)) { + echo '<script>alert("添加链接 ' . $name . ' 成功!");window.location.href="./link.php";</script>'; + } else echo '<script>alert("添加链接失败!");history.go(-1);</script>'; + } } elseif ($set == 'edit_submit') { - $id = $_GET['id']; - $rows2 = $DB->query("select * from lylme_links where id='$id' limit 1"); - $rows = $DB->fetch($rows2); - if (!$rows) echo '<script>alert("当前记录不存在!");history.go(-1);</script>'; - $name = $_POST['name']; - $url = $_POST['url']; - $icon = $_POST['icon']; - $link_pwd = $_POST['link_pwd']; - $group_id = $_POST['group_id']; - if ($name == NULL or $url == NULL) { - echo '<script>alert("保存错误,请确保带星号的都不为空!");history.go(-1);</script>'; - } else { - $sql = "UPDATE `lylme_links` SET `name` = '" . $name . "', `url` = '" . $url . "', `icon` = '" . $icon . "', `group_id` = '" . $group_id . "', `link_pwd` = " . $link_pwd . " WHERE `lylme_links`.`id` = '" . $id . "';"; - // exit($sql); - if ($DB->query($sql)) echo '<script>alert("修改链接 ' . $name . ' 成功!");window.location.href="./link.php";</script>'; - else echo '<script>alert("修改链接失败!");history.go(-1);</script>'; - } -// } elseif ($set == 'delete') { -// $id = $_GET['id']; -// $sql = "DELETE FROM lylme_links WHERE id='$id'"; -// if ($DB->query($sql)) echo '<script>alert("删除成功!");window.location.href="./link.php";</script>'; -// else echo '<script>alert("删除失败!");history.go(-1);</script>'; + $id = $_GET['id']; + $rows2 = $DB->query("select * from lylme_links where id='$id' limit 1"); + $rows = $DB->fetch($rows2); + if (!$rows) exit('<script>alert("当前记录不存在!");history.go(-1);</script>'); + $color = $_POST['color']; + $name = $_POST['name']; + if(empty($color)) { + $name1 = $name; + } else { + $name1 = '<font color="'.$color.'">'.$name.'</font>'; + } + $url = $_POST['url']; + $icon = $_POST['icon']; + $link_pwd = $_POST['link_pwd']; + $group_id = $_POST['group_id']; + if ($name == NULL or $url == NULL) { + echo '<script>alert("保存错误,请确保带星号的都不为空!");history.go(-1);</script>'; + } else { + $sql = "UPDATE `lylme_links` SET `name` = '" . $name1 . "', `url` = '" . $url . "', `icon` = '" . $icon . "', `group_id` = '" . $group_id . "', `link_pwd` = " . $link_pwd . " WHERE `lylme_links`.`id` = '" . $id . "';"; + // exit($sql); + if ($DB->query($sql)) echo '<script>alert("修改链接 ' . $name . ' 成功!");window.location.href="./link.php";</script>'; else echo '<script>alert("修改链接失败!");history.go(-1);</script>'; + } + // } elseif ($set == 'delete') { + // $id = $_GET['id']; + // $sql = "DELETE FROM lylme_links WHERE id='$id'"; + // if ($DB->query($sql)) echo '<script>alert("删除成功!");window.location.href="./link.php";</script>'; + // else echo '<script>alert("删除失败!");history.go(-1);</script>'; } else { - echo '<div id="listTable"></div> + echo '<div id="listTable"></div> </div> </div> </div> @@ -158,7 +185,6 @@ echo ' </div> </main> '; - } include './footer.php'; ?> @@ -166,6 +192,22 @@ include './footer.php'; <link href="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery-confirm/3.3.0/jquery-confirm.min.css" type="text/css" rel="stylesheet" /> <script src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/layer/3.1.1/layer.min.js" type="application/javascript"></script> <script src="https://lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery-confirm/3.3.0/jquery-confirm.min.js" type="application/javascript"></script> +<!--选色器--> +<link rel="stylesheet" type="text/css" href="css/coloris.min.css" /> +<script type="text/javascript" src="js/coloris.min.js"></script> +<script type="text/javascript">Coloris( { + el:'.coloris',swatches:['#000000','#555555','#666666','#264653','#2a9d8f','#f4a261','#e76f51','#ff0000','#d62828','#023e8a','#0077b6','#0096c7'] +}); +</script> +<style>.clr-alpha {display: none !important;}</style> +<script type="text/javascript"> + select_color(); +function select_color() { + var fontcolor = $('input[name="color"]').val(); + $('#urlname').css("color",fontcolor); +} +</script> +<!--选色器--> <!--消息提示--> <script src="js/bootstrap-notify.min.js"></script> <script type="text/javascript" src="js/lightyear.js"></script>