recaptcha added to contact us page
This commit is contained in:
parent
625fa1905b
commit
185e2808b1
|
|
@ -7,15 +7,14 @@ use Illuminate\Support\Facades\DB;
|
|||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Mail\SendMail;
|
||||
use App\User;
|
||||
use App\Rules\ReCaptchaRule;
|
||||
use ReCaptcha\ReCaptcha;
|
||||
|
||||
|
||||
|
||||
class ContactController extends Controller
|
||||
{
|
||||
|
||||
|
||||
public function habarlashyk(){
|
||||
|
||||
return view('web.habarlashyk')->with([
|
||||
'title' => 'Turkmen Tv | Habarlashyk',
|
||||
'keywords' => '',
|
||||
|
|
@ -23,20 +22,30 @@ class ContactController extends Controller
|
|||
]);
|
||||
}
|
||||
|
||||
public function send(Request $request){
|
||||
$data = array(
|
||||
'name' => $request->name,
|
||||
'email' => $request->email,
|
||||
'subject' => $request->subject,
|
||||
'message' => $request->message
|
||||
);
|
||||
Mail::send('email_temp', [
|
||||
'data' => $data
|
||||
], function ($message) use ($request) {
|
||||
$message->to('admin@turkmentv.gov.tm');
|
||||
$message->subject($request->subject);
|
||||
});
|
||||
return back()->with('success', 'Hat ustunlikli ugradyldy!');
|
||||
public function send(Request $request){
|
||||
$recapresponse = $request['g-recaptcha-response'];
|
||||
$recaptcha = new ReCaptcha('6LelUOQZAAAAAHBAEnflw1XLOvCgaAeKQb4TilEb');
|
||||
|
||||
$resp = $recaptcha->verify($recapresponse, $_SERVER['REMOTE_ADDR']);
|
||||
|
||||
if($resp->isSuccess()) {
|
||||
$data = array(
|
||||
'name' => $request->name,
|
||||
'email' => $request->email,
|
||||
'subject' => $request->subject,
|
||||
'message' => $request->message
|
||||
);
|
||||
Mail::send('email_temp', [
|
||||
'data' => $data
|
||||
], function ($message) use ($request) {
|
||||
$message->to('admin@turkmentv.gov.tm');
|
||||
$message->subject($request->subject);
|
||||
});
|
||||
return back()->with('success', 'Hat ustunlikli ugradyldy!');
|
||||
}
|
||||
else {
|
||||
return back()->with('success', 'Hat iberilmedi! Recaptcha ýalňyşlygy ýüze çykdy');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
namespace App\Rules;
|
||||
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
use ReCaptcha\ReCaptcha;
|
||||
|
||||
class ReCaptchaRule implements Rule
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{}
|
||||
|
||||
public function passes($attribute, $value)
|
||||
{
|
||||
// if (empty($value)) {
|
||||
// $this->error_msg = ':attribute field is required.';
|
||||
|
||||
// return false;
|
||||
// }
|
||||
|
||||
$recaptcha = new ReCaptcha('6LelUOQZAAAAAHBAEnflw1XLOvCgaAeKQb4TilEb');
|
||||
$resp = $recaptcha->verify($value, $_SERVER['REMOTE_ADDR']);
|
||||
//dd($resp);
|
||||
// if (!$resp->isSuccess()) {
|
||||
// $this->error_msg = 'ReCaptcha field is required.';
|
||||
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// if ($resp->getScore() < 0.5) {
|
||||
// $this->error_msg = 'Failed to validate captcha.';
|
||||
|
||||
// return false;
|
||||
// }
|
||||
|
||||
|
||||
return $resp;
|
||||
|
||||
}
|
||||
|
||||
public function message()
|
||||
{
|
||||
return "smth went wrong";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -15,6 +15,7 @@
|
|||
"barryvdh/laravel-elfinder": "^0.4.2",
|
||||
"davejamesmiller/laravel-breadcrumbs": "^5.2",
|
||||
"fideloper/proxy": "^4.0",
|
||||
"google/recaptcha": "^1.2",
|
||||
"guzzlehttp/guzzle": "^6.3",
|
||||
"laravel/framework": "5.8.*",
|
||||
"laravel/tinker": "^1.0",
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "3d83530c66a136ce4bbf2ebd38d3674f",
|
||||
"content-hash": "21274219b9e40c8c166930236c920a86",
|
||||
"packages": [
|
||||
{
|
||||
"name": "almasaeed2010/adminlte",
|
||||
|
|
@ -111,6 +111,7 @@
|
|||
"backpack",
|
||||
"base"
|
||||
],
|
||||
"abandoned": "backpack/crud",
|
||||
"time": "2019-03-19T08:08:26+00:00"
|
||||
},
|
||||
{
|
||||
|
|
@ -805,6 +806,7 @@
|
|||
"keywords": [
|
||||
"laravel"
|
||||
],
|
||||
"abandoned": "diglactic/laravel-breadcrumbs",
|
||||
"time": "2019-02-27T13:09:37+00:00"
|
||||
},
|
||||
{
|
||||
|
|
@ -1403,6 +1405,53 @@
|
|||
],
|
||||
"time": "2019-01-10T14:06:47+00:00"
|
||||
},
|
||||
{
|
||||
"name": "google/recaptcha",
|
||||
"version": "1.2.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/google/recaptcha.git",
|
||||
"reference": "614f25a9038be4f3f2da7cbfd778dc5b357d2419"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/google/recaptcha/zipball/614f25a9038be4f3f2da7cbfd778dc5b357d2419",
|
||||
"reference": "614f25a9038be4f3f2da7cbfd778dc5b357d2419",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.5"
|
||||
},
|
||||
"require-dev": {
|
||||
"friendsofphp/php-cs-fixer": "^2.2.20|^2.15",
|
||||
"php-coveralls/php-coveralls": "^2.1",
|
||||
"phpunit/phpunit": "^4.8.36|^5.7.27|^6.59|^7.5.11"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.2.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"ReCaptcha\\": "src/ReCaptcha"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"description": "Client library for reCAPTCHA, a free service that protects websites from spam and abuse.",
|
||||
"homepage": "https://www.google.com/recaptcha/",
|
||||
"keywords": [
|
||||
"Abuse",
|
||||
"captcha",
|
||||
"recaptcha",
|
||||
"spam"
|
||||
],
|
||||
"time": "2020-03-31T17:50:54+00:00"
|
||||
},
|
||||
{
|
||||
"name": "guzzlehttp/guzzle",
|
||||
"version": "6.3.3",
|
||||
|
|
@ -1696,6 +1745,7 @@
|
|||
"email": "jakub.onderka@gmail.com"
|
||||
}
|
||||
],
|
||||
"abandoned": "php-parallel-lint/php-console-color",
|
||||
"time": "2018-09-29T17:23:10+00:00"
|
||||
},
|
||||
{
|
||||
|
|
@ -1742,6 +1792,7 @@
|
|||
}
|
||||
],
|
||||
"description": "Highlight PHP code in terminal",
|
||||
"abandoned": "php-parallel-lint/php-console-highlighter",
|
||||
"time": "2018-09-29T18:48:56+00:00"
|
||||
},
|
||||
{
|
||||
|
|
@ -2210,6 +2261,7 @@
|
|||
"bcmath",
|
||||
"math"
|
||||
],
|
||||
"abandoned": "brick/math",
|
||||
"time": "2017-02-16T16:54:46+00:00"
|
||||
},
|
||||
{
|
||||
|
|
@ -6268,5 +6320,6 @@
|
|||
"platform": {
|
||||
"php": "^7.1.3"
|
||||
},
|
||||
"platform-dev": []
|
||||
"platform-dev": [],
|
||||
"plugin-api-version": "1.1.0"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,9 +74,12 @@
|
|||
<a href="https://info.flagcounter.com/Rtpe"><img src="https://s11.flagcounter.com/count2/Rtpe/bg_FFFFFF/txt_000000/border_CCCCCC/columns_8/maxflags_15/viewers_0/labels_0/pageviews_0/flags_0/percent_0/" alt="Flag Counter" border="0"></a>
|
||||
<!-- //Rating@Mail.ru counter -->
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
<br/><br/>
|
||||
<h1>2019 © TurkmenTV</h1>
|
||||
<script src="{{asset('static/js/jquery-2.1.4.min.js')}}"></script>
|
||||
<script src="{{asset('static/js/bootstrap.min.js')}}"></script>
|
||||
<script src="{{asset('js/app.js')}}"></script>
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
{{-- <h2 style="margin-top: 50px"><a href="" class="fontSemiBold">Habarlaşmak üçin <i class="fa fa-play-circle-o"></i></a></h2>--}}
|
||||
<div class="contact-form">
|
||||
|
||||
<form method='post' action='{{ url("contact/send") }}' class="col-lg-6 col-lg-offset-3 col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2 col-xs-12">
|
||||
<form id="contactForm" method='post' action='{{ url("contact/send") }}' class="col-lg-6 col-lg-offset-3 col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2 col-xs-12">
|
||||
@if($message = Session::get('success'))
|
||||
<div class="alert alert-success alert-block">
|
||||
<button type="button" class="close" data-dismiss="alert">
|
||||
|
|
@ -68,16 +68,23 @@
|
|||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-lg-10 col-lg-offset-1 col-md-10 col-md-offset-1 col-sm-12 col-xs-12">
|
||||
<input type="submit" class="btn btn-default" style="width: 100%; margin-top: 20px"
|
||||
value="Ugrat">
|
||||
<button class="btn btn-default g-recaptcha"
|
||||
data-sitekey="reCAPTCHA_site_key"
|
||||
data-callback='onSubmit'
|
||||
style="width: 100%; margin-top: 20px"
|
||||
data-action='submit'>Ugrat</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<script src="https://www.google.com/recaptcha/api.js"></script>
|
||||
<script>
|
||||
function onSubmit(token) {
|
||||
document.getElementById("contactForm").submit();
|
||||
}
|
||||
</script>
|
||||
@endsection
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
{{-- <h2 style="margin-top: 50px"><a href="" class="fontSemiBold">Habarlaşmak üçin <i class="fa fa-play-circle-o"></i></a></h2>--}}
|
||||
<div class="contact-form">
|
||||
|
||||
<form method='post' action='{{ url("contact/send") }}' class="col-lg-6 col-lg-offset-3 col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2 col-xs-12">
|
||||
<form id="demo-form" method='post' action='{{ url("contact/send") }}' onsubmit="onSubmit('6LelUOQZAAAAACceE0RqWbeFv0qBKjqeXxBjPQln')" class="col-lg-6 col-lg-offset-3 col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2 col-xs-12">
|
||||
@if($message = Session::get('success'))
|
||||
<div class="alert alert-success alert-block">
|
||||
<button type="button" class="close" data-dismiss="alert">
|
||||
|
|
@ -35,7 +35,6 @@
|
|||
<strong>{{ $message }}</strong>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
{{ csrf_field() }}
|
||||
|
||||
<div class="form-group">
|
||||
|
|
@ -66,18 +65,26 @@
|
|||
<textarea id='message' name='message' class='form-control' id='contact-message'
|
||||
rows='5' cols='100' style='margin-top: 5px;'></textarea> </label>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-lg-10 col-lg-offset-1 col-md-10 col-md-offset-1 col-sm-12 col-xs-12">
|
||||
<input type="submit" class="btn btn-default" style="width: 100%; margin-top: 20px"
|
||||
value="Ugrat">
|
||||
<button class="btn btn-default g-recaptcha"
|
||||
data-sitekey="6LelUOQZAAAAACceE0RqWbeFv0qBKjqeXxBjPQln"
|
||||
style="width: 100%; margin-top: 20px"
|
||||
data-callback='onSubmit'
|
||||
data-action='submit'>Ugrat</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<script src="https://www.google.com/recaptcha/api.js?render=6LelUOQZAAAAACceE0RqWbeFv0qBKjqeXxBjPQln"></script>
|
||||
<script>
|
||||
function onSubmit(token) {
|
||||
console.log(token);
|
||||
document.getElementById("demo-form").submit();
|
||||
}
|
||||
</script>
|
||||
@endsection
|
||||
|
|
|
|||
|
|
@ -12,37 +12,43 @@
|
|||
</ul>
|
||||
</div> </div>
|
||||
<div class="col-lg-3 col-md-3 col-sm-3 col-xs-6">
|
||||
<div class="tpl-block-list tpl-component-bottommenu2" id="nc-block-046b0969c2c6c0d1387303a23437d5d5"><ul>
|
||||
<li><a href="{{ route('newsList') }}" class = "fontRegular">Habarlar </li>
|
||||
<div class="tpl-block-list tpl-component-bottommenu2" id="nc-block-046b0969c2c6c0d1387303a23437d5d5">
|
||||
<ul>
|
||||
<li><a href="{{ route('newsList') }}" class = "fontRegular">Habarlar </li>
|
||||
|
||||
<li><a href="#" class = "fontRegular">Altyn Asyr</a></li>
|
||||
<li><a href="#" class = "fontRegular">Altyn Asyr</a></li>
|
||||
|
||||
<li><a href="#" class = "fontRegular">Aşgabat</a></li>
|
||||
<li><a href="#" class = "fontRegular">Aşgabat</a></li>
|
||||
|
||||
<li><a href="#" class = "fontRegular">Miras</a></li>
|
||||
<li><a href="#" class = "fontRegular">Miras</a></li>
|
||||
|
||||
<li><a href="#" class = "fontRegular">Türkmen owazy</a></li>
|
||||
</ul></div> </div>
|
||||
<li><a href="#" class = "fontRegular">Türkmen owazy</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-3 col-md-3 col-sm-3 col-xs-6">
|
||||
<div class="tpl-block-list tpl-component-bottommenu3" id="nc-block-ae49c1a6302481a184cbfb48f4ab1f7d"><ul>
|
||||
<div class="tpl-block-list tpl-component-bottommenu3" id="nc-block-ae49c1a6302481a184cbfb48f4ab1f7d">
|
||||
<ul>
|
||||
<li><a href="#" class = "fontRegular">Türkmenistan Sport</a></li>
|
||||
|
||||
<li><a href="#" class = "fontRegular">Türkmenistan Sport</a></li>
|
||||
<li><a href="#" class = "fontRegular">Türkmenistan</a></li>
|
||||
|
||||
<li><a href="#" class = "fontRegular">Türkmenistan</a></li>
|
||||
|
||||
<li><a href="#" class = "fontRegular">Ýaşlyk</a></li>
|
||||
</ul></div> </div>
|
||||
<li><a href="#" class = "fontRegular">Ýaşlyk</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-3 col-md-3 col-sm-3 col-xs-6">
|
||||
<div class="tpl-block-list tpl-component-bottommenu4" id="nc-block-d02f08f391f24158d5e8733c4b7f4446">
|
||||
{{-- <ul>
|
||||
|
||||
<li><a href="#" class = "fontRegular">Русский</a></li>
|
||||
<li><a href="#" class = "fontRegular">Русский</a></li>
|
||||
|
||||
<li><a href="#" class = "fontRegular">English</a></li>
|
||||
<li><a href="#" class = "fontRegular">English</a></li>
|
||||
|
||||
<li><a href="#" class = "fontRegular">Türkmen</a></li>
|
||||
</ul> --}}
|
||||
</div> </div>
|
||||
<li><a href="#" class = "fontRegular">Türkmen</a></li>
|
||||
</ul> --}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -85,6 +91,8 @@
|
|||
<!-- <a href="https://info.flagcounter.com/Rtpe"><img src="https://s11.flagcounter.com/count2/Rtpe/bg_FFFFFF/txt_000000/border_CCCCCC/columns_8/maxflags_15/viewers_0/labels_0/pageviews_0/flags_0/percent_0/" alt="Flag Counter" border="0"></a> -->
|
||||
<!-- //Rating@Mail.ru counter -->
|
||||
</div>
|
||||
<h4 style="color: #fff">{{ now()->format('Y') }} © TurkmenTV. All rights reserved.</h4>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</footer>
|
||||
|
|
|
|||
Loading…
Reference in New Issue