debug
This commit is contained in:
@@ -13,6 +13,7 @@ use app\model\ChapterModel;
|
||||
use app\model\SystemConfigModel;
|
||||
use app\model\NovelClicksModel;
|
||||
use app\model\NovelModel;
|
||||
use app\model\VideoModel;
|
||||
use app\common\helper\SiteStyle;
|
||||
use app\common\helper\CssBuilder;
|
||||
use app\common\helper\JsBuilder;
|
||||
@@ -566,6 +567,72 @@ class SiteContext
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* 兼容旧站的 /rss/so.xml。
|
||||
* 避免走模板标签 video:list 一次性读取/缓存大量完整视频文档导致内存溢出。
|
||||
*/
|
||||
public function getSoSitemapResponse(): Response
|
||||
{
|
||||
$strDomain = trim((string)($this->DomainModel->d_domain ?? ''));
|
||||
$strHost = $strDomain === '' ? trim((string)$this->Request->host()) : $strDomain;
|
||||
$strCacheKey = sprintf('SiteContext:getSoSitemapResponse:%s', $strHost);
|
||||
|
||||
$arrRows = VideoModel::getInstance()->findSitemapItemsWithCache(
|
||||
[],
|
||||
1000,
|
||||
['created_at' => -1, 'v_id' => -1],
|
||||
$strCacheKey,
|
||||
86400
|
||||
);
|
||||
|
||||
$arrXml = [
|
||||
'<?xml version="1.0" encoding="UTF-8"?>',
|
||||
'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">',
|
||||
];
|
||||
|
||||
$VideoService = app(VideoService::class);
|
||||
foreach ($arrRows as $arrVideo) {
|
||||
$intVId = (int)($arrVideo['v_id'] ?? 0);
|
||||
$strSlug = trim((string)($arrVideo['v_name_en'] ?? ''));
|
||||
if ($intVId <= 0 || $strSlug === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$strPath = $VideoService->getVideoInfoUrl($intVId, $strSlug);
|
||||
if ($strPath === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$strLoc = 'https://www.' . $strHost . $strPath;
|
||||
$strLastmod = trim((string)($arrVideo['v_publish_date'] ?? ''));
|
||||
if ($strLastmod === '') {
|
||||
$strLastmod = trim((string)($arrVideo['updated_at'] ?? ''));
|
||||
}
|
||||
if ($strLastmod === '') {
|
||||
$strLastmod = trim((string)($arrVideo['created_at'] ?? ''));
|
||||
}
|
||||
if ($strLastmod !== '') {
|
||||
$intTs = strtotime($strLastmod);
|
||||
if ($intTs !== false) {
|
||||
$strLastmod = date('Y-m-d', $intTs);
|
||||
}
|
||||
}
|
||||
|
||||
$arrXml[] = '<url>';
|
||||
$arrXml[] = '<loc>' . htmlspecialchars($strLoc, ENT_QUOTES | ENT_XML1, 'UTF-8') . '</loc>';
|
||||
if ($strLastmod !== '') {
|
||||
$arrXml[] = '<lastmod>' . htmlspecialchars($strLastmod, ENT_QUOTES | ENT_XML1, 'UTF-8') . '</lastmod>';
|
||||
}
|
||||
$arrXml[] = '</url>';
|
||||
}
|
||||
|
||||
$arrXml[] = '</urlset>';
|
||||
|
||||
return response(implode("\n", $arrXml), 200, [
|
||||
'Content-Type' => 'application/xml; charset=UTF-8',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 限速访问
|
||||
*
|
||||
@@ -817,6 +884,11 @@ class SiteContext
|
||||
return '';
|
||||
}
|
||||
|
||||
$arrTemplateCfg = is_array($this->DomainModel->t_cfg ?? null) ? $this->DomainModel->t_cfg : [];
|
||||
if (!array_key_exists($strLegacyKey, $arrTemplateCfg)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
try {
|
||||
return $this->normalizeSeoText($this->converterTemplate($strLegacyKey));
|
||||
} catch (\Throwable $Throwable) {
|
||||
|
||||
Reference in New Issue
Block a user