Server IP : 85.193.89.191 / Your IP : 3.128.205.47 Web Server : Apache System : Linux 956367-cx40159.tmweb.ru 3.10.0-1160.105.1.el7.x86_64 #1 SMP Thu Dec 7 15:39:45 UTC 2023 x86_64 User : bitrix ( 600) PHP Version : 8.1.27 Disable Function : NONE MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/bitrix/www/local/php_interface/include/ |
Upload File : |
<?php if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die(); /** * Redirects routine */ if(array_key_exists('REDIRECT_URL', $_SERVER) || array_key_exists('REQUEST_URI', $_SERVER)){ $tryUrl = trim($_SERVER['REDIRECT_URL'], '/'); if(empty($tryUrl)){ $tryUrl = trim($_SERVER['REQUEST_URI'], '/'); } if(strlen($tryUrl) > 1){ $newUrl = ''; require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/classes/general/csv_data.php"); $csvFile = new CCSVData('R', true); $filePath = $_SERVER['DOCUMENT_ROOT'] . '/upload/redirects.csv'; $csvFile->LoadFile($filePath); $bFirstHeaderTmp = $csvFile->GetFirstHeader(); $csvFile->SetDelimiter(';'); $csvFile->SetFirstHeader(true); while ($arRes = $csvFile->Fetch()) { if($arRes[0] == '/'.$tryUrl.'/'){ $newUrl = $arRes[1]; } } if(!$newUrl){ $res = CIBlockElement::GetList([], ['IBLOCK_ID' => CATALOG_IBLOCK_ID, 'CODE' => $tryUrl], false, false, ['ID','DETAIL_PAGE_URL']); if($arItem = $res->GetNext()){ $newUrl = $arItem['DETAIL_PAGE_URL']; } } /* if($newUrl){ CHTTP::SetStatus('301 Moved Permanently'); header('Location: ' . $newUrl); die(); } */ } }