55 private $quotes =
array();
60 global $BX_SECURITY_AV_ACTION;
61 if($BX_SECURITY_AV_ACTION ===
"notify_only")
62 $this->replace =
false;
71 isset(
$event[
"TO_MODULE_ID"]) &&
$event[
"TO_MODULE_ID"] ===
"security"
72 && isset(
$event[
"TO_CLASS"]) &&
$event[
"TO_CLASS"] ===
"CSecurityAntiVirus"
109 "SECURITY_VIRUS" =>
"[SECURITY_VIRUS] ".
GetMessage(
"SECURITY_VIRUS"),
115 if (CSecuritySystemInformation::isCliMode())
118 if (self::isSafetyRequest())
121 global
$APPLICATION, $BX_SECURITY_AV_TIMEOUT, $BX_SECURITY_AV_ACTION;
122 $BX_SECURITY_AV_TIMEOUT = COption::GetOptionInt(
"security",
"antivirus_timeout");
123 $BX_SECURITY_AV_ACTION = COption::GetOptionInt(
"security",
"antivirus_action");
129 $BX_SECURITY_AV_WHITE_LIST =
$CACHE_MANAGER->Get(
"b_sec_white_list");
133 $BX_SECURITY_AV_WHITE_LIST =
array();
136 $BX_SECURITY_AV_WHITE_LIST[] =
$ar[
"WHITE_SUBSTR"];
137 $CACHE_MANAGER->Set(
"b_sec_white_list", $BX_SECURITY_AV_WHITE_LIST);
144 if(defined(
"BX_SECURITY_AV_STARTED"))
157 register_shutdown_function(
array(
'CSecurityAntiVirus',
'PHPShutdown'));
160 $fname =
$_SERVER[
"DOCUMENT_ROOT"].BX_PERSONAL_ROOT.
"/managed_cache/b_sec_virus";
161 if(file_exists($fname))
163 $rsInfo = VirusTable::getList([
"filter" => [
"=SENT" =>
"N"]]);
165 if($arInfo = $rsInfo->Fetch())
173 if($arInfo[
"INFO"] <>
'')
175 $arEvent = unserialize(base64_decode($arInfo[
"INFO"]), [
'allowed_classes' =>
false]);
176 if(is_array($arEvent))
178 $arEvent[
"TIMESTAMP_X"] = $arInfo[
"TIMESTAMP_X"];
179 $arEvent[
"USER_ID"] =
null;
180 $arEvent[
"GUEST_ID"] =
null;
181 EventLogTable::add($arEvent);
184 VirusTable::update($arInfo[
"ID"], [
"SENT" =>
"Y"]);
186 }
while ($arInfo = $rsInfo->Fetch());
188 $date = new \Bitrix\Main\Type\DateTime();
189 $date->add(
"-{$BX_SECURITY_AV_TIMEOUT} minutes");
191 VirusTable::deleteList([
"<=TIMESTAMP_X" => $date]);
205 if (self::isSafetyRequest())
215 if (self::isSafetyRequest())
220 define(
"BX_SECURITY_AV_AFTER_EPILOG",
true);
225 if(defined(
"BX_SECURITY_AV_AFTER_EPILOG"))
232 if(mb_substr(
$content, 0, 6) ==
"<html>" && preg_match(
"#</html>\\s*\$#is",
$content))
249 $res = WhiteListTable::getList([
"order" =>
"ID"]);
257 WhiteListTable::deleteList([]);
259 foreach($arWhiteList as $white_str)
261 $white_str = trim($white_str);
263 WhiteListTable::add([
"ID" =>
$i++,
"WHITE_SUBSTR" => $white_str]);
272 if(mb_strpos($this->atributes,
'src="/bitrix/') !==
false)
275 if(preg_match(
'#src="http[s]?://(api-maps\\.yandex|maps\\.google|apis\\.google|stg\\.odnoklassniki)\\.[a-z]{2,3}/#', $this->atributes))
278 if(mb_strpos($this->body,
'BX_DEBUG_INFO') !==
false)
281 if(preg_match(
'#(google-analytics\\.com/ga\\.js|openstat\\.net/cnt\\.js|autocontext\\.begun\\.ru/autocontext\\.js|counter\\.yadro\\.ru/hit)#', $this->body))
284 if(preg_match(
'/var\s+(cmt|jsMnu_toolbar_|hint|desktopPage|arStructure|current_selected|arCrmSelected|arKernelCSS|lastUsers|arStore)/', $this->body))
287 if(preg_match(
'/(arFDDirs|arFDFiles|arPropFieldsList|PROP)\[/', $this->body))
290 if(preg_match(
'/(addPathRow|MoveProgress|Import|DoNext|JCMenu|AttachFile|CloseDialog|_processData|showComment|ShowWarnings|SWFObject|deliveryCalcProceed|structReload|addForumImagesShow|rsasec_form_bind|BX_YMapAddPolyline|BX_YMapAddPlacemark|CloseWaitWindow|DoChangeExternalSaleId|AjaxSend|readFileChunk|EndDump|createMenu|addProperty)\(/', $this->body))
293 if(mb_strpos($this->body,
'window.operation_success = true;') !==
false)
296 if(preg_match(
'/(jsAjaxUtil|jsUtils|jsPopup|elOnline|jsAdminChain|jsEvent|jsAjaxHistory|bxSession|BXHotKeys|oSearchDialog)\./', $this->body))
299 if(preg_match(
'/new\s+(PopupMenu|JCAdminFilter|JCSmartFilter|JCAdminMenu|BXHint|ViewTabControl|BXHTMLEditor|JCTitleSearch|JCWDTitleSearch|BxInterfaceForm|Date|JCEmployeeSelectControl|JCCatalogBigdataProducts|JCCatalogSection|JCCatalogElement|JCCatalogTopSlider|JCCatalogTopSection|JCCatalogSectionRec|JCCatalogSectionViewed|JCCatalogCompareList|JCCatalogItem|JCSaleGiftProduct|B24\.SearchTitle)/', $this->body))
302 if(mb_strpos($this->body,
'document\.write(\'<link href="/bitrix/templates/') !==
false)
305 if(preg_match(
'/(BX|document\.getElementById)\(\'session_time_result\'\).innerHTML/', $this->body))
308 if(preg_match(
'/(structRegisterDD|bx_adv_includeFlash|BXSnippetsTaskbar|BXPropertiesTaskbar|oBXDialogControls|editComment|taskManagerForm|SLtestParamsSetValue|SLshowError|arUsers|arImages|itm_name|form_tbl_dump|bx_template_params|GetAdminList|WDAddUser2Filter|pBXEventDispatcher|orderCallback|disableAddToCompare)/', $this->body))
311 if(preg_match(
'/(iblock_element_edit|iblock_element_search|posting_admin|fileman_file_view|sale_print|get_message|user_edit)\.php/', $this->body))
314 if(preg_match(
'/BX\.(WindowManager|reload|message|browser|ready|tooltip|admin|hint_replace|CDebugDialog|adjust|ajax|bind|loadScript|addCustomEvent|timeman|Finder|Access|loadCSS|CrmProductEditor|COpener|file_input|setKernelJS|TreeConditions|PULL|runSitemap|setCSSList|setJSList)/', $this->body))
317 if(preg_match(
'/window\.parent\.(InitActionProps|Tree|buildNoMenu)/', $this->body))
320 if(preg_match(
'/document\.forms\.meeting_edit/', $this->body))
323 if(preg_match(
'/top\.(jsBXAC|bx_req_res|BX|bxiu_simple_res|bxiu_wm_img_res|SetForumAjaxPostTmp|SetVoteAjaxPostTmp|SetReviewsAjaxPostTmp|bxBlogImageError|replaceKeys|FILE_UPLOADER_CALLBACK|setAuthResult)/', $this->body))
326 if(preg_match(
'/var\s+dates\s+=\s+(new\s+Array|\[\];)/', $this->body))
329 if(preg_match(
'/(updateURL|bx_incl_area|basketTotalWeight|iNoOnSelectionChange|arGDGroups|phpVars)\s+=/', $this->body))
332 if(preg_match(
'/^\s*__status\s+=\s+true;\s*$/', $this->body))
335 if(preg_match(
'/window\.(bx_load_items_res|oPhotoEditIconDialogError|bxph_error|bxph_action|bxphres|bx_req_res|MLSearchResult|arUsedCSS|arComp2Templates|arComp2TemplateProps|arComp2TemplateLists|arComp2Elements|arSnippets|JCCalendarViewMonth|JCCalendarViewWeek|JCCalendarViewDay|_bx_result|_bx_new_event|_bx_plann_mr|_bx_ar_events|_bx_calendar|_bx_plann_events|_bx_existent_event|_ml_items_colls|MLCollections|fmsBtimeout|fmsResult|arSnGroups|BXFM_result|BXFM_NoCopyToDir|oPhotoEditAlbumDialogError|structOptions|__bxst_result|_bx_def_calendar|GLOBAL_arMapObjects|autosave_|oPhotoEditDialogError|bxPlayerOnload|LHE_MESS|MLItems|fmPackTimeout|fmUnpackSuccess|BXFM_archiveExists|BXHtmlEditor)/', $this->body))
338 if(preg_match(
'/\s*(self|window)\.close\s*\(\s*\)\s*;*\s*$/', $this->body))
341 if($this->body ===
'window.location.reload();')
344 if($this->body ===
'window.location = window.location.href;')
347 if(preg_match(
'/^parent\.window\.(End\(\d+\)|EndTasks\(\)|buildNoMenu\(\));\s*$/', $this->body))
350 if(preg_match(
'/parent\.window\.|Start\(\s*\d+,\s*\d+\s*\);\s*$/', $this->body))
353 if(preg_match(
'/^top\.location\.href\s*=\s*([\'"])[^\'"]*\1;{0,1}$/', $this->body))
356 if(preg_match(
'/\.setTimeout\(\'CheckNew\(\)\'/', $this->body))
359 if(preg_match(
'/function\s+twitter_click_\d+\(longUrl\)/', $this->body))
362 if(preg_match(
'/(window\.)*parent\.document\.getElementById\(["\'](COUNTERS_UPDATED|div_PROPERTY_DEFAULT_VALUE)["\']\)\.innerHTML/',$this->body))
365 if(preg_match(
'/(TasksUsers|IntranetUsers).arEmployees/',$this->body))
368 if(preg_match(
'/window\.location\s*=\s*[\'"]\/bitrix\/admin\/iblock_bizproc_workflow_edit.php/', $this->body))
371 if(preg_match(
'/window\.parent\.location\.href\s*=\s*[\'"]\/bitrix\/admin\/sale_order_new.php/', $this->body))
374 if(preg_match(
'/^window\.open\(/', $this->body))
377 if(preg_match(
'/^\s*window\.__bxResult\[\'\d+\'\]\s*=\s*\{/', $this->body))
380 if(mb_strpos($this->body,
'showFLVPlayer') !==
false)
383 if(preg_match(
'/var\s+formSettingsDialogCRM_(LEAD|DEAL|COMPANY|CONTACT)_SHOW/', $this->body))
386 if(preg_match(
'/parent\.(FILE_UPLOADER_CALLBACK)/', $this->body))
389 if(preg_match(
'/bxForm_CRM/', $this->body))
392 if(preg_match(
'/\$\(([\'"])[^\'"]*[\'"]\)/', $this->body))
395 if(preg_match(
'/document\.documentElement\.className/i', $this->body))
399 if(preg_match(
'/var\s*fix_mode\s*=/i', $this->body))
403 if($this->type ==
'iframe' && preg_match(
'#\s*src=[\'"]https://(verify\.voximplant\.com|lookerstudio\.google\.com|datastudio\.google\.com|app\.powerbi\.com|www\.googletagmanager\.com)/#i', $this->atributes))
406 if(preg_match(
'#function\s+bizvalChange#', $this->body))
409 if($this->type ===
"script")
411 if(preg_match(
'#type="application/json"#is', $this->atributes))
414 if(preg_match(
'#type="application/ld\+json"#is', $this->atributes))
417 if(preg_match(
'#type="text/x-template"#is', $this->atributes))
421 $this->bodyWOquotes = trim(
$filter->removeQuotedStrings($this->body,
false),
" \t\n\r");
422 $this->bodyWOquotes = preg_replace(
"/\\s*(window\\.top|top|window|window\\.document|document)\\.(strWarning|location\\.href|location|action_warning|__bx_res_sn_filename|title|title[\\d]+\\s*=\\s*title[\\d]+|text[\\d]+\\s*=\\s*text[\\d]+)\\s*=\\s*(|\\s*\\+\\s*)+;{0,1}\\s*/s",
"", $this->bodyWOquotes, -1,
$count);
423 $this->bodyWOquotes = preg_replace(
"/\\s*(alert|SelFile)\\s*\\((|[0-9]+|\\s*\\+\\s*)+\\)\\s*;{0,1}\\s*/",
"", $this->bodyWOquotes);
424 $this->bodyWOquotes = trim($this->bodyWOquotes,
"\n\r\t ");
425 $this->bodyWOquotes = preg_replace(
"/^\\/\\/[^\n]*\$/",
"", $this->bodyWOquotes);
427 if($this->bodyWOquotes ===
"")
432 global $BX_SECURITY_AV_WHITE_LIST;
433 if(is_array($BX_SECURITY_AV_WHITE_LIST))
434 foreach($BX_SECURITY_AV_WHITE_LIST as $white_substr)
435 if(mb_strpos($this->data, $white_substr) !==
false)
459 global $BX_SECURITY_AV_TIMEOUT;
460 if(defined(
"ANTIVIRUS_CREATE_TRACE"))
463 $uniq_id = md5($this->data);
464 $arLog = VirusTable::getByPrimary($uniq_id)->fetch();
466 if($arLog && ($arLog[
"SENT"] ==
"Y"))
468 $date = new \Bitrix\Main\Type\DateTime();
469 $date->add(
"-{$BX_SECURITY_AV_TIMEOUT} minutes");
471 VirusTable::deleteList([
"SENT" =>
"Y",
"<TIMESTAMP_X" => $date]);
473 $arLog = VirusTable::getByPrimary($uniq_id)->fetch();
480 if(defined(
"ANTIVIRUS_CREATE_TRACE"))
481 foreach($this->resultrules as
$k=>$v)
482 $ss .=
"\n".$k.
"=".$v;
484 if(defined(
"SITE_ID") && !defined(
"ADMIN_SECTION"))
492 "filter" => [
"=ACTIVE" =>
"Y"],
493 "order" => [
"DEF" =>
"DESC",
"SORT" =>
"ASC"]
496 $SITE_ID = $arDefSite ? $arDefSite[
"LID"] :
null;
499 $s = serialize(
array(
500 "SEVERITY" =>
"SECURITY",
501 "AUDIT_TYPE_ID" =>
"SECURITY_VIRUS",
502 "MODULE_ID" =>
"security",
503 "ITEM_ID" =>
"UNKNOWN",
504 "REMOTE_ADDR" =>
$_SERVER[
"REMOTE_ADDR"],
505 "USER_AGENT" =>
$_SERVER[
"HTTP_USER_AGENT"],
506 "REQUEST_URI" =>
$_SERVER[
"REQUEST_URI"],
507 "SITE_ID" => defined(
"SITE_ID")?
SITE_ID:
false,
509 "GUEST_ID" => array_key_exists(
"SESS_GUEST_ID", $_SESSION) && ($_SESSION[
"SESS_GUEST_ID"] > 0)? $_SESSION[
"SESS_GUEST_ID"]:
false,
510 "DESCRIPTION" =>
"==".base64_encode($ss),
515 "TIMESTAMP_X" =>
new \
Bitrix\Main\Type\DateTime(),
517 "INFO" => base64_encode($s)
520 @fclose(@fopen(
$_SERVER[
"DOCUMENT_ROOT"].BX_PERSONAL_ROOT.
"/managed_cache/b_sec_virus",
"w"));
549 $cache_id = md5($this->data);
550 $fn =
$_SERVER[
"DOCUMENT_ROOT"].
"/bitrix/cache/virus.db/".$cache_id.
".vir";
551 if(!file_exists($fn))
554 $f = fopen($fn,
"wb");
556 fwrite(
$f, $this->data);
558 fwrite(
$f,
"\n------------------------------\n\$_SERVER:\n");
560 fwrite(
$f,
$k.
" = ".$v.
"\n");
562 fwrite(
$f,
"\n------------------------------\n\$this->resultrules:\n");
563 foreach($this->resultrules as
$k=>$v)
564 fwrite(
$f,
$k.
" = ".$v.
"\n");
568 @chmod($fn, BX_FILE_PERMISSIONS);
574 static $arLocalCache =
array();
576 $content_len = strlen(
$content) * 2;
577 Ini::adjustPcreBacktrackLimit($content_len);
579 $this->stylewithiframe = preg_match(
"/<style.*>\s*iframe/",
$content);
581 $arData = preg_split(
"/(<script.*?>.*?<\\/script.*?>|<iframe.*?>.*?<\\/iframe.*?>)/is",
$content, -1, PREG_SPLIT_DELIM_CAPTURE);
583 $cData = is_array($arData) ?
count($arData) : 0;
588 $bDataChanged =
false;
589 for($iData = 1; $iData < $cData; $iData += 2)
591 $this->data = $arData[$iData];
594 if(!preg_match(
'/^<(script|iframe)(.*?)>(.*?)(<\\/\\1.*?>)$/is', $this->data, $ret))
598 $this->prev = $arData[$iData-2].$arData[$iData-1];
600 $this->prev = $arData[$iData-1];
602 if($iData < $cData-2)
603 $this->next = $arData[$iData+1].$arData[$iData+2];
605 $this->next = $arData[$iData+1];
607 $this->resultrules =
array();
608 $this->bodylines =
false;
609 $this->atributes = $ret[2];
610 if(mb_strtolower($ret[1]) ==
'script')
613 $this->type =
'script';
618 $this->type =
'iframe';
622 if(!$this->whitelist_id)
624 $cache_id = md5($this->data);
625 if(!isset($arLocalCache[$cache_id]))
628 if($arLocalCache[$cache_id] >= $this->maxrating)
633 $bDataChanged =
true;
651 if($this->type==
'iframe')
653 if(!preg_match(
"/src=[\'\"]?http/", $this->atributes))
662 if($this->type==
'iframe')
666 elseif($this->type==
'script')
691 if(!$this->useglobalrules)
696 if($this->type==
'script' && $this->stylewithiframe
701 $this->resultrules[
'rulescriptglobals_styleiframe'] =
$val;
704 if($this->place ==
"post")
708 $this->resultrules[
'rulescriptglobals_blockafterend'] =
$val;
711 if($this->place ==
"pre")
715 $this->resultrules[
'rulescriptglobals_blockprestart'] =
$val;
725 $strp = preg_replace(
'/<!\-\-.*?\-\->$/',
'', $this->prev);
726 $strn = preg_replace(
'/^<!\-\-.*?\-\->/',
'', $this->next);
731 if(preg_match(
"/^\s*$/is", $strp))
735 $this->resultrules[
'rulescriptblocks_blockinstart'] =
$val;
739 if(preg_match(
"/^\s*$/is", $strn))
743 $this->resultrules[
'rulescriptblocks_endofhtml'] =
$val;
746 if(preg_match(
"/<body[^>]*?>\s*$/is", $strp))
750 $this->resultrules[
'rulescriptblocks_postbody'] =
$val;
753 if(preg_match(
"/^\s*<\\/body[^>]*?>/is", $strn))
757 $this->resultrules[
'rulescriptblocks_preendofbody'] =
$val;
760 if(preg_match(
"/<\\/html[^>]*?>\s*$/is", $strp))
764 $this->resultrules[
'rulescriptblocks_postendofhtml'] =
$val;
767 if($this->type ==
'iframe')
769 if(preg_match(
"/<div[^>]+((visibility\s*:\s*hidden)|(display\s*:\s*none))[^>]*>\s*$/is", $strp))
773 $this->resultrules[
'rulescriptblocks_inhideddiv'] =
$val;
777 if(preg_match(
"/^\s*<noscript/is", $strn))
781 $this->resultrules[
'rulescriptblocks_prenoscript'] =
$val;
792 preg_match(
'/visibility\s*:\s*hidden/is', $this->atributes)
793 || preg_match(
'/display\s*:\s*none/is', $this->atributes)
798 $this->resultrules[
'ruleframevisiblity_invisible'] =
$val;
802 preg_match(
'/width=[\'\"]?[10][\'\"]?/is', $this->atributes)
803 && preg_match(
'/height=[\'\"]?[10][\'\"]?/is', $this->atributes)
808 $this->resultrules[
'ruleframevisiblity_sizes'] =
$val;
811 if(preg_match(
'/position\s*:\s*absolute/is', $this->atributes))
815 $this->resultrules[
'ruleframevisiblity_position'] =
$val;
824 if(preg_match(
"/<iframe/is", $this->body))
828 $this->resultrules[
'rulescriptbasics_iframe'] =
$val;
831 if(preg_match(
"/eval\(/is", $this->body))
835 $this->resultrules[
'rulescriptbasics_eval'] =
$val;
838 if(preg_match(
"/replace\(/is", $this->body))
842 $this->resultrules[
'rulescriptbasics_raplace'] =
$val;
845 if(preg_match(
"/unescape\(/is", $this->body))
849 $this->resultrules[
'rulescriptbasics_unescape'] =
$val;
852 if(preg_match(
"/fromCharCode\(/is", $this->body))
856 $this->resultrules[
'rulescriptbasics_fromcharcode'] =
$val;
859 if(preg_match(
"/parseInt\(/is", $this->body))
863 $this->resultrules[
'rulescriptbasics_parseInt'] =
$val;
866 if(preg_match(
"/substr\(/is", $this->body))
870 $this->resultrules[
'rulescriptbasics_substr'] =
$val;
873 if(preg_match(
"/substring\(/is", $this->body))
877 $this->resultrules[
'rulescriptbasics_substring'] =
$val;
880 if(preg_match(
"/document\.write\(/is", $this->body))
884 $this->resultrules[
'rulescriptbasics_documentwrite'] =
$val;
887 if(preg_match(
"/window\.status/is", $this->body))
891 $this->resultrules[
'rulescriptbasics_windowstatus'] =
$val;
895 preg_match(
'/visibility\s*:\s*hidden/is', $this->body)
896 || preg_match(
'/display\s*:\s*none/is', $this->body)
901 $this->resultrules[
'rulescriptbasics_invisible'] =
$val;
911 if(preg_match(
'/vbscript/is', $this->atributes))
915 $this->resultrules[
'rulescript_vbscript'] =
$val;
929 "/googleanalytlcs\.net/is",
935 "/94\.247\.2\.195/is",
936 "/mmsreader\.com/is",
937 "/google-ana1yticz\.com/is",
938 "/my2\.mobilesect\.info/is",
939 "/thedeadpit\.com/is",
940 "/internetcountercheck\.com/is",
941 "/165\.194\.30\.123/is",
944 "/live-counter\.net/is",
945 "/klinoneshoes\.info/is",
946 "/protection-livescan\.com/is",
947 "/webexperience13\.com/is",
953 if(preg_match(
$url, $this->atributes))
957 $this->resultrules[
'ruleallsources_url'] =
$val;
962 if(preg_match(
'/src=.*anal.*google/is', $this->atributes))
966 $this->resultrules[
'ruleallsources_url'] =
$val;
971 preg_match(
'/src=.*google.*anal/is', $this->atributes)
972 && !preg_match(
'/src=.*google\-analytics\.com/is', $this->atributes)
977 $this->resultrules[
'ruleallsources_url'] =
$val;
981 if(preg_match(
'/src=.*\:\/\/\d+\.\d+\.\d+\.\d+/is', $this->atributes))
985 $this->resultrules[
'ruleallsources_ip'] =
$val;
989 if(preg_match(
'/src=.*\:\d+\//is', $this->atributes))
993 $this->resultrules[
'ruleallsources_port'] =
$val;
997 if(preg_match(
'/src=[\'\"]?http\:\/\//is', $this->atributes))
1001 $this->resultrules[
'ruleallsources_extern'] =
$val;
1011 if(!$this->bodylines)
1012 $this->bodylines = explode(
"\n", $this->body);
1016 if(
count($this->bodylines) == 1)
1018 $ll = mb_strlen(bin2hex($this->body)) / 2;
1023 $this->resultrules[
'rulescriptlenghts_sl'] =
$val;
1030 $this->resultrules[
'rulescriptlenghts_sl'] =
$val;
1037 $this->resultrules[
'rulescriptlenghts_sl'] =
$val;
1045 foreach($this->bodylines as
$str)
1047 $ll = mb_strlen(bin2hex(
$str)) / 2;
1056 $this->resultrules[
'rulescriptlenghts_ml'] =
$val;
1063 $this->resultrules[
'rulescriptlenghts_ml'] =
$val;
1070 $this->resultrules[
'rulescriptlenghts_ml'] =
$val;
1081 if(!$this->bodylines)
1082 $this->bodylines = explode(
"\n", $this->body);
1084 $all =
array(
"MAXCHAR"=>0,
"D"=>0,
"H"=>0,
"NW"=>0,
"B"=>0,
"LEN"=>0 );
1085 $maxes =
array(
"MAXCHAR"=>0,
"D"=>0,
"H"=>0,
"NW"=>0,
"B"=>0,
"LEN"=>0 );
1087 foreach($this->bodylines as
$str)
1091 $all[
'MAXCHAR'] += $ret[
'MAXCHAR'];
1092 $all[
'D'] += $ret[
'D'];
1093 $all[
'H'] += $ret[
'H'];
1094 $all[
'NW'] += $ret[
'NW'];
1095 $all[
'B'] += $ret[
'B'];
1096 $all[
'LEN'] += $ret[
'LEN'];
1098 if($ret[
'LEN'] > 30)
1100 $ret[
'MAXCHAR'] = $ret[
'MAXCHAR']*100/$ret[
'LEN'];
1101 $ret[
'D'] = $ret[
'D']*100/$ret[
'LEN'];
1102 $ret[
'H'] = $ret[
'H']*100/$ret[
'LEN'];
1103 $ret[
'NW'] = $ret[
'NW']*100/$ret[
'LEN'];
1104 $ret[
'B'] = $ret[
'B']*100/$ret[
'LEN'];
1106 if($ret[
'MAXCHAR'] > $maxes[
'MAXCHAR'])
1107 $maxes[
'MAXCHAR'] = $ret[
'MAXCHAR'];
1108 if($ret[
'D'] > $maxes[
'D'])
1109 $maxes[
'D'] = $ret[
'D'];
1110 if($ret[
'H'] > $maxes[
'H'])
1111 $maxes[
'H'] = $ret[
'H'];
1112 if($ret[
'NW'] > $maxes[
'NW'])
1113 $maxes[
'NW'] = $ret[
'NW'];
1114 if($ret[
'B'] > $maxes[
'B'])
1115 $maxes[
'B'] = $ret[
'B'];
1121 $all[
'MAXCHAR'] = $all[
'MAXCHAR']*100/$all[
'LEN'];
1122 $all[
'D'] = $all[
'D']*100/$all[
'LEN'];
1123 $all[
'H'] = $all[
'H']*100/$all[
'LEN'];
1124 $all[
'NW'] = $all[
'NW']*100/$all[
'LEN'];
1125 $all[
'B'] = $all[
'B']*100/$all[
'LEN'];
1129 $g3s=$g4s=$g5s=$g6s=0;
1132 if($all[
'LEN'] > 30)
1138 if($all[
'MAXCHAR'] > 17)
1144 $g3s =
"rulescriptfrequensy_maxchar";
1148 if($all[
'MAXCHAR'] > 19)
1154 $g3s =
"rulescriptfrequensy_maxchar";
1158 if($all[
'MAXCHAR'] > 20)
1164 $g3s =
"rulescriptfrequensy_maxchar";
1177 $g4s =
"rulescriptfrequensy_D";
1187 $g4s =
"rulescriptfrequensy_D";
1197 $g4s =
"rulescriptfrequensy_D";
1211 $g4s=
"rulescriptfrequensy_H";
1222 $g4s =
"rulescriptfrequensy_H";
1232 $g4s =
"rulescriptfrequensy_H";
1246 $g5s =
"rulescriptfrequensy_NW";
1256 $g5s =
"rulescriptfrequensy_NW";
1266 $g5s =
"rulescriptfrequensy_NW";
1279 $g6s =
"rulescriptfrequensy_B";
1289 $g6s =
"rulescriptfrequensy_B";
1299 $g6s =
"rulescriptfrequensy_B";
1307 if($maxes[
'MAXCHAR']>20)
1314 $g3s =
"rulescriptfrequensystr_MAXCHAR";
1318 if($maxes[
'MAXCHAR'] > 24)
1324 $g3s =
"rulescriptfrequensystr_MAXCHAR";
1328 if($maxes[
'MAXCHAR'] > 28)
1334 $g3s =
"rulescriptfrequensystr_MAXCHAR";
1342 if($maxes[
'D'] > 50)
1348 $g4s =
"rulescriptfrequensystr_D";
1352 if($maxes[
'D'] > 65)
1358 $g4s =
"rulescriptfrequensystr_D";
1362 if($maxes[
'D'] > 80)
1368 $g4s =
"rulescriptfrequensystr_D";
1376 if($maxes[
'H'] > 40)
1382 $g4s =
"rulescriptfrequensystr_H";
1386 if($maxes[
'H'] > 55)
1392 $g4s =
"rulescriptfrequensystr_H";
1396 if($maxes[
'H'] > 70)
1402 $g4s =
"rulescriptfrequensystr_H";
1410 if($maxes[
'NW'] > 23)
1416 $g5s =
"rulescriptfrequensystr_NW";
1420 if($maxes[
'NW'] > 26)
1426 $g5s =
"rulescriptfrequensystr_NW";
1430 if($maxes[
'NW'] > 30)
1436 $g5s =
"rulescriptfrequensystr_NW";
1444 if($maxes[
'B'] > 0.1)
1450 $g6s =
"rulescriptfrequensystr_B";
1454 if($maxes[
'B'] > 0.5)
1460 $g6s =
"rulescriptfrequensystr_B";
1470 $g6s =
"rulescriptfrequensystr_B";
1475 $this->resultrules[$g3s] = $g3;
1477 $this->resultrules[$g4s] = $g4;
1479 $this->resultrules[$g5s] = $g5;
1481 $this->resultrules[$g6s] = $g6;
1483 return ($g3+$g4+$g5+$g6);
1489 if(!$this->bodylines)
1490 $this->bodylines = explode(
"\n", $this->body);
1492 $ll = mb_strlen(bin2hex($this->body)) / 2;
1494 $lstr =
count($this->bodylines);
1496 if(!preg_match(
"/src=/", $this->atributes))
1501 $this->resultrules[
"rulescriptwhiterules_len"] =
$val;
1507 $this->resultrules[
"rulescriptwhiterules_len"] =
$val;
1513 $this->resultrules[
"rulescriptwhiterules_len"] =
$val;
1521 while((!$ok || !$ok2) &&
$i<$lstr)
1523 if(!$ok && preg_match(
"/^[\\s\\r\\n]*$/", $this->bodylines[
$i]))
1526 $this->resultrules[
"rulescriptwhiterules_nullines"] =
$val;
1531 if(!$ok2 && preg_match(
"/^(( )|(\t))/", $this->bodylines[
$i]))
1534 $this->resultrules[
"rulescriptwhiterules_tabs"] =
$val;
1546 $this->resultrules[
"rulescriptwhiterules_lines"] =
$val;
1552 $this->resultrules[
"rulescriptwhiterules_lines"] =
$val;
1558 $this->resultrules[
"rulescriptwhiterules_lines"] =
$val;
1569 $rr = $this->
getnames($this->body);
1575 foreach($rr[
'f'] as
$k=>$v)
1583 foreach($rr[
'n'] as
$k=>$v)
1596 $this->resultrules[
"rulescriptnamerules_nlen"] =
$val;
1602 $this->resultrules[
"rulescriptnamerules_nlen"] =
$val;
1608 $this->resultrules[
"rulescriptnamerules_nlen"] =
$val;
1613 foreach($rr[
's'] as
$k=>$v)
1615 $l = mb_strlen(bin2hex($v)) / 2;
1623 $this->resultrules[
"rulescriptnamerules_str"] =
$val;
1629 $this->resultrules[
"rulescriptnamerules_str"] =
$val;
1635 $this->resultrules[
"rulescriptnamerules_str"] =
$val;
1641 $nspp = 100*$cn/$cc;
1646 $this->resultrules[
"rulescriptnamerules_nnormnam"] =
$val;
1652 $this->resultrules[
"rulescriptnamerules_nnormnam"] =
$val;
1658 $this->resultrules[
"rulescriptnamerules_nnormnam"] =
$val;
1671 static $arCharClasses =
false;
1674 $arCharClasses =
array(
1681 for(
$i = ord(
'0'), $end = ord(
'9');
$i <= $end;
$i++)
1682 $arCharClasses[
'D'][] =
$i;
1684 for(
$i = ord(
'a'), $end = ord(
'f');
$i <= $end;
$i++)
1685 $arCharClasses[
'H'][] =
$i;
1687 for(
$i = ord(
'A'), $end = ord(
'F');
$i <= $end;
$i++)
1688 $arCharClasses[
'H'][] =
$i;
1690 for(
$i = 0;
$i < 32;
$i++)
1691 $arCharClasses[
'B'][] =
$i;
1693 $strPunct =
"`~!@#$%^&*[]{}();:'\",.\/?\|";
1694 $len = mb_strlen($strPunct);
1695 for(
$i = 0;
$i < $len;
$i++)
1696 $arCharClasses[
'NW'][] = ord(mb_substr($strPunct,
$i, 1));
1699 $chars = count_chars(
$str, 1);
1700 $len = array_sum($chars);
1710 'MAXCHAR' => $len &&
count($chars)? max($chars): 0,
1720 foreach($arCharClasses as $class => $arChars)
1721 foreach($arChars as
$ch)
1722 if(isset($chars[
$ch]))
1723 $out[$class] += $chars[
$ch];
1724 $out[
"H"] += $out[
"D"];
1732 $this->quotes[] = ($m[2]);
1739 $flt->removeQuotedStrings(
$str);
1740 $this->quotes = $flt->getQuotes();
1744 if(preg_match_all(
"/(?<=[^\w\d\_\'\"]|^)([a-z][\w\d\_]*)([^\w\d\_\'\"])/is",
$str, $ret))
1747 foreach($ret[1] as
$k => $v)
1749 if(!array_key_exists($v ,$added))
1751 if($ret[2][
$k] ==
'(')
1761 $r[
's'] = $this->quotes;
1768 $lnm = mb_strtolower($nm);
1769 if($lnm ==
'ac_fl_runcontent')
1771 if($lnm ==
'innerhtml')
1774 if(preg_match(
"/[a-z]\d+[a-z]+\d+[a-z]+/is", $nm))
1777 static $cache =
array();
1778 if(!isset($cache[$nm]))
1780 $chars = count_chars($nm, 1);
1781 $l = array_sum($chars);
1788 if(isset($chars[
$i]))
1797 if(isset($chars[
$i]))
1806 if(isset($chars[
$i]))
1810 if($cs<$cz && $cs>2 &&
$l>5)
1824 if(preg_match(
"/<script.*?>((\s*<!\-\-)|(<!\[CDATA\[))?\s*(.*?)\s*((\/\/\s*\-\->\s*)|(\/\/\s*\]\s*\]\s*))?<\/script.*>/is",
$str, $ret))
1831 return (!isset(
$_SERVER[
'REQUEST_METHOD']) || !in_array(
$_SERVER[
'REQUEST_METHOD'],
array(
'GET',
'POST')));
static getList(array $parameters=array())
static UpdateWhiteList($arWhiteList)
__construct($place="body")
static OnEndBufferContent(&$content)
static SetActive($bActive=false)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
$_SERVER["DOCUMENT_ROOT"]
RegisterModuleDependences($FROM_MODULE_ID, $MESSAGE_ID, $TO_MODULE_ID, $TO_CLASS="", $TO_METHOD="", $SORT=100, $TO_PATH="", $TO_METHOD_ARG=[])
UnRegisterModuleDependences($FROM_MODULE_ID, $MESSAGE_ID, $TO_MODULE_ID, $TO_CLASS="", $TO_METHOD="", $TO_PATH="", $TO_METHOD_ARG=[])
GetModuleEvents($MODULE_ID, $MESSAGE_ID, $bReturnArray=false)
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
GetMessage($name, $aReplace=null)
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."%"