Browse Source

もうシンプルに

dev-master
parent
commit
59883e0a2d
  1. 28
      app/Http/Controllers/Home/Comment.php
  2. 2
      resources/views/pages/common/comments.blade.php

28
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);
}
}

2
resources/views/pages/common/comments.blade.php

@ -25,7 +25,6 @@
<a href="/profile/{{ $user['user_id'] }}" style="{{ $user['showcol'] }}"><img style="width: 24px; height: 24px;" src="{{ $user['avatar'] }}" alt="{{ $user['showname'] }}さんのアイコン"> {{ $user['showname'] }}</a>
</div>
</div>
<input type="hidden" name="user_id" value="{{ $user['user_id'] }}" />
@endif
<div class="row">
<div class="col-md-4 col-lg-3">本文 <span class="badge badge-danger">必須</span></div>
@ -33,7 +32,6 @@
<textarea class="form-control" name="newmessage" rows="4"></textarea>
</div>
</div>
<input type="hidden" name="isvideo" value="{{ $isvideo }}" />
<input type="hidden" name="slug" value="{{ $slug }}" />
<div class="row" style="margin-top: 16px;">
<div class="col">

Loading…
Cancel
Save