1
This commit is contained in:
commit
3b89c0e7b1
8421 files changed
+1038244
No files matched your search
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\v1;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\TomTool\Flow;
|
||||
use App\Services\TomTool\Telegram\Slave as TeleSlave;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
class FreenodeController extends Controller
|
||||
{
|
||||
public function filePut(Request $oRequest)
|
||||
{
|
||||
|
||||
$sObjName = "freenode:filePub";
|
||||
$oFlow = Flow::make($sObjName);
|
||||
|
||||
$aData = $oRequest->all();
|
||||
|
||||
$sSubSiteCodeShort = $aData["site_code_short"];
|
||||
$aRaw = $aData["raw"];
|
||||
|
||||
$sDate = date('Ymd');
|
||||
$sSuffix = "nodes";
|
||||
$sRawKey = $sDate . $sSuffix;
|
||||
$sUniqueToken = hash_hmac('sha256', $sRawKey, 'wocaonide');
|
||||
$sShortToken = Str::substr($sUniqueToken, 0, 16);
|
||||
|
||||
$aResult = [];
|
||||
foreach ($aRaw as $sClient => $sContent) {
|
||||
|
||||
if (!$sContent) {
|
||||
$sMsg = "\n {$sObjName}来空?";
|
||||
echo $sMsg;
|
||||
TeleSlave::warn()->send($sMsg);
|
||||
continue;
|
||||
}
|
||||
|
||||
$sExtension = '.txt';
|
||||
if ($sClient == "v2ray") {
|
||||
$sExtension = ".txt";
|
||||
} else if ($sClient == "clash") {
|
||||
$sExtension = ".yaml";
|
||||
}
|
||||
|
||||
$sFileSavePath = $sSubSiteCodeShort."/".$sShortToken;
|
||||
$sFileSaveName = date("Ymd")."-".$sClient.$sExtension;
|
||||
$sFilePathFull = $sFileSavePath."/".$sFileSaveName;
|
||||
|
||||
if (!File::isDirectory($sFileSavePath)) {
|
||||
File::makeDirectory($sFileSavePath, 0755, true);
|
||||
}
|
||||
|
||||
$xSaveLenth = File::put($sFilePathFull, $sContent);
|
||||
chmod($sFilePathFull, 0644);
|
||||
// chmod($sFilePathFull, 0777);
|
||||
|
||||
if (!$xSaveLenth) {
|
||||
$sMsg = "\n {$sObjName}保存file失败?";
|
||||
echo $sMsg;
|
||||
TeleSlave::warn()->send($sMsg);
|
||||
continue;
|
||||
}
|
||||
|
||||
$sFileUrl = config("app.url")."/".$sFilePathFull;
|
||||
|
||||
if (config("app.is_loc") == false) {
|
||||
$oFlow = TeleSlave::log()
|
||||
->enableDetail(false)
|
||||
->setFileUrl($sFileUrl, "更新ok的".config("app.site_code_short")."的{$sSubSiteCodeShort}的{$sClient}的长{$xSaveLenth}")
|
||||
->send();
|
||||
|
||||
if ($oFlow->isFail()) {
|
||||
var_dump($oFlow->getResult());
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return response()->json($oFlow->done());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user