From 15514357f16e7ad2924ca56a1af24d7b807c50e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=AD=E9=9B=B6?= Date: Sat, 18 Jun 2022 20:54:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=E6=94=B6=E5=BD=95=E4=BD=93=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apply/index.php | 166 ++++++++---------------------------------------- 1 file changed, 25 insertions(+), 141 deletions(-) diff --git a/apply/index.php b/apply/index.php index 07daf67..e05f30c 100644 --- a/apply/index.php +++ b/apply/index.php @@ -1,98 +1,26 @@ query("SELECT * FROM `lylme_groups`"); if(!empty($url = isset($_GET['url']) ? $_GET['url'] : null)) { - 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($_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'].'"}'); } -$grouplists =$DB->query("SELECT * FROM `lylme_groups`"); -if(isset($_REQUEST['authcode'])) { - session_start(); - if(strtolower($_REQUEST['authcode'])== $_SESSION['authcode']) { - if(isset($_POST['name'])&& isset($_POST['url'])&& isset($_POST['icon'])&& isset($_POST['group_id'])) { - $status = $conf["apply"]; - if($status==2) { - exit('<script>alert("提交失败,网站已关闭申请收录功能!");window.location.href="./";</script>'); - } - $name=strip_tags(daddslashes($_POST['name'])); - $url=strip_tags(daddslashes($_POST['url'])); - $icon=strip_tags(daddslashes($_POST['icon'])); - $group_id=strip_tags(daddslashes($_POST['group_id'])); - $userip=strip_tags(get_real_ip()); - $sw = 1; - $date = date("Y-m-d H:i:s"); - if(empty($status)) { - $status=0; - } - } - function strlens($str) { - if(strlen($str) > 255) { - return true; - } else { - return false; - } - } - if($sw == 1) { - if(empty($name) || empty($url) || empty($group_id) || empty($userip) ) { - //|| empty($icon) - exit('<script>alert("提交失败,请确保所有选项都不为空!");history.go(-1);</script>'); - } else if(!preg_match('/^http*/i', $url)) { - exit('<script>alert("提交失败,输入不符合要求!");history.go(-1);</script>'); - } else if(strlens($name)||strlens($url)||strlens($icon)||strlens($group_id)||strlens($userip)) { - exit('<script>alert("非法参数!");history.go(-1);</script>'); - } else { - if($DB->num_rows($DB->query("SELECT * FROM `lylme_apply` WHERE `apply_url` LIKE '".$url."';"))>0) { - exit('<script>alert("链接已存在,请勿重复提交,如需修改请联系站长!");history.go(-1);</script>'); - } - $sql = "INSERT INTO `lylme_apply` (`apply_id`, `apply_name`, `apply_url`, `apply_group`, `apply_icon`, `apply_mail`, `apply_time`, `apply_status`) VALUES (NULL, '".$name."', '".$url."', '".$group_id."', '".$icon."', '".$userip."', '".$date."', '".$status."');"; - if($DB->query($sql)) { - switch ($status) { - case 0: - echo '<script>alert("提交成功!请等待管理员审核!");window.location.href="./";</script>'; - break; - case 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>'; - } else { - echo '<script>alert("提交成功!请等待管理员审核!");</script>'; - } - break; - } - } else { - echo '<script>alert("提交失败!请联系网站管理员!");history.go(-1);</script>'; - } - } - } - } else { - echo '<script>alert("验证码错误!");history.go(-1);</script>'; - } - exit(); +else if(isset($_GET['submit']) == 'post') { + if(isset($_REQUEST['authcode'])){ + session_start(); + if(strtolower($_REQUEST['authcode'])== $_SESSION['authcode']) { + $status = isset($conf["apply"]) ? $conf["apply"] :0; + if($status==2) { + exit('{"code": "400", "msg": "网站已关闭收录"}'); + } + exit(apply($_POST['name'], $_POST['url'], $_POST['icon'], $_POST['group_id'], $status)); + } + else { + exit('{"code": "-6", "msg": "验证码错误"}'); + } + } + exit(); } ?> <!DOCTYPE html> @@ -117,6 +45,8 @@ if(isset($_REQUEST['authcode'])) { .code{height:38px} .apply_gg{margin:20px 0;font-size:15px;line-height:2} .home{text-decoration: none;color: #bbb;line-height: 2;} +li {list-style-type: none;} +ol, ul {padding-left: 10px;} </style> </head> <body> @@ -131,15 +61,14 @@ if(!empty($background = background())){ <div class="lylme-form"> <div class="lylme-center"> <?php if($conf["apply"]==2) { - exit('<div class="lylme-header text-center"><h2>网站已关闭申请收录</h2></div>'. $conf['apply_gg']. '</div>'); + exit('<div class="lylme-header text-center"><h2>网站已关闭收录</h2></div>'. $conf['apply_gg']. '</div>'); } ?> <div class="lylme-header text-center"><h2>申请收录</h2></div> <div class="apply_gg"> <?php echo $conf['apply_gg']?> </div> -<form action="" method="POST" AUTOCOMPLETE="OFF"> - <div class="form-group"> +<div class="form-group"> <label>*URL链接地址:</label> <div class="input-group"> <input type="text" class="form-control" name="url" placeholder="完整链接或域名" value="" onchange="gurl()" required > @@ -186,13 +115,11 @@ if(!empty($background = background())){ <span class="mdi mdi-check form-control-feedback" aria-hidden="true"></span> </div> <div class="col-xs-4"> - <img id="captcha_img" title="验证码" src='../include/validatecode.php' class="pull-right code" - onclick="document.getElementById('captcha_img').src='../include/validatecode.php?r='+Math.random()" - /> + <img id="captcha_img" title="验证码" src='../include/validatecode.php' class="pull-right code" onclick="recode()"/> </div> </div> <div class="form-group"> -<input type="submit" id="submit"class="btn btn-primary btn-block" value="提交"></form> +<button class="btn btn-primary btn-block" onclick="submit()">提交</button> </div> <center><p><a href="../" class="home">返回首页</a></p><?php echo $conf['copyright']?></center> @@ -202,49 +129,6 @@ if(!empty($background = background())){ </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 geturl(){ - var url = $("input[name=\'url\']").val(); - if(!url){ - layer.msg('链接地址不能为空'); - return false; - } - $('#loading').css("display","flex"); - if (!/^http[s]?:\/\/+/.test(url)&&url!="") { - var url = "http://"+url; - $("input[name=\'url\']").val(url); - } - - $.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; -} -</script> +<script src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/sweetalert/2.1.2/sweetalert.min.js" type="application/javascript"></script> +<script src="https://cdn.lylme.com/lylme_spage/js/apply.js" type="application/javascript"></script> </html> \ No newline at end of file