function ParseFile($file) { $docRoot = CSite::GetSiteDocRoot(self::$curSite); $file = str_replace("//", "/", $file); $io = CBXVirtualIo::GetInstance(); $bIsDir = $io->DirectoryExists($file); if (is_link($file)) { return; } if ($bIsDir) { // Skip 'bitrix' and 'upload' folders if ($file == $docRoot . '/bitrix' || $file == $docRoot . '/upload' || $file == $docRoot . '/images') { return; } $oDir = new CFilemanUtilDir($file, array('obj' => $this, 'site' => self::$curSite, 'callBack' => "ParseFile", 'checkBreak' => "CheckBreak", 'checkSubdirs' => false)); $bSuccess = $oDir->Start(); $bBreak = $oDir->bBreak; $nextPath = $oDir->nextPath; if ($bBreak) { $this->ParseStop(CFilemanUtils::TrimPath($nextPath, $docRoot), self::$curSite); } } else { if (self::$bSkip) { if ($file == $docRoot . self::$lastPath) { self::$bSkip = false; } else { return; } // Files was handled earlier } $fileName = $io->ExtractNameFromPath($file); // Skip files stating from dot '.' or any non .php files if (GetFileExtension($fileName) != 'php' || preg_match('/^\\..*/i' . BX_UTF_PCRE_MODIFIER, $fileName)) { return; } // 1. Get file content $fTmp = $io->GetFile($file); $fileContent = $fTmp->GetContents(); $fileContent = str_replace("\r", "", $fileContent); $fileContent = str_replace("\n", "", $fileContent); // Find files with needed components $pattern = array('intranet.event_calendar', 'socialnetwork', 'socialnetwork_user', 'socialnetwork_group'); foreach ($pattern as $p) { if (preg_match('/includecomponent\\([\\n\\t\\r\\s]*("|\')bitrix:' . $p . '/i' . BX_UTF_PCRE_MODIFIER, $fileContent)) { $this->FetchParams($fileContent); break; } } } }
public function Init($Params) { $this->maxFileOpenSize = 1024 * COption::GetOptionString("fileman", "search_max_open_file_size", 1024); $this->maxResultCount = COption::GetOptionString("fileman", "search_max_res_count", false); $this->startTime = time(); $this->Params = $Params; $this->Result = array(); $this->docRoot = CSite::GetSiteDocRoot($Params['site']); $this->bSkip = $this->Params['lastPath'] ? true : false; if ($this->bSkip) { $this->Params['lastPath'] = Rel2Abs("/", $this->Params['lastPath']); $this->Params['lastPath'] = $this->docRoot . $this->Params['lastPath']; } $this->sSess = $this->Params['ssess'] ? $this->Params['ssess'] : false; $this->bReplace = $this->Params['bReplace'] && strlen($this->Params['phrase']) > 0; if ($this->bReplace) { $this->Params['bDirsToo'] = false; } $bSuccess = false; $bBreak = false; $nextPath = ''; // Search in results of the previous search if ($this->Params['bInResult']) { $searchRes = CFilemanSearch::GetSearchResult($this->Params['ssess'], array('id', 'asc')); for ($i = 0, $l = count($searchRes); $i < $l; $i++) { $path = $this->docRoot . $searchRes[$i]['path']; if ($this->CheckBreak()) { $bBreak = true; $nextPath = $path; break; } else { $this->Search($path); } } $bSuccess = true; $bStoped = false; } else { $path = Rel2Abs("/", $this->Params["dir"]); $path = $this->docRoot . $path; $oDir = new CFilemanUtilDir($path, array('obj' => $this, 'site' => $Params['site'], 'callBack' => "Search", 'checkBreak' => "CheckBreak", 'checkSubdirs' => $this->Params["bSubdir"])); $bSuccess = $oDir->Start(); $bBreak = $oDir->bBreak; $nextPath = $oDir->nextPath; $bStoped = $oDir->bStoped; if ($bStoped) { $bBreak = false; } } if ($bSuccess) { ?> <script> <?php if ($bBreak) { // Execution breaks on timeout ?> window.fmsBtimeout = true; window.fmsLastPath = '<?php echo CUtil::JSEscape(CFilemanUtils::TrimPath($nextPath, $this->docRoot)); ?> '; <?php } else { ?> window.fmsBtimeout = false; <?php } ?> <?php if ($bStoped) { // Execution breaks on timeout ?> window.fmsBstoped = true; <?php } else { ?> window.fmsBstoped = false; <?php } ?> <?php if ($this->Params['bCount']) { ?> window.fmsResult = <?php echo count($this->Result); ?> ; <?php } else { ?> window.fmsResult = <?php echo CUtil::PhpToJSObject($this->Result); ?> ; <?php } ?> </script> <?php } else { ?> <script> <?php if ($this->Params['bCount']) { ?> window.fmsResult = 0; <?php } else { ?> window.fmsResult = []; <?php } ?> </script> <?php } }
$bStoped = true; for($i = 0; $i < $filesCount; $i++) { $arFile = $arFilesEx[$i]; if ($io->DirectoryExists($arFile['ABS_PATH']) && $_POST['recurcive'] == "Y") { $oDir = new CFilemanUtilDir($arFile['ABS_PATH'], array( 'obj' => $oChmod, 'site' => $Params['site'], 'callBack' => "Chmod", 'checkBreak' => "CheckBreak", 'checkSubdirs' => true )); $bSuccess = $oDir->Start(); $bBreak = $oDir->bBreak; $nextPath = $oDir->nextPath; $bStoped = $oDir->bStoped; } else { $bBreak = $oChmod->CheckBreak(); $bStoped = $i == $filesCount - 1; // Last iterration if ($bBreak && !$bStoped) $nextPath = $arFilesEx[$i]['ABS_PATH']; } if ($bStoped) $bBreak = false;