mirror of
https://gitee.com/ledc/IYUUAutoReseed
synced 2025-06-13 04:08:57 +00:00
新增在线查询支持站点表格显示
This commit is contained in:
@ -10,6 +10,7 @@ use IYUU\Client\qBittorrent\qBittorrent;
|
|||||||
use IYUU\Client\Transmission\TransmissionRPC;
|
use IYUU\Client\Transmission\TransmissionRPC;
|
||||||
use IYUU\Library\IFile;
|
use IYUU\Library\IFile;
|
||||||
use IYUU\Library\Oauth;
|
use IYUU\Library\Oauth;
|
||||||
|
use IYUU\Library\Table;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IYUUAutoReseed自动辅种类
|
* IYUUAutoReseed自动辅种类
|
||||||
@ -89,6 +90,7 @@ class AutoReseed
|
|||||||
*/
|
*/
|
||||||
public static function init()
|
public static function init()
|
||||||
{
|
{
|
||||||
|
self::ShowTableSites();
|
||||||
global $configALL;
|
global $configALL;
|
||||||
self::$clients = isset($configALL['default']['clients']) && $configALL['default']['clients'] ? $configALL['default']['clients'] : array();
|
self::$clients = isset($configALL['default']['clients']) && $configALL['default']['clients'] ? $configALL['default']['clients'] : array();
|
||||||
echo "程序正在初始化运行参数... \n";
|
echo "程序正在初始化运行参数... \n";
|
||||||
@ -103,6 +105,43 @@ class AutoReseed
|
|||||||
Oauth::login(self::$apiUrl . self::$endpoints['login']);
|
Oauth::login(self::$apiUrl . self::$endpoints['login']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 显示支持站点列表
|
||||||
|
*/
|
||||||
|
private static function ShowTableSites(){
|
||||||
|
$list[] = 'gitee 源码仓库:https://gitee.com/ledc/IYUUAutoReseed';
|
||||||
|
$list[] = 'github源码仓库:https://github.com/ledccn/IYUUAutoReseed';
|
||||||
|
$list[] = '教程:https://gitee.com/ledc/IYUUAutoReseed/tree/master/wiki';
|
||||||
|
$list[] = "QQ群:859882209 【IYUU自动辅种交流】 \n";
|
||||||
|
foreach ($list as $key => $value) {
|
||||||
|
echo $value.PHP_EOL;
|
||||||
|
}
|
||||||
|
// 发起请求
|
||||||
|
echo "正在连接IYUUAutoReseed服务器,查询支持列表…… \n";
|
||||||
|
$curl = new Curl();
|
||||||
|
$curl->setOpt(CURLOPT_SSL_VERIFYPEER, false); // 禁止验证证书
|
||||||
|
$curl->setOpt(CURLOPT_SSL_VERIFYHOST, false); // 不检查证书
|
||||||
|
$res = $curl->post(self::$apiUrl);
|
||||||
|
$sites = json_decode($res->response, true);
|
||||||
|
$data = [];
|
||||||
|
$i = $j = $k = 0;
|
||||||
|
foreach($sites as $v)
|
||||||
|
{
|
||||||
|
// 控制多少列
|
||||||
|
if ($i > 4) {
|
||||||
|
$k++;
|
||||||
|
$i = 0;
|
||||||
|
}
|
||||||
|
$i++;
|
||||||
|
$j++;
|
||||||
|
$data[$k][] = $j.". ".$v['site'];
|
||||||
|
}
|
||||||
|
echo "IYUUAutoReseed自动辅种脚本,目前支持以下站点:".PHP_EOL;
|
||||||
|
//输出表格
|
||||||
|
$table = new Table();
|
||||||
|
$table->setRows($data);
|
||||||
|
echo($table->render());
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 连接远端RPC服务器
|
* 连接远端RPC服务器
|
||||||
*
|
*
|
||||||
|
300
app/Library/Table.php
Normal file
300
app/Library/Table.php
Normal file
@ -0,0 +1,300 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Created by PhpStorm.
|
||||||
|
* User: 大卫
|
||||||
|
* Date: 2020-1-19
|
||||||
|
* Time: 17:44
|
||||||
|
*/
|
||||||
|
namespace IYUU\Library;
|
||||||
|
|
||||||
|
class Table
|
||||||
|
{
|
||||||
|
const ALIGN_LEFT = 1;
|
||||||
|
const ALIGN_RIGHT = 0;
|
||||||
|
const ALIGN_CENTER = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 头信息数据
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $header = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 头部对齐方式 默认1 ALGIN_LEFT 0 ALIGN_RIGHT 2 ALIGN_CENTER
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
protected $headerAlign = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表格数据(二维数组)
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $rows = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单元格对齐方式 默认1 ALGIN_LEFT 0 ALIGN_RIGHT 2 ALIGN_CENTER
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
protected $cellAlign = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单元格宽度信息
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $colWidth = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表格输出样式
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $style = 'default';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表格样式定义
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $format = [
|
||||||
|
'compact' => [],
|
||||||
|
'default' => [
|
||||||
|
'top' => ['+', '-', '+', '+'],
|
||||||
|
'cell' => ['|', ' ', '|', '|'],
|
||||||
|
'middle' => ['+', '-', '+', '+'],
|
||||||
|
'bottom' => ['+', '-', '+', '+'],
|
||||||
|
'cross-top' => ['+', '-', '-', '+'],
|
||||||
|
'cross-bottom' => ['+', '-', '-', '+'],
|
||||||
|
],
|
||||||
|
'markdown' => [
|
||||||
|
'top' => [' ', ' ', ' ', ' '],
|
||||||
|
'cell' => ['|', ' ', '|', '|'],
|
||||||
|
'middle' => ['|', '-', '|', '|'],
|
||||||
|
'bottom' => [' ', ' ', ' ', ' '],
|
||||||
|
'cross-top' => ['|', ' ', ' ', '|'],
|
||||||
|
'cross-bottom' => ['|', ' ', ' ', '|'],
|
||||||
|
],
|
||||||
|
'borderless' => [
|
||||||
|
'top' => ['=', '=', ' ', '='],
|
||||||
|
'cell' => [' ', ' ', ' ', ' '],
|
||||||
|
'middle' => ['=', '=', ' ', '='],
|
||||||
|
'bottom' => ['=', '=', ' ', '='],
|
||||||
|
'cross-top' => ['=', '=', ' ', '='],
|
||||||
|
'cross-bottom' => ['=', '=', ' ', '='],
|
||||||
|
],
|
||||||
|
'box' => [
|
||||||
|
'top' => ['┌', '─', '┬', '┐'],
|
||||||
|
'cell' => ['│', ' ', '│', '│'],
|
||||||
|
'middle' => ['├', '─', '┼', '┤'],
|
||||||
|
'bottom' => ['└', '─', '┴', '┘'],
|
||||||
|
'cross-top' => ['├', '─', '┴', '┤'],
|
||||||
|
'cross-bottom' => ['├', '─', '┬', '┤'],
|
||||||
|
],
|
||||||
|
'box-double' => [
|
||||||
|
'top' => ['╔', '═', '╤', '╗'],
|
||||||
|
'cell' => ['║', ' ', '│', '║'],
|
||||||
|
'middle' => ['╠', '─', '╪', '╣'],
|
||||||
|
'bottom' => ['╚', '═', '╧', '╝'],
|
||||||
|
'cross-top' => ['╠', '═', '╧', '╣'],
|
||||||
|
'cross-bottom' => ['╠', '═', '╤', '╣'],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置表格头信息 以及对齐方式
|
||||||
|
* @access public
|
||||||
|
* @param array $header 要输出的Header信息
|
||||||
|
* @param int $align 对齐方式 默认1 ALGIN_LEFT 0 ALIGN_RIGHT 2 ALIGN_CENTER
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setHeader($header, $align = self::ALIGN_LEFT)
|
||||||
|
{
|
||||||
|
$this->header = $header;
|
||||||
|
$this->headerAlign = $align;
|
||||||
|
|
||||||
|
$this->checkColWidth($header);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置输出表格数据 及对齐方式
|
||||||
|
* @access public
|
||||||
|
* @param array $rows 要输出的表格数据(二维数组)
|
||||||
|
* @param int $align 对齐方式 默认1 ALGIN_LEFT 0 ALIGN_RIGHT 2 ALIGN_CENTER
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setRows($rows, $align = self::ALIGN_LEFT)
|
||||||
|
{
|
||||||
|
$this->rows = $rows;
|
||||||
|
$this->cellAlign = $align;
|
||||||
|
|
||||||
|
foreach ($rows as $row)
|
||||||
|
{
|
||||||
|
$this->checkColWidth($row);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查列数据的显示宽度
|
||||||
|
* @access public
|
||||||
|
* @param mixed $row 行数据
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function checkColWidth($row)
|
||||||
|
{
|
||||||
|
if (is_array($row))
|
||||||
|
{
|
||||||
|
foreach ($row as $key => $cell)
|
||||||
|
{
|
||||||
|
if (!isset($this->colWidth[$key]) || strlen($cell) > $this->colWidth[$key])
|
||||||
|
{
|
||||||
|
$this->colWidth[$key] = strlen($cell);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 增加一行表格数据
|
||||||
|
* @access public
|
||||||
|
* @param mixed $row 行数据
|
||||||
|
* @param bool $first 是否在开头插入
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function addRow($row, $first = false)
|
||||||
|
{
|
||||||
|
if ($first)
|
||||||
|
{
|
||||||
|
array_unshift($this->rows, $row);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->rows[] = $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->checkColWidth($row);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置输出表格的样式
|
||||||
|
* @access public
|
||||||
|
* @param string $style 样式名
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setStyle($style)
|
||||||
|
{
|
||||||
|
$this->style = isset($this->format[$style]) ? $style : 'default';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 输出分隔行
|
||||||
|
* @access public
|
||||||
|
* @param string $pos 位置
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function renderSeparator($pos)
|
||||||
|
{
|
||||||
|
$style = $this->getStyle($pos);
|
||||||
|
$array = [];
|
||||||
|
|
||||||
|
foreach ($this->colWidth as $width)
|
||||||
|
{
|
||||||
|
$array[] = str_repeat($style[1], $width + 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $style[0] . implode($style[2], $array) . $style[3] . PHP_EOL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 输出表格头部
|
||||||
|
* @access public
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function renderHeader()
|
||||||
|
{
|
||||||
|
$style = $this->getStyle('cell');
|
||||||
|
$content = $this->renderSeparator('top');
|
||||||
|
|
||||||
|
foreach ($this->header as $key => $header)
|
||||||
|
{
|
||||||
|
$array[] = ' ' . str_pad($header, $this->colWidth[$key], $style[1], $this->headerAlign);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($array))
|
||||||
|
{
|
||||||
|
$content .= $style[0] . implode(' ' . $style[2], $array) . ' ' . $style[3] . PHP_EOL;
|
||||||
|
|
||||||
|
if ($this->rows)
|
||||||
|
{
|
||||||
|
$content .= $this->renderSeparator('middle');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $content;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getStyle($style)
|
||||||
|
{
|
||||||
|
if ($this->format[$this->style])
|
||||||
|
{
|
||||||
|
$style = $this->format[$this->style][$style];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$style = [' ', ' ', ' ', ' '];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $style;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 输出表格
|
||||||
|
* @access public
|
||||||
|
* @param array $dataList 表格数据
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function render($dataList = [])
|
||||||
|
{
|
||||||
|
if ($dataList)
|
||||||
|
{
|
||||||
|
$this->setRows($dataList);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 输出头部
|
||||||
|
$content = $this->renderHeader();
|
||||||
|
$style = $this->getStyle('cell');
|
||||||
|
|
||||||
|
if ($this->rows)
|
||||||
|
{
|
||||||
|
foreach ($this->rows as $row)
|
||||||
|
{
|
||||||
|
if (is_string($row) && '-' === $row)
|
||||||
|
{
|
||||||
|
$content .= $this->renderSeparator('middle');
|
||||||
|
}
|
||||||
|
elseif (is_scalar($row))
|
||||||
|
{
|
||||||
|
$content .= $this->renderSeparator('cross-top');
|
||||||
|
$array = str_pad($row, 3 * (count($this->colWidth) - 1) + array_reduce($this->colWidth, function ($a, $b) {
|
||||||
|
return $a + $b;
|
||||||
|
}));
|
||||||
|
|
||||||
|
$content .= $style[0] . ' ' . $array . ' ' . $style[3] . PHP_EOL;
|
||||||
|
$content .= $this->renderSeparator('cross-bottom');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$array = [];
|
||||||
|
|
||||||
|
foreach ($row as $key => $val)
|
||||||
|
{
|
||||||
|
$array[] = ' ' . str_pad($val, $this->colWidth[$key], ' ', $this->cellAlign);
|
||||||
|
}
|
||||||
|
|
||||||
|
$content .= $style[0] . implode(' ' . $style[2], $array) . ' ' . $style[3] . PHP_EOL;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$content .= $this->renderSeparator('bottom');
|
||||||
|
|
||||||
|
return $content;
|
||||||
|
}
|
||||||
|
}
|
@ -342,37 +342,3 @@ function object_array($array)
|
|||||||
}
|
}
|
||||||
return $array;
|
return $array;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 显示支持的站点列表
|
|
||||||
*/
|
|
||||||
function ShowTableSites(){
|
|
||||||
$data = [];
|
|
||||||
$i = $j = $k = 0;
|
|
||||||
foreach(glob(APP_PATH.'Protocols'.DS.'*.php') as $key => $start_file)
|
|
||||||
{
|
|
||||||
$start_file = str_replace("\\","/",$start_file);
|
|
||||||
$offset = strripos($start_file,'/');
|
|
||||||
if ($offset===false) {
|
|
||||||
$start_file = substr($start_file,0,-4);
|
|
||||||
} else {
|
|
||||||
$start_file = substr($start_file,$offset+1,-4);
|
|
||||||
}
|
|
||||||
// 过滤示例、过滤解码接口
|
|
||||||
if (in_array($start_file,['axxxx','decodeBase'])) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// 控制多少列
|
|
||||||
if ($i > 4) {
|
|
||||||
$k++;
|
|
||||||
$i = 0;
|
|
||||||
}
|
|
||||||
$i++;
|
|
||||||
$j++;
|
|
||||||
$data[$k][] = $j.". ".$start_file;
|
|
||||||
}
|
|
||||||
//输出表格
|
|
||||||
$table = new Table();
|
|
||||||
$table->setRows($data);
|
|
||||||
echo($table->render());
|
|
||||||
}
|
|
||||||
|
10
iyuu.php
10
iyuu.php
@ -2,16 +2,6 @@
|
|||||||
require_once __DIR__ . '/init.php';
|
require_once __DIR__ . '/init.php';
|
||||||
use IYUU\AutoReseed;
|
use IYUU\AutoReseed;
|
||||||
|
|
||||||
#echo "IYUUAutoReseed自动辅种脚本,目前支持以下站点:".PHP_EOL;
|
|
||||||
#ShowTableSites();
|
|
||||||
echo <<<EOF
|
|
||||||
gitee 源码仓库:https://gitee.com/ledc/IYUUAutoReseed
|
|
||||||
github源码仓库:https://github.com/ledccn/IYUUAutoReseed
|
|
||||||
教程:https://gitee.com/ledc/IYUUAutoReseed/tree/master/wiki
|
|
||||||
QQ群:859882209 【IYUU自动辅种交流】
|
|
||||||
EOF;
|
|
||||||
echo PHP_EOL.PHP_EOL;
|
|
||||||
|
|
||||||
AutoReseed::init();
|
AutoReseed::init();
|
||||||
$hashArray = AutoReseed::get();
|
$hashArray = AutoReseed::get();
|
||||||
if (AutoReseed::$move != null) {
|
if (AutoReseed::$move != null) {
|
||||||
|
Reference in New Issue
Block a user