本文转载自:[极一Blog][1] ##前言 老高写的TpCache插件配合Redis确实是非常好用,但是一直存在一个很大的问题。当文章被评论后,评论者的个人信息也会被自动缓存下来(原本是保存在访客的cookies中的),导致下一个访客会看到上一个评论者的信息,造成信息泄露。 但是老高一直建议大家使用第三方评论系统,所以也没有去修复这个Bug。本篇文章通过修改comments.php文件解决了这个问题。 ##教程 首先编辑/usr/themes/你的主题/component/comments.php文件 分别找到这三个语句并全部替换为空值: ``` remember('author'); ?> remember('mail'); ?> remember('url'); ?> ``` 找到下列语句; ``` ``` 并修改为: ``` ``` 然后在文件底部插入一下代码: ``` 保存即可。 [1]: https://www.jiyiblog.com/archives/0324107.html 本文转载自:极一Blog前言老高写的TpCache插件配合Redis确实是非常好用,但是一直存在一个很大的问题。当文章被评论后,评论者的个人信息也会被自动缓存下来(原本是保存在访客的cookies中的),导致下一个访客会看到上一个评论者的信息,造成信息泄露。但是老高一直建议大家使用第三方评论系统,所以也没有去修复这个Bug。本篇文章通过修改comments.php文件解决了这个问题。教程首先编辑/usr/themes/你的主题/component/comments.php文件分别找到这三个语句并全部替换为空值:<?php $this->remember('author'); ?> <?php $this->remember('mail'); ?> <?php $this->remember('url'); ?>找到下列语句;<div id="author_info" class="hide">并修改为:<div id="author_info">然后在文件底部插入一下代码:<script> <?php if(!$this->user->hasLogin()){ ?> function getCookie(name){ var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)"); if(arr=document.cookie.match(reg)) return unescape(decodeURI(arr[2])); else return null; } function adduser(){ document.getElementById('author').value = getCookie('<?php echo md5($this->request->getUrlPrefix()); ?>__typecho_remember_author'); document.getElementById('mail').value = getCookie('<?php echo md5($this->request->getUrlPrefix()); ?>__typecho_remember_mail'); document.getElementById('url').value = getCookie('<?php echo md5($this->request->getUrlPrefix()); ?>__typecho_remember_url'); } adduser(); <?php } ?> </script> 保存即可。 Last modification:June 30, 2020 © Allow specification reprint Like 如果觉得我的文章对你有用,请随意赞赏 文章引用 反向引用 Loading... 暂未引用其他文章 暂未被其它文章引用 Next Previous One comment Loading... 躲闪的匿名人士 July 26th, 2024 at 10:59 am 无法评论呢 Reply Leave a Comment Cancel reply 使用cookie技术保留您的个人信息以便您下次快速评论,继续评论表示您已同意该条款 Comment * Private comment Name * 🎲 Email Site Leave a Comment submitting...
One comment
无法评论呢