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 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;
 }
Beispiel #3
0
 public function getRequestedPage()
 {
     if ($this->requestedFile !== null) {
         return $this->requestedFile;
     }
     $page = $this->getScriptName();
     if (empty($page)) {
         return $this->requestedFile = $page;
     }
     $page = IO\Path::normalize($page);
     if (substr($page, 0, 1) !== "/" && !preg_match("#^[a-z]:[/\\\\]#i", $page)) {
         $page = "/" . $page;
     }
     return $this->requestedFile = $page;
 }
Beispiel #4
0
 /**
  * Converts request uri into path safe file with .html extention.
  * Returns empty string if fails.
  *
  * @param string $Uri
  * @return string
  */
 public static function convertUriToPath($Uri, $host = "")
 {
     $match = array();
     if (preg_match("#^(/.+?)\\.php\\?([^\\\\/]*)#", $Uri, $match) > 0) {
         $PageFile = $match[1] . "@" . $match[2];
     } elseif (preg_match("#^(/.+)\\.php\$#", $Uri, $match) > 0) {
         $PageFile = $match[1] . "@";
     } elseif (preg_match("#^(/.+?|)/\\?([^\\\\/]*)#", $Uri, $match) > 0) {
         $PageFile = $match[1] . "/index@" . $match[2];
     } elseif (preg_match("#^(/.+|)/\$#", $Uri, $match) > 0) {
         $PageFile = $match[1] . "/index@";
     } else {
         return "";
     }
     if (strlen($host) > 0) {
         $host = "/" . $host;
         $host = preg_replace("/:(\\d+)\$/", "-\\1", $host);
     }
     $PageFile = $host . str_replace(".", "_", $PageFile) . ".html";
     if (!Main\IO\Path::validate($PageFile)) {
         return "";
     }
     if (Main\IO\Path::normalize($PageFile) !== $PageFile) {
         return "";
     }
     return $PageFile;
 }
Beispiel #5
0
 private static function loadLazy($code, $language)
 {
     if ($code == '') {
         return;
     }
     $trace = Main\Diag\Helper::getBackTrace(4, DEBUG_BACKTRACE_IGNORE_ARGS);
     $currentFile = null;
     for ($i = 3; $i >= 1; $i--) {
         if (stripos($trace[$i]["function"], "GetMessage") === 0) {
             $currentFile = Path::normalize($trace[$i]["file"]);
             break;
         }
     }
     if ($currentFile !== null && isset(self::$lazyLoadFiles[$currentFile])) {
         //in most cases we know the file containing the "code" - load it directly
         self::loadLanguageFile($currentFile, $language);
         unset(self::$lazyLoadFiles[$currentFile]);
     }
     if (!isset(self::$messages[$language][$code])) {
         //we still don't know which file contains the "code" - go through the files in the reverse order
         $unset = array();
         if (($file = end(self::$lazyLoadFiles)) !== false) {
             do {
                 self::loadLanguageFile($file, $language);
                 $unset[] = $file;
                 if (isset(self::$messages[$language][$code])) {
                     if (defined("FX_MESS_LOG") && $currentFile !== null) {
                         file_put_contents(FX_MESS_LOG, 'CTranslateUtils::CopyMessage("' . $code . '", "' . $file . '", "' . $currentFile . '");' . "\n", FILE_APPEND);
                     }
                     break;
                 }
             } while (($file = prev(self::$lazyLoadFiles)) !== false);
         }
         foreach ($unset as $file) {
             unset(self::$lazyLoadFiles[$file]);
         }
     }
 }
Beispiel #6
0
 protected function convertToPath($path)
 {
     $p = strpos($path, "?");
     if ($p !== false) {
         $path = substr($path, 0, $p);
     }
     if (substr($path, -1, 1) === "/") {
         $path .= "index.php";
     }
     $path = IO\Path::normalize($path);
     return $path;
 }