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

View File

@@ -211,36 +211,49 @@ class GanRaoMaModel extends MongoModel
$arrFilter = [
'grm_domain' => (string) $strDomain,
'grm_page_code' => (string) $strPageCode,
'grm_page_diff' => (string) $strDifference ?? '0',
'grm_page_diff' => (string) ($strDifference ?? '0'),
];
$arrResult = self::getInstance()->getOne($arrFilter, self::$arrOptions);
// chatgpt 给 处理 日志 重复插入报错
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 = [];
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);
$arrData['grm_code'] = $arrGrmCode;
// ✅ 更安全的方式
self::getInstance()->updateOne(
$arrFilter,
['$setOnInsert' => ['grm_code' => $arrGrmCode]],
['upsert' => true]
);
return $arrGrmCode;
} else {
$arrGrmCode = $arrResult['grm_code'];
return $arrResult['grm_code'];
}
return $arrGrmCode;
// 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

View File

@@ -294,8 +294,8 @@ class ChapterService
$arrNovel = $this->NovelModel->getNovelByNId($arrParams['n_id']);
$intButtonNum = $arrParams['button_num'];
$intPage = $arrChapter['page'];
$intLimit = $arrChapter['limit'];
$intPage = $arrChapter['page'] ?? 1;
$intLimit = $arrChapter['limit'] ?? 10 ;
$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);

View File

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

View File

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

View File

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