diff --git a/app/Http/Controllers/ContactController.php b/app/Http/Controllers/ContactController.php index c399cb35..e869ed54 100644 --- a/app/Http/Controllers/ContactController.php +++ b/app/Http/Controllers/ContactController.php @@ -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,21 +22,31 @@ 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'); + } + } public function sendMail(Request $request){ diff --git a/app/Rules/ReCaptchaRule.php b/app/Rules/ReCaptchaRule.php new file mode 100644 index 00000000..1c34e8f5 --- /dev/null +++ b/app/Rules/ReCaptchaRule.php @@ -0,0 +1,47 @@ +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"; + } + +} \ No newline at end of file diff --git a/composer.json b/composer.json index 6e0a47e5..f0183bba 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/composer.lock b/composer.lock index 980776b6..3246c68f 100644 --- a/composer.lock +++ b/composer.lock @@ -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" } diff --git a/resources/views/layouts/footer.blade.php b/resources/views/layouts/footer.blade.php index 409a449a..27cda58e 100644 --- a/resources/views/layouts/footer.blade.php +++ b/resources/views/layouts/footer.blade.php @@ -74,9 +74,12 @@ Flag Counter + +

+

2019 © TurkmenTV

diff --git a/resources/views/web/contact.blade.php b/resources/views/web/contact.blade.php index 11c52bed..9b584b5e 100644 --- a/resources/views/web/contact.blade.php +++ b/resources/views/web/contact.blade.php @@ -26,7 +26,7 @@ {{--

Habarlaşmak üçin

--}}
-
+ @if($message = Session::get('success'))
- +
- - + + @endsection diff --git a/resources/views/web/habarlashyk.blade.php b/resources/views/web/habarlashyk.blade.php index 11c52bed..77a92c5b 100644 --- a/resources/views/web/habarlashyk.blade.php +++ b/resources/views/web/habarlashyk.blade.php @@ -26,7 +26,7 @@ {{--

Habarlaşmak üçin

--}}
-
+ @if($message = Session::get('success'))
@endif - {{ csrf_field() }}
@@ -66,18 +65,26 @@
+
- +
- - - + + @endsection diff --git a/resources/views/web/layouts/footerMenu.blade.php b/resources/views/web/layouts/footerMenu.blade.php index 5dd910bd..e9738b39 100644 --- a/resources/views/web/layouts/footerMenu.blade.php +++ b/resources/views/web/layouts/footerMenu.blade.php @@ -12,37 +12,43 @@
-
+
  • Türkmen owazy
  • + +
    +
    -
    +
  • Ýaşlyk
  • + +
    +
    {{-- --}} -
    +
  • Türkmen
  • + --}} + + @@ -85,6 +91,8 @@ +

    {{ now()->format('Y') }} © TurkmenTV. All rights reserved.

    +