话不多说,大家想必也知道这个东西的重要性,一旦有人恶意搞你,这个可能会让用户主动给你发起提醒并删除!
代码位置:
首先新建一个控制器,内容如下:
<?php namespace Home\plugins; use Home\c\CommonController; use FrPHP\Extend\Page; class JubaoController extends CommonController { function checklogin(){ if(!$this->islogin){ if($this->frparam('ajax')){ JsonReturn(['code'=>1,'msg'=>'您还未登录,请重新登录!']); } Redirect(U('login/index')); } } function check(){ $n = 100; //扣除积分 M('member')->goDec(array('id'=>$this->member['id'] ),'jifen',$n); $w['userid'] = $this->member['id']; $w['buytype'] = 'jifen'; $w['type'] = 2; $w['msg'] = '举报扣除'; $w['addtime'] = time(); $w['orderno'] = 'Jb'.date('YmdHis'); $w['amount'] = 100;//每次扣除数量 $w['money'] = $w['amount']/($this->webconf['money_exchange']);//每次签到钱包转化率 $r = M('buylog')->add($w); } function send(){ $id = $this->member['id']; $jifen = M('member')->getField(array('id'=>$id),'jifen'); $url = $this->frparam('url',1); $title = $this->frparam('title',1); $user = $this->frparam('user',1); $jubao = $this->frparam('jubao',1); // $this->check(); //此项开启则会开启举报扣除积分记录 $DateAndTime = date('m-d-Y h:i:s a', time()); $to = '741500926@qq.com'; $subject = 'FiimeROM举报提醒!'; $message = "收到ROM举报:$url\r\nROM名称:$title\r\nROM作者:$user\r\n举报者信息:$jubao\r\n举报时间:$DateAndTime"; $from = 'rockssr@163.cn'; echo $data['title']; // Sending email if(mail($to, $subject, $message)){ echo '举报信息发送成功.'; } else{ echo '异常请重试.'; } $jifen = $jifen -100; echo "<script language=\"JavaScript\">\r\n"; echo "prompt(\"请输入举报原因:\",\"\")\r\n"; echo "alert(\"举报成功!\");\r\n"; // 历史返回; echo " history.back();\r\n"; sleep(1); echo "</script>"; } public function index() { $this->checklogin(); $this->islogin = true; $this->member = $_SESSION['member']; $id = $this->member['id']; //$jifen = M('member')->getField(array('id'=>$id),'jifen'); //此项开启则会扣除积分 $this->send(); // if($jifen<1000){ // echo "<script language=\"JavaScript\">\r\n"; // echo " alert(\"您的积分为:".$jifen."积分低于1000.00,无法使用举报功能!\");\r\n"; // // 历史返回; // echo " history.back();\r\n"; // echo "</script>"; // }else{ // $this->send(); // } } function topic() { $this->checklogin(); $this->islogin = true; $this->member = $_SESSION['member']; $id = $this->member['id']; $url = $this->frparam('url',1); $title = $this->frparam('title',1); $neirong = $this->frparam('neirong',1); $jubao = $this->frparam('jubao',1); $DateAndTime = date('m-d-Y h:i:s a', time()); $to = '你的邮箱地址'; $subject = '邮件名称!'; $message = "收到评论举报:$url\r\n资源名称:$title\r\n举报内容:$neirong\r\n举报者信息:$jubao\r\n举报时间:$DateAndTime"; $from = 'rockssr@163.cn'; echo $data['title']; // Sending email if(mail($to, $subject, $message)){ echo '举报信息发送成功.'; } else{ echo '异常请重试.'; } echo "<script language=\"JavaScript\">\r\n"; echo " alert(\"举报成功,我们会尽快处理,感谢您的支持!\");\r\n"; // 历史返回; echo " history.back();\r\n"; echo "</script>"; } }
这个代码里面包含的功能和逻辑如下:
1.首先会判断用户是否登陆,不登录你你举报个啥?
2.其次会判断用户积分是否低于1000分,低于可以防止小号恶意举报
3.第三个我注释掉的功能是是否开启举报扣除或者增加积分的选项,也会在消费记录中记载
4.发送邮件到指定的邮箱
前台插入问题,这个自己琢磨,只给代码:
自然就是这段代码:
<button id="btnpost" onclick="window.location.href='/Jubao/topic?url={$jz[url]}&title={$jz[title]}&neirong={fun htmlspecialchars_decode($v['body'])}||被举报者ID:{$v['userinfo']['id']}&jubao={$member[username]}({$member[id]})'">
参数自己修改下!
https://mi.fiime.cn/FindROM/3918.html
具体看下效果
关于发送邮件PHP代码问题可以参考我的博客:
https://blog.fiime.cn/blog/101
效果:
BUG:
举报内容没搞定 有缘人可以留言告诉我下