예제 #1
0
 /**
  * Deletes the file
  * with predefined path (current request uri)
  *
  * @return void
  */
 public function delete()
 {
     if ($this->cacheFile && $this->cacheFile->isExists()) {
         $cacheDirectory = $this->cacheFile->getDirectory();
         $fileSize = $this->cacheFile->getFileSize();
         if (defined("FX_COMPOSITE_DEBUG")) {
             $backupName = $this->cacheFile->getPath() . ".delete." . microtime(true);
             if ($this->checkQuota()) {
                 AddMessage2Log($backupName, "composite");
                 $backupFile = new Main\IO\File($backupName);
                 $backupFile->putContents($this->cacheFile->getContents());
                 $this->writeStatistic(0, 0, 0, 0, $fileSize);
             } else {
                 AddMessage2Log($backupName . "(quota exceeded)", "composite");
             }
         }
         $this->cacheFile->delete();
         //Try to cleanup directory
         $children = $cacheDirectory->getChildren();
         if (empty($children)) {
             $cacheDirectory->delete();
         }
         //Update total files size
         $this->writeStatistic(0, 0, 0, 0, -$fileSize);
     }
 }
예제 #2
0
 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++) {
         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' => $arComponents[$i]["DATA"]["PARAMS"]["SEF_MODE"] == "Y" ? Component\ParametersTable::SEF_MODE : Component\ParametersTable::NOT_SEF_MODE, 'SEF_FOLDER' => $arComponents[$i]["DATA"]["PARAMS"]["SEF_MODE"] == "Y" ? $arComponents[$i]["DATA"]["PARAMS"]["SEF_FOLDER"] : null, 'START_CHAR' => $arComponents[$i]["START"], 'END_CHAR' => $arComponents[$i]["END"], 'PARAMETERS' => serialize($arComponents[$i]["DATA"]["PARAMS"])));
         if ($arComponents[$i]["DATA"]["PARAMS"]["SEF_MODE"] == "Y") {
             $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;
 }