优化 收录页
This commit is contained in:
parent
81042fdbf7
commit
71d4609e2c
231
apply/index.php
231
apply/index.php
|
@ -2,8 +2,8 @@
|
|||
include("../include/common.php");
|
||||
if(!empty($url = isset($_GET['url']) ? $_GET['url'] : null)) {
|
||||
function get_head($url) {
|
||||
$get_heads = array();
|
||||
$opts = array(
|
||||
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
|
||||
|
@ -13,6 +13,7 @@ if(!empty($url = isset($_GET['url']) ? $_GET['url'] : null)) {
|
|||
preg_match('/<title>(.*?)<\/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);
|
||||
|
@ -23,9 +24,10 @@ if(!empty($url = isset($_GET['url']) ? $_GET['url'] : null)) {
|
|||
}
|
||||
return $get_heads;
|
||||
}
|
||||
$head = get_head($url);
|
||||
$head = get_head($_GET['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']."'}");
|
||||
exit('{"title": "'.$head['title'].'", "icon": "'.$head['icon'].'","charset": "'.$head['charset'].'"}');
|
||||
}
|
||||
$grouplists =$DB->query("SELECT * FROM `lylme_groups`");
|
||||
if(isset($_REQUEST['authcode'])) {
|
||||
|
@ -70,10 +72,10 @@ if(isset($_REQUEST['authcode'])) {
|
|||
if($DB->query($sql)) {
|
||||
switch ($status) {
|
||||
case 0:
|
||||
echo '<script>alert("提交成功!请等待管理员审核!");window.location.href="./";</script>';
|
||||
echo '<script>alert("提交成功!请等待管理员审核!");window.location.href="./";</script>';
|
||||
break;
|
||||
case 1:
|
||||
$link_order = $DB->count('select MAX(id) from `lylme_links`')+1;
|
||||
$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 . "', '" . $userip . "的提交 ', '" . $link_order . "');";
|
||||
if($DB->query($sql1)) {
|
||||
echo '<script>alert("提交成功!网站已成功收录!");window.location.href="./";</script>';
|
||||
|
@ -104,88 +106,33 @@ if(isset($_REQUEST['authcode'])) {
|
|||
<link href="https://cdn.lylme.com/admin/lyear/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="https://cdn.lylme.com/admin/lyear/css/style.min.css" rel="stylesheet">
|
||||
<style>
|
||||
#loading {
|
||||
position:absolute;
|
||||
left:0;
|
||||
top:0;
|
||||
height:100vh;
|
||||
width:100vw;
|
||||
z-index:1;
|
||||
display:none;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background-color:rgba(0,0,0,0.5);
|
||||
color: #bbb;
|
||||
font-size: 16px;
|
||||
}
|
||||
#loading>img {
|
||||
height:32px;
|
||||
width:32px;
|
||||
}
|
||||
.lylme-wrapper {
|
||||
position: relative;
|
||||
}
|
||||
.lylme-form {
|
||||
display: flex !important;
|
||||
min-height: 100vh;
|
||||
align-items: center !important;
|
||||
justify-content: center !important;
|
||||
}
|
||||
.lylme-form:after {
|
||||
content: '';
|
||||
min-height: inherit;
|
||||
font-size: 0;
|
||||
}
|
||||
.lylme-center {
|
||||
background: #fff;
|
||||
min-width: 29.25rem;
|
||||
padding: 30px;
|
||||
border-radius: 20px;
|
||||
margin: 2.85714em;
|
||||
}
|
||||
.lylme-header {
|
||||
margin-bottom: 1.5rem !important;
|
||||
}
|
||||
.lylme-center .has-feedback.feedback-left .form-control {
|
||||
padding-left: 38px;
|
||||
padding-right: 12px;
|
||||
}
|
||||
.lylme-center .has-feedback.feedback-left .form-control-feedback {
|
||||
left: 0;
|
||||
right: auto;
|
||||
width: 38px;
|
||||
height: 38px;
|
||||
line-height: 38px;
|
||||
z-index: 4;
|
||||
color: #dcdcdc;
|
||||
}
|
||||
.lylme-center .has-feedback.feedback-left.row .form-control-feedback {
|
||||
left: 15px;
|
||||
}
|
||||
.code {
|
||||
/*padding-left: 10px;*/
|
||||
/*padding-right: 0px;*/
|
||||
height: 38px;
|
||||
/*max-width: 100px;*/
|
||||
}
|
||||
.apply_gg {
|
||||
margin: 20px 0;
|
||||
font-size: 15px;
|
||||
line-height: 2;
|
||||
}
|
||||
#loading{position:absolute;left:0;top:0;height:100vh;width:100vw;z-index:100;display:none;align-items:center;justify-content:center;background-color:rgba(0,0,0,0.5);color:#bbb;font-size:16px}
|
||||
#loading>img{height:18px;width:18px}
|
||||
.lylme-wrapper{position:relative}
|
||||
.lylme-form{display:flex !important;min-height:100vh;align-items:center !important;justify-content:center !important}
|
||||
.lylme-form:after{content:'';min-height:inherit;font-size:0}
|
||||
.lylme-center{background:#fff;min-width:29.25rem;padding:30px;border-radius:20px;margin:2.85714em}
|
||||
.lylme-header{margin-bottom:1.5rem !important}
|
||||
.lylme-center .has-feedback.feedback-left .form-control{padding-left:38px;padding-right:12px}
|
||||
.lylme-center .has-feedback.feedback-left .form-control-feedback{left:0;right:auto;width:38px;height:38px;line-height:38px;z-index:4;color:#dcdcdc}
|
||||
.lylme-center .has-feedback.feedback-left.row .form-control-feedback{left:15px}
|
||||
.code{height:38px}
|
||||
.apply_gg{margin:20px 0;font-size:15px;line-height:2}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="loading"><img src="https://cdn.lylme.com/admin/lyear/img/loading.gif"/>
|
||||
正在获取....</div>
|
||||
<?php if(!empty(background())){
|
||||
echo '<div class="row lylme-wrapper" style="background-image: url('.background().');background-size: cover;">';}
|
||||
else{ echo '<div class="row lylme-wrapper">';}?>
|
||||
<div id="loading"><img src="https://cdn.lylme.com/admin/lyear/img/loading.gif"/> 正在获取....</div>
|
||||
<?php
|
||||
if(!empty($background = background())){
|
||||
$background = str_replace('./','../',$background);
|
||||
echo '<div class="row lylme-wrapper" style="background-image: url('.$background.');background-size: cover;">';}
|
||||
else{ echo '<div class="row lylme-wrapper">';}
|
||||
?>
|
||||
|
||||
<div class="lylme-form">
|
||||
<div class="lylme-center">
|
||||
<?php if($conf["apply"]==2) {
|
||||
exit('<div class="lylme-header text-center"><h2>网站已关闭申请收录</h2></div> </div>');
|
||||
exit('<div class="lylme-header text-center"><h2>网站已关闭申请收录</h2></div>'. $conf['apply_gg']. '</div>');
|
||||
}
|
||||
?>
|
||||
<div class="lylme-header text-center"><h2>申请收录</h2></div>
|
||||
|
@ -193,13 +140,14 @@ if(isset($_REQUEST['authcode'])) {
|
|||
<?php echo $conf['apply_gg']?>
|
||||
</div>
|
||||
<form action="" method="POST" AUTOCOMPLETE="OFF">
|
||||
<div class="form-group has-feedback feedback-left row">
|
||||
<div class="col-xs-12">
|
||||
<label>* 网站链接:</label>
|
||||
<input type="text" id="url" class="form-control" name="url" value="" onchange="get_head()" required placeholder="完整网址或域名">
|
||||
<span class="mdi mdi-link-variant form-control-feedback" aria-hidden="true"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>*URL链接地址:</label>
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" name="url" placeholder="完整链接或域名" value="" onchange="gurl()" required >
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-default" onclick="geturl()" type="button">自动获取</button>
|
||||
</span>
|
||||
</div></div>
|
||||
<div class="form-group has-feedback feedback-left row">
|
||||
<div class="col-xs-12">
|
||||
<label>* 选择分组:</label>
|
||||
|
@ -220,25 +168,18 @@ if(isset($_REQUEST['authcode'])) {
|
|||
<label>* 网站名称:</label>
|
||||
<input type="text" class="form-control" id="title" name="name" value="" required placeholder="网站名称">
|
||||
<span class="mdi mdi-format-title form-control-feedback" aria-hidden="true"></span>
|
||||
<small class="help-block">填写网站链接后点击空白处自动获取</small>
|
||||
<small class="help-block">填写网站名称</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group has-feedback feedback-left row">
|
||||
<div class="col-xs-12">
|
||||
<label>网站图标:</label>
|
||||
<textarea type="text" id="icon" class="form-control" name="icon" placeholder="如:https://hao.lylme.com/assets/img/logo.png"></textarea>
|
||||
<textarea type="text" id="icon" class="form-control" name="icon" placeholder="填写图标的URL地址"></textarea>
|
||||
<span class="mdi mdi-emoticon form-control-feedback" aria-hidden="true"></span>
|
||||
<small class="help-block">填写图标的<code>URL</code>地址,如:<code>http://www.xxx.com/img/logo.png</code><br>
|
||||
<small class="help-block">填写图标的<code>URL</code>地址,如:<code>http://www.xxx.com/logo.png</code><br>
|
||||
部分网站无法自动获取,请手动填写</small>
|
||||
</div>
|
||||
</div>
|
||||
<!--<div class="form-group has-feedback feedback-left row">-->
|
||||
<!-- <div class="col-xs-12">-->
|
||||
<!-- <label>* 联系邮箱:</label>-->
|
||||
<!-- <input type="text" class="form-control" name="mail" value="" autocomplete="off" required placeholder="填写邮箱">-->
|
||||
<!-- <span class="mdi mdi-email form-control-feedback" aria-hidden="true"></span>-->
|
||||
<!-- </div>-->
|
||||
<!--</div>-->
|
||||
<label>* 验证码:</label>
|
||||
<div class="form-group has-feedback feedback-left row">
|
||||
<div class="col-xs-8">
|
||||
|
@ -258,65 +199,51 @@ if(isset($_REQUEST['authcode'])) {
|
|||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-2-M/jquery/3.5.1/jquery.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 get_head() {
|
||||
var xmlhttp;
|
||||
if (window.XMLHttpRequest) {
|
||||
// IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
|
||||
xmlhttp=new XMLHttpRequest();
|
||||
} else {
|
||||
// IE6, IE5 浏览器执行代码
|
||||
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
|
||||
function geturl(){
|
||||
var url = $("input[name=\'url\']").val();
|
||||
if(!url){
|
||||
layer.msg('链接地址不能为空');
|
||||
return false;
|
||||
}
|
||||
xmlhttp.onreadystatechange=function() {
|
||||
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
|
||||
document.getElementById('loading').style.display = "none";
|
||||
var data=xmlhttp.responseText;
|
||||
var jsonobj=eval("("+data+")");
|
||||
document.getElementById("title").value=jsonobj.title;
|
||||
if(jsonobj.title==''&& jsonobj.icon==''){
|
||||
document.getElementById('title').placeholder="自动获取失败!可能原因:网站无法访问、被防火墙拦截或代码不规范";
|
||||
}
|
||||
document.getElementById("icon").value=jsonobj.icon;
|
||||
}
|
||||
}
|
||||
document.getElementById('loading').style.display = "flex";
|
||||
document.getElementById('title').placeholder="网站名称";
|
||||
var url = document.getElementById('url').value;
|
||||
var re =/^http[s]?:\/\/+/;
|
||||
if (!re.test(url)&&url!="") {
|
||||
$('#loading').css("display","flex");
|
||||
if (!/^http[s]?:\/\/+/.test(url)&&url!="") {
|
||||
var url = "http://"+url;
|
||||
document.getElementById("url").value=url;
|
||||
$("input[name=\'url\']").val(url);
|
||||
}
|
||||
|
||||
var strSendUrl = "?url=" + url;
|
||||
xmlhttp.open("GET",strSendUrl,true);
|
||||
xmlhttp.send();
|
||||
$.ajax({
|
||||
url:"index.php",
|
||||
type:"GET",
|
||||
dataType:"json",
|
||||
data:{url:url},
|
||||
success:function(data){
|
||||
var head = eval(data);
|
||||
$("input[name=\'name\']").val(head.title);
|
||||
if(!head.icon){
|
||||
layer.msg('未获取到网站图标');
|
||||
}
|
||||
$("textarea[name=\'icon\']").val(head.icon);
|
||||
$('#loading').css("display","none");
|
||||
return true;
|
||||
},
|
||||
error:function(data){
|
||||
layer.msg('获取失败,网站无法访问或对方防火墙限制!');
|
||||
$('#loading').css("display","none");
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
function gurl(){
|
||||
var url = $("input[name=\'url\']").val();
|
||||
if (!/^http[s]?:\/\/+/.test(url)&&url!="") {
|
||||
var url = "http://"+url;
|
||||
$("input[name=\'url\']").val(url);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// window.onload = function() {
|
||||
// var inputInt = document.getElementById('icon');
|
||||
// var submit = document.getElementById("submit");
|
||||
// function sw_on() {
|
||||
// inputInt.style.borderColor = "#ebebeb";
|
||||
// submit.disabled = false;
|
||||
// submit.value = "提交";
|
||||
// }
|
||||
// function sw_off() {
|
||||
// inputInt.style.borderColor = "#ff0000";
|
||||
// submit.disabled = true;
|
||||
// submit.value = "输入不符合要求";
|
||||
// }
|
||||
// inputInt.oninput = function() {
|
||||
// var re =/^http[s]?:\/\/([\w-]+\.)+[\w]+(\/[\w-./%&=]*)\.(jpg|png|ico|gif)$/
|
||||
// if (!re.test(this.value)) {
|
||||
// sw_off();
|
||||
// } else {
|
||||
// sw_on();
|
||||
// }
|
||||
// }
|
||||
// ;
|
||||
// sw_on();
|
||||
// }
|
||||
</script>
|
||||
|
||||
</html>
|
Loading…
Reference in New Issue