Your IP : 18.191.103.151


Current Path : /home/bitrix/ext_www/dev.klimatlend.ua/bitrix/php_interface/include/
Upload File :
Current File : /home/bitrix/ext_www/dev.klimatlend.ua/bitrix/php_interface/include/functions.php

<?
function pre($array) {
    global $USER;
    if ($USER->isAdmin()) {
        echo '<!--pre>';
        print_r($array);
        echo '</pre-->';
    }
}
function Redirect404() {

    if(ERROR_404=='Y' || CHTTP::GetLastStatus() == "404 Not Found")
    {

        global $APPLICATION;
        $APPLICATION->RestartBuffer();

        //include($_SERVER["DOCUMENT_ROOT"].SITE_TEMPLATE_PATH."/header.php");
        include($_SERVER["DOCUMENT_ROOT"].PATH_TO_404);
        //include($_SERVER["DOCUMENT_ROOT"].SITE_TEMPLATE_PATH."/footer.php");
    }
}
AddEventHandler("main", "OnEpilog", "My404PageInSiteStyle");
function My404PageInSiteStyle()
{
    global $APPLICATION;
    if (strpos($APPLICATION->GetCurPage(false), '/catalog/') !== false) {
        $curPage = trim($APPLICATION->GetCurPage(false), '/');
        $explodeCurPage = explode('/', $curPage);
        $elementCode = end($explodeCurPage);

        $arOrderEl = array('SORT' => 'ASC');
        $arFilterEl = array(
            'IBLOCK_ID' => CATALOG_RU_ID,
            'ACTIVE' => 'Y',
            '=CODE' => $elementCode
        );
        $arSelectFieldsEl = array(
            'CODE',
            'DETAIL_PAGE_URL'
        );
        $rsElements = CIBlockElement::GetList($arOrderEl, $arFilterEl, false, false, $arSelectFieldsEl);
        if ($arElement = $rsElements->GetNext()) {
            $detailPageUrl = $arElement['DETAIL_PAGE_URL'];
        }
        if (!empty($detailPageUrl)) {
            LocalRedirect($detailPageUrl, true, '301 Moved Permanently');
        }
    }

    if (defined('ERROR_404') && ERROR_404 == 'Y') {
        global $APPLICATION;
        $APPLICATION->RestartBuffer();

        include $_SERVER['DOCUMENT_ROOT'] . SITE_TEMPLATE_PATH . '/header.php';
        include $_SERVER['DOCUMENT_ROOT'] . '/404.php';
        include $_SERVER['DOCUMENT_ROOT'] . SITE_TEMPLATE_PATH . '/footer.php';
    }
}
function GetPriceFilePath($arFile)
{
    $originalPath = $_SERVER['DOCUMENT_ROOT'] . $arFile["SRC"];
    $arFile["ORIGINAL_NAME"] = $arFile["SUBDIR"]."/".$arFile["EXTERNAL_ID"]."/".$arFile["ORIGINAL_NAME"];

    $pathAlias = "/upload/price_list/". $arFile["ORIGINAL_NAME"];
    $fullPath = $_SERVER['DOCUMENT_ROOT'] . $pathAlias;

    $bFileExist = false;
    $io = CBXVirtualIo::GetInstance();

    if ($io->FileExists($fullPath))
    {
        /*$origHash = md5_file($originalPath);
        $aliasHahs = md5_file($fullPath);
        if ($origHash === $aliasHahs)
        {*/
            $bFileExist = true;
//        }
    }
    if (!$bFileExist)
    {
        $io->Copy($originalPath, $fullPath);
    }
    return $pathAlias;
}