diff --git a/common/models/Feedback.php b/common/models/Feedback.php new file mode 100644 index 0000000..cae9a3f --- /dev/null +++ b/common/models/Feedback.php @@ -0,0 +1,90 @@ + self::SCENARIO_DEFAULT, + ], + [[ + 'reCaptcha' + ], + \himiklab\yii2\recaptcha\ReCaptchaValidator::className(), + 'secret' => '6LcmYmcUAAAAACVi_73RmSAIjJlw4BCgQpfUsrPs', + 'uncheckedMessage' => 'Please confirm that you are not a bot.', + 'on' => self::SCENARIO_DEFAULT, + ], + [ + [ + 'name', + 'email', + ], + 'required', + 'on' => self::SCENARIO_FEEDBACK, + ], + [ + [ + 'phone', + 'name', + ], + 'required', + 'on' => self::SCENARIO_CALLBACK, + ], + [ + ['email'], + 'email', + ], + // [ + // [ 'phone' ], + // 'match', + // 'pattern' => '/^\+38\(\d{3}\)\d{3}-\d{2}-\d{2}$/', + // ], + [ + [ + 'name', + 'phone', + 'email', + ], + 'string', + 'max' => 255, + ], + [ + [ + 'message', + ], + 'string', + ], + [ + [ + 'status', + ], + 'boolean', + ], + [ + 'returnUrl', + 'safe', + ], + ]; + } + +} + + +?> \ No newline at end of file diff --git a/composer.json b/composer.json index ddcb42e..393353e 100755 --- a/composer.json +++ b/composer.json @@ -38,7 +38,8 @@ "kartik-v/yii2-widget-datepicker": "@dev", "yiisoft/yii2-jui": "^2.0", "skeeks/yii2-assets-auto-compress": "*", - "zyx/zyx-phpmailer": "@stable" + "zyx/zyx-phpmailer": "@stable", + "himiklab/yii2-recaptcha-widget": "*" }, "require-dev": { "yiisoft/yii2-debug": "~2.0.0", diff --git a/composer.lock b/composer.lock index 1103248..095189a 100755 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "327786678167aec639aac10434a84c27", + "hash": "2f688f9614eac03da72eef7df04c6d22", + "content-hash": "3a33f40efa994f6a041392840080911f", "packages": [ { "name": "2amigos/yii2-tinymce-widget", @@ -1090,6 +1091,50 @@ "time": "2017-03-20 17:10:46" }, { + "name": "himiklab/yii2-recaptcha-widget", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/himiklab/yii2-recaptcha-widget.git", + "reference": "cc8a023bf51db3b40f1b8532cd94fc00c532edf5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/himiklab/yii2-recaptcha-widget/zipball/cc8a023bf51db3b40f1b8532cd94fc00c532edf5", + "reference": "cc8a023bf51db3b40f1b8532cd94fc00c532edf5", + "shasum": "" + }, + "require": { + "yiisoft/yii2": "~2.0.11", + "yiisoft/yii2-httpclient": "*" + }, + "type": "yii2-extension", + "autoload": { + "psr-4": { + "himiklab\\yii2\\recaptcha\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "HimikLab", + "homepage": "https://github.com/himiklab/" + } + ], + "description": "Yii2 Google reCAPTCHA widget", + "keywords": [ + "captcha", + "google", + "recaptcha", + "widget", + "yii2" + ], + "time": "2018-07-03 13:34:52" + }, + { "name": "hiqdev/yii2-asset-icheck", "version": "1.0.2.5", "source": { @@ -1491,7 +1536,7 @@ }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/kartik-v/yii2-widget-datepicker/zipball/9110ecce9deb59dc116fe6c3dd6df5d7eb439a3c", + "url": "https://api.github.com/repos/kartik-v/yii2-widget-datepicker/zipball/39e0e71277d0f115341e118a2b879a0dfcbd01c3", "reference": "9110ecce9deb59dc116fe6c3dd6df5d7eb439a3c", "shasum": "" }, @@ -1600,7 +1645,7 @@ }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/kartik-v/yii2-widget-select2/zipball/690ddac32f6796f63b8317783f26e89ca26fa94a", + "url": "https://api.github.com/repos/kartik-v/yii2-widget-select2/zipball/d08a5b302fe04216bd04290f0e99e26386801a37", "reference": "690ddac32f6796f63b8317783f26e89ca26fa94a", "shasum": "" }, @@ -2080,7 +2125,7 @@ } ], "description": "PHPMailer is a full-featured email creation and transfer class for PHP", - "time": "2014-05-14T07:04:18+00:00" + "time": "2014-05-14 07:04:18" }, { "name": "phpoffice/phpexcel", @@ -3062,6 +3107,53 @@ "time": "2016-12-20 13:26:02" }, { + "name": "yiisoft/yii2-httpclient", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/yiisoft/yii2-httpclient.git", + "reference": "720e3c9bdda260abffe61babfe39b91c4308ac4c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/yiisoft/yii2-httpclient/zipball/720e3c9bdda260abffe61babfe39b91c4308ac4c", + "reference": "720e3c9bdda260abffe61babfe39b91c4308ac4c", + "shasum": "" + }, + "require": { + "yiisoft/yii2": "~2.0.0" + }, + "type": "yii2-extension", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "yii\\httpclient\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Paul Klimov", + "email": "klimov.paul@gmail.com" + } + ], + "description": "HTTP client extension for the Yii framework", + "keywords": [ + "curl", + "http", + "httpclient", + "yii2" + ], + "time": "2017-06-23 09:36:13" + }, + { "name": "yiisoft/yii2-imagine", "version": "2.1.0", "source": { @@ -3265,7 +3357,7 @@ "theme", "yii2" ], - "time": "2017-05-22T11:24:30+00:00" + "time": "2017-05-22 11:24:30" }, { "name": "zyx/zyx-phpmailer", @@ -3309,7 +3401,7 @@ "phpmailer", "yii2" ], - "time": "2014-05-14T20:30:24+00:00" + "time": "2014-05-14 20:30:24" } ], "packages-dev": [ diff --git a/frontend/config/main.php b/frontend/config/main.php index fef3125..02c40ee 100755 --- a/frontend/config/main.php +++ b/frontend/config/main.php @@ -28,6 +28,12 @@ 'csrfParam' => '_csrf-frontend', 'baseUrl' => '/', ], + 'reCaptcha' => [ + 'name' => 'reCaptcha', + 'class' => 'himiklab\yii2\recaptcha\ReCaptcha', + 'siteKey' => '6LcmYmcUAAAAAASKWf3qnHXJCg9vGfJfDefY9TzW', + 'secret' => '6LcmYmcUAAAAACVi_73RmSAIjJlw4BCgQpfUsrPs', + ], 'user' => [ 'identityClass' => 'artbox\order\models\Customer', 'enableAutoLogin' => true, diff --git a/frontend/views/site/contact.php b/frontend/views/site/contact.php index 3d76dbc..803c07e 100755 --- a/frontend/views/site/contact.php +++ b/frontend/views/site/contact.php @@ -11,6 +11,7 @@ use yii\helpers\Html; use yii\bootstrap\ActiveForm; use yii\web\View; +use himiklab\yii2\recaptcha\ReCaptcha; MapAsset::register($this); $settings = Settings::getInstance(); @@ -168,7 +169,10 @@ JS; ] ); ?> - + field($contact, 'reCaptcha')->widget( + \himiklab\yii2\recaptcha\ReCaptcha::className(), + ['siteKey' => '6LcmYmcUAAAAAASKWf3qnHXJCg9vGfJfDefY9TzW'] + ) ?>
Отправить сообщение', -- libgit2 0.21.4