陈德本 hace 5 años
padre
commit
e7c55fdfce

+ 47 - 0
App/Api/Controller/Api.php

@@ -0,0 +1,47 @@
+<?php
+
+
+namespace Heanup\App\Api\Controller;
+
+
+use Heanup\App\Api\Config\Code;
+use Heanup\App\Api\Controller;
+use Heanup\App\Api\Package\Database\Num;
+use Heanup\Library\Sms\SmsFree;
+
+class Api extends Controller
+{
+    protected function main()
+    {
+        $do = $this->getRequest()->string("do", "Country");
+        $lib = new SmsFree();
+
+        if ($do == "Country") {
+            $data = $lib->getCountry();
+            $data = array_map(function ($a) {
+                $a['flag'] = "http://sms.x.97admin.com/flag/" . $a['flag'] . ".png";
+                return $a;
+            }, $data);
+            $this->showSuccess($data);
+        }
+
+        if ($do = "List") {
+            $country = $this->getQuery()->string("Country");
+            if ($country) {
+                $where = ['country' => $country];
+            } else {
+                $where = [];
+            }
+            $page = $this->getQuery()->intval("page", 1);
+            $pgSize = 20;
+            $data = Num::getPageList($where, "", $page, $pgSize, ['id' => true]);
+            $data = array_map(function ($a) {
+                $a['flag'] = "http://sms.x.97admin.com" . Code::getData($a['country'])['flag'];
+                return $a;
+            }, $data['data']);
+            $this->showSuccess($data);
+        }
+
+    }
+
+}

+ 76 - 0
App/Api/Controller/Novel/Api.php

@@ -0,0 +1,76 @@
+<?php
+
+
+namespace Heanup\App\Api\Controller\Novel;
+
+
+use Heanup\App\Api\Controller;
+use Heanup\Library\Book;
+
+class Api extends Controller
+{
+    protected function main()
+    {
+        $do = $this->getRequest()->string("do", "index");
+        $keyword = $this->getRequest()->string("keyword");
+        $book_id = $this->getRequest()->intval("book_id");
+        $chapter_id = $this->getRequest()->intval("chapter_id");
+        $page = $this->getRequest()->intval("page", 1);
+        $result = "[]";
+        if ($do == "index") {
+            $result = Book::getInstance()->getIndexData();
+            $result = json_decode($result, true);
+            $result = $result['data'];
+        }
+        if ($do == "search") {
+            $result = Book::getInstance()->search($keyword);
+            $result = json_decode($result, true);
+            $response = [];
+            foreach ($result['data'] as $item) {
+                $response[] = [
+                    'id' => $item['Id'],
+                    'img' => $item['Img'],//Book::getInstance()->getImageUrl($item['Img']),
+                    'name' => $item['Name'],
+                    'author' => $item['Author'],
+                    'introduce' => $item['Desc']
+                ];
+            }
+            $result = $response;
+        }
+        if ($do == "detail") {
+            $result = Book::getInstance()->getBookDetail($book_id);
+            $result = json_decode(trim($result), true);
+            $result = $result['data'];
+            $response=[];
+            $response['id']=$result['Id'];
+            $response['name']=$result['Name'];
+            $response['author']=$result['Author'];
+            $response['sort']=$result['CName'];
+            $response['state']=$result['BookStatus'];
+            $response['time']=$result['LastTime'];
+            $response['img']=Book::getInstance()->getImageUrl($result['Img']);
+            $response['intro']=$result['Desc'];
+            $response['news']=$result['LastChapter'];
+            $chapter=Book::getInstance()->getChapter($book_id);
+            $chapter=\GuzzleHttp\json_decode($chapter,true);
+            $_chapter=[];
+            foreach ($chapter['data']['list'] as $item) {
+                foreach ($item['list'] as $val) {
+                    $_chapter[]=$val;
+                }
+            }
+            $response=[
+                'data'=>$response,
+                'list'=>$_chapter
+            ];
+            $result = $response;
+        }
+        if ($do == "content") {
+            $result = Book::getInstance()->getContent($book_id, $chapter_id);
+            $result = json_decode($result, true);
+            $result = nl2br($result['data']['content']);
+        }
+
+        $this->showSuccess($result);
+    }
+}

