cfn/app/Http/Controllers/Article/SingleController.php
2026-05-15 15:28:59 +08:00

131 lines
3.9 KiB
PHP
Executable File

<?php
namespace App\Http\Controllers\Article;
use Illuminate\Http\Request;
use App\Models\ArticleList;
use App\Models\Option;
use App\Models\Jichang;
use App\Services\Time;
use App\Services\Tag;
use voku\helper\AntiXSS;
use App\Services\TomTool\Http;
use App\Services\TomTool\HttpV2;
class SingleController extends Controller
{
protected $sType = '';
protected $sCode = '';
protected $aData = [];
protected $aDataCommon = [];
protected $sViewPath = 'article/single';
public function __construct()
{
$this->oAntiXss = new AntiXSS();
parent::__construct();
}
protected function view()
{
$this->aData['sType'] = $this->sType;
$this->aData['aTagNames'] = Tag::strToNames($this->aData['tags']);
return view($this->sViewPath, [
"aData" => $this->aData,
"aDataCommon" => $this->aDataCommon,
"sMenu" => $this->aData['sMenu'],
]);
}
public function client ($iCode)
{
$this->code = $this->oAntiXss->xss_clean($iCode);
$this->aData = ArticleList::where("code", "=", $iCode)->first()->toArray();
$this->sType = 'client';
$this->aData['sTypeName'] = '客户端';
$this->aData['pathBase'] = '/client/';
$this->aData['urlParent'] = '/client';
$this->aData['sMenu'] = 'client';
$this->aData['pageTitle'] = $this->aData["title"];
// $this->aData['pageKw'] = "Clash,Quantumult,Shadowrocket,SSR,v2ray,免费节点,节点,订阅链接";
return $this->view();
}
public function freenode ($iCode)
{
$this->code = $this->oAntiXss->xss_clean($iCode);
$this->aData = ArticleList::where("code", "=", $iCode)->first()->toArray();
$this->sType = 'freenode';
$this->aData['sTypeName'] = '免费节点';
$this->aData['pathBase'] = '/fn/';
$this->aData['urlParent'] = '/';
$this->aData['sMenu'] = 'freenode';
$this->aData['pageTitle'] = '「'.$this->aData['date_str'].'」'.$this->aData["title"];
// $this->aData['pageKw'] = "Clash,Quantumult,Shadowrocket,SSR,v2ray,免费节点,节点,订阅链接";
// $this->aData['v2rayPath'] = env('APP_URL')."/feed/v2ray-".$iCode.".txt";
//
// $this->aData['clashPath'] = env('APP_URL')."/feed/clash-".$iCode.".yaml";
$aOption = Option::_all();
$aOptionFreenodeClient = explode(",", $aOption["freenode_client"]);
$oHttp = new Http();
foreach ($aOptionFreenodeClient as $sFnClient) {
$oHttp->sToUrl = "https://".env("url_master_base")."/api/v1/freenode/url_feed_today/".env("site_code_short")."/{$sFnClient}";
$sHttp = $oHttp->send();
$sHttp = json_decode($sHttp, 1);
$this->aData["fnFilePath"][$sFnClient] = "https://".$sHttp;
// $sEnding = ".txt";
// if ($sFnClient == "v2ray") {
// $sEnding = ".txt";
// } else if ($sFnClient == "clash") {
// $sEnding = ".yaml";
// }
//
// $this->aData["fnFilePath"][$sFnClient] = env('APP_URL')."/sub/".$iCode."-".$sFnClient.$sEnding;
}
$this->aData['jichang'] = Jichang::first()->toArray();
// $oHttp = new Http();
$oHttp->sToUrl = $this->aData['jichang']['url']."/api/huodong/datehit";
// $oHttp->sToUrl = env("url_jichang_base")."/api/huodong/datehit/2025-01-01";
$sHuodong = $oHttp->send();
$aHuodong = json_decode($sHuodong, 1);
$this->aData['aHuodong'] = $aHuodong;
$this->sViewPath = 'freenode/single';
return $this->view();
}
}