From 253e09b79e7d046cb13d0843b161c27aa215aaa0 Mon Sep 17 00:00:00 2001 From: koogua Date: Thu, 13 May 2021 20:29:02 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E5=AE=8C=E5=96=84=E7=A7=AF=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Admin/Views/setting/point.volt | 18 ++++++++++++++++++ .../Home/Controllers/QuestionController.php | 3 +++ app/Http/Home/Views/macros/point.volt | 10 ++++++++++ app/Services/Logic/Article/ArticleCreate.php | 1 + .../Logic/Point/History/AnswerPost.php | 6 ++++++ .../Logic/Point/History/CommentPost.php | 4 +++- app/Services/Logic/Question/QuestionCreate.php | 4 +++- 7 files changed, 44 insertions(+), 2 deletions(-) diff --git a/app/Http/Admin/Views/setting/point.volt b/app/Http/Admin/Views/setting/point.volt index 7dafc75f..1d645873 100644 --- a/app/Http/Admin/Views/setting/point.volt +++ b/app/Http/Admin/Views/setting/point.volt @@ -115,6 +115,24 @@ + + 发布问题 + + + + + + + + + 回答问题 + + + + + + +
diff --git a/app/Http/Home/Controllers/QuestionController.php b/app/Http/Home/Controllers/QuestionController.php index cc616caf..0ee20625 100644 --- a/app/Http/Home/Controllers/QuestionController.php +++ b/app/Http/Home/Controllers/QuestionController.php @@ -65,7 +65,10 @@ class QuestionController extends Controller $this->seo->prependTitle('提问题'); + $referer = $this->request->getHTTPReferer(); + $this->view->pick('question/edit'); + $this->view->setVar('referer', $referer); $this->view->setVar('question', $question); $this->view->setVar('xm_tags', $xmTags); } diff --git a/app/Http/Home/Views/macros/point.volt b/app/Http/Home/Views/macros/point.volt index 51918bf5..19ef5d61 100644 --- a/app/Http/Home/Views/macros/point.volt +++ b/app/Http/Home/Views/macros/point.volt @@ -47,6 +47,10 @@ 发布评论 {% elseif value == 10 %} 发布文章 + {% elseif value == 11 %} + 发布问题 + {% elseif value == 12 %} + 发布回答 {% endif %} {%- endmacro %} @@ -78,5 +82,11 @@ {% elseif type == 10 %} {% set article_url = url({'for':'home.article.show','id':info.article.id}) %}

{{ info.article.title }}

+ {% elseif type == 11 %} + {% set question_url = url({'for':'home.question.show','id':info.question.id}) %} +

{{ info.question.title }}

+ {% elseif type == 12 %} + {% set question_url = url({'for':'home.question.show','id':info.question.id}) %} +

{{ info.question.title }}

