summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBigCoke233 <hi@guhub.cn>2020-07-11 08:36:13 +0800
committerBigCoke233 <hi@guhub.cn>2020-07-11 08:36:13 +0800
commitb0d993e2a2244cc392c89bd9d4971151dab6e9b4 (patch)
tree2c3690ba00e62096fb46c385ec17d30adc3f75d5
parented54b109c4d95bf3f8f3f481ee884e835018efa6 (diff)
:bug: Fix: 修复评论区无法使用
-rw-r--r--functions.php1
-rw-r--r--includes/comments.php2
-rw-r--r--libs/Comments.php4
-rw-r--r--libs/Utils.php2
4 files changed, 5 insertions, 4 deletions
diff --git a/functions.php b/functions.php
index e9e6d79..b3cbe10 100644
--- a/functions.php
+++ b/functions.php
@@ -2,6 +2,7 @@
<?php
require_once("libs/Utils.php");
require_once("libs/Contents.php");
+require_once("libs/Comments.php");
require_once("libs/Options.php");
/**
diff --git a/includes/comments.php b/includes/comments.php
index b414021..78b6357 100644
--- a/includes/comments.php
+++ b/includes/comments.php
@@ -109,4 +109,4 @@ echo $commentClass;
</div>
</div>
<?php //兼容 typecho 反垃圾
- if ($this->options->commentsAntiSpam) { Comments::AntiSpam($this); } ?> \ No newline at end of file
+ if ($this->options->commentsAntiSpam) { Comments::AntiSpam($this->respondId, Typecho_Common::shuffleScriptVar($this->security->getToken(preg_replace('/\??&?_pjax=[^&]+/i','',$this->request->getRequestUrl())))); } ?> \ No newline at end of file
diff --git a/libs/Comments.php b/libs/Comments.php
index 78fd087..d97b4bc 100644
--- a/libs/Comments.php
+++ b/libs/Comments.php
@@ -15,9 +15,9 @@ class Comments
*
* @access public
*/
- public static function AntiSpam($comment) {
+ public static function AntiSpam($id, $value) {
if ($comment->options->switch && in_array('html', $comment->options->switch)) { echo '<!--<nocompress>-->'; }
- echo '<script>(function(){var a=document.addEventListener?{add:"addEventListener",focus:"focus",load:"DOMContentLoaded"}:{add:"attachEvent",focus:"onfocus",load:"onload"};var c,d,e,f,b=document.getElementById("'.$comment->respondId.'");null!=b&&(c=b.getElementsByTagName("form"),c.length>0&&(d=c[0],e=d.getElementsByTagName("textarea")[0],f=!1,null!=e&&"text"==e.name&&e[a.add](a.focus,function(){if(!f){var a=document.createElement("input");a.type="hidden",a.name="_",d.appendChild(a),f=!0,a.value='.Typecho_Common::shuffleScriptVar($comment->security->getToken($comment->request->getRequestUrl())).'}})))})();</script>';
+ echo '<script>(function(){var a=document.addEventListener?{add:"addEventListener",focus:"focus",load:"DOMContentLoaded"}:{add:"attachEvent",focus:"onfocus",load:"onload"};var c,d,e,f,b=document.getElementById("'.$id.'");null!=b&&(c=b.getElementsByTagName("form"),c.length>0&&(d=c[0],e=d.getElementsByTagName("textarea")[0],f=!1,null!=e&&"text"==e.name&&e[a.add](a.focus,function(){if(!f){var a=document.createElement("input");a.type="hidden",a.name="_",d.appendChild(a),f=!0,a.value='.$value.'}})))})();</script>';
if ($comment->options->switch && in_array('html', $comment->options->switch)) { echo '<!--</nocompress>-->'; }
}
diff --git a/libs/Utils.php b/libs/Utils.php
index 69ebe60..f9785bc 100644
--- a/libs/Utils.php
+++ b/libs/Utils.php
@@ -113,7 +113,7 @@ class Utils
/**
* 自动生成引用
*/
- function addRequires($files,$type,$cdn,$custom) {
+ public static function addRequires($files,$type,$cdn,$custom) {
if ($cdn=='1'){
$path = 'https://cdn.jsdelivr.net/gh/BigCoke233/miracles@'.themeVersion()."/assets/";
}