mirror of
https://gitee.com/ledc/IYUUAutoReseed
synced 2025-05-23 18:15:22 +00:00
后端API迁移至新架构,升级版本号到1.0.0
This commit is contained in:
parent
ea158ddd55
commit
2ce1920c51
@ -21,7 +21,7 @@ class AutoReseed
|
|||||||
* 版本号
|
* 版本号
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
const VER = '0.2.0';
|
const VER = '1.0.0';
|
||||||
/**
|
/**
|
||||||
* RPC连接池
|
* RPC连接池
|
||||||
* @var array
|
* @var array
|
||||||
@ -59,13 +59,15 @@ class AutoReseed
|
|||||||
* @var string
|
* @var string
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public static $apiUrl = 'http://pt.iyuu.cn';
|
public static $apiUrl = 'http://api.iyuu.cn';
|
||||||
public static $endpoints = array(
|
public static $endpoints = array(
|
||||||
'add' => '/api/add',
|
'add' => '/api/add',
|
||||||
'update' => '/api/update',
|
'update' => '/api/update',
|
||||||
'reseed' => '/api/reseed',
|
'reseed' => '/api/reseed',
|
||||||
'move' => '/api/move',
|
'infohash'=> '/api/infohash',
|
||||||
'login' => '/login',
|
'sites' => '/api/sites',
|
||||||
|
'move' => '/api/move',
|
||||||
|
'login' => '/user/login',
|
||||||
);
|
);
|
||||||
/**
|
/**
|
||||||
* curl
|
* curl
|
||||||
@ -137,8 +139,9 @@ class AutoReseed
|
|||||||
$curl = new Curl();
|
$curl = new Curl();
|
||||||
$curl->setOpt(CURLOPT_SSL_VERIFYPEER, false); // 禁止验证证书
|
$curl->setOpt(CURLOPT_SSL_VERIFYPEER, false); // 禁止验证证书
|
||||||
$curl->setOpt(CURLOPT_SSL_VERIFYHOST, false); // 不检查证书
|
$curl->setOpt(CURLOPT_SSL_VERIFYHOST, false); // 不检查证书
|
||||||
$res = $curl->post(self::$apiUrl);
|
$res = $curl->get(self::$apiUrl.self::$endpoints['sites'].'?sign='.Oauth::getSign());
|
||||||
$sites = json_decode($res->response, true);
|
$rs = json_decode($res->response, true);
|
||||||
|
$sites = isset($rs['data']['sites']) && $rs['data']['sites'] ? $rs['data']['sites'] : false;
|
||||||
// 数据写入本地
|
// 数据写入本地
|
||||||
if ($sites) {
|
if ($sites) {
|
||||||
$json = array_column($sites, null, 'site');
|
$json = array_column($sites, null, 'site');
|
||||||
@ -149,6 +152,9 @@ class AutoReseed
|
|||||||
$worldsnum = @fwrite($file_pointer, $json);
|
$worldsnum = @fwrite($file_pointer, $json);
|
||||||
@fclose($file_pointer);
|
@fclose($file_pointer);
|
||||||
} else {
|
} else {
|
||||||
|
if (isset($rs['msg']) && $rs['msg']) {
|
||||||
|
die($rs['msg']);
|
||||||
|
}
|
||||||
die('远端服务器无响应,请稍后再试!!!');
|
die('远端服务器无响应,请稍后再试!!!');
|
||||||
}
|
}
|
||||||
$data = [];
|
$data = [];
|
||||||
@ -399,8 +405,8 @@ class AutoReseed
|
|||||||
{
|
{
|
||||||
$resArray = array();
|
$resArray = array();
|
||||||
// 签名
|
// 签名
|
||||||
$hashArray['timestamp'] = time();
|
|
||||||
$hashArray['sign'] = Oauth::getSign();
|
$hashArray['sign'] = Oauth::getSign();
|
||||||
|
$hashArray['timestamp'] = time();
|
||||||
$hashArray['version'] = self::VER;
|
$hashArray['version'] = self::VER;
|
||||||
// 写请求日志
|
// 写请求日志
|
||||||
wlog($hashArray, 'hashString');
|
wlog($hashArray, 'hashString');
|
||||||
@ -429,14 +435,15 @@ class AutoReseed
|
|||||||
// 发起请求
|
// 发起请求
|
||||||
echo "正在提交辅种信息……".PHP_EOL;
|
echo "正在提交辅种信息……".PHP_EOL;
|
||||||
$res = self::$curl->post(self::$apiUrl . self::$endpoints['reseed'], $hashArray);
|
$res = self::$curl->post(self::$apiUrl . self::$endpoints['reseed'], $hashArray);
|
||||||
$resArray = json_decode($res->response, true);
|
$res = json_decode($res->response, true);
|
||||||
|
$resArray = isset($res['data']) && $res['data'] ? $res['data'] : array();
|
||||||
// 写返回日志
|
// 写返回日志
|
||||||
wlog($resArray, 'reseed');
|
wlog($res, 'reseed');
|
||||||
// 判断返回值
|
// 判断返回值
|
||||||
if (isset($resArray['errmsg']) && ($resArray['errmsg'] == 'ok')) {
|
if (isset($resArray['errmsg']) && ($resArray['errmsg'] == 'ok')) {
|
||||||
echo "辅种信息提交成功!!!".PHP_EOL.PHP_EOL;
|
echo "辅种信息提交成功!!!".PHP_EOL.PHP_EOL;
|
||||||
} else {
|
} else {
|
||||||
$errmsg = isset($resArray['errmsg']) ? $resArray['errmsg'] : '远端服务器无响应,请稍后重试!';
|
$errmsg = isset($res['msg']) && $res['msg'] ? $res['msg'] : '远端服务器无响应,请稍后重试!';
|
||||||
echo '-----辅种失败,原因:' .$errmsg.PHP_EOL.PHP_EOL;
|
echo '-----辅种失败,原因:' .$errmsg.PHP_EOL.PHP_EOL;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -640,14 +647,15 @@ class AutoReseed
|
|||||||
// 发起请求
|
// 发起请求
|
||||||
echo "正在提交转移信息……".PHP_EOL;
|
echo "正在提交转移信息……".PHP_EOL;
|
||||||
$res = self::$curl->post(self::$apiUrl . self::$endpoints['move'], $hashArray);
|
$res = self::$curl->post(self::$apiUrl . self::$endpoints['move'], $hashArray);
|
||||||
$resArray = json_decode($res->response, true);
|
$res = json_decode($res->response, true);
|
||||||
|
$resArray = isset($res['data']) && $res['data'] ? $res['data'] : array();
|
||||||
// 写日志
|
// 写日志
|
||||||
wlog($resArray, 'move');
|
wlog($res, 'move');
|
||||||
// 判断返回值
|
// 判断返回值
|
||||||
if (isset($resArray['errmsg']) && ($resArray['errmsg'] == 'ok')) {
|
if (isset($resArray['errmsg']) && ($resArray['errmsg'] == 'ok')) {
|
||||||
echo "转移数据返回:成功!!!".PHP_EOL.PHP_EOL;
|
echo "转移数据返回:成功!!!".PHP_EOL.PHP_EOL;
|
||||||
} else {
|
} else {
|
||||||
$errmsg = isset($resArray['errmsg']) ? $resArray['errmsg'] : '远端服务器无响应,请稍后重试!';
|
$errmsg = isset($res['msg']) && $res['msg'] ? $res['msg'] : '远端服务器无响应,请稍后重试!';
|
||||||
echo '-----转移请求失败,原因:' .$errmsg.PHP_EOL.PHP_EOL;
|
echo '-----转移请求失败,原因:' .$errmsg.PHP_EOL.PHP_EOL;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
3
init.php
3
init.php
@ -1,7 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
//----------------------------------
|
|
||||||
// 公共入口文件
|
|
||||||
//----------------------------------
|
|
||||||
// 定义目录
|
// 定义目录
|
||||||
defined('ROOT_PATH') or define("ROOT_PATH", __DIR__);
|
defined('ROOT_PATH') or define("ROOT_PATH", __DIR__);
|
||||||
define('DS', DIRECTORY_SEPARATOR);
|
define('DS', DIRECTORY_SEPARATOR);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user