mirror of
https://github.com/LyLme/lylme_spage.git
synced 2024-11-17 14:34:08 +08:00
增加 微信推送
This commit is contained in:
parent
d0d20423f1
commit
cb6466e537
@ -50,6 +50,7 @@ if($applyrows>0) {
|
||||
<li class="nav-item active"> <a href="./link.php"><i class="mdi mdi-web"></i>链接管理</a></li>
|
||||
<li class="nav-item active"> <a href="./pwd.php"><i class="mdi mdi-key-variant"></i>加密管理</a></li>
|
||||
<li class="nav-item active"> <a href="./update.php"><i class="mdi mdi-update"></i>检查更新</a> </li>
|
||||
<li class="nav-item active"> <a href="./wxplus.php"><i class="mdi mdi-wechat"></i>微信推送</a> </li>
|
||||
<li> <a href="javascript:loginout()"><i class="mdi mdi-logout"></i> 退出登录</a> </li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
51
admin/wxplus.php
Normal file
51
admin/wxplus.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
$title = '微信推送';
|
||||
include './head.php';
|
||||
$set=isset($_GET['set'])?$_GET['set']:null;
|
||||
if($set=='save') {
|
||||
$userkey=$_POST['userkey'];
|
||||
$wxplustime=$_POST['wxplustime'];
|
||||
saveSetting('wxplus',$userkey);
|
||||
saveSetting('wxplustime',$wxplustime);
|
||||
if(empty($userkey)) {
|
||||
echo '<script>alert("微信推送已关闭");window.location.href="./wxplus.php";</script>';
|
||||
} else {
|
||||
echo '<script>alert("微信推送密钥配置成功");window.location.href="./wxplus.php";</script>';
|
||||
}
|
||||
} else {
|
||||
?>
|
||||
<!--页面主要内容-->
|
||||
<main class="lyear-layout-content">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<form method="post" action="wxplus.php?set=save" class="site-form">
|
||||
<div class="form-group">
|
||||
<label class="control-label">微信推送密钥</label>
|
||||
<textarea type="text" class="form-control" name="userkey" id="userkey" ><?php echo $conf['wxplus'];
|
||||
?></textarea>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">微信推送时间</label>
|
||||
<input class="form-control" type="time" id="wxplustime" name="wxplustime" placeholder="请选择推送提醒时间" value="<?php echo $conf['wxplustime'];?>" />
|
||||
</div>
|
||||
<p class="m-t-15">
|
||||
1. 功能说明:开启微信推送,用户提交申请收录会推送提醒到<code>上云六零</code>公众号<br>
|
||||
2. 开启功能:填写用户的微信推送密钥<br>
|
||||
3. 关闭功能:编辑框留空保存即可关闭该功能<br>
|
||||
4. 获取密钥:微信关注公众号<code>上云六零</code>回复<code>推送密钥</code>复制到编辑框中保存即可<br>
|
||||
5. 温馨提示:为了避免打扰,每天最多推送一次。当日<?php echo $conf['wxplustime'];?>前的提交会在<?php echo $conf['wxplustime'];?>前推送,之后提交的在次日<?php echo $conf['wxplustime'];?>前推送</p>
|
||||
<button type="submit" class="btn btn-primary">保存</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
<?php
|
||||
}
|
||||
include './footer.php';
|
||||
?>
|
229
apply/apply.js
Normal file
229
apply/apply.js
Normal file
@ -0,0 +1,229 @@
|
||||
//抓取网页(旧版)
|
||||
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.title && !head.icon){
|
||||
layer.msg('获取失败,请手动填写');
|
||||
}
|
||||
else 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;
|
||||
}
|
||||
});
|
||||
}
|
||||
//补全URL
|
||||
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;
|
||||
}
|
||||
|
||||
//生成二维码
|
||||
function recode(){
|
||||
$('#captcha_img').attr('src','../include/validatecode.php?r='+Math.random());
|
||||
$("input[name=\'authcode\']").val('');
|
||||
}
|
||||
//微信相关推送
|
||||
function wxPlus(){
|
||||
var url = $("input[name=\'url\']").val();
|
||||
var name = $("input[name=\'name\']").val();
|
||||
if(!url || !name){
|
||||
return false;
|
||||
}
|
||||
$.ajax({
|
||||
url:"./wxplus.php?wx=plus",
|
||||
type:"POST",
|
||||
data:{
|
||||
wx_name: name,
|
||||
wx_url: url
|
||||
},success:function(data){
|
||||
console.log(data.data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//提交
|
||||
function submit(){
|
||||
var url = $("input[name=\'url\']");
|
||||
var name = $("input[name=\'name\']");
|
||||
var group_id = $("select[name=\'group_id\']");
|
||||
var icon = $("input[name=\'icon\']") ? $("input[name=\'icon\']") : $("textarea[name=\'icon\']");
|
||||
var authcode = $("input[name=\'authcode\']");
|
||||
if(!url.val() || !name.val() || !group_id.val() || !authcode.val()){
|
||||
layer.msg('必填项不能为空');
|
||||
return false;
|
||||
}
|
||||
$.ajax({
|
||||
url:"index.php?submit=post",
|
||||
type:"POST",
|
||||
dataType:"json",
|
||||
data:{
|
||||
url: url.val(),
|
||||
name: name.val(),
|
||||
group_id: group_id.val(),
|
||||
icon: icon.val(),
|
||||
authcode: authcode.val()
|
||||
},
|
||||
success:function(data){
|
||||
if(data.code == '200'){
|
||||
wxPlus(name,url);
|
||||
swal({
|
||||
title: "成功",
|
||||
text: data.msg,
|
||||
icon: "success",
|
||||
allowOutsideClick:false,
|
||||
button : "确定"
|
||||
}).then(function () {
|
||||
recode();
|
||||
window.location.replace("./");
|
||||
return true;
|
||||
});
|
||||
}
|
||||
else{
|
||||
swal({
|
||||
title: "失败",
|
||||
text: data.msg,
|
||||
icon: "error",
|
||||
allowOutsideClick:false,
|
||||
button : "确定"
|
||||
}).then(function () {
|
||||
recode();
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
error:function(data){
|
||||
layer.msg('服务器错误');
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//抓取网页(新版)
|
||||
function get_url(){
|
||||
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){
|
||||
$("input[name=\'name\']").val(data.title);
|
||||
if(!data.title && !data.icon){
|
||||
layer.msg('获取失败,请手动填写');
|
||||
}
|
||||
else if(!data.icon){
|
||||
layer.msg('未获取到网站图标');
|
||||
}
|
||||
layer.msg('正则抓取目标网站图标...');
|
||||
downloadimg(data.icon,url);
|
||||
$('#loading').css("display","none");
|
||||
return true;
|
||||
},
|
||||
error:function(data){
|
||||
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);
|
||||
$("input[name=\'icon\']").val(data.url);
|
||||
$("#review").attr("src",data.url);
|
||||
$("#review").show();
|
||||
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);
|
||||
$("input[name=\'icon\']").val(data.url);
|
||||
$("#review").attr("src",data.url);
|
||||
$("#review").show();
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
layer.msg(data.msg);
|
||||
return false;
|
||||
}
|
||||
},
|
||||
error:function(data){
|
||||
layer.msg('服务器错误');
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
@ -124,5 +124,5 @@ if(!empty($background = background())) {
|
||||
<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 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>
|
||||
<script src="./apply.js" type="application/javascript"></script>
|
||||
</html>
|
16
apply/wxplus.php
Normal file
16
apply/wxplus.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
include("../include/common.php");
|
||||
if($_GET['wx']=="plus"){
|
||||
$wx_key = $conf["wxplus"];
|
||||
$plus_time = $conf["plus_time"]?$conf["plus_time"]:"22:00";
|
||||
$web_title = explode("-", $conf['title'])[0];
|
||||
//$web_title = "六零导航页";
|
||||
if(empty($wx_key)){exit("微信推送未开启");}
|
||||
$wx_name = $_POST['wx_name'];
|
||||
$url = parse_url($_POST['wx_url'])['host'];
|
||||
$wx_url = $url?$url:$_POST['wx_url'];
|
||||
$data = '
|
||||
{"wx_name":"'.$wx_name.'","wx_url":"'.$wx_url.'","web_name":"'.$web_title.'","plus_time":"'.$plus_time.'","wx_key":"'.$wx_key.'"}';
|
||||
exit(wxPlus($data));
|
||||
}
|
||||
?>
|
@ -170,27 +170,20 @@ function get_urlpath($srcurl,$baseurl) {
|
||||
}
|
||||
//获取客户端IP
|
||||
function get_real_ip() {
|
||||
$ip=FALSE;
|
||||
//客户端IP 或 NONE
|
||||
if(!empty($_SERVER["HTTP_CLIENT_IP"])) {
|
||||
$ip = $_SERVER["HTTP_CLIENT_IP"];
|
||||
$real_ip = '';
|
||||
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
||||
$arr = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
|
||||
$pos = array_search('unknown', $arr);
|
||||
if (false !== $pos) {
|
||||
unset($arr[$pos]);
|
||||
}
|
||||
//多重代理服务器下的客户端真实IP地址(可能伪造),如果没有使用代理,此字段为空
|
||||
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
||||
$ips = explode (", ", $_SERVER['HTTP_X_FORWARDED_FOR']);
|
||||
if ($ip) {
|
||||
array_unshift($ips, $ip);
|
||||
$ip = FALSE;
|
||||
$real_ip = trim($arr[0]);
|
||||
} elseif (isset($_SERVER['HTTP_CLIENT_IP'])) {
|
||||
$real_ip = $_SERVER['HTTP_CLIENT_IP'];
|
||||
} elseif (isset($_SERVER['REMOTE_ADDR'])) {
|
||||
$real_ip = $_SERVER['REMOTE_ADDR'];
|
||||
}
|
||||
for ($i = 0; $i < count($ips); $i++) {
|
||||
if (!eregi ("^(10│172.16│192.168).", $ips[$i])) {
|
||||
$ip = $ips[$i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//客户端IP 或 (最后一个)代理服务器 IP
|
||||
return ($ip ? $ip : $_SERVER['REMOTE_ADDR']);
|
||||
return $real_ip;
|
||||
}
|
||||
function yan() {
|
||||
$filename = ROOT.'/assets/data/data.dat';
|
||||
@ -352,4 +345,17 @@ function theme_file($file) {
|
||||
return 'template/'.$file;
|
||||
}
|
||||
}
|
||||
function wxPlus($data){
|
||||
//申请收录后推送到微信公众号
|
||||
$curl = curl_init();
|
||||
curl_setopt($curl, CURLOPT_URL, "https://wx.lylme.com/api/apply/");
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
|
||||
curl_setopt($curl, CURLOPT_POST, 1);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
||||
$output = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
return $output;
|
||||
}
|
||||
?>
|
@ -57,6 +57,10 @@ if($sqlvn < 10501) {
|
||||
$version = 'v1.5.1';
|
||||
$sql = $sql.file_get_contents(ROOT.'install/update6.sql');
|
||||
}
|
||||
if($sqlvn < 10600) {
|
||||
$version = 'v1.6.0';
|
||||
$sql = $sql.file_get_contents(ROOT.'install/update7.sql');
|
||||
}
|
||||
$sql=explode(';',$sql);
|
||||
for ($i=0;$i<count($sql);$i++) {
|
||||
if (trim($sql[$i])=='')continue;
|
||||
|
@ -1,3 +1,3 @@
|
||||
<?php
|
||||
define('VERSION', '1.5.1');
|
||||
define('VERSION', '1.6.0');
|
||||
?>
|
3
install/update7.sql
Normal file
3
install/update7.sql
Normal file
@ -0,0 +1,3 @@
|
||||
-- v1.6.0
|
||||
INSERT INTO `lylme_config` VALUES ('wxplus', '','微信推送密钥');
|
||||
INSERT INTO `lylme_config` VALUES ('wxplustime', '20:00','微信推送时间');
|
Loading…
Reference in New Issue
Block a user