1.打开include/model/comment_model.php文件
找到while ($row = $this->db->fetch_array($ret)) { (约第45行),增加:
$row['useragent'] = htmlspecialchars($row['useragent']);
再找到function addComment($name, $content, $mail, $url, $imgcode, $blogId, $pid),在$ipaddr = getIp();下方添加:
$useragent = $_SERVER['HTTP_USER_AGENT'];
再将其中的:
$sql = 'INSERT INTO '.DB_PREFIX."comment (date,poster,gid,comment,mail,url,hide,ip,pid) VALUES ('$utctimestamp','$name','$blogId','$content','$mail','$url','$hide','$ipaddr','$pid')";
改为:
$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')";
2.打开模板目录中的module.php文件,添加:
<?php //获取评论用户操作系统、浏览器等信息 function useragent($info){ require_once 'useragent.class.php'; $useragent = UserAgentFactory::analyze($info); ?> <img src="<?php echo TEMPLATE_URL.$useragent->platform['image']?>"> <?php echo $useragent->platform['title']; ?> <img src="<?php echo TEMPLATE_URL.$useragent->browser['image']?>"> <?php echo $useragent->browser['title']; ?> <?php }?>
然后在module.php评论列表和子评论列表适当位置调用即可:
<?php echo useragent($comment['useragent']); ?>
3.将下载的文件放到模板目录中
文件下载:
4.在数据表中新建一个字段
OK,到此大功告成!
有朋自远方来...评论一下呗O(∩_∩)O