74 lines
1.6 KiB
PHP
Executable File
74 lines
1.6 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Http\Controllers\Api;
|
|
|
|
use Illuminate\Http\Request;
|
|
//use voku\helper\AntiXSS;
|
|
use App\Models\ArticleList as Article;
|
|
|
|
class GithubController extends Controller
|
|
{
|
|
|
|
public function todayUpd()
|
|
{
|
|
|
|
$sCode = date("Ymd");
|
|
|
|
$bUpd = Article::where("code", $sCode)->exists();
|
|
|
|
return $bUpd;
|
|
|
|
}
|
|
|
|
public function getLast()
|
|
{
|
|
// $sCode = date("Ymd");
|
|
|
|
$aToday = Article::orderBy("id", "desc")->first()->toArray();
|
|
|
|
echo json_encode($aToday);
|
|
|
|
}
|
|
|
|
|
|
// 始终返回数据,今天没有就是前一天,前一天没有就是异常情况
|
|
public function getFnToday($sDate = false)
|
|
{
|
|
if (!$sDate) {
|
|
$sDate = date("Ymd");
|
|
}
|
|
|
|
$sCode = $sDate;
|
|
|
|
//// test
|
|
// 20250721 - 23 有数据
|
|
// $sCode = "20250720";
|
|
|
|
$bUpd = Article::where("code", $sCode)->exists();
|
|
|
|
if ($bUpd === true) {
|
|
$sCodeTrue = $sCode;
|
|
} else {
|
|
$sCodeTrue = date("Ymd", strtotime("-1 day"));
|
|
}
|
|
|
|
$sFilePathClash = "sub/".$sCodeTrue."-clash.yaml";
|
|
$sFilePathV2ray = "sub/".$sCodeTrue."-v2ray.txt";
|
|
|
|
$sFileClash = file_get_contents($sFilePathClash);
|
|
$sFileV2ray = file_get_contents($sFilePathV2ray);
|
|
|
|
$aData = [
|
|
"code" => "100",
|
|
"clash" => $sFileClash,
|
|
"v2ray" => $sFileV2ray
|
|
];
|
|
|
|
echo json_encode($aData);
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
}
|