%PDF- %PDF-
Server IP : 37.220.80.31 / Your IP : 3.142.173.89 Web Server : Apache/2.4.52 (Ubuntu) System : Linux 3051455-guretool.twc1.net 5.15.0-107-generic #117-Ubuntu SMP Fri Apr 26 12:26:49 UTC 2024 x86_64 User : www-root ( 1010) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/www-root/data/www/dev.artlot24.ru/bitrix/modules/main/lib/analytics/ |
Upload File : |
<?php namespace Bitrix\Main\Analytics; use Bitrix\Main\Config\Configuration; use Bitrix\Main\Context; use Bitrix\Main\Page\Asset; use Bitrix\Main\Page\AssetLocation; use Bitrix\Main\Text\JsExpression; class Counter { protected static $data = array(); protected static $enabled = true; protected static $bufferRestarted = false; public static function enable() { static::$enabled = true; } public static function disable() { static::$enabled = false; } public static function getInjectedJs($stripTags = false) { $accountId = static::getAccountId(); $params = static::injectDataParams(); $host = Context::getCurrent()->getServer()->getHttpHost(); $host = preg_replace("/:(80|443)$/", "", $host); $host = \CUtil::JSEscape($host); $js = <<<JS var _ba = _ba || []; _ba.push(["aid", "{$accountId}"]); _ba.push(["host", "{$host}"]); {$params} (function() { var ba = document.createElement("script"); ba.type = "text/javascript"; ba.async = true; ba.src = (document.location.protocol == "https:" ? "https://" : "http://") + "bitrix.info/ba.js"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ba, s); })(); JS; $js = str_replace(array("\n", "\t"), "", $js); if ($stripTags === false) { return "<script type=\"text/javascript\">".$js."</script>"; } else { return $js; } } public static function injectIntoPage() { Asset::getInstance()->addString(static::getInjectedJs(), false, AssetLocation::AFTER_JS); } public static function getAccountId() { if (defined("LICENSE_KEY")) { return md5("BITRIX".LICENSE_KEY."LICENCE"); } else { return ""; } } public static function getPrivateKey() { if (defined("LICENSE_KEY")) { return md5(LICENSE_KEY); } else { return ""; } } public static function onBeforeEndBufferContent() { $request = Context::getCurrent()->getRequest(); $isAjaxRequest = $request->isAjaxRequest(); $isAdminSection = defined("ADMIN_SECTION") && ADMIN_SECTION === true; if ($isAjaxRequest || $isAdminSection) { return; } $isSlider = $request->getQuery('IFRAME') === "Y"; if (static::$bufferRestarted === true && !$isSlider) { return; } $settings = Configuration::getValue("analytics_counter"); $forceEnabled = isset($settings["enabled"]) && $settings["enabled"] === true; if ($forceEnabled === false && SiteSpeed::isIntranetSite(SITE_ID)) { return; } if (SiteSpeed::isOn() && static::$enabled === true) { Counter::injectIntoPage(); } } public static function onBeforeRestartBuffer() { static::$bufferRestarted = true; } public static function sendData($id, array $arParams) { static::$data[$id] = $arParams; } private static function injectDataParams() { $result = ""; foreach (static::$data as $index => $arItem) { foreach ($arItem as $key => $value) { if (is_array($value)) { $jsValue = '"'.\CUtil::PhpToJSObject($value).'"'; } elseif ($value instanceof JsExpression) { $jsValue = $value; } else { $jsValue = '"'.\CUtil::JSEscape($value).'"'; } $result .= '_ba.push(["ad['.$index.']['.\CUtil::JSEscape($key).']", '.$jsValue.']);'; } } return $result; } }