コード例 #1
0
ファイル: counter.php プロジェクト: Satariall/izurit
 public static function onBeforeEndBufferContent()
 {
     $server = Context::getCurrent()->getServer();
     $ajax = $server->get("HTTP_BX_AJAX");
     if (SiteSpeed::isOn() && static::$enabled === true && $ajax === null && (!defined("ADMIN_SECTION") || ADMIN_SECTION !== true)) {
         Counter::injectIntoPage();
     }
 }
コード例 #2
0
ファイル: counterdata.php プロジェクト: rasuldev/torino
 public static function submitData($limit = 5)
 {
     if (!Catalog::isOn()) {
         return '\\' . __METHOD__ . '(5);';
     }
     $ids = array();
     $rows = array();
     $r = static::getList(array('order' => array('ID' => 'ASC'), 'limit' => $limit));
     while ($row = $r->fetch()) {
         $rows[] = array('type' => $row['TYPE'], 'data' => $row['DATA']);
         $ids[] = $row['ID'];
     }
     if (!empty($rows)) {
         // get queue size
         $totalCount = static::getCount();
         $queueSize = $totalCount > $limit ? $totalCount - $limit : 0;
         // send data
         $data = \http_build_query(array('op' => 'e', 'aid' => Counter::getAccountId(), 'ad[cd][value]' => base64_encode(json_encode($rows)), 'ad[cd][queue]' => $queueSize));
         if (strlen($data) > 30000) {
             if ($limit > 1) {
                 return '\\' . __METHOD__ . '(' . max(1, $limit - 1) . ');';
             }
         }
         $f = fsockopen('bitrix.info', 80, $errno, $errstr, 3);
         if ($f) {
             $out = "POST /bx_stat HTTP/1.1\r\n";
             $out .= "Host: bitrix.info\r\n";
             $out .= "Content-type: application/x-www-form-urlencoded\r\n";
             $out .= "Content-length: " . strlen($data) . "\r\n";
             $out .= "User-Agent: Bitrix Stats Counter\r\n";
             $out .= "Connection: Close\r\n";
             $out .= "\r\n";
             $out .= $data . "\r\n\r\n";
             fwrite($f, $out);
             $response = '';
             while (!feof($f)) {
                 $response .= fgets($f, 128);
             }
             fclose($f);
             // delete rows if service received data
             if (strpos($response, 'uid')) {
                 foreach ($ids as $id) {
                     static::delete($id);
                 }
             }
         }
     }
     return '\\' . __METHOD__ . '(5);';
 }
コード例 #3
0
ファイル: site_speed.php プロジェクト: Satariall/izurit
echo Loc::getMessage("MAIN_SITE_SPEED_NOTES");
echo EndNote();
?>
	</div>

</div>

<script type="text/javascript">

