效果截图
- 浏览器显示IP代码如下:
首先在include/model/comment_model.php 大概45行左右添加以下代码
$row['useragent'] = htmlspecialchars($row['useragent']);
同在comment_model.php的249行左右替换以下代码
function addComment($name, $content, $mail, $url, $imgcode, $blogId, $pid) { $ipaddr = getIp(); $useragent = $_SERVER['HTTP_USER_AGENT']; $utctimestamp = time(); if($pid != 0) { $comment = $this->getOneComment($pid); $content = '@' . addslashes($comment['poster']) . ':' . $content; } $ischkcomment = Option::get('ischkcomment'); $hide = ROLE == ROLE_VISITOR ? $ischkcomment : 'n'; $sql = 'INSERT INTO '.DB_PREFIX."comment (date,poster,gid,comment,mail,url,hide,ip,pid,useragent) VALUES ('$utctimestamp','$name','$blogId','$content','$mail','$url','$hide','$ipaddr','$pid','$useragent')"; $ret = $this->db->query($sql); $cid = $this->db->insert_id(); $CACHE = Cache::getInstance(); if ($hide == 'n') { $this->db->query('UPDATE '.DB_PREFIX."blog SET comnum = comnum + 1 WHERE gid='$blogId'"); $CACHE->updateCache(array('sta', 'comment')); doAction('comment_saved', $cid); emDirect(Url::log($blogId).'#'.$cid); } else { $CACHE->updateCache('sta'); doAction('comment_saved', $cid); emMsg('评论发表成功,请等待管理员审核', Url::log($blogId)); } }
下载附件
下载链接:https://pan.baidu.com/s/1pLtBuuZ 查看密码:9pg9
本文作者为Mr.Bai,转载请注明。
发的个地方[得意]
下载了支持