debug-log

This commit is contained in:
make
2025-05-18 17:52:38 +08:00
parent 0d2f5b88c9
commit 0468aa1b57
7 changed files with 52 additions and 30 deletions

View File

@@ -69,13 +69,13 @@ namespace {
function replaceLastPageNumber($url, $number) function replaceLastPageNumber($url, $number)
{ {
// 使用正则表达式替换最后一个 "1" 为 "number" // 使用正则表达式替换最后一个 "1" 为 "number"
return preg_replace('/1(?=[^1]*$)/', $number, $url); return preg_replace('/1(?=[^1]*$)/', $number, (string)$url);
} }
function removeScriptTags($rpText, $newText) function removeScriptTags($rpText, $newText)
{ {
// 使用正则表达式替换所有 <script> 标签 // 使用正则表达式替换所有 <script> 标签
return preg_replace($rpText, '', $newText); return preg_replace($rpText, '', (string)$newText);
} }
function extractFilename($url) function extractFilename($url)

View File

@@ -211,36 +211,49 @@ class GanRaoMaModel extends MongoModel
$arrFilter = [ $arrFilter = [
'grm_domain' => (string) $strDomain, 'grm_domain' => (string) $strDomain,
'grm_page_code' => (string) $strPageCode, 'grm_page_code' => (string) $strPageCode,
'grm_page_diff' => (string) $strDifference ?? '0', 'grm_page_diff' => (string) ($strDifference ?? '0'),
]; ];
$arrResult = self::getInstance()->getOne($arrFilter, self::$arrOptions); $arrResult = self::getInstance()->getOne($arrFilter, self::$arrOptions);
// chatgpt 给 处理 日志 重复插入报错
if (empty($arrResult)) { if (empty($arrResult)) {
// $intNum = mt_rand($intStartNumber, $intEndNumber);
// $arrGrmCode = self::$arrSelfClosing;
// shuffle($arrGrmCode);
// $arrGrmCode = array_slice($arrGrmCode, 0, $intNum);
// $strGrmCode = implode('', $arrGrmCode);
// $intRandNum = substr_count($strGrmCode, '%s');
// $arrRandStr = self::generateRandomStrings($intRandNum);
// $strGrmCode = sprintf($strGrmCode, ...$arrRandStr);
$arrGrmCode = []; $arrGrmCode = [];
while ($intNum-- > 0) { while ($intNum-- > 0) {
// $arrGrmCode[] = self::generateRandomCustomizeHtml(mt_rand(1, 3), mt_rand(3, 6));
$arrGrmCode[] = self::generateRandomCustomizeHtml(1, 1); $arrGrmCode[] = self::generateRandomCustomizeHtml(1, 1);
} }
$arrData = $arrFilter; $arrData = $arrFilter;
$arrData['grm_code'] = $arrGrmCode; $arrData['grm_code'] = $arrGrmCode;
self::getInstance()->insert($arrData); // ✅ 更安全的方式
} else { self::getInstance()->updateOne(
$arrGrmCode = $arrResult['grm_code']; $arrFilter,
} ['$setOnInsert' => ['grm_code' => $arrGrmCode]],
['upsert' => true]
);
return $arrGrmCode; return $arrGrmCode;
} else {
return $arrResult['grm_code'];
}
// if (empty($arrResult)) {
// $arrGrmCode = [];
// while ($intNum-- > 0) {
// // $arrGrmCode[] = self::generateRandomCustomizeHtml(mt_rand(1, 3), mt_rand(3, 6));
// $arrGrmCode[] = self::generateRandomCustomizeHtml(1, 1);
// }
// $arrData = $arrFilter;
// $arrData['grm_code'] = $arrGrmCode;
// self::getInstance()->insert($arrData);
// } else {
// $arrGrmCode = $arrResult['grm_code'];
// }
// return $arrGrmCode;
} }
static public function splitTagsToArray(string $htmlTags): array static public function splitTagsToArray(string $htmlTags): array

