Пример #1
0
 function _RenderAllComponents($arParams, $bLPA)
 {
     global $APPLICATION, $USER;
     $s = '';
     $arPHP = PHPParser::ParseFile($arParams['source']);
     $l = count($arPHP);
     if ($l > 0) {
         $new_source = '';
         $end = 0;
         $comp_count = 0;
         ob_start();
         for ($n = 0; $n < $l; $n++) {
             //Trim php tags
             $src = $arPHP[$n][2];
             if (SubStr($src, 0, 5) == "<?" . "php") {
                 $src = SubStr($src, 5);
             } else {
                 $src = SubStr($src, 2);
             }
             $src = SubStr($src, 0, -2);
             $comp2_begin = '$APPLICATION->INCLUDECOMPONENT(';
             if (strtoupper(substr($src, 0, strlen($comp2_begin))) != $comp2_begin) {
                 continue;
             }
             $arRes = PHPParser::CheckForComponent2($arPHP[$n][2]);
             if ($arRes) {
                 $comp_name = CMain::_ReplaceNonLatin($arRes['COMPONENT_NAME']);
                 $template_name = CMain::_ReplaceNonLatin($arRes['TEMPLATE_NAME']);
                 $arParams = $arRes['PARAMS'];
                 $arParams['BX_EDITOR_RENDER_MODE'] = 'Y';
                 if ($bLPA) {
                     $arPHPparams = array();
                     CMain::LPAComponentChecker($arParams, $arPHPparams);
                     $len = count($arPHPparams);
                 }
                 $br = "\r\n";
                 $code = '$APPLICATION->IncludeComponent(' . $br . "\t" . '"' . $comp_name . '",' . $br . "\t" . '"' . $template_name . '",' . $br;
                 // If exist at least one parameter with php code inside
                 if (count($arParams) > 0) {
                     // Get array with description of component params
                     $arCompParams = CComponentUtil::GetComponentProps($comp_name);
                     $arTemplParams = CComponentUtil::GetTemplateProps($comp_name, $template_name, $template);
                     $arParameters = array();
                     if (isset($arCompParams["PARAMETERS"]) && is_array($arCompParams["PARAMETERS"])) {
                         $arParameters = $arParameters + $arCompParams["PARAMETERS"];
                     }
                     if (is_array($arTemplParams)) {
                         $arParameters = $arParameters + $arTemplParams;
                     }
                     if ($bLPA) {
                         // Replace values from 'DEFAULT'
                         for ($e = 0; $e < $len; $e++) {
                             $par_name = $arPHPparams[$e];
                             $arParams[$par_name] = isset($arParameters[$par_name]['DEFAULT']) ? $arParameters[$par_name]['DEFAULT'] : '';
                         }
                     }
                     foreach ($arParams as $key => $val) {
                         if ($key != addslashes($key)) {
                             unset($arParams[$key]);
                         } else {
                             $arParams[$key] = addslashes($val);
                         }
                     }
                     //ReturnPHPStr
                     $params = PHPParser::ReturnPHPStr2($arParams, $arParameters);
                     $code .= "\t" . 'Array(' . $br . "\t" . $params . $br . "\t" . ')';
                 } else {
                     $code .= "\t" . 'Array()';
                 }
                 $parent_comp = CMain::_ReplaceNonLatin($arRes['PARENT_COMP']);
                 $arExParams_ = $arRes['FUNCTION_PARAMS'];
                 $bEx = isset($arExParams_) && is_array($arExParams_) && count($arExParams_) > 0;
                 if (!$parent_comp || strtolower($parent_comp) == 'false') {
                     $parent_comp = false;
                 }
                 if ($parent_comp) {
                     if ($parent_comp == 'true' || intVal($parent_comp) == $parent_comp) {
                         $code .= ',' . $br . "\t" . $parent_comp;
                     } else {
                         $code .= ',' . $br . "\t\"" . $parent_comp . '"';
                     }
                 }
                 if ($bEx) {
                     if (!$parent_comp) {
                         $code .= ',' . $br . "\tfalse";
                     }
                     $arExParams = array();
                     foreach ($arExParams_ as $k => $v) {
                         $k = CMain::_ReplaceNonLatin($k);
                         $v = CMain::_ReplaceNonLatin($v);
                         if (strlen($k) > 0 && strlen($v) > 0) {
                             $arExParams[$k] = $v;
                         }
                     }
                     $exParams = PHPParser::ReturnPHPStr2($arExParams);
                     $code .= ',' . $br . "\tArray(" . $exParams . ')';
                 }
                 $code .= $br . ');';
                 echo '#BX_RENDERED_COMPONENT_' . $comp_count . '#';
                 eval($code);
                 echo '#BX_RENDERED_COMPONENT_' . $comp_count . '#';
             }
             $comp_count++;
         }
         $s = ob_get_contents();
         ob_end_clean();
     }
     return $s;
 }
