瀏覽代碼

添加hCaptcha验证码 + 添加返利模式开关

兔姬桑 5 年之前
父節點
當前提交
c8cc80051e

+ 1 - 0
.gitignore

@@ -19,3 +19,4 @@ npm-debug.log
 yarn-error.log
 .env
 .phpunit.result.cache
+_ide_helper_models.php

+ 34 - 86
_ide_helper.php

@@ -3,7 +3,7 @@
 
 /**
  * A helper file for Laravel 5, to provide autocomplete information to your IDE
- * Generated for Laravel 5.8.36 on 2020-01-05 03:12:08.
+ * Generated for Laravel 5.8.37 on 2020-04-04 05:47:15.
  *
  * This file should not be included in your code, only analyzed by your IDE!
  *
@@ -333,10 +333,10 @@ namespace Illuminate\Support\Facades {
          * @return string|bool 
          * @static 
          */ 
-        public static function environment($environments = null)
+        public static function environment(...$environments)
         {
                         /** @var \Illuminate\Foundation\Application $instance */
-                        return $instance->environment($environments);
+                        return $instance->environment(...$environments);
         }
         
         /**
@@ -2373,10 +2373,10 @@ namespace Illuminate\Support\Facades {
          * @return bool 
          * @static 
          */ 
-        public static function check($name, $parameters = null)
+        public static function check($name, ...$parameters)
         {
                         /** @var \Illuminate\View\Compilers\BladeCompiler $instance */
-                        return $instance->check($name, $parameters);
+                        return $instance->check($name, ...$parameters);
         }
         
         /**
@@ -3667,10 +3667,10 @@ namespace Illuminate\Support\Facades {
          * @return void 
          * @static 
          */ 
-        public static function queue($parameters = null)
+        public static function queue(...$parameters)
         {
                         /** @var \Illuminate\Cookie\CookieJar $instance */
-                        $instance->queue($parameters);
+                        $instance->queue(...$parameters);
         }
         
         /**
@@ -7900,61 +7900,6 @@ namespace Illuminate\Support\Facades {
                         return $instance->setConnectionName($name);
         }
         
-        /**
-         * Release a reserved job back onto the queue.
-         *
-         * @param string $queue
-         * @param \Illuminate\Queue\Jobs\DatabaseJobRecord $job
-         * @param int $delay
-         * @return mixed 
-         * @static 
-         */ 
-        public static function release($queue, $job, $delay)
-        {
-                        /** @var \Illuminate\Queue\DatabaseQueue $instance */
-                        return $instance->release($queue, $job, $delay);
-        }
-        
-        /**
-         * Delete a reserved job from the queue.
-         *
-         * @param string $queue
-         * @param string $id
-         * @return void 
-         * @throws \Exception|\Throwable
-         * @static 
-         */ 
-        public static function deleteReserved($queue, $id)
-        {
-                        /** @var \Illuminate\Queue\DatabaseQueue $instance */
-                        $instance->deleteReserved($queue, $id);
-        }
-        
-        /**
-         * Get the queue or return the default.
-         *
-         * @param string|null $queue
-         * @return string 
-         * @static 
-         */ 
-        public static function getQueue($queue)
-        {
-                        /** @var \Illuminate\Queue\DatabaseQueue $instance */
-                        return $instance->getQueue($queue);
-        }
-        
-        /**
-         * Get the underlying database instance.
-         *
-         * @return \Illuminate\Database\Connection 
-         * @static 
-         */ 
-        public static function getDatabase()
-        {
-                        /** @var \Illuminate\Queue\DatabaseQueue $instance */
-                        return $instance->getDatabase();
-        }
-        
         /**
          * Get the retry delay for an object-based queue handler.
          *
@@ -7965,7 +7910,7 @@ namespace Illuminate\Support\Facades {
         public static function getJobRetryDelay($job)
         {
             //Method inherited from \Illuminate\Queue\Queue            
-                        /** @var \Illuminate\Queue\DatabaseQueue $instance */
+                        /** @var \Illuminate\Queue\SyncQueue $instance */
                         return $instance->getJobRetryDelay($job);
         }
         
