mirror of
https://gitee.com/ledc/IYUUAutoReseed
synced 2025-07-30 19:17:19 +00:00
标准化格式
This commit is contained in:
@@ -109,7 +109,8 @@ class AutoReseed
|
|||||||
/**
|
/**
|
||||||
* 显示支持站点列表
|
* 显示支持站点列表
|
||||||
*/
|
*/
|
||||||
private static function ShowTableSites(){
|
private static function ShowTableSites()
|
||||||
|
{
|
||||||
$list[] = 'gitee 源码仓库:https://gitee.com/ledc/IYUUAutoReseed';
|
$list[] = 'gitee 源码仓库:https://gitee.com/ledc/IYUUAutoReseed';
|
||||||
$list[] = 'github源码仓库:https://github.com/ledccn/IYUUAutoReseed';
|
$list[] = 'github源码仓库:https://github.com/ledccn/IYUUAutoReseed';
|
||||||
$list[] = '教程:https://gitee.com/ledc/IYUUAutoReseed/tree/master/wiki';
|
$list[] = '教程:https://gitee.com/ledc/IYUUAutoReseed/tree/master/wiki';
|
||||||
@@ -136,8 +137,7 @@ class AutoReseed
|
|||||||
}
|
}
|
||||||
$data = [];
|
$data = [];
|
||||||
$i = $j = $k = 0;
|
$i = $j = $k = 0;
|
||||||
foreach($sites as $v)
|
foreach ($sites as $v) {
|
||||||
{
|
|
||||||
// 控制多少列
|
// 控制多少列
|
||||||
if ($i > 4) {
|
if ($i > 4) {
|
||||||
$k++;
|
$k++;
|
||||||
|
@@ -124,8 +124,7 @@ class Table
|
|||||||
$this->rows = $rows;
|
$this->rows = $rows;
|
||||||
$this->cellAlign = $align;
|
$this->cellAlign = $align;
|
||||||
|
|
||||||
foreach ($rows as $row)
|
foreach ($rows as $row) {
|
||||||
{
|
|
||||||
$this->checkColWidth($row);
|
$this->checkColWidth($row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -138,12 +137,9 @@ class Table
|
|||||||
*/
|
*/
|
||||||
protected function checkColWidth($row)
|
protected function checkColWidth($row)
|
||||||
{
|
{
|
||||||
if (is_array($row))
|
if (is_array($row)) {
|
||||||
{
|
foreach ($row as $key => $cell) {
|
||||||
foreach ($row as $key => $cell)
|
if (!isset($this->colWidth[$key]) || strlen($cell) > $this->colWidth[$key]) {
|
||||||
{
|
|
||||||
if (!isset($this->colWidth[$key]) || strlen($cell) > $this->colWidth[$key])
|
|
||||||
{
|
|
||||||
$this->colWidth[$key] = strlen($cell);
|
$this->colWidth[$key] = strlen($cell);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -159,12 +155,9 @@ class Table
|
|||||||
*/
|
*/
|
||||||
public function addRow($row, $first = false)
|
public function addRow($row, $first = false)
|
||||||
{
|
{
|
||||||
if ($first)
|
if ($first) {
|
||||||
{
|
|
||||||
array_unshift($this->rows, $row);
|
array_unshift($this->rows, $row);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->rows[] = $row;
|
$this->rows[] = $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,8 +186,7 @@ class Table
|
|||||||
$style = $this->getStyle($pos);
|
$style = $this->getStyle($pos);
|
||||||
$array = [];
|
$array = [];
|
||||||
|
|
||||||
foreach ($this->colWidth as $width)
|
foreach ($this->colWidth as $width) {
|
||||||
{
|
|
||||||
$array[] = str_repeat($style[1], $width + 2);
|
$array[] = str_repeat($style[1], $width + 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,17 +203,14 @@ class Table
|
|||||||
$style = $this->getStyle('cell');
|
$style = $this->getStyle('cell');
|
||||||
$content = $this->renderSeparator('top');
|
$content = $this->renderSeparator('top');
|
||||||
|
|
||||||
foreach ($this->header as $key => $header)
|
foreach ($this->header as $key => $header) {
|
||||||
{
|
|
||||||
$array[] = ' ' . str_pad($header, $this->colWidth[$key], $style[1], $this->headerAlign);
|
$array[] = ' ' . str_pad($header, $this->colWidth[$key], $style[1], $this->headerAlign);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($array))
|
if (!empty($array)) {
|
||||||
{
|
|
||||||
$content .= $style[0] . implode(' ' . $style[2], $array) . ' ' . $style[3] . PHP_EOL;
|
$content .= $style[0] . implode(' ' . $style[2], $array) . ' ' . $style[3] . PHP_EOL;
|
||||||
|
|
||||||
if ($this->rows)
|
if ($this->rows) {
|
||||||
{
|
|
||||||
$content .= $this->renderSeparator('middle');
|
$content .= $this->renderSeparator('middle');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -231,12 +220,9 @@ class Table
|
|||||||
|
|
||||||
protected function getStyle($style)
|
protected function getStyle($style)
|
||||||
{
|
{
|
||||||
if ($this->format[$this->style])
|
if ($this->format[$this->style]) {
|
||||||
{
|
|
||||||
$style = $this->format[$this->style][$style];
|
$style = $this->format[$this->style][$style];
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$style = [' ', ' ', ' ', ' '];
|
$style = [' ', ' ', ' ', ' '];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,8 +237,7 @@ class Table
|
|||||||
*/
|
*/
|
||||||
public function render($dataList = [])
|
public function render($dataList = [])
|
||||||
{
|
{
|
||||||
if ($dataList)
|
if ($dataList) {
|
||||||
{
|
|
||||||
$this->setRows($dataList);
|
$this->setRows($dataList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,16 +245,11 @@ class Table
|
|||||||
$content = $this->renderHeader();
|
$content = $this->renderHeader();
|
||||||
$style = $this->getStyle('cell');
|
$style = $this->getStyle('cell');
|
||||||
|
|
||||||
if ($this->rows)
|
if ($this->rows) {
|
||||||
{
|
foreach ($this->rows as $row) {
|
||||||
foreach ($this->rows as $row)
|
if (is_string($row) && '-' === $row) {
|
||||||
{
|
|
||||||
if (is_string($row) && '-' === $row)
|
|
||||||
{
|
|
||||||
$content .= $this->renderSeparator('middle');
|
$content .= $this->renderSeparator('middle');
|
||||||
}
|
} elseif (is_scalar($row)) {
|
||||||
elseif (is_scalar($row))
|
|
||||||
{
|
|
||||||
$content .= $this->renderSeparator('cross-top');
|
$content .= $this->renderSeparator('cross-top');
|
||||||
$array = str_pad($row, 3 * (count($this->colWidth) - 1) + array_reduce($this->colWidth, function ($a, $b) {
|
$array = str_pad($row, 3 * (count($this->colWidth) - 1) + array_reduce($this->colWidth, function ($a, $b) {
|
||||||
return $a + $b;
|
return $a + $b;
|
||||||
@@ -277,18 +257,14 @@ class Table
|
|||||||
|
|
||||||
$content .= $style[0] . ' ' . $array . ' ' . $style[3] . PHP_EOL;
|
$content .= $style[0] . ' ' . $array . ' ' . $style[3] . PHP_EOL;
|
||||||
$content .= $this->renderSeparator('cross-bottom');
|
$content .= $this->renderSeparator('cross-bottom');
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$array = [];
|
$array = [];
|
||||||
|
|
||||||
foreach ($row as $key => $val)
|
foreach ($row as $key => $val) {
|
||||||
{
|
|
||||||
$array[] = ' ' . str_pad($val, $this->colWidth[$key], ' ', $this->cellAlign);
|
$array[] = ' ' . str_pad($val, $this->colWidth[$key], ' ', $this->cellAlign);
|
||||||
}
|
}
|
||||||
|
|
||||||
$content .= $style[0] . implode(' ' . $style[2], $array) . ' ' . $style[3] . PHP_EOL;
|
$content .= $style[0] . implode(' ' . $style[2], $array) . ' ' . $style[3] . PHP_EOL;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -200,7 +200,8 @@ function convertToMB($from)
|
|||||||
* 字节数Byte转换为KB、MB、GB、TB
|
* 字节数Byte转换为KB、MB、GB、TB
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function getFilesize($num){
|
function getFilesize($num)
|
||||||
|
{
|
||||||
$p = 0;
|
$p = 0;
|
||||||
$format='bytes';
|
$format='bytes';
|
||||||
if ($num>0 && $num<1024) {
|
if ($num>0 && $num<1024) {
|
||||||
@@ -323,7 +324,8 @@ function filter($site = '', $torrent = array())
|
|||||||
/**
|
/**
|
||||||
* 日志记录函数
|
* 日志记录函数
|
||||||
*/
|
*/
|
||||||
function wlog($data='',$name = '',$path = ''){
|
function wlog($data='', $name = '', $path = '')
|
||||||
|
{
|
||||||
// 数据转换
|
// 数据转换
|
||||||
if (is_bool($data)) {
|
if (is_bool($data)) {
|
||||||
$show_data=$data ? 'true' : 'false';
|
$show_data=$data ? 'true' : 'false';
|
||||||
@@ -398,7 +400,8 @@ function evenFilter($var)
|
|||||||
* 发布员签名
|
* 发布员签名
|
||||||
* 注意:同时配置iyuu.cn与secret时,优先使用secret。
|
* 注意:同时配置iyuu.cn与secret时,优先使用secret。
|
||||||
*/
|
*/
|
||||||
function sign( $timestamp ){
|
function sign($timestamp)
|
||||||
|
{
|
||||||
global $configALL;
|
global $configALL;
|
||||||
// 爱语飞飞
|
// 爱语飞飞
|
||||||
$token = isset($configALL['iyuu.cn']) && $configALL['iyuu.cn'] ? $configALL['iyuu.cn'] : '';
|
$token = isset($configALL['iyuu.cn']) && $configALL['iyuu.cn'] ? $configALL['iyuu.cn'] : '';
|
||||||
@@ -412,7 +415,8 @@ function sign( $timestamp ){
|
|||||||
* token算法:IYUU + uid + T + sha1(openid+time+盐)
|
* token算法:IYUU + uid + T + sha1(openid+time+盐)
|
||||||
* @param string $token 用户请求token
|
* @param string $token 用户请求token
|
||||||
*/
|
*/
|
||||||
function getUid($token){
|
function getUid($token)
|
||||||
|
{
|
||||||
//验证是否IYUU开头,strpos($token,'T')<15,token总长度小于60(40+10+5)
|
//验证是否IYUU开头,strpos($token,'T')<15,token总长度小于60(40+10+5)
|
||||||
return (strlen($token)<60)&&(strpos($token, 'IYUU')===0)&&(strpos($token, 'T')<15) ? substr($token, 4, strpos($token, 'T')-4): false;
|
return (strlen($token)<60)&&(strpos($token, 'IYUU')===0)&&(strpos($token, 'T')<15) ? substr($token, 4, strpos($token, 'T')-4): false;
|
||||||
}
|
}
|
||||||
@@ -420,7 +424,8 @@ function getUid($token){
|
|||||||
/**
|
/**
|
||||||
* 显示支持的站点列表
|
* 显示支持的站点列表
|
||||||
*/
|
*/
|
||||||
function ShowTableSites($dir = 'Protocols',$filter = array()){
|
function ShowTableSites($dir = 'Protocols', $filter = array())
|
||||||
|
{
|
||||||
// 过滤的文件
|
// 过滤的文件
|
||||||
switch ($dir) {
|
switch ($dir) {
|
||||||
case 'Protocols':
|
case 'Protocols':
|
||||||
@@ -435,8 +440,7 @@ function ShowTableSites($dir = 'Protocols',$filter = array()){
|
|||||||
}
|
}
|
||||||
$data = [];
|
$data = [];
|
||||||
$i = $j = $k = 0;
|
$i = $j = $k = 0;
|
||||||
foreach(glob(APP_PATH.$dir.DS.'*.php') as $key => $start_file)
|
foreach (glob(APP_PATH.$dir.DS.'*.php') as $key => $start_file) {
|
||||||
{
|
|
||||||
$start_file = str_replace("\\", "/", $start_file);
|
$start_file = str_replace("\\", "/", $start_file);
|
||||||
$offset = strripos($start_file, '/');
|
$offset = strripos($start_file, '/');
|
||||||
if ($offset===false) {
|
if ($offset===false) {
|
||||||
|
@@ -43,6 +43,24 @@ return array(
|
|||||||
'/sda1' => '/volume1',
|
'/sda1' => '/volume1',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
'filter' => array(
|
||||||
|
'size'=>array(
|
||||||
|
'min' => '1GB',
|
||||||
|
'max' => '280GB',
|
||||||
|
),
|
||||||
|
'seeders'=>array(
|
||||||
|
'min' => 1,
|
||||||
|
'max' => 3,
|
||||||
|
),
|
||||||
|
'leechers'=>array(
|
||||||
|
'min' => 0,
|
||||||
|
'max' => 10000,
|
||||||
|
),
|
||||||
|
'completed'=>array(
|
||||||
|
'min' => 0,
|
||||||
|
'max' => 10000,
|
||||||
|
),
|
||||||
|
),
|
||||||
'CONNECTTIMEOUT'=> 60,
|
'CONNECTTIMEOUT'=> 60,
|
||||||
'TIMEOUT' => 600,
|
'TIMEOUT' => 600,
|
||||||
),
|
),
|
||||||
|
Reference in New Issue
Block a user