From cd8612d6f02c31c3b9569e21e392dad8857a39f7 Mon Sep 17 00:00:00 2001 From: "iyuu.cn" <367013672@qq.com> Date: Mon, 23 Dec 2019 13:51:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8A=9F=E8=83=BD=EF=BC=9A?= =?UTF-8?q?=E4=B8=8A=E6=AC=A1=E8=BE=85=E7=A7=8D=E6=88=90=E5=8A=9F=E7=9A=84?= =?UTF-8?q?=EF=BC=8C=E6=9C=AC=E6=AC=A1=E6=99=BA=E8=83=BD=E8=B7=B3=E8=BF=87?= =?UTF-8?q?=EF=BC=9B=20=E5=A2=9E=E5=8A=A0=E5=90=88=E4=BD=9C=E7=AB=99?= =?UTF-8?q?=E7=82=B9=E9=AA=8C=E8=AF=81=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- iyuu.cn.php | 44 +++++++++++++++++++++++++++++++++++--------- readme.md | 5 +++++ 2 files changed, 40 insertions(+), 9 deletions(-) diff --git a/iyuu.cn.php b/iyuu.cn.php index f0675eb..aa1d06c 100644 --- a/iyuu.cn.php +++ b/iyuu.cn.php @@ -20,7 +20,7 @@ class iyuuAutoReseed * 版本号 * @var string */ - const VER = '2019年12月21日20:26:48'; + const VER = '0.1.0'; // RPC连接池 public static $links = array(); /** @@ -35,6 +35,7 @@ class iyuuAutoReseed * 缓存路径 */ public static $cacheDir = TORRENT_PATH.'cache'.DS; + public static $cacheHash = TORRENT_PATH.'cachehash'.DS; /** * API接口配置 */ @@ -43,6 +44,7 @@ class iyuuAutoReseed 'add' => '/api/add', 'update' => '/api/update', 'reseed' => '/api/reseed', + 'login' => '/login', ); /** * 退出状态码 @@ -59,11 +61,16 @@ class iyuuAutoReseed global $configALL; self::$clients = isset($configALL['default']['clients']) && $configALL['default']['clients'] ? $configALL['default']['clients'] : array(); + echo "程序正在初始化运行参数... \n"; // 递归删除上次历史记录 IFile::rmdir(self::$cacheDir, true); // 建立目录 IFile::mkdir(self::$cacheDir); + IFile::mkdir(self::$cacheHash); self::links(); + // 合作站点自动注册鉴权 + Oauth::login(self::$apiUrl . self::$endpoints['login']); + #exit; } /** * 连接远端RPC服务器 @@ -195,11 +202,6 @@ class iyuuAutoReseed exit(1); } } - // 写日志:文件句柄 - $resource = fopen(self::$cacheDir.'hashString.txt', "wb"); - // 成功:返回写入字节数,失败返回false - $worldsnum = fwrite($resource, p($hashArray, false)); - fclose($resource); return $hashArray; } /** @@ -262,13 +264,22 @@ class iyuuAutoReseed public static function call($hashArray = array()) { global $configALL; - $resArray = $sites = array(); $curl = new Curl(); $curl->setOpt(CURLOPT_SSL_VERIFYPEER, false); // 签名 $hashArray['timestamp'] = time(); - $hashArray['sign'] = sign($hashArray['timestamp']); + // 爱语飞飞token + $hashArray['sign'] = Oauth::getSign(); + $hashArray['version'] = self::VER; + // 写日志 + if (true) { + // 文件句柄 + $resource = fopen(self::$cacheDir.'hashString.txt', "wb"); + // 成功:返回写入字节数,失败返回false + $worldsnum = fwrite($resource, p($hashArray, false)); + fclose($resource); + } // 发起请求 echo "正在提交辅种信息…… \n"; $res = $curl->post(self::$apiUrl . self::$endpoints['reseed'], $hashArray); @@ -337,8 +348,23 @@ class iyuuAutoReseed // 与客户端现有种子重复 echo '-------与客户端现有种子重复:'.$_url."\n\n"; }else{ + // 判断上次是否成功添加? + if ( is_file(self::$cacheHash . $value['info_hash'].'.txt') ) { + echo '-------当前种子上次辅种已成功添加,已跳过!'.$_url."\n\n"; + continue; + } + // 把拼接的种子URL,推送给下载器 - self::add($k, $url, $downloadDir); + $ret = false; + $ret = self::add($k, $url, $downloadDir); + // 写日志 + if ($ret) { + // 文件句柄 + $resource = fopen(self::$cacheHash . $value['info_hash'].'.txt', "wb"); + // 成功:返回写入字节数,失败返回false + $worldsnum = fwrite($resource, $url); + fclose($resource); + } } }else{ // 不辅种 diff --git a/readme.md b/readme.md index 8614371..80d1767 100644 --- a/readme.md +++ b/readme.md @@ -20,6 +20,9 @@ IYUU自动辅种工具(英文名:iyuuAutoReseed),是一款PHP语言编 所有具备PHP运行环境的所有平台! 例如:Linux、Windows、MacOS +## 下载源码 + - 码云仓库:https://gitee.com/ledc/IYUUAutoReseed + ## 使用方法 详见Wiki @@ -29,6 +32,8 @@ IYUU自动辅种工具(英文名:iyuuAutoReseed),是一款PHP语言编 ## 捐助开发者 如果觉得我的付出,节约了您的宝贵时间,请随意打赏一杯咖啡!或者一杯水! 您所有的打赏将用于服务器续期,增加服务的延续性。 + + ![微信打赏.png][2]