17 if (preg_match(
"'^\x01([0-9]+)\x02$'s",
$str))
19 return preg_replace_callback(
"'\x01([0-9]+)\x02's",
"PHPParser::getString",
$str);
23 return preg_replace_callback(
"'\x01([0-9]+)\x02's",
"PHPParser::getQuotedString",
$str);
31 return "={" . preg_replace_callback(
"'\x01([0-9]+)\x02's",
"PHPParser::getQuotedString",
$str) .
"}";
42 return '"' . self::$arAllStr[
$matches[1]] .
'"';
51 for (
$i = 0;
$i < $params_l;
$i++)
54 if (
$ch ==
"(" ||
$ch ==
"[")
88 if (strtolower(substr(
$params, 0, 6)) ==
'array(')
91 $paramsList = substr(
$params, 6);
96 $paramsList = substr(
$params, 1);
100 $arParams = static::GetParams($paramsList);
103 if (strtolower(substr($el, 0, 6)) ==
'array(' || str_starts_with($el,
'['))
111 $p = mb_strpos($el,
"=>");
128 $el_ind = static::ReplString(mb_substr($el, 0,
$p),
$arAllStr);
129 $el_val = mb_substr($el,
$p + 2);
143 if (str_starts_with(
$str,
"<?php"))
161 $length = mb_strlen(
$str);
162 while (
$i < $length - 1)
168 if ($string_tmp !=
"")
176 if (
$ch ==
"/" &&
$i + 1 < $length)
179 if (mb_substr(
$str,
$i + 1, 1) ==
"*" && ($ti = mb_strpos(
$str,
"*/",
$i + 2)) !==
false)
183 elseif (mb_substr(
$str,
$i + 1, 1) ==
"/" && ($ti = mb_strpos(
$str,
"\n",
$i + 2)) !==
false)
196 if (
$ch ==
" " ||
$ch ==
"\r" ||
$ch ==
"\n" ||
$ch ==
"\t")
202 if ($bInString &&
$ch ==
"\\" && !$bSlashed)
208 if (
$ch ==
"\"" ||
$ch ==
"'")
212 if (!$bSlashed && $quote_ch ==
$ch)
236 if ($pos = mb_strpos($new_str,
"("))
238 $func_name = mb_substr($new_str, 0, $pos + 1);
239 if (preg_match(
"/^(\\\$[A-Z_][A-Z0-9_]*)(\\s*=\\s*)/i", $func_name, $arMatch))
241 $var_name = $arMatch[1];
242 $func_name = mb_substr($func_name, mb_strlen($arMatch[0]));
248 $func_name = preg_replace(
"'\\\$GLOBALS\\[(\"|\\')(.+?)(\"|\\')\\]'s",
"\$\\2", $func_name);
249 switch (mb_strtoupper($func_name))
251 case '$APPLICATION->INCLUDEFILE(':
252 $params = mb_substr($new_str, $pos + 1);
254 $arIncludeParams = [];
256 if (preg_match(
"/^array\\(/i",
$arParams[1]))
258 $arParams2 = static::GetParams(mb_substr(
$arParams[1], 6));
259 foreach ($arParams2 as $el)
261 $p = mb_strpos($el,
"=>");
262 $el_ind = static::ReplString(mb_substr($el, 0,
$p),
$arAllStr);
263 $el_val = mb_substr($el,
$p + 2);
264 if (preg_match(
"/^array\\(/i", $el_val))
267 $arParamsN = static::GetParams(mb_substr($el_val, 6));
268 foreach ($arParamsN as $param)
270 $res_ar[] = static::ReplString($param,
$arAllStr);
273 $arIncludeParams[$el_ind] = $res_ar;
277 $arIncludeParams[$el_ind] = static::ReplString($el_val,
$arAllStr);
283 "PARAMS" => $arIncludeParams,
284 "VARIABLE" => $var_name,
293 if ($pos = mb_strpos($instruction,
"("))
295 $func_name = mb_substr($instruction, 0, $pos + 1);
296 if (preg_match(
"/(\\\$[A-Z_][A-Z0-9_]*)(\\s*=\\s*)/i", $func_name, $arMatch))
298 $var_name = $arMatch[1];
305 $params = mb_substr($instruction, $pos + 1);
308 $arIncludeParams = [];
322 "PARAMS" => $arIncludeParams,
324 "VARIABLE" => $var_name,
325 "FUNCTION_PARAMS" => $arFuncParams,
335 $componentNumber = -1;
337 $bInComponent =
false;
348 $allChars = preg_split(
'//u', $scriptContent, -1, PREG_SPLIT_NO_EMPTY);
350 if ($allChars ===
false)
355 $scriptContentLength = mb_strlen($scriptContent);
358 while ($ind < $scriptContentLength - 1)
361 $ch = $allChars[$ind];
367 if (!$bInComponent && $instruction <>
'')
369 if (preg_match(
"#\\s*((\\\$[A-Z_][A-Z0-9_]*\\s*=)?\\s*\\\$APPLICATION->IncludeComponent\\s*\\()#is", $instruction, $arMatches))
372 $bInComponent =
true;
374 $instruction = $arMatches[1];
376 $arComponents[$componentNumber] = [
377 "START" => ($ind - mb_strlen($arMatches[1])),
383 if ($string !==
false)
396 $bInComponent =
false;
397 $arComponents[$componentNumber][
"END"] = $ind + 1;
398 $arComponents[$componentNumber][
"DATA"] = static::GetComponentParams(preg_replace(
"#[ \r\n\t]#",
"", $instruction),
$arAllStr);
403 if (
$ch ==
"/" && $ind < $scriptContentLength - 2)
405 $nextChar = $allChars[$ind + 1];
406 if ($nextChar ==
"/")
408 $endPos = mb_strpos($scriptContent,
"\n", $ind + 2);
410 if ($endPos ===
false)
412 $ind = $scriptContentLength - 1;
423 $endPos = mb_strpos($scriptContent,
"*/", $ind + 2);
425 if ($endPos ===
false)
427 $ind = $scriptContentLength - 1;
438 if (
$ch ==
"\"" ||
$ch ==
"'")
446 if (
$ch ==
"?" && $ind < $scriptContentLength - 2 && $allChars[$ind + 1] ==
">")
451 $bInComponent =
false;
452 $arComponents[$componentNumber][
"END"] = $ind - 1;
453 $arComponents[$componentNumber][
"DATA"] = static::GetComponentParams(preg_replace(
"#[ \r\n\t]#",
"", $instruction),
$arAllStr);
462 if (
$ch ==
" " ||
$ch ==
"\r" ||
$ch ==
"\n" ||
$ch ==
"\t")
469 if (
$ch ==
"\\" && !$bSlashed)
474 if (
$ch == $quoteChar && !$bSlashed)
488 if ($ind < $scriptContentLength - 5 && $allChars[$ind + 1] . $allChars[$ind + 2] . $allChars[$ind + 3] . $allChars[$ind + 4] ==
"?php")
493 elseif ($ind < $scriptContentLength - 2 && $allChars[$ind + 1] ==
"?")
501 return $arComponents;
507 if (str_starts_with(
$str,
"<?php"))
525 $length = mb_strlen(
$str);
526 while (
$i < $length - 1)
532 if ($string_tmp !=
"")
540 if (
$ch ==
"/" &&
$i + 1 < $length)
543 if (mb_substr(
$str,
$i + 1, 1) ==
"*" && ($ti = mb_strpos(
$str,
"*/",
$i + 2)) !==
false)
547 elseif (mb_substr(
$str,
$i + 1, 1) ==
"/" && ($ti = mb_strpos(
$str,
"\n",
$i + 2)) !==
false)
560 if (
$ch ==
" " ||
$ch ==
"\r" ||
$ch ==
"\n" ||
$ch ==
"\t")
566 if ($bInString &&
$ch ==
"\\" && !$bSlashed)
572 if (
$ch ==
"\"" ||
$ch ==
"'")
576 if (!$bSlashed && $quote_ch ==
$ch)
600 if ($pos = mb_strpos($new_str,
"("))
602 $func_name = mb_substr($new_str, 0, $pos + 1);
603 if (preg_match(
"/^(\\\$[A-Z_][A-Z0-9_]*)(\\s*=\\s*)/i", $func_name, $arMatch))
605 $var_name = $arMatch[1];
606 $func_name = mb_substr($func_name, mb_strlen($arMatch[0]));
614 $func_name = preg_replace_callback(
"'\x01([0-9]+)\x02's",
"PHPParser::getString", $func_name);
616 $isComponent2Begin =
false;
617 $arIncludeComponentFunctionStrings = self::getComponentFunctionStrings();
618 foreach ($arIncludeComponentFunctionStrings as $functionName)
620 $component2Begin = mb_strtoupper($functionName) .
'(';
621 if (mb_strtoupper($func_name) == $component2Begin)
623 $isComponent2Begin =
true;
627 if ($isComponent2Begin)
629 $params = mb_substr($new_str, $pos + 1);
632 $arIncludeParams = [];
640 "PARAMS" => $arIncludeParams,
642 "VARIABLE" => $var_name,
643 "FUNCTION_PARAMS" => $arFuncParams,
662 while (
$i < $nLen - 1)
669 if (
$ch ==
"/" &&
$i + 1 < $nLen)
673 if ($posnext ===
false)
681 if (mb_substr(
$filesrc,
$i + 1, 1) ==
"*" && ($ti = mb_strpos(
$filesrc,
"*/",
$i + 2)) !==
false)
694 if ($ti > $posnext && mb_substr(
$filesrc,
$i + 1, 1) !=
"*")
698 $arScripts[] = [
$p, $posnext, mb_substr(
$filesrc,
$p, $posnext -
$p)];
710 if (
$ch ==
"?" &&
$i + 1 < $nLen && mb_substr(
$filesrc,
$i + 1, 1) ==
">")
718 if ($bInString &&
$ch ==
"\\" && !$bSlashed)
724 if (
$ch ==
"\"" ||
$ch ==
"'")
728 if (!$bSlashed && $quote_ch ==
$ch)
746 if ($limit &&
count($arScripts) == $limit)
757 if (str_starts_with(
$str,
"={") && str_ends_with(
$str,
"}") && mb_strlen(
$str) > 3)
759 return substr(
$str, 2, -1);
775 $res .=
"\r\n\t\"" .
$key .
"\"\t=>\t";
778 $res .=
"array(" . $comm .
"\r\n";
790 $zn .=
"\t\t\t\t\t" . static::PreparePHP(
$p);
792 $res .= $zn .
"\r\n\t\t\t\t),";
796 $res .=
"array(" . static::PreparePHP(
$val[0]) .
")," . $comm;
800 $res .= static::PreparePHP(
$val) .
"," . $comm;
806 for ($j = 1; $j <=
$i; $j++)
808 $p = mb_strpos(
$res,
"$un|$j|");
809 $pn = mb_strrpos(mb_substr(
$res, 0,
$p),
"\n");
818 for ($j = 1; $j <=
$i; $j++)
820 $res = str_replace($un .
"|$j|", str_repeat(
"\t", intval((
$max - $lngth[$j] + 7) / 8)),
$res);
823 return trim(
$res,
" \t,\r\n");
826 public static function ReturnPHPStrRec(
$arVal, $level, $comm =
"")
829 $pref = str_repeat(
"\t", $level + 1);
832 $result .=
"[" . (($level == 1) ? $comm :
"") .
"\n";
835 $result .= $pref .
"\t" . ((intval(
$key) .
"|" ==
$key .
"|") ?
$key : static::PreparePHP(
$key)) .
" => " . static::ReturnPHPStrRec($value, $level + 1);
841 $result .= static::PreparePHP(
$arVal) .
"," . (($level == 1) ? $comm :
"") .
"\n";
847 public static function ReturnPHPStr2($arVals,
$arParams = [])
854 $res .= static::ReturnPHPStrRec(
$val, 1, $comm);
857 return trim(
$res,
" \t,\r\n");
863 $arComponents = static::ParseScript(
$filesrc);
867 for (
$i = 0, $cnt =
count($arComponents);
$i < $cnt;
$i++)
869 $nLineFrom = substr_count(mb_substr(
$filesrc, 0, $arComponents[
$i][
"START"]),
"\n") + 1;
870 $nLineTo = substr_count(mb_substr(
$filesrc, 0, $arComponents[
$i][
"END"]),
"\n") + 1;
872 if ($nLineFrom <= $src_line && $nLineTo >=
$src_line)
874 if ($arComponents[
$i][
"DATA"][
"COMPONENT_NAME"] == $component_name)
888 public static function getPhpChunks(
$filesrc, $limit =
false)
893 if (function_exists(
"token_get_all"))
895 foreach (token_get_all(
$filesrc) as $token)
899 if (is_array($token))
902 if ($token[0] === T_CLOSE_TAG)
907 if ($limit &&
count($chunks) == $limit)
920 if (is_array($token))
922 if ($token[0] === T_OPEN_TAG || $token[0] === T_OPEN_TAG_WITH_ECHO)
933 foreach (static::ParseFile(
$filesrc, $limit) as $chunk)
935 $chunks[] = $chunk[2];
939 if ($php && $chunk !=
'')
947 public static function getPageTitle(
$filesrc, $prolog =
false)
949 if ($prolog ===
false)
951 $chunks = static::getPhpChunks(
$filesrc, 1);
954 $prolog = &$chunks[0];
966 if (preg_match(
"/\\\$APPLICATION->SetTitle\\s*\\(\\s*\"(.*?)(?<!\\\\)\"\\s*\\);/is", $prolog, $regs))
970 elseif (preg_match(
"/\\\$APPLICATION->SetTitle\\s*\\(\\s*'(.*?)(?<!\\\\)'\\s*\\);/is", $prolog, $regs))
974 elseif (preg_match(
"'<title[^>]*>([^>]+)</title[^>]*>'i", $prolog, $regs))
980 if (!
$title && preg_match(
"'<title[^>]*>([^>]+)</title[^>]*>'i",
$filesrc, $regs))
988 public static function getComponentFunctionStrings()
991 '$APPLICATION->IncludeComponent',
992 'EventMessageThemeCompiler::includeComponent',
996 public static function buildComponentCode(
array $component, ?
string $templateName =
null, ?
array $parameters =
null): string
998 if ($templateName ===
null)
1000 $templateName = $component[
'DATA'][
'TEMPLATE_NAME'];
1002 if ($parameters ===
null)
1004 $parameters = $component[
'DATA'][
'PARAMS'];
1007 $functionParams =
'';
1008 if (!empty($component[
'DATA'][
'FUNCTION_PARAMS']))
1010 $functionParams =
",\n"
1012 .
"\t\t" . static::ReturnPHPStr2($component[
'DATA'][
'FUNCTION_PARAMS']) .
"\n"
1015 elseif (!empty($component[
'DATA'][
'RETURN_RESULT']))
1017 $functionParams =
",\n\t[]";
1020 $code = ($component[
'DATA'][
'VARIABLE'] ? $component[
'DATA'][
'VARIABLE'] .
' = ' :
'')
1021 .
"\$APPLICATION->IncludeComponent(\n"
1022 .
"\t\"" . $component[
'DATA'][
'COMPONENT_NAME'] .
"\", \n"
1023 .
"\t\"" . $templateName .
"\", \n"
1025 .
"\t\t" . static::ReturnPHPStr2($parameters) .
"\n"
1027 .
"\t" . (!empty($component[
'DATA'][
'PARENT_COMP']) ? $component[
'DATA'][
'PARENT_COMP'] :
'false')
1029 . (!empty($component[
'DATA'][
'RETURN_RESULT']) ?
",\n\t" . $component[
'DATA'][
'RETURN_RESULT'] :
'')
static ReplString($str, $arAllStr)
static ParseScript($scriptContent)
static CheckForComponent2($str)
static getString($matches)
static GetParams($params)
static GetComponentParams($instruction, $arAllStr)
static getQuotedString($matches)
static GetParamsRec($params, &$arAllStr, &$arResult)
static CheckForComponent($str)
static ReturnPHPStr($arVals, $arParams)
static ParseFile($filesrc, $limit=false)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
EscapePHPString($str, $encloser='"')
UnEscapePHPString($str, $encloser='"')
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']