/** * @return array | null */ private function _getSavedData() { if (!$this->_file->isExists()) { return array(); } return \WS\Migrations\jsonToArray($this->_file->getContents()); }
/** * Returns array with cache statistics data. * Returns an empty array in case of disabled html cache. * * @return array */ public function readStatistic() { $result = array(); if ($this->statFile && $this->statFile->isExists()) { $fileValues = explode(",", $this->statFile->getContents()); $result = array("HITS" => intval($fileValues[0]), "MISSES" => intval($fileValues[1]), "QUOTA" => intval($fileValues[2]), "POSTS" => intval($fileValues[3]), "FILE_SIZE" => doubleval($fileValues[4])); } return $result; }
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; }
<?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;
/** * @param string $path This variable is the path to the file for the installation process. * @param null $siteId This variable is the id current site. * @throws Main\ArgumentNullException * @throws Main\IO\FileNotFoundException */ public static function installProcess($path, $siteId = null) { if (empty($path)) { throw new Main\ArgumentNullException("path"); } if (!Main\Loader::includeModule("bizproc")) { return; } $path = Main\Loader::getDocumentRoot() . $path; $iblockType = static::getIBlockType(); $db = \CIBlockType::GetList(array(), array("=ID" => $iblockType)); $res = $db->Fetch(); if (!$res) { static::createIBlockType(); } $file = new Main\IO\File($path); if ($file->isExists() && $file->getExtension() == "prc") { static::import($iblockType, $file->getContents(), $siteId); } }