예제 #1
1
 public static function onBeforeHTMLEditorScriptRuns()
 {
     $asset = Asset::getInstance();
     $asset->addJs('/bitrix/js/newkaliningrad.typografru/typograf.js');
     $messages = Loc::loadLanguageFile(Path::normalize(__FILE__));
     $asset->addString(sprintf('<script>BX.message(%s)</script>', Json::encode($messages, JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE)));
 }
예제 #2
0
 function acrit_exportpro()
 {
     require __DIR__ . '/version.php';
     $path = str_replace("\\", "/", __FILE__);
     $path = substr($path, 0, strlen($path) - strlen("/index.php"));
     include $path . "/version.php";
     if (is_array($arModuleVersion) && array_key_exists("VERSION", $arModuleVersion)) {
         $this->MODULE_VERSION = $arModuleVersion["VERSION"];
         $this->MODULE_VERSION_DATE = $arModuleVersion["VERSION_DATE"];
     }
     $this->MODULE_NAME = GetMessage('ACRIT_EXPORTPRO_MODULE_NAME');
     $this->MODULE_DESCRIPTION = GetMessage('ACRIT_EXPORTPRO_MODULE_DESC');
     $this->PARTNER_NAME = GetMessage("ACRIT_EXPORTPRO_PARTNER_NAME");
     $this->PARTNER_URI = GetMessage("ACRIT_EXPORTPRO_PARTNER_URI");
     $app = \Bitrix\Main\Application::getInstance();
     $dbSite = \Bitrix\Main\SiteTable::getList();
     while ($arSite = $dbSite->Fetch()) {
         if (!$arSite['DOC_ROOT']) {
             $this->siteArray[$arSite['LID']] = $app->getDocumentRoot() . $arSite['DIR'];
         } else {
             $this->siteArray[$arSite['LID']] = $arSite['DOC_ROOT'];
         }
         $this->siteArray[$arSite['LID']] = \Bitrix\Main\IO\Path::normalize($this->siteArray[$arSite['LID']]);
     }
 }
예제 #3
0
 public function getRequestedPage()
 {
     if ($this->requestedFile != null) {
         return $this->requestedFile;
     }
     $page = $this->getScriptName();
     $page = IO\Path::normalize($page);
     if (IO\Path::validate($page)) {
         return $this->requestedFile = $page;
     }
     throw new SystemException("Script name is not valid");
 }
예제 #4
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();
 }
예제 #5
0
 /**
  * Loads language messages for specified file
  *
  * @param string $file
  * @param string $language
  * @return array
  */
 public static function loadLanguageFile($file, $language = null)
 {
     if ($language === null) {
         $language = \Bitrix\Main\Context::getCurrent()->getLanguage();
     }
     if (!isset(self::$messages[$language])) {
         self::$messages[$language] = array();
     }
     //first time call only for lang
     if (self::$customMessages === null) {
         self::$customMessages = self::loadCustomMessages($language);
     }
     $file = Path::normalize($file);
     static $dirCache = array();
     //let's find language folder
     $langDir = $fileName = "";
     $filePath = $file;
     while (($slashPos = strrpos($filePath, "/")) !== false) {
         $filePath = substr($filePath, 0, $slashPos);
         if (!isset($dirCache[$filePath])) {
             $dirCache[$filePath] = $isDir = is_dir($filePath . "/lang");
         } else {
             $isDir = $dirCache[$filePath];
         }
         if ($isDir) {
             $langDir = $filePath . "/lang";
             $fileName = substr($file, $slashPos);
             break;
         }
     }
     $mess = array();
     if ($langDir != "") {
         //load messages for default lang first
         $defaultLang = self::getDefaultLang($language);
         if ($defaultLang != $language) {
             $langFile = $langDir . "/" . $defaultLang . $fileName;
             if (file_exists($langFile)) {
                 $mess = self::includeFile($langFile);
             }
         }
         //then load messages for specified lang
         $langFile = $langDir . "/" . $language . $fileName;
         if (file_exists($langFile)) {
             $mess = array_merge($mess, self::includeFile($langFile));
         }
         foreach ($mess as $key => $val) {
             self::$messages[$language][$key] = $val;
         }
     }
     return $mess;
 }
예제 #6
0
 public function getRequestedPage()
 {
     if ($this->requestedPage === null) {
         $page = $this->getScriptName();
         if (!empty($page)) {
             $page = IO\Path::normalize($page);
             if (substr($page, 0, 1) !== "/" && !preg_match("#^[a-z]:[/\\\\]#i", $page)) {
                 $page = "/" . $page;
             }
         }
         $this->requestedPage = $page;
     }
     return $this->requestedPage;
 }
