介绍:
插件比较简单,就不上传源码了。这里用pushplus推送加(https://www.pushplus.plus/)做微信通知,目前限额200条/天
操作步骤:
1,在网站根目录创建:/e/extend/pushplus/2,然后新建文件:/e/extend/pushplus/comment_push.php
复制这段代码进去
<?php
if(!defined('InEmpireCMS'))
{
exit();
}
//================== PushPlus评论通知插件 ==================
function empire_pushplus_comment($classid,$id,$username,$email,$saytext)
{
global $empire,$dbtbpre,$class_r;
$pushplus_token = "填写你的PushPlusToken";
// 获取文章标题
$r = $empire->fetch1("select title from {$dbtbpre}ecms_".$class_r[$classid][tbname]." where id='$id'");
// 显示用户名或邮箱
$show_user = !empty($email) ? $email : $username;
$title = "网站收到新评论";
$content = "文章标题:".$r['title']."
评论人:".$show_user."
评论内容:".$saytext."
评论时间:".date("Y-m-d H:i:s");
$post_data = array(
"token" => $pushplus_token,
"title" => $title,
"content" => $content,
"template" => "txt"
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.pushplus.plus/send");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($post_data));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
curl_exec($ch);
curl_close($ch);
}
?>
3,打开:/e/pl/plfun.php
找到 $plid=$empire->lastid($dbtbpre.'enewspl_'.$restb,'plid');
在它下面加:
@include_once(ECMS_PATH.'e/extend/pushplus/comment_push.php');
empire_pushplus_comment($classid,$id,$username,$email,$saytext);
到此结束
插件优点
推送逻辑完全独立以后想改模板只改插件文件
删除插件 = 关闭推送
系统升级不影响插件文件