View File

@@ -294,8 +294,8 @@ class ChapterService
$arrNovel = $this->NovelModel->getNovelByNId($arrParams['n_id']); $arrNovel = $this->NovelModel->getNovelByNId($arrParams['n_id']);
$intButtonNum = $arrParams['button_num']; $intButtonNum = $arrParams['button_num'];
$intPage = $arrChapter['page']; $intPage = $arrChapter['page'] ?? 1;
$intLimit = $arrChapter['limit']; $intLimit = $arrChapter['limit'] ?? 10 ;
$strBaseUrl = app(NovelService::class)->getNovelCatalogUrl($arrParams['n_id'], $arrNovel['n_name_pinyin'], $arrParams['sort_type'], '{page}'); $strBaseUrl = app(NovelService::class)->getNovelCatalogUrl($arrParams['n_id'], $arrNovel['n_name_pinyin'], $arrParams['sort_type'], '{page}');
$arrPaginator = CusteomPage02::generate($intPage, $arrChapter['total'], $intLimit, $strBaseUrl, $intButtonNum); $arrPaginator = CusteomPage02::generate($intPage, $arrChapter['total'], $intLimit, $strBaseUrl, $intButtonNum);

View File

@@ -148,7 +148,7 @@ class NovelService
'intPage' => $intPage ?? 1, 'intPage' => $intPage ?? 1,
]); ]);
$strUrl = preg_replace('#/{2,}#', '/', $strUrl); $strUrl = preg_replace('#/{2,}#', '/', (string)$strUrl);
return (string)$strUrl; return (string)$strUrl;
} }
@@ -175,7 +175,7 @@ class NovelService
'intPage' => $intPage ?? 1, 'intPage' => $intPage ?? 1,
]); ]);
$strUrl = preg_replace('#/{2,}#', '/', $strUrl); $strUrl = preg_replace('#/{2,}#', '/', (string)$strUrl);
return (string)$strUrl; return (string)$strUrl;
} }
@@ -593,8 +593,8 @@ class NovelService
public function generateSearchPager(array $arrParams, array $arrSort, array $arrNovel): array public function generateSearchPager(array $arrParams, array $arrSort, array $arrNovel): array
{ {
$strKey = $arrParams['key']; $strKey = $arrParams['key'];
$intPage = $arrNovel['page']; $intPage = $arrNovel['page'] ?? 1;
$intLimit = $arrNovel['limit']; $intLimit = $arrNovel['limit'] ?? 10;
$intButtomNum = $arrParams['button_num']; $intButtomNum = $arrParams['button_num'];
$strBaseUrl = app(NovelService::class)->getNovelSearchUrl($strKey, '{page}'); $strBaseUrl = app(NovelService::class)->getNovelSearchUrl($strKey, '{page}');
$arrPaginator = CusteomPage02::generate($intPage, $arrNovel['total'], $intLimit, $strBaseUrl, $intButtomNum); $arrPaginator = CusteomPage02::generate($intPage, $arrNovel['total'], $intLimit, $strBaseUrl, $intButtomNum);

View File

@@ -360,13 +360,21 @@ class SiteContext
$strOrder = $this->Request->param('strOrder'); $strOrder = $this->Request->param('strOrder');
$strLang = $this->Request->param('strLang'); $strLang = $this->Request->param('strLang');
$intPage = $this->Request->param('intPage'); $intPage = $this->Request->param('intPage');
$strVYear = 'all';
if (!empty($strYear)) {
if (key_exists($strYear, StaticConfig::$arrVideoYear) && $strYear != 'all') {
$strVYear = StaticConfig::$arrVideoYear[$strYear];
}
}
ConverterMovel::setVal([ ConverterMovel::setVal([
'strVideoParentCategoryName' => empty($strParentCategory) || $strParentCategory == 'all' ? '' : StaticConfig::$arrVideoClass[$strParentCategory], 'strVideoParentCategoryName' => empty($strParentCategory) || $strParentCategory == 'all' ? '' : StaticConfig::$arrVideoClass[$strParentCategory],
'strVideoCategoryName' => empty($strCategory) || $strCategory == 'all' ? '' : VideoCategoryModel::$arrCategory[$strCategory], 'strVideoCategoryName' => empty($strCategory) || $strCategory == 'all' ? '' : VideoCategoryModel::$arrCategory[$strCategory],
'strAreaName' => empty($strArea) || $strArea == 'all' ? '' : StaticConfig::$arrVideoArea[$strArea], 'strAreaName' => empty($strArea) || $strArea == 'all' ? '' : StaticConfig::$arrVideoArea[$strArea],
'strLangName' => empty($strLang) || $strLang == 'all' ? '' : StaticConfig::$arrVideoLang[$strLang], 'strLangName' => empty($strLang) || $strLang == 'all' ? '' : StaticConfig::$arrVideoLang[$strLang],
'strOrderName' => empty($strOrder) || $strOrder == 'all' ? '' : StaticConfig::$arrVideoSortType[$strOrder], 'strOrderName' => empty($strOrder) || $strOrder == 'all' ? '' : StaticConfig::$arrVideoSortType[$strOrder],
'strYear' => empty($strYear) || $strYear == 'all' ? '' : StaticConfig::$arrVideoYear[$strYear], 'strYear' => $strVYear,
'intPage' => $intPage ?? 1, 'intPage' => $intPage ?? 1,
]); ]);
} }

