| 
@@ -10,6 +10,7 @@ | 
 | 
@@ -10,6 +10,7 @@ | 
| 
10
 | 
 
 | 
10
 | 
 
 | 
| 
11
 | 
 use App\Http\Controllers\Controller;
 | 
11
 | 
 use App\Http\Controllers\Controller;
 | 
| 
12
 | 
 use App\Models\SyncSubmitTask\SyncSubmitTask;
 | 
12
 | 
 use App\Models\SyncSubmitTask\SyncSubmitTask;
 | 
| 
 | 
   | 
13
 | 
+use App\Models\WebSetting\WebSetting;
 | 
| 
13
 | 
 use Illuminate\Http\Exceptions\HttpResponseException;
 | 
14
 | 
 use Illuminate\Http\Exceptions\HttpResponseException;
 | 
| 
14
 | 
 use Illuminate\Http\JsonResponse;
 | 
15
 | 
 use Illuminate\Http\JsonResponse;
 | 
| 
15
 | 
 use Illuminate\Http\Request;
 | 
16
 | 
 use Illuminate\Http\Request;
 | 
 | 
@@ -27,6 +28,7 @@ class NoticeController extends Controller | 
 | 
@@ -27,6 +28,7 @@ class NoticeController extends Controller | 
| 
27
 | 
     const SUCCESS = 200;
 | 
28
 | 
     const SUCCESS = 200;
 | 
| 
28
 | 
     const ERROR = 400;
 | 
29
 | 
     const ERROR = 400;
 | 
| 
29
 | 
     const SERVERERROR = 500;
 | 
30
 | 
     const SERVERERROR = 500;
 | 
| 
 | 
   | 
31
 | 
+    const FORBBIDEN = 401;
 | 
| 
30
 | 
     const  TYPEVISIT = "visit";
 | 
32
 | 
     const  TYPEVISIT = "visit";
 | 
| 
31
 | 
     const TYPEINQUIRY = "inquiry";
 | 
33
 | 
     const TYPEINQUIRY = "inquiry";
 | 
| 
32
 | 
     const TRAFFICZERO = 0;
 | 
34
 | 
     const TRAFFICZERO = 0;
 | 
 | 
@@ -251,6 +253,72 @@ public function websiteHtml(Request $request) | 
 | 
@@ -251,6 +253,72 @@ public function websiteHtml(Request $request) | 
| 
251
 | 
     }
 | 
253
 | 
     }
 | 
| 
252
 | 
 
 | 
254
 | 
 
 | 
| 
253
 | 
     /**
 | 
255
 | 
     /**
 | 
| 
 | 
   | 
256
 | 
+     * 文案
 | 
| 
 | 
   | 
257
 | 
+     * @param Request $request
 | 
| 
 | 
   | 
258
 | 
+     */
 | 
| 
 | 
   | 
259
 | 
+    public function getRandInquiryText(Request $request){
 | 
| 
 | 
   | 
260
 | 
+        //IP限流+验证参数
 | 
| 
 | 
   | 
261
 | 
+        $this->limitIp($request);
 | 
| 
 | 
   | 
262
 | 
+
 | 
| 
 | 
   | 
263
 | 
+        try {
 | 
| 
 | 
   | 
264
 | 
+            $requestUrl = "https://fob.ai.cc/api/get_inquiry_text";
 | 
| 
 | 
   | 
265
 | 
+            $resStr = $this->httpGet($requestUrl);
 | 
| 
 | 
   | 
266
 | 
+        } catch (\Exception $e) {
 | 
| 
 | 
   | 
267
 | 
+            $resStr = $e->getMessage();
 | 
| 
 | 
   | 
268
 | 
+        }
 | 
| 
 | 
   | 
269
 | 
+        $this->response("ok",self::SUCCESS,$resStr);
 | 
| 
 | 
   | 
270
 | 
+        return;
 | 
| 
 | 
   | 
271
 | 
+    }
 | 
| 
 | 
   | 
272
 | 
+
 | 
| 
 | 
   | 
273
 | 
+    /**
 | 
| 
 | 
   | 
274
 | 
+     * @param $url
 | 
| 
 | 
   | 
275
 | 
+     * @return bool|string
 | 
| 
 | 
   | 
276
 | 
+     */
 | 
| 
 | 
   | 
277
 | 
