public static final function Load($path, $name) { if (class_exists($name)) { return true; } PHPParser::LoadPHPFile($path); if (!class_exists($name)) { throw new ApplicationException(sprintf(_("%s must contain %s class."), $path, $name), E_ERROR); } return true; }
private function main() { while ($this->isRunning === TRUE) { // Setup our listen arrays $sockReads = $sockWrites = $socketExcept = array(); if (!$this->isWindows) { $sockReads[] = STDIN; } // Add host sockets to the arrays as needed // While at it, check if we need to connect to any of the hosts. $this->hosts->getSelectableSockets($sockReads, $sockWrites); // Add http sockets to the arrays as needed $this->http->getSelectableSockets($sockReads, $sockWrites); // Add telnet sockets to the arrays as needed $this->telnet->getSelectableSockets($sockReads, $sockWrites); // Update timeout if there are timers waiting to be fired. $this->updateSelectTimeOut($this->sleep, $this->uSleep); # Error suppression used because this function returns a "Invalid CRT parameters detected" only on Windows. $numReady = @stream_select($sockReads, $sockWrites, $socketExcept, $this->sleep, $this->uSleep); // Keep looping until you've handled all activities on the sockets. while ($numReady > 0) { $numReady -= $this->hosts->checkTraffic($sockReads, $sockWrites); $numReady -= $this->http->checkTraffic($sockReads, $sockWrites); $numReady -= $this->telnet->checkTraffic($sockReads, $sockWrites); // KB input if (in_array(STDIN, $sockReads)) { $numReady--; $kbInput = trim(fread(STDIN, STREAM_READ_BYTES)); // Split up the input $exp = explode(' ', $kbInput); // Process the command (the first char or word of the line) switch ($exp[0]) { case 'c': console(sprintf('%32s - %64s', 'COMMAND', 'DESCRIPTOIN')); foreach ($this->plugins->getPlugins() as $plugin => $details) { foreach ($details->sayCommands as $command => $detail) { console(sprintf('%32s - %64s', $command, $detail['info'])); } } break; case 'h': console(sprintf('%14s %28s:%-5s %8s %22s', 'Host ID', 'IP', 'PORT', 'UDPPORT', 'STATUS')); foreach ($this->hosts->getHostsInfo() as $host) { $status = ($host['connStatus'] == CONN_CONNECTED ? '' : ($host['connStatus'] == CONN_VERIFIED ? 'VERIFIED &' : ' NOT')) . ' CONNECTED'; $socketType = $host['socketType'] == SOCKTYPE_TCP ? 'tcp://' : 'udp://'; console(sprintf('%14s %28s:%-5s %8s %22s', $host['id'], $socketType . $host['ip'], $host['port'], $host['udpPort'], $status)); } break; case 'I': console('RE-INITIALISING PRISM...'); $this->initialise(NULL, NULL); break; case 'p': console(sprintf('%28s %8s %24s %64s', 'NAME', 'VERSION', 'AUTHOR', 'DESCRIPTION')); foreach ($this->plugins->getPlugins() as $plugin => $details) { console(sprintf("%28s %8s %24s %64s", $plugin::NAME, $plugin::VERSION, $plugin::AUTHOR, $plugin::DESCRIPTION)); } break; case 'x': $this->isRunning = FALSE; break; case 'w': console(sprintf('%15s:%5s %5s', 'IP', 'PORT', 'LAST ACTIVITY')); foreach ($this->http->getHttpInfo() as $v) { $lastAct = time() - $v['lastActivity']; console(sprintf('%15s:%5s %13d', $v['ip'], $v['port'], $lastAct)); } console('Counted ' . $this->http->getHttpNumClients() . ' http client' . ($this->http->getHttpNumClients() == 1 ? '' : 's')); break; default: console('Available Commands:'); console(' h - show host info'); console(' I - re-initialise PRISM (reload ini files / reconnect to hosts / reset http socket'); console(' p - show plugin info'); console(' x - exit PHPInSimMod'); console(' w - show www connections'); console(' c - show command list'); } } } // End while(numReady) // No need to do the maintenance check every turn if ($this->nextMaintenance > time()) { continue; } $this->nextMaintenance = time() + MAINTENANCE_INTERVAL; if (!$this->hosts->maintenance()) { $this->isRunning = FALSE; } $this->http->maintenance(); PHPParser::cleanSessions(); } // End while(isRunning) }
foreach ($aPostValues as $name => $value) { if (is_array($value) && count($value) == 1 && isset($value[0]) && $value[0] == "") { $aPostValues[$name] = array(); } elseif ($bLimitPhpAccess && substr($value, 0, 2) == '={' && substr($value, -1) == '}') { $aPostValues[$name] = $arValues[$name]; } } //check template name $sTemplateName = ""; foreach ($arComponentTemplates as $templ) { if ($templ["NAME"] == $_POST["NEW_COMPONENT_TEMPLATE"]) { $sTemplateName = $templ["NAME"]; break; } } $code = ($arComponent["DATA"]["VARIABLE"] ? $arComponent["DATA"]["VARIABLE"] . "=" : "") . "\$APPLICATION->IncludeComponent(\"" . $arComponent["DATA"]["COMPONENT_NAME"] . "\", " . "\"" . $sTemplateName . "\", " . "array(\n\t" . PHPParser::ReturnPHPStr2($aPostValues) . "\n\t)" . ",\n\t" . (strlen($arComponent["DATA"]["PARENT_COMP"]) > 0 ? $arComponent["DATA"]["PARENT_COMP"] : "false") . (!empty($arComponent["DATA"]["FUNCTION_PARAMS"]) ? ",\n\t" . "array(\n\t" . PHPParser::ReturnPHPStr2($arComponent["DATA"]["FUNCTION_PARAMS"]) . "\n\t)" : "") . "\n);"; $filesrc_for_save = substr($filesrc, 0, $arComponent["START"]) . $code . substr($filesrc, $arComponent["END"]); $f = $io->GetFile($abs_path); $arUndoParams = array('module' => 'fileman', 'undoType' => 'edit_component_props', 'undoHandler' => 'CFileman::UndoEditFile', 'arContent' => array('absPath' => $abs_path, 'content' => $f->GetContents())); if ($APPLICATION->SaveFileContent($abs_path, $filesrc_for_save)) { CUndo::ShowUndoMessage(CUndo::Add($arUndoParams)); $obJSPopup->Close(); } else { $strWarning .= GetMessage("comp_prop_err_save") . "<br>"; } } } } $componentPath = CComponentEngine::MakeComponentPath($_GET["component_name"]); $arComponentDescription["ICON"] = ltrim($arComponentDescription["ICON"], "/"); $localPath = getLocalPath("components" . $componentPath);
private function reindexFile($siteId, $rootPath, $path, $maxFileSize = 0) { $pathAbs = IO\Path::combine($rootPath, $path); if (!UrlRewriter::checkPath($pathAbs)) { return 0; } $file = new IO\File($pathAbs); if ($maxFileSize > 0 && $file->getFileSize() > $maxFileSize * 1024) { return 0; } $fileSrc = $file->getContents(); if (!$fileSrc || $fileSrc == "") { return 0; } $arComponents = \PHPParser::parseScript($fileSrc); for ($i = 0, $cnt = count($arComponents); $i < $cnt; $i++) { $sef = is_array($arComponents[$i]["DATA"]["PARAMS"]) && $arComponents[$i]["DATA"]["PARAMS"]["SEF_MODE"] == "Y"; Component\ParametersTable::add(array('SITE_ID' => $siteId, 'COMPONENT_NAME' => $arComponents[$i]["DATA"]["COMPONENT_NAME"], 'TEMPLATE_NAME' => $arComponents[$i]["DATA"]["TEMPLATE_NAME"], 'REAL_PATH' => $path, 'SEF_MODE' => $sef ? Component\ParametersTable::SEF_MODE : Component\ParametersTable::NOT_SEF_MODE, 'SEF_FOLDER' => $sef ? $arComponents[$i]["DATA"]["PARAMS"]["SEF_FOLDER"] : null, 'START_CHAR' => $arComponents[$i]["START"], 'END_CHAR' => $arComponents[$i]["END"], 'PARAMETERS' => serialize($arComponents[$i]["DATA"]["PARAMS"]))); if ($sef) { if (array_key_exists("SEF_RULE", $arComponents[$i]["DATA"]["PARAMS"])) { $ruleMaker = new UrlRewriterRuleMaker(); $ruleMaker->process($arComponents[$i]["DATA"]["PARAMS"]["SEF_RULE"]); $arFields = array("CONDITION" => $ruleMaker->getCondition(), "RULE" => $ruleMaker->getRule(), "ID" => $arComponents[$i]["DATA"]["COMPONENT_NAME"], "PATH" => $path, "SORT" => self::DEFAULT_SORT); } else { $arFields = array("CONDITION" => "#^" . $arComponents[$i]["DATA"]["PARAMS"]["SEF_FOLDER"] . "#", "RULE" => "", "ID" => $arComponents[$i]["DATA"]["COMPONENT_NAME"], "PATH" => $path, "SORT" => self::DEFAULT_SORT); } UrlRewriter::add($siteId, $arFields); } } return true; }
/** * Mark a source code file based on the coverage data gathered * * @param $phpFile Name of the actual source file * @param $fileLink Link to the html mark-up file for the $phpFile * @param &$coverageLines Coverage recording for $phpFile * @return boolean FALSE on failure * @access protected */ protected function markFile($phpFile, $fileLink, &$coverageLines) { global $util; $fileLink = $util->replaceBackslashes($fileLink); $parentDir = $util->replaceBackslashes(dirname($fileLink)); if (!file_exists($parentDir)) { //echo "\nCreating dir: $parentDir\n"; $util->makeDirRecursive($parentDir, 0755); } $writer = fopen($fileLink, "w"); if (empty($writer)) { $this->logger->error("Could not open file for writing: {$fileLink}", __FILE__, __LINE__); return false; } // Get the header for file $filestr = $this->writePhpFileHeader(basename($phpFile), $fileLink); // Add header for table $filestr .= '<table width="100%" border="0" cellpadding="2" cellspacing="0">'; $filestr .= $this->writeFileTableHead(); $lineCnt = $coveredCnt = $uncoveredCnt = 0; $parser = new PHPParser(); $parser->parse($phpFile); $lastLineType = "non-exec"; $fileLines = array(); while (($line = $parser->getLine()) !== false) { if (substr($line, -1) == "\n") { $line = substr($line, 0, -1); } $lineCnt++; $coverageLineNumbers = array_keys($coverageLines); if (in_array($lineCnt, $coverageLineNumbers)) { $lineType = $parser->getLineType(); if ($lineType == LINE_TYPE_EXEC) { $coveredCnt++; $type = "covered"; } else { if ($lineType == LINE_TYPE_CONT) { // XDebug might return this as covered - when it is // actually merely a continuation of previous line if ($lastLineType == "covered" || $lastLineType == "covered_cont") { unset($coverageLines[$lineCnt]); $type = "covered_cont"; $coveredCnt++; } else { $ft = "uncovered_cont"; for ($il = $lineCnt - 1; $il >= 0 && isset($fileLines[$lineCnt - 1]["type"]) && $ft == "uncovered_cont"; $il--) { $ft = $fileLines[$il]["type"]; $uncoveredCnt--; $coveredCnt++; if ($ft == "uncovered") { $fileLines[$il]["type"] = "covered"; } else { $fileLines[$il]["type"] = "covered_cont"; } } $coveredCnt++; $type = "covered_cont"; } } else { $type = "non-exec"; $coverageLines[$lineCnt] = 0; } } } else { if ($parser->getLineType() == LINE_TYPE_EXEC) { $uncoveredCnt++; $type = "uncovered"; } else { if ($parser->getLineType() == LINE_TYPE_CONT) { if ($lastLineType == "uncovered" || $lastLineType == "uncovered_cont") { $uncoveredCnt++; $type = "uncovered_cont"; } else { if ($lastLineType == "covered" || $lastLineType == "covered_cont") { $coveredCnt++; $type = "covered_cont"; } else { $type = $lastLineType; $this->logger->debug("LINE_TYPE_CONT with lastLineType={$lastLineType}", __FILE__, __LINE__); } } } else { $type = "non-exec"; } } } // Save line type $lastLineType = $type; //echo $line . "\t[" . $type . "]\n"; if (!isset($coverageLines[$lineCnt])) { $coverageLines[$lineCnt] = 0; } $fileLines[$lineCnt] = array("type" => $type, "lineCnt" => $lineCnt, "line" => $line, "coverageLines" => $coverageLines[$lineCnt]); } $this->logger->debug("File lines: " . print_r($fileLines, true), __FILE__, __LINE__); for ($i = 1; $i <= count($fileLines); $i++) { $filestr .= $this->writeFileTableRow($fileLines[$i]["type"], $fileLines[$i]["lineCnt"], $fileLines[$i]["line"], $fileLines[$i]["coverageLines"]); } $filestr .= "</table>"; $filestr .= $this->writePhpFileFooter(); fwrite($writer, $filestr); fclose($writer); return array('filename' => $phpFile, 'covered' => $coveredCnt, 'uncovered' => $uncoveredCnt, 'total' => $lineCnt); }
} } 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);
$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);
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; }
public static function ReindexFile($path, $SEARCH_SESS_ID = "", $max_file_size = 0) { global $APPLICATION; CMain::InitPathVars($site, $path); $DOC_ROOT = CSite::GetSiteDocRoot($site); if (!CUrlRewriter::CheckPath($path)) { return 0; } if ($max_file_size > 0 && filesize($DOC_ROOT . "/" . $path) > $max_file_size * 1024) { return 0; } $filesrc = $APPLICATION->GetFileContent($DOC_ROOT . "/" . $path); if (!$filesrc || $filesrc == "") { return 0; } $arComponents = PHPParser::ParseScript($filesrc); for ($i = 0, $cnt = count($arComponents); $i < $cnt; $i++) { if ($arComponents[$i]["DATA"]["PARAMS"]["SEF_MODE"] == "Y") { if (array_key_exists("SEF_RULE", $arComponents[$i]["DATA"]["PARAMS"])) { $ruleMaker = new \Bitrix\Main\UrlRewriterRuleMaker(); $ruleMaker->process($arComponents[$i]["DATA"]["PARAMS"]["SEF_RULE"]); CUrlRewriter::Add(array("SITE_ID" => $site, "CONDITION" => $ruleMaker->getCondition(), "RULE" => $ruleMaker->getRule(), "ID" => $arComponents[$i]["DATA"]["COMPONENT_NAME"], "PATH" => $path)); } else { CUrlRewriter::Add(array("SITE_ID" => $site, "CONDITION" => "#^" . $arComponents[$i]["DATA"]["PARAMS"]["SEF_FOLDER"] . "#", "RULE" => "", "ID" => $arComponents[$i]["DATA"]["COMPONENT_NAME"], "PATH" => $path)); } } } return true; }
function GetDirList($path, &$arDirs, &$arFiles, $arFilter = array(), $sort = array(), $type = "DF", $bLogical = false, $task_mode = false) { global $USER, $APPLICATION; CMain::InitPathVars($site, $path); $DOC_ROOT = CSite::GetSiteDocRoot($site); $arDirs = array(); $arFiles = array(); $exts = strtolower($arFilter["EXTENSIONS"]); $arexts = explode(",", $exts); if (isset($arFilter["TYPE"])) { $type = strtoupper($arFilter["TYPE"]); } $io = CBXVirtualIo::GetInstance(); $path = $io->CombinePath("/", $path); $abs_path = $io->CombinePath($DOC_ROOT, $path); if (!$io->DirectoryExists($abs_path)) { return false; } $date_format = CDatabase::DateFormatToPHP(CLang::GetDateFormat("FULL")); $tzOffset = CTimeZone::GetOffset(); $dir = $io->GetDirectory($abs_path); $arChildren = $dir->GetChildren(); foreach ($arChildren as $child) { $arFile = array(); if (($type == "F" || $type == "") && $child->IsDirectory()) { continue; } if (($type == "D" || $type == "") && !$child->IsDirectory()) { continue; } $file = $child->GetName(); if ($bLogical) { if ($child->IsDirectory()) { $sSectionName = ""; $fsn = $io->CombinePath($abs_path, $file, ".section.php"); if (!$io->FileExists($fsn)) { continue; } include $io->GetPhysicalName($fsn); $arFile["LOGIC_NAME"] = $sSectionName; } else { if (CFileMan::GetFileTypeEx($file) != "php") { continue; } if ($file == '.section.php') { continue; } if (!preg_match('/^\\.(.*)?\\.menu\\.(php|html|php3|php4|php5|php6|phtml)$/', $file, $regs)) { $f = $io->GetFile($abs_path . "/" . $file); $filesrc = $f->GetContents(); $title = PHPParser::getPageTitle($filesrc); if ($title === false) { continue; } $arFile["LOGIC_NAME"] = $title; } } } $arFile["PATH"] = $abs_path . "/" . $file; $arFile["ABS_PATH"] = $path . "/" . $file; $arFile["NAME"] = $file; $arPerm = $APPLICATION->GetFileAccessPermission(array($site, $path . "/" . $file), $USER->GetUserGroupArray(), $task_mode); if ($task_mode) { $arFile["PERMISSION"] = $arPerm[0]; if (count($arPerm[1]) > 0) { $arFile["PERMISSION_EX"] = $arPerm[1]; } } else { $arFile["PERMISSION"] = $arPerm; } $arFile["TIMESTAMP"] = $child->GetModificationTime() + $tzOffset; $arFile["DATE"] = date($date_format, $arFile["TIMESTAMP"]); if (isset($arFilter["TIMESTAMP_1"]) && strtotime($arFile["DATE"]) < strtotime($arFilter["TIMESTAMP_1"])) { continue; } if (isset($arFilter["TIMESTAMP_2"]) && strtotime($arFile["DATE"]) > strtotime($arFilter["TIMESTAMP_2"])) { continue; } if (is_set($arFilter, "MIN_PERMISSION") && $arFile["PERMISSION"] < $arFilter["MIN_PERMISSION"] && !$task_mode) { continue; } if (!$child->IsDirectory() && $arFile["PERMISSION"] <= "R" && !$task_mode) { continue; } if ($bLogical) { if (strlen($arFilter["NAME"]) > 0 && strpos($arFile["LOGIC_NAME"], $arFilter["NAME"]) === false) { continue; } } else { if (strlen($arFilter["NAME"]) > 0 && strpos($arFile["NAME"], $arFilter["NAME"]) === false) { continue; } } //if(strlen($arFilter["NAME"])>0 && strpos($arFile["NAME"], $arFilter["NAME"])===false) // continue; if (substr($arFile["ABS_PATH"], 0, strlen(BX_ROOT . "/modules")) == BX_ROOT . "/modules" && !$USER->CanDoOperation('edit_php') && !$task_mode) { continue; } if ($arFile["PERMISSION"] == "U" && !$task_mode) { $ftype = GetFileType($arFile["NAME"]); if ($ftype != "SOURCE" && $ftype != "IMAGE" && $ftype != "UNKNOWN") { continue; } if (substr($arFile["NAME"], 0, 1) == ".") { continue; } } if ($child->IsDirectory()) { $arFile["SIZE"] = 0; $arFile["TYPE"] = "D"; $arDirs[] = $arFile; } else { if ($exts != "") { if (!in_array(strtolower(substr($file, bxstrrpos($file, ".") + 1)), $arexts)) { continue; } } $arFile["TYPE"] = "F"; $arFile["SIZE"] = $child->GetFileSize(); $arFiles[] = $arFile; } } if (is_array($sort) && count($sort) > 0) { $by = key($sort); $order = strtolower($sort[$by]); $by = strtolower($by); if ($order != "desc") { $order = "asc"; } if ($by != "size" && $by != "timestamp") { $by = "name"; } usort($arDirs, array("_FilesCmp", "cmp_" . $by . "_" . $order)); usort($arFiles, array("_FilesCmp", "cmp_" . $by . "_" . $order)); } return null; }
protected function markFile($phpFile, $fileLink, &$coverageLines) { global $util; $fileLink = $util->replaceBackslashes($fileLink); $parentDir = $util->replaceBackslashes(dirname($fileLink)); $lineCnt = $coveredCnt = $uncoveredCnt = 0; $parser = new PHPParser(); $parser->parse($phpFile); $lastLineType = "non-exec"; $fileLines = array(); while (($line = $parser->getLine()) !== false) { $line = substr($line, 0, strlen($line) - 1); $lineCnt++; $coverageLineNumbers = array_keys($coverageLines); if (in_array($lineCnt, $coverageLineNumbers)) { $lineType = $parser->getLineType(); if ($lineType == LINE_TYPE_EXEC) { $coveredCnt++; $type = "covered"; } else { if ($lineType == LINE_TYPE_CONT) { // XDebug might return this as covered - when it is // actually merely a continuation of previous line if ($lastLineType == "covered") { unset($coverageLines[$lineCnt]); $type = $lastLineType; } else { if ($lineCnt - 1 >= 0 && isset($fileLines[$lineCnt - 1]["type"])) { if ($fileLines[$lineCnt - 1]["type"] == "uncovered") { $uncoveredCnt--; } $fileLines[$lineCnt - 1]["type"] = $lastLineType = "covered"; } $coveredCnt++; $type = "covered"; } } else { $type = "non-exec"; $coverageLines[$lineCnt] = 0; } } } else { if ($parser->getLineType() == LINE_TYPE_EXEC) { $uncoveredCnt++; $type = "uncovered"; } else { if ($parser->getLineType() == LINE_TYPE_CONT) { $type = $lastLineType; } else { $type = "non-exec"; } } } // Save line type $lastLineType = $type; if (!isset($coverageLines[$lineCnt])) { $coverageLines[$lineCnt] = 0; } $fileLines[$lineCnt] = array("type" => $type, "lineCnt" => $lineCnt, "line" => $line, "coverageLines" => $coverageLines[$lineCnt]); } return array('filename' => $phpFile, 'covered' => $coveredCnt, 'uncovered' => $uncoveredCnt, 'total' => $lineCnt); }
$functionParams = ""; if(!empty($arComponent["DATA"]["FUNCTION_PARAMS"])) { $functionParams = ",\n". "\tarray(\n". "\t\t".PHPParser::ReturnPHPStr2($arComponent["DATA"]["FUNCTION_PARAMS"])."\n". "\t)"; } $code = ($arComponent["DATA"]["VARIABLE"]? $arComponent["DATA"]["VARIABLE"]." = ":""). "\$APPLICATION->IncludeComponent(\n". "\t\"".$arComponent["DATA"]["COMPONENT_NAME"]."\", \n". "\t\"".$sTemplateName."\", \n". "\tarray(\n". "\t\t".PHPParser::ReturnPHPStr2($aPostValues)."\n". "\t),\n". "\t".($arComponent["DATA"]["PARENT_COMP"] <> ''? $arComponent["DATA"]["PARENT_COMP"] : "false"). $functionParams. "\n);"; $filesrc_for_save = substr($filesrc, 0, $arComponent["START"]).$code.substr($filesrc, $arComponent["END"]); $f = $io->GetFile($abs_path); $arUndoParams = array( 'module' => 'fileman', 'undoType' => 'edit_component_props', 'undoHandler' => 'CFileman::UndoEditFile', 'arContent' => array( 'absPath' => $abs_path, 'content' => $f->GetContents()
} } //check template name $sTemplateName = ""; $arComponentTemplates = CComponentUtil::GetTemplatesList($componentName, $templateId); foreach ($arComponentTemplates as $templ) { if ($templ["NAME"] == $_POST["COMPONENT_TEMPLATE"]) { $sTemplateName = $templ["NAME"]; break; } } $functionParams = ""; if (!empty($arComponent["DATA"]["FUNCTION_PARAMS"])) { $functionParams = ",\n" . "\tarray(\n" . "\t\t" . PHPParser::ReturnPHPStr2($arComponent["DATA"]["FUNCTION_PARAMS"]) . "\n" . "\t)"; } $code = ($arComponent["DATA"]["VARIABLE"] ? $arComponent["DATA"]["VARIABLE"] . " = " : "") . "\$APPLICATION->IncludeComponent(\n" . "\t\"" . $arComponent["DATA"]["COMPONENT_NAME"] . "\", \n" . "\t\"" . $sTemplateName . "\", \n" . "\tarray(\n" . "\t\t" . PHPParser::ReturnPHPStr2($aPostValues) . "\n" . "\t),\n" . "\t" . ($arComponent["DATA"]["PARENT_COMP"] != '' ? $arComponent["DATA"]["PARENT_COMP"] : "false") . $functionParams . "\n);"; $filesrc_for_save = substr($filesrc, 0, $arComponent["START"]) . $code . substr($filesrc, $arComponent["END"]); $f = $io->GetFile($abs_path); $arUndoParams = array('module' => 'fileman', 'undoType' => 'edit_component_props', 'undoHandler' => 'CFileman::UndoEditFile', 'arContent' => array('absPath' => $abs_path, 'content' => $f->GetContents())); if ($APPLICATION->SaveFileContent($abs_path, $filesrc_for_save)) { CUndo::ShowUndoMessage(CUndo::Add($arUndoParams)); $obJSPopup->Close(); } else { $strWarning .= GetMessage("comp_prop_err_save") . "<br>"; } } } } $componentPath = CComponentEngine::MakeComponentPath($componentName); if ($strWarning !== "") { $obJSPopup->ShowValidationError($strWarning);
{ $strWarning = GetMessage("comp_prop_err_save"); } else { if(!is_array($arComponent["DATA"]["FUNCTION_PARAMS"])) $arComponent["DATA"]["FUNCTION_PARAMS"] = array(); $arComponent["DATA"]["FUNCTION_PARAMS"]["ACTIVE_COMPONENT"] = ($_GET['active'] == 'N'? 'N':'Y'); $code = ($arComponent["DATA"]["VARIABLE"]? $arComponent["DATA"]["VARIABLE"]."=":""). "\$APPLICATION->IncludeComponent(\"".$arComponent["DATA"]["COMPONENT_NAME"]."\", ". "\"".$arComponent["DATA"]["TEMPLATE_NAME"]."\", ". "array(\r\n\t".PHPParser::ReturnPHPStr2($arComponent["DATA"]["PARAMS"])."\r\n\t)". ",\r\n\t".(strlen($arComponent["DATA"]["PARENT_COMP"]) > 0? $arComponent["DATA"]["PARENT_COMP"] : "false"). ",\r\n\t"."array(\r\n\t".PHPParser::ReturnPHPStr2($arComponent["DATA"]["FUNCTION_PARAMS"])."\r\n\t)". "\r\n);"; $filesrc_for_save = substr($filesrc, 0, $arComponent["START"]).$code.substr($filesrc, $arComponent["END"]); $f = $io->GetFile($abs_path); $arUndoParams = array( 'module' => 'fileman', 'undoType' => $_GET['active'] == 'N'? 'disable_component' : 'enable_component' , 'undoHandler' => 'CFileman::UndoEditFile', 'arContent' => array( 'absPath' => $abs_path, 'content' => $f->GetContents() ) );
} } } if ($aComponent === false) { $strWarning .= GetMessage("comp_prop_err_comp") . "<br>"; } } //$_SERVER["REQUEST_METHOD"] == "POST" && $_GET["action"] == "refresh" if ($strWarning == "") { $arTemplate = CTemplates::GetByID($_GET["path"], $arValues, $_GET["template_id"]); /* save parameters to file */ if ($_SERVER["REQUEST_METHOD"] == "POST" && $_GET["action"] == "save" && $aComponent !== false && $arTemplate !== false) { if (!check_bitrix_sessid()) { $strWarning .= GetMessage("comp_prop_err_save") . "<br>"; } else { $params = PHPParser::ReturnPHPStr($_POST, $arTemplate["PARAMS"]); if ($params != "") { $code = "<" . "?" . ($arRes["VARIABLE"] ? $arRes["VARIABLE"] . "=" : "") . "\$APPLICATION->IncludeFile(\"" . $_GET["path"] . "\", Array(\r\n\t" . $params . "\r\n\t)\r\n);?" . ">"; } else { $code = "<" . "?" . ($arRes["VARIABLE"] ? $arRes["VARIABLE"] . "=" : "") . "\$APPLICATION->IncludeFile(\"" . $_GET["path"] . "\");?" . ">"; } $filesrc_for_save = substr($filesrc, 0, $aComponent[0]) . $code . substr($filesrc, $aComponent[1]); if ($APPLICATION->SaveFileContent($abs_path, $filesrc_for_save)) { $obJSPopup->Close(); } else { $strWarning .= GetMessage("comp_prop_err_save") . "<br />"; } } } } if ($arTemplate["ICON"] == "" || !is_file($_SERVER["DOCUMENT_ROOT"] . $arTemplate["ICON"])) {
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; }
public static function getPageTitle($filesrc, $prolog = false) { if ($prolog === false) { $chunks = PHPParser::getPhpChunks($filesrc, 1); if (!empty($chunks)) { $prolog =& $chunks[0]; } else { $prolog = ''; } } $title = false; if ($prolog != '') { if (preg_match("/\\\$APPLICATION->SetTitle\\s*\\(\\s*\"(.*?)(?<!\\\\)\"\\s*\\);/is", $prolog, $regs)) { $title = UnEscapePHPString($regs[1]); } elseif (preg_match("/\\\$APPLICATION->SetTitle\\s*\\(\\s*'(.*?)(?<!\\\\)'\\s*\\);/is", $prolog, $regs)) { $title = UnEscapePHPString($regs[1]); } elseif (preg_match("'<title[^>]*>([^>]+)</title[^>]*>'i", $prolog, $regs)) { $title = $regs[1]; } } if (!$title && preg_match("'<title[^>]*>([^>]+)</title[^>]*>'i", $filesrc, $regs)) { $title = $regs[1]; } return $title; }
function ParseFileContent($filesrc, $params = array()) { ///////////////////////////////////// // Parse prolog, epilog, title ///////////////////////////////////// $filesrc = trim($filesrc); $prolog = $epilog = ''; $php_doubleq = false; $php_singleq = false; $php_comment = false; $php_star_comment = false; $php_line_comment = false; $php_st = "<" . "?"; $php_ed = "?" . ">"; if ($params["use_php_parser"] && substr($filesrc, 0, 2) == $php_st) { $phpChunks = PHPParser::getPhpChunks($filesrc); if (!empty($phpChunks)) { $prolog = $phpChunks[0]; $filesrc = substr($filesrc, strlen($prolog)); } } elseif (substr($filesrc, 0, 2) == $php_st) { $fl = strlen($filesrc); $p = 2; while ($p < $fl) { $ch2 = substr($filesrc, $p, 2); $ch1 = substr($ch2, 0, 1); if ($ch2 == $php_ed && !$php_doubleq && !$php_singleq && !$php_star_comment) { $p += 2; break; } elseif (!$php_comment && $ch2 == "//" && !$php_doubleq && !$php_singleq) { $php_comment = $php_line_comment = true; $p++; } elseif ($php_line_comment && ($ch1 == "\n" || $ch1 == "\r" || $ch2 == "?>")) { $php_comment = $php_line_comment = false; } elseif (!$php_comment && $ch2 == "/*" && !$php_doubleq && !$php_singleq) { $php_comment = $php_star_comment = true; $p++; } elseif ($php_star_comment && $ch2 == "*/") { $php_comment = $php_star_comment = false; $p++; } elseif (!$php_comment) { if (($php_doubleq || $php_singleq) && $ch2 == "\\\\") { $p++; } elseif (!$php_doubleq && $ch1 == '"') { $php_doubleq = true; } elseif ($php_doubleq && $ch1 == '"' && substr($filesrc, $p - 1, 1) != '\\') { $php_doubleq = false; } elseif (!$php_doubleq) { if (!$php_singleq && $ch1 == "'") { $php_singleq = true; } elseif ($php_singleq && $ch1 == "'" && substr($filesrc, $p - 1, 1) != '\\') { $php_singleq = false; } } } $p++; } $prolog = substr($filesrc, 0, $p); $filesrc = substr($filesrc, $p); } elseif (preg_match("'(.*?<title>.*?</title>)(.*)\$'is", $filesrc, $reg)) { $prolog = $reg[1]; $filesrc = $reg[2]; } $title = PHPParser::getPageTitle($filesrc, $prolog); $arPageProps = array(); if (strlen($prolog)) { if (preg_match_all("'\\\$APPLICATION->SetPageProperty\\(([\"\\'])(.*?)(?<!\\\\)[\"\\'] *, *([\"\\'])(.*?)(?<!\\\\)[\"\\']\\);'i", $prolog, $out)) { foreach ($out[2] as $i => $m1) { $arPageProps[UnEscapePHPString($m1, $out[1][$i])] = UnEscapePHPString($out[4][$i], $out[3][$i]); } } } if (substr($filesrc, -2) == "?" . ">") { if (isset($phpChunks) && count($phpChunks) > 1) { $epilog = $phpChunks[count($phpChunks) - 1]; $filesrc = substr($filesrc, 0, -strlen($epilog)); } else { $p = strlen($filesrc) - 2; $php_start = "<" . "?"; while ($p > 0 && substr($filesrc, $p, 2) != $php_start) { $p--; } $epilog = substr($filesrc, $p); $filesrc = substr($filesrc, 0, $p); } } return array("PROLOG" => $prolog, "TITLE" => $title, "PROPERTIES" => $arPageProps, "CONTENT" => $filesrc, "EPILOG" => $epilog); }
$sTemplateName = ""; foreach($arComponentTemplates as $templ) { if($templ["NAME"] == $_POST["NEW_COMPONENT_TEMPLATE"]) { $sTemplateName = $templ["NAME"]; break; } } $code = ($arComponent["DATA"]["VARIABLE"]? $arComponent["DATA"]["VARIABLE"]."=":""). "\$APPLICATION->IncludeComponent(\"".$arComponent["DATA"]["COMPONENT_NAME"]."\", ". "\"".$sTemplateName."\", ". "array(\n\t".PHPParser::ReturnPHPStr2($aPostValues)."\n\t)". ",\n\t".(strlen($arComponent["DATA"]["PARENT_COMP"]) > 0? $arComponent["DATA"]["PARENT_COMP"] : "false"). (!empty($arComponent["DATA"]["FUNCTION_PARAMS"])? ",\n\t"."array(\n\t".PHPParser::ReturnPHPStr2($arComponent["DATA"]["FUNCTION_PARAMS"])."\n\t)" : ""). "\n);"; $filesrc_for_save = substr($filesrc, 0, $arComponent["START"]).$code.substr($filesrc, $arComponent["END"]); $f = $io->GetFile($abs_path); $arUndoParams = array( 'module' => 'fileman', 'undoType' => 'edit_component_props', 'undoHandler' => 'CFileman::UndoEditFile', 'arContent' => array( 'absPath' => $abs_path, 'content' => $f->GetContents() ) ); if($APPLICATION->SaveFileContent($abs_path, $filesrc_for_save))
function IncludePHPFile($params, &$smarty) { PHPParser::SafeLoadPHPFile($params['path']); }
public function handleInput(&$data, &$errNo) { // What is this? we're getting input while we're sending a reply? if ($this->sendFile) { $this->writeFileReset(); $this->httpRequest = null; } else { if ($this->sendQLen > 0) { $this->sendQReset(); $this->httpRequest = null; } } if (!$this->httpRequest) { $this->httpRequest = new HttpRequest(); } // Pass the incoming data to the HttpRequest class, so it can handle it. if (!$this->httpRequest->handleInput($data)) { // An error was encountered while receiving the requst. // Send reply (unless 444, a special 'direct reject' code) and return false to close this connection. if ($this->httpRequest->errNo != 444) { $r = new HttpResponse('1.1', $this->httpRequest->errNo); $r->addBody($this->createErrorPage($this->httpRequest->errNo, $this->httpRequest->errStr)); if ($this->httpRequest->errNo == 405) { $r->addHeader('Allow: GET, POST, HEAD'); $r->addHeader('Access-Control-Allow-Methods: GET, POST, HEAD'); } $this->write($r->getHeaders()); $this->write($r->getBody()); $this->logRequest($r->getResponseCode(), $r->getHeader('Content-Length') ? $r->getHeader('Content-Length') : 0); } else { $this->logRequest(444, 0); } $errNo = $this->httpRequest->errNo; return false; } // If we have no headers, or we are busy with receiving. // Just return and wait for more data. if (!$this->httpRequest->hasHeaders || $this->httpRequest->isReceiving) { // We're still receiving the body of a request return true; } // Return true to just wait and try again later // At this point we have a fully qualified and parsed HttpRequest // The HttpRequest object contains all info about the headers / GET / POST / COOKIE / FILES // Just finalise it by adding some extra client info. $this->httpRequest->SERVER['REMOTE_ADDR'] = $this->ip; $this->httpRequest->SERVER['REMOTE_PORT'] = $this->port; $this->httpRequest->SERVER['SERVER_ADDR'] = $this->localIP; $this->httpRequest->SERVER['SERVER_PORT'] = $this->localPort; $exp = explode(':', $this->httpRequest->headers['Host']); $this->httpRequest->SERVER['SERVER_NAME'] = $exp[0]; $this->httpRequest->SERVER['HTTP_HOST'] = $this->httpRequest->headers['Host']; $this->httpRequest->SERVER['HTTP_USER_AGENT'] = isset($this->httpRequest->headers['User-Agent']) ? $this->httpRequest->headers['User-Agent'] : ''; $this->httpRequest->SERVER['HTTP_ACCEPT'] = isset($this->httpRequest->headers['Accept']) ? $this->httpRequest->headers['Accept'] : ''; $this->httpRequest->SERVER['HTTP_ACCEPT_LANGUAGE'] = isset($this->httpRequest->headers['Accept-Language']) ? $this->httpRequest->headers['Accept-Language'] : ''; $this->httpRequest->SERVER['HTTP_ACCEPT_ENCODING'] = isset($this->httpRequest->headers['Accept-Encoding']) ? $this->httpRequest->headers['Accept-Encoding'] : ''; $this->httpRequest->SERVER['HTTP_ACCEPT_CHARSET'] = isset($this->httpRequest->headers['Accept-Charset']) ? $this->httpRequest->headers['Accept-Charset'] : ''; $this->httpRequest->SERVER['HTTP_CONNECTION'] = isset($this->httpRequest->headers['Connection']) ? $this->httpRequest->headers['Connection'] : ''; $this->httpRequest->SERVER['HTTP_KEEP_ALIVE'] = isset($this->httpRequest->headers['Keep-Alive']) ? $this->httpRequest->headers['Keep-Alive'] : ''; if (isset($this->httpRequest->headers['Referer'])) { $this->httpRequest->SERVER['HTTP_REFERER'] = $this->httpRequest->headers['Referer']; } if (isset($this->httpRequest->headers['Range'])) { $this->httpRequest->SERVER['HTTP_RANGE'] = $this->httpRequest->headers['Range']; } if (isset($this->httpRequest->headers['Cookie'])) { $this->httpRequest->SERVER['HTTP_COOKIE'] = $this->httpRequest->headers['Cookie']; } if (isset($this->httpRequest->headers['Authorization'])) { $this->httpRequest->SERVER['HTTP_AUTHORIZATION'] = $this->httpRequest->headers['Authorization']; } $this->httpRequest->SERVER['REQUEST_TIME'] = time(); // Check if we have to match siteDomain if ($this->http->getSiteDomain() != '' && $this->http->getSiteDomain() != $this->httpRequest->SERVER['SERVER_NAME']) { $r = new HttpResponse($this->httpRequest->SERVER['httpVersion'], 404); $r->addBody($this->createErrorPage(404)); $this->write($r->getHeaders()); $this->write($r->getBody()); $errNo = 404; $this->logRequest($r->getResponseCode(), $r->getHeader('Content-Length') ? $r->getHeader('Content-Length') : 0); return false; } // HTTP Authorisation? if ($this->http->getHttpAuthPath() != '') { $scriptPath = pathinfo($this->httpRequest->SERVER['SCRIPT_NAME'], PATHINFO_DIRNAME); // Check if path must be auth'd and if HTTP_AUTHORIZATION header exists and if so, validate it if (isDirInDir($this->http->getHttpAuthPath(), $this->http->getDocRoot() . $scriptPath) && (!isset($this->httpRequest->SERVER['HTTP_AUTHORIZATION']) || !$this->validateAuthorization())) { // Not validated - send 401 Unauthorized do { $nonce = createRandomString(17, RAND_HEX); if (!$this->http->getNonceInfo($nonce)) { break; } } while (true); $opaque = $this->http->addNewNonce($nonce); $r = new HttpResponse($this->httpRequest->SERVER['httpVersion'], 401); if ($this->http->getHttpAuthType() == 'Digest') { $r->addHeader('WWW-Authenticate: Digest realm="' . HTTP_AUTH_REALM . '", qop="auth", nonce="' . $nonce . '", opaque="' . $opaque . '"'); } else { $r->addHeader('WWW-Authenticate: Basic realm="' . HTTP_AUTH_REALM . '"'); } $r->addBody($this->createErrorPage(401, '', true)); $this->write($r->getHeaders()); $this->write($r->getBody()); $errNo = 401; $this->logRequest($r->getResponseCode(), $r->getHeader('Content-Length') ? $r->getHeader('Content-Length') : 0); $this->httpRequest = null; return true; // we return true this time because we may stay connected } } //var_dump($this->httpRequest->headers); //var_dump($this->httpRequest->SERVER); //var_dump($this->httpRequest->GET); //var_dump($this->httpRequest->POST); //var_dump($this->httpRequest->COOKIE); // Rewrite script name? (keep it internal - don't rewrite SERVER header $scriptName = $this->httpRequest->SERVER['SCRIPT_NAME'] == '/' ? '/index.php' : $this->httpRequest->SERVER['SCRIPT_NAME']; if (file_exists($this->http->getDocRoot() . $scriptName)) { // Should we serve a file or pass the request to PHPParser for page generation? if (preg_match('/^.*\\.php$/', $scriptName)) { if ($this->httpRequest->SERVER['REQUEST_METHOD'] == 'HEAD') { $r = new HttpResponse($this->httpRequest->SERVER['httpVersion'], 200); $this->write($r->getHeaders()); } else { // 'Parse' the php file $r = new HttpResponse($this->httpRequest->SERVER['httpVersion'], 200); $html = PHPParser::parseFile($r, $scriptName, $this->httpRequest->SERVER, $this->httpRequest->GET, $this->httpRequest->POST, $this->httpRequest->COOKIE, $this->httpRequest->FILES); $r->addBody($html); $this->write($r->getHeaders()); $this->write($r->getBody()); } } else { if (is_dir($this->http->getDocRoot() . $this->httpRequest->SERVER['SCRIPT_NAME'])) { // 403 - not allowed to view folder contents $r = new HttpResponse($this->httpRequest->SERVER['httpVersion'], 403); $r->addBody($this->createErrorPage(403)); $this->write($r->getHeaders()); $this->write($r->getBody()); } else { // Send a file if ($this->httpRequest->SERVER['REQUEST_METHOD'] == 'HEAD') { $r = new HttpResponse($this->httpRequest->SERVER['httpVersion'], 200); $this->write($r->getHeaders()); } else { $r = $this->serveFile(); } } } } else { // 404 $r = new HttpResponse($this->httpRequest->SERVER['httpVersion'], 404); $r->addBody($this->createErrorPage(404)); $this->write($r->getHeaders()); $this->write($r->getBody()); } // log line $this->logRequest($r->getResponseCode(), $r->getHeader('Content-Length') ? $r->getHeader('Content-Length') : 0); // Reset httpRequest $this->httpRequest = null; return true; }
public static function OnChangeFileComponent($path, $site) { /** @global CMain $APPLICATION */ global $APPLICATION; // kind of optimization if (!HasScriptExtension($path)) { return; } $docRoot = CSite::GetSiteDocRoot($site); CUrlRewriter::Delete(array("SITE_ID" => $site, "PATH" => $path, "ID" => "NULL")); if (class_exists("\\Bitrix\\Main\\Application", false)) { \Bitrix\Main\Component\ParametersTable::deleteByFilter(array("SITE_ID" => $site, "REAL_PATH" => $path)); } $fileSrc = $APPLICATION->GetFileContent($docRoot . $path); $arComponents = PHPParser::ParseScript($fileSrc); for ($i = 0, $cnt = count($arComponents); $i < $cnt; $i++) { if (class_exists("\\Bitrix\\Main\\Application", false)) { $isSEF = is_array($arComponents[$i]["DATA"]["PARAMS"]) && $arComponents[$i]["DATA"]["PARAMS"]["SEF_MODE"] == "Y"; \Bitrix\Main\Component\ParametersTable::add(array('SITE_ID' => $site, 'COMPONENT_NAME' => $arComponents[$i]["DATA"]["COMPONENT_NAME"], 'TEMPLATE_NAME' => $arComponents[$i]["DATA"]["TEMPLATE_NAME"], 'REAL_PATH' => $path, 'SEF_MODE' => $isSEF ? \Bitrix\Main\Component\ParametersTable::SEF_MODE : \Bitrix\Main\Component\ParametersTable::NOT_SEF_MODE, 'SEF_FOLDER' => $isSEF ? $arComponents[$i]["DATA"]["PARAMS"]["SEF_FOLDER"] : null, 'START_CHAR' => $arComponents[$i]["START"], 'END_CHAR' => $arComponents[$i]["END"], 'PARAMETERS' => serialize($arComponents[$i]["DATA"]["PARAMS"]))); } if (isset($arComponents[$i]["DATA"]["PARAMS"]) && is_array($arComponents[$i]["DATA"]["PARAMS"])) { if (array_key_exists("SEF_MODE", $arComponents[$i]["DATA"]["PARAMS"]) && $arComponents[$i]["DATA"]["PARAMS"]["SEF_MODE"] == "Y") { if (array_key_exists("SEF_RULE", $arComponents[$i]["DATA"]["PARAMS"])) { $ruleMaker = new \Bitrix\Main\UrlRewriterRuleMaker(); $ruleMaker->process($arComponents[$i]["DATA"]["PARAMS"]["SEF_RULE"]); CUrlRewriter::Add(array("SITE_ID" => $site, "CONDITION" => $ruleMaker->getCondition(), "RULE" => $ruleMaker->getRule(), "ID" => $arComponents[$i]["DATA"]["COMPONENT_NAME"], "PATH" => $path)); } else { CUrlRewriter::Add(array("SITE_ID" => $site, "CONDITION" => "#^" . $arComponents[$i]["DATA"]["PARAMS"]["SEF_FOLDER"] . "#", "ID" => $arComponents[$i]["DATA"]["COMPONENT_NAME"], "PATH" => $path)); } } } } }
$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];
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];
function ReindexFile($path, $SEARCH_SESS_ID = "", $max_file_size = 0) { global $APPLICATION; CMain::InitPathVars($site, $path); $DOC_ROOT = CSite::GetSiteDocRoot($site); if (!CUrlRewriter::CheckPath($path)) { return 0; } if ($max_file_size > 0 && filesize($DOC_ROOT . "/" . $path) > $max_file_size * 1024) { return 0; } $filesrc = $APPLICATION->GetFileContent($DOC_ROOT . "/" . $path); if (!$filesrc || $filesrc == "") { return 0; } $arComponents = PHPParser::ParseScript($filesrc); for ($i = 0, $cnt = count($arComponents); $i < $cnt; $i++) { if ($arComponents[$i]["DATA"]["PARAMS"]["SEF_MODE"] == "Y") { $arFields = array("SITE_ID" => $site, "CONDITION" => "#^" . $arComponents[$i]["DATA"]["PARAMS"]["SEF_FOLDER"] . "#", "RULE" => "", "ID" => $arComponents[$i]["DATA"]["COMPONENT_NAME"], "PATH" => $path); CUrlRewriter::Add($arFields); } } return true; }
} } if ($strWarning == "") { $arComponent = PHPParser::FindComponent($_GET["component_name"], $filesrc, $src_line); if ($arComponent === false) { $strWarning = GetMessage("comp_prop_err_comp"); } } if ($strWarning == "") { if (!check_bitrix_sessid()) { $strWarning = GetMessage("comp_prop_err_save"); } else { if (!is_array($arComponent["DATA"]["FUNCTION_PARAMS"])) { $arComponent["DATA"]["FUNCTION_PARAMS"] = array(); } $arComponent["DATA"]["FUNCTION_PARAMS"]["ACTIVE_COMPONENT"] = $_GET['active'] == 'N' ? 'N' : 'Y'; $code = ($arComponent["DATA"]["VARIABLE"] ? $arComponent["DATA"]["VARIABLE"] . "=" : "") . "\$APPLICATION->IncludeComponent(\"" . $arComponent["DATA"]["COMPONENT_NAME"] . "\", " . "\"" . $arComponent["DATA"]["TEMPLATE_NAME"] . "\", " . "array(\r\n\t" . PHPParser::ReturnPHPStr2($arComponent["DATA"]["PARAMS"]) . "\r\n\t)" . ",\r\n\t" . (strlen($arComponent["DATA"]["PARENT_COMP"]) > 0 ? $arComponent["DATA"]["PARENT_COMP"] : "false") . ",\r\n\t" . "array(\r\n\t" . PHPParser::ReturnPHPStr2($arComponent["DATA"]["FUNCTION_PARAMS"]) . "\r\n\t)" . "\r\n);"; $filesrc_for_save = substr($filesrc, 0, $arComponent["START"]) . $code . substr($filesrc, $arComponent["END"]); $f = $io->GetFile($abs_path); $arUndoParams = array('module' => 'fileman', 'undoType' => $_GET['active'] == 'N' ? 'disable_component' : 'enable_component', 'undoHandler' => 'CFileman::UndoEditFile', 'arContent' => array('absPath' => $abs_path, 'content' => $f->GetContents())); if (!$APPLICATION->SaveFileContent($abs_path, $filesrc_for_save)) { $strWarning = GetMessage("comp_prop_err_save"); } else { CUndo::ShowUndoMessage(CUndo::Add($arUndoParams)); } } } if ($strWarning != "") { echo "<script>alert('" . CUtil::JSEscape($strWarning) . "')</script>"; } require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_admin_js.php";
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; }
<?php if (!class_exists('RESTObserver')) { PHPParser::SafeLoadPHPFile('events/includes/class.RESTObserver.php'); } class RESTInvoiceObserver extends RESTObserver implements IInvoiceObserver, IConfigurable { public function __construct(DataForm $Config) { $this->Config = $Config; } public static function GetConfigurationForm() { $ConfigurationForm = new DataForm(); $ConfigurationForm->SetInlineHelp(""); $methods = get_class_methods(__CLASS__); foreach ($methods as $method) { if ($method != '__construct' && $method != 'GetConfigurationForm') { $ConfigurationForm->AppendField(new DataFormField("{$method}URL", FORM_FIELD_TYPE::TEXT, "{$method} URL")); } } return $ConfigurationForm; } public function OnIssued(Invoice $Invoice) { $this->Request('OnIssued', array('Invoice' => $Invoice->ToArray())); } public function OnPaid(Invoice $Invoice, AbstractPaymentModule $payment_module = null) { $module_name = $payment_module !== null ? $payment_module->GetModuleName() : "Manual"; $this->Request('OnPaid', array('Invoice' => $Invoice->ToArray(), 'payment_module' => $module_name));
/** * Generate the WSDL * */ public function createWSDL() { $this->classes = $this->PHPParser->getClasses(); foreach ($this->classes as $class => $methods) { $pbs = array(); ksort($methods); foreach ($methods as $method => $components) { if ($components["type"] == "public" || $components["type"] == "") { if (array_key_exists("params", $components)) { $this->createMessage($method, $components["returnType"], $components["params"]); } else { $this->createMessage($method, $components["returnType"]); } $pbs[$class][$method]["documentation"] = $components["description"]; $pbs[$class][$method]["input"] = $method; $pbs[$class][$method]["output"] = $method; } } $this->createPortType($pbs); $this->createBinding($pbs); $this->createService($pbs); } // adding typens foreach ($this->typens as $typenNo => $url) { $this->WSDLXML->setAttribute("xmlns:" . $typenNo, $url); } // add types if (is_array($this->typensDefined) && count($this->typensDefined) > 0) { $types = new XMLCreator("types"); $xsdSchema = new XMLCreator("xsd:schema"); $xsdSchema->setAttribute("xmlns", "http://www.w3.org/2001/XMLSchema"); $xsdSchema->setAttribute("targetNamespace", "urn:" . $this->name); $vars = $this->PHPParser->getClassesVars(); foreach ($this->typensDefined as $typensDefined) { $complexType = new XMLCreator("xsd:complexType"); $complexType->setAttribute("name", $typensDefined); $all = new XMLCreator("xsd:all"); if (isset($vars[$typensDefined]) && is_array($vars[$typensDefined])) { ksort($vars[$typensDefined]); foreach ($vars[$typensDefined] as $varName => $varType) { $element = new XMLCreator("xsd:element"); $element->setAttribute("name", $varName); $varType = isset($this->xsd[$varType]) ? "xsd:" . $this->xsd[$varType] : "anyType"; $element->setAttribute("type", $this->xsd[$varType]); $all->addChild($element); } } $complexType->addChild($all); $xsdSchema->addChild($complexType); } $types->addChild($xsdSchema); $this->WSDLXML->addChild($types); } // adding messages foreach ($this->messages as $message) { $this->WSDLXML->addChild($message); } // adding port types foreach ($this->portTypes as $portType) { $this->WSDLXML->addChild($portType); } // adding bindings foreach ($this->bindings as $binding) { $this->WSDLXML->addChild($binding); } // adding services $s = new XMLCreator("service"); $s->setAttribute("name", $this->name . "Service"); foreach ($this->services as $service) { $s->addChild($service); } $this->WSDLXML->addChild($s); $this->WSDL = "<?xml version='1.0' encoding='UTF-8'?>\n"; $this->WSDL .= "<!-- WSDL file generated by PHP WSDLCreator (http://www.protung.ro) -->\n"; $this->WSDL .= $this->WSDLXML->getXML(); }
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]; }