Browse Source

登录、注册验证码

zhangjiangbin 8 năm trước cách đây
mục cha
commit
dfba6f14fc

+ 255 - 42
_ide_helper.php

@@ -1,7 +1,7 @@
 <?php
 <?php
 /**
 /**
  * A helper file for Laravel 5, to provide autocomplete information to your IDE
  * A helper file for Laravel 5, to provide autocomplete information to your IDE
- * Generated for Laravel 5.4.27 on 2017-07-18.
+ * Generated for Laravel 5.4.30 on 2017-11-07.
  *
  *
  * @author Barry vd. Heuvel <[email protected]>
  * @author Barry vd. Heuvel <[email protected]>
  * @see https://github.com/barryvdh/laravel-ide-helper
  * @see https://github.com/barryvdh/laravel-ide-helper
@@ -1898,35 +1898,35 @@ namespace Illuminate\Support\Facades {
         /**
         /**
          * Determine if the current user is authenticated.
          * Determine if the current user is authenticated.
          *
          *
-         * @return bool 
+         * @return \App\User 
+         * @throws \Illuminate\Auth\AuthenticationException
          * @static 
          * @static 
          */ 
          */ 
-        public static function check()
+        public static function authenticate()
         {
         {
-            return \Illuminate\Auth\SessionGuard::check();
+            return \Illuminate\Auth\SessionGuard::authenticate();
         }
         }
         
         
         /**
         /**
-         * Determine if the current user is a guest.
+         * Determine if the current user is authenticated.
          *
          *
          * @return bool 
          * @return bool 
          * @static 
          * @static 
          */ 
          */ 
-        public static function guest()
+        public static function check()
         {
         {
-            return \Illuminate\Auth\SessionGuard::guest();
+            return \Illuminate\Auth\SessionGuard::check();
         }
         }
         
         
         /**
         /**
-         * Determine if the current user is authenticated.
+         * Determine if the current user is a guest.
          *
          *
-         * @return \App\User 
-         * @throws \Illuminate\Auth\AuthenticationException
+         * @return bool 
          * @static 
          * @static 
          */ 
          */ 
-        public static function authenticate()
+        public static function guest()
         {
         {
-            return \Illuminate\Auth\SessionGuard::authenticate();
+            return \Illuminate\Auth\SessionGuard::guest();
         }
         }
         
         
         /**
         /**
@@ -3594,7 +3594,7 @@ namespace Illuminate\Support\Facades {
         /**
         /**
          * Set the PDO connection.
          * Set the PDO connection.
          *
          *
-         * @param \PDO|null $pdo
+         * @param \PDO|\Closure|null $pdo
          * @return $this 
          * @return $this 
          * @static 
          * @static 
          */ 
          */ 
@@ -3607,7 +3607,7 @@ namespace Illuminate\Support\Facades {
         /**
         /**
          * Set the PDO connection used for reading.
          * Set the PDO connection used for reading.
          *
          *
-         * @param \PDO|null $pdo
+         * @param \PDO|\Closure|null $pdo
          * @return $this 
          * @return $this 
          * @static 
          * @static 
          */ 
          */ 
@@ -11153,32 +11153,6 @@ namespace Illuminate\Support\Facades {
             return \Illuminate\View\Factory::getShared();
             return \Illuminate\View\Factory::getShared();
         }
         }
         
         
