86 lines
2.2 KiB
PHP
Executable File
86 lines
2.2 KiB
PHP
Executable File
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Services\Cron;
|
|
|
|
//use App\Models\CrawlFreenode as ModelCrawlFreenode;
|
|
use App\Services\TomTool\Telegram\Slave as TeleSlave;
|
|
//use App\Services\TomTool\Telegram\Master as TeleMaster;
|
|
//use App\Models\SiteMap as ModelSiteMap;
|
|
use App\Services\TomTool\Http;
|
|
//use Symfony\Component\Yaml\Yaml;
|
|
use App\Models\ArticleList as ModelArticle;
|
|
|
|
final class ArticleLive
|
|
{
|
|
private const TYPE_CLIENT = [
|
|
'ios',
|
|
'android',
|
|
'mac',
|
|
'win',
|
|
'linux',
|
|
];
|
|
|
|
public static function client()
|
|
{
|
|
echo "\n\nArticleLive::client() - 开始";
|
|
|
|
$iRandX = 10; // 期望每x天更新一篇
|
|
|
|
// $iRandX = 1; //// test
|
|
|
|
$iRand = rand(1, $iRandX);
|
|
|
|
if ($iRand !== 1) {
|
|
echo "\n - 未命中";
|
|
return false;
|
|
}
|
|
|
|
$oArticleClient = ModelArticle::whereIn("type", self::TYPE_CLIENT)->orderBy("updated_at", "asc")->first();
|
|
$sUpdatedAtOld = (string) $oArticleClient->updated_at;
|
|
$oArticleClient->updated_at = time();
|
|
$oArticleClient->save();
|
|
|
|
$oHttp = new Http();
|
|
|
|
$oHttp->sMethod = "get";
|
|
$oHttp->bIsJson = "true";
|
|
$oHttp->sToUrl = env("APP_URL")."/exec/html/client";
|
|
$r = $oHttp->send();
|
|
|
|
echo "\n - $r";
|
|
|
|
$aData["ArticleLive::client() - ok"] = [
|
|
"code" => $oArticleClient->code,
|
|
"title" => $oArticleClient->title,
|
|
"update_at" => (string) $oArticleClient->updated_at,
|
|
"update_at::old" => $sUpdatedAtOld,
|
|
];
|
|
|
|
var_dump($aData);
|
|
|
|
TeleSlave::log()->enableSlaveQueue(false)->send($aData);
|
|
|
|
echo "\n - ok";
|
|
}
|
|
|
|
public static function main()
|
|
{
|
|
echo "\n\nArticleLive::main() - 开始";
|
|
|
|
@unlink("index.html");
|
|
|
|
$ch = curl_init();
|
|
curl_setopt($ch, CURLOPT_URL, env("APP_URL"));
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
|
|
|
curl_exec($ch);
|
|
|
|
echo "\n - ok";
|
|
}
|
|
|
|
}
|