3require_once(
$_SERVER[
"DOCUMENT_ROOT"].
"/bitrix/modules/statistic/classes/general/keepstatistic.php");
9 public static function GetAdvGuestHost($ADV_ID, $GUEST_ID, $IP_NUMBER, $BACK=
"")
12 $ADV_ID = intval($ADV_ID);
13 $GID = intval($GUEST_ID);
18 ".$DB->DateToCharFunction(
"max(DATE_HOST_HIT)",
"SHORT").
" MAX_DATE_HOST_HIT
20 WHERE ADV_ID=$ADV_ID and IP_NUMBER='".
$DB->ForSQL($IP_NUMBER).
"'
23 $rsResult=
$DB->Query($strSql);
24 if(!($arHost = $rsResult->Fetch()))
25 $arHost =
array(
"ADV_HOSTS"=>0,
"MAX_DATE_HOST_HIT"=>
false);
30 ".$DB->DateToCharFunction(
"max(DATE_GUEST_HIT)",
"SHORT").
" MAX_DATE_GUEST_HIT
32 WHERE ADV_ID=$ADV_ID and GUEST_ID=$GID
35 $rsResult=
$DB->Query($strSql);
36 if(!($arGuest = $rsResult->Fetch()))
37 $arGuest =
array(
"ADV_GUESTS"=>0,
"MAX_DATE_GUEST_HIT"=>
false);
39 $rsResult =
new CDBResult;
40 $rsResult->InitFromArray(
array(array_merge($arGuest,$arHost)));
44 public static function StartBuffer()
60 if (isset($_GET[
"show_link_stat"]))
62 if ($_GET[
"show_link_stat"]==
"Y")
64 $_SESSION[
"SHOW_LINK_STAT"] =
"Y";
66 elseif ($_GET[
"show_link_stat"]==
"N")
68 $_SESSION[
"SHOW_LINK_STAT"] =
"N";
84 "TEXT" =>
GetMessage(
"STAT_PAGE_GRAPH_PANEL_BUTTON"),
85 "TITLE" =>
GetMessage(
"STAT_PAGE_GRAPH_PANEL_BUTTON"),
86 "IMAGE" =>
"/bitrix/images/statistic/page_traffic.gif",
87 "ACTION" =>
"javascript:window.open('/bitrix/admin/section_graph_list.php?lang=". LANGUAGE_ID.
"&public=Y&width=".
$width.
"&height=".$height.
"§ion=".urlencode($CURRENT_PAGE).
"&set_default=Y','','target=_blank,scrollbars=yes,resizable=yes,width=".
$width.
",height=".$height.
",left='+Math.floor((screen.width - ".
$width.
")/2)+',top='+Math.floor((screen.height- ".$height.
")/2))",
91 "ICON" =>
"bx-panel-statistics-icon",
99 "TEXT" =>
GetMessage(
"STAT_PANEL_BUTTON_HINT"),
104 public static function EndBuffer(&
$content)
109 if (defined(
"ADMIN_SECTION") &&
ADMIN_SECTION===
true)
return;
116 function ShowStatLinkPage()
120 ShowStatLinkPageEx();
124 alert(
'<?echo GetMessage("STAT_LINK_STAT_PANEL_BUTTON_ALERT")?>');
132 $arUniqLink =
array();
133 $arHashLink =
array();
136 if(preg_match_all(
"#<a[^>]+?href\\s*=\\s*([\"'])(.*?)\\1#is",
$content,
$arr))
138 foreach(
$arr[2] as $link)
144 if (mb_strpos($link,
$_SERVER[
"HTTP_HOST"]) !==
false)
146 $arUniqLink[
crc32ex($link)] = $link;
154 if (
count($arUniqLink)>0)
160 $CURRENT_PAGE_CRC32 =
crc32ex($CURRENT_PAGE);
161 foreach($arUniqLink as $link_crc => $link)
163 if ($CURRENT_PAGE != $link)
172 PREV_PAGE_HASH = '".$CURRENT_PAGE_CRC32.
"'
173 and LAST_PAGE_HASH = '".$link_crc.
"'
177 $rs =
$DB->Query($strSql);
179 $CNT = intval(
$ar[
"CNT"]);
182 $arHashLink[$link_crc] =
array(
187 if($MAX ===
false || ($CNT > $MAX))
194 if((
count($arHashLink) > 0) && ($SUM > 0))
199 uasort($arHashLink,
"__SortLinkStat");
201 foreach($arHashLink as $link_crc => $arLink)
204 $arHashLink[$link_crc][
"ID"] =
$i;
205 $arHashLink[$link_crc][
"PERCENT"] = round((100*$arLink[
"CNT"])/$SUM, 1);
209 $pcre_backtrack_limit = intval(ini_get(
"pcre.backtrack_limit"));
212 if($pcre_backtrack_limit < $content_len)
213 @ini_set(
"pcre.backtrack_limit", $content_len);
215 $content = preg_replace_callback(
"#(<a[^>]+?href\\s*=\\s*)([\"'])(.*?)(\\2.*?>)(.*?)(</.+?>)#is",
"__ModifyATags",
$content);
221 div.stat_pages h2 { background-
color:#EEEEEE; font-family:Verdana,Arial,sans-serif; font-
size:82%; padding:4px 10px; }
222 div.stat_pages p { font-family:Verdana,Arial,sans-serif; font-
size:82%; }
223 div.stat_pages td { font-family:Verdana,Arial,sans-serif; font-
size:70%; border: 1px solid #BDC6E0; padding:3px; background-
color: white; }
225 div.stat_pages td.head { background-
color:#E6E9F4; }
226 div.stat_pages td.tail { background-
color:#EAEDF7; }
228 <div
class=
"stat_pages">
231 <table border=
"0" cellspacing=
"0" cellpadding=
"0" width=
"100%">
233 <td
class=
"head" align=
"center">#</td>
234 <td
class=
"head"><?=
GetMessage(
"STAT_LINK")?></td>
235 <td colspan=
"2" class=
"head"><?=
GetMessage(
"STAT_CLICKS")?></td>
236 <td
class=
"head">&
nbsp;</td>
239 $max_relation = ($MAX*100)/90;
240 foreach($arHashLink as
$ar):
241 $w = round((
$ar[
"CNT"]*100)/$max_relation);
244 <td valign=
"top" align=
"right" width=
"0%" nowrap><?=
$ar[
"ID"]?>.</td>
246 <td valign=
"top" align=
"right" width=
"5%" nowrap><?=
$ar[
"PERCENT"].
"%"?></td>
247 <td valign=
"top" align=
"right" width=
"5%" nowrap><?=
$ar[
"CNT"]?></td>
248 <td valign=
"top" nowrap
width=
"40%"><img src=
"/bitrix/images/statistic/votebar.gif" width=
"<?echo ($w==0) ? "0
" : $w."%
"?>" height=
"10" border=0 alt=
""></td>
252 <td
width=
"0%" colspan=
"3" nowrap
align=
"right" class=
"tail"><?echo
GetMessage(
"STAT_TOTAL")?></td>
253 <td
width=
"0%" nowrap
align=
"right" class=
"tail"><?=$SUM?></td>
254 <td
width=
"100%" class=
"tail">&
nbsp;</td>
257 <p><form><input type=
"button" onClick=
"window.close()" value=
"<?echo GetMessage("STAT_CLOSE
")?>"></form></p>
260 $stat_table = trim(ob_get_contents());
261 $js_table =
"wnd.document.write('".CUtil::JSEscape($stat_table).
"');";
268 function ShowStatLinkPageEx()
272 if(
height < screen.height-28)
273 top = Math.floor((screen.height -
height)/2-14);
274 if(
width < screen.width-10)
275 left = Math.floor((screen.width -
width)/2-5);
278 var wnd = window.open(
"",
"",
"scrollbars=yes,resizable=yes,width="+
width+
",height="+
height+
",left="+
left+
",top="+
top);
279 wnd.document.write(
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n");
280 wnd.document.write(
"<html><head>\n");
281 wnd.document.write(
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=<?echo LANG_CHARSET?>\">\n");
282 wnd.document.write(
"<"+
"script>\n");
283 wnd.document.write(
"<!--\n");
284 wnd.document.write(
"function KeyPress()\n");
285 wnd.document.write(
"{\n");
286 wnd.document.write(
" if(window.event.keyCode == 27)\n");
287 wnd.document.write(
" window.close();\n");
288 wnd.document.write(
"}\n");
289 wnd.document.write(
"//-->\n");
290 wnd.document.write(
"</"+
"script>\n");
291 wnd.document.write(
"<title><?=GetMessage("STAT_LINK_STAT_TITLE
")?></title></head>\n");
292 wnd.document.write(
"<body style=\"padding:10px;\" topmargin=\"0\" leftmargin=\"0\" marginwidth=\"0\" marginheight=\"0\" onKeyPress=\"KeyPress()\">\n");
294 wnd.document.write(
"</body>");
295 wnd.document.write(
"</html>");
296 wnd.document.close();
300 $js = ob_get_contents();
310 public static function DBDateCompare($FIELD_NAME, $DATE=
false, $DATE_FORMAT=
"SHORT")
315 $date =
$DB->CurrentDateFunction();
317 elseif(($DATE_FORMAT ==
"SHORT") && (
$DB->type ==
"MYSQL"))
319 $date =
"cast(".$DB->CharToDateFunction($DATE, $DATE_FORMAT).
" as date)";
323 $date =
$DB->CharToDateFunction($DATE, $DATE_FORMAT);
325 return " $FIELD_NAME = $date ";
328 public static function CleanUpStatistics_1()
331 if ((!isset($_SESSION[
"SESS_NO_AGENT_STATISTIC"]) || $_SESSION[
"SESS_NO_AGENT_STATISTIC"] !=
"Y") && !defined(
"NO_AGENT_STATISTIC"))
349 return "CStatistics::CleanUpStatistics_1();";
352 public static function CleanUpStatistics_2()
355 if ((!isset($_SESSION[
"SESS_NO_AGENT_STATISTIC"]) || $_SESSION[
"SESS_NO_AGENT_STATISTIC"] !=
"Y") && !defined(
"NO_AGENT_STATISTIC"))
360 return "CStatistics::CleanUpStatistics_2();";
366 public static function OnSearch($search_phrase)
369 if(intval($_SESSION[
"SESS_SEARCHER_ID"]) > 0)
372 if(COption::GetOptionString(
"statistic",
"SAVE_REFERERS") !=
"N")
374 if(!array_key_exists(
"SESS_PHRASE_ID", $_SESSION))
375 $_SESSION[
"SESS_PHRASE_ID"] =
array();
376 $search_phrase = mb_substr(trim($search_phrase), 0, 255);
377 if($search_phrase <>
'')
380 if(array_key_exists($search_phrase, $_SESSION[
"SESS_PHRASE_ID"]))
383 return "phrase_id=".$_SESSION[
"SESS_PHRASE_ID"][$search_phrase];
391 elseif(defined(
"SITE_ID"))
393 $sql_site =
"'".$DB->ForSql(
SITE_ID, 2).
"'";
402 "DATE_HIT" =>
$DB->GetNowFunction(),
403 "SEARCHER_ID" =>
'1',
404 "PHRASE" =>
"'".$DB->ForSql($search_phrase).
"'",
405 "SESSION_ID" => intval($_SESSION[
"SESS_SESSION_ID"]),
406 "SITE_ID" => $sql_site,
408 $_SESSION[
"SESS_PHRASE_ID"][$search_phrase] = $phrase_id =
$DB->Insert(
"b_stat_phrase_list",
$arFields,
"File: ".__FILE__.
"<br>Line: ".__LINE__);
410 while(
count($_SESSION[
"SESS_PHRASE_ID"]) > 10)
412 array_shift($_SESSION[
"SESS_PHRASE_ID"]);
419 "PHRASES" =>
"PHRASES + 1",
421 $DB->Update(
"b_stat_searcher",
$arFields,
"WHERE ID=1",
"File: ".__FILE__.
"<br>Line: ".__LINE__);
422 $_SESSION[
"SESS_FROM_SEARCHERS"][] = 1;
424 return "phrase_id=".$phrase_id;
434 public static function Update_Adv()
441 if (intval($_SESSION[
"SESS_ADV_ID"])>0)
444 $t = CStatistics::GetAdvGuestHost(
445 $_SESSION[
"SESS_ADV_ID"],
446 $_SESSION[
"SESS_GUEST_ID"],
447 $REMOTE_ADDR_NUMBER);
448 $MAX_DATE_GUEST_HIT =
"";
449 $MAX_DATE_HOST_HIT =
"";
452 while ($tr = $t->Fetch())
454 if ($guest_counter != 1)
455 $guest_counter = (intval($tr[
"ADV_GUESTS"])>0) ? 0 : 1;
456 if ($host_counter != 1)
457 $host_counter = (intval($tr[
"ADV_HOSTS"])>0) ? 0 : 1;
460 $MAX_DATE_GUEST_HIT = $tr[
"MAX_DATE_GUEST_HIT"];
463 $MAX_DATE_HOST_HIT = $tr[
"MAX_DATE_HOST_HIT"];
467 $new_guest_counter = ($_SESSION[
"SESS_GUEST_NEW"] ==
"Y") ? 1 : 0;
470 "GUESTS" =>
"GUESTS + ".$guest_counter,
471 "NEW_GUESTS" =>
"NEW_GUESTS + ".$new_guest_counter,
472 "C_HOSTS" =>
"C_HOSTS + ".$host_counter,
473 "SESSIONS" =>
"SESSIONS + 1"
480 $DB->Update(
"b_stat_adv",
$arFields,
"WHERE ID=".intval($_SESSION[
"SESS_ADV_ID"]),
'',
false,
false,
false);
482 $DB->Update(
"b_stat_adv",
array(
"DATE_FIRST"=>
$DB->GetNowFunction()),
"WHERE ID=".intval($_SESSION[
"SESS_ADV_ID"]).
" and DATE_FIRST is null",
'',
false,
false,
false);
488 $guest_day_counter = ($MAX_DATE_GUEST_HIT!=$now_date) ? 1 : 0;
489 $host_day_counter = ($MAX_DATE_HOST_HIT!=$now_date) ? 1 : 0;
491 $arFields[
"GUESTS_DAY"] =
"GUESTS_DAY + ".$guest_day_counter;
492 $arFields[
"C_HOSTS_DAY"] =
"C_HOSTS_DAY + ".$host_day_counter;
495 $rows =
$DB->Update(
"b_stat_adv_day",
$arFields,
"WHERE ADV_ID=".intval($_SESSION[
"SESS_ADV_ID"]).
" and ".CStatistics::DBDateCompare(
"DATE_STAT"),
'',
false,
false,
false);
497 if (intval(
$rows)<=0)
501 "ADV_ID" => intval($_SESSION[
"SESS_ADV_ID"]),
502 "DATE_STAT" =>
$DB->GetNowDate(),
503 "GUESTS" => $guest_counter,
505 "NEW_GUESTS" => $new_guest_counter,
506 "C_HOSTS" => $host_counter,
510 $DB->Insert(
"b_stat_adv_day",$arFields_i);
516 $strSql =
"SELECT ID FROM b_stat_adv_day WHERE ADV_ID=".intval($_SESSION[
"SESS_ADV_ID"]).
" and ".CStatistics::DBDateCompare(
"DATE_STAT").
" ORDER BY ID";
517 $rs =
$DB->Query($strSql);
518 while (
$ar =
$rs->Fetch())
523 $strSql =
"DELETE FROM b_stat_adv_day WHERE ID = ".$ar[
"ID"];
530 if (intval($guest_counter)==1 || intval($host_counter)==1)
534 "ADV_ID" => intval($_SESSION[
"SESS_ADV_ID"]),
535 "GUEST_ID" => intval($_SESSION[
"SESS_GUEST_ID"]),
536 "DATE_GUEST_HIT" =>
$DB->GetNowFunction(),
537 "DATE_HOST_HIT" =>
$DB->GetNowFunction(),
538 "SESSION_ID" => intval($_SESSION[
"SESS_SESSION_ID"]),
539 "IP_NUMBER" =>
"'".
$DB->ForSql($REMOTE_ADDR_NUMBER).
"'",
540 "IP" =>
"'".$DB->ForSql(
$_SERVER[
"REMOTE_ADDR"],15).
"'",
548 $arFields = Array(
"DATE_GUEST_HIT" =>
$DB->GetNowFunction());
549 $DB->Update(
"b_stat_adv_guest",
$arFields,
"WHERE ADV_ID=".intval($_SESSION[
"SESS_ADV_ID"]).
" and GUEST_ID=".intval($_SESSION[
"SESS_GUEST_ID"]).
" and BACK='N'");
552 $arFields = Array(
"DATE_HOST_HIT" =>
$DB->GetNowFunction());
553 $DB->Update(
"b_stat_adv_guest",
$arFields,
"WHERE ADV_ID=".intval($_SESSION[
"SESS_ADV_ID"]).
" and IP_NUMBER='".
$DB->ForSql($REMOTE_ADDR_NUMBER).
"' and BACK='N'");
556 $GLOBALS[
"APPLICATION"]->set_cookie(
"LAST_ADV", $_SESSION[
"SESS_ADV_ID"].
"_Y");
559 elseif (intval($_SESSION[
"SESS_LAST_ADV_ID"])>0)
562 $t = CStatistics::GetAdvGuestHost(
563 $_SESSION[
"SESS_LAST_ADV_ID"],
564 $_SESSION[
"SESS_GUEST_ID"],
567 $MAX_DATE_GUEST_HIT =
"";
568 $MAX_DATE_HOST_HIT =
"";
569 $guest_back_counter = 0;
570 $host_back_counter = 0;
571 while ($tr = $t->Fetch())
574 if ($guest_back_counter!=1) $guest_back_counter = (intval($tr[
"ADV_GUESTS"])>0) ? 0 : 1;
577 if ($host_back_counter!=1) $host_back_counter = (intval($tr[
"ADV_HOSTS"])>0) ? 0 : 1;
580 $MAX_DATE_GUEST_HIT = $tr[
"MAX_DATE_GUEST_HIT"];
583 $MAX_DATE_HOST_HIT = $tr[
"MAX_DATE_HOST_HIT"];
588 "GUESTS_BACK" =>
"GUESTS_BACK + ".$guest_back_counter,
589 "HOSTS_BACK" =>
"HOSTS_BACK + ".$host_back_counter,
590 "SESSIONS_BACK" =>
"SESSIONS_BACK + 1"
593 if($_SESSION[
"SESS_LAST_ADV_ID"] > 0)
596 $arFields[
"GUESTS_BACK"] =
"GUESTS_BACK";
598 $guest_back_counter = 0;
599 $host_back_counter = 0;
601 $DB->Update(
"b_stat_adv",
$arFields,
"WHERE ID=".intval($_SESSION[
"SESS_LAST_ADV_ID"]),
'',
false,
false,
false);
605 $guest_day_back_counter = ($MAX_DATE_GUEST_HIT!=$now_date) ? 1 : 0;
606 $host_day_back_counter = ($MAX_DATE_HOST_HIT!=$now_date) ? 1 : 0;
608 $arFields[
"GUESTS_DAY_BACK"] =
"GUESTS_DAY_BACK + ".$guest_day_back_counter;
609 $arFields[
"HOSTS_DAY_BACK"] =
"HOSTS_DAY_BACK + ".$host_day_back_counter;
612 $rows =
$DB->Update(
"b_stat_adv_day",
$arFields,
"WHERE ADV_ID=".intval($_SESSION[
"SESS_LAST_ADV_ID"]).
" and ".CStatistics::DBDateCompare(
"DATE_STAT"),
'',
false,
false,
false);
614 if (intval(
$rows)<=0)
618 "ADV_ID" => intval($_SESSION[
"SESS_LAST_ADV_ID"]),
619 "DATE_STAT" =>
$DB->GetNowDate(),
620 "GUESTS_BACK" => $guest_back_counter,
621 "GUESTS_DAY_BACK" => 1,
622 "HOSTS_BACK" => $host_back_counter,
623 "HOSTS_DAY_BACK" => 1,
632 $strSql =
"SELECT ID FROM b_stat_adv_day WHERE ADV_ID=".intval($_SESSION[
"SESS_LAST_ADV_ID"]).
" and ".CStatistics::DBDateCompare(
"DATE_STAT").
" ORDER BY ID";
633 $rs =
$DB->Query($strSql);
634 while (
$ar =
$rs->Fetch())
639 $strSql =
"DELETE FROM b_stat_adv_day WHERE ID = ".$ar[
"ID"];
647 if (intval($guest_back_counter)==1 || intval($host_back_counter)==1)
651 "ADV_ID" => intval($_SESSION[
"SESS_LAST_ADV_ID"]),
652 "GUEST_ID" => intval($_SESSION[
"SESS_GUEST_ID"]),
653 "DATE_GUEST_HIT" =>
$DB->GetNowFunction(),
654 "DATE_HOST_HIT" =>
$DB->GetNowFunction(),
655 "SESSION_ID" => intval($_SESSION[
"SESS_SESSION_ID"]),
656 "IP_NUMBER" =>
"'".
$DB->ForSql($REMOTE_ADDR_NUMBER).
"'",
657 "IP" =>
"'".$DB->ForSql(
$_SERVER[
"REMOTE_ADDR"],15).
"'",
665 $arFields = Array(
"DATE_GUEST_HIT" =>
$DB->GetNowFunction());
666 $DB->Update(
"b_stat_adv_guest",
$arFields,
"WHERE ADV_ID=".intval($_SESSION[
"SESS_LAST_ADV_ID"]).
" and GUEST_ID=".intval($_SESSION[
"SESS_GUEST_ID"]).
" and BACK='Y'");
669 $arFields = Array(
"DATE_HOST_HIT" =>
$DB->GetNowFunction());
670 $DB->Update(
"b_stat_adv_guest",
$arFields,
"WHERE ADV_ID=".intval($_SESSION[
"SESS_LAST_ADV_ID"]).
" and IP_NUMBER='".
$DB->ForSql($REMOTE_ADDR_NUMBER).
"' and BACK='Y'");
673 $GLOBALS[
"APPLICATION"]->set_cookie(
"LAST_ADV", $_SESSION[
"SESS_LAST_ADV_ID"]);
680 public static function Set_Adv()
687 (!isset($_SESSION[
"SESS_SESSION_ID"]) || intval($_SESSION[
"SESS_SESSION_ID"])<=0)
688 && (!isset($_SESSION[
"SESS_ADV_ID"]) || intval($_SESSION[
"SESS_ADV_ID"])<=0)
700 $site_name = $PROT.$SN;
709 b_stat_adv_searcher S,
710 b_stat_searcher_params P
713 and P.SEARCHER_ID = S.SEARCHER_ID
714 and upper('".$DB->ForSql(trim($site_name),2000).
"')
715 like ".
$DB->Concat(
"'%'",
"upper(P.DOMAIN)",
"'%'").
"
717 $w =
$DB->Query($strSql);
718 while ($wr=$w->Fetch())
720 $ref1 = $wr[
"REFERER1"];
721 $ref2 = $wr[
"REFERER2"];
722 $arrADV[] = intval($wr[
"ADV_ID"]);
726 $site_name = $PROT.$SN.$PAGE_FROM;
731 if ($_SESSION[
"referer1"] <>
'' || $_SESSION[
"referer2"] <>
'')
733 CAdv::SetByReferer(trim($_SESSION[
"referer1"]), trim($_SESSION[
"referer2"]), $arrADV, $ref1, $ref2);
736 if(COption::GetOptionString(
"statistic",
"OPENSTAT_ACTIVE") ===
"Y" &&
$_REQUEST[
"_openstat"] <>
'')
739 if(mb_strpos($openstat,
";") ===
false)
740 $openstat = base64_decode($openstat);
741 $openstat = explode(
";", $openstat);
744 array(
"#service-name#",
"#campaign-id#",
"#ad-id#",
"#source-id#"),
746 COption::GetOptionString(
"statistic",
"OPENSTAT_R1_TEMPLATE")
749 array(
"#service-name#",
"#campaign-id#",
"#ad-id#",
"#source-id#"),
751 COption::GetOptionString(
"statistic",
"OPENSTAT_R2_TEMPLATE")
753 $arrADV, $ref1, $ref2
756 $arrADV = array_unique($arrADV);
759 if (
count($arrADV)>1)
762 $str = implode(
",",$arrADV);
763 $strSql =
"SELECT ID, REFERER1, REFERER2 FROM b_stat_adv WHERE ID in ($str) ORDER BY PRIORITY desc, ID desc";
764 $z =
$DB->Query($strSql);
766 $_SESSION[
"SESS_ADV_ID"] = intval(
$zr[
"ID"]);
767 $_SESSION[
"referer1"] =
$zr[
"REFERER1"];
768 $_SESSION[
"referer2"] =
$zr[
"REFERER2"];
773 $_SESSION[
"SESS_ADV_ID"] = intval($value);
774 $_SESSION[
"referer1"] = $ref1;
775 $_SESSION[
"referer2"] = $ref2;
778 if (intval($_SESSION[
"SESS_ADV_ID"])>0) $_SESSION[
"SESS_LAST_ADV_ID"] = $_SESSION[
"SESS_ADV_ID"];
779 $_SESSION[
"SESS_LAST_ADV_ID"] = intval($_SESSION[
"SESS_LAST_ADV_ID"] ?? 0);
785 public static function Set_Guest()
799 if (defined(
"ADMIN_SECTION") &&
ADMIN_SECTION===
true) $sql_site =
"null";
801 else $sql_site =
"null";
803 $ERROR_404 = (defined(
"ERROR_404") && ERROR_404==
"Y") ?
"Y" :
"N";
804 $REPAIR_COOKIE_GUEST =
"N";
805 if (!isset($_SESSION[
"SESS_GUEST_NEW"])) $_SESSION[
"SESS_GUEST_NEW"] =
"N";
806 $_SESSION[
"SESS_GUEST_ID"] = intval($_SESSION[
"SESS_GUEST_ID"] ?? 0);
809 $COOKIE_GUEST_ID = intval(
$APPLICATION->get_cookie(
"GUEST_ID"));
810 if($COOKIE_GUEST_ID==0) $COOKIE_GUEST_ID = intval($_SESSION[
"SESS_GUEST_ID"]);
813 if (!isset($_SESSION[
"SESS_SESSION_ID"]) || intval($_SESSION[
"SESS_SESSION_ID"])<=0)
818 if (!($qr=$q->Fetch()))
821 $_SESSION[
"SESS_GUEST_ID"] = 0;
822 $_SESSION[
"SESS_GUEST_NEW"] =
"Y";
823 $_SESSION[
"SESS_GUEST_FAVORITES"] =
"N";
825 if ($COOKIE_GUEST_ID>0)
827 $_SESSION[
"SESS_GUEST_NEW"] =
"N";
830 if ($LAST_VISIT =
MkDateTime(
$GLOBALS[
"APPLICATION"]->get_cookie(
"LAST_VISIT"),
"d.m.Y H:i:s"))
834 if ($DATE_INSTALL==
"NOT_FOUND")
836 $DATE_INSTALL = date(
"d.m.Y H:i:s",time());
837 COption::SetOptionString(
"main",
"INSTALL_STATISTIC_TABLES", $DATE_INSTALL,
"Installation date of Statistics module tables");
839 if ($DATE_INSTALL =
MkDateTime($DATE_INSTALL,
"d.m.Y H:i:s"))
842 if ($DATE_INSTALL>$LAST_VISIT)
845 $_SESSION[
"SESS_GUEST_NEW"] =
"Y";
850 $REPAIR_COOKIE_GUEST =
"Y";
852 $COOKIE_ADV =
$GLOBALS[
"APPLICATION"]->get_cookie(
"LAST_ADV");
858 $_SESSION[
"SESS_GUEST_FAVORITES"] = $qr[
"FAVORITES"];
859 $_SESSION[
"SESS_GUEST_FAVORITES"] = ($_SESSION[
"SESS_GUEST_FAVORITES"]==
"Y") ?
"Y" :
"N";
860 if (!isset($_SESSION[
"SESS_GUEST_NEW"])) $_SESSION[
"SESS_GUEST_NEW"] =
"N";
861 $_SESSION[
"SESS_GUEST_ID"] = intval($qr[
"ID"]);
862 $_SESSION[
"SESS_LAST_ADV_ID"]=intval($qr[
"LAST_ADV_ID"]);
863 $_SESSION[
"SESS_LAST_USER_ID"] = intval($qr[
"LAST_USER_ID"]);
864 $_SESSION[
"SESS_LAST"] = $qr[
"LAST"];
865 if ($_SESSION[
"SESS_LAST_ADV_ID"]>0)
867 $strSql =
"SELECT REFERER1, REFERER2 FROM b_stat_adv WHERE ID=".$_SESSION[
"SESS_LAST_ADV_ID"];
868 $w =
$DB->Query($strSql);
869 if ($wr = $w->Fetch())
871 $last_referer1 = $wr[
"REFERER1"];
872 $last_referer2 = $wr[
"REFERER2"];
879 if ($_SESSION[
"SESS_GUEST_ID"]<=0)
883 "FIRST_DATE" =>
$DB->GetNowFunction(),
884 "FIRST_URL_FROM" =>
"'".$DB->ForSql(
$_SERVER[
"HTTP_REFERER"] ??
'', 2000).
"'",
886 "FIRST_URL_TO_404" =>
"'".
$DB->ForSql($ERROR_404).
"'",
887 "FIRST_SITE_ID" => $sql_site,
888 "FIRST_ADV_ID" => intval($_SESSION[
"SESS_ADV_ID"]) ,
889 "FIRST_REFERER1" =>
"'".
$DB->ForSql($_SESSION[
"referer1"],255).
"'",
890 "FIRST_REFERER2" =>
"'".$DB->ForSql($_SESSION[
"referer2"],255).
"'",
891 "FIRST_REFERER3" =>
"'".$DB->ForSql($_SESSION[
"referer3"],255).
"'"
894 if ($REPAIR_COOKIE_GUEST==
"Y")
897 if ($_SESSION[
"SESS_GUEST_NEW"]==
"N")
$arFields[
"SESSIONS"] = 1;
899 $COOKIE_ADV = intval($COOKIE_ADV);
903 $strSql =
"SELECT REFERER1, REFERER2 FROM b_stat_adv WHERE ID='".$COOKIE_ADV.
"'";
904 $w =
$DB->Query($strSql);
906 if ($wr = $w->Fetch())
909 $_SESSION[
"SESS_LAST_ADV_ID"] = $COOKIE_ADV;
913 $arFields[
"FIRST_REFERER1"] =
"'".$DB->ForSql($wr[
"REFERER1"],255).
"'";
914 $arFields[
"FIRST_REFERER2"] =
"'".$DB->ForSql($wr[
"REFERER2"],255).
"'";
917 $arFields[
"LAST_REFERER1"] =
"'".$DB->ForSql($wr[
"REFERER1"],255).
"'";
918 $arFields[
"LAST_REFERER2"] =
"'".$DB->ForSql($wr[
"REFERER2"],255).
"'";
919 $last_referer1 = $wr[
"REFERER1"];
920 $last_referer2 = $wr[
"REFERER2"];
924 $_SESSION[
"SESS_GUEST_ID"] =
$DB->Insert(
"b_stat_guest",
$arFields);
927 CStatistics::Set404(
"b_stat_guest",
"ID = ".intval($_SESSION[
"SESS_GUEST_ID"]),
array(
"FIRST_URL_TO_404" =>
"Y"));
932 if (is_object(
$USER) && intval(
$USER->GetID())>0)
935 $_SESSION[
"SESS_LAST_USER_ID"] = intval(
$USER->GetID());
937 if (intval($_SESSION[
"SESS_LAST_USER_ID"] ?? 0) <= 0)
939 $_SESSION[
"SESS_LAST_USER_ID"] =
"";
942 if ($_SESSION[
"SESS_GUEST_ID"]>0)
945 $GLOBALS[
"APPLICATION"]->set_cookie(
"GUEST_ID", $_SESSION[
"SESS_GUEST_ID"]);
948 $GLOBALS[
"APPLICATION"]->set_cookie(
"LAST_VISIT", date(
"d.m.Y H:i:s",time()));
951 "last_referer1" => $last_referer1,
952 "last_referer2" => $last_referer2,
960 public static function BlockVisitorActivity()
965 if(defined(
"STATISTIC_SKIP_ACTIVITY_CHECK"))
967 if(COption::GetOptionString(
"statistic",
"DEFENCE_ON")==
"Y")
969 $_SESSION[
"SESS_SEARCHER_CHECK_ACTIVITY"] = (isset($_SESSION[
"SESS_SEARCHER_CHECK_ACTIVITY"]) && $_SESSION[
"SESS_SEARCHER_CHECK_ACTIVITY"]==
"N") ?
"N" :
"Y";
972 !isset($_SESSION[
"SESS_SEARCHER_ID"])
973 || intval($_SESSION[
"SESS_SEARCHER_ID"]) <= 0
974 || $_SESSION[
"SESS_SEARCHER_CHECK_ACTIVITY"] ==
"Y"
985 if (!empty($_SESSION[
"SESS_GRABBER_STOP_TIME"]))
988 if (($stmp - $_SESSION[
"SESS_GRABBER_STOP_TIME"]) <=
$DEFENCE_DELAY)
991 $_SESSION[
"SESS_GRABBER_DEFENCE_STACK"] = [];
997 $_SESSION[
"SESS_GRABBER_STOP_TIME"] =
"";
1003 !isset($_SESSION[
"SESS_GRABBER_DEFENCE_STACK"])
1004 || !is_array($_SESSION[
"SESS_GRABBER_DEFENCE_STACK"])
1007 $_SESSION[
"SESS_GRABBER_DEFENCE_STACK"] = [];
1009 $_SESSION[
"SESS_GRABBER_DEFENCE_STACK"][] = $stmp;
1012 $first_element = reset($_SESSION[
"SESS_GRABBER_DEFENCE_STACK"]);
1013 $current_stack_length = $stmp - $first_element;
1014 while ($current_stack_length > $STACK_TIME &&
count($_SESSION[
"SESS_GRABBER_DEFENCE_STACK"]) > 0)
1016 $first_element = array_shift($_SESSION[
"SESS_GRABBER_DEFENCE_STACK"]);
1017 $current_stack_length = $stmp - $first_element;
1021 $STACK_HITS =
count($_SESSION[
"SESS_GRABBER_DEFENCE_STACK"]);
1023 if ($STACK_HITS > $MAX_STACK_HITS)
1026 $_SESSION[
"SESS_GRABBER_STOP_TIME"] = $stmp;
1028 if (COption::GetOptionString(
"statistic",
"DEFENCE_LOG") ===
"Y")
1030 "#ACTIVITY_TIME_LIMIT#" => $STACK_TIME,
1031 "#ACTIVITY_HITS#" => $STACK_HITS,
1032 "#ACTIVITY_EXCEEDING#" => $STACK_HITS - $MAX_STACK_HITS,
1036 if ($_SESSION[
"ACTIVITY_EXCEEDING_NOTIFIED"] !=
"Y")
1041 $arSite = $rsSite->Fetch();
1047 $arSite = $rsSite->Fetch();
1051 $SESSION_LINK = intval($_SESSION[
"SESS_SESSION_ID"]) > 0 ?
"/bitrix/admin/session_list.php?lang=". $arSite[
"LANGUAGE_ID"].
"&find_id=".$_SESSION[
"SESS_SESSION_ID"].
"&find_id_exact_match=Y&set_filter=Y" :
"";
1052 $VISITOR_LINK = intval($_SESSION[
"SESS_GUEST_ID"]) > 0 ?
"/bitrix/admin/guest_list.php?lang=". $arSite[
"LANGUAGE_ID"].
"&find_id=".$_SESSION[
"SESS_GUEST_ID"].
"&find_id_exact_match=Y&set_filter=Y" :
"";
1055 $STOPLIST_LINK =
"/bitrix/admin/stoplist_edit.php?lang=". $arSite[
"LANGUAGE_ID"].
"&net1=".intval(
$arr[0]).
"&net2=".intval(
$arr[1]).
"&net3=". intval(
$arr[2]).
"&net4=".intval(
$arr[3]).
"&user_agent=".urlencode(
$_SERVER[
"HTTP_USER_AGENT"]);
1057 $SEARCHER_LINK = intval($_SESSION[
"SESS_SEARCHER_ID"]) > 0 ?
"/bitrix/admin/hit_searcher_list.php?lang=". $arSite[
"LANGUAGE_ID"].
"&find_searcher_id=".$_SESSION[
"SESS_SEARCHER_ID"].
"&set_filter=Y" :
"";
1059 $arEventFields =
array(
1060 "ACTIVITY_TIME_LIMIT" => $STACK_TIME,
1061 "ACTIVITY_HITS" => $STACK_HITS,
1062 "ACTIVITY_HITS_LIMIT" => $MAX_STACK_HITS,
1063 "ACTIVITY_EXCEEDING" => $STACK_HITS - $MAX_STACK_HITS,
1064 "CURRENT_TIME" =>
GetTime($stmp,
"FULL", $arSite[
"ID"]),
1066 "USER_AGENT" =>
$_SERVER[
"HTTP_USER_AGENT"],
1067 "SESSION_ID" => $_SESSION[
"SESS_SESSION_ID"],
1068 "SESSION_LINK" => $SESSION_LINK,
1069 "SERACHER_ID" => $_SESSION[
"SESS_SEARCHER_ID"],
1070 "SEARCHER_NAME" => $_SESSION[
"SESS_SEARCHER_NAME"],
1071 "SEARCHER_LINK" => $SEARCHER_LINK,
1072 "VISITOR_ID" => $_SESSION[
"SESS_GUEST_ID"],
1073 "VISITOR_LINK" => $VISITOR_LINK,
1074 "STOPLIST_LINK" => $STOPLIST_LINK,
1075 "EMAIL_TO" => COption::GetOptionString(
"main",
"email_from",
""),
1080 $_SESSION[
"ACTIVITY_EXCEEDING_NOTIFIED"] =
"Y";
1089 public static function GetAuditTypes()
1092 "STAT_ACTIVITY_LIMIT" =>
"[STAT_ACTIVITY_LIMIT] ".
GetMessage(
"STAT_DEFENCE_LOG_EVENT"),
1096 public static function Set404($table =
false, $where =
false, $arrUpdate =
false)
1099 static $STAT_DB_404 =
array();
1101 if($table !==
false)
1103 if($table <>
'' && $where <>
'' && is_array($arrUpdate))
1105 foreach($arrUpdate as $field => $value)
1107 $STAT_DB_404[
$table][$where][$field] =
"'".$DB->ForSql($value).
"'";
1113 if(defined(
"ERROR_404") && ERROR_404==
"Y")
1115 foreach($STAT_DB_404 as $table => $arrWhere)
1117 foreach($arrWhere as $where =>
$arFields)
1119 $DB->Update($table,
$arFields,
"WHERE ".$where,
"File: ".__FILE__.
"<br>Line: ".__LINE__);
1120 unset($STAT_DB_404[$table][$where]);
1122 unset($STAT_DB_404[$table]);
1124 $STAT_DB_404 =
array();
1132 public static function CleanUp($cleanup_date=
"", &$arErrors)
1134 $err_mess =
"File: ".__FILE__.
"<br>Line: ";
1136 if ($cleanup_date ==
'')
1138 $fname =
$_SERVER[
"DOCUMENT_ROOT"].
"/bitrix/modules/statistic/install/db/".mb_strtolower(
$DB->type).
"/clean_up.sql";
1139 if (file_exists($fname))
1141 $arErrors =
$DB->RunSQLBatch($fname);
1144 $fname =
$_SERVER[
"DOCUMENT_ROOT"].
"/bitrix/modules/statistic/install/db/".mb_strtolower(
$DB->type).
"/adv.sql";
1145 $arErrors2 =
$DB->RunSQLBatch($fname);
1146 if (!$arErrors2)
return true;
else
1148 $arErrors = array_merge($arErrors, $arErrors2);
1161 "b_stat_adv_guest" =>
"DATE_HOST_HIT",
1162 "b_stat_adv_day" =>
"DATE_STAT",
1163 "b_stat_adv_event_day" =>
"DATE_STAT",
1164 "b_stat_day" =>
"DATE_STAT",
1165 "b_stat_day_site" =>
"DATE_STAT",
1166 "b_stat_event_day" =>
"DATE_STAT",
1167 "b_stat_event_list" =>
"DATE_ENTER",
1168 "b_stat_guest" =>
"LAST_DATE",
1169 "b_stat_hit" =>
"DATE_HIT",
1170 "b_stat_searcher_hit" =>
"DATE_HIT",
1171 "b_stat_phrase_list" =>
"DATE_HIT",
1172 "b_stat_referer" =>
"DATE_LAST",
1173 "b_stat_referer_list" =>
"DATE_HIT",
1174 "b_stat_searcher_day" =>
"DATE_STAT",
1175 "b_stat_session" =>
"DATE_LAST",
1176 "b_stat_page" =>
"DATE_STAT",
1177 "b_stat_country_day" =>
"DATE_STAT",
1178 "b_stat_path" =>
"DATE_STAT"
1181 foreach ($arrTables as $table_name => $date_name)
1193 public static function RecountBaseCurrency($new_base_currency)
1199 if (CModule::IncludeModule(
"currency"))
1204 if ($rate!=1 && $rate>0)
1207 array(
"TABLE" =>
"b_stat_adv",
"FIELDS" =>
array(
"COST",
"REVENUE")),
1208 array(
"TABLE" =>
"b_stat_event",
"FIELDS" =>
array(
"MONEY")),
1209 array(
"TABLE" =>
"b_stat_event_day",
"FIELDS" =>
array(
"MONEY")),
1210 array(
"TABLE" =>
"b_stat_event_list",
"FIELDS" =>
array(
"MONEY"))
1213 ignore_user_abort(
true);
1214 $DB->StartTransaction();
1215 foreach ($arUpdate as
$arr)
1218 $strSql =
"UPDATE ".$arr[
"TABLE"].
" SET ";
1224 $str .= $field.
" = round(".$field.
"*".$rate.
",2)";
1227 $DB->Query($strSql.$str);
1237 public static function GetEventParam(
$site_id =
false)
1242 public static function Set_Event($event1, $event2 =
"", $event3 =
"", $goto =
"", $money =
"",
$currency =
"", $chargeback =
"N",
$site_id =
false)
1247 public static function CheckForDDL()
1250 $rs=
$DB->Query(
"select count(*) CNT from b_stat_ddl",
true);
1254 if(
$ar && intval(
$ar[
"CNT"])>0)
1262 public static function GetDDL()
1266 $rs=
$DB->Query(
"select * from b_stat_ddl order by ID",
true);
1275 public static function ExecuteDDL(
$ID)
1279 $rs=
$DB->Query(
"select * from b_stat_ddl where ID=".
$ID,
true);
1285 if(
$DB->Query(
$ar[
"SQL_TEXT"],
true))
1291 if(mb_strpos(
$DB->db_Error,
"Duplicate key name") === 0) $bSuccess=
true;
1292 if(mb_strpos(
$DB->db_Error,
"Can't DROP") === 0) $bSuccess=
true;
1294 if(mb_strpos(
$DB->db_Error,
"ORA-00955") === 0) $bSuccess=
true;
1295 if(mb_strpos(
$DB->db_Error,
"ORA-01418") === 0) $bSuccess=
true;
1297 if(mb_strpos(
$DB->db_Error,
"#S0011") === 0) $bSuccess=
true;
1298 if(mb_strpos(
$DB->db_Error,
"#S0002") === 0) $bSuccess=
true;
1303 $DB->Query(
"delete from b_stat_ddl where ID=".
$ID,
true);
static SetByPage($page, &$arrADV, &$ref1, &$ref2, $type="TO")
static SetByReferer($referer1, $referer2, &$arrADV, &$ref1, &$ref2)
static GetByID($currency)
static GetConvertFactor($curFrom, $curTo, $valDate="")
static GetModuleConnection($module_id, $bModuleInclude=false)
static GetOptionString($module_id, $name, $def="", $site=false, $bExactSite=false)
static GetOptionInt($module_id, $name, $def="", $site=false)
static SetOptionString($module_id, $name, $value="", $desc=false, $site="")
static AddCurrent($event1, $event2="", $event3="", $money="", $currency="", $goto="", $chargeback="N", $site_id=false)
static GetGID($site_id=false)
static Send($event, $lid, $arFields, $Duplicate="Y", $message_id="", $files=[], $languageId='')
static Log($SEVERITY, $AUDIT_TYPE_ID, $MODULE_ID, $ITEM_ID, $DESCRIPTION=false, $SITE_ID=false)
static CleanUpCountries()
static CleanUpPathDynamic()
static CleanUpAdvDynamic()
static CleanUpSearcherHits()
static CleanUpRefererList()
static CleanUpPathCache()
static CleanUpEventDynamic()
static CleanUpAdvGuests()
static CleanUpTableByDate($cleanup_date, $table_name, $date_name)
static CleanUpSearcherDynamic()
hidden PROPERTY[<?=$propertyIndex?>][CODE]<?=htmlspecialcharsEx( $propertyCode)?> height
bx popup label bx width30 PAGE_NEW_MENU_NAME text width
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
bx_acc_lim_group_list limitGroupList[] multiple<?=$group[ 'ID']?> ID selected margin top
hidden mSiteList<?=htmlspecialcharsbx(serialize( $siteList))?><?=htmlspecialcharsbx( $siteList[ $j]["ID"])?> _Propery<? if(((COption::GetOptionString( $module_id, "different_set", "N")=="Y") &&( $j !=0))||(COption::GetOptionString( $module_id, "different_set", "N")=="N")) echo "display: none;"?> top adm detail content cell l top adm detail content cell r heading center center ID left
$_SERVER["DOCUMENT_ROOT"]
if(preg_match('/^ else[a-z0-9_]{2}$/i', $siteID)===1)
if( $adminSidePanelHelper->isSidePanel())
ConvertDateTime($datetime, $to_format=false, $from_site=false, $bSearchInSitesOnly=false)
InsertSpaces($sText, $iMaxChar=80, $symbol=" ", $bHTML=false)
GetTime($timestamp, $type="SHORT", $site=false, $bSearchInSitesOnly=false)
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
GetMessage($name, $aReplace=null)
MkDateTime($strDT, $format="d.m.Y H:i:s")
global_menu_<?echo $menu["menu_id"]?> adm main menu item icon adm main menu item text text adm main menu hover adm submenu menucontainer menu_id menu_id items_id items_id desktop menu_id block none adm global submenu<?=($subMenuDisplay=="block" ? " adm-global-submenu-active" :"")?> global_submenu_<?echo $menu["menu_id"]?> text MAIN_PR_ADMIN_FAV items adm submenu items wrap adm submenu items stretch wrap BX adminMenu itemsStretchScroll()"> <table class if (!empty( $menu["items"])) elseif ( $menu[ 'menu_id']=='desktop') if ( $menu[ 'menu_id']=='desktop') endforeach
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
const BX_STATISTIC_BUFFER_USED
$GLOBALS['_____370096793']