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