-        /**
-         * Register a view composer event.
-         *
-         * @param array|string $views
-         * @param \Closure|string $callback
-         * @return array 
-         * @static 
-         */ 
-        public static function composer($views, $callback)
-        {
-            return \Illuminate\View\Factory::composer($views, $callback);
-        }
-        
-        /**
-         * Register a view creator event.
-         *
-         * @param array|string $views
-         * @param \Closure|string $callback
-         * @return array 
-         * @static 
-         */ 
-        public static function creator($views, $callback)
-        {
-            return \Illuminate\View\Factory::creator($views, $callback);
-        }
-        
         /**
         /**
          * Start a component rendering process.
          * Start a component rendering process.
          *
          *
@@ -11227,6 +11201,19 @@ namespace Illuminate\Support\Facades {
             \Illuminate\View\Factory::endSlot();
             \Illuminate\View\Factory::endSlot();
         }
         }
         
         
+        /**
+         * Register a view creator event.
+         *
+         * @param array|string $views
+         * @param \Closure|string $callback
+         * @return array 
+         * @static 
+         */ 
+        public static function creator($views, $callback)
+        {
+            return \Illuminate\View\Factory::creator($views, $callback);
+        }
+        
         /**
         /**
          * Register multiple view composers via an array.
          * Register multiple view composers via an array.
          *
          *
@@ -11239,6 +11226,19 @@ namespace Illuminate\Support\Facades {
             return \Illuminate\View\Factory::composers($composers);
             return \Illuminate\View\Factory::composers($composers);
         }
         }
         
         
+        /**
+         * Register a view composer event.
+         *
+         * @param array|string $views
+         * @param \Closure|string $callback
+         * @return array 
+         * @static 
+         */ 
+        public static function composer($views, $callback)
+        {
+            return \Illuminate\View\Factory::composer($views, $callback);
+        }
+        
         /**
         /**
          * Call the composer for a given view.
          * Call the composer for a given view.
          *
          *
@@ -11554,6 +11554,201 @@ namespace Illuminate\Support\Facades {
  
  
 }
 }
 
 
+namespace Maatwebsite\Excel\Facades { 
+
+    class Excel {
+        
+        /**
+         * Create a new file
+         *
+         * @param $filename
+         * @param callable|null $callback
+         * @return \Maatwebsite\Excel\LaravelExcelWriter 
+         * @static 
+         */ 
+        public static function create($filename, $callback = null)
+        {
+            return \Maatwebsite\Excel\Excel::create($filename, $callback);
+        }
+        
+        /**
+         * Load an existing file
+         *
+         * @param string $file The file we want to load
+         * @param callback|null $callback
+         * @param string|null $encoding
+         * @param bool $noBasePath
+         * @param callback|null $callbackConfigReader
+         * @return \Maatwebsite\Excel\LaravelExcelReader 
+         * @static 
+         */ 
+        public static function load($file, $callback = null, $encoding = null, $noBasePath = false, $callbackConfigReader = null)
+        {
+            return \Maatwebsite\Excel\Excel::load($file, $callback, $encoding, $noBasePath, $callbackConfigReader);
+        }
+        
+        /**
+         * Set select sheets
+         *
+         * @param $sheets
+         * @return \Maatwebsite\Excel\LaravelExcelReader 
+         * @static 
+         */ 
+        public static function selectSheets($sheets = array())
+        {
+            return \Maatwebsite\Excel\Excel::selectSheets($sheets);
+        }
+        
+        /**
+         * Select sheets by index
+         *
+         * @param array $sheets
+         * @return $this 
+         * @static 
+         */ 
+        public static function selectSheetsByIndex($sheets = array())
+        {
+            return \Maatwebsite\Excel\Excel::selectSheetsByIndex($sheets);
+        }
+        
+        /**
+         * Batch import
+         *
+         * @param $files
+         * @param callback $callback
+         * @return \PHPExcel 
+         * @static 
+         */ 
+        public static function batch($files, $callback)
+        {
+            return \Maatwebsite\Excel\Excel::batch($files, $callback);
+        }
+        
+        /**
+         * Create a new file and share a view
+         *
+         * @param string $view
+         * @param array $data
+         * @param array $mergeData
+         * @return \Maatwebsite\Excel\LaravelExcelWriter 
+         * @static 
+         */ 
+        public static function shareView($view, $data = array(), $mergeData = array())
+        {
+            return \Maatwebsite\Excel\Excel::shareView($view, $data, $mergeData);
+        }
+        
+        /**
+         * Create a new file and load a view
+         *
+         * @param string $view
+         * @param array $data
+         * @param array $mergeData
+         * @return \Maatwebsite\Excel\LaravelExcelWriter 
+         * @static 
+         */ 
+        public static function loadView($view, $data = array(), $mergeData = array())
+        {
+            return \Maatwebsite\Excel\Excel::loadView($view, $data, $mergeData);
+        }
+        
+        /**
+         * Set filters
+         *
+         * @param array $filters
+         * @return \Excel 
+         * @static 
+         */ 
+        public static function registerFilters($filters = array())
+        {
+            return \Maatwebsite\Excel\Excel::registerFilters($filters);
+        }
+        
+        /**
+         * Enable certain filters
+         *
+         * @param string|array $filter
+         * @param bool|false|string $class
+         * @return \Excel 
+         * @static 
+         */ 
+        public static function filter($filter, $class = false)
+        {
+            return \Maatwebsite\Excel\Excel::filter($filter, $class);
+        }
+        
+        /**
+         * Get register, enabled (or both) filters
+         *
+         * @param string|boolean $key [description]
+         * @return array 
+         * @static 
+         */ 
+        public static function getFilters($key = false)
+        {
+            return \Maatwebsite\Excel\Excel::getFilters($key);
+        }
+         
+    }
+ 
+}
+
+namespace Mews\Captcha\Facades { 
+
+    class Captcha {
+        
+        /**
+         * Create captcha image
+         *
+         * @param string $config
+         * @return \Mews\Captcha\ImageManager->response 
+         * @static 
+         */ 
+        public static function create($config = 'default')
+        {
+            return \Mews\Captcha\Captcha::create($config);
+        }
+        
+        /**
+         * Captcha check
+         *
+         * @param $value
+         * @return bool 
+         * @static 
+         */ 
+        public static function check($value)
+        {
+            return \Mews\Captcha\Captcha::check($value);
+        }
+        
+        /**
+         * Generate captcha image source
+         *
+         * @param null $config
+         * @return string 
+         * @static 
+         */ 
+        public static function src($config = null)
+        {
+            return \Mews\Captcha\Captcha::src($config);
+        }
+        
+        /**
+         * Generate captcha image html tag
+         *
+         * @param null $config
+         * @return string 
+         * @static 
+         */ 
+        public static function img($config = null)
+        {
+            return \Mews\Captcha\Captcha::img($config);
+        }
+         
+    }
+ 
+}
+
 
 
 namespace  { 
 namespace  { 
 
 
@@ -11946,7 +12141,7 @@ namespace  {
              * Save a new model and return the instance.
              * Save a new model and return the instance.
              *
              *
              * @param array $attributes
              * @param array $attributes
-             * @return \Illuminate\Database\Eloquent\Model 
+             * @return \Illuminate\Database\Eloquent\Model|$this 
              * @static 
              * @static 
              */ 
              */ 
             public static function create($attributes = array())
             public static function create($attributes = array())
@@ -11958,7 +12153,7 @@ namespace  {
              * Save a new model and return the instance. Allow mass-assignment.
              * Save a new model and return the instance. Allow mass-assignment.
              *
              *
              * @param array $attributes
              * @param array $attributes
-             * @return \Illuminate\Database\Eloquent\Model 
+             * @return \Illuminate\Database\Eloquent\Model|$this 
              * @static 
              * @static 
              */ 
              */ 
             public static function forceCreate($attributes)
             public static function forceCreate($attributes)
@@ -12169,6 +12364,20 @@ namespace  {
                 return \Illuminate\Database\Eloquent\Builder::when($value, $callback, $default);
                 return \Illuminate\Database\Eloquent\Builder::when($value, $callback, $default);
             }
             }
          
          
+            /**
+             * Apply the callback's query changes if the given "value" is false.
+             *
+             * @param mixed $value
+             * @param callable $callback
+             * @param callable $default
+             * @return mixed 
+             * @static 
+             */ 
+            public static function unless($value, $callback, $default = null)
+            {    
+                return \Illuminate\Database\Eloquent\Builder::unless($value, $callback, $default);
+            }
+         
             /**
             /**
              * Add a relationship count / exists condition to the query.
              * Add a relationship count / exists condition to the query.
              *
              *
@@ -13603,6 +13812,10 @@ namespace  {
     class Validator extends \Illuminate\Support\Facades\Validator {}
     class Validator extends \Illuminate\Support\Facades\Validator {}
 
 
     class View extends \Illuminate\Support\Facades\View {}
     class View extends \Illuminate\Support\Facades\View {}
+
+    class Excel extends \Maatwebsite\Excel\Facades\Excel {}
+
+    class Captcha extends \Mews\Captcha\Facades\Captcha {}
  
  
 }
 }
 
 

+ 6 - 6
app/Console/Commands/AutoDecGoodsTrafficJob.php

@@ -20,15 +20,15 @@ class AutoDecGoodsTrafficJob extends Command
 
 
     public function handle()
     public function handle()
     {
     {
-        $orderGoods = OrderGoods::where('is_expire', 0)->get();
+        $orderGoods = OrderGoods::query()->where('is_expire', 0)->get();
         foreach ($orderGoods as $og) {
         foreach ($orderGoods as $og) {
-            $goods = Goods::where('id', $og->goods_id)->first();
+            $goods = Goods::query()->where('id', $og->goods_id)->first();
             if (empty($goods)) {
             if (empty($goods)) {
                 continue;
                 continue;
             }
             }
 
 
             if (date("Y-m-d H:i:s", strtotime("-" . $goods->days . " days")) >= $og->created_at) {
             if (date("Y-m-d H:i:s", strtotime("-" . $goods->days . " days")) >= $og->created_at) {
-                $u = User::where('id', $og->user_id)->first();
+                $u = User::query()->where('id', $og->user_id)->first();
                 if (empty($u)) {
                 if (empty($u)) {
                     continue;
                     continue;
                 }
                 }
@@ -36,13 +36,13 @@ class AutoDecGoodsTrafficJob extends Command
                 // 流量包到期自动扣总流量
                 // 流量包到期自动扣总流量
                 //if ($goods->type == 1) {
                 //if ($goods->type == 1) {
                     if ($u->transfer_enable - $goods->traffic * 1048576 <= 0) {
                     if ($u->transfer_enable - $goods->traffic * 1048576 <= 0) {
-                        User::where('id', $og->user_id)->update(['transfer_enable' => 0]);
+                        User::query()->where('id', $og->user_id)->update(['transfer_enable' => 0]);
                     } else {
                     } else {
-                        User::where('id', $og->user_id)->decrement('transfer_enable', $goods->traffic * 1048576);
+                        User::query()->where('id', $og->user_id)->decrement('transfer_enable', $goods->traffic * 1048576);
                     }
                     }
                 //}
                 //}
 
 
-                OrderGoods::where('id', $og->id)->update(['is_expire' => 1]);
+                OrderGoods::query()->where('id', $og->id)->update(['is_expire' => 1]);
             }
             }
         }
         }
 
 

+ 1 - 1
app/Console/Commands/AutoDisableExpireUserJob.php

@@ -19,7 +19,7 @@ class autoDisableExpireUserJob extends Command
     public function handle()
     public function handle()
     {
     {
         // 到期账号禁用
         // 到期账号禁用
-        User::where('enable', 1)->where('expire_time', '<=', date('Y-m-d'))->update(['enable' => 0]);
+        User::query()->where('enable', 1)->where('expire_time', '<=', date('Y-m-d'))->update(['enable' => 0]);
 
 
         Log::info('定时任务:' . $this->description);
         Log::info('定时任务:' . $this->description);
     }
     }

+ 2 - 2
app/Console/Commands/AutoExpireCouponJob.php

@@ -18,10 +18,10 @@ class AutoExpireCouponJob extends Command
 
 
     public function handle()
     public function handle()
     {
     {
-        $couponList = Coupon::where('status', 0)->where('available_end', '<=', time())->get();
+        $couponList = Coupon::query()->where('status', 0)->where('available_end', '<=', time())->get();
         if (!$couponList->isEmpty()) {
         if (!$couponList->isEmpty()) {
             foreach ($couponList as $coupon) {
             foreach ($couponList as $coupon) {
-                Coupon::where('id', $coupon->id)->update(['status' => 2]);
+                Coupon::query()->where('id', $coupon->id)->update(['status' => 2]);
             }
             }
         }
         }
 
 

+ 2 - 2
app/Console/Commands/AutoExpireInviteJob.php

@@ -18,10 +18,10 @@ class AutoExpireInviteJob extends Command
 
 
     public function handle()
     public function handle()
     {
     {
-        $inviteList = Invite::where('status', 0)->where('dateline', '<=', date('Y-m-d H:i:s'))->get();
+        $inviteList = Invite::query()->where('status', 0)->where('dateline', '<=', date('Y-m-d H:i:s'))->get();
         if (!$inviteList->isEmpty()) {
         if (!$inviteList->isEmpty()) {
             foreach ($inviteList as $invite) {
             foreach ($inviteList as $invite) {
-                Invite::where('id', $invite->id)->update(['status' => 2]);
+                Invite::query()->where('id', $invite->id)->update(['status' => 2]);
             }
             }
         }
         }
 
 

+ 45 - 15
app/Console/Commands/AutoGetLocationInfoJob.php

@@ -18,37 +18,67 @@ class AutoGetLocationInfoJob extends Command
 
 
     public function handle()
     public function handle()
     {
     {
-        $articleLogList = ArticleLog::where('is_pull', 0)->get();
+        $articleLogList = ArticleLog::query()->where('is_pull', 0)->get();
         foreach ($articleLogList as $articleLog) {
         foreach ($articleLogList as $articleLog) {
-            $url = "http://apis.map.qq.com/ws/geocoder/v1/?location=" . $articleLog->lat . ',' . $articleLog->lng . '&key=XXXXX';
+            $url = $this->makeUrl($articleLog->lat, $articleLog->lng);
             $ret = file_get_contents($url);
             $ret = file_get_contents($url);
             $result = json_decode($ret, true);
             $result = json_decode($ret, true);
-            //Log::info(var_export($result, true));
+            Log::info(var_export($result, true));
 
 
             if ($result['status']) {
             if ($result['status']) {
-                continue;
                 Log::error('文章日志通过API获取坐标对应的地址信息失败.');
                 Log::error('文章日志通过API获取坐标对应的地址信息失败.');
+                continue;
             }
             }
 
 
             // 更新日志信息
             // 更新日志信息
             $data = [
             $data = [
-                'nation' => $result['result']['address_component']['nation'],
-                'province' => $result['result']['address_component']['province'],
-                'city' => $result['result']['address_component']['city'],
-                'district' => $result['result']['address_component']['district'],
-                'street' => $result['result']['address_component']['street'],
+                'nation'        => $result['result']['address_component']['nation'],
+                'province'      => $result['result']['address_component']['province'],
+                'city'          => $result['result']['address_component']['city'],
+                'district'      => $result['result']['address_component']['district'],
+                'street'        => $result['result']['address_component']['street'],
                 'street_number' => $result['result']['address_component']['street_number'],
                 'street_number' => $result['result']['address_component']['street_number'],
-                'address' => $result['result']['address'],
-                'full' => $ret,
-                'is_pull' => 1
+                'address'       => $result['result']['address'],
+                'full'          => $ret,
+                'is_pull'       => 1
             ];
             ];
 
 
-            ArticleLog::where('id', $articleLog->id)->update($data);
+            ArticleLog::query()->where('id', $articleLog->id)->update($data);
 
 
-            // 暂停一秒,防止QPS超限导致返回错误
-            sleep(1);
+            // 休眠0.2秒,防止QPS超限导致返回错误
+            usleep(200000);
         }
         }
 
 
         Log::info('定时任务:' . $this->description);
         Log::info('定时任务:' . $this->description);
     }
     }
+
+    // 生成坐标查询URL
+    private function makeUrl($lat, $lng)
+    {
+        $coordinate = $this->translate($lat, $lng);
+
+        $url = "http://apis.map.qq.com/ws/geocoder/v1/?location={$coordinate['lat']},{$coordinate['lng']}&key=XXXX";
+
+        return $url;
+    }
+
+    /**
+     * 地图坐标系转换
+     * 百度地图(BD09)转腾讯地图(GCJ02)坐标系
+     * @param double $lat 纬度
+     * @param double $lng 经度
+     * @return array
+     **/
+    private function translate($lat, $lng)
+    {
+        $x_pi = 3.14159265358979324 * 3000.0 / 180.0;
+        $x = $lng - 0.0065;
+        $y = $lat - 0.006;
+        $z = sqrt($x * $x + $y * $y) - 0.00002 * sin($y * $x_pi);
+        $theta = atan2($y, $x) - 0.000003 * cos($x * $x_pi);
+        $lng = $z * cos($theta);
+        $lat = $z * sin($theta);
+
+        return ['lat' => $lat, 'lng' => $lng];
+    }
 }
 }

+ 3 - 3
app/Console/Commands/AutoResetUserTrafficJob.php

@@ -18,7 +18,7 @@ class AutoResetUserTrafficJob extends Command
     {
     {
         parent::__construct();
         parent::__construct();
 
 
-        $config = Config::get();
+        $config = Config::query()->get();
         $data = [];
         $data = [];
         foreach ($config as $vo) {
         foreach ($config as $vo) {
             $data[$vo->name] = $vo->value;
             $data[$vo->name] = $vo->value;
@@ -30,8 +30,8 @@ class AutoResetUserTrafficJob extends Command
     public function handle()
     public function handle()
     {
     {
         if (self::$config['reset_traffic']) {
         if (self::$config['reset_traffic']) {
-            $user_ids = User::where('pay_way', '<>', 0)->select(['id'])->get();
-            User::whereIn('id', $user_ids)->update(['u' => 0, 'd' => 0]);
+            $user_ids = User::query()->where('pay_way', '<>', 0)->select(['id'])->get();
+            User::query()->whereIn('id', $user_ids)->update(['u' => 0, 'd' => 0]);
         }
         }
 
 
         Log::info('定时任务:' . $this->description);
         Log::info('定时任务:' . $this->description);

+ 3 - 3
app/Console/Commands/AutoStatisticsUserDailyTrafficJob.php

@@ -21,13 +21,13 @@ class AutoStatisticsUserDailyTrafficJob extends Command
 
 
     public function handle()
     public function handle()
     {
     {
-        $userList = User::where('status', '>=', 0)->where('enable', 1)->get();
+        $userList = User::query()->where('status', '>=', 0)->where('enable', 1)->get();
         foreach ($userList as $user) {
         foreach ($userList as $user) {
             // 统计一次所有节点的总和
             // 统计一次所有节点的总和
             $this->statisticsByNode($user->id);
             $this->statisticsByNode($user->id);
 
 
             // 统计每个节点产生的流量
             // 统计每个节点产生的流量
-            $nodeList = SsNode::get();
+            $nodeList = SsNode::query()->get();
             foreach ($nodeList as $node) {
             foreach ($nodeList as $node) {
                 $this->statisticsByNode($user->id, $node->id);
                 $this->statisticsByNode($user->id, $node->id);
             }
             }
@@ -40,7 +40,7 @@ class AutoStatisticsUserDailyTrafficJob extends Command
         $start_time = strtotime(date('Y-m-d 00:00:00', strtotime("-1 day")));
         $start_time = strtotime(date('Y-m-d 00:00:00', strtotime("-1 day")));
         $end_time = strtotime(date('Y-m-d 23:59:59', strtotime("-1 day")));
         $end_time = strtotime(date('Y-m-d 23:59:59', strtotime("-1 day")));
 
 
-        $query = UserTrafficLog::where('user_id', $user_id)->whereBetween('log_time', [$start_time, $end_time]);
+        $query = UserTrafficLog::query()->where('user_id', $user_id)->whereBetween('log_time', [$start_time, $end_time]);
 
 
         if ($node_id) {
         if ($node_id) {
             $query->where('node_id', $node_id);
             $query->where('node_id', $node_id);

+ 3 - 3
app/Console/Commands/AutoStatisticsUserHourlyTrafficJob.php

@@ -21,13 +21,13 @@ class AutoStatisticsUserHourlyTrafficJob extends Command
 
 
     public function handle()
     public function handle()
     {
     {
-        $userList = User::where('status', '>=', 0)->where('enable', 1)->get();
+        $userList = User::query()->where('status', '>=', 0)->where('enable', 1)->get();
         foreach ($userList as $user) {
         foreach ($userList as $user) {
             // 统计一次所有节点的总和
             // 统计一次所有节点的总和
             $this->statisticsByNode($user->id);
             $this->statisticsByNode($user->id);
 
 
             // 统计每个节点产生的流量
             // 统计每个节点产生的流量
-            $nodeList = SsNode::get();
+            $nodeList = SsNode::query()->get();
             foreach ($nodeList as $node) {
             foreach ($nodeList as $node) {
                 $this->statisticsByNode($user->id, $node->id);
                 $this->statisticsByNode($user->id, $node->id);
             }
             }
@@ -40,7 +40,7 @@ class AutoStatisticsUserHourlyTrafficJob extends Command
         $start_time = strtotime(date('Y-m-d H:i:s', strtotime("-1 hour")));
         $start_time = strtotime(date('Y-m-d H:i:s', strtotime("-1 hour")));
         $end_time = time();
         $end_time = time();
 
 
-        $query = UserTrafficLog::where('user_id', $user_id)->whereBetween('log_time', [$start_time, $end_time]);
+        $query = UserTrafficLog::query()->where('user_id', $user_id)->whereBetween('log_time', [$start_time, $end_time]);
 
 
         if ($node_id) {
         if ($node_id) {
             $query->where('node_id', $node_id);
             $query->where('node_id', $node_id);

+ 2 - 2
app/Console/Commands/UserExpireWarningJob.php

@@ -21,7 +21,7 @@ class UserExpireWarningJob extends Command
     {
     {
         parent::__construct();
         parent::__construct();
 
 
-        $config = Config::get();
+        $config = Config::query()->get();
         $data = [];
         $data = [];
         foreach ($config as $vo) {
         foreach ($config as $vo) {
             $data[$vo->name] = $vo->value;
             $data[$vo->name] = $vo->value;
@@ -33,7 +33,7 @@ class UserExpireWarningJob extends Command
     public function handle()
     public function handle()
     {
     {
         if (self::$config['expire_warning']) {
         if (self::$config['expire_warning']) {
-            $userList = User::where('transfer_enable', '>', 0)->whereIn('status', [0, 1])->where('enable', 1)->get();
+            $userList = User::query()->where('transfer_enable', '>', 0)->whereIn('status', [0, 1])->where('enable', 1)->get();
             foreach ($userList as $user) {
             foreach ($userList as $user) {
                 // 用户名不是邮箱的跳过
                 // 用户名不是邮箱的跳过
                 if (false === filter_var($user->username, FILTER_VALIDATE_EMAIL)) {
                 if (false === filter_var($user->username, FILTER_VALIDATE_EMAIL)) {

+ 2 - 2
app/Console/Commands/UserTrafficWarningJob.php

@@ -21,7 +21,7 @@ class UserTrafficWarningJob extends Command
     {
     {
         parent::__construct();
         parent::__construct();
 
 
-        $config = Config::get();
+        $config = Config::query()->get();
         $data = [];
         $data = [];
         foreach ($config as $vo) {
         foreach ($config as $vo) {
             $data[$vo->name] = $vo->value;
             $data[$vo->name] = $vo->value;
@@ -33,7 +33,7 @@ class UserTrafficWarningJob extends Command
     public function handle()
     public function handle()
     {
     {
         if (self::$config['traffic_warning']) {
         if (self::$config['traffic_warning']) {
-            $userList = User::where('transfer_enable', '>', 0)->whereIn('status', [0, 1])->where('enable', 1)->get();
+            $userList = User::query()->where('transfer_enable', '>', 0)->whereIn('status', [0, 1])->where('enable', 1)->get();
             foreach ($userList as $user) {
             foreach ($userList as $user) {
                 // 用户名不是邮箱的跳过
                 // 用户名不是邮箱的跳过
                 if (false === filter_var($user->username, FILTER_VALIDATE_EMAIL)) {
                 if (false === filter_var($user->username, FILTER_VALIDATE_EMAIL)) {

+ 12 - 0
app/Http/Controllers/LoginController.php

@@ -7,6 +7,7 @@ use App\Http\Models\UserScoreLog;
 use Illuminate\Http\Request;
 use Illuminate\Http\Request;
 use Response;
 use Response;
 use Redirect;
 use Redirect;
+use Captcha;
 use Cache;
 use Cache;
 
 
 /**
 /**
@@ -29,6 +30,7 @@ class LoginController extends BaseController
         if ($request->method() == 'POST') {
         if ($request->method() == 'POST') {
             $username = trim($request->get('username'));
             $username = trim($request->get('username'));
             $password = trim($request->get('password'));
             $password = trim($request->get('password'));
+            $captcha = trim($request->get('captcha'));
 
 
             if (empty($username) || empty($password)) {
             if (empty($username) || empty($password)) {
                 $request->session()->flash('errorMsg', '请输入用户名和密码');
                 $request->session()->flash('errorMsg', '请输入用户名和密码');
@@ -36,6 +38,15 @@ class LoginController extends BaseController
                 return Redirect::back();
                 return Redirect::back();
             }
             }
 
 
+            // 是否校验验证码
+            if (self::$config['is_captcha']) {
+                if (!Captcha::check($captcha)) {
+                    $request->session()->flash('errorMsg', '验证码错误,请重新输入');
+
+                    return Redirect::back()->withInput();
+                }
+            }
+
             $user = User::query()->where('username', $username)->where('password', md5($password))->first();
             $user = User::query()->where('username', $username)->where('password', md5($password))->first();
             if (!$user) {
             if (!$user) {
                 $request->session()->flash('errorMsg', '用户名或密码错误');
                 $request->session()->flash('errorMsg', '用户名或密码错误');
@@ -88,6 +99,7 @@ class LoginController extends BaseController
 
 
             return Redirect::to('user');
             return Redirect::to('user');
         } else {
         } else {
+            $view['is_captcha'] = self::$config['is_captcha'];
             $view['is_register'] = self::$config['is_register'];
             $view['is_register'] = self::$config['is_register'];
 
 
             return Response::view('login', $view);
             return Response::view('login', $view);

+ 12 - 0
app/Http/Controllers/RegisterController.php

@@ -8,6 +8,7 @@ use App\Http\Models\User;
 use App\Http\Models\Verify;
 use App\Http\Models\Verify;
 use Illuminate\Http\Request;
 use Illuminate\Http\Request;
 use App\Mail\activeUser;
 use App\Mail\activeUser;
+use Captcha;
 use Response;
 use Response;
 use Redirect;
 use Redirect;
 use Mail;
 use Mail;
@@ -33,6 +34,7 @@ class RegisterController extends BaseController
             $username = trim($request->get('username'));
             $username = trim($request->get('username'));
             $password = trim($request->get('password'));
             $password = trim($request->get('password'));
             $repassword = trim($request->get('repassword'));
             $repassword = trim($request->get('repassword'));
+            $captcha = trim($request->get('captcha'));
             $code = trim($request->get('code'));
             $code = trim($request->get('code'));
             $aff = intval($request->get('aff', 0));
             $aff = intval($request->get('aff', 0));
 
 
@@ -58,6 +60,15 @@ class RegisterController extends BaseController
                 return Redirect::back()->withInput();
                 return Redirect::back()->withInput();
             }
             }
 
 
+            // 是否校验验证码
+            if (self::$config['is_captcha']) {
+                if (!Captcha::check($captcha)) {
+                    $request->session()->flash('errorMsg', '验证码错误,请重新输入');
+
+                    return Redirect::back()->withInput($request->except(['password', 'repassword']));
+                }
+            }
+
             // 是否开启注册
             // 是否开启注册
             if (!self::$config['is_register']) {
             if (!self::$config['is_register']) {
                 $request->session()->flash('errorMsg', '系统维护暂停注册,如需账号请联系管理员');
                 $request->session()->flash('errorMsg', '系统维护暂停注册,如需账号请联系管理员');
@@ -158,6 +169,7 @@ class RegisterController extends BaseController
 
 
             return Redirect::to('login');
             return Redirect::to('login');
         } else {
         } else {
+            $view['is_captcha'] = self::$config['is_captcha'];
             $view['is_register'] = self::$config['is_register'];
             $view['is_register'] = self::$config['is_register'];
             $view['is_invite_register'] = self::$config['is_invite_register'];
             $view['is_invite_register'] = self::$config['is_invite_register'];
 
 

+ 2 - 1
composer.json

@@ -10,7 +10,8 @@
         "guzzlehttp/guzzle": "^6.3",
         "guzzlehttp/guzzle": "^6.3",
         "laravel/framework": "5.4.*",
         "laravel/framework": "5.4.*",
         "laravel/tinker": "~1.0",
         "laravel/tinker": "~1.0",
-        "maatwebsite/excel": "~2.1.0"
+        "maatwebsite/excel": "~2.1.0",
+        "mews/captcha": "^2.1"
     },
     },
     "require-dev": {
     "require-dev": {
         "fzaninotto/faker": "~1.4",
         "fzaninotto/faker": "~1.4",

+ 141 - 4
composer.lock

@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
         "This file is @generated automatically"
         "This file is @generated automatically"
     ],
     ],
-    "content-hash": "1db545b9e18088f18d459d1563a53042",
+    "content-hash": "c3b689972dda94578780a423aa31c71c",
     "packages": [
     "packages": [
         {
         {
             "name": "barryvdh/laravel-ide-helper",
             "name": "barryvdh/laravel-ide-helper",
@@ -451,6 +451,76 @@
             ],
             ],
             "time": "2017-03-20T17:10:46+00:00"
             "time": "2017-03-20T17:10:46+00:00"
         },
         },
+        {
+            "name": "intervention/image",
+            "version": "2.4.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/Intervention/image.git",
+                "reference": "3603dbcc9a17d307533473246a6c58c31cf17919"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://files.phpcomposer.com/files/Intervention/image/3603dbcc9a17d307533473246a6c58c31cf17919.zip",
+                "reference": "3603dbcc9a17d307533473246a6c58c31cf17919",
+                "shasum": ""
+            },
+            "require": {
+                "ext-fileinfo": "*",
+                "guzzlehttp/psr7": "~1.1",
+                "php": ">=5.4.0"
+            },
+            "require-dev": {
+                "mockery/mockery": "~0.9.2",
+                "phpunit/phpunit": "^4.8 || ^5.7"
+            },
+            "suggest": {
+                "ext-gd": "to use GD library based image processing.",
+                "ext-imagick": "to use Imagick based image processing.",
+                "intervention/imagecache": "Caching extension for the Intervention Image library"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "2.3-dev"
+                },
+                "laravel": {
+                    "providers": [
+                        "Intervention\\Image\\ImageServiceProvider"
+                    ],
+                    "aliases": {
+                        "Image": "Intervention\\Image\\Facades\\Image"
+                    }
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Intervention\\Image\\": "src/Intervention/Image"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Oliver Vogel",
+                    "email": "[email protected]",
+                    "homepage": "http://olivervogel.com/"
+                }
+            ],
+            "description": "Image handling and manipulation library with support for Laravel integration",
+            "homepage": "http://image.intervention.io/",
+            "keywords": [
+                "gd",
+                "image",
+                "imagick",
+                "laravel",
+                "thumbnail",
+                "watermark"
+            ],
+            "time": "2017-09-21T16:29:17+00:00"
+        },
         {
         {
             "name": "jakub-onderka/php-console-color",
             "name": "jakub-onderka/php-console-color",
             "version": "0.1",
             "version": "0.1",
@@ -949,6 +1019,73 @@
             ],
             ],
             "time": "2017-09-19T19:36:48+00:00"
             "time": "2017-09-19T19:36:48+00:00"
         },
         },
+        {
+            "name": "mews/captcha",
+            "version": "2.1.7",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/mewebstudio/captcha.git",
+                "reference": "7d48d7dc5df0fb2225b086ba85cb3fef9832b235"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://files.phpcomposer.com/files/mewebstudio/captcha/7d48d7dc5df0fb2225b086ba85cb3fef9832b235.zip",
+                "reference": "7d48d7dc5df0fb2225b086ba85cb3fef9832b235",
+                "shasum": ""
+            },
+            "require": {
+                "ext-gd": "*",
+                "illuminate/config": "~5.0",
+                "illuminate/filesystem": "~5.0",
+                "illuminate/hashing": "~5.0",
+                "illuminate/support": "~5.0",
+                "intervention/image": "~2.2",
+                "php": ">=5.4"
+            },
+            "require-dev": {
+                "mockery/mockery": "0.9.*",
+                "phpunit/phpunit": "~4.1"
+            },
+            "type": "package",
+            "extra": {
+                "laravel": {
+                    "providers": [
+                        "Mews\\Captcha\\CaptchaServiceProvider"
+                    ],
+                    "aliases": {
+                        "Captcha": "Mews\\Captcha\\Facades\\Captcha"
+                    }
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Mews\\Captcha\\": "src/"
+                },
+                "files": [
+                    "src/helpers.php"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Muharrem ER?N",
+                    "email": "[email protected]",
+                    "homepage": "https://github.com/mewebstudio",
+                    "role": "Developer"
+                }
+            ],
+            "description": "Laravel 5 Captcha Package",
+            "homepage": "https://github.com/mewebstudio/captcha",
+            "keywords": [
+                "captcha",
+                "laravel5 Captcha",
+                "laravel5 Security"
+            ],
+            "time": "2017-09-11T14:59:20+00:00"
+        },
         {
         {
             "name": "monolog/monolog",
             "name": "monolog/monolog",
             "version": "1.23.0",
             "version": "1.23.0",
@@ -1748,7 +1885,7 @@
             ],
             ],
             "authors": [
             "authors": [
                 {
                 {
-                    "name": "Jean-Francois Simon",
+                    "name": "Jean-Fran?ois Simon",
                     "email": "[email protected]"
                     "email": "[email protected]"
                 },
                 },
                 {
                 {
@@ -2688,7 +2825,7 @@
             ],
             ],
             "authors": [
             "authors": [
                 {
                 {
-                    "name": "Francois Zaninotto"
+                    "name": "Fran?ois Zaninotto"
                 }
                 }
             ],
             ],
             "description": "Faker is a PHP library that generates fake data for you.",
             "description": "Faker is a PHP library that generates fake data for you.",
@@ -2783,7 +2920,7 @@
             ],
             ],
             "authors": [
             "authors": [
                 {
                 {
-                    "name": "Padraic Brady",
+                    "name": "P¨¢draic Brady",
                     "email": "[email protected]",
                     "email": "[email protected]",
                     "homepage": "http://blog.astrumfutura.com"
                     "homepage": "http://blog.astrumfutura.com"
                 },
                 },

+ 3 - 0
config/app.php

@@ -179,6 +179,8 @@ return [
 
 
         Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class,
         Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class,
         Maatwebsite\Excel\ExcelServiceProvider::class,
         Maatwebsite\Excel\ExcelServiceProvider::class,
+        Mews\Captcha\CaptchaServiceProvider::class,
+
     ],
     ],
 
 
     /*
     /*
@@ -228,6 +230,7 @@ return [
         'Validator' => Illuminate\Support\Facades\Validator::class,
         'Validator' => Illuminate\Support\Facades\Validator::class,
         'View' => Illuminate\Support\Facades\View::class,
         'View' => Illuminate\Support\Facades\View::class,
         'Excel' => Maatwebsite\Excel\Facades\Excel::class,
         'Excel' => Maatwebsite\Excel\Facades\Excel::class,
+        'Captcha' => Mews\Captcha\Facades\Captcha::class,
 
 
     ],
     ],
 
 

+ 46 - 0
config/captcha.php

@@ -0,0 +1,46 @@
+<?php
+
+return [
+
+    'characters' => '2346789abcdefghjmnpqrtuxyzABCDEFGHJMNPQRTUXYZ',
+
+    'default'   => [
+        'length'    => 4,
+        'width'     => 90,
+        'height'    => 43,
+        'quality'   => 90,
+        'lines'     => 4,
+    ],
+
+    'flat'   => [
+        'length'    => 6,
+        'width'     => 160,
+        'height'    => 46,
+        'quality'   => 90,
+        'lines'     => 6,
+        'bgImage'   => false,
+        'bgColor'   => '#ecf2f4',
+        'fontColors'=> ['#2c3e50', '#c0392b', '#16a085', '#c0392b', '#8e44ad', '#303f9f', '#f57c00', '#795548'],
+        'contrast'  => -5,
+    ],
+
+    'mini'   => [
+        'length'    => 3,
+        'width'     => 60,
+        'height'    => 32,
+    ],
+
+    'inverse'   => [
+        'length'    => 5,
+        'width'     => 120,
+        'height'    => 36,
+        'quality'   => 90,
+        'sensitive' => true,
+        'angle'     => 12,
+        'sharpen'   => 10,
+        'blur'      => 2,
+        'invert'    => true,
+        'contrast'  => -5,
+    ]
+
+];

+ 179 - 0
config/ide-helper.php

@@ -0,0 +1,179 @@
+<?php
+
+return array(
+
+    /*
+    |--------------------------------------------------------------------------
+    | Filename & Format
+    |--------------------------------------------------------------------------
+    |
+    | The default filename (without extension) and the format (php or json)
+    |
+    */
+
+    'filename'  => '_ide_helper',
+    'format'    => 'php',
+
+    /*
+    |--------------------------------------------------------------------------
+    | Fluent helpers
+    |--------------------------------------------------------------------------
+    |
+    | Set to true to generate commonly used Fluent methods
+    |
+    */
+
+    'include_fluent' => false,
+
+    /*
+    |--------------------------------------------------------------------------
+    | Write Model Magic methods
+    |--------------------------------------------------------------------------
+    |
+    | Set to false to disable write magic methods of model
+    |
+    */
+
+    'write_model_magic_where' => true,
+
+    /*
+    |--------------------------------------------------------------------------
+    | Helper files to include
+    |--------------------------------------------------------------------------
+    |
+    | Include helper files. By default not included, but can be toggled with the
+    | -- helpers (-H) option. Extra helper files can be included.
+    |
+    */
+
+    'include_helpers' => false,
+
+    'helper_files' => array(
+        base_path().'/vendor/laravel/framework/src/Illuminate/Support/helpers.php',
+    ),
+
+    /*
+    |--------------------------------------------------------------------------
+    | Model locations to include
+    |--------------------------------------------------------------------------
+    |
+    | Define in which directories the ide-helper:models command should look
+    | for models.
+    |
+    */
+
+    'model_locations' => array(
+        'app',
+    ),
+
+
+    /*
+    |--------------------------------------------------------------------------
+    | Extra classes
+    |--------------------------------------------------------------------------
+    |
+    | These implementations are not really extended, but called with magic functions
+    |
+    */
+
+    'extra' => array(
+        'Eloquent' => array('Illuminate\Database\Eloquent\Builder', 'Illuminate\Database\Query\Builder'),
+        'Session' => array('Illuminate\Session\Store'),
+    ),
+
+    'magic' => array(
+        'Log' => array(
+            'debug'     => 'Monolog\Logger::addDebug',
+            'info'      => 'Monolog\Logger::addInfo',
+            'notice'    => 'Monolog\Logger::addNotice',
+            'warning'   => 'Monolog\Logger::addWarning',
+            'error'     => 'Monolog\Logger::addError',
+            'critical'  => 'Monolog\Logger::addCritical',
+            'alert'     => 'Monolog\Logger::addAlert',
+            'emergency' => 'Monolog\Logger::addEmergency',
+        )
+    ),
+
+    /*
+    |--------------------------------------------------------------------------
+    | Interface implementations
+    |--------------------------------------------------------------------------
+    |
+    | These interfaces will be replaced with the implementing class. Some interfaces
+    | are detected by the helpers, others can be listed below.
+    |
+    */
+
+    'interfaces' => array(
+
+    ),
+
+    /*
+    |--------------------------------------------------------------------------
+    | Support for custom DB types
+    |--------------------------------------------------------------------------
+    |
+    | This setting allow you to map any custom database type (that you may have
+    | created using CREATE TYPE statement or imported using database plugin
+    | / extension to a Doctrine type.
+    |
+    | Each key in this array is a name of the Doctrine2 DBAL Platform. Currently valid names are:
+    | 'postgresql', 'db2', 'drizzle', 'mysql', 'oracle', 'sqlanywhere', 'sqlite', 'mssql'
+    |
+    | This name is returned by getName() method of the specific Doctrine/DBAL/Platforms/AbstractPlatform descendant
+    |
+    | The value of the array is an array of type mappings. Key is the name of the custom type,
+    | (for example, "jsonb" from Postgres 9.4) and the value is the name of the corresponding Doctrine2 type (in
+    | our case it is 'json_array'. Doctrine types are listed here:
+    | http://doctrine-dbal.readthedocs.org/en/latest/reference/types.html
+    |
+    | So to support jsonb in your models when working with Postgres, just add the following entry to the array below:
+    |
+    | "postgresql" => array(
+    |       "jsonb" => "json_array",
+    |  ),
+    |
+    */
+    'custom_db_types' => array(
+
+    ),
+
+    /*
+     |--------------------------------------------------------------------------
+     | Support for camel cased models
+     |--------------------------------------------------------------------------
+     |
+     | There are some Laravel packages (such as Eloquence) that allow for accessing
+     | Eloquent model properties via camel case, instead of snake case.
+     |
+     | Enabling this option will support these packages by saving all model
+     | properties as camel case, instead of snake case.
+     |
+     | For example, normally you would see this:
+     |
+     |  * @property \Carbon\Carbon $created_at
+     |  * @property \Carbon\Carbon $updated_at
+     |
+     | With this enabled, the properties will be this:
+     |
+     |  * @property \Carbon\Carbon $createdAt
+     |  * @property \Carbon\Carbon $updatedAt
+     |
+     | Note, it is currently an all-or-nothing option.
+     |
+     */
+    'model_camel_case_properties' => false,
+
+    /*
+    |--------------------------------------------------------------------------
+    | Property Casts
+    |--------------------------------------------------------------------------
+    |
+    | Cast the given "real type" to the given "type".
+    |
+    */
+   'type_overrides' => array(
+        'integer' => 'int',
+        'boolean' => 'bool',
+   ),
+);

+ 12 - 3
readme.md

@@ -15,7 +15,7 @@ telegram频道:https://t.me/ssrpanel
 telegram群组:https://t.me/chatssrpanel
 telegram群组:https://t.me/chatssrpanel
 开发测试演示:http://www.ssrpanel.com
 开发测试演示:http://www.ssrpanel.com
 用户名:admin 密码:123456
 用户名:admin 密码:123456
-(请大家勿改admin的密码,SSR被滥用,我已关闭)
+(请大家勿改admin的密码)
 ````
 ````
 
 
 ![VPS推荐](https://github.com/ssrpanel/ssrpanel/wiki/VPS%E6%8E%A8%E8%8D%90)
 ![VPS推荐](https://github.com/ssrpanel/ssrpanel/wiki/VPS%E6%8E%A8%E8%8D%90)
@@ -47,9 +47,9 @@ telegram群组:https://t.me/chatssrpanel
 |Royal|¥25|
 |Royal|¥25|
 |bingo|¥8|
 |bingo|¥8|
 |Eason|¥10|
 |Eason|¥10|
-|Kris|¥40|
+|【要求匿名】|¥60|
 
 
-截止目前收到的捐赠:¥472,实际到账:¥467.28 (提款手续费4.72)
+截止目前收到的捐赠:¥492,实际到账:¥487.08 (提款手续费4.92)
 
 
 这些捐赠的用途:
 这些捐赠的用途:
 - 1.30刀买了1台VPS做开发测试用(后被干扰到几乎无法SSH)
 - 1.30刀买了1台VPS做开发测试用(后被干扰到几乎无法SSH)
@@ -153,7 +153,16 @@ wget -N --no-check-certificate https://raw.githubusercontent.com/ssrpanel/ssrpan
 ## 更新代码
 ## 更新代码
 ````
 ````
 chmod a+x update.sh && sh update.sh
 chmod a+x update.sh && sh update.sh
+
+如果每次更新都会出现数据库文件被覆盖
+请先执行一次 chmod a+x fix_git.sh && sh fix_git.sh
+````
+
+## 网卡流量监控一键脚本
 ````
 ````
+wget -N --no-check-certificate https://raw.githubusercontent.com/ssrpanel/ssrpanel/master/server/deploy_vnstat.sh;chmod +x deploy_vnstat.sh;./deploy_vnstat.sh
+````
+
 
 
 ## 说明
 ## 说明
 ````
 ````

+ 22 - 0
resources/views/admin/system.blade.php

@@ -107,6 +107,13 @@
                                                             <span class="help-block"> 启用后用户可以通过邮件重置密码 </span>
                                                             <span class="help-block"> 启用后用户可以通过邮件重置密码 </span>
                                                         </div>
                                                         </div>
                                                     </div>
                                                     </div>
+                                                    <div class="form-group">
+                                                        <label for="is_captcha" class="col-md-2 control-label">验证码</label>
+                                                        <div class="col-md-6">
+                                                            <input type="checkbox" class="make-switch" @if($is_captcha) checked @endif id="is_captcha" data-on-color="success" data-off-color="danger" data-on-text="启用" data-off-text="关闭">
+                                                            <span class="help-block"> 启用后登录、注册需要输入验证码 </span>
+                                                        </div>
+                                                    </div>
                                                 </div>
                                                 </div>
                                             </form>
                                             </form>
                                         </div>
                                         </div>
@@ -508,6 +515,21 @@
             }
             }
         });
         });
 
 
+        // 启用、禁用验证码
+        $('#is_captcha').on({
+            'switchChange.bootstrapSwitch': function(event, state) {
+                var is_captcha = state ? 1 : 0;
+
+                $.post("{{url('admin/setConfig')}}", {_token:'{{csrf_token()}}', name:'is_captcha', value:is_captcha}, function (ret) {
+                    if (ret.status == 'fail') {
+                        layer.msg(ret.message, {time:1000}, function() {
+                            window.location.reload();
+                        });
+                    }
+                });
+            }
+        });
+
         // 启用、禁用用户激活账号
         // 启用、禁用用户激活账号
         $('#is_active_register').on({
         $('#is_active_register').on({
             'switchChange.bootstrapSwitch': function(event, state) {
             'switchChange.bootstrapSwitch': function(event, state) {

+ 9 - 2
resources/views/login.blade.php

@@ -56,14 +56,21 @@
             </div>
             </div>
         @endif
         @endif
         <div class="form-group">
         <div class="form-group">
-            <!--ie8, ie9 does not support html5 placeholder, so we just show field title for that-->
             <label class="control-label visible-ie8 visible-ie9">用户名</label>
             <label class="control-label visible-ie8 visible-ie9">用户名</label>
-            <input class="form-control form-control-solid placeholder-no-fix" type="text" autocomplete="off" placeholder="用户名" name="username" value="{{Request::old('username')}}" /> </div>
+            <input class="form-control form-control-solid placeholder-no-fix" type="text" autocomplete="off" placeholder="用户名" name="username" value="{{Request::old('username')}}" />
+        </div>
         <div class="form-group">
         <div class="form-group">
             <label class="control-label visible-ie8 visible-ie9">密码</label>
             <label class="control-label visible-ie8 visible-ie9">密码</label>
             <input class="form-control form-control-solid placeholder-no-fix" type="password" autocomplete="off" placeholder="密码" name="password" value="{{Request::old('password')}}" />
             <input class="form-control form-control-solid placeholder-no-fix" type="password" autocomplete="off" placeholder="密码" name="password" value="{{Request::old('password')}}" />
             <input type="hidden" name="_token" value="{{csrf_token()}}" />
             <input type="hidden" name="_token" value="{{csrf_token()}}" />
         </div>
         </div>
+        @if($is_captcha)
+            <div class="form-group">
+                <label class="control-label visible-ie8 visible-ie9">验证码</label>
+                <input class="form-control form-control-solid placeholder-no-fix" style="width:60%;float:left;" type="text" autocomplete="off" placeholder="验证码" name="captcha" value="" />
+                <img src="{{captcha_src()}}" onclick="this.src='/captcha/default?'+Math.random()" alt="验证码" style="float:right;" />
+            </div>
+        @endif
         <div class="form-actions">
         <div class="form-actions">
             <div class="pull-left">
             <div class="pull-left">
                 <label class="rememberme mt-checkbox mt-checkbox-outline">
                 <label class="rememberme mt-checkbox mt-checkbox-outline">

+ 7 - 0
resources/views/register.blade.php

@@ -66,6 +66,13 @@
                     <input class="form-control placeholder-no-fix" type="text" autocomplete="off" placeholder="邀请码" name="code" value="{{Request::old('code')}}" required />
                     <input class="form-control placeholder-no-fix" type="text" autocomplete="off" placeholder="邀请码" name="code" value="{{Request::old('code')}}" required />
                 </div>
                 </div>
             @endif
             @endif
+            @if($is_captcha)
+            <div class="form-group padding-bottom-20">
+                <label class="control-label visible-ie8 visible-ie9">验证码</label>
+                <input class="form-control placeholder-no-fix" style="width:60%;float:left;" type="text" autocomplete="off" placeholder="验证码" name="captcha" value="" required />
+                <img src="{{captcha_src()}}" onclick="this.src='/captcha/default?'+Math.random()" alt="验证码" style="float:right;" />
+            </div>
+            @endif
             <div class="form-group margin-top-20 margin-bottom-20">
             <div class="form-group margin-top-20 margin-bottom-20">
                 <label class="mt-checkbox mt-checkbox-outline">
                 <label class="mt-checkbox mt-checkbox-outline">
                     <input type="checkbox" name="tnc" checked disabled /> 我已阅读并同意遵守
                     <input type="checkbox" name="tnc" checked disabled /> 我已阅读并同意遵守

+ 1 - 0
sql/db.sql

@@ -270,6 +270,7 @@ INSERT INTO `config` VALUES ('28', 'default_days', 7);
 INSERT INTO `config` VALUES ('29', 'subscribe_max', 3);
 INSERT INTO `config` VALUES ('29', 'subscribe_max', 3);
 INSERT INTO `config` VALUES ('30', 'min_port', 10000);
 INSERT INTO `config` VALUES ('30', 'min_port', 10000);
 INSERT INTO `config` VALUES ('31', 'max_port', 40000);
 INSERT INTO `config` VALUES ('31', 'max_port', 40000);
+INSERT INTO `config` VALUES ('32', 'is_captcha', 0);
 
 
 
 
 -- ----------------------------
 -- ----------------------------

+ 2 - 0
sql/update/20171107.sql

@@ -0,0 +1,2 @@
+-- 是否启用验证码
+INSERT INTO `config` VALUES ('32', 'is_captcha', 0);