Beispiel #1
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();
 }
Beispiel #2
0
 public function __construct($fileName, $arSettings)
 {
     $this->settings = array('SITE_ID' => $arSettings['SITE_ID'], 'PROTOCOL' => $arSettings['PROTOCOL'] == 'https' ? 'https' : 'http', 'DOMAIN' => $arSettings['DOMAIN']);
     $arSite = SiteTable::getRow(array("filter" => array("LID" => $this->settings['SITE_ID'])));
     $this->siteRoot = Path::combine(SiteTable::getDocumentRoot($this->settings['SITE_ID']), $arSite['DIR']);
     if (substr($fileName, -strlen(self::FILE_EXT)) != self::FILE_EXT) {
         $fileName .= self::FILE_EXT;
     }
     if ($this->partFile == '') {
         $this->partFile = $fileName;
     }
     $this->pathPhysical = null;
     // hack for object reconstuct during file splitting
     parent::__construct($this->siteRoot . '/' . $fileName, $this->settings['SITE_ID']);
     $this->partChanged = $this->isExists();
 }
Beispiel #3
0
 public static function getDocumentRoot($siteId = null)
 {
     if ($siteId === null) {
         $context = Application::getInstance()->getContext();
         $siteId = $context->getSite();
     }
     if (!isset(self::$documentRootCache[$siteId])) {
         $ar = SiteTable::getRow(array("filter" => array("LID" => $siteId)));
         if ($ar && ($docRoot = $ar["DOC_ROOT"]) && strlen($docRoot) > 0) {
             if (!IO\Path::isAbsolute($docRoot)) {
                 $docRoot = IO\Path::combine(Application::getDocumentRoot(), $docRoot);
             }
             self::$documentRootCache[$siteId] = $docRoot;
         } else {
             self::$documentRootCache[$siteId] = Application::getDocumentRoot();
         }
     }
     return self::$documentRootCache[$siteId];
 }