25 return microtime(
true);
35function InputType($strType, $strName, $strValue, $strCmp, $strPrintValue =
false, $strPrint =
"", $field1 =
"", $strId =
"")
40 if (is_array($strCmp))
42 $bCheck = in_array($strValue, $strCmp);
46 $bCheck = in_array($strValue, explode(
",", $strCmp));
50 if ($strType ==
'radio')
56 if ($strType ==
'radio' || $strType ==
'checkbox')
58 $bId = !preg_match(
'/^id="/', $field1) && !preg_match(
'/\sid="/', $field1);
61 return ($bLabel ?
'<label>' :
'') .
'<input type="' . $strType .
'" ' . $field1 .
' name="' . $strName .
'"' .
62 ($bId ?
' id="' . ($strId <>
'' ? $strId : $strName) .
'"' :
'') .
63 ' value="' . $strValue .
'"' .
64 ($bCheck ?
' checked' :
'') .
'>' . ($strPrintValue ? $strValue : $strPrint) . ($bLabel ?
'</label>' :
'');
77function SelectBox($strBoxName,
$a, $strDetText =
"", $strSelectedVal =
"", $field1 =
"class=\"typeselect\"")
79 $strReturnBox =
"<select " . $field1 .
" name=\"" . $strBoxName .
"\" id=\"" . $strBoxName .
"\">";
80 if ($strDetText <>
'')
82 $strReturnBox = $strReturnBox .
"<option value=\"NOT_REF\">" . $strDetText .
"</option>";
84 while ((
$ar =
$a->Fetch()))
86 $reference_id =
$ar[
"REFERENCE_ID"] ??
'';
87 $reference =
$ar[
"REFERENCE"] ??
'';
88 if ($reference_id ==
'')
90 $reference_id =
$ar[
"reference_id"];
94 $reference =
$ar[
"reference"];
97 $strReturnBox = $strReturnBox .
"<option ";
98 if (strcasecmp($reference_id, $strSelectedVal) == 0)
100 $strReturnBox = $strReturnBox .
" selected ";
104 return $strReturnBox .
"</select>";
119function SelectBoxM($strBoxName,
$a,
$arr, $strDetText =
"", $strDetText_selected =
false, $size =
"5", $field1 =
"class=\"typeselect\"")
121 $strReturnBox =
"<select " . $field1 .
" multiple name=\"" . $strBoxName .
"\" id=\"" . $strBoxName .
"\" size=\"" . $size .
"\">";
122 if ($strDetText <>
'')
124 $strReturnBox = $strReturnBox .
"<option ";
125 if ($strDetText_selected)
127 $strReturnBox = $strReturnBox .
" selected ";
129 $strReturnBox = $strReturnBox .
" value='NOT_REF'>" . $strDetText .
"</option>";
131 while (
$ar =
$a->Fetch())
133 $reference_id =
$ar[
"REFERENCE_ID"];
134 $reference =
$ar[
"REFERENCE"];
135 if ($reference_id ==
'')
137 $reference_id =
$ar[
"reference_id"];
139 if ($reference ==
'')
141 $reference =
$ar[
"reference"];
144 $sel = (is_array(
$arr) && in_array($reference_id,
$arr) ?
"selected" :
"");
145 $strReturnBox = $strReturnBox .
"<option " . $sel;
148 return $strReturnBox .
"</select>";
163function SelectBoxMFromArray($strBoxName,
$a,
$arr, $strDetText =
"", $strDetText_selected =
false, $size =
"5", $field1 =
"class='typeselect'")
165 $strReturnBox =
"<select " . $field1 .
" multiple name=\"" . $strBoxName .
"\" id=\"" . $strBoxName .
"\" size=\"" . $size .
"\">";
167 if (array_key_exists(
"REFERENCE_ID",
$a))
169 $reference_id =
$a[
"REFERENCE_ID"];
171 elseif (array_key_exists(
"reference_id",
$a))
173 $reference_id =
$a[
"reference_id"];
180 if (array_key_exists(
"REFERENCE",
$a))
182 $reference =
$a[
"REFERENCE"];
184 elseif (array_key_exists(
"reference",
$a))
186 $reference =
$a[
"reference"];
193 if ($strDetText <>
'')
195 $strReturnBox .=
"<option ";
196 if ($strDetText_selected)
198 $strReturnBox .=
" selected ";
200 $strReturnBox .=
" value='NOT_REF'>" . $strDetText .
"</option>";
203 foreach ($reference_id as
$key => $value)
205 $sel = (is_array(
$arr) && in_array($value,
$arr) ?
"selected" :
"");
209 $strReturnBox .=
"</select>";
210 return $strReturnBox;
219 $strSelectedVal =
"",
221 $field1 =
"class='typeselect'",
229 $funName = preg_replace(
"/[^a-z0-9_]/i",
"", $strBoxName);
230 $jsName = CUtil::JSEscape($strBoxName);
232 $strReturnBox =
"<script>\n" .
233 "function " . $funName .
"LinkUp()\n" .
234 "{var number = document." . $form .
"['" . $jsName .
"'].selectedIndex;\n" .
235 "if(document." . $form .
"['" . $jsName .
"'].options[number].value!=\"0\"){ \n" .
236 "document." . $form .
"['" . $jsName .
"_SELECTED'].value=\"yes\";\n" .
237 "document." . $form .
".submit();\n" .
240 $strReturnBox .=
'<input type="hidden" name="' . $boxName .
'_SELECTED" id="' . $boxName .
'_SELECTED" value="">';
241 $strReturnBox .=
'<select ' . $field1 .
' name="' . $boxName .
'" id="' . $boxName .
'" onchange="' . $funName .
'LinkUp()" class="typeselect">';
245 $strReturnBox =
'<select ' . $field1 .
' name="' . $boxName .
'" id="' . $boxName .
'">';
248 if (isset($db_array[
"reference"]) && is_array($db_array[
"reference"]))
250 $ref = $db_array[
"reference"];
252 elseif (isset($db_array[
"REFERENCE"]) && is_array($db_array[
"REFERENCE"]))
254 $ref = $db_array[
"REFERENCE"];
261 if (isset($db_array[
"reference_id"]) && is_array($db_array[
"reference_id"]))
263 $ref_id = $db_array[
"reference_id"];
265 elseif (isset($db_array[
"REFERENCE_ID"]) && is_array($db_array[
"REFERENCE_ID"]))
267 $ref_id = $db_array[
"REFERENCE_ID"];
274 if ($strDetText <>
'')
276 $strReturnBox .=
'<option value="">' . $strDetText .
'</option>';
279 foreach ($ref as
$i =>
$val)
281 $strReturnBox .=
'<option';
282 if (strcasecmp($ref_id[
$i], $strSelectedVal) == 0)
284 $strReturnBox .=
' selected';
288 return $strReturnBox .
'</select>';
303 'bitrix:main.calendar',
308 'INPUT_NAME' => $fieldName,
309 'FORM_NAME' => $formName,
313 [
'HIDE_ICONS' =>
'Y']
316 return ob_get_clean();
319function CalendarDate($fieldName, $value, $formName =
"", $size =
"10", $param =
"class=\"typeinput\"")
326 return '<input type="text" name="' . $fieldName .
'" id="' . $fieldName .
'" size="' . $size .
'" value="' .
htmlspecialcharsbx($value) .
'" ' . $param .
' /> ' .
"\n" .
Calendar($fieldName, $formName) .
"\n";
329function CalendarPeriod($sFromName, $sFromVal, $sToName, $sToVal, $sFormName =
"skform", $show_select =
"N", $field_select =
"class=\"typeselect\"", $field_input =
"class=\"typeinput\"", $size =
"10")
339 if ($show_select ==
"Y")
341 $sname = $sFromName .
"_DAYS_TO_BACK";
344function " . $sFromName .
"_SetDate()
346 var number = document." . $sFormName .
"." . $sname .
".selectedIndex-1;
347 document." . $sFormName .
"." . $sFromName .
".disabled = false;
350 document." . $sFormName .
"." . $sFromName .
".value = dates[number];
351 document." . $sFormName .
"." . $sFromName .
".disabled = true;
358 if ((
string)$value <>
'' && $value !=
"NOT_REF")
367 for (
$i = 0;
$i <= 90;
$i++)
369 $prev_date =
GetTime(time() - 86400 *
$i);
370 ?>dates[<?=
$i?>] =
"<?=$prev_date?>";<?
371 if (!is_array(
$arr[
"reference"]))
373 $arr[
"reference"] = [];
375 if (!is_array(
$arr[
"reference_id"]))
377 $arr[
"reference_id"] = [];
380 $arr[
"reference_id"][] =
$i;
387 '<input ' . $ds .
' ' . $field_input .
' type="text" name="' . $sFromName .
'" id="' . $sFromName .
'" size="' . $size .
'" value="' .
htmlspecialcharsbx($sFromVal) .
'" /> ' .
"\n" .
388 Calendar($sFromName, $sFormName) .
' ... ' .
"\n" .
389 '<input ' . $field_input .
' type="text" name="' . $sToName .
'" id="' . $sToName .
'" size="' . $size .
'" value="' .
htmlspecialcharsbx($sToVal) .
'" /> ' .
"\n" .
390 Calendar($sToName, $sFormName) .
"\n";
392 return '<span style="white-space: nowrap;">' .
$str .
'</span>';
400 $datetime = (string)$datetime;
402 if ($format ===
false && defined(
"FORMAT_DATETIME"))
414 $day = (int)
$ar[
"DD"];
417 if (isset(
$ar[
"MMMM"]))
419 if (is_numeric(
$ar[
"MMMM"]))
421 $month = (int)
$ar[
"MMMM"];
428 $month = (int)date(
'm', strtotime(
$ar[
"MMMM"]));
434 $month = (int)
$ar[
"MM"];
438 if (is_numeric(
$ar[
"M"]))
440 $month = (int)
$ar[
"M"];
447 $month = (int)date(
'm', strtotime(
$ar[
"M"]));
452 if (isset(
$ar[
"HH"]))
454 $hour = (int)
$ar[
"HH"];
458 $hour = (int)
$ar[
"H"];
462 $hour = (int)
$ar[
"GG"];
466 $hour = (int)
$ar[
"G"];
468 if (isset(
$ar[
'TT']) || isset(
$ar[
'T']))
470 $middletime =
$ar[
'TT'] ??
$ar[
'T'];
471 if (strcasecmp(
'pm', $middletime) === 0)
486 $min = (int)(
$ar[
"MI"] ?? 0);
487 $sec = (int)(
$ar[
"SS"] ?? 0);
489 if (!checkdate($month, $day,
$year))
494 if ($hour > 24 || $hour < 0 || $min < 0 || $min > 59 || $sec < 0 || $sec > 59)
499 if (!isset(
$ar[
"SS"]))
502 $format = str_replace(
':SS',
'', $format);
505 $s1 = preg_replace(
"~([^:\\\\/\\s.,0-9-]+|[^:\\\\/\\s.,a-z-]+)[\n\r\t ]*~iu",
"P", $datetime);
506 $s2 = preg_replace(
"/(DD|MMMM|MM|MI|M|YYYY|HH|H|GG|G|SS|TT|T)[\n\r\t ]*/iu",
"P", $format);
508 if (mb_strlen($s1) <= mb_strlen($s2))
510 return $s1 == mb_substr($s2, 0, mb_strlen($s1));
513 return $s2 == mb_substr($s1, 0, mb_strlen($s2));
524 for (
$i = 1;
$i <= 12;
$i++)
526 if (strcasecmp(
$MESS[
'MONTH_' .
$i .
'_S'], $month) === 0 || strcasecmp(
$MESS[
'MON_' .
$i], $month) === 0 || strcasecmp(
$MESS[
'MONTH_' .
$i], $month) === 0)
540 if ($format ===
false && defined(
"FORMAT_DATETIME"))
547 $day = (int)(
$ar[
"DD"] ?? 0);
550 if (isset(
$ar[
"MMMM"]))
552 if (is_numeric(
$ar[
"MMMM"]))
554 $month = (int)
$ar[
"MMMM"];
561 $month = (int)date(
'm', strtotime(
$ar[
"MMMM"]));
567 $month = (int)
$ar[
"MM"];
571 if (is_numeric(
$ar[
"M"]))
573 $month = (int)
$ar[
"M"];
580 $month = (int)date(
'm', strtotime(
$ar[
"M"]));
585 if (isset(
$ar[
"HH"]))
587 $hour = (int)
$ar[
"HH"];
591 $hour = (int)
$ar[
"H"];
595 $hour = (int)
$ar[
"GG"];
599 $hour = (int)
$ar[
"G"];
601 if (isset(
$ar[
'TT']) || isset(
$ar[
'T']))
603 $middletime =
$ar[
'TT'] ??
$ar[
'T'];
604 if (strcasecmp(
'pm', $middletime) === 0)
619 $min = (int)(
$ar[
"MI"] ?? 0);
620 $sec = (int)(
$ar[
"SS"] ?? 0);
622 if (!checkdate($month, $day,
$year))
627 if ($hour > 24 || $hour < 0 || $min < 0 || $min > 59 || $sec < 0 || $sec > 59)
632 return mktime($hour, $min, $sec, $month, $day,
$year);
640 if ($datetime ===
null)
644 if ($format ===
false && defined(
"FORMAT_DATETIME"))
650 if (preg_match_all(
"/(DD|MI|MMMM|MM|M|YYYY|HH|H|SS|TT|T|GG|G)/i", $format, $fm_args))
653 if (preg_match_all(
"~([^:\\\\/\\s.,0-9-]+|[^:\\\\/\\s.,a-z-]+)~iu", $datetime, $dt_args))
656 foreach ($fm_args[0] as
$i => $v)
658 if (isset($dt_args[0][
$i]))
660 if (is_numeric($dt_args[0][
$i]))
662 $arrResult[$v] = sprintf(
"%0" . mb_strlen($v) .
"d", intval($dt_args[0][
$i]));
664 elseif (($dt_args[0][
$i] ===
"am" || $dt_args[0][
$i] ===
"pm") && in_array(
"T", $fm_args[0]))
666 $arrResult[
"T"] = $dt_args[0][
$i];
668 elseif (($dt_args[0][
$i] ===
"AM" || $dt_args[0][
$i] ===
"PM") && in_array(
"TT", $fm_args[0]))
670 $arrResult[
"TT"] = $dt_args[0][
$i];
674 $arrResult[$v] = $dt_args[0][
$i];
693 if (is_array($arrAdd))
695 foreach ($arrAdd as
$key => $value)
697 $value = intval($value);
701 $stmp =
AddTime($stmp, $value,
"D");
704 $stmp =
AddTime($stmp, $value,
"MN");
707 $stmp =
AddTime($stmp, $value,
"Y");
710 $stmp =
AddTime($stmp, $value,
"H");
713 $stmp =
AddTime($stmp, $value,
"M");
716 $stmp =
AddTime($stmp, $value,
"S");
724function ConvertDateTime($datetime, $to_format =
false, $from_site =
false, $bSearchInSitesOnly =
false)
726 if ($to_format ===
false && defined(
"FORMAT_DATETIME"))
730 return FmtDate($datetime, $to_format, $from_site,
false, $bSearchInSitesOnly);
735 if ($timestamp ===
false)
745function FmtDate($str_date, $format =
false,
$site =
false, $bSearchInSitesOnly =
false)
748 if (
$site ===
false && defined(
"SITE_ID"))
752 if ($format ===
false && defined(
"FORMAT_DATETIME"))
757 return $DB::FormatDate($str_date, CSite::GetDateFormat(
"FULL",
$site, $bSearchInSitesOnly), $format);
774 $val = abs($value % 100);
795 if (2 <= $dec && $dec <= 4)
826 if (isset($arParsedDate[
"H"]))
828 $arParsedDate[
"HH"] = intval($arParsedDate[
"H"]);
830 elseif (isset($arParsedDate[
"GG"]))
832 $arParsedDate[
"HH"] = intval($arParsedDate[
"GG"]);
834 elseif (isset($arParsedDate[
"G"]))
836 $arParsedDate[
"HH"] = intval($arParsedDate[
"G"]);
839 if (isset($arParsedDate[
'TT']) || isset($arParsedDate[
'T']))
841 $middletime = $arParsedDate[
'TT'] ?? $arParsedDate[
'T'];
842 if (strcasecmp(
'pm', $middletime) === 0)
844 if ($arParsedDate[
"HH"] < 12)
846 $arParsedDate[
"HH"] += 12;
848 elseif ($arParsedDate[
"HH"] == 12)
850 $arParsedDate[
"HH"] = 12;
854 $arParsedDate[
"HH"] -= 12;
859 $ts = mktime($arParsedDate[
'HH'], $arParsedDate[
'MI'], ($arParsedDate[
'SS'] ?? 0), 3, 7, 2012);
871function FormatDate($format =
"", $timestamp =
false, $now =
false, ?
string $languageId =
null)
875 if ($timestamp ===
false)
881 if ($timestamp instanceof
Main\
Type\Date)
883 $timestamp = $timestamp->getTimestamp();
887 $timestamp = (int)$timestamp;
899 $now = $now->getTimestamp();
916 if (is_array($format))
918 $seconds_ago = $now - $timestamp;
919 foreach ($format as $format_interval => $format_value)
921 if ($format_interval ===
"s")
923 if ($seconds_ago < 60)
925 return FormatDate($format_value, $timestamp, $now, $languageId);
928 elseif (preg_match(
'/^s(\d+)>?(\d+)?/', $format_interval, $match))
930 if (isset($match[1], $match[2]))
933 $seconds_ago < (
int)$match[1]
934 && $seconds_ago > (
int)$match[2]
937 return FormatDate($format_value, $timestamp, $now, $languageId);
942 if ($seconds_ago < (
int)$match[1])
944 return FormatDate($format_value, $timestamp, $now, $languageId);
948 elseif ($format_interval ===
"i")
950 if ($seconds_ago < 60 * 60)
952 return FormatDate($format_value, $timestamp, $now, $languageId);
955 elseif (preg_match(
'/^i(\d+)>?(\d+)?/', $format_interval, $match))
957 if (isset($match[1], $match[2]))
960 $seconds_ago < (
int)$match[1] * 60
961 && $seconds_ago > (
int)$match[2] * 60
964 return FormatDate($format_value, $timestamp, $now, $languageId);
969 if ($seconds_ago < (
int)$match[1] * 60)
971 return FormatDate($format_value, $timestamp, $now, $languageId);
975 elseif ($format_interval ===
"H")
977 if ($seconds_ago < 24 * 60 * 60)
979 return FormatDate($format_value, $timestamp, $now, $languageId);
982 elseif (preg_match(
'/^H(\d+)>?(\d+)?/', $format_interval, $match))
984 if (isset($match[1], $match[2]))
987 $seconds_ago < (
int)$match[1] * 60 * 60
988 && $seconds_ago > (
int)$match[2] * 60 * 60
991 return FormatDate($format_value, $timestamp, $now, $languageId);
996 if ($seconds_ago < (
int)$match[1] * 60 * 60)
998 return FormatDate($format_value, $timestamp, $now, $languageId);
1002 elseif ($format_interval ===
"d")
1004 if ($seconds_ago < 31 * 24 * 60 * 60)
1006 return FormatDate($format_value, $timestamp, $now, $languageId);
1009 elseif (preg_match(
'/^d(\d+)>?(\d+)?/', $format_interval, $match))
1011 if (isset($match[1], $match[2]))
1014 $seconds_ago < (
int)$match[1] * 24 * 60 * 60
1015 && $seconds_ago > (
int)$match[2] * 24 * 60 * 60
1018 return FormatDate($format_value, $timestamp, $now, $languageId);
1023 if ($seconds_ago < (
int)$match[1] * 24 * 60 * 60)
1025 return FormatDate($format_value, $timestamp, $now, $languageId);
1029 elseif ($format_interval ===
"m")
1031 if ($seconds_ago < 365 * 24 * 60 * 60)
1033 return FormatDate($format_value, $timestamp, $now, $languageId);
1036 elseif (preg_match(
'/^m(\d+)>?(\d+)?/', $format_interval, $match))
1038 if (isset($match[1], $match[2]))
1041 $seconds_ago < (
int)$match[1] * 31 * 24 * 60 * 60
1042 && $seconds_ago > (
int)$match[2] * 31 * 24 * 60 * 60
1045 return FormatDate($format_value, $timestamp, $now, $languageId);
1050 if ($seconds_ago < (
int)$match[1] * 31 * 24 * 60 * 60)
1052 return FormatDate($format_value, $timestamp, $now, $languageId);
1056 elseif ($format_interval ===
"now")
1058 if ($timestamp === $now)
1060 return FormatDate($format_value, $timestamp, $now, $languageId);
1063 elseif ($format_interval ===
"today")
1065 $arNow = localtime($now);
1066 $today_1 = mktime(0, 0, 0, $arNow[4] + 1, $arNow[3], $arNow[5] + 1900);
1067 $today_2 = mktime(0, 0, 0, $arNow[4] + 1, $arNow[3] + 1, $arNow[5] + 1900);
1068 if ($timestamp >= $today_1 && $timestamp < $today_2)
1070 return FormatDate($format_value, $timestamp, $now, $languageId);
1073 elseif ($format_interval ===
"todayFuture")
1075 $arNow = localtime($now);
1077 $today_2 = mktime(0, 0, 0, $arNow[4] + 1, $arNow[3] + 1, $arNow[5] + 1900);
1078 if ($timestamp >= $today_1 && $timestamp < $today_2)
1080 return FormatDate($format_value, $timestamp, $now, $languageId);
1083 elseif ($format_interval ===
"yesterday")
1085 $arNow = localtime($now);
1089 $yesterday_1 = mktime(0, 0, 0, $arNow[4] + 1, $arNow[3] - 1, $arNow[5] + 1900);
1091 $yesterday_2 = mktime(0, 0, 0, $arNow[4] + 1, $arNow[3], $arNow[5] + 1900);
1093 if ($timestamp >= $yesterday_1 && $timestamp < $yesterday_2)
1095 return FormatDate($format_value, $timestamp, $now, $languageId);
1098 elseif ($format_interval ===
"tommorow" || $format_interval ===
"tomorrow")
1100 $arNow = localtime($now);
1101 $tomorrow_1 = mktime(0, 0, 0, $arNow[4] + 1, $arNow[3] + 1, $arNow[5] + 1900);
1102 $tomorrow_2 = mktime(0, 0, 0, $arNow[4] + 1, $arNow[3] + 2, $arNow[5] + 1900);
1104 if ($timestamp >= $tomorrow_1 && $timestamp < $tomorrow_2)
1106 return FormatDate($format_value, $timestamp, $now, $languageId);
1109 elseif ($format_interval ===
"-")
1111 if ($seconds_ago < 0)
1113 return FormatDate($format_value, $timestamp, $now, $languageId);
1117 return FormatDate(array_pop($format), $timestamp, $now, $languageId);
1120 $bCutZeroTime =
false;
1121 if (str_starts_with($format,
'^'))
1123 $bCutZeroTime =
true;
1124 $format = substr($format, 1);
1127 $arFormatParts = preg_split(
"/(?<!\\\\)(
1128 sago|iago|isago|Hago|dago|mago|Yago|
1129 sdiff|idiff|Hdiff|ddiff|mdiff|Ydiff|
1130 sshort|ishort|Hshort|dshort|mshort|Yshort|
1131 yesterday|today|tomorrow|tommorow|
1133 )/x", $format, 0, PREG_SPLIT_DELIM_CAPTURE);
1138 foreach ($arFormatParts as $format_part)
1140 switch ($format_part)
1145 $seconds_ago = $now - $timestamp;
1149 "0" =>
"FD_SECOND_AGO_0",
1150 "1" =>
"FD_SECOND_AGO_1",
1151 "10_20" =>
"FD_SECOND_AGO_10_20",
1152 "MOD_1" =>
"FD_SECOND_AGO_MOD_1",
1153 "MOD_2_4" =>
"FD_SECOND_AGO_MOD_2_4",
1154 "MOD_OTHER" =>
"FD_SECOND_AGO_MOD_OTHER",
1160 $seconds_ago = $now - $timestamp;
1164 "0" =>
"FD_SECOND_DIFF_0",
1165 "1" =>
"FD_SECOND_DIFF_1",
1166 "10_20" =>
"FD_SECOND_DIFF_10_20",
1167 "MOD_1" =>
"FD_SECOND_DIFF_MOD_1",
1168 "MOD_2_4" =>
"FD_SECOND_DIFF_MOD_2_4",
1169 "MOD_OTHER" =>
"FD_SECOND_DIFF_MOD_OTHER",
1175 $seconds_ago = $now - $timestamp;
1178 [
"#VALUE#" => $seconds_ago],
1183 $minutes_ago = (int)(($now - $timestamp) / 60);
1187 "0" =>
"FD_MINUTE_AGO_0",
1188 "1" =>
"FD_MINUTE_AGO_1",
1189 "10_20" =>
"FD_MINUTE_AGO_10_20",
1190 "MOD_1" =>
"FD_MINUTE_AGO_MOD_1",
1191 "MOD_2_4" =>
"FD_MINUTE_AGO_MOD_2_4",
1192 "MOD_OTHER" =>
"FD_MINUTE_AGO_MOD_OTHER",
1198 $minutes_ago = (int)(($now - $timestamp) / 60);
1202 "0" =>
"FD_MINUTE_DIFF_0",
1203 "1" =>
"FD_MINUTE_DIFF_1",
1204 "10_20" =>
"FD_MINUTE_DIFF_10_20",
1205 "MOD_1" =>
"FD_MINUTE_DIFF_MOD_1",
1206 "MOD_2_4" =>
"FD_MINUTE_DIFF_MOD_2_4",
1207 "MOD_OTHER" =>
"FD_MINUTE_DIFF_MOD_OTHER",
1213 $minutes_ago = (int)(($now - $timestamp) / 60);
1216 [
"#VALUE#" => $minutes_ago],
1221 $minutes_ago = (int)(($now - $timestamp) / 60);
1225 "0" =>
"FD_MINUTE_0",
1226 "1" =>
"FD_MINUTE_1",
1227 "10_20" =>
"FD_MINUTE_10_20",
1228 "MOD_1" =>
"FD_MINUTE_MOD_1",
1229 "MOD_2_4" =>
"FD_MINUTE_MOD_2_4",
1230 "MOD_OTHER" =>
"FD_MINUTE_MOD_OTHER",
1237 $seconds_ago = $now - $timestamp - ($minutes_ago * 60);
1241 "0" =>
"FD_SECOND_AGO_0",
1242 "1" =>
"FD_SECOND_AGO_1",
1243 "10_20" =>
"FD_SECOND_AGO_10_20",
1244 "MOD_1" =>
"FD_SECOND_AGO_MOD_1",
1245 "MOD_2_4" =>
"FD_SECOND_AGO_MOD_2_4",
1246 "MOD_OTHER" =>
"FD_SECOND_AGO_MOD_OTHER",
1252 $hours_ago = (int)(($now - $timestamp) / 60 / 60);
1256 "0" =>
"FD_HOUR_AGO_0",
1257 "1" =>
"FD_HOUR_AGO_1",
1258 "10_20" =>
"FD_HOUR_AGO_10_20",
1259 "MOD_1" =>
"FD_HOUR_AGO_MOD_1",
1260 "MOD_2_4" =>
"FD_HOUR_AGO_MOD_2_4",
1261 "MOD_OTHER" =>
"FD_HOUR_AGO_MOD_OTHER",
1267 $hours_ago = (int)(($now - $timestamp) / 60 / 60);
1271 "0" =>
"FD_HOUR_DIFF_0",
1272 "1" =>
"FD_HOUR_DIFF_1",
1273 "10_20" =>
"FD_HOUR_DIFF_10_20",
1274 "MOD_1" =>
"FD_HOUR_DIFF_MOD_1",
1275 "MOD_2_4" =>
"FD_HOUR_DIFF_MOD_2_4",
1276 "MOD_OTHER" =>
"FD_HOUR_DIFF_MOD_OTHER",
1282 $hours_ago = (int)(($now - $timestamp) / 60 / 60);
1285 [
"#VALUE#" => $hours_ago],
1300 $days_ago = (int)(($now - $timestamp) / 60 / 60 / 24);
1304 "0" =>
"FD_DAY_AGO_0",
1305 "1" =>
"FD_DAY_AGO_1",
1306 "10_20" =>
"FD_DAY_AGO_10_20",
1307 "MOD_1" =>
"FD_DAY_AGO_MOD_1",
1308 "MOD_2_4" =>
"FD_DAY_AGO_MOD_2_4",
1309 "MOD_OTHER" =>
"FD_DAY_AGO_MOD_OTHER",
1315 $days_ago = (int)(($now - $timestamp) / 60 / 60 / 24);
1319 "0" =>
"FD_DAY_DIFF_0",
1320 "1" =>
"FD_DAY_DIFF_1",
1321 "10_20" =>
"FD_DAY_DIFF_10_20",
1322 "MOD_1" =>
"FD_DAY_DIFF_MOD_1",
1323 "MOD_2_4" =>
"FD_DAY_DIFF_MOD_2_4",
1324 "MOD_OTHER" =>
"FD_DAY_DIFF_MOD_OTHER",
1330 $days_ago = (int)(($now - $timestamp) / 60 / 60 / 24);
1333 [
"#VALUE#" => $days_ago],
1338 $months_ago = (int)(($now - $timestamp) / 60 / 60 / 24 / 31);
1342 "0" =>
"FD_MONTH_AGO_0",
1343 "1" =>
"FD_MONTH_AGO_1",
1344 "10_20" =>
"FD_MONTH_AGO_10_20",
1345 "MOD_1" =>
"FD_MONTH_AGO_MOD_1",
1346 "MOD_2_4" =>
"FD_MONTH_AGO_MOD_2_4",
1347 "MOD_OTHER" =>
"FD_MONTH_AGO_MOD_OTHER",
1353 $months_ago = (int)(($now - $timestamp) / 60 / 60 / 24 / 31);
1357 "0" =>
"FD_MONTH_DIFF_0",
1358 "1" =>
"FD_MONTH_DIFF_1",
1359 "10_20" =>
"FD_MONTH_DIFF_10_20",
1360 "MOD_1" =>
"FD_MONTH_DIFF_MOD_1",
1361 "MOD_2_4" =>
"FD_MONTH_DIFF_MOD_2_4",
1362 "MOD_OTHER" =>
"FD_MONTH_DIFF_MOD_OTHER",
1368 $months_ago = (int)(($now - $timestamp) / 60 / 60 / 24 / 31);
1371 [
"#VALUE#" => $months_ago],
1376 $years_ago = (int)(($now - $timestamp) / 60 / 60 / 24 / 365);
1380 "0" =>
"FD_YEARS_AGO_0",
1381 "1" =>
"FD_YEARS_AGO_1",
1382 "10_20" =>
"FD_YEARS_AGO_10_20",
1383 "MOD_1" =>
"FD_YEARS_AGO_MOD_1",
1384 "MOD_2_4" =>
"FD_YEARS_AGO_MOD_2_4",
1385 "MOD_OTHER" =>
"FD_YEARS_AGO_MOD_OTHER",
1391 $years_ago = (int)(($now - $timestamp) / 60 / 60 / 24 / 365);
1395 "0" =>
"FD_YEARS_DIFF_0",
1396 "1" =>
"FD_YEARS_DIFF_1",
1397 "10_20" =>
"FD_YEARS_DIFF_10_20",
1398 "MOD_1" =>
"FD_YEARS_DIFF_MOD_1",
1399 "MOD_2_4" =>
"FD_YEARS_DIFF_MOD_2_4",
1400 "MOD_OTHER" =>
"FD_YEARS_DIFF_MOD_OTHER",
1406 $years_ago = (int)(($now - $timestamp) / 60 / 60 / 24 / 365);
1410 "0" =>
"FD_YEARS_SHORT_0",
1411 "1" =>
"FD_YEARS_SHORT_1",
1412 "10_20" =>
"FD_YEARS_SHORT_10_20",
1413 "MOD_1" =>
"FD_YEARS_SHORT_MOD_1",
1414 "MOD_2_4" =>
"FD_YEARS_SHORT_MOD_2_4",
1415 "MOD_OTHER" =>
"FD_YEARS_SHORT_MOD_OTHER",
1421 if ($currentLanguage ===
"en")
1423 $result .= date($format_part, $timestamp);
1428 "MONTH_" . date(
"n", $timestamp) .
"_S",
1435 if ($currentLanguage ===
"en")
1437 $result .= date(
"F", $timestamp);
1442 "MONTH_" . date(
"n", $timestamp),
1449 if ($currentLanguage ===
"en")
1451 $result .= date($format_part, $timestamp);
1456 "MON_" . date(
"n", $timestamp),
1463 if ($currentLanguage ===
"en")
1465 $result .= date($format_part, $timestamp);
1470 "DAY_OF_WEEK_" . date(
"w", $timestamp),
1477 if ($currentLanguage ===
"en")
1479 $result .= date($format_part, $timestamp);
1484 "DOW_" . date(
"w", $timestamp),
1491 $dayOfMonth = date(
"j", $timestamp);
1495 $result .= str_replace(
"#DAY#", $dayOfMonth, $dayPattern);
1503 $year = date(
"Y", $timestamp);
1518 $formats[
"tomorrow"] =
"tomorrow, " . $timeFormat;
1519 $formats[
"-"] = preg_replace(
'/:s/',
'', $DB::DateFormatToPHP(CSite::GetDateFormat(
"FULL")));
1520 $formats[
"s"] =
"sago";
1521 $formats[
"i"] =
"iago";
1522 $formats[
"today"] =
"today, " . $timeFormat;
1523 $formats[
"yesterday"] =
"yesterday, " . $timeFormat;
1524 $formats[
""] = preg_replace(
'/:s/',
'', $DB::DateFormatToPHP(CSite::GetDateFormat(
"FULL")));
1529 "tomorrow" =>
"tomorrow",
1530 "-" => $DB::DateFormatToPHP(CSite::GetDateFormat(
"SHORT")),
1532 "yesterday" =>
"yesterday",
1533 "" => $DB::DateFormatToPHP(CSite::GetDateFormat(
"SHORT")),
1534 ], $timestamp, $now, $languageId);
1539 $formats[
"tomorrow"] = $timeFormat;
1540 $formats[
"today"] = $timeFormat;
1541 $formats[
"yesterday"] = $timeFormat;
1562 $days_ago = (int)(($now - $timestamp) / 60 / 60 / 24);
1563 if ($days_ago === 0)
1577 ], $timestamp, $now, $languageId);
1581 $result .= date($format_part, $timestamp);
1589 [
"/\\s*00:00:00\\s*/",
"/(\\d\\d:\\d\\d)(:00)/",
"/(\\s*00:00\\s*)(?!:)/"],
1600 $strDate = trim($strDate);
1602 if (
false === $new_format)
1604 $new_format = CSite::GetDateFormat(
'FULL');
1607 $new_format = str_replace(
"MI",
"I", $new_format);
1608 $new_format = preg_replace(
"/([DMYIHGST])\\1+/isu",
"\\1", $new_format);
1612 if (isset($arParsedDate[
"MMMM"]))
1614 if (is_numeric($arParsedDate[
"MMMM"]))
1616 $arParsedDate[
"MM"] = intval($arParsedDate[
"MMMM"]);
1620 $arParsedDate[
"MM"] =
GetNumMonth($arParsedDate[
"MMMM"]);
1621 if (!$arParsedDate[
"MM"])
1623 $arParsedDate[
"MM"] = intval(date(
'm', strtotime($arParsedDate[
"MMMM"])));
1627 elseif (isset($arParsedDate[
"MM"]))
1629 $arParsedDate[
"MM"] = intval($arParsedDate[
"MM"]);
1631 elseif (isset($arParsedDate[
"M"]))
1633 if (is_numeric($arParsedDate[
"M"]))
1635 $arParsedDate[
"MM"] = intval($arParsedDate[
"M"]);
1639 $arParsedDate[
"MM"] =
GetNumMonth($arParsedDate[
"M"],
true);
1640 if (!$arParsedDate[
"MM"])
1642 $arParsedDate[
"MM"] = intval(date(
'm', strtotime($arParsedDate[
"M"])));
1647 if (isset($arParsedDate[
"H"]))
1649 $arParsedDate[
"HH"] = intval($arParsedDate[
"H"]);
1651 elseif (isset($arParsedDate[
"GG"]))
1653 $arParsedDate[
"HH"] = intval($arParsedDate[
"GG"]);
1655 elseif (isset($arParsedDate[
"G"]))
1657 $arParsedDate[
"HH"] = intval($arParsedDate[
"G"]);
1660 if (isset($arParsedDate[
'TT']) || isset($arParsedDate[
'T']))
1662 $middletime = $arParsedDate[
'TT'] ?? $arParsedDate[
'T'];
1663 if (strcasecmp(
'pm', $middletime) === 0)
1665 if ($arParsedDate[
"HH"] < 12)
1667 $arParsedDate[
"HH"] += 12;
1671 $arParsedDate[
"HH"] -= 12;
1676 if (isset($arParsedDate[
"YYYY"]))
1678 $arParsedDate[
"YY"] = $arParsedDate[
"YYYY"];
1681 if (intval($arParsedDate[
"DD"]) <= 0 || intval($arParsedDate[
"MM"]) <= 0 || intval($arParsedDate[
"YY"]) <= 0)
1688 if (intval($arParsedDate[
"YY"]) > 1970 && intval($arParsedDate[
"YY"]) < 2038)
1691 intval($arParsedDate[
"HH"] ?? 0),
1692 intval($arParsedDate[
"MI"] ?? 0),
1693 intval($arParsedDate[
"SS"] ?? 0),
1694 intval($arParsedDate[
"MM"] ?? 0),
1695 intval($arParsedDate[
"DD"] ?? 0),
1696 intval($arParsedDate[
"YY"] ?? 0)
1699 $new_format_l = mb_strlen($new_format);
1700 $dontChange =
false;
1702 for (
$i = 0;
$i < $new_format_l;
$i++)
1704 $simbol = mb_substr($new_format,
$i, 1);
1706 if (!$dontChange && $simbol ===
"\\")
1721 $match =
GetMessage(
"MONTH_" . date(
"n", $ux_time) .
"_S");
1724 $match =
GetMessage(
"MONTH_" . date(
"n", $ux_time));
1727 $match =
GetMessage(
"MON_" . date(
"n", $ux_time));
1730 $match =
GetMessage(
"DAY_OF_WEEK_" . date(
"w", $ux_time));
1733 $match =
GetMessage(
"DOW_" . date(
"w", $ux_time));
1736 $match = date(mb_substr($new_format,
$i, 1), $ux_time);
1740 $match = str_replace(
"#DAY#", $match, $dayPattern);
1744 $match = date(mb_substr($new_format,
$i, 1), $ux_time);
1749 $strResult .= $match;
1750 $dontChange =
false;
1755 if ($arParsedDate[
"MM"] < 1 || $arParsedDate[
"MM"] > 12)
1757 $arParsedDate[
"MM"] = 1;
1759 $new_format_l = mb_strlen($new_format);
1760 $dontChange =
false;
1762 for (
$i = 0;
$i < $new_format_l;
$i++)
1764 $simbol = mb_substr($new_format,
$i, 1);
1766 if (!$dontChange && $simbol ===
"\\")
1782 $match = str_pad($arParsedDate[
"MM"], 2,
"0", STR_PAD_LEFT);
1783 if (intval($arParsedDate[
"MM"]) > 0)
1785 $match =
GetMessage(
"MONTH_" . intval($arParsedDate[
"MM"]) . ($simbol ==
'F' ?
'_S' :
''));
1789 $match = str_pad($arParsedDate[
"MM"], 2,
"0", STR_PAD_LEFT);
1790 if (intval($arParsedDate[
"MM"]) > 0)
1792 $match =
GetMessage(
"MON_" . intval($arParsedDate[
"MM"]));
1796 $match = str_pad($arParsedDate[
"DD"], 2,
"0", STR_PAD_LEFT);
1797 if (intval($arParsedDate[
"DD"]) > 0)
1799 $match =
GetMessage(
"DAY_OF_WEEK_" . intval($arParsedDate[
"DD"]));
1803 $match = str_pad($arParsedDate[
"DD"], 2,
"0", STR_PAD_LEFT);
1804 if (intval($arParsedDate[
"DD"]) > 0)
1806 $match =
GetMessage(
"DOW_" . intval($arParsedDate[
"DD"]));
1810 $match = str_pad($arParsedDate[
"DD"], 2,
"0", STR_PAD_LEFT);
1813 $match = str_pad($arParsedDate[
"MM"], 2,
"0", STR_PAD_LEFT);
1816 $match = intval($arParsedDate[
"DD"]);
1820 $match = str_replace(
"#DAY#", $match, $dayPattern);
1824 $match = str_pad($arParsedDate[
"YY"], 4,
"0", STR_PAD_LEFT);
1827 $match = mb_substr($arParsedDate[
"YY"], 2);
1830 $match = str_pad($arParsedDate[
"HH"], 2,
"0", STR_PAD_LEFT);
1833 $match = str_pad($arParsedDate[
"MI"], 2,
"0", STR_PAD_LEFT);
1836 $match = str_pad($arParsedDate[
"SS"], 2,
"0", STR_PAD_LEFT);
1839 $match = intval($arParsedDate[
"HH"]);
1842 $match = $match - 12;
1847 $match = intval($arParsedDate[
"HH"]);
1850 $match = ($match - 12) .
" PM";
1857 if (mb_substr($new_format,
$i, 1) ==
"a")
1859 $match = mb_strtolower($match);
1863 $match = mb_substr($new_format,
$i, 1);
1868 $strResult .= $match;
1869 $dontChange =
false;
1879 if ($format ===
'FULL' || $format ===
'SHORT')
1900 $format = CSite::GetDateFormat(
$type,
$site, $bSearchInSitesOnly);
1903 return date($DB::DateFormatToPHP($format), $timestamp);
1916 date(
"H", $stmp) + $add, date(
"i", $stmp), date(
"s", $stmp),
1917 date(
"m", $stmp), date(
"d", $stmp), date(
"Y", $stmp));
1921 date(
"H", $stmp), date(
"i", $stmp) + $add, date(
"s", $stmp),
1922 date(
"m", $stmp), date(
"d", $stmp), date(
"Y", $stmp));
1926 date(
"H", $stmp), date(
"i", $stmp), date(
"s", $stmp) + $add,
1927 date(
"m", $stmp), date(
"d", $stmp), date(
"Y", $stmp));
1931 date(
"H", $stmp), date(
"i", $stmp), date(
"s", $stmp),
1932 date(
"m", $stmp), date(
"d", $stmp) + $add, date(
"Y", $stmp));
1936 date(
"H", $stmp), date(
"i", $stmp), date(
"s", $stmp),
1937 date(
"m", $stmp) + $add, date(
"d", $stmp), date(
"Y", $stmp));
1941 date(
"H", $stmp), date(
"i", $stmp), date(
"s", $stmp),
1942 date(
"m", $stmp), date(
"d", $stmp), date(
"Y", $stmp) + $add);
1953 $day = $month =
$year = 0;
1954 $args = preg_split(
'#[/.-]#', $strDate);
1955 $bound = min(mb_strlen($format),
count($args));
1956 for (
$i = 0;
$i < $bound;
$i++)
1958 if ($format[
$i] ==
'm')
1960 $month = intval($args[
$i]);
1964 $day = intval($args[
$i]);
1971 return (checkdate($month, $day,
$year) ? [$day, $month,
$year] : 0);
1979 static $arr = [
"d.m.Y",
"d.m.Y H:i",
"d.m.Y H:i:s"];
1981 if (!(in_array($format,
$arr)))
1986 $strDT = preg_replace(
"/[\n\r\t ]+/",
" ", $strDT);
1988 $dateTime = explode(
" ", $strDT);
1990 $date = trim($dateTime[0] ??
'');
1991 $time = trim($dateTime[1] ??
'');
1993 $dayMonthYear = explode(
".", $date);
1995 $day = (int)($dayMonthYear[0] ?? 0);
1996 $month = (int)($dayMonthYear[1] ?? 0);
1997 $year = (int)($dayMonthYear[2] ?? 0);
1999 $hourMinSec = explode(
":",
$time);
2001 $hour = (int)($hourMinSec[0] ?? 0);
2002 $min = (int)($hourMinSec[1] ?? 0);
2003 $sec = (int)($hourMinSec[2] ?? 0);
2005 if (!checkdate($month, $day,
$year))
2009 if ($hour > 24 || $hour < 0 || $min < 0 || $min > 59 || $sec < 0 || $sec > 59)
2014 $ts = mktime($hour, $min, $sec, $month, $day,
$year);
2029 return date($format,
MkDateTime(
FmtDate($strDateTime,
"D.M.Y H:I:S"),
"d.m.Y H:i:s"));
2057 if (is_array($arSort) && !empty($arSort))
2060 foreach ($arSort as
$val)
2062 $arSort1 = explode(
" ", trim(
$val));
2063 $order = array_pop($arSort1);
2064 $order_ = mb_strtoupper(trim(
$order));
2065 if (!($order_ ==
"DESC" || $order_ ==
"ASC"))
2070 $by = implode(
" ", $arSort1);
2071 if ($by <>
'' && !array_key_exists($by, $arSort2))
2073 $arSort2[$by] = $order_;
2077 foreach ($arSort2 as $by =>
$order)
2079 $arSort[] = $by .
" " .
$order;
2092 $arr_res[
$key] = $$value;
2100 if (is_array(
$arr) && !empty(
$arr))
2102 foreach (
$arr as $value)
2105 $$value = ($$value ==
"Y") ?
"Y" :
"N";
2112 if (!is_array(
$arr))
2124 if (trim($value) ==
'')
2135 if (
$k ===
false && func_num_args() == 1)
2142 return isset(
$a[
$k]) || array_key_exists(
$k,
$a);
2156 if (is_array($pass_chars))
2162 if ($pass_chars !==
false)
2187 if (mb_strlen($strText) > $intLen)
2189 return rtrim(mb_substr($strText, 0, $intLen),
".") .
"...";
2197function InsertSpaces($sText, $iMaxChar = 80, $symbol =
" ", $bHTML =
false)
2199 $iMaxChar = intval($iMaxChar);
2200 if ($iMaxChar > 0 && mb_strlen($sText) > $iMaxChar)
2204 $obSpacer =
new CSpacer($iMaxChar, $symbol);
2205 return $obSpacer->InsertSpaces($sText);
2209 return preg_replace(
"/([^() \\n\\r\\t%!?{}\\][-]{" . $iMaxChar .
"})/u",
"\\1" . $symbol, $sText);
2225 if ($side ==
"both" || $side ==
"left")
2227 if (mb_substr(
$str, 0, 1) == $symbol)
2232 if ($side ==
"both" || $side ==
"right")
2234 if (mb_substr(
$str, -1) == $symbol)
2249 return mb_strtoupper(
$str);
2259 return mb_strtolower(
$str);
2270 if (
$lang ===
false)
2272 $lang = LANGUAGE_ID;
2278 $text = preg_replace(
"#<code(\\s+[^>]*>|>)(.+?)</code(\\s+[^>]*>|>)#is",
"[code]\\2[/code]",
$text);
2279 $text = preg_replace_callback(
"#\\[code(\\s+[^\\]]*\\]|\\])(.+?)\\[/code(\\s+[^\\]]*\\]|\\])#is", [$helper,
"convertCodeTagForEmail"],
$text);
2281 $text = preg_replace(
"/^(\r|\n)+?(.*)$/",
"\\2",
$text);
2282 $text = preg_replace(
"#<b>(.+?)</b>#is",
"\\1",
$text);
2283 $text = preg_replace(
"#<i>(.+?)</i>#is",
"\\1",
$text);
2284 $text = preg_replace(
"#<u>(.+?)</u>#is",
"_\\1_",
$text);
2285 $text = preg_replace(
"#\\[b\\](.+?)\\[/b\\]#is",
"\\1",
$text);
2286 $text = preg_replace(
"#\\[i\\](.+?)\\[/i\\]#is",
"\\1",
$text);
2287 $text = preg_replace(
"#\\[u\\](.+?)\\[/u\\]#is",
"_\\1_",
$text);
2289 $text = preg_replace(
"#<(/?)quote(.*?)>#is",
"[\\1quote]",
$text);
2291 $s =
"-------------- " . $arMsg[
"MAIN_QUOTE_S"] .
" -----------------";
2292 $text = preg_replace(
"#\\[quote(.*?)\\]#is",
"\n>" . $s .
"\n",
$text);
2293 $text = preg_replace(
"#\\[/quote(.*?)\\]#is",
"\n>" . str_repeat(
"-", mb_strlen($s)) .
"\n",
$text);
2295 if ($convert_url_tag)
2297 $text = preg_replace(
"#<a[^>]*href=[\"']?([^>\"' ]+)[\"']?[^>]*>(.+?)</a>#is",
"\\2 (URL: \\1)",
$text);
2298 $text = preg_replace(
"#\\[url\\](\\S+?)\\[/url\\]#is",
"(URL: \\1)",
$text);
2299 $text = preg_replace(
"#\\[url\\s*=\\s*(\\S+?)\\s*\\](.*?)\\[\\/url\\]#is",
"\\2 (URL: \\1)",
$text);
2302 if ($convert_image_tag)
2304 $text = preg_replace(
"#<img[^>]*src=[\"']?([^>\"' ]+)[\"']?[^>]*>#is",
" (IMAGE: \\1) ",
$text);
2305 $text = preg_replace(
"#\\[img\\](.+?)\\[/img\\]#is",
" (IMAGE: \\1) ",
$text);
2308 $text = preg_replace(
"#<ul(\\s+[^>]*>|>)#is",
"\n",
$text);
2309 $text = preg_replace(
"#<ol(\\s+[^>]*>|>)#is",
"\n",
$text);
2310 $text = preg_replace(
"#<li(\\s+[^>]*>|>)#is",
" [*] ",
$text);
2311 $text = preg_replace(
"#</li>#is",
"",
$text);
2312 $text = preg_replace(
"#</ul>#is",
"\n\n",
$text);
2313 $text = preg_replace(
"#</ol>#is",
"\n\n",
$text);
2315 $text = preg_replace(
"#\\[list\\]#is",
"\n",
$text);
2316 $text = preg_replace(
"#\\[/list\\]#is",
"\n",
$text);
2318 $text = preg_replace(
"#<br>#is",
"\n",
$text);
2319 $text = preg_replace(
"#<wbr>#is",
"",
$text);
2349 return str_replace(
$arr, $replace,
$text);
2355 return $helper->convertCodeTagForHtmlBefore(stripslashes(
$text));
2365 $helper->setCodeClasses($code_table_class, $code_head_class, $code_body_class, $code_textarea_class);
2366 return $helper->convertCodeTagForHtmlAfter(stripslashes(
$text));
2371 global $QUOTE_OPENED;
2373 return "<table class='$quote_table_class' width='95%' border='0' cellpadding='3' cellspacing='1'><tr><td class='" . $quote_head_class .
"'>" .
GetMessage(
"MAIN_QUOTE") .
"</td></tr><tr><td class='" . $quote_body_class .
"'>";
2378 global $QUOTE_ERROR, $QUOTE_OPENED, $QUOTE_CLOSED;
2379 if ($QUOTE_OPENED == 0)
2385 return "</td></tr></table>";
2390 global $QUOTE_ERROR, $QUOTE_OPENED, $QUOTE_CLOSED;
2397 $helper->setQuoteClasses($quote_table_class, $quote_head_class, $quote_body_class);
2399 $txt = preg_replace_callback(
"#\\[quote\\]#i", [$helper,
"convertOpenQuoteTag"], $txt);
2400 $txt = preg_replace_callback(
"#\\[/quote\\]#i", [$helper,
"convertCloseQuoteTag"], $txt);
2401 if ($helper->checkQuoteError())
2414 while (mb_strpos(
",}])>.", mb_substr($s, -1, 1)) !==
false)
2416 $s2 = mb_substr($s, -1, 1);
2417 $s = mb_substr($s, 0, mb_strlen($s) - 1);
2419 $res = chr(1) . $s .
"/" . chr(1) . $s2;
2423function convert_to_href(
$url, $link_class =
"", $event1 =
"", $event2 =
"", $event3 =
"", $script =
"", $link_target =
"_self")
2427 $target = $link_target ==
'_self' ?
'' :
' target="' . $link_target .
'"';
2437 $s = stripslashes($s);
2446 $QUOTE_ENABLED =
"N",
2447 $NOT_CONVERT_AMPERSAND =
"Y",
2448 $CODE_ENABLED =
"N",
2450 $quote_table_class =
"quotetable",
2451 $quote_head_class =
"tdquotehead",
2452 $quote_body_class =
"tdquote",
2453 $code_table_class =
"codetable",
2454 $code_head_class =
"tdcodehead",
2455 $code_body_class =
"tdcodebody",
2456 $code_textarea_class =
"codetextarea",
2457 $link_class =
"txttohtmllink",
2459 $link_target =
"_self"
2462 global $QUOTE_ERROR, $QUOTE_OPENED, $QUOTE_CLOSED;
2463 $QUOTE_ERROR = $QUOTE_OPENED = $QUOTE_CLOSED = 0;
2468 if ($iMaxStringLen > 0)
2474 $str = str_replace(
"\\", chr(8),
$str);
2477 if ($QUOTE_ENABLED ==
"Y")
2479 $str = preg_replace(
"#(?:<|\\[)(/?)quote(.*?)(?:>|\\])#is",
" [\\1quote]",
$str);
2485 if ($CODE_ENABLED ==
"Y")
2488 $str = preg_replace(
"#<code(\\s+[^>]*>|>)(.+?)</code(\\s+[^>]*>|>)#is",
"[code]\\2[/code]",
$str);
2489 $str = preg_replace_callback(
"#\\[code(\\s+[^\\]]*\\]|\\])(.+?)\\[/code(\\s+[^\\]]*\\]|\\])#is", [$helper,
"convertCodeTagForHtmlBefore"],
$str);
2495 if ($BIU_ENABLED ==
"Y")
2497 $str = preg_replace(
"#<b(\\s+[^>]*>|>)(.+?)</b(\\s+[^>]*>|>)#is",
"[b]\\2[/b]",
$str);
2498 $str = preg_replace(
"#<i(\\s+[^>]*>|>)(.+?)</i(\\s+[^>]*>|>)#is",
"[i]\\2[/i]",
$str);
2499 $str = preg_replace(
"#<u(\\s+[^>]*>|>)(.+?)</u(\\s+[^>]*>|>)#is",
"[u]\\2[/u]",
$str);
2507 $str = preg_replace_callback(
"#((http|https|ftp):\\/\\/[a-z:@,.'/\\#\\%=~\\&?*+\\[\\]_0-9\x01-\x08-]+)#is", [
"CConvertorsPregReplaceHelper",
"extractUrl"],
$str);
2508 $str = preg_replace(
"#(([=_\\.'0-9a-z+~\x01-\x08-]+)@[_0-9a-z\x01-\x08-.]+\\.[a-z]{2,10})#is", chr(3) .
"\\1" . chr(3),
$str);
2510 $str = str_replace(chr(11),
'@',
$str);
2514 if ($NOT_CONVERT_AMPERSAND !=
"Y")
2516 $str = str_replace(
"&",
"&",
$str);
2518 static $search = [
"<",
">",
"\"",
"'",
"%",
")",
"(",
"+"];
2519 static $replace = [
"<",
">",
""",
"'",
"%",
")",
"(",
"+"];
2520 $str = str_replace($search, $replace,
$str);
2527 $helper->setLinkClass($link_class);
2528 $helper->setLinkTarget($link_target);
2530 $str = preg_replace_callback(
"#\x01([^\n\x01]+?)/\x01#is", [$helper,
"convertToHref"],
$str);
2531 $str = preg_replace_callback(
"#\x03([^\n\x03]+?)\x03#is", [$helper,
"convertToMailTo"],
$str);
2534 $str = str_replace(
"\r\n",
"\n",
$str);
2535 $str = str_replace(
"\n",
"<br />\n",
$str);
2536 $str = preg_replace(
"# {2}#",
" ",
$str);
2537 $str = preg_replace(
"#\t#",
" ",
$str);
2540 if ($iMaxStringLen > 0)
2542 $str = str_replace(chr(2),
"<wbr>",
$str);
2546 if ($QUOTE_ENABLED ==
"Y")
2549 $helper->setQuoteClasses($quote_table_class, $quote_head_class, $quote_body_class);
2550 $str = preg_replace_callback(
"#(\\[quote(.*?)\\](.*)\\[/quote(.*?)\\])#is", [$helper,
"convertQuoteTag"],
$str);
2556 if ($CODE_ENABLED ==
"Y")
2559 $helper->setCodeClasses($code_table_class, $code_head_class, $code_body_class, $code_textarea_class);
2560 $str = preg_replace_callback(
"#\\[code\\](.*?)\\[/code\\]#is", [$helper,
"convertCodeTagForHtmlAfter"],
$str);
2561 $str = str_replace(chr(4),
"\n",
$str);
2562 $str = str_replace(chr(5),
"\r",
$str);
2563 $str = str_replace(chr(6),
" ",
$str);
2564 $str = str_replace(chr(7),
"\t",
$str);
2565 $str = str_replace(chr(16),
"[",
$str);
2566 $str = str_replace(chr(17),
"]",
$str);
2572 if ($BIU_ENABLED ==
"Y")
2574 $str = preg_replace(
"#\\[b\\](.*?)\\[/b\\]#is",
"<b>\\1</b>",
$str);
2575 $str = preg_replace(
"#\\[i\\](.*?)\\[/i\\]#is",
"<i>\\1</i>",
$str);
2576 $str = preg_replace(
"#\\[u\\](.*?)\\[/u\\]#is",
"<u>\\1</u>",
$str);
2590 $str = preg_replace(
"/[\\t\\n\\r]/",
" ",
$str);
2594 "'<script[^>]*?>.*?</script>'si",
2595 "'<style[^>]*?>.*?</style>'si",
2596 "'<svg[^>]*?>.*?</svg>'si",
2597 "'<select[^>]*?>.*?</select>'si",
2599 "'&(iexcl|#161);'i",
2615 $str = preg_replace($search, $replace,
$str);
2617 $str = preg_replace(
"#<[/]{0,1}(b|i|u|em|small|strong)>#i",
"",
$str);
2618 $str = preg_replace(
"#<div[^>]*>#i",
"\r\n",
$str);
2619 $str = preg_replace(
"#<[/]{0,1}(font|div|span)[^>]*>#i",
"",
$str);
2622 $str = preg_replace(
"#<ul[^>]*>#i",
"\r\n",
$str);
2623 $str = preg_replace(
"#<li[^>]*>#i",
"\r\n - ",
$str);
2626 foreach ($aDelete as $del_reg)
2628 $str = preg_replace($del_reg,
"",
$str);
2632 $str = preg_replace(
"/(<img\\s[^>]*?src\\s*=\\s*)([\"']?)(\\/.*?)(\\2)(\\s.+?>|\\s*>)/is",
"[" . chr(1) . $strSiteUrl .
"\\3" . chr(1) .
"] ",
$str);
2633 $str = preg_replace(
"/(<img\\s[^>]*?src\\s*=\\s*)([\"']?)(.*?)(\\2)(\\s.+?>|\\s*>)/is",
"[" . chr(1) .
"\\3" . chr(1) .
"] ",
$str);
2636 $str = preg_replace(
"/(<a\\s[^>]*?href\\s*=\\s*)([\"']?)(\\/.*?)(\\2)(.*?>)(.*?)<\\/a>/is",
"\\6 [" . chr(1) . $strSiteUrl .
"\\3" . chr(1) .
"] ",
$str);
2637 $str = preg_replace(
"/(<a\\s[^>]*?href\\s*=\\s*)([\"']?)(.*?)(\\2)(.*?>)(.*?)<\\/a>/is",
"\\6 [" . chr(1) .
"\\3" . chr(1) .
"] ",
$str);
2640 $str = preg_replace(
"#<br[^>]*>#i",
"\r\n",
$str);
2643 $str = preg_replace(
"#<p[^>]*>#i",
"\r\n\r\n",
$str);
2646 $str = preg_replace(
"#<hr[^>]*>#i",
"\r\n----------------------\r\n",
$str);
2649 $str = preg_replace(
"#<[/]{0,1}(thead|tbody)[^>]*>#i",
"",
$str);
2650 $str = preg_replace(
"#<([/]{0,1})th[^>]*>#i",
"<\\1td>",
$str);
2652 $str = preg_replace(
"#</td>#i",
"\t",
$str);
2653 $str = preg_replace(
"#</tr>#i",
"\r\n",
$str);
2654 $str = preg_replace(
"#<table[^>]*>#i",
"\r\n",
$str);
2656 $str = preg_replace(
"#\r\n[ ]+#",
"\r\n",
$str);
2659 $str = preg_replace(
"#<[/]{0,1}[^>]+>#i",
"",
$str);
2661 $str = preg_replace(
"#[ ]+ #",
" ",
$str);
2662 $str = str_replace(
"\t",
" ",
$str);
2667 $str = preg_replace(
"#(^|[\\r\\n])([^\\n\\r]{" . intval($maxlen) .
"}[^ \\r\\n]*[\\] ])([^\\r])#",
"\\1\\2\r\n\\3",
$str);
2670 $str = str_replace(chr(1),
" ",
$str);
2677 if (strtolower($strTextType) ==
"html")
2682 return TxtToHtml($strText);
2687 static $search = [
"&",
"<",
">",
""",
""",
""",
"'",
"'",
"<",
">",
"\""];
2688 static $replace = [
"&amp;",
"&lt;",
"&gt;",
"&quot;",
"&#34;",
"&#x22;",
"&#39;",
"&#x27;",
"<",
">",
"""];
2695 static $search = [
"<",
">",
""",
"'",
"&"];
2696 static $replace = [
"<",
">",
"\"",
"'",
"&"];
2704 return htmlspecialchars((
string)$string, $flags,
"UTF-8", $doubleEncode);
2710 if (!str_ends_with(
$path,
"/"))
2724 if (!file_exists(
$path))
2726 return mkdir(
$path, BX_DIR_PERMISSIONS,
true);
2729 return is_dir(
$path);
2732function CopyDirFiles($path_from, $path_to, $ReWrite =
true, $Recursive =
false, $bDeleteAfterCopy =
false, $strExclude =
"")
2734 if (mb_strpos($path_to .
"/", $path_from .
"/") === 0 || realpath($path_to) === realpath($path_from))
2739 if (is_dir($path_from))
2743 elseif (is_file($path_from))
2746 $path_to_dir = mb_substr($path_to, 0,
$p);
2749 if (file_exists($path_to) && !$ReWrite)
2754 @copy($path_from, $path_to);
2755 if (is_file($path_to))
2757 @chmod($path_to, BX_FILE_PERMISSIONS);
2760 if ($bDeleteAfterCopy)
2762 @unlink($path_from);
2772 if (
$handle = @opendir($path_from))
2774 while (($file = readdir(
$handle)) !==
false)
2776 if ($file ==
"." || $file ==
"..")
2781 if ($strExclude <>
'' && str_starts_with($file, $strExclude))
2786 if (is_dir($path_from .
"/" . $file) && $Recursive)
2788 CopyDirFiles($path_from .
"/" . $file, $path_to .
"/" . $file, $ReWrite, $Recursive, $bDeleteAfterCopy, $strExclude);
2789 if ($bDeleteAfterCopy)
2791 @rmdir($path_from .
"/" . $file);
2794 elseif (is_file($path_from .
"/" . $file))
2796 if (file_exists($path_to .
"/" . $file) && !$ReWrite)
2801 @copy($path_from .
"/" . $file, $path_to .
"/" . $file);
2802 @chmod($path_to .
"/" . $file, BX_FILE_PERMISSIONS);
2804 if ($bDeleteAfterCopy)
2806 @unlink($path_from .
"/" . $file);
2812 if ($bDeleteAfterCopy)
2835 $full_path = $root .
"/" .
$path;
2836 $full_path = preg_replace(
"#[\\\\\\/]+#",
"/", $full_path);
2839 if (is_file($full_path) || is_link($full_path))
2841 if (@unlink($full_path))
2847 elseif (is_dir($full_path))
2849 if (
$handle = opendir($full_path))
2851 while (($file = readdir(
$handle)) !==
false)
2853 if ($file ==
"." || $file ==
"..")
2865 if (!@rmdir($full_path))
2879 while ($entry = $d->read())
2881 if ($entry ==
"." || $entry ==
"..")
2885 if (in_array($entry, $arExept))
2889 @unlink($toDir .
"/" . $entry);
2903 if (!fwrite($fd, $strContent))
2914 static $FILEMAN_SCRIPT_EXT =
false;
2915 if ($FILEMAN_SCRIPT_EXT !==
false)
2917 return $FILEMAN_SCRIPT_EXT;
2920 $script_files = COption::GetOptionString(
"fileman",
"~script_files",
"php,php3,php4,php5,php6,php7,php8,phtml,pl,asp,aspx,cgi,dll,exe,ico,shtm,shtml,fcg,fcgi,fpl,asmx,pht,py,psp,var");
2921 $arScriptFiles = [];
2922 foreach (explode(
",", mb_strtolower($script_files)) as $ext)
2924 if (($e = trim($ext)) !=
"")
2926 $arScriptFiles[] = $e;
2930 $FILEMAN_SCRIPT_EXT = $arScriptFiles;
2931 return $arScriptFiles;
2936 return rtrim(
$path,
"\0.\\/+ ");
2944 $arParts = explode(
".",
$name);
2945 foreach ($arParts as
$i => $part)
2947 if (
$i > 0 && in_array(mb_strtolower(
TrimUnsafe($part)), $arExt))
2949 unset($arParts[
$i]);
2953 return $path . implode(
".", $arParts);
2961 $arParts = explode(
".", $check_name);
2962 foreach ($arParts as
$i => $part)
2964 if (
$i > 0 && in_array(mb_strtolower(
TrimUnsafe($part)), $arExt))
2980 return mb_substr(
$path, $pos + 1);
2996 return trim(
$path,
'.');
3010 return mb_substr(
$path,
$p + 1);
3021 $fileList = COption::GetOptionString(
"main",
"~unsafe_files",
".htaccess,.htpasswd,web.config,global.asax");
3022 $arFiles = explode(
",", mb_strtolower($fileList));
3033 "/bitrix/.settings.php",
3037 foreach ($list as $file)
3039 if (str_ends_with(
$path, $file))
3099 if (is_array($arrDirIndex) && !empty($arrDirIndex))
3101 foreach ($arrDirIndex as $page_index)
3103 if (file_exists($doc_root .
$dir . $page_index))
3114 static $arDefault = [
"index.php",
"index.html",
"index.htm",
"index.phtml",
"default.html",
"index.php3"];
3116 if ($strDirIndex ===
false && !defined(
"DIRECTORY_INDEX"))
3121 if ($strDirIndex ===
false && defined(
"DIRECTORY_INDEX"))
3123 $strDirIndex = DIRECTORY_INDEX;
3127 $arr = explode(
" ", $strDirIndex);
3128 foreach (
$arr as $page_index)
3130 $page_index = trim($page_index);
3131 if ($page_index <>
'')
3133 $arrRes[] = $page_index;
3141 if (
null === $get_index_page)
3143 if (defined(
'BX_DISABLE_INDEX_PAGE'))
3145 $get_index_page = !BX_DISABLE_INDEX_PAGE;
3149 $get_index_page =
true;
3157 if (
$page ===
false)
3164 static $terminate = [
"?",
"#"];
3165 foreach ($terminate as $term)
3167 if (($found = mb_strpos($sPath, $term)) !==
false)
3169 $sPath = mb_substr($sPath, 0, $found);
3174 $sPath = preg_replace(
"/%+[0-9a-f]{0,1}$/i",
"", $sPath);
3176 $sPath = urldecode($sPath);
3178 if (mb_substr($sPath, -1, 1) ==
"/" && $get_index_page)
3183 $sPath =
Rel2Abs(
"/", $sPath);
3185 static $aSearch = [
"<",
">",
"\"",
"'",
"%",
"\r",
"\n",
"\t",
"\\"];
3186 static $aReplace = [
"<",
">",
""",
"'",
"%25",
"%0d",
"%0a",
"%09",
"%5C"];
3187 $sPath = str_replace($aSearch, $aReplace, $sPath);
3194 $uriPath =
"/" . ltrim(
$_SERVER[
"REQUEST_URI"] ??
'',
"/");
3195 if (($index = mb_strpos($uriPath,
"?")) !==
false)
3197 $uriPath = mb_substr($uriPath, 0, $index);
3200 if (defined(
"BX_DISABLE_INDEX_PAGE") && BX_DISABLE_INDEX_PAGE ===
true)
3202 if (str_ends_with($uriPath,
"/index.php"))
3204 $uriPath = substr($uriPath, 0, -9);
3209 if ($queryString !=
"")
3211 $uriPath = $uriPath .
"?" . $queryString;
3220 if (
null === $get_index_page)
3222 if (defined(
'BX_DISABLE_INDEX_PAGE'))
3224 $get_index_page = !BX_DISABLE_INDEX_PAGE;
3228 $get_index_page =
true;
3232 $found = mb_strpos(
$page,
"?");
3233 $sPath = ($found !==
false ? mb_substr(
$page, 0, $found) :
$page);
3235 $sPath = urldecode($sPath);
3237 if (mb_substr($sPath, -1, 1) ==
"/" && $get_index_page)
3249 $p = mb_strrpos($sPath,
"/");
3256 return mb_substr($sPath, 0,
$p + 1);
3272 if (preg_match(
"#[^\\\\/]+$#",
$path, $match))
3279 $ext_len = mb_strlen($ext);
3280 if (mb_strlen(
$path) > $ext_len && mb_substr(
$path, -$ext_len) == $ext)
3304 if (str_starts_with($relpath,
"/") || preg_match(
"#^[a-z]:/#i", $relpath))
3310 if (!str_starts_with($curdir,
"/") && !preg_match(
"#^[a-z]:/#i", $curdir))
3312 $curdir =
"/" . $curdir;
3314 if (!str_ends_with($curdir,
"/"))
3318 $res = $curdir . $relpath;
3321 if ((mb_strpos(
$res,
"\0")) !==
false)
3328 if (!str_starts_with(
$res,
"/") && !preg_match(
"#^[a-z]:/#i",
$res))
3346 if (strncasecmp(PHP_OS,
"WIN", 3) == 0)
3349 $strPath = str_replace(
"\\",
"/", $strPath);
3352 $arPath = explode(
'/', $strPath);
3356 for (
$i = 0;
$i < $nPath;
$i++)
3362 if ((
$arPath[
$i] ===
'') && (
$i !== ($nPath - 1)) && (
$i !== 0))
3369 array_pop($pathStack);
3377 $strResult = implode(
"/", $pathStack);
3386 return "/" . ltrim(mb_substr(
$path, mb_strlen(
$_SERVER[
"DOCUMENT_ROOT"])),
"/");
3404 if (is_array($aReplace))
3406 $s = strtr($s, $aReplace);
3430 if (
$lang ===
false)
3432 $lang = LANGUAGE_ID;
3447 if (file_exists($before .
$lang . $after))
3449 return $before .
$lang . $after;
3451 if (file_exists($before .
"en" . $after))
3453 return $before .
"en" . $after;
3456 if (!str_contains($before,
"/bitrix/modules/"))
3458 return $_SERVER[
"DOCUMENT_ROOT"] .
"/bitrix/modules/main/lang/en/tools.php";
3461 $old_path = rtrim($before,
"/");
3462 $old_path = mb_substr($old_path, mb_strlen(
$_SERVER[
"DOCUMENT_ROOT"]));
3463 $path = mb_substr($old_path, 16);
3464 $module = mb_substr(
$path, 0, mb_strpos(
$path,
"/"));
3466 if (str_ends_with(
$path,
"/lang"))
3471 return $_SERVER[
"DOCUMENT_ROOT"] .
"/bitrix/modules/" . $module .
"/lang/" .
$lang .
$path . $after;
3487 $langKey = array_search(
'lang',
$arr);
3488 if ($langKey !==
false && isset(
$arr[$langKey + 1]))
3490 $language =
$arr[$langKey + 1];
3493 static $encodingCache = [];
3494 if (isset($encodingCache[$language]))
3496 [$convertEncoding, $targetEncoding, $sourceEncoding] = $encodingCache[$language];
3501 $targetEncoding = $sourceEncoding =
'';
3502 if ($convertEncoding)
3508 $encodingCache[$language] = [$convertEncoding, $targetEncoding, $sourceEncoding];
3519 if (file_exists(
$path))
3527 if ($convertEncoding)
3534 if ($convertEncoding)
3536 if ($targetEncoding !==
'utf-8' || !preg_match(
'//u',
$val))
3569 if (file_exists(
$path))
3577 static $bFirstCall =
true;
3580 $bFirstCall =
false;
3581 $fname =
getLocalPath(
"php_interface/user_lang/" . LANGUAGE_ID .
"/lang.php");
3582 if ($fname !==
false)
3593 $path = str_replace(
"\\",
"/", realpath(
$path));
3617 $filepath = rtrim(preg_replace(
"'[\\\\/]+'",
"/", $filepath),
"/ ");
3618 $module_path =
"/bitrix/modules/";
3619 $module_name = $templ_path = $file_name = $template_name =
"";
3622 "/local/templates/",
3623 BX_PERSONAL_ROOT .
"/templates/",
3625 foreach ($dirs as
$dir)
3627 if (str_contains($filepath,
$dir))
3630 $templ_pos = mb_strlen($filepath) - mb_strpos(strrev($filepath), strrev($templ_path));
3631 $rel_path = mb_substr($filepath, $templ_pos);
3632 $p = mb_strpos($rel_path,
"/");
3637 $template_name = mb_substr($rel_path, 0,
$p);
3638 $file_name = mb_substr($rel_path,
$p + 1);
3639 $p = mb_strpos($file_name,
"/");
3642 $module_name = mb_substr($file_name, 0,
$p);
3647 if ($templ_path ==
"")
3649 if (str_contains($filepath, $module_path))
3651 $templ_pos = mb_strlen($filepath) - mb_strpos(strrev($filepath), strrev($module_path));
3652 $rel_path = mb_substr($filepath, $templ_pos);
3653 $p = mb_strpos($rel_path,
"/");
3658 $module_name = mb_substr($rel_path, 0,
$p);
3659 if (defined(
"SITE_TEMPLATE_ID"))
3661 $template_name = SITE_TEMPLATE_ID;
3665 $template_name =
".default";
3667 $file_name = mb_substr($rel_path,
$p + mb_strlen(
"/install/templates/"));
3675 $BX_DOC_ROOT = rtrim(preg_replace(
"'[\\\\/]+'",
"/",
$_SERVER[
"DOCUMENT_ROOT"]),
"/ ");
3676 $module_path = $BX_DOC_ROOT . $module_path;
3678 if (
$lang ===
false)
3680 $lang = LANGUAGE_ID;
3685 if ((str_ends_with($file_name,
".description.php")) && $module_name !=
"")
3687 if ($subst_lang <>
$lang)
3689 $fname = $module_path . $module_name .
"/install/templates/lang/" . $subst_lang .
"/" . $file_name;
3691 if (file_exists($fname))
3697 $fname = $module_path . $module_name .
"/install/templates/lang/" .
$lang .
"/" . $file_name;
3699 if (file_exists($fname))
3705 $checkModule =
true;
3706 if ($templ_path <>
"")
3708 $templ_path = $BX_DOC_ROOT . $templ_path;
3709 $checkDefault =
true;
3712 if ($subst_lang <>
$lang)
3714 $fname = $templ_path . $template_name .
"/lang/" . $subst_lang .
"/" . $file_name;
3716 if (file_exists($fname))
3719 $checkDefault = $checkModule =
false;
3724 $fname = $templ_path . $template_name .
"/lang/" .
$lang .
"/" . $file_name;
3726 if (file_exists($fname))
3729 $checkDefault = $checkModule =
false;
3733 if ($checkDefault && $template_name !=
".default")
3735 if ($subst_lang <>
$lang)
3737 $fname = $templ_path .
".default/lang/" . $subst_lang .
"/" . $file_name;
3739 if (file_exists($fname))
3742 $checkModule =
false;
3746 $fname = $templ_path .
".default/lang/" .
$lang .
"/" . $file_name;
3748 if (file_exists($fname))
3751 $checkModule =
false;
3755 if ($checkModule && $module_name !=
"")
3757 if ($subst_lang <>
$lang)
3759 $fname = $module_path . $module_name .
"/install/templates/lang/" . $subst_lang .
"/" . $file_name;
3761 if (file_exists($fname))
3767 $fname = $module_path . $module_name .
"/install/templates/lang/" .
$lang .
"/" . $file_name;
3769 if (file_exists($fname))
3780 if (
$lang ===
false && $bReturnArray ===
false)
3786 $filepath = rtrim(preg_replace(
"'[\\\\/]+'",
"/", $filepath),
"/ ");
3787 $module_path =
"/modules/";
3788 if (str_contains($filepath, $module_path))
3790 $pos = mb_strlen($filepath) - mb_strpos(strrev($filepath), strrev($module_path));
3791 $rel_path = mb_substr($filepath, $pos);
3792 $p = mb_strpos($rel_path,
"/");
3798 $module_name = mb_substr($rel_path, 0,
$p);
3799 $rel_path = mb_substr($rel_path,
$p + 1);
3800 $BX_DOC_ROOT = rtrim(preg_replace(
"'[\\\\/]+'",
"/",
$_SERVER[
"DOCUMENT_ROOT"]),
"/ ");
3801 $module_path = $BX_DOC_ROOT .
getLocalPath($module_path . $module_name);
3803 elseif (str_contains($filepath,
"/.last_version/"))
3805 $pos = mb_strlen($filepath) - mb_strpos(strrev($filepath), strrev(
"/.last_version/"));
3806 $rel_path = mb_substr($filepath, $pos);
3807 $module_path = mb_substr($filepath, 0, $pos - 1);
3814 if (
$lang ===
false)
3816 $lang = (defined(
'LANGUAGE_ID') ? LANGUAGE_ID :
'en');
3822 if ($lang_subst <>
$lang)
3824 $fname = $module_path .
"/lang/" . $lang_subst .
"/" . $rel_path;
3826 if (file_exists($fname))
3832 $fname = $module_path .
"/lang/" .
$lang .
"/" . $rel_path;
3834 if (file_exists($fname))
3839 $arMess = array_merge($arMess, $msg);
3859function mydump($thing, $maxdepth = -1, $depth = 0)
3862 $fmt = sprintf(
"%%%ds", 4 * $depth);
3863 $pfx = sprintf($fmt,
"");
3864 $type = gettype($thing);
3865 if (
$type ==
'array')
3867 $n =
sizeof($thing);
3868 $res .=
"$pfx array($n) => \n";
3869 foreach (array_keys($thing) as
$key)
3871 $res .=
" $pfx" .
"[" .
$key .
"] =>\n";
3877 $n = mb_strlen($thing);
3878 $res .=
"$pfx string($n) =>\n";
3879 $res .=
"$pfx\"" . $thing .
"\"\n";
3883 $name = get_class($thing);
3884 $res .=
"$pfx object($name) =>\n";
3885 $methodArray = get_class_methods(
$name);
3886 foreach (array_keys($methodArray) as $m)
3888 $res .=
" $pfx method($m) => $methodArray" .
"[" . $m .
"]\n";
3890 $classVars = get_class_vars(
$name);
3891 foreach (array_keys($classVars) as $v)
3893 $res .=
" $pfx default => $v =>\n";
3894 $res .=
mydump($classVars[$v], $maxdepth, $depth + 2);
3896 $objectVars = get_object_vars($thing);
3897 foreach (array_keys($objectVars) as $v)
3899 $res .=
" $pfx $v =>\n";
3900 $res .=
mydump($objectVars[$v], $maxdepth, $depth + 2);
3907 $res .=
"$pfx boolean(true)\n";
3911 $res .=
"$pfx boolean(false)\n";
3916 $res .=
"$pfx $type(" . $thing .
")\n";
3924 if (defined(
'ERROR_EMAIL') && ERROR_EMAIL <>
'')
3926 $from = (defined(
'ERROR_EMAIL_FROM') && ERROR_EMAIL_FROM <>
'' ? ERROR_EMAIL_FROM :
'error@bitrix.ru');
3927 $reply_to = (defined(
'ERROR_EMAIL_REPLY_TO') && ERROR_EMAIL_REPLY_TO <>
'' ? ERROR_EMAIL_REPLY_TO :
'admin@bitrix.ru');
3930 "HTTP_GET_VARS:\n" .
mydump($_GET) .
"\n\n" .
3931 "HTTP_POST_VARS:\n" .
mydump($_POST) .
"\n\n" .
3932 "HTTP_COOKIE_VARS:\n" .
mydump($_COOKIE) .
"\n\n" .
3934 "From: " . $from .
"\r\n" .
3935 "Reply-To: " . $reply_to .
"\r\n" .
3936 "X-Mailer: PHP/" . phpversion()
3943 if (defined(
'LOG_FILENAME') && LOG_FILENAME <>
'')
3946 if ($logger ===
null)
3950 $logger->setFormatter($formatter);
3954 if ($traceDepth > 0)
3960 'module' => $module,
3967 . ($module !=
'' ?
"Module: {module}\n" :
'')
3980 static $search = [
"\t",
"\n",
"\r"];
3981 static $replace =
" ";
3983 if (defined(
'ANALYTICS_FILENAME') && is_writable(ANALYTICS_FILENAME))
3985 if ($user_id ===
null && is_object(
$USER) && !defined(
"BX_CHECK_AGENT_START"))
3987 $user_id =
$USER->GetID();
3992 .
"\t" . str_replace($search, $replace, $module)
3993 .
"\t" . str_replace($search, $replace,
$action)
3994 .
"\t" . str_replace($search, $replace, $tag)
3995 .
"\t" . str_replace($search, $replace, $label)
3996 .
"\t" . str_replace($search, $replace, $action_type)
3997 .
"\t" . intval($user_id)
4007 $redirectResponse = Context::getCurrent()->getResponse()->redirectTo(
$url);
4009 ->setSkipSecurity($skip_security_check)
4013 Application::getInstance()->end(0, $redirectResponse);
4022function FindUserID($tag_name, $tag_value, $user_name =
"", $form_name =
"form1", $tag_size =
"3", $tag_maxlength =
"", $button_value =
"...", $tag_class =
"typeinput", $button_class =
"tablebodybutton", $search_page =
"/bitrix/admin/user_search.php")
4027 $selfFolderUrl = (defined(
"SELF_FOLDER_URL") ? SELF_FOLDER_URL :
"/bitrix/admin/");
4028 $search_page = str_replace(
"/bitrix/admin/",
$selfFolderUrl, $search_page);
4029 $tag_name_x = preg_replace(
"/([^a-z0-9]|\\[|\\])/is",
"x", $tag_name);
4033<input type=\"text\" name=\"" . $tag_name .
"\" id=\"" . $tag_name .
"\" value=\"" .
htmlspecialcharsbx($tag_value) .
"\" size=\"" . $tag_size .
"\" maxlength=\"" . $tag_maxlength .
"\" class=\"" . $tag_class .
"\">
4034<iframe style=\"width:0; height:0; border:0\" src=\"javascript:''\" name=\"hiddenframe" . $tag_name .
"\" id=\"hiddenframe" . $tag_name .
"\"></iframe>
4035<input class=\"" . $button_class .
"\" type=\"button\" name=\"FindUser\" id=\"FindUser\" OnClick=\"window.open('" . $search_page .
"?lang=" . LANGUAGE_ID .
"&FN=" . $form_name .
"&FC=" . $tag_name .
"', '', 'scrollbars=yes,resizable=yes,width=760,height=500,top='+Math.floor((screen.height - 560)/2-14)+',left='+Math.floor((screen.width - 760)/2-5));\" value=\"" . $button_value .
"\">
4036<span id=\"div_" . $tag_name .
"\" class=\"adm-filter-text-search\">" . $user_name .
"</span>
4039 if ($user_name ==
"")
4041 $strReturn .=
"var tv" . $tag_name_x .
"='';\n";
4045 $strReturn .=
"var tv" . $tag_name_x .
"='" . CUtil::JSEscape($tag_value) .
"';\n";
4049function Ch" . $tag_name_x .
"()
4051 var DV_" . $tag_name_x .
";
4052 DV_" . $tag_name_x .
" = BX(\"div_" . $tag_name .
"\");
4053 if (!!DV_" . $tag_name_x .
")
4055 if (tv" . $tag_name_x .
"!=document." . $form_name .
"['" . $tag_name .
"'].value)
4057 tv" . $tag_name_x .
"=document." . $form_name .
"['" . $tag_name .
"'].value;
4058 if (tv" . $tag_name_x .
"!='')
4060 DV_" . $tag_name_x .
".innerHTML = '<i>" .
GetMessage(
"MAIN_WAIT") .
"</i>';
4061 BX(\"hiddenframe" . $tag_name .
"\").src='get_user.php?ID=' + tv" . $tag_name_x .
"+'&strName=" . $tag_name .
"&lang=" . LANG . (defined(
"ADMIN_SECTION") &&
ADMIN_SECTION ===
true ?
"&admin_section=Y" :
"") .
"';
4065 DV_" . $tag_name_x .
".innerHTML = '';
4069 setTimeout(function(){Ch" . $tag_name_x .
"()},1000);
4073 //js error during admin filter initialization, IE9, http://msdn.microsoft.com/en-us/library/gg622929%28v=VS.85%29.aspx?ppud=4, mantis: 33208
4076 setTimeout(function(){Ch" . $tag_name_x .
"()},3000);
4079 Ch" . $tag_name_x .
"();
4088 <input type=\"text\" name=\"$tag_name\" id=\"$tag_name\" value=\"" .
htmlspecialcharsbx($tag_value) .
"\" size=\"$tag_size\" maxlength=\"strMaxLenght\">
4089 <input type=\"button\" name=\"FindUser\" id=\"FindUser\" OnClick=\"window.open('" . $search_page .
"?lang=" . LANGUAGE_ID .
"&FN=$form_name&FC=$tag_name', '', 'scrollbars=yes,resizable=yes,width=760,height=560,top='+Math.floor((screen.height - 560)/2-14)+',left='+Math.floor((screen.width - 760)/2-5));\" value=\"$button_value\">
4098 $URL = COption::GetOptionString(
'main',
'whois_service_url',
'http://whois.domaintools.com/#IP#');
4099 $URL = str_replace(
"#IP#", urlencode($ip), $URL);
4100 return '<a href="' . $URL .
'"' . ($class <>
'' ?
' class="' . $class .
'"' :
'') .
' target="_blank" title="' .
GetMessage(
"WHOIS_SERVICE") .
'">' .
htmlspecialcharsbx($ip) .
'</a>';
4105 global $HTTP_USER_AGENT;
4107 !str_contains($HTTP_USER_AGENT,
"Opera")
4108 && preg_match(
'#(MSIE|Internet Explorer) ([0-9]+)\\.([0-9]+)#', $HTTP_USER_AGENT, $version)
4111 if (intval($version[2]) > 0)
4113 return doubleval($version[2] .
"." . $version[3]);
4129 return $msg[
"COUNTRY_" . $id] ??
'';
4136 if (is_array($arMsg))
4138 foreach ($arMsg as $id =>
$country)
4140 if (str_starts_with($id,
"COUNTRY_"))
4147 $arCountry = [
"reference_id" => array_keys(
$arr),
"reference" => array_values(
$arr)];
4151function GetCountries(
$lang = LANGUAGE_ID)
4153 static $countries =
null;
4154 if (isset($countries[
$lang]))
4156 return $countries[
$lang];
4159 include __DIR__ .
'/countries.php';
4162 $countries[
$lang] = [];
4164 foreach ($arCounries as
$country => $countryId)
4169 'NAME' => $msg[
'COUNTRY_' . $countryId],
4172 return $countries[
$lang];
4178 $countries = GetCountries();
4180 return $countries[
$code][
'ID'] ??
false;
4183function GetCountryCodeById($countryId)
4185 $countryId = (int)$countryId;
4187 static $countryCodes =
null;
4188 if ($countryCodes ===
null)
4190 include __DIR__ .
'/countries.php';
4192 $countryCodes = array_flip($arCounries);
4195 return $countryCodes[$countryId] ??
'';
4200 $minver = explode(
".", $vercheck);
4201 $curver = explode(
".", phpversion());
4202 if ((intval($curver[0]) < intval($minver[0])) || ((intval($curver[0]) == intval($minver[0])) && (intval($curver[1]) < intval($minver[1]))) || ((intval($curver[0]) == intval($minver[0])) && (intval($curver[1]) == intval($minver[1])) && (intval($curver[2]) < intval($minver[2]))))
4215 '_GET' => 1,
'_SESSION' => 1,
'_POST' => 1,
'_COOKIE' => 1,
'_REQUEST' => 1,
'_FILES' => 1,
'_SERVER' => 1,
'GLOBALS' => 1,
'_ENV' => 1,
4216 'DBType' => 1,
'DBDebug' => 1,
'DBDebugToFile' => 1,
'DBHost' => 1,
'DBName' => 1,
'DBLogin' => 1,
'DBPassword' => 1,
4217 'HTTP_ENV_VARS' => 1,
'HTTP_GET_VARS' => 1,
'HTTP_POST_VARS' => 1,
'HTTP_POST_FILES' => 1,
'HTTP_COOKIE_VARS' => 1,
'HTTP_SERVER_VARS' => 1,
4221 foreach ($superglobals as $gl => $t)
4226 unset($_COOKIE[$gl]);
4230 if (!$register_globals)
4236 if (!isset($superglobals[
$key]))
4244 if (!isset($superglobals[
$key]))
4252 if (!isset($superglobals[
$key]))
4260 if (!isset($superglobals[
$key]))
4268 if (!isset($superglobals[
$key]))
4274 foreach ($toGlobals as
$key =>
$val)
4287function QueryGetData($SITE, $PORT, $PATH, $QUERY_STR, &$errno, &$errstr, $sMethod =
"GET", $sProto =
"", $sContentType =
'N')
4294 $PATH . ($sMethod ==
'GET' ? ((!str_contains($PATH,
'?') ?
'?' :
'&') . $QUERY_STR) :
''),
4295 $sMethod ==
'POST' ? $QUERY_STR :
false,
4300 $errno = $ob->errno;
4301 $errstr = $ob->errstr;
4309 $vals = $index = $array = [];
4310 $parser = xml_parser_create(
"ISO-8859-1");
4311 xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
4312 xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
4313 xml_parse_into_struct($parser,
$data, $vals, $index);
4314 xml_parser_free($parser);
4318 $tagname = $vals[
$i][
'tag'];
4319 if (isset($vals[
$i][
'attributes']))
4321 $array[$tagname][
'@'] = $vals[
$i][
'attributes'];
4325 $array[$tagname][
'@'] = [];
4337 if (isset($vals[
$i][
'value']))
4344 switch ($vals[
$i][
'type'])
4347 $tagname = $vals[
$i][
'tag'] ??
'';
4358 if (isset($vals[
$i][
'attributes']))
4360 $children[$tagname][$size][
'@'] = $vals[
$i][
"attributes"];
4370 $tagname = $vals[
$i][
'tag'];
4381 if (isset($vals[
$i][
'value']))
4383 $children[$tagname][$size][
"#"] = $vals[
$i][
'value'];
4390 if (isset($vals[
$i][
'attributes']))
4392 $children[$tagname][$size][
'@'] = $vals[
$i][
'attributes'];
4404function Help($module =
"", $anchor =
"", $help_file =
"")
4408 if ($help_file ==
'')
4414 $anchor =
"#" . $anchor;
4417 if ($IS_HELP !==
true)
4423 function Help(file, module, anchor)
4425 window.open('" .
BX_ROOT .
"/tools/help_view.php?local=Y&file='+file+'&module='+module+'&lang=" . LANGUAGE_ID .
"'+anchor, '','scrollbars=yes,resizable=yes,width=" .
$width .
",height=" . $height .
",top='+Math.floor((screen.height - " . $height .
")/2-14)+',left='+Math.floor((screen.width - " .
$width .
")/2-5));
4430 echo
"<a href=\"javascript:Help('" . urlencode($help_file) .
"','" . $module .
"','" . $anchor .
"')\" title='" .
GetMessage(
"TOOLS_HELP") .
"'><img src='" .
BX_ROOT .
"/images/main/show_help.gif' width='16' height='16' border='0' alt='" .
GetMessage(
"TOOLS_HELP") .
"' align='absbottom' vspace='2' hspace='1'></a>";
4452 $end = mb_strpos(
$url,
"#");
4453 $length = ($end > 0) ? $end -
$start - 1 : mb_strlen(
$url);
4471 $str = str_replace([
"<br>",
"<br />",
"<BR>",
"<BR />"],
"\n",
$str);
4485 "bitrix:system.show_message",
4488 "MESSAGE" => $strNote,
4493 "HIDE_ICONS" =>
"Y",
4507 "bitrix:system.show_message",
4515 "HIDE_ICONS" =>
"Y",
4526 if (!is_array($arMess))
4528 $arMess = [
"MESSAGE" => $arMess,
"TYPE" =>
"ERROR"];
4531 if (!empty($arMess[
"MESSAGE"]))
4534 "bitrix:system.show_message",
4537 "MESSAGE" => $arMess[
"MESSAGE"],
4538 "STYLE" => ($arMess[
"TYPE"] ==
"OK" ?
"notetext" :
"errortext"),
4542 "HIDE_ICONS" =>
"Y",
4556 foreach (array_keys($aParams) as
$key)
4558 foreach ($ParamNames as $param)
4560 if (strcasecmp($param,
$key) == 0)
4562 unset($aParams[
$key]);
4568 return http_build_query($aParams,
"",
"&");
4576 if (preg_match(
"#.*?[<\\[\\(](.*?)[>\\]\\)].*#i",
$email,
$arr) &&
$arr[1] <>
'')
4584 if (mb_strlen(
$email) > 320)
4592 static $atom =
"\\p{L}=_0-9a-z+~'!\$&*^`|\\#%/?{}-";
4593 static $domain =
"\\p{L}a-z0-9-";
4597 if (preg_match(
"#^[{$atom}]+(\\.[{$atom}]+)*@(([{$domain}]+\\.)+)([{$domain}]{2,20})$#ui",
$email))
4602 $parts = explode(
'@',
$email);
4603 $host = $parts[1] .
'.';
4605 return (checkdnsrr(
$host,
'MX') || checkdnsrr(
$host,
'A'));
4617 if (!isset($$varname))
4625 $n = mb_strlen($prefix);
4628 if (strncmp(
$key, $prefix,
$n) == 0)
4637 $eps = 1.00 / pow(10, $prec + 4);
4638 return round(doubleval($value) + $eps, $prec);
4645 $value =
"0" . $value;
4647 $value =
roundEx(DoubleVal($value), $len);
4648 $value = sprintf(
"%01." . $dec .
"f", $value);
4649 if ($len > 0 && mb_strlen($value) > $len - $dec)
4651 $value = trim(mb_substr($value, 0, $len - $dec),
".");
4673 Application::getInstance()->getKernelSession()->set(
"fixed_session_id",
$val);
4678 return md5(CMain::GetServerUniqID() . Application::getInstance()->getKernelSession()->getId());
4683 return md5(
"nobody" . CMain::GetServerUniqID() .
"nowhere");
4688 $request = Main\Context::getCurrent()->getRequest();
4702 static $invocations = 0;
4703 if ($returnInvocations)
4705 return $invocations;
4708 $id = $invocations ? $varname .
'_' . $invocations : $varname;
4711 return '<input type="hidden" name="' . $varname .
'" id="' . $id .
'" value="' .
bitrix_sessid() .
'" />';
4716 return ($strUrl ==
'' ? $strText :
"<a href=\"" . $strUrl .
"\" " . $sParams .
">" . $strText .
"</a>");
4724 $APPLICATION->AddHeadString(
'<script>var ajaxMessages = {wait:"' . CUtil::JSEscape(
GetMessage(
'AJAX_WAIT')) .
'"}</script>',
true);
4725 $APPLICATION->AddHeadScript(
'/bitrix/js/main/cphttprequest.js',
true);
4730 if ($default_value ===
false)
4732 $default_value =
"left=" .
GetMessage(
"main_tools_menu_left") .
",top=" .
GetMessage(
"main_tools_menu_top");
4735 $mt = COption::GetOptionString(
"fileman",
"menutypes", $default_value,
$site);
4741 $armt_ = unserialize(stripslashes($mt), [
'allowed_classes' =>
false]);
4743 if (is_array($armt_))
4757 $armt_ = explode(
",", $mt);
4760 $pos = mb_strpos($armt_[
$i],
'=');
4765 $key = trim(mb_substr($armt_[
$i], 0, $pos));
4770 $armt[
$key] = trim(mb_substr($armt_[
$i], $pos + 1));
4777 return COption::SetOptionString(
'fileman',
"menutypes", addslashes(serialize(
$armt)),
$description,
$site);
4786 $prolog = $epilog =
'';
4788 $php_doubleq =
false;
4789 $php_singleq =
false;
4790 $php_comment =
false;
4791 $php_star_comment =
false;
4792 $php_line_comment =
false;
4794 if (!empty(
$params[
"use_php_parser"]) && str_starts_with(
$filesrc,
"<?"))
4796 $phpChunks = PHPParser::getPhpChunks(
$filesrc);
4797 if (!empty($phpChunks))
4799 $prolog = $phpChunks[0];
4810 $ch1 = mb_substr($ch2, 0, 1);
4812 if ($ch2 ==
"?>" && !$php_doubleq && !$php_singleq && !$php_star_comment)
4817 elseif (!$php_comment && $ch2 ==
"//" && !$php_doubleq && !$php_singleq)
4819 $php_comment = $php_line_comment =
true;
4822 elseif ($php_line_comment && ($ch1 ==
"\n" || $ch1 ==
"\r" || $ch2 ==
"?>"))
4824 $php_comment = $php_line_comment =
false;
4826 elseif (!$php_comment && $ch2 ==
"/*" && !$php_doubleq && !$php_singleq)
4828 $php_comment = $php_star_comment =
true;
4831 elseif ($php_star_comment && $ch2 ==
"*/")
4833 $php_comment = $php_star_comment =
false;
4838 if (($php_doubleq || $php_singleq) && $ch2 ==
"\\\\")
4842 elseif (!$php_doubleq && $ch1 ==
'"')
4844 $php_doubleq =
true;
4846 elseif ($php_doubleq && $ch1 ==
'"' && mb_substr(
$filesrc,
$p - 1, 1) !=
'\\')
4848 $php_doubleq =
false;
4852 if (!$php_singleq && $ch1 ==
"'")
4854 $php_singleq =
true;
4856 elseif ($php_singleq && $ch1 ==
"'" && mb_substr(
$filesrc,
$p - 1, 1) !=
'\\')
4858 $php_singleq =
false;
4869 elseif (preg_match(
"'(.*?<title>.*?</title>)(.*)$'is",
$filesrc, $reg))
4880 if (preg_match_all(
"'\\\$APPLICATION->SetPageProperty\\(([\"\\'])(.*?)(?<!\\\\)[\"\\'] *, *([\"\\'])(.*?)(?<!\\\\)[\"\\']\\);'i", $prolog, $out))
4882 foreach ($out[2] as
$i => $m1)
4891 if (isset($phpChunks) &&
count($phpChunks) > 1)
4893 $epilog = $phpChunks[
count($phpChunks) - 1];
4899 while ((
$p > 0) && (mb_substr(
$filesrc,
$p, 2) !=
"<?"))
4909 "PROLOG" => $prolog,
4911 "PROPERTIES" => $arPageProps,
4913 "EPILOG" => $epilog,
4919 if ($encloser ==
"'")
4921 $from = [
"\\",
"'"];
4922 $to = [
"\\\\",
"\\'"];
4926 $from = [
"\\",
"\$",
"\""];
4927 $to = [
"\\\\",
"\\\$",
"\\\""];
4930 return str_replace($from, $to,
$str);
4935 if ($encloser ==
"'")
4937 $from = [
"\\\\",
"\\'"];
4942 $from = [
"\\\\",
"\\\$",
"\\\""];
4943 $to = [
"\\",
"\$",
"\""];
4946 return str_replace($from, $to,
$str);
4951 if (preg_match(
'/(^|;)[OC]\\:\\+{0,1}\\d+:/',
$str))
4961 $minLength = intval($minLength);
4962 if ($minLength <= 0 || mb_strlen($number) < $minLength)
4967 if (mb_strlen($number) >= 10 && str_starts_with($number,
'+8'))
4969 $number =
'00' . mb_substr($number, 1);
4972 $number = preg_replace(
"/[^0-9\#\*,;]/i",
"", $number);
4973 if (mb_strlen($number) >= 10)
4975 if (str_starts_with($number,
'80') || str_starts_with($number,
'81') || str_starts_with($number,
'82'))
4978 elseif (str_starts_with($number,
'00'))
4980 $number = substr($number, 2);
4982 elseif (str_starts_with($number,
'011'))
4984 $number = substr($number, 3);
4986 elseif (str_starts_with($number,
'8'))
4988 $number =
'7' . substr($number, 1);
4990 elseif (str_starts_with($number,
'0'))
4992 $number = substr($number, 1);
5010 'arguments' => (
object)[
5012 'subject' => &$subject,
5014 'additional_headers' => &$additional_headers,
5015 'additional_parameters' => &$additional_parameters,
5022 $defaultMailConfiguration = Configuration::getValue(
"smtp");
5024 is_array($defaultMailConfiguration)
5025 && isset($defaultMailConfiguration[
'enabled'])
5026 && $defaultMailConfiguration[
'enabled'] ===
true;
5032 || (!empty($defaultMailConfiguration[
'host']) && !empty($defaultMailConfiguration[
'login']))
5037 return $mailer->sendMailBySmtp($to, $subject,
$message, $additional_headers, $additional_parameters);
5043 if (function_exists(
"custom_mail"))
5045 return custom_mail($to, $subject,
$message, $additional_headers, $additional_parameters,
$context);
5048 if ($additional_parameters !=
"")
5050 return @mail($to, $subject,
$message, $additional_headers, $additional_parameters);
5053 return @mail($to, $subject,
$message, $additional_headers);
5061 Application::resetAccelerator();
5087function sortByColumn(
array &$array, $columns, $callbacks =
'', $defaultValueIfNotSetValue =
null, $preserveKeys =
false)
5094 $root = rtrim(
$_SERVER[
"DOCUMENT_ROOT"],
"\\/");
5096 static $hasLocalDir =
null;
5097 if ($hasLocalDir ===
null)
5099 $hasLocalDir = is_dir($root .
"/local");
5102 if ($hasLocalDir && file_exists($root .
"/local/" .
$path))
5104 return "/local/" .
$path;
5106 elseif (file_exists($root . $baseFolder .
"/" .
$path))
5108 return $baseFolder .
"/" .
$path;
5112 if (empty(
$_SERVER[
"DOCUMENT_ROOT"]) || defined(
'REPOSITORY_ROOT'))
5114 $root = realpath(__DIR__ .
'/../../');
5132 Application::getInstance()->getKernelSession()->set(
"IS_EXPIRED", $pIsExpired);
5140 return Application::getInstance()->getKernelSession()->get(
"IS_EXPIRED") ===
true;
5145function ShowImage($PICTURE_ID, $iMaxW = 0, $iMaxH = 0, $sParams =
false, $strImageUrl =
"", $bPopup =
false, $strPopupTitle =
false, $iSizeWHTTP = 0, $iSizeHHTTP = 0)
5147 return CFile::ShowImage($PICTURE_ID, $iMaxW, $iMaxH, $sParams, $strImageUrl, $bPopup, $strPopupTitle, $iSizeWHTTP, $iSizeHHTTP);
5152 CPHPCache::ClearCache($full, $initdir);
5165function AddEventHandler($FROM_MODULE_ID, $MESSAGE_ID, $CALLBACK, $SORT = 100, $FULL_PATH =
false)
5168 return $eventManager->addEventHandlerCompatible($FROM_MODULE_ID, $MESSAGE_ID, $CALLBACK, $FULL_PATH, $SORT);
5174 return $eventManager->removeEventHandler($FROM_MODULE_ID, $MESSAGE_ID, $iEventHandlerKey);
5180 $arrResult =
$eventManager->findEventHandlers($MODULE_ID, $MESSAGE_ID);
5182 foreach ($arrResult as
$k =>
$event)
5184 $arrResult[
$k][
'FROM_MODULE_ID'] = $MODULE_ID;
5185 $arrResult[
$k][
'MESSAGE_ID'] = $MESSAGE_ID;
5194 $resRS =
new CDBResult;
5195 $resRS->InitFromArray($arrResult);
5206 for (
$i = 1, $nArgs = func_num_args();
$i < $nArgs;
$i++)
5208 $args[] = func_get_arg(
$i);
5219 isset($arEvent[
"TO_MODULE_ID"])
5220 && $arEvent[
"TO_MODULE_ID"] <>
""
5221 && $arEvent[
"TO_MODULE_ID"] <>
"main"
5224 if (!CModule::IncludeModule($arEvent[
"TO_MODULE_ID"]))
5230 isset($arEvent[
"TO_PATH"])
5231 && $arEvent[
"TO_PATH"] <>
""
5232 && file_exists(
$_SERVER[
"DOCUMENT_ROOT"] .
BX_ROOT . $arEvent[
"TO_PATH"])
5238 isset($arEvent[
"FULL_PATH"])
5239 && $arEvent[
"FULL_PATH"] <>
""
5240 && file_exists($arEvent[
"FULL_PATH"])
5243 $result = include_once($arEvent[
"FULL_PATH"]);
5246 if ((empty($arEvent[
"TO_CLASS"]) || empty($arEvent[
"TO_METHOD"])) && !isset($arEvent[
"CALLBACK"]))
5251 if (isset($arEvent[
"TO_METHOD_ARG"]) && is_array($arEvent[
"TO_METHOD_ARG"]) && !empty($arEvent[
"TO_METHOD_ARG"]))
5253 $args = array_merge($arEvent[
"TO_METHOD_ARG"],
$arParams);
5261 global $BX_MODULE_EVENT_LAST;
5262 $BX_MODULE_EVENT_LAST = $arEvent;
5264 if (isset($arEvent[
"CALLBACK"]))
5266 $result = call_user_func_array($arEvent[
"CALLBACK"], $args);
5271 if (class_exists($arEvent[
"TO_CLASS"]) && is_callable([$arEvent[
"TO_CLASS"], $arEvent[
"TO_METHOD"]]))
5273 $result = call_user_func_array([$arEvent[
"TO_CLASS"], $arEvent[
"TO_METHOD"]], $args);
5277 $exception =
new SystemException(
"Event handler error: could not invoke {$arEvent["TO_CLASS
"]}::{$arEvent["TO_METHOD
"]}. Class or method does not exist.");
5279 $exceptionHandler =
$application->getExceptionHandler();
5280 $exceptionHandler->writeToLog($exception);
5292 $eventManager->unRegisterEventHandler($FROM_MODULE_ID, $MESSAGE_ID, $TO_MODULE_ID, $TO_CLASS, $TO_METHOD, $TO_PATH, $TO_METHOD_ARG);
5295function RegisterModuleDependences($FROM_MODULE_ID, $MESSAGE_ID, $TO_MODULE_ID, $TO_CLASS =
"", $TO_METHOD =
"", $SORT = 100, $TO_PATH =
"", $TO_METHOD_ARG = [])
5298 $eventManager->registerEventHandlerCompatible($FROM_MODULE_ID, $MESSAGE_ID, $TO_MODULE_ID, $TO_CLASS, $TO_METHOD, $SORT, $TO_PATH, $TO_METHOD_ARG);
5309 $i = array_search(
"modules",
$arr);
5321 return (version_compare($version1, $version2) >= 0);
if(!Loader::includeModule('catalog')) if(!AccessController::getCurrent() ->check(ActionDictionary::ACTION_PRICE_EDIT)) if(!check_bitrix_sessid()) $request
static getBool(string $param)
static getBackTrace($limit=0, $options=null, $skip=1)
static create(string $id, $params=[])
static loadMessages($file)
static getDefaultLang($lang)
static getMessage($code, $replace=null, $language=null)
static getSourceEncoding($lang)
static getCurrentEncoding()
static needConvertEncoding($language, $targetEncoding=null)
static checkPathRestrictionConvertEncoding($langFile)
static convertLangPath($langFile, $language)
static getInstance(Context $context)
static unRegisterModule($moduleName)
static registerModule($moduleName)
static isModuleInstalled($moduleName)
static getString($length, $caseSensitive=false)
static getStringByArray(int $length, array $charsetList)
static getStringByCharsets($length, $charsetList)
static convertEncoding($data, $charsetFrom, $charsetTo)
static str_replace($search, $replace, $str)
static getLastPosition($haystack, $needle)
static sortByColumn(array &$array, $columns, $callbacks='', $defaultValueIfNotSetValue=null, $preserveKeys=false)
static CalendarDate($sFieldName, $sValue="", $size="10", $bTime=false)
static CalendarPeriod($sFromName, $sToName, $sFromVal="", $sToVal="", $bSelectShow=false, $size=10, $bTime=false)
static Calendar($sFieldName, $sFromName="", $sToName="", $bTime=false)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if(Loader::includeModule( 'bitrix24')) elseif(Loader::includeModule('intranet') &&CIntranetUtils::getPortalZone() !=='ru') $description
$_SERVER["DOCUMENT_ROOT"]
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
const AM_PM_NONE(!defined('BX_CRONTAB_SUPPORT'))
if(!defined('SITE_ID')) $lang
CheckSerializedData($str, $max_depth=200)
EscapePHPString($str, $encloser='"')
IsAmPmMode($returnConst=false)
mydump($thing, $maxdepth=-1, $depth=0)
bitrix_sessid_post($varname='sessid', $returnInvocations=false)
ClearVars($prefix="str_")
ConvertDateTime($datetime, $to_format=false, $from_site=false, $bSearchInSitesOnly=false)
WriteFinalMessage($message="")
minimumPHPVersion($vercheck)
check_bitrix_sessid($varname='sessid')
roundDB($value, $len=18, $dec=4)
convert_open_quote_tag($quote_table_class, $quote_head_class, $quote_body_class)
PHPFormatDateTime($strDateTime, $format="d.m.Y H:i:s")
InsertSpaces($sText, $iMaxChar=80, $symbol=" ", $bHTML=false)
GetDirectoryIndex($path, $strDirIndex=false)
GetDirIndexArray($strDirIndex=false)
ExecuteModuleEventEx($arEvent, $arParams=[])
FormatText($strText, $strTextType="text")
AddMessage2Log($text, $module='', $traceDepth=6, $showArgs=false)
TrimArr(&$arr, $trim_value=false)
CalendarDate($fieldName, $value, $formName="", $size="10", $param="class=\"typeinput\"")
Help($module="", $anchor="", $help_file="")
GetCountryByID($id, $lang=LANGUAGE_ID)
SetMenuTypes($armt, $site='', $description=false)
GetFileFromURL($page, $get_index_page=null)
convert_code_tag_for_html_before($text="")
CalendarPeriod($sFromName, $sFromVal, $sToName, $sToVal, $sFormName="skform", $show_select="N", $field_select="class=\"typeselect\"", $field_input="class=\"typeinput\"", $size="10")
PrepareTxtForEmail($text, $lang=false, $convert_url_tag=true, $convert_image_tag=true)
GetPagePath($page=false, $get_index_page=null)
GetCountryIdByCode($code)
ParseFileContent($filesrc, $params=[])
NormalizePhone($number, $minLength=10)
setSessionExpired($pIsExpired=true)
bxstrrpos($haystack, $needle)
GetMenuTypes($site=false, $default_value=false)
QueryGetData($SITE, $PORT, $PATH, $QUERY_STR, &$errno, &$errstr, $sMethod="GET", $sProto="", $sContentType='N')
FormatDate($format="", $timestamp=false, $now=false, ?string $languageId=null)
htmlspecialcharsback($str)
IsModuleInstalled($module_id)
RemoveScriptExtension($check_name)
GetCountryArray($lang=LANGUAGE_ID)
InputType($strType, $strName, $strValue, $strCmp, $strPrintValue=false, $strPrint="", $field1="", $strId="")
initvar($varname, $value='')
DeleteDirFiles($frDir, $toDir, $arExept=[])
ExecuteModuleEvent($arEvent)
ShowImage($PICTURE_ID, $iMaxW=0, $iMaxH=0, $sParams=false, $strImageUrl="", $bPopup=false, $strPopupTitle=false, $iSizeWHTTP=0, $iSizeHHTTP=0)
CheckVersion($version1, $version2)
delete_special_symbols($text, $replace="")
HasScriptExtension($check_name)
ParseDateTime($datetime, $format=false)
SelectBox($strBoxName, $a, $strDetText="", $strSelectedVal="", $field1="class=\"typeselect\"")
RegisterModuleDependences($FROM_MODULE_ID, $MESSAGE_ID, $TO_MODULE_ID, $TO_CLASS="", $TO_METHOD="", $SORT=100, $TO_PATH="", $TO_METHOD_ARG=[])
bx_basename($path, $ext="")
SelectBoxM($strBoxName, $a, $arr, $strDetText="", $strDetText_selected=false, $size="5", $field1="class=\"typeselect\"")
FmtDate($str_date, $format=false, $site=false, $bSearchInSitesOnly=false)
print_url($strUrl, $strText, $sParams="")
FormatDateEx($strDate, $format=false, $new_format=false)
AddEventHandler($FROM_MODULE_ID, $MESSAGE_ID, $CALLBACK, $SORT=100, $FULL_PATH=false)
ShowError($strError, $cls="errortext")
UnRegisterModuleDependences($FROM_MODULE_ID, $MESSAGE_ID, $TO_MODULE_ID, $TO_CLASS="", $TO_METHOD="", $TO_PATH="", $TO_METHOD_ARG=[])
RewriteFile($abs_path, $strContent)
convert_close_quote_tag()
DelDuplicateSort(&$arSort)
SelectBoxMFromArray($strBoxName, $a, $arr, $strDetText="", $strDetText_selected=false, $size="5", $field1="class='typeselect'")
Calendar($fieldName, $formName="")
_FormatDateMessage($value, $messages, ?string $languageId=null)
convert_to_mailto($s, $link_class="")
AddEventToStatFile($module, $action, $tag, $label, $action_type='', $user_id=null)
HTMLToTxt($str, $strSiteUrl="", $aDelete=[], $maxlen=70)
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
GetTime($timestamp, $type="SHORT", $site=false, $bSearchInSitesOnly=false)
TxtToHTML( $str, $bMakeUrls=true, $iMaxStringLen=0, $QUOTE_ENABLED="N", $NOT_CONVERT_AMPERSAND="Y", $CODE_ENABLED="N", $BIU_ENABLED="N", $quote_table_class="quotetable", $quote_head_class="tdquotehead", $quote_body_class="tdquote", $code_table_class="codetable", $code_head_class="tdcodehead", $code_body_class="tdcodebody", $code_textarea_class="codetextarea", $link_class="txttohtmllink", $arUrlEvent=[], $link_target="_self")
ConvertTimeStamp($timestamp=false, $type="SHORT", $site=false, $bSearchInSitesOnly=false)
GetModuleEvents($MODULE_ID, $MESSAGE_ID, $bReturnArray=false)
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
DeleteDirFilesEx($path, $root=null)
Rel2Abs($curdir, $relpath)
CopyDirFiles($path_from, $path_to, $ReWrite=true, $Recursive=false, $bDeleteAfterCopy=false, $strExclude="")
GetMessage($name, $aReplace=null)
BXClearCache($full=false, $initdir='')
FindUserID($tag_name, $tag_value, $user_name="", $form_name="form1", $tag_size="3", $tag_maxlength="", $button_value="...", $tag_class="typeinput", $button_class="tablebodybutton", $search_page="/bitrix/admin/user_search.php")
ParseDate($strDate, $format="dmy")
sortByColumn(array &$array, $columns, $callbacks='', $defaultValueIfNotSetValue=null, $preserveKeys=false)
check_email($email, $strict=false, $domainCheck=false)
IsConfigFile(string $path)
array_convert_name_2_value($arr)
AddToTimeStamp($arrAdd, $stmp=false)
getLocalPath($path, $baseFolder="/bitrix")
CheckDateTime($datetime, $format=false)
MkDateTime($strDT, $format="d.m.Y H:i:s")
bitrix_sessid_set($val=false)
ShowNote($strNote, $cls="notetext")
randString($pass_len=10, $pass_chars=false)
GetLangFileName($before, $after, $lang=false)
convertTimeToMilitary($strTime, $fromFormat='H:MI T', $toFormat='HH:MI')
FormatDateFromDB($date, $format='FULL', $phpFormat=false)
UnEscapePHPString($str, $encloser='"')
GetFileNameWithoutExtension($path)
__IncludeLang($path, $bReturnArray=false, $bFileChecked=false)
convert_to_href($url, $link_class="", $event1="", $event2="", $event3="", $script="", $link_target="_self")
GetWhoisLink($ip, $class='')
MakeTimeStamp($datetime, $format=false)
bxmail($to, $subject, $message, $additional_headers="", $additional_parameters="", Main\Mail\Context $context=null)
IncludeTemplateLangFile($filepath, $lang=false)
xml_depth_xmldata($vals, &$i)
bitrix_sessid_get($varname='sessid')
LocalRedirect($url, $skip_security_check=false, $status="302 Found")
GetDirIndex($path, $strDirIndex=false)
SelectBoxFromArray( $strBoxName, $db_array, $strSelectedVal="", $strDetText="", $field1="class='typeselect'", $go=false, $form="form1")
RemoveEventHandler($FROM_MODULE_ID, $MESSAGE_ID, $iEventHandlerKey)
TruncateText($strText, $intLen)
TrimEx($str, $symbol, $side="both")
convert_quote_tag($text='', $quote_table_class='', $quote_head_class='', $quote_body_class='')
AddTime($stmp, $add, $type="D")
convert_code_tag_for_html_after($text='', $code_table_class='', $code_head_class='', $code_body_class='', $code_textarea_class='')
GetMessageJS($name, $aReplace=false)
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
if(empty($signedUserToken)) $key
</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."%"
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
$GLOBALS['_____370096793']