@@ -7979,7 +7924,7 @@ namespace Illuminate\Support\Facades {
         public static function getJobExpiration($job)
         {
             //Method inherited from \Illuminate\Queue\Queue            
-                        /** @var \Illuminate\Queue\DatabaseQueue $instance */
+                        /** @var \Illuminate\Queue\SyncQueue $instance */
                         return $instance->getJobExpiration($job);
         }
         
@@ -7993,7 +7938,7 @@ namespace Illuminate\Support\Facades {
         public static function createPayloadUsing($callback)
         {
             //Method inherited from \Illuminate\Queue\Queue            
-                        \Illuminate\Queue\DatabaseQueue::createPayloadUsing($callback);
+                        \Illuminate\Queue\SyncQueue::createPayloadUsing($callback);
         }
         
         /**
@@ -8006,7 +7951,7 @@ namespace Illuminate\Support\Facades {
         public static function setContainer($container)
         {
             //Method inherited from \Illuminate\Queue\Queue            
-                        /** @var \Illuminate\Queue\DatabaseQueue $instance */
+                        /** @var \Illuminate\Queue\SyncQueue $instance */
                         $instance->setContainer($container);
         }
          
@@ -8498,10 +8443,10 @@ namespace Illuminate\Support\Facades {
          * @return bool 
          * @static 
          */ 
-        public static function is($patterns = null)
+        public static function is(...$patterns)
         {
                         /** @var \Illuminate\Http\Request $instance */
-                        return $instance->is($patterns);
+                        return $instance->is(...$patterns);
         }
         
         /**
@@ -8511,10 +8456,10 @@ namespace Illuminate\Support\Facades {
          * @return bool 
          * @static 
          */ 
-        public static function routeIs($patterns = null)
+        public static function routeIs(...$patterns)
         {
                         /** @var \Illuminate\Http\Request $instance */
-                        return $instance->routeIs($patterns);
+                        return $instance->routeIs(...$patterns);
         }
         
         /**
@@ -8524,10 +8469,10 @@ namespace Illuminate\Support\Facades {
          * @return bool 
          * @static 
          */ 
-        public static function fullUrlIs($patterns = null)
+        public static function fullUrlIs(...$patterns)
         {
                         /** @var \Illuminate\Http\Request $instance */
-                        return $instance->fullUrlIs($patterns);
+                        return $instance->fullUrlIs(...$patterns);
         }
         
         /**
@@ -9835,7 +9780,9 @@ namespace Illuminate\Support\Facades {
          * Gets the preferred format for the response by inspecting, in the following order:
          *   * the request format set using setRequestFormat
          *   * the values of the Accept HTTP header
-         *   * the content type of the body of the request.
+         * 
+         * Note that if you use this method, you should send the "Vary: Accept" header
+         * in the response to prevent any issues with intermediary HTTP caches.
          *
          * @static 
          */ 
@@ -10454,9 +10401,9 @@ namespace Illuminate\Support\Facades {
          *
          * @static 
          */ 
-        public static function validate($rules, $params = null)
+        public static function validate($rules, ...$params)
         {
-                        return \Illuminate\Http\Request::validate($rules, $params);
+                        return \Illuminate\Http\Request::validate($rules, ...$params);
         }
         
         /**
@@ -11438,10 +11385,10 @@ namespace Illuminate\Support\Facades {
          * @return bool 
          * @static 
          */ 
-        public static function is($patterns = null)
+        public static function is(...$patterns)
         {
                         /** @var \Illuminate\Routing\Router $instance */
-                        return $instance->is($patterns);
+                        return $instance->is(...$patterns);
         }
         
         /**
@@ -11451,10 +11398,10 @@ namespace Illuminate\Support\Facades {
          * @return bool 
          * @static 
          */ 
-        public static function currentRouteNamed($patterns = null)
+        public static function currentRouteNamed(...$patterns)
         {
                         /** @var \Illuminate\Routing\Router $instance */
-                        return $instance->currentRouteNamed($patterns);
+                        return $instance->currentRouteNamed(...$patterns);
         }
         
         /**
@@ -11476,10 +11423,10 @@ namespace Illuminate\Support\Facades {
          * @return bool 
          * @static 
          */ 
-        public static function uses($patterns = null)
+        public static function uses(...$patterns)
         {
                         /** @var \Illuminate\Routing\Router $instance */
-                        return $instance->uses($patterns);
+                        return $instance->uses(...$patterns);
         }
         
         /**
@@ -15334,7 +15281,7 @@ namespace Mews\Captcha\Facades {
     /**
      * 
      *
-     * @see \Mews\Captcha
+     * @see \Mews\Captcha\Captcha
      */ 
     class Captcha {
         
@@ -16018,13 +15965,14 @@ namespace Mews\Purifier\Facades {
          *
          * @param $dirty
          * @param null $config
+         * @param \Closure|null $postCreateConfigHook
          * @return mixed 
          * @static 
          */ 
-        public static function clean($dirty, $config = null)
+        public static function clean($dirty, $config = null, $postCreateConfigHook = null)
         {
                         /** @var \Mews\Purifier\Purifier $instance */
-                        return $instance->clean($dirty, $config);
+                        return $instance->clean($dirty, $config, $postCreateConfigHook);
         }
         
         /**
@@ -18323,10 +18271,10 @@ namespace  {
              * @return \Illuminate\Database\Query\Builder 
              * @static 
              */ 
-            public static function groupBy($groups = null)
+            public static function groupBy(...$groups)
             {
                                 /** @var \Illuminate\Database\Query\Builder $instance */
-                                return $instance->groupBy($groups);
+                                return $instance->groupBy(...$groups);
             }
          
             /**

+ 16 - 16
app/Components/Callback.php

@@ -6,6 +6,7 @@ use App\Http\Models\Goods;
 use App\Http\Models\GoodsLabel;
 use App\Http\Models\Order;
 use App\Http\Models\Payment;
+use App\Http\Models\ReferralLog;
 use App\Http\Models\User;
 use App\Http\Models\UserLabel;
 use DB;
@@ -143,29 +144,28 @@ trait Callback
 								}
 							}
 
-							// 写入返利日志
-							if($order->user->referral_uid){
-								$this->addReferralLog($order->user_id, $order->user->referral_uid, $order->oid, $order->amount, $order->amount*self::$systemConfig['referral_percent']);
-								// 邀请注册功能开启时,每成功邀请一名付费用户,返还邀请者邀请名额
-								if(self::$systemConfig['is_invite_register']){
-									User::query()->where('id', $order->user->referral_uid)->increment('invite_num', 1);
-								}
-							}
-
 							Helpers::addUserTrafficModifyLog($order->user_id, $order->oid, $user->transfer_enable, $userTraffic, '[在线支付]加上用户购买的套餐流量');
 							User::query()->where('id', $order->user_id)->increment('invite_num', $goods->invite_num? : 0, ['transfer_enable' => $userTraffic, 'reset_time' => $nextResetTime, 'expire_time' => $expireTime, 'enable' => 1]);
 						}else{
 							//预支付订单先给上账号时间用于流量重置判断
 							User::query()->where('id', $order->user_id)->update(['expire_time' => date('Y-m-d', strtotime("+".$goods->days." days", strtotime($user->expire_time)))]);
 						}
-						break;
-					case 3:
-						$order->status = 2;
-						$order->save();
-						User::query()->where('id', $order->user_id)->increment('balance', $goods->price*100);
 
-						// 余额变动记录日志
-						$this->addUserBalanceLog($order->user_id, $order->oid, $order->user->balance, $order->user->balance+$goods->price, $goods->price, '用户在线充值');
+						// 是否返利
+						if(Helpers::systemConfig()['referral_type'] && $order->user->referral_uid){
+							//获取历史返利记录
+							$referral = ReferralLog::where('user_id', $order->user_id)->get();
+							// 无记录 / 首次返利
+							if(!$referral && self::$systemConfig['is_invite_register']){
+								// 邀请注册功能开启时,返还邀请者邀请名额
+								User::query()->where('id', $order->user->referral_uid)->increment('invite_num', 1);
+							}
+							//按照返利模式进行返利判断
+							if(Helpers::systemConfig()['referral_type'] == 2 || (Helpers::systemConfig()['referral_type'] == 1 && !$referral)){
+								$this->addReferralLog($order->user_id, $order->user->referral_uid, $order->oid, $order->amount, $order->amount*self::$systemConfig['referral_percent']);
+							}
+						}
+
 						break;
 					default:
 						Log::info('【处理订单】出现错误-未知套餐类型');

+ 12 - 6
app/Components/CaptchaVerify.php

@@ -9,9 +9,17 @@ namespace App\Components;
  */
 Class CaptchaVerify
 {
-	/**
-	 * 从后台获取 Geetest_id 和 Geetest_key
-	 */
+	//从后台获取 hcaptcha_sitekey 和 hcaptcha_secret
+	public static function hCaptchaGetConfig()
+	{
+		return [
+			"sitekey" => Helpers::systemConfig()["hcaptcha_sitekey"],
+			"secret"  => Helpers::systemConfig()["hcaptcha_secret"],
+			"options" => []
+		];
+	}
+
+	//从后台获取 Geetest_id 和 Geetest_key
 	public static function geetestCaptchaGetConfig()
 	{
 		return [
@@ -20,9 +28,7 @@ Class CaptchaVerify
 		];
 	}
 
-	/**
-	 * 从后台获取 google_captcha_sitekey 和 google_captcha_secret
-	 */
+	//从后台获取 google_captcha_sitekey 和 google_captcha_secret
 	public static function googleCaptchaGetConfig()
 	{
 		return [

+ 50 - 58
app/Http/Controllers/AuthController.php

@@ -58,39 +58,13 @@ class AuthController extends Controller
 			]);
 
 			$email = $request->input('email');
-			$captcha = $request->input('captcha');
 			$password = $request->input('password');
 			$remember = $request->input('remember');
 
 			// 是否校验验证码
-			switch(self::$systemConfig['is_captcha']){
-				case 1: // 默认图形验证码
-					if(!Captcha::check($captcha)){
-						return Redirect::back()->withInput()->withErrors(trans('auth.captcha_error'));
-					}
-					break;
-				case 2: // Geetest
-					$result = $this->validate($request, [
-						'geetest_challenge' => 'required|geetest'
-					], [
-						'geetest' => trans('auth.captcha_fail')
-					]);
-
-					if(!$result){
-						return Redirect::back()->withInput()->withErrors(trans('auth.fail_captcha'));
-					}
-					break;
-				case 3: // Google reCAPTCHA
-					$result = $this->validate($request, [
-						'g-recaptcha-response' => 'required|NoCaptcha'
-					]);
-
-					if(!$result){
-						return Redirect::back()->withInput()->withErrors(trans('auth.fail_captcha'));
-					}
-					break;
-				default: // 不启用验证码
-					break;
+			$captcha = $this->check_captcha($request);
+			if($captcha != FALSE){
+				return $captcha;
 			}
 
 			// 验证账号并创建会话
@@ -184,6 +158,50 @@ class AuthController extends Controller
 		$log->save();
 	}
 
+	// 校验验证码
+	private function check_captcha($request)
+	{
+		switch(self::$systemConfig['is_captcha']){
+			case 1: // 默认图形验证码
+				if(!Captcha::check($request->input('captcha'))){
+					return Redirect::back()->withInput()->withErrors(trans('auth.captcha_error'));
+				}
+				break;
+			case 2: // Geetest
+				$result = $this->validate($request, [
+					'geetest_challenge' => 'required|geetest'
+				], [
+					'geetest' => trans('auth.captcha_fail')
+				]);
+
+				if(!$result){
+					return Redirect::back()->withInput()->withErrors(trans('auth.fail_captcha'));
+				}
+				break;
+			case 3: // Google reCAPTCHA
+				$result = $this->validate($request, [
+					'g-recaptcha-response' => 'required|NoCaptcha'
+				]);
+
+				if(!$result){
+					return Redirect::back()->withInput()->withErrors(trans('auth.fail_captcha'));
+				}
+				break;
+			case 4: // hCaptcha
+				$result = $this->validate($request, [
+					'h-captcha-response' => 'required|HCaptcha'
+				]);
+
+				if(!$result){
+					return Redirect::back()->withInput()->withErrors(trans('auth.fail_captcha'));
+				}
+				break;
+			default: // 不启用验证码
+				break;
+		}
+	}
+
+
 	// 退出
 	public function logout()
 	{
@@ -222,7 +240,6 @@ class AuthController extends Controller
 			$register_token = $request->input('register_token');
 			$code = $request->input('code');
 			$verify_code = $request->input('verify_code');
-			$captcha = $request->input('captcha');
 			$aff = intval($request->input('aff'));
 
 			// 防止重复提交
@@ -277,34 +294,9 @@ class AuthController extends Controller
 			}
 
 			// 是否校验验证码
-			switch(self::$systemConfig['is_captcha']){
-				case 1: // 默认图形验证码
-					if(!Captcha::check($captcha)){
-						return Redirect::back()->withInput()->withErrors(trans('auth.captcha_error'));
-					}
-					break;
-				case 2: // Geetest
-					$result = $this->validate($request, [
-						'geetest_challenge' => 'required|geetest'
-					], [
-						'geetest' => trans('auth.captcha_fail')
-					]);
-
-					if(!$result){
-						return Redirect::back()->withInput()->withErrors(trans('auth.captcha_fail'));
-					}
-					break;
-				case 3: // Google reCAPTCHA
-					$result = $this->validate($request, [
-						'g-recaptcha-response' => 'required|NoCaptcha'
-					]);
-
-					if(!$result){
-						return Redirect::back()->withInput()->withErrors(trans('auth.captcha_fail'));
-					}
-					break;
-				default: // 不启用验证码
-					break;
+			$captcha = $this->check_captcha($request);
+			if($captcha != FALSE){
+				return $captcha;
 			}
 
 			// 24小时内同IP注册限制

+ 1 - 0
composer.json

@@ -33,6 +33,7 @@
     "rap2hpoutre/laravel-log-viewer": "^1.3",
     "riverslei/payment": "*",
     "spatie/laravel-permission": "^3.4",
+    "ssrpanel/hcaptcha": "^2.0",
     "xhat/payjs": "^1.4"
   },
   "require-dev": {

+ 57 - 2
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": "7dcdad19274c70ff2e5617fcd6f1780f",
+    "content-hash": "92b1ef4f3751fdbe50e28a11e25fef46",
     "packages": [
         {
             "name": "barryvdh/laravel-debugbar",
@@ -4314,6 +4314,60 @@
             ],
             "time": "2020-03-03T21:31:02+00:00"
         },
+        {
+            "name": "ssrpanel/hcaptcha",
+            "version": "2.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/ssrpanel/hcaptcha.git",
+                "reference": "3536768d467270f95054375554060cf75c7b9198"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/ssrpanel/hcaptcha/zipball/3536768d467270f95054375554060cf75c7b9198",
+                "reference": "3536768d467270f95054375554060cf75c7b9198",
+                "shasum": "",
+                "mirrors": [
+                    {
+                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+                        "preferred": true
+                    }
+                ]
+            },
+            "require": {
+                "guzzlehttp/guzzle": "^6.2",
+                "illuminate/support": "5.0.*|5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*|5.7.*|5.8.*",
+                "php": ">=5.5.5"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "~4.8"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "SSRPanel\\HCaptcha\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "ssrpanel",
+                    "email": "admin@ssrpanel.com"
+                }
+            ],
+            "description": "hCaptcha For Laravel5.x",
+            "keywords": [
+                "captcha",
+                "hcaptcha",
+                "laravel",
+                "laravel5",
+                "ssrpanel"
+            ],
+            "time": "2020-04-13T16:54:55+00:00"
+        },
         {
             "name": "swiftmailer/swiftmailer",
             "version": "v6.2.3",
@@ -8060,5 +8114,6 @@
         "ext-json": "*",
         "ext-openssl": "*"
     },
-    "platform-dev": []
+    "platform-dev": [],
+    "plugin-api-version": "1.1.0"
 }

+ 10 - 0
config/HCaptcha.php

@@ -0,0 +1,10 @@
+<?php
+
+return [
+	'secret'            => env('HCAPTCHA_SECRET'),
+	'sitekey'           => env('HCAPTCHA_SITEKEY'),
+	'server-get-config' => TRUE,
+	'options'           => [
+		'timeout' => 30,
+	],
+];

+ 2 - 0
config/app.php

@@ -157,6 +157,7 @@ return [
 		Misechow\NoCaptcha\NoCaptchaServiceProvider::class, // Google reCAPTCHA
 		Overtrue\LaravelLang\TranslationServiceProvider::class, // 多国语言包功能
 		Rap2hpoutre\LaravelLogViewer\LaravelLogViewerServiceProvider::class,//日志查看
+		SSRPanel\HCaptcha\HCaptchaServiceProvider::class, //HCaptcha
 
 		/*
 		 * Application Service Providers...
@@ -198,6 +199,7 @@ return [
 		'File'         => Illuminate\Support\Facades\File::class,
 		'Gate'         => Illuminate\Support\Facades\Gate::class,
 		'Hash'         => Illuminate\Support\Facades\Hash::class,
+		'HCaptcha'     => SSRPanel\HCaptcha\Facades\HCaptcha::class,
 		'Lang'         => Illuminate\Support\Facades\Lang::class,
 		'Log'          => Illuminate\Support\Facades\Log::class,
 		'Mail'         => Illuminate\Support\Facades\Mail::class,

+ 1 - 1
public/assets/examples/css/pages/login-v3.css

@@ -48,7 +48,7 @@
 }
 
 @media screen and (max-height: 575px) {
-    .g-recaptcha {
+    .g-recaptcha .h-captcha {
         -webkit-transform: scale(0.81);
         transform: scale(0.81);
         -webkit-transform-origin: 0 0;

+ 1 - 1
public/assets/examples/css/pages/login-v3.min.css

@@ -1,3 +1,3 @@
 .page-login-v3:before{position:fixed;top:0;left:0;content:'';width:100%;height:100%;background-position:center top;background-size:cover;z-index:-1;background:#3e8ef7;background-image:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzYyYThlYSIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiMxNTcxYjEiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);background-image:linear-gradient(to bottom,#3e8ef7 0%,#0b69e3 100%);background-repeat:repeat-x}.page-login-v3 .panel{width:400px;margin-bottom:45px;background:#fff;border-radius:0.286rem}.page-login-v3 .panel.brand-text{margin-top:12px}.page-login-v3 form{margin:0 0 30px}.page-login-v3 form.form-material.floating+.page-login-v3 form.form-material.floating{margin-top:30px}.page-login-v3 form.form-material label{color:#a3afb7;font-weight:300}
 @media(max-width:479.98px){.page-login-v3 .panel{width:330px;padding:10px}}
-@media screen and(max-height:575px){.g-recaptcha{-webkit-transform:scale(0.81);transform:scale(0.81);-webkit-transform-origin:0 0;transform-origin:0 0}}.geetest_holder.geetest_wind{min-width:245px!important}
+@media screen and(max-height:575px){.g-recaptcha .h-captcha {-webkit-transform:scale(0.81);transform:scale(0.81);-webkit-transform-origin:0 0;transform-origin:0 0}}.geetest_holder.geetest_wind{min-width:245px!important}

二進制
public/qqwry.dat


+ 83 - 50
resources/views/admin/system.blade.php

@@ -221,7 +221,7 @@
 									<div class="form-group col-lg-6">
 										<div class="row">
 											<label class="col-md-3 col-form-label" for="is_activate_account">激活账号</label>
-											<select class="col-md-3" id="is_activate_account" data-plugin="selectpicker" data-style="btn-outline btn-primary" onchange="updateFromOther('select','is_activate_account')">
+											<select class="col-md-4" id="is_activate_account" data-plugin="selectpicker" data-style="btn-outline btn-primary" onchange="updateFromOther('select','is_activate_account')">
 												<option value="0">关闭</option>
 												<option value="1">注册前激活</option>
 												<option value="2">注册后激活</option>
@@ -229,18 +229,6 @@
 											<span class="text-help offset-md-3"> 启用后用户需要通过邮件来激活账号 </span>
 										</div>
 									</div>
-									<div class="form-group col-lg-6">
-										<div class="row">
-											<label class="col-md-3 col-form-label" for="is_captcha">验证码</label>
-											<select class="col-md-5" id="is_captcha" data-plugin="selectpicker" data-style="btn-outline btn-primary" onchange="updateFromOther('select','is_captcha')">
-												<option value="0">关闭</option>
-												<option value="1">普通验证码</option>
-												<option value="2">极验Geetest</option>
-												<option value="3">Google reCAPTCHA</option>
-											</select>
-											<span class="text-help offset-md-3"> 启用后登录、注册需要输入验证码 </span>
-										</div>
-									</div>
 									<div class="form-group col-lg-6">
 										<div class="row">
 											<label class="col-md-3 col-form-label" for="is_reset_password">重置密码</label>
@@ -492,55 +480,88 @@
 											<span class="text-help offset-md-3"> 管理员生成邀请码的有效期 </span>
 										</div>
 									</div>
-									@if($is_captcha == 2)
-										<div class="form-group col-lg-6">
-											<div class="row">
-												<label class="col-md-3 col-form-label" for="geetest_id">极验ID</label>
-												<div class="col-md-7">
-													<div class="input-group">
-														<input type="text" class="form-control" id="geetest_id" value="{{$geetest_id}}"/>
-														<span class="input-group-append"><button class="btn btn-primary" type="button" onclick="update('geetest_id')">修改</button></span>
-													</div>
+									<div class="form-group col-lg-6">
+										<div class="row">
+											<label class="col-md-3 col-form-label" for="is_captcha">验证码</label>
+											<select class="col-md-5" id="is_captcha" data-plugin="selectpicker" data-style="btn-outline btn-primary" onchange="updateFromOther('select','is_captcha')">
+												<option value="0">关闭</option>
+												<option value="1">普通验证码</option>
+												<option value="2">极验Geetest</option>
+												<option value="3">Google reCaptcha</option>
+												<option value="4">hCaptcha</option>
+											</select>
+											<span class="text-help offset-md-3"> 启用后登录、注册需要输入验证码 </span>
+										</div>
+									</div>
+									<div class="form-group col-lg-6">
+										<div class="row">
+											<label class="col-md-3 col-form-label" for="geetest_id">极验ID</label>
+											<div class="col-md-7">
+												<div class="input-group">
+													<input type="text" class="form-control" id="geetest_id" value="{{$geetest_id}}"/>
+													<span class="input-group-append"><button class="btn btn-primary" type="button" onclick="update('geetest_id')">修改</button></span>
 												</div>
-												<span class="text-help offset-md-3"> 本功能需要 <a href="https://auth.geetest.com/login/" target="_blank">极验后台</a> 申请权限及应用 </span>
 											</div>
+											<span class="text-help offset-md-3"> 本功能需要 <a href="https://auth.geetest.com/login/" target="_blank">极验后台</a> 申请权限及应用 </span>
 										</div>
-										<div class="form-group col-lg-6">
-											<div class="row">
-												<label class="col-md-3 col-form-label" for="geetest_key">极验KEY</label>
-												<div class="col-md-7">
-													<div class="input-group">
-														<input type="text" class="form-control" id="geetest_key" value="{{$geetest_key}}"/>
-														<span class="input-group-append"><button class="btn btn-primary" type="button" onclick="update('geetest_key')">修改</button></span>
-													</div>
+									</div>
+									<div class="form-group col-lg-6">
+										<div class="row">
+											<label class="col-md-3 col-form-label" for="geetest_key">极验KEY</label>
+											<div class="col-md-7">
+												<div class="input-group">
+													<input type="text" class="form-control" id="geetest_key" value="{{$geetest_key}}"/>
+													<span class="input-group-append"><button class="btn btn-primary" type="button" onclick="update('geetest_key')">修改</button></span>
 												</div>
 											</div>
 										</div>
-									@elseif($is_captcha == 3)
-										<div class="form-group col-lg-6">
-											<div class="row">
-												<label class="col-md-3 col-form-label" for="google_captcha_sitekey">网站密钥</label>
-												<div class="col-md-7">
-													<div class="input-group">
-														<input type="text" class="form-control" id="google_captcha_sitekey" value="{{$google_captcha_sitekey}}"/>
-														<span class="input-group-append"><button class="btn btn-primary" type="button" onclick="update('google_captcha_sitekey')">修改</button></span>
-													</div>
+									</div>
+									<div class="form-group col-lg-6">
+										<div class="row">
+											<label class="col-md-3 control-label" for="google_captcha_secret">密钥</label>
+											<div class="col-md-7">
+												<div class="input-group">
+													<input type="text" class="form-control" id="google_captcha_secret" value="{{$google_captcha_secret}}"/>
+													<span class="input-group-append"><button class="btn btn-primary" type="button" onclick="update('google_captcha_secret')">修改</button></span>
 												</div>
-												<span class="text-help offset-md-3"> 本功能需要 <a href="https://www.google.com/recaptcha/admin" target="_blank">Google reCAPTCHA后台</a> 申请权限及应用 (申请需科学上网,日常验证不用)</span>
 											</div>
+											<span class="text-help offset-md-3"> 本功能需要 <a href="https://www.google.com/recaptcha/admin" target="_blank">Google reCAPTCHA后台</a> 申请权限及应用 (申请需科学上网,日常验证不用)</span>
 										</div>
-										<div class="form-group col-lg-6">
-											<div class="row">
-												<label class="col-md-3 control-label" for="google_captcha_secret">密钥</label>
-												<div class="col-md-7">
-													<div class="input-group">
-														<input type="text" class="form-control" id="google_captcha_secret" value="{{$google_captcha_secret}}"/>
-														<span class="input-group-append"><button class="btn btn-primary" type="button" onclick="update('google_captcha_secret')">修改</button></span>
-													</div>
+									</div>
+									<div class="form-group col-lg-6">
+										<div class="row">
+											<label class="col-md-3 col-form-label" for="google_captcha_sitekey">网站密钥</label>
+											<div class="col-md-7">
+												<div class="input-group">
+													<input type="text" class="form-control" id="google_captcha_sitekey" value="{{$google_captcha_sitekey}}"/>
+													<span class="input-group-append"><button class="btn btn-primary" type="button" onclick="update('google_captcha_sitekey')">修改</button></span>
+												</div>
+											</div>
+										</div>
+									</div>
+									<div class="form-group col-lg-6">
+										<div class="row">
+											<label class="col-md-3 control-label" for="google_captcha_secret">hCaptcha Secret密钥</label>
+											<div class="col-md-7">
+												<div class="input-group">
+													<input type="text" class="form-control" id="hcaptcha_secret" value="{{$hcaptcha_secret}}"/>
+													<span class="input-group-append"><button class="btn btn-primary" type="button" onclick="update('hcaptcha_secret')">修改</button></span>
+												</div>
+											</div>
+											<span class="text-help offset-md-3"> 本功能需要 <a href="https://hCaptcha.com/?r=2d46d3aa7a4e" target="_blank">hCaptcha后台</a> 申请权限及应用</span>
+										</div>
+									</div>
+									<div class="form-group col-lg-6">
+										<div class="row">
+											<label class="col-md-3 col-form-label" for="google_captcha_sitekey">hCaptcha Site Key网站密钥</label>
+											<div class="col-md-7">
+												<div class="input-group">
+													<input type="text" class="form-control" id="hcaptcha_sitekey" value="{{$hcaptcha_sitekey}}"/>
+													<span class="input-group-append"><button class="btn btn-primary" type="button" onclick="update('hcaptcha_sitekey')">修改</button></span>
 												</div>
 											</div>
 										</div>
-									@endif
+									</div>
 								</div>
 							</form>
 						</div>
@@ -605,6 +626,17 @@
 											<span class="text-help offset-md-3"> 关闭后用户不可见,但是不影响其正常邀请返利 </span>
 										</div>
 									</div>
+									<div class="form-group col-lg-6">
+										<div class="row">
+											<label class="col-md-3 col-form-label" for="referral_type">返利模式</label>
+											<select class="col-md-5" id="referral_type" data-plugin="selectpicker" data-style="btn-outline btn-primary" onchange="updateFromOther('select','referral_type')">
+												<option value="0">关闭</option>
+												<option value="1">首购返利</option>
+												<option value="2">循环返利</option>
+											</select>
+											<span class="text-help offset-md-3"> 启用后登录、注册需要输入验证码 </span>
+										</div>
+									</div>
 									<div class="form-group col-lg-6">
 										<div class="row">
 											<label class="col-md-3 col-form-label" for="referral_traffic">注册送流量</label>
@@ -1120,6 +1152,7 @@
             $('#is_invite_register').selectpicker('val', {{$is_invite_register}});
             $('#is_activate_account').selectpicker('val', {{$is_activate_account}});
             $('#is_captcha').selectpicker('val', {{$is_captcha}});
+            $('#referral_type').selectpicker('val', {{$referral_type}});
             $('#is_email_filtering').selectpicker('val', {{$is_email_filtering}});
             $('#initial_labels_for_user').selectpicker('val', [{{$initial_labels_for_user}}]);
             $('#is_notification').selectpicker('val', {{$is_notification}});

+ 20 - 22
resources/views/auth/login.blade.php

@@ -38,12 +38,18 @@
 				{!! Geetest::render() !!}
 			</div>
 			@break
-			@case(3)<!-- Google noCAPTCHA -->
+			@case(3)<!-- Google reCaptcha -->
 			<div class="form-group form-material floating" data-plugin="formMaterial">
 				{!! NoCaptcha::display() !!}
 				{!! NoCaptcha::renderJs(session::get('locale')) !!}
 			</div>
 			@break
+			@case(4)<!-- hCaptcha -->
+			<div class="form-group form-material floating" data-plugin="formMaterial">
+				{!! HCaptcha::display() !!}
+				{!! HCaptcha::renderJs(session::get('locale')) !!}
+			</div>
+			@break
 			@default
 		@endswitch
 		<div class="form-group clearfix">
@@ -62,31 +68,23 @@
 @section('script')
 	<script type="text/javascript">
         $('#login-form').submit(function (event) {
+			@switch(\App\Components\Helpers::systemConfig()['is_captcha'])
+			@case(3)
             // 先检查Google reCAPTCHA有没有进行验证
             if ($('#g-recaptcha-response').val() === '') {
-                Msg(false, "{{trans('login.required_captcha')}}", 'error');
+                swal.fire({title: '{{trans('auth.required_captcha')}}', type: 'error'});
                 return false;
             }
-        });
-
-        // 生成提示
-        function Msg(clear, msg, type) {
-            if (!clear) $('.login-form .alert').remove();
-
-            var typeClass = 'alert-danger',
-                clear = clear ? clear : false,
-                $elem = $('.login-form');
-            type === 'error' ? typeClass = 'alert-danger' : typeClass = 'alert-success';
-
-            const tpl = '<div class="alert ' + typeClass + '">' +
-                '<button type="button" class="close" onclick="$(this).parent().remove();"></button>' +
-                '<span> ' + msg + ' </span></div>';
-
-            if (!clear) {
-                $elem.prepend(tpl);
-            } else {
-                $('.login-form .alert').remove();
+			@break
+			@case(4)
+            // 先检查Google reCAPTCHA有没有进行验证
+            if ($('#h-captcha-response').val() === '') {
+                swal.fire({title: '{{trans('auth.required_captcha')}}', type: 'error'});
+                return false;
             }
-        }
+			@break
+			@default
+			@endswitch
+        });
 	</script>
 @endsection

+ 20 - 1
resources/views/auth/register.blade.php

@@ -84,12 +84,18 @@
 					{!! Geetest::render() !!}
 				</div>
 				@break
-				@case(3)<!-- Google noCAPTCHA -->
+				@case(3)<!-- Google reCaptcha -->
 				<div class="form-group form-material floating" data-plugin="formMaterial">
 					{!! NoCaptcha::display() !!}
 					{!! NoCaptcha::renderJs(session::get('locale')) !!}
 				</div>
 				@break
+				@case(4)<!-- hCaptcha -->
+				<div class="form-group form-material floating" data-plugin="formMaterial">
+					{!! HCaptcha::display() !!}
+					{!! HCaptcha::renderJs(session::get('locale')) !!}
+				</div>
+				@break
 				@default
 			@endswitch
 			<div class="form-group mt-20 mb-20">
@@ -231,11 +237,24 @@
 			@if($emailList)
             getEmail();
 			@endif
+
+			@switch(\App\Components\Helpers::systemConfig()['is_captcha'])
+			@case(3)
             // 先检查Google reCAPTCHA有没有进行验证
             if ($('#g-recaptcha-response').val() === '') {
                 swal.fire({title: '{{trans('auth.required_captcha')}}', type: 'error'});
                 return false;
             }
+			@break
+			@case(4)
+            // 先检查Google reCAPTCHA有没有进行验证
+            if ($('#h-captcha-response').val() === '') {
+                swal.fire({title: '{{trans('auth.required_captcha')}}', type: 'error'});
+                return false;
+            }
+			@break
+			@default
+			@endswitch
         });
 	</script>
 @endsection

+ 3 - 1
sql/db.sql

@@ -304,7 +304,7 @@ INSERT INTO `config` VALUES ('6', 'website_name', 'SSRPanel');
 INSERT INTO `config` VALUES ('7', 'is_reset_password', 1);
 INSERT INTO `config` VALUES ('8', 'reset_password_times', 3);
 INSERT INTO `config` VALUES ('9', 'website_url', 'https://www.ssrpanel.com');
-INSERT INTO `config` VALUES ('10', 'is_active_register', 1);
+INSERT INTO `config` VALUES ('10', 'referral_type', 0);
 INSERT INTO `config` VALUES ('11', 'active_times', 3);
 INSERT INTO `config` VALUES ('12', 'is_checkin', 1);
 INSERT INTO `config` VALUES ('13', 'min_rand_traffic', 10);
@@ -399,6 +399,8 @@ insert into `config` VALUES ('101', 'maintenance_mode', '0');
 insert into `config` VALUES ('102', 'maintenance_time', '');
 insert into `config` VALUES ('103', 'maintenance_content', '');
 insert into `config` VALUES ('104', 'bark_key', '');
+INSERT INTO `config` VALUES ('105', 'hcaptcha_secret', '');
+INSERT INTO `config` VALUES ('106', 'hcaptcha_sitekey', '');
 
 -- ----------------------------
 -- Table structure for `article`

+ 1 - 1
sql/mod/20200412.sql

@@ -5,7 +5,7 @@ alter table `notification_log` CHANGE `type` `type` TINYINT(4) NOT NULL DEFAULT
 insert into `config` VALUES ('104', 'bark_key', '');
 
 update `config` SET `name` = 'is_node_offline' where `config`.`id` = 37;
-update `config` SET `name` = 'is_notification', `value` = '0'  where `config`.`id` = 39;
+update `config` SET `name` = 'is_notification', `value` = '0' where `config`.`id` = 39;
 update `config` SET `name` = 'is_email_filtering',`value` = '0' where `config`.`id` = 58;
 update `config` SET `name` = 'detection_check_times' where `config`.`id` = 68;
 update `config` SET `name` = 'is_activate_account', `value` = '0' where `config`.`id` = 73;

+ 5 - 0
sql/mod/20200414.sql

@@ -0,0 +1,5 @@
+-- 返利模式可调:1-初次返利、2-循环返利
+UPDATE `config` SET `name` = 'referral_type', `value` = '0' where `config`.`id` = 10;
+-- 增加:hCaptcha的密钥和网站密钥
+INSERT INTO `config` VALUES ('105', 'hcaptcha_secret', '');
+INSERT INTO `config` VALUES ('106', 'hcaptcha_sitekey', '');