+ 18 - 0
App/Api/Controller/Novel/IndexData.php

@@ -0,0 +1,18 @@
+<?php
+
+
+namespace Heanup\App\Api\Controller\Novel;
+
+
+use Heanup\App\Api\Controller;
+use Heanup\Library\Book;
+
+class IndexData extends Controller
+{
+    protected function main()
+    {
+        $book=new Book();
+        $data=Book::getInstance()->getBookDetail(478);
+
+    }
+}

+ 22 - 0
App/Api/Controller/Novel/Search.php

@@ -0,0 +1,22 @@
+<?php
+namespace Heanup\App\Api\Controller\Novel;
+
+
+use Heanup\App\Api\Controller;
+use Heanup\Library\Book;
+use Heanup\Library\Curl;
+
+class Search extends Controller
+{
+    //商城小说:
+    //https://scxs.pigqq.com/BookFiles/Html/1/478/info.html
+    //https://scxs.pigqq.com/prov8/base/man2.html
+    //
+    protected function main()
+    {
+        $keyword=$this->getRequest()->string("keyword");
+        echo Book::getInstance()->search($keyword);
+
+    }
+
+}

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 13 - 2
App/Api/Template/Index.phtml


+ 11 - 10
App/Script/Controller/Server.php

@@ -10,8 +10,9 @@ namespace Heanup\App\Script\Controller;
 
 
 use Heanup\App\Script\Controller;