+    public function httpGet($url){
 | 
| 
 | 
   | 
278
 | 
+        $ch1     = curl_init();
 | 
| 
 | 
   | 
279
 | 
+        $timeout = 0;
 | 
| 
 | 
   | 
280
 | 
+        curl_setopt($ch1, CURLOPT_URL, $url);
 | 
| 
 | 
   | 
281
 | 
+        curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
 | 
| 
 | 
   | 
282
 | 
+        curl_setopt($ch1, CURLOPT_ENCODING, '');
 | 
| 
 | 
   | 
283
 | 
+        curl_setopt($ch1, CURLOPT_MAXREDIRS, 10);
 | 
| 
 | 
   | 
284
 | 
+        curl_setopt($ch1, CURLOPT_HTTPHEADER, array());
 | 
| 
 | 
   | 
285
 | 
+        curl_setopt($ch1, CURLOPT_CONNECTTIMEOUT, $timeout);
 | 
| 
 | 
   | 
286
 | 
+        curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, FALSE);
 | 
| 
 | 
   | 
287
 | 
+        curl_setopt($ch1, CURLOPT_SSL_VERIFYHOST, FALSE);
 | 
| 
 | 
   | 
288
 | 
+        curl_setopt($ch1, CURLOPT_FOLLOWLOCATION, true);
 | 
| 
 | 
   | 
289
 | 
+        curl_setopt($ch1, CURLOPT_CUSTOMREQUEST, 'GET');
 | 
| 
 | 
   | 
290
 | 
+        curl_setopt($ch1, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
 | 
| 
 | 
   | 
291
 | 
+        $access_txt = curl_exec($ch1);
 | 
| 
 | 
   | 
292
 | 
+        curl_close($ch1);
 | 
| 
 | 
   | 
293
 | 
+        return $access_txt;
 | 
| 
 | 
   | 
294
 | 
+    }
 | 
| 
 | 
   | 
295
 | 
+
 | 
| 
 | 
   | 
296
 | 
+    /**
 | 
| 
 | 
   | 
297
 | 
+     * IP限流
 | 
| 
 | 
   | 
298
 | 
+     * @param $request
 | 
| 
 | 
   | 
299
 | 
+     */
 | 
| 
 | 
   | 
300
 | 
+    public function limitIp($request)
 | 
| 
 | 
   | 
301
 | 
+    {
 | 
| 
 | 
   | 
302
 | 
+        //同一ip 2秒内超过6次 限制1分钟
 | 
| 
 | 
   | 
303
 | 
+        $ip = $request->ip();
 | 
| 
 | 
   | 
304
 | 
+        $ip_limit_key = 'ip_limit_' . $ip;
 | 
| 
 | 
   | 
305
 | 
+        $num_limit_key = 'num_limit_' . $ip;
 | 
| 
 | 
   | 
306
 | 
+        if (Cache::has($ip_limit_key)) {
 | 
| 
 | 
   | 
307
 | 
+            $this->response("error", self::FORBBIDEN, "请求频繁,请稍后再试");
 | 
| 
 | 
   | 
308
 | 
+        }
 | 
| 
 | 
   | 
309
 | 
+        if (Cache::has($num_limit_key)) {
 | 
| 
 | 
   | 
310
 | 
+            $count = Cache::get($num_limit_key);
 | 
| 
 | 
   | 
311
 | 
+            if ($count >= 6) {
 | 
| 
 | 
   | 
312
 | 
+                Cache::put($ip_limit_key, 1, 60);
 | 
| 
 | 
   | 
313
 | 
+                $this->response("error", self::FORBBIDEN, "请求频繁,请稍后再试");
 | 
| 
 | 
   | 
314
 | 
+            }
 | 
| 
 | 
   | 
315
 | 
+            Cache::increment($num_limit_key);
 | 
| 
 | 
   | 
316
 | 
+        } else {
 | 
| 
 | 
   | 
317
 | 
+            Cache::put($num_limit_key, 1, 2);
 | 
| 
 | 
   | 
318
 | 
+        }
 | 
| 
 | 
   | 
319
 | 
+    }
 | 
| 
 | 
   | 
320
 | 
+
 | 
| 
 | 
   | 
321
 | 
+    /**
 | 
| 
254
 | 
      * 网站html解压
 | 
322
 | 
      * 网站html解压
 | 
| 
255
 | 
      * @param $zip_count
 | 
323
 | 
      * @param $zip_count
 | 
| 
256
 | 
      * @param $domain
 | 
324
 | 
      * @param $domain
 |