View File

@@ -487,6 +487,7 @@ class VideoService
} }
} }
# v_year filter # v_year filter
if (!empty($strVYear)) { if (!empty($strVYear)) {
if (key_exists($strVYear, StaticConfig::$arrVideoYear) && $strVYear != 'all') { if (key_exists($strVYear, StaticConfig::$arrVideoYear) && $strVYear != 'all') {
@@ -634,7 +635,7 @@ class VideoService
{ {
$strKey = $arrParams['key']; $strKey = $arrParams['key'];
$intPage = $arrVideo['page'] ?? 1; $intPage = $arrVideo['page'] ?? 1;
$intLimit = $arrVideo['limit']; $intLimit = $arrVideo['limit'] ?? 10;
$intButtomNum = $arrParams['button_num']; $intButtomNum = $arrParams['button_num'];
$strBaseUrl = app(VideoService::class)->getVideoSearchUrl($strKey, '{page}'); $strBaseUrl = app(VideoService::class)->getVideoSearchUrl($strKey, '{page}');
$arrPaginator = CusteomPage02::generate($intPage, $arrVideo['total'], $intLimit, $strBaseUrl, $intButtomNum); $arrPaginator = CusteomPage02::generate($intPage, $arrVideo['total'], $intLimit, $strBaseUrl, $intButtomNum);
@@ -661,8 +662,8 @@ class VideoService
$strYear = $arrParams['v_year']; $strYear = $arrParams['v_year'];
$strOrder = $arrParams['sort_type']; $strOrder = $arrParams['sort_type'];
$intPage = $arrVideo['page']; $intPage = $arrVideo['page'] ?? 1;
$intLimit = $arrVideo['limit']; $intLimit = $arrVideo['limit'] ?? 10;
$intButtomNum = $arrParams['button_num']; $intButtomNum = $arrParams['button_num'];
$strBaseUrl = app(VideoService::class)->getVideoCategoryUrl($strCategory, $strParentCategory, $strArea, $strLang, $strYear, $strOrder, '{page}'); $strBaseUrl = app(VideoService::class)->getVideoCategoryUrl($strCategory, $strParentCategory, $strArea, $strLang, $strYear, $strOrder, '{page}');
$arrPaginator = CusteomPage02::generate($intPage, $arrVideo['total'], $intLimit, $strBaseUrl, $intButtomNum); $arrPaginator = CusteomPage02::generate($intPage, $arrVideo['total'], $intLimit, $strBaseUrl, $intButtomNum);