fix antispam method

This commit is contained in:
joyqi 2017-08-18 14:20:20 +08:00
parent 13fc1b7169
commit 0ba45f1006
4 changed files with 26 additions and 24 deletions

View File

@ -419,7 +419,7 @@ class Widget_Abstract_Comments extends Widget_Abstract
*
* @param mixed $text
* @access public
* @return void
* @return string
*/
public function autoP($text)
{
@ -443,7 +443,7 @@ class Widget_Abstract_Comments extends Widget_Abstract
*
* @param mixed $text
* @access public
* @return void
* @return string
*/
public function markdown($text)
{

View File

@ -959,7 +959,7 @@ class Widget_Abstract_Contents extends Widget_Abstract
*
* @param mixed $text
* @access public
* @return void
* @return string
*/
public function autoP($text)
{
@ -983,7 +983,7 @@ class Widget_Abstract_Contents extends Widget_Abstract
*
* @param mixed $text
* @access public
* @return void
* @return string
*/
public function markdown($text)
{

View File

@ -306,7 +306,7 @@ class Widget_Archive extends Widget_Abstract_Contents
$commentUrl .= '?parent=' . $reply;
}
return $this->options->commentsAntiSpam ? $commentUrl : $this->security->getTokenUrl($commentUrl);
return $commentUrl;
}
/**
@ -1795,35 +1795,36 @@ class Widget_Archive extends Widget_Abstract_Contents
(function () {
var event = document.addEventListener ? {
add: 'addEventListener',
focus: 'focus',
triggers: ['scroll', 'mousemove', 'keyup', 'touchstart'],
load: 'DOMContentLoaded'
} : {
add: 'attachEvent',
focus: 'onfocus',
triggers: ['onfocus', 'onmousemove', 'onkeyup', 'ontouchstart'],
load: 'onload'
};
}, added = false;
document[event.add](event.load, function () {
var r = document.getElementById('{$this->respondId}');
var r = document.getElementById('{$this->respondId}'),
input = document.createElement('input');
input.type = 'hidden';
input.name = '_';
input.value = " . Typecho_Common::shuffleScriptVar(
$this->security->getToken($this->request->getRequestUrl())) . "
if (null != r) {
var forms = r.getElementsByTagName('form');
if (forms.length > 0) {
var f = forms[0], textarea = f.getElementsByTagName('textarea')[0] || f.text, added = false;
if (null != textarea && 'text' == textarea.name) {
textarea[event.add](event.focus, function () {
if (!added) {
var input = document.createElement('input');
input.type = 'hidden';
input.name = '_';
input.value = " . Typecho_Common::shuffleScriptVar(
$this->security->getToken($this->request->getRequestUrl())) . "
f.appendChild(input);
added = true;
}
});
function append() {
if (!added) {
forms[0].appendChild(input);
added = true;
}
}
for (var i = 0; i < event.triggers.length; i ++) {
var trigger = event.triggers[i];
document[event.add](trigger, append);
window[event.add](trigger, append);
}
}
}

View File

@ -38,6 +38,7 @@ class Widget_Feedback extends Widget_Abstract_Comments implements Widget_Interfa
private function comment()
{
// 使用安全模块保护
$this->security->enable($this->options->commentsAntiSpam);
$this->security->protect();
$comment = array(