(function() {
	"use strict";
	var siteSpeed = new BX.Main.SiteSpeed("<?php 
echo CUtil::JSEscape(Analytics\Counter::getPrivateKey());
?>
", "<?php 
echo CUtil::JSEscape(Analytics\Counter::getAccountId());
?>
");

	BX.ready(function() {
		BX.bind(BX("site-speed-domains"), "change", drawStatForCurrentHost);
		drawStatForCurrentHost();
	});

	function drawStat(host)
	{
		var lastHitsData = null;
		var histoLoaded = false;
		var graphLoaded = false;

		siteSpeed.getHistoData(
コード例 #4
0
ファイル: class.php プロジェクト: Satariall/izurit
 protected function getServiceRequestParamsByType($type)
 {
     $a = array('uid' => $_COOKIE['BX_USER_ID'], 'aid' => \Bitrix\Main\Analytics\Counter::getAccountId(), 'count' => $this->arParams['PAGE_ELEMENT_COUNT'] + 10);
     // random choices
     if ($type == 'any_similar') {
         $possible = array('similar_sell', 'similar_view', 'similar');
         $type = $possible[array_rand($possible)];
     } elseif ($type == 'any_personal') {
         $possible = array('bestsell', 'personal');
         $type = $possible[array_rand($possible)];
     } elseif ($type == 'any') {
         $possible = array('similar_sell', 'similar_view', 'similar', 'bestsell', 'personal');
         $type = $possible[array_rand($possible)];
     }
     // configure
     if ($type == 'bestsell') {
         $a['op'] = 'sim_domain_items';
         $a['type'] = 'order';
         $a['domain'] = Bitrix\Main\Context::getCurrent()->getServer()->getHttpHost();
     } elseif ($type == 'personal') {
         $a['op'] = 'recommend';
     } elseif ($type == 'similar_sell') {
         $a['op'] = 'simitems';
         $a['eid'] = $this->arParams['ID'];
         $a['type'] = 'order';
     } elseif ($type == 'similar_view') {
         $a['op'] = 'simitems';
         $a['eid'] = $this->arParams['ID'];
         $a['type'] = 'view';
     } elseif ($type == 'similar') {
         $a['op'] = 'simitems';
         $a['eid'] = $this->arParams['ID'];
     } else {
         // unkonwn type
     }
     // get iblocks
     $iblocks = array();
     if (!empty($this->arParams['IBLOCK_ID'])) {
         $iblocks = array($this->arParams['IBLOCK_ID']);
     } else {
         $iblockList = array();
         /* catalog */
         $iblockIterator = \Bitrix\Catalog\CatalogIblockTable::getList(array('select' => array('IBLOCK_ID', 'PRODUCT_IBLOCK_ID')));
         while ($iblock = $iblockIterator->fetch()) {
             $iblock['IBLOCK_ID'] = (int) $iblock['IBLOCK_ID'];
             $iblock['PRODUCT_IBLOCK_ID'] = (int) $iblock['PRODUCT_IBLOCK_ID'];
             $iblockList[$iblock['IBLOCK_ID']] = $iblock['IBLOCK_ID'];
             if ($iblock['PRODUCT_IBLOCK_ID'] > 0) {
                 $iblockList[$iblock['PRODUCT_IBLOCK_ID']] = $iblock['PRODUCT_IBLOCK_ID'];
             }
         }
         /* iblock */
         $iblockIterator = \Bitrix\Iblock\IblockSiteTable::getList(array('select' => array('IBLOCK_ID'), 'filter' => array('@IBLOCK_ID' => $iblockList, '=SITE_ID' => $this->getSiteId())));
         while ($iblock = $iblockIterator->fetch()) {
             $iblocks[] = $iblock['IBLOCK_ID'];
         }
     }
     $a['ib'] = join('.', $iblocks);
     return $a;
 }
コード例 #5
0
		$this->AbortResultCache();
		ShowError(GetMessage("CATALOG_ELEMENT_NOT_FOUND"));
		@define("ERROR_404", "Y");
		if($arParams["SET_STATUS_404"]==="Y")
			CHTTP::SetStatus("404 Not Found");
	}
}

if(isset($arResult["ID"]))
{
	if (isset($arResult['counterData']))
	{
		// send counter data
		if (\Bitrix\Main\Analytics\Catalog::isOn())
		{
			\Bitrix\Main\Analytics\Counter::sendData('ct', $arResult['counterData']);
		}
	}

	if ('N' != $arParams['USE_ELEMENT_COUNTER'])
	{
		if (Loader::includeModule('iblock'))
		{
			CIBlockElement::CounterInc($arResult["ID"]);
		}
	}

	if (!isset($_SESSION["VIEWED_ENABLE"]) && isset($_SESSION["VIEWED_PRODUCT"]) && $_SESSION["VIEWED_PRODUCT"] != $arResult["ID"] && Loader::includeModule("sale"))
	{
		$_SESSION["VIEWED_ENABLE"] = "Y";
		$arFields = array(
コード例 #6
0
ファイル: counterdata.php プロジェクト: DarneoStudio/bitrix
 public static function submitData($limit = 50)
 {
     if (!Catalog::isOn()) {
         return '\\' . __METHOD__ . '();';
     }
     $rows = array();
     $r = static::getList(array('order' => array('ID' => 'ASC'), 'limit' => $limit));
     while ($row = $r->fetch()) {
         $rows[$row['ID']] = array('type' => $row['TYPE'], 'data' => $row['DATA']);
     }
     if (!empty($rows)) {
         // get queue size
         $totalCount = static::getCount();
         $queueSize = $totalCount > $limit ? $totalCount - $limit : 0;
         // set limit
         $dataSizeLimit = 45000;
         // make an optimal dataset
         $dataSize = strlen(base64_encode(json_encode(array_values($rows))));
         // records to delete
         $toDelete = array();
         if ($dataSize > $dataSizeLimit) {
             $reducedRows = array();
             foreach ($rows as $id => $row) {
                 $rowSize = strlen(base64_encode(json_encode(array_values($row))));
                 $reducedDataSize = strlen(base64_encode(json_encode(array_values($reducedRows))));
                 if ($rowSize > $dataSizeLimit) {
                     // abnormally big row, delete it
                     $toDelete[] = $id;
                 } elseif (!empty($reducedRows) && $reducedDataSize + $rowSize > $dataSizeLimit) {
                     // it's enough
                     break;
                 } else {
                     $reducedRows[$id] = $row;
                 }
             }
             $rows = $reducedRows;
         }
         if (!empty($rows)) {
             // if there are still some data, send it
             $data = \http_build_query(array('op' => 'e', 'aid' => Counter::getAccountId(), 'ad[cd][value]' => base64_encode(json_encode(array_values($rows))), 'ad[cd][queue]' => $queueSize));
             $f = fsockopen('bitrix.info', 80, $errno, $errstr, 3);
             if ($f) {
                 $out = "POST /bx_stat HTTP/1.1\r\n";
                 $out .= "Host: bitrix.info\r\n";
                 $out .= "Content-type: application/x-www-form-urlencoded\r\n";
                 $out .= "Content-length: " . strlen($data) . "\r\n";
                 $out .= "User-Agent: Bitrix Stats Counter\r\n";
                 $out .= "Connection: Close\r\n";
                 $out .= "\r\n";
                 $out .= $data . "\r\n\r\n";
                 fwrite($f, $out);
                 $response = '';
                 while (!feof($f)) {
                     $response .= fgets($f, 128);
                 }
                 fclose($f);
                 // delete rows if service received data
                 if (strpos($response, '200 OK')) {
                     $toDelete = array_merge($toDelete, array_keys($rows));
                 }
             }
         }
         // delete abnormally big and sent rows
         foreach ($toDelete as $id) {
             static::delete($id);
         }
     }
     return '\\' . __METHOD__ . '();';
 }
コード例 #7
0
ファイル: class.php プロジェクト: ASDAFF/1C_Bitrix_info_site
 protected function getServiceRequestParamsByType($type)
 {
     $a = array('uid' => $_COOKIE['BX_USER_ID'], 'aid' => \Bitrix\Main\Analytics\Counter::getAccountId(), 'count' => $this->arParams['PAGE_ELEMENT_COUNT'] + 10);
     // random choices
     if ($type == 'any_similar') {
         $possible = array('similar_sell', 'similar_view', 'similar');
         $type = $possible[array_rand($possible)];
     } elseif ($type == 'any_personal') {
         $possible = array('bestsell', 'personal');
         $type = $possible[array_rand($possible)];
     } elseif ($type == 'any') {
         $possible = array('similar_sell', 'similar_view', 'similar', 'bestsell', 'personal');
         $type = $possible[array_rand($possible)];
     }
     // configure
     if ($type == 'bestsell') {
         $a['op'] = 'sim_domain_items';
         $a['type'] = 'order';
         $a['domain'] = Bitrix\Main\Context::getCurrent()->getServer()->getHttpHost();
     } elseif ($type == 'personal') {
         $a['op'] = 'recommend';
     } elseif ($type == 'similar_sell') {
         $a['op'] = 'simitems';
         $a['eid'] = $this->arParams['ID'];
         $a['type'] = 'order';
     } elseif ($type == 'similar_view') {
         $a['op'] = 'simitems';
         $a['eid'] = $this->arParams['ID'];
         $a['type'] = 'view';
     } elseif ($type == 'similar') {
         $a['op'] = 'simitems';
         $a['eid'] = $this->arParams['ID'];
     } else {
         // unkonwn type
     }
     return $a;
 }