Пример #2
0
    }
}
if (strlen($propeditmore) > 0) {
    $bVarsFromForm = True;
}
$bEditProps = false;
if (!$bVarsFromForm) {
    if (!$bEdit && strlen($filename) <= 0) {
        $filename = $USER->CanDoOperation('edit_php') || $limit_php_access ? "untitled.php" : "untitled.html";
    }
    if (!$bFullPHP) {
        $res = CFileman::ParseFileContent($filesrc_tmp, true);
        $filesrc = $res["CONTENT"];
        // ###########  L  P  A  ############
        if ($limit_php_access) {
            $arPHP = PHPParser::ParseFile($filesrc);
            $l = count($arPHP);
            if ($l > 0) {
                $new_filesrc = '';
                $end = 0;
                $php_count = 0;
                for ($n = 0; $n < $l; $n++) {
                    $start = $arPHP[$n][0];
                    $new_filesrc .= substr($filesrc, $end, $start - $end);
                    $end = $arPHP[$n][1];
                    //Trim php tags
                    $src = $arPHP[$n][2];
                    if (SubStr($src, 0, 5) == "<?" . "php") {
                        $src = SubStr($src, 5);
                    } else {
                        $src = SubStr($src, 2);
Пример #3
0
     $CONTENT = $new_content;
 } else {
     $CONTENT = CMain::EncodePHPTags($new_content);
 }
 // Get array of PHP scripts from original template src
 if (strlen($ID) > 0) {
     $templ = CSiteTemplate::GetByID($ID);
     if (!$templ->ExtractFields("str_")) {
         $strWarning = GetMessage('templ_create_err', array('#ID#' => $ID));
     }
 } else {
     $strWarning = GetMessage('templ_create_err1');
 }
 checkError($strWaring);
 $old_content = htmlspecialcharsback($str_CONTENT);
 $arPHP = PHPParser::ParseFile($old_content);
 $l = count($arPHP);
 $s1 = "";
 if ($l > 0) {
     $new_content = '';
     $end = 0;
     $php_count = 0;
     $wa = '#WORK_AREA#';
     for ($n = 0; $n < $l; $n++) {
         $start = $arPHP[$n][0];
         $s_cont = substr($old_content, $end, $start - $end);
         $end = $arPHP[$n][1];
         if ($n == 0) {
             continue;
         }
         $src = $arPHP[$n][2];
Пример #4
0
 function ProcessLPA($filesrc = false, $old_filesrc = false)
 {
     if ($filesrc === false) {
         return '';
     }
     // Find all php fragments in $filesrc and:
     // 	1. Kill all non-component 2.0 fragments
     // 	2. Get and check params of components
     $arPHP = PHPParser::ParseFile($filesrc);
     $l = count($arPHP);
     if ($l > 0) {
         $new_filesrc = '';
         $end = 0;
         for ($n = 0; $n < $l; $n++) {
             $start = $arPHP[$n][0];
             $new_filesrc .= CMain::EncodePHPTags(substr($filesrc, $end, $start - $end));
             $end = $arPHP[$n][1];
             //Trim php tags
             $src = $arPHP[$n][2];
             if (substr($src, 0, 5) == "<?php") {
                 $src = '<?' . substr($src, 5);
             }
             //If it's Component 2 - we handle it's params, non components2 will be erased
             $comp2_begin = '<?$APPLICATION->INCLUDECOMPONENT(';
             if (strtoupper(substr($src, 0, strlen($comp2_begin))) == $comp2_begin) {
                 $arRes = PHPParser::CheckForComponent2($src);
                 if ($arRes) {
                     $comp_name = CMain::_ReplaceNonLatin($arRes['COMPONENT_NAME']);
                     $template_name = CMain::_ReplaceNonLatin($arRes['TEMPLATE_NAME']);
                     $arParams = $arRes['PARAMS'];
                     $arPHPparams = array();
                     CMain::LPAComponentChecker($arParams, $arPHPparams);
                     $len = count($arPHPparams);
                     $br = "\r\n";
                     $code = '$APPLICATION->IncludeComponent(' . $br . "\t" . '"' . $comp_name . '",' . $br . "\t" . '"' . $template_name . '",' . $br;
                     // If exist at least one parameter with php code inside
                     if (count($arParams) > 0) {
                         // Get array with description of component params
                         $arCompParams = CComponentUtil::GetComponentProps($comp_name);
                         $arTemplParams = CComponentUtil::GetTemplateProps($comp_name, $template_name);
                         $arParameters = array();
                         if (isset($arCompParams["PARAMETERS"]) && is_array($arCompParams["PARAMETERS"])) {
                             $arParameters = $arParameters + $arCompParams["PARAMETERS"];
                         }
                         if (is_array($arTemplParams)) {
                             $arParameters = $arParameters + $arTemplParams;
                         }
                         // Replace values from 'DEFAULT'
                         for ($e = 0; $e < $len; $e++) {
                             $par_name = $arPHPparams[$e];
                             $arParams[$par_name] = isset($arParameters[$par_name]['DEFAULT']) ? $arParameters[$par_name]['DEFAULT'] : '';
                         }
                         //ReturnPHPStr
                         $params = PHPParser::ReturnPHPStr2($arParams, $arParameters);
                         $code .= "\t" . 'array(' . $br . "\t" . $params . $br . "\t" . ')';
                     } else {
                         $code .= "\t" . 'array()';
                     }
                     $parent_comp = CMain::_ReplaceNonLatin($arRes['PARENT_COMP']);
                     $arExParams_ = $arRes['FUNCTION_PARAMS'];
                     $bEx = isset($arExParams_) && is_array($arExParams_) && count($arExParams_) > 0;
                     if (!$parent_comp || strtolower($parent_comp) == 'false') {
                         $parent_comp = false;
                     }
                     if ($parent_comp) {
                         if ($parent_comp == 'true' || intVal($parent_comp) == $parent_comp) {
                             $code .= ',' . $br . "\t" . $parent_comp;
                         } else {
                             $code .= ',' . $br . "\t\"" . $parent_comp . '"';
                         }
                     }
                     if ($bEx) {
                         if (!$parent_comp) {
                             $code .= ',' . $br . "\tfalse";
                         }
                         $arExParams = array();
                         foreach ($arExParams_ as $k => $v) {
                             $k = CMain::_ReplaceNonLatin($k);
                             $v = CMain::_ReplaceNonLatin($v);
                             if (strlen($k) > 0 && strlen($v) > 0) {
                                 $arExParams[$k] = $v;
                             }
                         }
                         //CComponentUtil::PrepareVariables($arExParams);
                         $exParams = PHPParser::ReturnPHPStr2($arExParams);
                         $code .= ',' . $br . "\tarray(" . $exParams . ')';
                     }
                     $code .= $br . ');';
                     $code = '<?' . $code . '?>';
                     $new_filesrc .= $code;
                 }
             }
         }
         $new_filesrc .= CMain::EncodePHPTags(substr($filesrc, $end));
         $filesrc = $new_filesrc;
     } else {
         $filesrc = CMain::EncodePHPTags($filesrc);
     }
     if (strpos($filesrc, '#PHP') !== false && $old_filesrc !== false) {
         // Get array of PHP scripts from old saved file
         $arPHP = PHPParser::ParseFile($old_filesrc);
         $arPHPscripts = array();
         $l = count($arPHP);
         if ($l > 0) {
             $new_filesrc = '';
             $end = 0;
             for ($n = 0; $n < $l; $n++) {
                 $start = $arPHP[$n][0];
                 $new_filesrc .= substr($old_filesrc, $end, $start - $end);
                 $end = $arPHP[$n][1];
                 $src = $arPHP[$n][2];
                 $src = SubStr($src, SubStr($src, 0, 5) == "<?" . "php" ? 5 : 2, -2);
                 // Trim php tags
                 $comp2_begin = '$APPLICATION->INCLUDECOMPONENT(';
                 if (strtoupper(substr($src, 0, strlen($comp2_begin))) != $comp2_begin) {
                     $arPHPscripts[] = $src;
                 }
             }
         }
         // Ok, so we already have array of php scripts lets check our new content
         // LPA-users CAN delete PHP fragments and swap them but CAN'T add new or modify existent:
         while (preg_match('/#PHP\\d{4}#/i' . BX_UTF_PCRE_MODIFIER, $filesrc, $res)) {
             $php_begin = strpos($filesrc, $res[0]);
             $php_fr_num = intval(substr($filesrc, $php_begin + 4, 4)) - 1;
             // Number of PHP fragment from #PHPXXXX# conctruction
             if (isset($arPHPscripts[$php_fr_num])) {
                 $filesrc = substr($filesrc, 0, $php_begin) . '<?' . $arPHPscripts[$php_fr_num] . '?>' . substr($filesrc, $php_begin + 9);
             } else {
                 $filesrc = substr($filesrc, 0, $php_begin) . substr($filesrc, $php_begin + 9);
             }
         }
     }
     return $filesrc;
 }
Пример #5
0
    $str_SITE_ID = htmlspecialcharsbx($site);
    $str_BODY_TYPE = "html";
    $str_TITLE = htmlspecialcharsbx($str_TITLE);
} else {
    $doc_files = CWorkflow::GetFileList($ID);
    while ($zr = $doc_files->GetNext()) {
        $arDocFiles[] = $zr;
    }
    $str_BODY = htmlspecialcharsback($str_BODY);
}
if ($message) {
    $DB->InitTableVarsForEdit("b_workflow_document", "", "str_");
}
if ($USER->CanDoFileOperation('fm_lpa', array($str_SITE_ID, $str_FILENAME)) && !$USER->CanDoOperation('edit_php')) {
    $content = $str_BODY;
    $arPHP = PHPParser::ParseFile($content);
    $l = count($arPHP);
    if ($l > 0) {
        $str_BODY = '';
        $end = 0;
        $php_count = 0;
        for ($n = 0; $n < $l; $n++) {
            $start = $arPHP[$n][0];
            $str_BODY .= substr($content, $end, $start - $end);
            $end = $arPHP[$n][1];
            //Trim php tags
            $src = $arPHP[$n][2];
            if (SubStr($src, 0, 5) == "<?" . "php") {
                $src = SubStr($src, 5);
            } else {
                $src = SubStr($src, 2);
Пример #6
0
 public static function getPhpChunks($filesrc, $limit = false)
 {
     $chunks = array();
     $chunk = '';
     $php = false;
     if (function_exists("token_get_all")) {
         foreach (token_get_all($filesrc) as $token) {
             if ($php) {
                 if (is_array($token)) {
                     $chunk .= $token[1];
                     if ($token[0] === T_CLOSE_TAG) {
                         $chunks[] = $chunk;
                         $chunk = '';
                         $php = false;
                         if ($limit && count($chunks) == $limit) {
                             break;
                         }
                     }
                 } else {
                     $chunk .= $token;
                 }
             } else {
                 if (is_array($token)) {
                     if ($token[0] === T_OPEN_TAG || $token[0] === T_OPEN_TAG_WITH_ECHO) {
                         $chunk .= $token[1];
                         $php = true;
                     }
                 }
             }
         }
     } else {
         foreach (PHPParser::ParseFile($filesrc, $limit) as $chunk) {
             $chunks[] = $chunk[2];
         }
     }
     if ($php && $chunk != '') {
         $chunks[] = $chunk;
     }
     return $chunks;
 }
Пример #7
0
 function FetchParams($content)
 {
     // 1. Parse file
     $arPHP = PHPParser::ParseFile($content);
     $arComponents = array('bitrix:intranet.event_calendar', 'bitrix:socialnetwork', 'bitrix:socialnetwork_user', 'bitrix:socialnetwork_group');
     if (count($arPHP) > 0) {
         self::$types = CCalendarConvert::GetOption('__convert_types');
         self::$iblockTypes = CCalendarConvert::GetOption('__convert_ibl_types');
         self::$settings = CCalendarConvert::GetOption('__convert_settings');
         foreach ($arPHP as $code) {
             $arRes = PHPParser::CheckForComponent2($code[2]);
             if ($arRes && in_array($arRes['COMPONENT_NAME'], $arComponents)) {
                 $PARAMS = $arRes['PARAMS'];
                 if ($arRes['COMPONENT_NAME'] == 'bitrix:intranet.event_calendar') {
                     if (!in_array($PARAMS['IBLOCK_TYPE'], self::$iblockTypes) && $PARAMS['IBLOCK_TYPE']) {
                         self::$iblockTypes[] = $PARAMS['IBLOCK_TYPE'];
                     }
                     if (self::$types['user']['iblockType'] == '') {
                         self::$types['user']['iblockType'] = $PARAMS['IBLOCK_TYPE'];
                     }
                     if (self::$types['group']['iblockType'] == '') {
                         self::$types['group']['iblockType'] = $PARAMS['IBLOCK_TYPE'];
                     }
                     if (isset($PARAMS['USERS_IBLOCK_ID']) && $PARAMS['USERS_IBLOCK_ID'] > 0 && self::$types['user']['iblockId'] <= 0) {
                         self::$types['user']['iblockId'] = intval($PARAMS['USERS_IBLOCK_ID']);
                     }
                     if (isset($PARAMS['SUPERPOSE_GROUPS_IBLOCK_ID']) && $PARAMS['SUPERPOSE_GROUPS_IBLOCK_ID'] > 0 && self::$types['group']['iblockId'] <= 0) {
                         self::$types['group']['iblockId'] = intval($PARAMS['SUPERPOSE_GROUPS_IBLOCK_ID']);
                     }
                     // Settings
                     self::SetModuleOption('path_to_user', $PARAMS['PATH_TO_USER']);
                     self::SetModuleOption('week_holidays', $PARAMS['WEEK_HOLIDAYS']);
                     self::SetModuleOption('year_holidays', $PARAMS['YEAR_HOLIDAYS']);
                     self::SetModuleOption('work_time_start', $PARAMS['WORK_TIME_START']);
                     self::SetModuleOption('work_time_end', $PARAMS['WORK_TIME_END']);
                     self::SetModuleOption('rm_iblock_type', $PARAMS['CALENDAR_IBLOCK_TYPE']);
                     self::SetModuleOption('rm_iblock_id', $PARAMS['CALENDAR_RES_MEETING_IBLOCK_ID']);
                     self::SetModuleOption('path_to_rm', $PARAMS['CALENDAR_PATH_TO_RES_MEETING']);
                     self::SetModuleOption('vr_iblock_id', $PARAMS['CALENDAR_VIDEO_MEETING_IBLOCK_ID']);
                     self::SetModuleOption('path_to_vr', $PARAMS['CALENDAR_PATH_TO_VIDEO_MEETING_DETAIL']);
                     self::SetModuleOption('path_to_vr', $PARAMS['CALENDAR_PATH_TO_VIDEO_MEETING']);
                 } else {
                     if (!in_array($PARAMS['CALENDAR_IBLOCK_TYPE'], self::$iblockTypes) && $PARAMS['CALENDAR_IBLOCK_TYPE']) {
                         self::$iblockTypes[] = $PARAMS['CALENDAR_IBLOCK_TYPE'];
                     }
                     if (self::$types['user']['iblockType'] == '') {
                         self::$types['user']['iblockType'] = $PARAMS['CALENDAR_IBLOCK_TYPE'];
                     }
                     if (self::$types['group']['iblockType'] == '') {
                         self::$types['group']['iblockType'] = $PARAMS['CALENDAR_IBLOCK_TYPE'];
                     }
                     if (isset($PARAMS['CALENDAR_USER_IBLOCK_ID']) && $PARAMS['CALENDAR_USER_IBLOCK_ID'] > 0 && self::$types['user']['iblockId'] <= 0) {
                         self::$types['user']['iblockId'] = intval($PARAMS['CALENDAR_USER_IBLOCK_ID']);
                     }
                     if (isset($PARAMS['CALENDAR_GROUP_IBLOCK_ID']) && $PARAMS['CALENDAR_GROUP_IBLOCK_ID'] > 0 && self::$types['group']['iblockId'] <= 0) {
                         self::$types['group']['iblockId'] = intval($PARAMS['CALENDAR_GROUP_IBLOCK_ID']);
                     }
                     self::SetModuleOption('path_to_user', $PARAMS['PATH_TO_USER']);
                     self::SetModuleOption('path_to_group', $PARAMS['PATH_TO_GROUP']);
                     if (isset($PARAMS['SEF_URL_TEMPLATES']['group_calendar']) && (strpos($PARAMS['SEF_URL_TEMPLATES']['group_calendar'], 'extranet') === false && strpos($PARAMS['SEF_FOLDER'], 'extranet') === false)) {
                         self::SetModuleOption('path_to_group_calendar', $PARAMS['SEF_FOLDER'] . $PARAMS['SEF_URL_TEMPLATES']['group_calendar']);
                     }
                     if (isset($PARAMS['SEF_URL_TEMPLATES']['user_calendar']) && (strpos($PARAMS['SEF_URL_TEMPLATES']['user_calendar'], 'extranet') === false && strpos($PARAMS['SEF_FOLDER'], 'extranet') === false)) {
                         self::SetModuleOption('path_to_user_calendar', $PARAMS['SEF_FOLDER'] . $PARAMS['SEF_URL_TEMPLATES']['user_calendar']);
                     }
                     self::SetModuleOption('week_holidays', $PARAMS['CALENDAR_WEEK_HOLIDAYS']);
                     self::SetModuleOption('year_holidays', $PARAMS['CALENDAR_YEAR_HOLIDAYS']);
                     self::SetModuleOption('work_time_start', $PARAMS['CALENDAR_WORK_TIME_START']);
                     self::SetModuleOption('work_time_end', $PARAMS['CALENDAR_WORK_TIME_END']);
                     self::SetModuleOption('rm_iblock_type', $PARAMS['CALENDAR_IBLOCK_TYPE']);
                     self::SetModuleOption('rm_iblock_id', $PARAMS['CALENDAR_RES_MEETING_IBLOCK_ID']);
                     self::SetModuleOption('path_to_rm', $PARAMS['CALENDAR_PATH_TO_RES_MEETING']);
                     self::SetModuleOption('vr_iblock_id', $PARAMS['CALENDAR_VIDEO_MEETING_IBLOCK_ID']);
                     self::SetModuleOption('path_to_vr', $PARAMS['CALENDAR_PATH_TO_VIDEO_MEETING_DETAIL']);
                     self::SetModuleOption('path_to_vr', $PARAMS['CALENDAR_PATH_TO_VIDEO_MEETING']);
                 }
             }
         }
         CCalendarConvert::SetOption('__convert_types', self::$types);
         CCalendarConvert::SetOption('__convert_ibl_types', self::$iblockTypes);
         CCalendarConvert::SetOption('__convert_settings', self::$settings);
     }
     return true;
 }
Пример #8
0
if($bVarsFromForm)
{
	$str_ID = htmlspecialcharsex($_POST["ID"]);
	$str_NAME = htmlspecialcharsex($_POST["NAME"]);
	$str_DESCRIPTION = htmlspecialcharsex($_POST["DESCRIPTION"]);
	$str_CONTENT = htmlspecialcharsex($_POST["CONTENT"]);
	$str_STYLES = htmlspecialcharsex($_POST["STYLES"]);
	$str_TEMPLATE_STYLES = htmlspecialcharsex($_POST["TEMPLATE_STYLES"]);
	$usehtmled = (isset($_REQUEST["CONTENT_editor"]) && $_REQUEST["CONTENT_editor"] == 'on') ? 'Y' : 'N';
}

if ($lpa || $lpa_view)
{
	$str_CONTENT = htmlspecialcharsback($str_CONTENT);
	$arPHP = PHPParser::ParseFile($str_CONTENT);
	$l = count($arPHP);
	if ($l > 0)
	{
		$new_content = '';
		$end = 0;
		$php_count = 0;

		for ($n = 0; $n < $l; $n++)
		{
			$start = $arPHP[$n][0];
			$s_cont = substr($str_CONTENT, $end, $start - $end);
			$end = $arPHP[$n][1];
			$new_content .= $s_cont;

			$src = $arPHP[$n][2];
Пример #9
0
 /* Try to open script containing the component call */
 $src_path = $_GET["src_path"];
 $src_line = intval($_GET["src_line"]);
 if (!$src_path || $src_line <= 0) {
     $strWarning .= GetMessage("comp_prop_err_param") . "<br>";
 } else {
     $abs_path = $src_path;
     $f = $io->GetFile($abs_path);
     $filesrc = $f->GetContents();
     if (!$filesrc || $filesrc == "") {
         $strWarning .= GetMessage("comp_prop_err_open") . "<br>";
     }
 }
 if ($strWarning == "") {
     /* parse source file for PHP code */
     $arScripts = PHPParser::ParseFile($filesrc);
     /* identify the component by line number */
     $aComponents = array();
     foreach ($arScripts as $script) {
         $nLineFrom = substr_count(substr($filesrc, 0, $script[0]), "\n") + 1;
         $nLineTo = substr_count(substr($filesrc, 0, $script[1]), "\n") + 1;
         if ($nLineFrom <= $src_line && $nLineTo >= $src_line) {
             $aComponents[] = $script;
         }
         if ($nLineTo > $src_line) {
             break;
         }
     }
     foreach ($aComponents as $component) {
         $arRes = PHPParser::CheckForComponent($component[2]);
         if ($arRes && $arRes["SCRIPT_NAME"] == $_GET["path"]) {
Пример #10
0
function WDUFGetComponentsOnPage($filesrc = false)
{
    static $cache = array();
    if (!array_key_exists($filesrc, $cache)) {
        $text = '';
        $arResult = array();
        if ($filesrc !== false) {
            $io = CBXVirtualIo::GetInstance();
            $filesrc = $io->CombinePath("/", $filesrc);
            $filesrc = CSite::GetSiteDocRoot(SITE_ID) . $filesrc;
            $f = $io->GetFile($filesrc);
            $text = $f->GetContents();
        }
        if ($text != '') {
            $arPHP = PHPParser::ParseFile($text);
            foreach ($arPHP as $php) {
                $src = $php[2];
                if (stripos($src, '$APPLICATION->IncludeComponent(') !== false) {
                    $arResult[] = PHPParser::CheckForComponent2($src);
                }
            }
        }
        $cache[$filesrc] = $arResult;
    }
    return $cache[$filesrc];
}