diff --git a/app/AutoReseed.php b/app/AutoReseed.php index 13e8ff7..4abdff6 100644 --- a/app/AutoReseed.php +++ b/app/AutoReseed.php @@ -90,6 +90,7 @@ class AutoReseed */ public static function init() { + // 显示支持站点列表 self::ShowTableSites(); global $configALL; self::$clients = isset($configALL['default']['clients']) && $configALL['default']['clients'] ? $configALL['default']['clients'] : array(); @@ -123,6 +124,16 @@ class AutoReseed $curl->setOpt(CURLOPT_SSL_VERIFYHOST, false); // 不检查证书 $res = $curl->post(self::$apiUrl); $sites = json_decode($res->response, true); + // 数据写入本地 + if (true) { + $json = array_column($sites, null, 'site'); + ksort($json); + $json = json_encode($json, JSON_UNESCAPED_UNICODE); + $myfile = ROOT_PATH.DS.'config'.DS.'sites.json'; + $file_pointer = @fopen($myfile,"w"); + $worldsnum = @fwrite($file_pointer,$json); + @fclose($file_pointer); + } $data = []; $i = $j = $k = 0; foreach($sites as $v) diff --git a/app/helper.php b/app/helper.php index 84d9acc..93dde64 100644 --- a/app/helper.php +++ b/app/helper.php @@ -196,6 +196,37 @@ function convertToMB($from) } } +/** + * 字节数Byte转换为KB、MB、GB、TB + * + */ +function getFilesize($num){ + $p = 0; + $format='bytes'; + if($num>0 && $num<1024){ + $p = 0; + return number_format($num).' '.$format; + } + if($num>=1024 && $num=pow(1024, 2) && $num=pow(1024, 3) && $num=pow(1024, 4) && $num $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, $filter)) { + continue; + } + // 控制多少列 + if ($i > 4) { + $k++; + $i = 0; + } + $i++; + $j++; + $data[$k][] = $j.". ".$start_file; + } + //输出表格 + $table = new Table(); + $table->setRows($data); + echo($table->render()); +} diff --git a/init.php b/init.php index e0dfbd4..6e27ded 100644 --- a/init.php +++ b/init.php @@ -36,6 +36,12 @@ if (file_exists(ROOT_PATH."/config/config.php")) { // 示例配置 $configALL = require_once ROOT_PATH . '/config/config.sample.php'; } +// 读取支持列表 +if (is_file(ROOT_PATH . "/config/sites.json")) { + $sitesJson = file_get_contents(ROOT_PATH . "/config/sites.json"); + $configALL['sitesALL'] = json_decode($sitesJson, true); +} + require_once ROOT_PATH . '/vendor/autoload.php'; global $argv;