Browse Source

fix #898 留言改为昵称

magicblack 3 years ago
parent
commit
1faa14a83d
2 changed files with 10 additions and 2 deletions
  1. 5 1
      application/index/controller/Comment.php
  2. 5 1
      application/index/controller/Gbook.php

+ 5 - 1
application/index/controller/Comment.php

@@ -77,8 +77,12 @@ class Comment extends Base
         else{
             $param['comment_name'] = cookie('user_name');
             $param['user_id'] = intval(cookie('user_id'));
+            $user_data = model('User')->field('user_nick_name')->where(['user_id' => $param['user_id']])->find();
+            if (!empty($user_data['user_nick_name'])) {
+                $param['comment_name'] = $user_data['user_nick_name'];
+            }
         }
-        $param['comment_name'] = htmlentities($param['comment_name']);
+        $param['comment_name'] = htmlentities(trim($param['comment_name']));
         $param['comment_rid'] = intval($param['comment_rid']);
         $param['comment_pid'] = intval($param['comment_pid']);
         if($GLOBALS['config']['comment']['audit'] ==1){

+ 5 - 1
application/index/controller/Gbook.php

@@ -83,8 +83,12 @@ class Gbook extends Base
         else{
             $param['gbook_name'] = cookie('user_name');
             $param['user_id'] = intval(cookie('user_id'));
+            $user_data = model('User')->field('user_nick_name')->where(['user_id' => $param['user_id']])->find();
+            if (!empty($user_data['user_nick_name'])) {
+                $param['gbook_name'] = $user_data['user_nick_name'];
+            }
         }
-        $param['gbook_name'] = htmlentities($param['gbook_name']);
+        $param['gbook_name'] = htmlentities(trim($param['gbook_name']));
 
         if($GLOBALS['config']['gbook']['audit'] ==1){
             $param['gbook_status'] = 0;