示例#1
0
 public function rename($newPath)
 {
     $newPathNormalized = Path::normalize($newPath);
     $success = true;
     if ($this->isExists()) {
         $success = rename($this->getPhysicalPath(), Path::convertLogicalToPhysical($newPathNormalized));
     }
     if ($success) {
         $this->originalPath = $newPath;
         $this->path = $newPathNormalized;
         $this->pathPhysical = null;
     }
     return $success;
 }
示例#2
0
 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;
 }
示例#3
0
 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);
 }
示例#4
0
 public function read(&$arAllVars, $baseDir, $initDir, $filename, $TTL)
 {
     $documentRoot = \Bitrix\Main\Application::getDocumentRoot();
     $fn = IO\Path::combine($documentRoot, $baseDir, $initDir, $filename);
     $file = new IO\File($fn);
     if (!$file->isExists()) {
         return false;
     }
     $ser_content = "";
     $dateexpire = 0;
     $datecreate = 0;
     $zeroDanger = false;
     $handle = null;
     if (is_array($arAllVars)) {
         $INCLUDE_FROM_CACHE = 'Y';
         if (!(include IO\Path::convertLogicalToPhysical($fn))) {
             return false;
         }
         if ($zeroDanger) {
             $ser_content = str_replace("", "*", $ser_content);
         }
     } else {
         if (!$file instanceof IO\IFileStream) {
             return false;
         }
         $handle = $file->open("r");
         if (!$handle) {
             return false;
         }
         $datecreate = fread($handle, 2);
         if ($datecreate == "BX") {
             $datecreate = fread($handle, 12);
             $dateexpire = fread($handle, 12);
         } else {
             $datecreate .= fread($handle, 10);
         }
     }
     /* We suppress warning here in order not to break
     		the compression under Zend Server */
     $this->read = $file->getFileSize();
     if (intval($datecreate) < mktime() - $TTL) {
         return false;
     }
     if (is_array($arAllVars)) {
         $arAllVars = unserialize($ser_content);
     } else {
         $arAllVars = fread($handle, $this->read);
         fclose($handle);
     }
     return true;
 }