/** * @return array | null */ private function _getSavedData() { if (!$this->_file->isExists()) { return array(); } return \WS\Migrations\jsonToArray($this->_file->getContents()); }
public static function showTab($div, $iblockElementInfo) { $engineList = array(); if (Option::get('main', 'vendor', '') == '1c_bitrix') { $engineList[] = array("DIV" => "yandex_direct", "TAB" => Loc::getMessage("SEO_ADV_YANDEX_DIRECT"), "TITLE" => Loc::getMessage("SEO_ADV_YANDEX_DIRECT_TITLE"), "HANDLER" => IO\Path::combine(Application::getDocumentRoot(), BX_ROOT, "/modules/seo/admin/tab/seo_search_yandex_direct.php")); } if (count($engineList) > 0) { $engineTabControl = new \CAdminViewTabControl("engineTabControl", $engineList); ?> <tr> <td colspan="2"> <?php $engineTabControl->begin(); foreach ($engineList as $engineTab) { $engineTabControl->beginNextTab(); $file = new IO\File($engineTab["HANDLER"]); if ($file->isExists()) { require $file->getPath(); } } $engineTabControl->end(); ?> </td> </tr> <?php } }
function seoSitemapGetFilesData($PID, $arSitemap, $arCurrentDir, $sitemapFile) { global $NS; $arDirList = array(); if ($arCurrentDir['ACTIVE'] == SitemapRuntimeTable::ACTIVE) { $list = \CSeoUtils::getDirStructure($arSitemap['SETTINGS']['logical'] == 'Y', $arSitemap['SITE_ID'], $arCurrentDir['ITEM_PATH']); foreach ($list as $dir) { $dirKey = "/" . ltrim($dir['DATA']['ABS_PATH'], "/"); if ($dir['TYPE'] == 'F') { if (!isset($arSitemap['SETTINGS']['FILE'][$dirKey]) || $arSitemap['SETTINGS']['FILE'][$dirKey] == 'Y') { if (preg_match($arSitemap['SETTINGS']['FILE_MASK_REGEXP'], $dir['FILE'])) { $f = new IO\File($dir['DATA']['PATH'], $arSitemap['SITE_ID']); $sitemapFile->addFileEntry($f); $NS['files_count']++; } } } else { if (!isset($arSitemap['SETTINGS']['DIR'][$dirKey]) || $arSitemap['SETTINGS']['DIR'][$dirKey] == 'Y') { $arDirList[] = $dirKey; } } } } else { $len = strlen($arCurrentDir['ITEM_PATH']); if (!empty($arSitemap['SETTINGS']['DIR'])) { foreach ($arSitemap['SETTINGS']['DIR'] as $dirKey => $checked) { if ($checked == 'Y') { if (strncmp($arCurrentDir['ITEM_PATH'], $dirKey, $len) === 0) { $arDirList[] = $dirKey; } } } } if (!empty($arSitemap['SETTINGS']['FILE'])) { foreach ($arSitemap['SETTINGS']['FILE'] as $dirKey => $checked) { if ($checked == 'Y') { if (strncmp($arCurrentDir['ITEM_PATH'], $dirKey, $len) === 0) { $fileName = IO\Path::combine(SiteTable::getDocumentRoot($arSitemap['SITE_ID']), $dirKey); if (!is_dir($fileName)) { $f = new IO\File($fileName, $arSitemap['SITE_ID']); if ($f->isExists() && !$f->isSystem() && preg_match($arSitemap['SETTINGS']['FILE_MASK_REGEXP'], $f->getName())) { $sitemapFile->addFileEntry($f); $NS['files_count']++; } } } } } } } if (count($arDirList) > 0) { foreach ($arDirList as $dirKey) { $arRuntimeData = array('PID' => $PID, 'ITEM_PATH' => $dirKey, 'PROCESSED' => SitemapRuntimeTable::UNPROCESSED, 'ACTIVE' => SitemapRuntimeTable::ACTIVE, 'ITEM_TYPE' => SitemapRuntimeTable::ITEM_TYPE_DIR); SitemapRuntimeTable::add($arRuntimeData); } } SitemapRuntimeTable::update($arCurrentDir['ID'], array('PROCESSED' => SitemapRuntimeTable::PROCESSED)); }
/** * Returns urlrewrite array * * @param string $site Site ID. * @return array */ private static function getRewriteRules($site) { $docRoot = rtrim(\Bitrix\Main\SiteTable::getDocumentRoot($site), '/'); $rewriteRules = array(); $arUrlRewrite =& $rewriteRules; $rewriteFile = new IO\File($docRoot . '/urlrewrite.php'); if ($rewriteFile->isExists()) { include $rewriteFile->getPath(); } return $rewriteRules; }
/** * FileAccessManager constructor. * * @param string $path Full path to file .access.php * * @throws InvalidPathException Invalid path to file. */ public function __construct($path) { if (empty($path)) { throw new InvalidPathException($path); } $this->path = $path; $file = new File($path); if ($file->getName() === '.access.php') { $this->isFileAccess = true; } }
public function finish() { foreach ($this->partList as $key => $partName) { $f = new File(Path::combine($this->getDirectoryName(), $partName)); $f->rename(str_replace($this->getPrefix(), '', $f->getPath())); $this->partList[$key] = $f->getName(); } if ($this->isCurrentPartNotEmpty()) { $this->addFooter(); $this->rename(str_replace($this->getPrefix(), '', $this->getPath())); } }
protected static function prepareDataToInsertFromFileArray(array $fileData, array $data, ErrorCollection $errorCollection) { list($relativePath, $absolutePath) = self::generatePath(); $file = new IO\File($fileData['tmp_name']); if (!$file->isExists()) { $errorCollection->addOne(new Error('Could not find file', self::ERROR_EXISTS_FILE)); return null; } if (!$file->rename($absolutePath)) { $errorCollection->addOne(new Error('Could not move file', self::ERROR_MOVE_FILE)); return null; } //now you can set CREATED_BY $data = array_intersect_key($data, array('CREATED_BY' => true)); return array_merge(array('TOKEN' => bx_basename($relativePath), 'FILENAME' => $fileData['name'], 'PATH' => $relativePath, 'BUCKET_ID' => '', 'SIZE' => '', 'IS_CLOUD' => '', 'WIDTH' => empty($fileData['width']) ? '' : $fileData['width'], 'HEIGHT' => empty($fileData['height']) ? '' : $fileData['height']), $data); }
private function isRequestedUriExists() { /** @var $request HttpRequest */ $request = $this->getContext()->getRequest(); $absUrl = IO\Path::convertRelativeToAbsolute($request->getRequestedPage()); return IO\File::isFileExists($absUrl); }
/** * Updates cache usage statistics. * Each of parameters is added to appropriate existing stats. * * @param int $hit * @param int $miss * @param int $quota * @param int $posts * @param float $files * @return void */ public function writeStatistic($hit = 0, $miss = 0, $quota = 0, $posts = 0, $files = 0.0) { $fileValues = $this->readStatistic(); if ($fileValues) { $newValues = array(intval($fileValues["HITS"]) + $hit, intval($fileValues["MISSES"]) + $miss, intval($fileValues["QUOTA"]) + $quota, intval($fileValues["POSTS"]) + $posts, $files === false ? 0 : doubleval($fileValues["FILE_SIZE"]) + doubleval($files)); $this->statFile->putContents(implode(",", $newValues)); } }
private function createMap() { $mapFilePath = Application::getDocumentRoot() . "/bitrix/modules/mobileapp/maps/config.php"; $file = new File($mapFilePath); if (!$file->isExists()) { throw new SystemException("The map file '" . $mapFilePath . "' doesn't exists!", 100); } $map = (include $mapFilePath); if (!is_array($map)) { throw new SystemException("The map file does exist but has some broken structure.", 101); } self::$configMap = $map; self::$configMap["groups"] = array(); $groupTypes = array(ParameterType::GROUP, ParameterType::GROUP_BACKGROUND, ParameterType::GROUP_BACKGROUND_LIGHT); foreach ($map["types"] as $paramName => $intType) { if (in_array($intType, $groupTypes)) { self::$configMap["groups"][] = $paramName; } } }
public function __construct($type) { parent::__construct(); $type = trim(strtolower($type), '.'); if (!$this->issetType($type)) { throw new SystemException("Could not find type '{$type}' in BlankFile"); } $typeData = $this->getType($type); $this->name = $typeData['newFileName'] . $typeData['ext']; $this->mimeType = TypeFile::getMimeTypeByFilename($this->name); $this->src = $typeData['src']; $this->size = IO\File::isFileExists($typeData['src']) ? filesize($typeData['src']) : 0; }
private static function saveRules($siteId, array $arUrlRewrite) { $site = SiteTable::getRow(array("filter" => array("LID" => $siteId))); $docRoot = $site["DOC_ROOT"]; if (!empty($docRoot)) { $docRoot = IO\Path::normalize($docRoot); } else { $docRoot = Application::getDocumentRoot(); } $data = var_export($arUrlRewrite, true); IO\File::putFileContents($docRoot . "/urlrewrite.php", "<" . "?php\n\$arUrlRewrite=" . $data . ";\n"); Application::resetAccelerator(); }
function renderExceptionMessage(\Exception $exception, $debug = false) { if ($debug) { echo ExceptionHandlerFormatter::format($exception, true); } else { $p = Main\IO\Path::convertRelativeToAbsolute("/error.php"); if (Main\IO\File::isFileExists($p)) { include $p; } else { $context = Main\Application::getInstance(); if ($context) { echo Main\Localization\Loc::getMessage("eho_render_exception_message"); } else { echo "A error occurred during execution of this script. You can turn on extended error reporting in .settings.php file."; } } } }
/** * Sets viewport-metadata */ public static function initScripts() { global $APPLICATION; \CJSCore::Init(); $APPLICATION->AddHeadString("<script type=\"text/javascript\">var mobileSiteDir=\"" . SITE_DIR . "\"; var appVersion = " . self::$apiVersion . ";var platform = \"" . self::$platform . "\";</script>", false, true); if (self::$platform == "android") { /** * This is workaround for android * We use console.log() to tell the application about successful loading of this page */ $APPLICATION->AddHeadString("<script type=\"text/javascript\">console.log(\"bxdata://success\")</script>", false, true); } if (self::getInstance()->getBXScriptSupported()) { /** * If the application tells us bxscript-feature is available * it means that device can load cordova-scripts (including plugins) itself. */ $pgJsFile = "/bitrix/js/mobileapp/__deviceload__/cordova.js"; $APPLICATION->AddHeadString("<script type=\"text/javascript\" src=\"" . $pgJsFile . "\"></script>", false, true); } else { $pgJsFile = "/bitrix/js/mobileapp/" . self::$platform . "-cordova-" . self::$pgVersion . ".js"; if (!File::isFileExists(Application::getDocumentRoot() . $pgJsFile)) { $pgJsFile = self::$remoteScriptPath . self::$platform . "-cordova-" . self::$pgVersion . ".js"; } $APPLICATION->AddHeadString("<script type=\"text/javascript\" src=\"" . \CUtil::GetAdditionalFileURL($pgJsFile) . "\"></script>", false, true); } $APPLICATION->AddHeadString("<script type=\"text/javascript\" src=\"" . \CUtil::GetAdditionalFileURL("/bitrix/js/mobileapp/bitrix_mobile.js") . "\"></script>", false, true); $APPLICATION->AddHeadString("<script type=\"text/javascript\" src=\"" . \CUtil::GetAdditionalFileURL("/bitrix/js/mobileapp/mobile_lib.js") . "\"></script>", false, true); if (self::$platform == "android") { $APPLICATION->AddHeadString("<script type=\"text/javascript\">app.bindloadPageBlank();</script>", false, false); } $APPLICATION->AddHeadString(Mobile::getInstance()->getViewPort()); }
/** * Downloads and saves a file. * * @param string $url URI to download * @param string $filePath Absolute file path * @return bool */ public function download($url, $filePath) { $dir = IO\Path::getDirectory($filePath); IO\Directory::createDirectory($dir); $file = new IO\File($filePath); $handler = $file->open("w+"); if ($handler !== false) { $this->setOutputStream($handler); $res = $this->query(self::HTTP_GET, $url); fclose($handler); return $res; } return false; }
<?php /** Bitrix Framework * Bitrix vars * @global CUser $USER * @global CMain $APPLICATION */ use Bitrix\Main\IO\File; require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_before.php"; if ($USER->IsAdmin()) { $server = isset($_REQUEST['SERVER']) ? trim($_REQUEST['SERVER']) : false; $param = isset($_REQUEST['PARAM']) ? trim($_REQUEST['PARAM']) : false; $period = isset($_REQUEST['PERIOD']) ? trim($_REQUEST['PERIOD']) : false; if ($server && $period && $param) { $pathToImages = "/var/lib/munin"; $path = $pathToImages . '/' . $server . '/' . $server . '/' . $param . '-' . $period . '.png'; $f = new File($path); if ($f->isExists()) { header("Content-type: image/png"); echo $f->getContents(); } } } die;
$bCanEdit = false; } //need fm_lpa for every .php file, even with no php code inside if ($bCanEdit && !$USER->CanDoOperation('edit_php') && in_array(GetFileExtension($currentFilePath), GetScriptFileExt()) && !$USER->CanDoFileOperation('fm_lpa', array(SITE_ID, $currentFilePath))) { $bCanEdit = false; } if ($bCanEdit && IsModuleInstalled("fileman") && !($USER->CanDoOperation("fileman_admin_files") && $USER->CanDoOperation("fileman_edit_existent_files"))) { $bCanEdit = false; } if ($bCanEdit) { echo $APPLICATION->IncludeStringBefore(); $BX_GLOBAL_AREA_EDIT_ICON = true; } } } define("START_EXEC_PROLOG_AFTER_2", microtime()); $GLOBALS["BX_STATE"] = "WA"; $APPLICATION->RestartWorkarea(true); //magically replacing the current file with another one $event = new Main\Event("main", "OnFileRewrite", array("path" => Main\Context::getCurrent()->getRequest()->getScriptFile())); $event->send(); foreach ($event->getResults() as $evenResult) { if (($result = $evenResult->getParameters()) != '') { $file = new Main\IO\File($_SERVER["DOCUMENT_ROOT"] . $result); if ($file->isExists()) { //only the first result matters include $file->getPhysicalPath(); die; } } }
private function appendContentNonCloud($fileContent, $startRange, $endRange, $fileSize) { $file = new IO\File($this->getAbsolutePath()); if (!$file->isExists()) { $this->errorCollection->addOne(new Error('Could not find file', static::ERROR_EXISTS_FILE)); return false; } if ($file->putContents($fileContent, $file::APPEND) === false) { $this->errorCollection->addOne(new Error('Could not put contents to file', static::ERROR_PUT_CONTENTS)); return false; } return true; }
private function transferUri($url) { $url = IO\Path::normalize($url); $urlTmp = trim($url, " \t\n\r\v\\/"); if (empty($urlTmp)) { throw new ArgumentNullException("url"); } $ext = IO\Path::getExtension($url); if (strtolower($ext) != "php") { throw new SystemException("Only php files are allowable for url rewriting"); } $arUrl = explode("/", $url); $rootDirName = ""; while (!empty($arUrl) && ($rootDirName = array_shift($arUrl)) === "") { } $rootDirName = strtolower(str_replace(".", "", $rootDirName)); if (in_array($rootDirName, array("bitrix", "local", "upload"))) { throw new SystemException(sprintf("Can not use path '%s' for url rewriting", $url)); } if (!IO\Path::validate($url)) { throw new SystemException(sprintf("Path '%s' is not valid", $url)); } $absUrl = IO\Path::convertRelativeToAbsolute($url); if (!IO\File::isFileExists($absUrl)) { throw new SystemException(sprintf("Path '%s' is not found", $url)); } $absUrlPhysical = IO\Path::convertLogicalToPhysical($absUrl); global $APPLICATION, $USER, $DB; include_once $absUrlPhysical; die; }
/** * Sets license key Bitrix CMS. * * @param InputInterface $input * @param OutputInterface $output * @param string $licenseKey */ protected function configureLicenseKey(InputInterface $input, OutputInterface $output, $licenseKey) { if (!is_string($licenseKey)) { throw new \InvalidArgumentException('Config "licenseKey" must be string type.'); } $licenseFileContent = "<" . "? \$" . "LICENSE_KEY = \"" . EscapePHPString($licenseKey) . "\"; ?" . ">"; File::putFileContents(Application::getDocumentRoot() . BX_ROOT . '/license_key.php', $licenseFileContent); }
</select> <input type="hidden" value="<?php echo $paySystem['ACTION_FILE']; ?> " name="PRIOR_ACTION_FILE"> </td> </tr> <tbody id="pay_system_ps_mode"> <?php $psMode = $request->get('PS_MODE') ? $request->get('PS_MODE') : $paySystem['PS_MODE']; /** @var PaySystem\BaseServiceHandler $className */ $className = PaySystem\Manager::getClassNameFromPath($handlerName); if (!class_exists($className)) { $path = PaySystem\Manager::getPathToHandlerFolder($handler); $fullPath = $documentRoot . $path . '/handler.php'; if ($path && \Bitrix\Main\IO\File::isFileExists($fullPath)) { require_once $fullPath; } } $handlerModeList = array(); if (class_exists($className)) { $handlerModeList = $className::getHandlerModeList(); } if ($handlerModeList) { ?> <tr> <td width="40%" valign="top"><?php echo Loc::getMessage("F_PS_MODE"); ?> :</td> <td width="60%" valign="top">
public function __construct($siteId) { $this->siteId = $siteId; $this->documentRoot = SiteTable::getDocumentRoot($this->siteId); parent::__construct(IO\Path::combine($this->documentRoot, self::ROBOTS_FILE_NAME)); }
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; }
/** * Binds (and creates if it's necessary) template to the application folder * * @param $templateId - symbolic code of the template * @param $folder - the application folder * @param bool $createNew - flag of the necessity of creating a new template */ public static function bindTemplate($templateId, $folder, $createNew) { $arFields = array("TEMPLATE" => array()); if ($createNew) { CopyDirFiles(Application::getDocumentRoot() . "/bitrix/modules/mobileapp/templates/default_app/", Application::getDocumentRoot() . "/bitrix/templates/" . $templateId, True, True); File::putFileContents(Application::getDocumentRoot() . "/bitrix/templates/" . $templateId . "/description.php", str_replace(array("#mobile_template_name#"), array($templateId), File::getFileContents(Application::getDocumentRoot() . "/bitrix/templates/" . $templateId . "/description.php"))); $arFields["TEMPLATE"][] = array("SORT" => 1, "CONDITION" => "CSite::InDir('/" . $folder . "/')", "TEMPLATE" => $templateId); } $default_site_id = \CSite::GetDefSite(); if ($default_site_id) { $dbTemplates = \CSite::GetTemplateList($default_site_id); $arFields["LID"] = $default_site_id; $isTemplateFound = false; while ($template = $dbTemplates->Fetch()) { $arFields["TEMPLATE"][] = array("TEMPLATE" => $template['TEMPLATE'], "SORT" => $template['SORT'], "CONDITION" => $template['CONDITION']); if ($template["TEMPLATE"] == $templateId && !$createNew && !$isTemplateFound) { $isTemplateFound = true; $arFields["TEMPLATE"][] = array("SORT" => 1, "CONDITION" => "CSite::InDir('/" . $folder . "/')", "TEMPLATE" => $templateId); } } $obSite = new \CSite(); $obSite->Update($default_site_id, $arFields); } }
/** * Repacks exported document from Google.Drive, which has wrong order files in archive to show preview * in Google.Viewer. In Google.Viewer document should have file '[Content_Types].xml' on first position in archive. * @param FileData $fileData * @return FileData * @throws IO\FileNotFoundException * @throws IO\InvalidPathException * @internal */ public function repackDocument(FileData $fileData) { if (!extension_loaded('zip')) { return null; } if (!TypeFile::isDocument($fileData->getName())) { return null; } $file = new IO\File($fileData->getSrc()); if (!$file->isExists() || $file->getSize() > 15 * 1024 * 1024) { return null; } unset($file); $ds = DIRECTORY_SEPARATOR; $targetDir = \CTempFile::getDirectoryName(2, 'disk_repack' . $ds . md5(uniqid('di', true))); checkDirPath($targetDir); $targetDir = IO\Path::normalize($targetDir) . $ds; $zipOrigin = new \ZipArchive(); if (!$zipOrigin->open($fileData->getSrc())) { return null; } if ($zipOrigin->getNameIndex(0) === '[Content_Types].xml') { $zipOrigin->close(); return null; } if (!$zipOrigin->extractTo($targetDir)) { $zipOrigin->close(); return null; } $zipOrigin->close(); unset($zipOrigin); if (is_dir($targetDir) !== true) { return null; } $newName = md5(uniqid('di', true)); $newFilepath = $targetDir . '..' . $ds . $newName; $repackedZip = new \ZipArchive(); if (!$repackedZip->open($newFilepath, \ZipArchive::CREATE)) { return null; } $source = realpath($targetDir); $repackedZip->addFile($source . $ds . '[Content_Types].xml', '[Content_Types].xml'); $files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST); foreach ($files as $file) { if ($file->getBasename() === '[Content_Types].xml') { continue; } $file = str_replace('\\', '/', $file); $file = realpath($file); if (is_dir($file) === true) { $repackedZip->addEmptyDir(str_replace('\\', '/', str_replace($source . $ds, '', $file . $ds))); } elseif (is_file($file) === true) { $repackedZip->addFile($file, str_replace('\\', '/', str_replace($source . $ds, '', $file))); } } $repackedZip->close(); $newFileData = new FileData(); $newFileData->setSrc($newFilepath); return $newFileData; }
/** * @param $templateName * @param $html * @return bool|int */ public static function update($templateName, $html) { $result = false; $fullPathOfFile = \Bitrix\Main\Loader::getLocal(static::LOCAL_DIR_TMPL . bx_basename($templateName) . '.php'); if ($fullPathOfFile) { $result = File::putFileContents($fullPathOfFile, $html); } return $result; }
private function sendToEventHandler(array $handler, Event $event) { try { $result = true; $event->addDebugInfo($handler); if (isset($handler["TO_MODULE_ID"]) && !empty($handler["TO_MODULE_ID"]) && $handler["TO_MODULE_ID"] != 'main') { $result = Loader::includeModule($handler["TO_MODULE_ID"]); } elseif (isset($handler["TO_PATH"]) && !empty($handler["TO_PATH"])) { $path = ltrim($handler["TO_PATH"], "/"); if (($path = Loader::getLocal($path)) !== false) { $result = (include_once $path); } } elseif (isset($handler["FULL_PATH"]) && !empty($handler["FULL_PATH"]) && IO\File::isFileExists($handler["FULL_PATH"])) { $result = (include_once $handler["FULL_PATH"]); } $event->addDebugInfo($result); if (isset($handler["TO_METHOD_ARG"]) && is_array($handler["TO_METHOD_ARG"]) && !empty($handler["TO_METHOD_ARG"])) { $args = $handler["TO_METHOD_ARG"]; } else { $args = array(); } if ($handler["VERSION"] > 1) { $args[] = $event; } else { $args = array_merge($args, array_values($event->getParameters())); } $callback = null; if (isset($handler["CALLBACK"])) { $callback = $handler["CALLBACK"]; } elseif (!empty($handler["TO_CLASS"]) && !empty($handler["TO_METHOD"]) && class_exists($handler["TO_CLASS"])) { $callback = array($handler["TO_CLASS"], $handler["TO_METHOD"]); } if ($callback != null) { $result = call_user_func_array($callback, $args); } if ($result != null && !$result instanceof EventResult) { $result = new EventResult(EventResult::UNDEFINED, $result, $handler["TO_MODULE_ID"]); } $event->addDebugInfo($result); if ($result != null) { $event->addResult($result); } } catch (\Exception $ex) { if ($event->isDebugOn()) { $event->addException($ex); } else { throw $ex; } } }
public function clearLogFile() { $logDir = $this->getLogFileDir(); if (!Main\IO\Directory::isDirectoryExists($logDir)) { Main\IO\Directory::createDirectory($logDir); } $logFile = $this->getLogFilePath(); Main\IO\File::putFileContents($logFile, ''); }
/** * Returns file relative path for URL. * * @param File $f File object. * * @return string */ protected function getFileUrl(File $f) { static $indexNames; if(!is_array($indexNames)) { $indexNames = GetDirIndexArray(); } $path = '/'; if (substr($this->path, 0, strlen($this->documentRoot)) === $this->documentRoot) { $path = '/'.substr($f->getPath(), strlen($this->documentRoot)); } $path = Path::convertLogicalToUri($path); $path = in_array($f->getName(), $indexNames) ? str_replace('/'.$f->getName(), '/', $path) : $path; return '/'.ltrim($path, '/'); }
private static function loadTriggers($moduleId) { static $triggersCache = array(); if (isset($triggersCache[$moduleId])) { return; } if (!IO\Path::validateFilename($moduleId)) { throw new Main\ArgumentOutOfRangeException("moduleId"); } $triggersCache[$moduleId] = true; $path = IO\Path::convertRelativeToAbsolute("/bitrix/modules/" . $moduleId . "/option_triggers.php"); if (!IO\File::isFileExists($path)) { return; } include IO\Path::convertLogicalToPhysical($path); }