From 59883e0a2d5fadcdd056a4084443ae4ed78ae020 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=86=E3=82=AF=E3=83=8B=E3=82=AB=E3=83=AB=E8=AB=8F?= =?UTF-8?q?=E8=A8=AA=E5=AD=90?= Date: Sat, 4 Sep 2021 17:21:11 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=82=E3=81=86=E3=82=B7=E3=83=B3=E3=83=97?= =?UTF-8?q?=E3=83=AB=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Home/Comment.php | 28 ++++++------------- .../views/pages/common/comments.blade.php | 2 -- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/app/Http/Controllers/Home/Comment.php b/app/Http/Controllers/Home/Comment.php index dbd1c9d..dce1fe1 100644 --- a/app/Http/Controllers/Home/Comment.php +++ b/app/Http/Controllers/Home/Comment.php @@ -8,7 +8,8 @@ use Illuminate\Http\Request; class Comment { public function add (Request $r) { if (!isset($r->submit)) return ''; - if ($r->isvideo == 'f') $id = DB::table('blg_content')->select('id')->where('slug', $r->slug)->first()->id; + $isvideo = false; + if (!$cont = DB::table('blg_content')->where('slug', $r->slug)->first()) { if ($cont = DB::table('vid_video')->where('vid', $r->slug)->first()) $isvideo = true; } $banned = DB::table('blg_blacklist')->where('isShadow', 0)->get(); foreach ($banned as $b) { $ip = explode('.', getIp()); @@ -20,13 +21,15 @@ class Comment { ) return redirect('/bot-trap/'); } - if ($r->user_id == 0 && (str_contains($r->newmessage, 'http://') || str_contains($r->newmessage, 'https://'))) return redirect('/'); + $user = null; + if (isset($_COOKIE['kero_token'])) $user = DB::table('users')->select('id')->where('kero_token', $_COOKIE['kero_token'])->first()->id; + if ($user == 0 && (str_contains($r->newmessage, 'http://') || str_contains($r->newmessage, 'https://'))) return redirect('/'); $shadow = DB::table('blg_blacklist')->where('isShadow', 1)->where('ipaddress', getIp())->first(); $add = DB::table('blg_comments')->insertGetId([ - 'user_id' => ($r->user_id != 0 ?: null), - 'post_id' => ($r->isvideo == 'f' ? $id : 0), - 'video_id' => ($r->isvideo == 't' ? $r->slug : ''), + 'user_id' => $user, + 'post_id' => (!$isvideo ? $cont->id : 0), + 'video_id' => ($isvideo ? $r->slug : ''), 'name' => (isset($r->newname) ? $r->newname : null), 'email' => (isset($r->newmail) ? $r->newmail : null), 'message' => $r->newmessage, @@ -37,19 +40,6 @@ class Comment { // 返事だったら、メールを送って - $res = DB::table('blg_comments')->select('id', 'name', 'created', 'message')->where('id', $add)->first(); - $res->created = date('Y年m月d日 H:i:s', $res->created); - - if (!is_null($r->user_id) && !empty(userDetail($r->user_id))) { - $det = userDetail($r->user_id); - $res->user_id = $det['user_id']; - $res->showname = $det['showname']; - $res->showcol = $det['showcol']; - $res->avatar = $det['avatar']; - $res->replyCount = 0; - $res->isvideo = $r->isvideo; - } - - return redirect('/'.($r->isvideo == 't' ? 'video/play' : 'blog').'/'.$r->slug.'#comment-'.$add); + return redirect('/'.($isvideo ? 'video/play' : 'blog').'/'.$r->slug.'#comment-'.$add); } } \ No newline at end of file diff --git a/resources/views/pages/common/comments.blade.php b/resources/views/pages/common/comments.blade.php index 67476ea..3b7a0cf 100644 --- a/resources/views/pages/common/comments.blade.php +++ b/resources/views/pages/common/comments.blade.php @@ -25,7 +25,6 @@ {{ $user['showname'] }}さんのアイコン {{ $user['showname'] }} - @endif
本文 必須
@@ -33,7 +32,6 @@
-