diff --git a/app/Http/Controllers/SiteController.php b/app/Http/Controllers/SiteController.php index 5829e68..4d1983a 100644 --- a/app/Http/Controllers/SiteController.php +++ b/app/Http/Controllers/SiteController.php @@ -57,6 +57,14 @@ class SiteController extends Controller { $get->display_name = $p->display_name; foreach ($get->comments as $k => $c) { + if (count(userDetail($c->user_id)) > 0) { + $det = userDetail($c->user_id); + $c->user_id = $det['user_id']; + $c->showname = $det['showname']; + $c->showcol = $det['showcol']; + $c->avatar = $det['avatar']; + } + if ($c->isShadow == 0) { if (getIp() != $c->ipaddress) unset($get->comments[$k]); } @@ -82,6 +90,7 @@ class SiteController extends Controller { } } + $get->user = userDetail(null, $kero); $get->post_date = strftime('%Y/%m/%d(%a) %H:%M:%S %Z', $get->post_date); $get->publish_date = strftime('%Y/%m/%d(%a) %H:%M:%S %Z', $get->publish_date); @@ -96,6 +105,7 @@ class SiteController extends Controller { $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 : ''), 'name' => $com['name'], @@ -110,6 +120,15 @@ class SiteController extends Controller { $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 (count(userDetail($r->user_id)) > 0) { + $det = userDetail($r->user_id); + $res->user_id = $det['user_id']; + $res->showname = $det['showname']; + $res->showcol = $det['showcol']; + $res->avatar = $det['avatar']; + } + return array('status' => '010100', 'message' => 'OK', 'result' => $res); } diff --git a/app/Http/Controllers/VideoController.php b/app/Http/Controllers/VideoController.php index 4f81dab..b0c1381 100644 --- a/app/Http/Controllers/VideoController.php +++ b/app/Http/Controllers/VideoController.php @@ -66,16 +66,25 @@ class VideoController extends Controller { $res->mgametitle = $game->name; $slugger = $res->vid; $res->slug = $game->slug; + $res->pageslug = $vid; if ($res->gametitle == '') $res->gametitle = '初代'; - $comments = DB::table('blg_comments')->where('video_id', $slugger)->orderBy('id', 'asc')->get()->toArray(); + $comments = DB::table('blg_comments')->where('video_id', $vid)->orderBy('id', 'asc')->get()->toArray(); $ytslug = explode('?v=', $res->youtube); $res->ytcomment = $this->getYouTubeCome($ytslug[1]); $res->nicocomment = array(); $res->bccomment = array(); foreach ($comments as $k => $c) { + if (count(userDetail($c->user_id)) > 0) { + $det = userDetail($c->user_id); + $c->user_id = $det['user_id']; + $c->showname = $det['showname']; + $c->showcol = $det['showcol']; + $c->avatar = $det['avatar']; + } + if ($c->isShadow == 0) { if (getIp() != $c->ipaddress) unset($comments[$k]); } @@ -87,6 +96,7 @@ class VideoController extends Controller { } } + $res->user = userDetail(null, $this->cook); $res->comments = $comments; return view('pages.site.video.prayer', ['res' => $res, 'menu' => $this->menu, 'user' => $this->user]); diff --git a/app/helpers.php b/app/helpers.php index 24e2cb9..d577c8c 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -23,4 +23,37 @@ function getIp () { return $ip; } +function userDetail ($id, $kero=null) { + if ($kero || $id) { + $log_username = null; + if (!is_null($id)) $log_username = DB::table('users')->select('id', 'username')->where('id', $id)->first(); + else $log_username = DB::table('users')->select('id', 'username')->where('kero_token', $kero)->first(); + $perm_id = DB::table('usr_perm_id')->select('perm_id')->where('user_id', $log_username->id)->first()->perm_id; + $p3 = DB::table('usr_profile')->select('gender', 'avatar', 'name_style', 'display_name')->where('user_id', $log_username->id)->first(); + $user_id = $log_username->id; + $log_username = $log_username->username; + $showname = ''; + $showcol = ''; + + if (!empty($p3->display_name)) $showname = $p3->display_name; + else $showname = $log_username; + + if (!empty($p3->name_style)) $showcol = $p3->name_style; + else { + foreach ($ucol as $j3) { + if ($j3->id == $perm_id) { + if ($p3->gender == 1) $showcol = $j3->colour_m; + else if ($p3->gender == 2) $showcol = $j3->colour_f; + else $showcol = $j3->colour_u; + } + } + } + + $p3->avatar = ($p3->avatar ? '/'.$p3->avatar : '/img/noicon.webp'); + return array('user_id' => $user_id, 'showname' => $showname, 'showcol' => $showcol, 'avatar' => $p3->avatar); + } + + return array(); +} + ?> diff --git a/resources/js/components/comments.vue b/resources/js/components/comments.vue index c9758e5..a2c3cc7 100644 --- a/resources/js/components/comments.vue +++ b/resources/js/components/comments.vue @@ -13,7 +13,10 @@ {{ (c.name || '名無しのテクニシャン') }} - {{ (c.name || '名無しのテクニシャン') }} + + {{ c.showname }} + {{ (c.name || '名無しのテクニシャン') }} + より: {{ c.created }} @@ -26,18 +29,28 @@
{{ err }}
-
-
名前
-
- + +
+
名前
+
+ +
-
-
-
メールアドレス
-
- +
+
メールアドレス
+
+ +
-
+ + +
+
名前
+ +
+
本文
@@ -55,7 +68,7 @@