예제 #7
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;
 }
예제 #8
0
파일: uri.php 프로젝트: ASDAFF/bxApiDocs
 public function convertToPath()
 {
     if ($this->uriType != UriType::RELATIVE) {
         $path = $this->parse(UriPart::PATH);
     } else {
         $path = $this->uri;
         $p = strpos($path, "?");
         if ($p !== false) {
             $path = substr($path, 0, $p);
         }
     }
     if (substr($path, -1, 1) === "/") {
         $path = self::addDirectoryIndex($path);
     }
     $path = IO\Path::normalize($path);
     return $path;
 }
예제 #9
0
 public function convertToPath()
 {
     if ($this->uriType != UriType::RELATIVE) {
         $path = $this->parse(UriPart::PATH);
     } else {
         $path = $this->uri;
         $p = strpos($path, "?");
         if ($p !== false) {
             $path = substr($path, 0, $p);
         }
     }
     if (substr($path, -1, 1) === "/") {
         $path = self::addDirectoryIndex($path);
     }
     $path = IO\Path::normalize($path);
     if (IO\Path::validate($path)) {
         return $path;
     }
     throw new \Bitrix\Main\SystemException("Uri is not valid");
 }
예제 #10
0
 /**
  * Gets lang messages
  * @return array
  */
 public function getLangMessages()
 {
     return Loc::loadLanguageFile(Path::normalize(__FILE__));
 }
예제 #11
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;
 }
예제 #12
0
 protected static function normalize($path)
 {
     if (substr($path, -1, 1) === "/") {
         $path .= "index.php";
     }
     $path = IO\Path::normalize($path);
     return $path;
 }
예제 #13
0
 /**
  * Repacks exported document from Google.Drive, which has wrong order files in archive to show preview
  * in Google.Viewer. In Google.Viewer document should have file '[Content_Types].xml' on first position in archive.
  * @param FileData $fileData
  * @return FileData
  * @throws IO\FileNotFoundException
  * @throws IO\InvalidPathException
  * @internal
  */
 public function repackDocument(FileData $fileData)
 {
     if (!extension_loaded('zip')) {
         return null;
     }
     if (!TypeFile::isDocument($fileData->getName())) {
         return null;
     }
     $file = new IO\File($fileData->getSrc());
     if (!$file->isExists() || $file->getSize() > 15 * 1024 * 1024) {
         return null;
     }
     unset($file);
     $ds = DIRECTORY_SEPARATOR;
     $targetDir = \CTempFile::getDirectoryName(2, 'disk_repack' . $ds . md5(uniqid('di', true)));
     checkDirPath($targetDir);
     $targetDir = IO\Path::normalize($targetDir) . $ds;
     $zipOrigin = new \ZipArchive();
     if (!$zipOrigin->open($fileData->getSrc())) {
         return null;
     }
     if ($zipOrigin->getNameIndex(0) === '[Content_Types].xml') {
         $zipOrigin->close();
         return null;
     }
     if (!$zipOrigin->extractTo($targetDir)) {
         $zipOrigin->close();
         return null;
     }
     $zipOrigin->close();
     unset($zipOrigin);
     if (is_dir($targetDir) !== true) {
         return null;
     }
     $newName = md5(uniqid('di', true));
     $newFilepath = $targetDir . '..' . $ds . $newName;
     $repackedZip = new \ZipArchive();
     if (!$repackedZip->open($newFilepath, \ZipArchive::CREATE)) {
         return null;
     }
     $source = realpath($targetDir);
     $repackedZip->addFile($source . $ds . '[Content_Types].xml', '[Content_Types].xml');
     $files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST);
     foreach ($files as $file) {
         if ($file->getBasename() === '[Content_Types].xml') {
             continue;
         }
         $file = str_replace('\\', '/', $file);
         $file = realpath($file);
         if (is_dir($file) === true) {
             $repackedZip->addEmptyDir(str_replace('\\', '/', str_replace($source . $ds, '', $file . $ds)));
         } elseif (is_file($file) === true) {
             $repackedZip->addFile($file, str_replace('\\', '/', str_replace($source . $ds, '', $file)));
         }
     }
     $repackedZip->close();
     $newFileData = new FileData();
     $newFileData->setSrc($newFilepath);
     return $newFileData;
 }
예제 #14
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;
 }
예제 #15
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;
 }
예제 #16
0
파일: loc.php 프로젝트: spas-viktor/books
 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("BX_MESS_LOG") && $currentFile !== null) {
                         file_put_contents(BX_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]);
         }
     }
 }