Last active
August 22, 2026 13:53
-
-
Save hipot/7938e44b2a34b588bc97420e4851a9d7 to your computer and use it in GitHub Desktop.
log 404 in content part
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // log 404 in content part | |
| $lastStatus = \CHTTP::GetLastStatus(); | |
| if ((constant('ERROR_404') == 'Y' || strpos($lastStatus, '404') !== false) | |
| && $APPLICATION->GetCurPage() != '/404.php' | |
| ) { | |
| /* | |
| CREATE TABLE `hi_seo_error404log` ( | |
| `ID` int(11) unsigned NOT NULL AUTO_INCREMENT, | |
| `UF_DATETIME` datetime DEFAULT NULL, | |
| `UF_URL` text, | |
| `UF_REFERER` text, | |
| `UF_USER_AGENT` text, | |
| `UF_ADDR` text, | |
| PRIMARY KEY (`ID`), | |
| KEY `IDX_DT` (`UF_DATETIME`) | |
| ); | |
| */ | |
| $error404TableEntity = Bitrix\Main\ORM\Entity::compileEntity('Error404LogTable', [ | |
| new Bitrix\Main\ORM\Fields\IntegerField('ID', [ | |
| 'primary' => true | |
| ]), | |
| new Bitrix\Main\ORM\Fields\DatetimeField('UF_DATETIME'), | |
| new Bitrix\Main\ORM\Fields\TextField('UF_URL'), | |
| new Bitrix\Main\ORM\Fields\TextField('UF_REFERER'), | |
| new Bitrix\Main\ORM\Fields\TextField('UF_USER_AGENT'), | |
| new Bitrix\Main\ORM\Fields\TextField('UF_ADDR'), | |
| ], [ | |
| 'table_name' => 'hi_seo_error404log' | |
| ]); | |
| $r = $error404TableEntity->getDataClass()::add([ | |
| 'UF_DATETIME' => \Bitrix\Main\Type\DateTime::createFromTimestamp(time()), | |
| 'UF_URL' => $APPLICATION->GetCurPageParam("", [], false), | |
| 'UF_REFERER' => $_SERVER['HTTP_REFERER'], // . var_export($_SERVER, true), | |
| 'UF_USER_AGENT' => $_SERVER['HTTP_USER_AGENT'], | |
| 'UF_ADDR' => $_SERVER['REMOTE_ADDR'] | |
| ]); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment