public function store(Request $request) { $data = array('secret' => '6LcBGBUTAAAAAIMMSwe-ebmOhgMO3c-vmXn_Yyfb', 'response' => $_POST['g-recaptcha-response']); # Create a connection $url = 'https://www.google.com/recaptcha/api/siteverify'; $ch = curl_init($url); # Form data string $postString = http_build_query($data, '', '&'); # Setting our options curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postString); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); # Get the response $response = curl_exec($ch); curl_close($ch); if (!$response) { Comment::create($request->except('g-recaptcha-response', 'q')); return redirect()->route('front.post', $request->resourceId)->with('success', 'true'); } else { return redirect()->route('front.post', $request->resourceId)->with('success', 'false'); } }
public function destroy(Comment $comment) { $comment->delete(); return redirect()->route('admin.comment.index'); }
public function Post(\Model\Post\ModelName $post) { $contentOriginal = $post->getContent(); $lc = app()->getlocale(); if ($lc == 'kg' && $post->title != '') { } elseif ($lc == 'ru' && $post->titleRu != '') { } else { return redirect()->route('front.home'); } $post->incrementViewed(); $categories = \Model\Category\ModelName::where('general', '=', '1')->get(); $backgroundMain = \Model\Background\ModelName::where('published', '=', true)->first(); $parent = \Model\PhotoParent\ModelName::where('id', '=', $post->parentId)->first(); if ($parent) { $images = json_decode($parent->images); } else { $images = null; } if ($lc == 'kg') { $relatedPosts = \Model\Post\ModelName::where('category_id', '=', $post->category_id)->where('general', '=', '1')->languagekg()->take(6)->skip(0)->orderBy('id', 'desc')->get(); $contentFinal = $contentOriginal; if ($post->related1) { if (strpos($contentFinal, 'POST1LEFT') != false) { $post1Pos = strripos($contentFinal, 'POST1LEFT'); $contentFinal = substr_replace($contentFinal, $post->relatedFunctionLeft($post->related1), $post1Pos, 9); } elseif (strpos($contentFinal, 'POST1RIGHT') != false) { $post1Pos = strripos($contentFinal, 'POST1RIGHT'); $contentFinal = substr_replace($contentFinal, $post->relatedFunctionRight($post->related1), $post1Pos, 10); } } if ($post->related2) { if (strpos($contentFinal, 'POST2LEFT') != false) { $post2Pos = strripos($contentFinal, 'POST2LEFT'); $contentFinal = substr_replace($contentFinal, $post->relatedFunctionLeft($post->related2), $post2Pos, 9); } elseif (strpos($contentFinal, 'POST2RIGHT') != false) { $post2Pos = strripos($contentFinal, 'POST2RIGHT'); $contentFinal = substr_replace($contentFinal, $post->relatedFunctionRight($post->related2), $post2Pos, 10); } } if ($post->related3) { if (strpos($contentFinal, 'POST3LEFT') != false) { $post3Pos = strripos($contentFinal, 'POST3LEFT'); $contentFinal = substr_replace($contentFinal, $post->relatedFunctionLeft($post->related3), $post3Pos, 9); } elseif (strpos($contentFinal, 'POST3RIGHT') != false) { $post3Pos = strripos($contentFinal, 'POST3RIGHT'); $contentFinal = substr_replace($contentFinal, $post->relatedFunctionRight($post->related3), $post3Pos, 10); } } } elseif ($lc == 'ru') { $relatedPosts = \Model\Post\ModelName::where('category_id', '=', $post->category_id)->where('general', '=', '1')->languageru()->take(6)->skip(0)->orderBy('id', 'desc')->get(); $contentFinal = $contentOriginal; if ($post->relatedRu1) { if (strpos($contentFinal, 'POST1LEFT') != false) { $post1Pos = strripos($contentFinal, 'POST1LEFT'); $contentFinal = substr_replace($contentFinal, $post->relatedFunctionLeft($post->relatedRu1), $post1Pos, 9); } elseif (strpos($contentFinal, 'POST1RIGHT') != false) { $post1Pos = strripos($contentFinal, 'POST1RIGHT'); $contentFinal = substr_replace($contentFinal, $post->relatedFunctionRight($post->relatedRu1), $post1Pos, 10); } } if ($post->relatedRu2) { if (strpos($contentFinal, 'POST2LEFT') != false) { $post2Pos = strripos($contentFinal, 'POST2LEFT'); $contentFinal = substr_replace($contentFinal, $post->relatedFunctionLeft($post->relatedRu2), $post2Pos, 9); } elseif (strpos($contentFinal, 'POST2RIGHT') != false) { $post2Pos = strripos($contentFinal, 'POST2RIGHT'); $contentFinal = substr_replace($contentFinal, $post->relatedFunctionRight($post->relatedRu2), $post2Pos, 10); } } if ($post->relatedRu3) { if (strpos($contentFinal, 'POST3LEFT') != false) { $post3Pos = strripos($contentFinal, 'POST3LEFT'); $contentFinal = substr_replace($contentFinal, $post->relatedFunctionLeft($post->relatedRu3), $post3Pos, 9); } elseif (strpos($contentFinal, 'POST3RIGHT') != false) { $post3Pos = strripos($contentFinal, 'POST3RIGHT'); $contentFinal = substr_replace($contentFinal, $post->relatedFunctionRight($post->relatedRu3), $post3Pos, 10); } } } $comments = Comment::where('resourceType', '=', 'post')->where('resourceId', '=', $post->id)->where('approved', '=', '1')->orderBy('id', 'desc')->get(); return view('Front::post.post', ['post' => $post, 'relatedPosts' => $relatedPosts, 'images' => $images, 'content' => $contentFinal, 'comments' => $comments, 'categories' => $categories, 'backgroundMain' => $backgroundMain, 'positionTop' => $this->positionTop, 'positionRight' => $this->positionRight, 'positionCenter' => $this->positionCenter, 'positionBottom' => $this->positionBottom, 'positionLeft' => $this->positionLeft]); }