25 $docRoot = rtrim(\
Bitrix\Main\SiteTable::getDocumentRoot($site),
'/');
27 $url = str_replace(
'\\',
'/', $url);
28 $url = \CHTTP::urnEncode($url);
29 $uri =
new Web\Uri($url);
31 $path = \CHTTP::urnDecode($uri->getPath());
32 if (mb_substr($path, -1, 1) ==
'/')
35 $file =
new IO\File($docRoot.$path);
36 if ($file->isExists())
37 return mb_substr($file->getPath(), mb_strlen($docRoot));
39 if ($rewriteRules = AdminHelper::getRewriteRules($site))
41 $pathQuery = \CHTTP::urnDecode($uri->getPathQuery());
43 foreach ($rewriteRules as &$item)
45 if (preg_match($item[
'CONDITION'], $pathQuery))
47 $url = empty($item[
'PATH']) && !empty($item[
'RULE'])
48 ? preg_replace($item[
'CONDITION'], $item[
'RULE'], $pathQuery)
51 $url = \CHTTP::urnEncode($url);
52 $uri =
new Web\Uri($url);
54 $path = \CHTTP::urnDecode($uri->getPath());
56 $file =
new IO\File($docRoot.$path);
57 if ($file->isExists())
59 $pathTmp = str_replace(
'.',
'', mb_strtolower(ltrim($path,
'/\\')));
60 $pathTmp7 = mb_substr($pathTmp, 0, 7);
62 if ($pathTmp7 ==
'upload/' || $pathTmp7 ==
'bitrix/')
65 if ($file->getExtension() !=
'php')
68 return mb_substr($file->getPath(), mb_strlen($docRoot));
105 $cache = new \CPHPCache();
107 if ($cache->initCache(time()-strtotime(
'today'),
'abtest_site_capacity',
'/abtest'))
109 $capacity = $cache->getVars();
111 else if (Loader::includeModule(
'conversion'))
113 if ($conversionRates = Conversion\RateManager::getTypes(array(
'ACTIVE' =>
true)))
115 $baseRate = array_slice($conversionRates, 0, 1,
true);
119 $from = new \DateTime(
'first day of last month');
120 $to = new \DateTime(
'today');
124 $res = \Bitrix\Main\SiteTable::getList();
125 while ($site = $res->fetch())
129 $reportContext->setAttribute(
'conversion_site', $lid);
131 $rateData = reset($reportContext->getRatesDeprecated(
133 '>=DAY' =>
Type\Date::createFromPhp($from),
134 '<=DAY' =>
Type\Date::createFromPhp($to)
138 $reportContext->unsetAttribute(
'conversion_site', $lid);
140 $rate = $rateData[
'RATE'];
141 $hits = $rateData[
'DENOMINATOR'];
143 $daily = floor($hits / (date_diff($from, $to)->format(
'%a')+1));
145 $min = $rate > 0 && $rate < 1 ? ceil(16 * (1 / $rate - 1) / pow(
MIN_EFFECT, 2)) : 0;
146 $est = $daily ? $min / ($daily / 2) : 0;
148 $capacity[$lid] = array(
155 $cache->startDataCache(strtotime(
'tomorrow')-time());
156 $cache->endDataCache($capacity);
161 foreach ((array) $id as $lid)
162 $result[$lid] = isset($capacity[$lid]) ? $capacity[$lid] : array(
'min' => 0,
'est' => 0);
164 return is_array($id) ? $result : reset($result);
175 $cache = new \CPHPCache();
177 if ($cache->initCache(time()-strtotime(
'today'),
'abtest_capacity_'.intval($id),
'/abtest'))
179 $capacity = $cache->getVars();
181 else if (Loader::includeModule(
'conversion'))
183 if ($conversionRates = Conversion\RateManager::getTypes(array(
'ACTIVE' =>
true)))
185 if ($abtest = ABTestTable::getById($id)->fetch())
187 $lid = $abtest[
'SITE_ID'];
189 $baseRate = array_slice($conversionRates, 0, 1,
true);
194 $reportContext->setAttribute(
'abtest', $id);
196 $reportContext->setAttribute(
'abtest_section',
'A');
197 $groupAData = reset($reportContext->getRatesDeprecated($baseRate, array(),
null));
199 $reportContext->unsetAttribute(
'abtest_section',
'A');
200 $reportContext->setAttribute(
'abtest_section',
'B');
201 $groupBData = reset($reportContext->getRatesDeprecated($baseRate, array(),
null));
204 'A' => $groupAData[
'DENOMINATOR'],
205 'B' => $groupBData[
'DENOMINATOR']
208 $cache->startDataCache(strtotime(
'tomorrow')-time());
209 $cache->endDataCache($capacity);
214 return !empty($capacity) ? $capacity : array(
'A' => 0,
'B' => 0);