{% endif %} {%- endmacro %} \ No newline at end of file diff --git a/app/Services/Logic/Article/ArticleCreate.php b/app/Services/Logic/Article/ArticleCreate.php index 616d7857..f382abad 100644 --- a/app/Services/Logic/Article/ArticleCreate.php +++ b/app/Services/Logic/Article/ArticleCreate.php @@ -23,6 +23,7 @@ class ArticleCreate extends LogicService $data = $this->handlePostData($post); $data['published'] = $this->getPublishStatus($user); + $data['owner_id'] = $user->id; $article->create($data); diff --git a/app/Services/Logic/Point/History/AnswerPost.php b/app/Services/Logic/Point/History/AnswerPost.php index 3f4da0e4..6bf957c1 100644 --- a/app/Services/Logic/Point/History/AnswerPost.php +++ b/app/Services/Logic/Point/History/AnswerPost.php @@ -58,10 +58,16 @@ class AnswerPost extends PointHistory $user = $userRepo->findById($answer->owner_id); + $answerSummary = kg_substr($answer->summary, 0, 32); + $eventInfo = [ 'question' => [ 'id' => $question->id, 'title' => $question->title, + ], + 'answer' => [ + 'id' => $answer->id, + 'summary' => $answerSummary, ] ]; diff --git a/app/Services/Logic/Point/History/CommentPost.php b/app/Services/Logic/Point/History/CommentPost.php index a193485b..827db1e1 100644 --- a/app/Services/Logic/Point/History/CommentPost.php +++ b/app/Services/Logic/Point/History/CommentPost.php @@ -53,10 +53,12 @@ class CommentPost extends PointHistory $user = $userRepo->findById($comment->owner_id); + $commentContent = kg_substr($comment->content, 0, 32); + $eventInfo = [ 'comment' => [ 'id' => $comment->id, - 'content' => $comment->content, + 'content' => $commentContent, ] ]; diff --git a/app/Services/Logic/Question/QuestionCreate.php b/app/Services/Logic/Question/QuestionCreate.php index 96cd6b92..f8f2834a 100644 --- a/app/Services/Logic/Question/QuestionCreate.php +++ b/app/Services/Logic/Question/QuestionCreate.php @@ -22,6 +22,8 @@ class QuestionCreate extends LogicService $data = $this->handlePostData($post); + $data['published'] = $this->getPublishStatus($user); + $data['owner_id'] = $user->id; $question->create($data); @@ -39,7 +41,7 @@ class QuestionCreate extends LogicService protected function getPublishStatus(UserModel $user) { - return $user->question_count > 3 ? QuestionModel::PUBLISH_APPROVED : QuestionModel::PUBLISH_PENDING; + return $user->question_count > 100 ? QuestionModel::PUBLISH_APPROVED : QuestionModel::PUBLISH_PENDING; } protected function recountUserQuestions(UserModel $user) From a1d38eee9a302e9e7d4f98da06e384d7977f2366 Mon Sep 17 00:00:00 2001 From: koogua Date: Mon, 12 Jul 2021 10:10:56 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Library/AppInfo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Library/AppInfo.php b/app/Library/AppInfo.php index 351bec49..acf6df78 100644 --- a/app/Library/AppInfo.php +++ b/app/Library/AppInfo.php @@ -16,7 +16,7 @@ class AppInfo protected $link = 'https://koogua.com'; - protected $version = '1.3.7'; + protected $version = '1.3.8'; public function __get($name) { From 69f41d71c7ebb37e1be4ef15cd009f17a872dbb7 Mon Sep 17 00:00:00 2001 From: koogua Date: Tue, 13 Jul 2021 10:02:49 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E7=83=AD=E9=97=A8=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=BF=87=E6=BB=A4=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Caches/HotQuestionList.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Caches/HotQuestionList.php b/app/Caches/HotQuestionList.php index d6d533b8..e09b517d 100644 --- a/app/Caches/HotQuestionList.php +++ b/app/Caches/HotQuestionList.php @@ -111,6 +111,7 @@ class HotQuestionList extends Cache { return QuestionModel::query() ->where('create_time > :create_time:', ['create_time' => $createTime]) + ->andWhere('published = 1 AND deleted = 0') ->orderBy('score DESC') ->limit($limit) ->execute(); From 6174b3fc7b3e1fd5f5268be5e730656cc871f65f Mon Sep 17 00:00:00 2001 From: koogua Date: Wed, 28 Jul 2021 10:37:16 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E6=81=A2=E5=A4=8D=E9=81=97=E6=BC=8F?= =?UTF-8?q?=E7=9A=84=E6=95=B0=E6=8D=AE=E8=BF=81=E7=A7=BB=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/migrations/20210720153027.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/db/migrations/20210720153027.php b/db/migrations/20210720153027.php index fe48bbe8..21e1f9d8 100644 --- a/db/migrations/20210720153027.php +++ b/db/migrations/20210720153027.php @@ -19,8 +19,10 @@ final class V20210720153027 extends AbstractMigration $this->alterTagTable(); $this->handleTagScopes(); $this->handleCategoryIcon(); + $this->handleCourseTags(); $this->handleReviewPublish(); $this->handleConsultPublish(); + $this->handleRoleRoutes(); } protected function createCourseTagTable() From 6412c8367159210ecf0cb4d289426ed45fcc74fa Mon Sep 17 00:00:00 2001 From: jacky huang Date: Mon, 9 Aug 2021 20:06:35 +0800 Subject: [PATCH 5/6] Create SECURITY.md --- SECURITY.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 SECURITY.md diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000..249f19b8 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,5 @@ +# Security Policy + +## Reporting a Vulnerability + +Please report security issues to `xiaochong0302@gmail.com` From 7ac456bb67b55280a313f8e209156913e1e5dbf6 Mon Sep 17 00:00:00 2001 From: koogua Date: Wed, 8 Sep 2021 12:18:06 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E9=AA=8C=E8=AF=81=E6=B5=AE=E7=82=B9=E6=95=B0?= =?UTF-8?q?=E7=B2=BE=E5=BA=A6=E4=B8=A2=E5=A4=B1=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/Pay/Wxpay.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Services/Pay/Wxpay.php b/app/Services/Pay/Wxpay.php index 82273537..86c8493e 100644 --- a/app/Services/Pay/Wxpay.php +++ b/app/Services/Pay/Wxpay.php @@ -185,7 +185,12 @@ class Wxpay extends PayService if (!$trade) return false; - if ($data->total_fee != 100 * $trade->amount) { + /** + * 注意浮点数精度丢失问题 + */ + $amount = intval(strval(100 * $trade->amount)); + + if ($data->total_fee != $amount) { return false; }