-use Heanup\Library\Curl;
-use Heanup\Library\Proxy;
+use Heanup\Library\Sms\ReceiveSmsCc;
+use Heanup\Library\Sms\ReceiveSmsFree;
+use Heanup\Library\Sms\SmsFree;
 
 class Server extends Controller
 {
@@ -22,14 +23,14 @@ class Server extends Controller
     protected function main()
     {
 
-
-        $url="http://www.97admin.com/message/589?debug=1";
-        $i=1;
-        while (true){
-            $proxy= Proxy::instance()->connect()->zRangeByScore("proxies:universal", 24, 25);
-            foreach ($proxy as $item) {
-                echo "正在请求".$url."第".($i++)."次".PHP_EOL;
-                Curl::get($url,$item);
+        $tasks=[
+            new  ReceiveSmsFree(),
+            new  ReceiveSmsCc()
+        ];
+        foreach ($tasks as $task) {
+            $countries = $task->getCountry();
+            foreach ($countries as $country) {
+                $task->getPhoneNums($country['link']);
             }
         }
     }

+ 4 - 0
Frame/Dispatcher.php

@@ -60,6 +60,10 @@ class Dispatcher
      */
     public static function dispatch($customPrefix, $pathInfo = '')
     {
+        header("HTTP/1.1 200");
+        header("Access-Control-Allow-Origin: *");
+        header("Access-Control-Allow-Methods: GET, POST, PUT, PATCH, DELETE");
+        header("Access-Control-Allow-Headers: *");
         // 获取前缀
         $prefix = '\Heanup\\App\\' . self::convertToClassName($customPrefix) . "\\Controller";
         if (!$pathInfo) {

+ 109 - 0
Library/Book.php

@@ -0,0 +1,109 @@
+<?php
+
+
+namespace Heanup\Library;
+
+
+class Book
+{
+    private static $instance;
+    private $domain = [
+        'index' => "https://scxs.pigqq.com/prov8/base/man2.html",
+        'search' => 'https://souxs.pigqq.com/search.aspx?key=%s&page=%d&siteid=%s',
+        'image' => 'https://imgapixs.pigqq.com/BookFiles/BookImages/%s',
+        'detail' => 'https://infosxs.pigqq.com/BookFiles/Html/%d/%d/info.html',
+        'chapter' => 'https://infosxs.pigqq.com/BookFiles/Html/%d/%d/index.html',
+        'content_info' => 'https://contentxs.pigqq.com/BookFiles/Html/%d/%d/%d.html',
+    ];
+
+
+    /**
+     * 搜索小说
+     * @return false|string
+     */
+    public function getIndexData()
+    {
+        $url = $this->domain['index'];
+        return Curl::get($url);
+    }
+    /**
+     * 搜索小说
+     * @param $keyword
+     * @param int $page
+     * @return false|string
+     */
+    public function search($keyword, $page = 1)
+    {
+        $siteid = "app2";
+        $url = sprintf($this->domain['search'], urlencode($keyword), $page, $siteid);
+        return Curl::get($url);
+    }
+
+
+    /**
+     * 获取小说详情
+     * @param $book_id
+     * @return false|string
+     */
+    public function getBookDetail($book_id)
+    {
+        $pre = (int)ceil($book_id / 1000);
+        $url = sprintf($this->domain['detail'], $pre, $book_id);
+        return Curl::get($url);
+    }
+
+    /**
+     * 获取章节内容
+     * @param $book_id
+     * @return false|string
+     */
+    public function getChapter($book_id)
+    {
+        $pre = (int)ceil($book_id / 1000);
+        $url = sprintf($this->domain['chapter'], $pre, $book_id);
+        $result=Curl::get($url);
+        $result=str_replace("},]", "}]", $result);
+        return $result;
+    }
+
+    /**
+     * 获取章节内容
+     * @param $book_id
+     * @param $chapter_id
+     * @return false|string
+     */
+    public function getContent($book_id,$chapter_id){
+        $pre = (int)ceil($book_id / 1000);
+        $url = sprintf($this->domain['content_info'], $pre, $book_id,$chapter_id);
+        return Curl::get($url);
+    }
+
+    /**
+     * 获取完整图片URL
+     * @param $img
+     * @return string
+     */
+    public function getImageUrl($img)
+    {
+        return $url = sprintf($this->domain['image'], $img);
+    }
+
+
+    public function __construct()
+    {
+        Curl::get("https://scxs.pigqq.com/prov8/base/initconf.html");//初始化接口配置
+    }
+
+    public static function getInstance(): Book
+    {
+        if (!isset(self::$instance)) {
+            $instance = new self();
+            self::$instance = $instance;
+        } else {
+            $instance = self::$instance;
+        }
+        return $instance;
+    }
+
+
+}

+ 1 - 1
Library/Curl.php

@@ -79,7 +79,7 @@ class Curl
 //        $this->http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
         curl_close($curl);
 
-        return $content;
+        return removeBOM($content);
     }
 
     /**

+ 2 - 2
Library/Sms/SmsFree.php

@@ -40,7 +40,7 @@ class SmsFree implements Sms
             'country' => $link,
             'do' => "List"
         ];
-        $result = Curl::post($url, $data, "host.docker.internal:7777");
+        $result = Curl::post($url, $data);
         $result = json_decode($result, true);
         $response = $result['Phone'];
         $this->insert($link, $result['Phone']);
@@ -48,7 +48,7 @@ class SmsFree implements Sms
         for ($i = 2; $i <= $total; $i++) {
             $temp = $data;
             $temp['page'] = $i;
-            $result = Curl::post($url, $temp, "host.docker.internal:7777");
+            $result = Curl::post($url, $temp);
             $result = json_decode($result, true);
             if ($result) {
                 $this->insert($link, $result['Phone']);

+ 6 - 0
functions.php

@@ -64,4 +64,10 @@ function microtime_float()
 {
     list($usec, $sec) = explode(" ", microtime());
     return ((float)$usec + (float)$sec);
+}
+function removeBOM($data) {
+    if (0 === strpos(bin2hex($data), 'efbbbf')) {
+        return substr($data, 3);
+    }
+    return $data;
 }

Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio