shell bypass 403
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Response;
use Illuminate\Support\Str;
use App\Models\Comment;
use App\Models\CommentReplay;
use App\Models\Post;
use Auth;
class CommentController extends Controller
{
//
public function insert_comment(Request $req)
{
if(auth()->check())
{
$id = $req->postId;
$post = Post::find($id);
if(!$post)
{
return response()->json(['posterror'=>'Post Not Found!']);
}
$validation = Validator::make($req->all(),[
'Comment' => 'required|max:3000',
],[
'Comment.required' => 'Please Enter Comment Text',
'Comment.max' => 'Comment Max Length Is 3000',
]);
if(!$validation->passes())
{
return response()->json(['error'=>$validation->errors()]);
}
else
{
$AddComment = new Comment;
$AddComment->post_id = $id;
$AddComment->user_id = Auth::user()->id;
$AddComment->comment = $req->Comment;
$AddComment->save();
return response()->json(['success'=>'Comment Add Successfully']);
}
}
else
{
return response()->json(['loginerror'=>'Please Login First']);
}
}
public function reply_comment(Request $req)
{
if(auth()->check())
{
$id = $req->commentId;
$comment = Comment::find($id);
if(!$comment)
{
return response()->json(['commenterror'=>'Comment Not Found!']);
}
$validation = Validator::make($req->all(),[
'reply' => 'required|max:3000',
],[
'reply.required' => 'Please Enter Comment Text',
'reply.max' => 'Comment Max Length Is 3000',
]);
if(!$validation->passes())
{
return response()->json(['error'=>$validation->errors()]);
}
else
{
$AddReply = new CommentReplay;
$AddReply->comment_id = $req->commentId;
$AddReply->user_id = Auth::user()->id;
$AddReply->comment = $req->reply;
$AddReply->save();
return response()->json(['success'=>'Replay Add Successfully']);
}
}
else
{
return response()->json(['loginerror'=>'Please Login First']);
}
}
}