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(); }
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, ''); }
/** * 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); } }
/** * @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; }
/** * 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); }
/** * Writes query text and part of backtrace into log file. * * @param string $sql Query to be dumped. * @param float $executionTime Query time. * @param string $additional Additional info string to be added to header. * @param integer $traceSkip How many backtrace frames to skip in output. * * @return void * @see \Bitrix\Main\Diag\SqlTracker->startFileLog * @see \Bitrix\Main\Diag\SqlTracker->stopFileLog */ public function writeFileLog($sql, $executionTime = 0.0, $additional = "", $traceSkip = 2) { if ($this->logFilePath) { $header = "TIME: " . round($executionTime, 6) . " SESSION: " . session_id() . " " . $additional . "\n"; $headerLength = strlen($header); $body = $this->formatSql($sql); $trace = $this->formatTrace(\Bitrix\Main\Diag\Helper::getBackTrace($this->depthBackTrace, null, $traceSkip)); $footer = str_repeat("-", $headerLength); $message = "\n" . $header . "\n" . $body . "\n\n" . $trace . "\n" . $footer . "\n"; \Bitrix\Main\IO\File::putFileContents($this->logFilePath, $message, \Bitrix\Main\IO\File::APPEND); } }