get(); $aResultAll = []; foreach ($oFnSiteList as $oFnSite) { $aSiteConfig = json_decode($oFnSite->config, true); $aSiteConfigFnClient = $aSiteConfig["freenode_client"] ?? []; $aSiteApi = json_decode($oFnSite->api_path, true); $sSiteApiFreenodeReceive = $aSiteApi["freenode_receive"] ?? ""; $aFnContent = []; foreach ($aSiteConfigFnClient as $aSiteConfigFnClientRow) { $sFilePath = $sDirBase."public/freenode/merge/".$oFnSite->code."/".$aSiteConfigFnClientRow."/".date("Y-m-d").".txt"; if (file_exists($sFilePath)) { $aFnContent[$aSiteConfigFnClientRow] = file_get_contents($sFilePath); } else { $sMsg = "freenodeSync的run没有当天文件".$sFilePath; TeleSlave::warn()->send($sMsg); } } $sApiUrl = "https://".$oFnSite->url."/".$sSiteApiFreenodeReceive; $sResult = HttpV2::make($sApiUrl, "post")->setDataA($aFnContent)->enableJsonSend()->send(); $aResult = json_decode($sResult, true); if (!isset($aResult["is_done"]) || $aResult["is_done"] != true) { $sMsg = "freenodeSync::同步失败 ->".$oFnSite->name."->".$sResult; echo $sMsg; TeleSlave::warn()->setMsgS($sMsg)->send(); continue; } } echo " - ok \n"; } static function nodehub() { echo "\nFeenodeSync::nodehub() - 开始 \n"; $sDirBase = $_ENV["dir_base"]; $oFnSiteList = ModelSiteMap::where("group_code", "nodehub")->get(); $aResultAll = []; foreach ($oFnSiteList as $oFnSite) { $aSiteConfig = json_decode($oFnSite->config, true); $aSiteConfigFnClient = $aSiteConfig["freenode_client"] ?? []; $aSiteApi = json_decode($oFnSite->api_path, true); $sSiteApiFreenodeReceive = $aSiteApi["freenode_receive"] ?? ""; $aFnContent = []; foreach ($aSiteConfigFnClient as $aSiteConfigFnClientRow) { $sFilePath = $sDirBase."public/freenode/merge/".$oFnSite->code."/".$aSiteConfigFnClientRow."/".date("Y-m-d").".txt"; if (!file_exists($sFilePath)) { $sMsg = "freenodeSync的run没有当天文件".$sFilePath; TeleSlave::warn()->send($sMsg); echo "\n - ".$sMsg; continue; } $aFnContent[$aSiteConfigFnClientRow] = file_get_contents($sFilePath); } $sApiUrl = "https://".$oFnSite->url."/".$sSiteApiFreenodeReceive; //// test $sResult = HttpV2::make($sApiUrl, "post")->setDataA($aFnContent)->enableJsonSend()->send(); $aResult = json_decode($sResult, true); if (!isset($aResult["isDone"]) || $aResult["isDone"] != true) { $sMsg = "freenodeSync::同步失败 ->".$oFnSite->name; echo $sMsg.$sResult; TeleSlave::warn()->setMsgS($sMsg)->send(); continue; } if (isset($aResult["sMsg"])) { $sMsg = json_encode($aResult["sMsg"]); TeleSlave::notify()->setMsgS($sMsg)->send(); } else { TeleSlave::log()->setMsgS("nodehub同步完成")->send(); } } echo " - 完成 \n"; } // static function run_b() // { // echo "\nFeenodeSync::run_b() - 开始 \n"; // // $sDirBase = $_ENV["dir_base"]; // // $oFnSiteList = ModelSiteMap::where("group_code", "fn_b")->get(); // $oSiteNodehub = ModelSiteMap::where("code", "nodehub")->first(); // $aSiteNodehubConfig = json_decode($oSiteNodehub->config ?? '', true); // // $aFreenodeClient = $aSiteNodehubConfig["freenode_client"] ?? []; // $aNodehubApis = json_decode($oSiteNodehub->api_path, true); // $sSiteApiFreenodeReceive = $aNodehubApis["freenode_receive"] ?? ""; // // $aResultAll = []; // foreach ($oFnSiteList as $oFnSite) { // //// $aSiteConfig = json_decode($oFnSite->config, true); //// $aSiteConfigFnClient = $aSiteConfig["freenode_client"] ?? []; //// $aSiteConfigFnClient = ["clash", "v2ray"]; //// $aSiteApi = json_decode($oFnSite->api_path, true); //// $sSiteApiFreenodeReceive = $aSiteApi["freenode_receive"] ?? ""; // // $aData = []; // $aData["site_code_short"] = $oFnSite->code_short; // foreach ($aFreenodeClient as $aSiteConfigFnClientRow) { // $sFilePath = $sDirBase."public/freenode/merge/".$oFnSite->code."/".$aSiteConfigFnClientRow."/".date("Y-m-d").".txt"; // // if (!file_exists($sFilePath)) { // $sMsg = "freenodeSync的run没有当天文件".$sFilePath; // TeleSlave::warn()->send($sMsg); // echo "\n - ".$sMsg; // continue; // } // // $aData["raw"][$aSiteConfigFnClientRow] = file_get_contents($sFilePath); // } // // $sApiUrl = "https://".$oSiteNodehub->url."/".$sSiteApiFreenodeReceive; //// tomd($sApiUrl, 1); // $sResult = HttpV2::make($sApiUrl, "post")->setDataA($aData)->enableJsonSend()->send(); // $aResult = json_decode($sResult, true); // // if (!isset($aResult["isDone"]) || $aResult["isDone"] != true) { // $sMsg = "freenodeSync::同步失败 ->".$oFnSite->name."->".$sResult; // echo $sMsg; //// TeleSlave::warn()->setMsgS($sMsg)->send(); // continue; // } // // if (isset($aResult["sMsg"])) { // $sMsg = json_encode($aResult["sMsg"]); //// TeleSlave::warn()->setMsgS($sMsg)->send(); // } // // } // // echo " - 完成 \n"; // } }