コード例 #1
0
ファイル: file.php プロジェクト: andy-profi/bxApiDocs
 /**
  * <p>Метод удаляет файл из таблицы зарегистрированных файлов (b_file) и с диска. Статичный метод.</p>
  *
  *
  * @param int $id  Цифровой идентификатор файла.
  *
  * @return mixed 
  *
  * <h4>Example</h4> 
  * <pre>
  * &lt;?
  * // удаляем изображение формы
  * $arFilter = array("ID" =&gt; 1, "ID_EXACT_MATCH" =&gt; "Y");
  * $rsForm = CForm::GetList($by, $order, $arFilter, $is_filtered);
  * if ($arForm = $rsForm-&gt;Fetch())
  * {
  *     if (intval($arForm["IMAGE_ID"])&gt;0) <b>CFile::Delete</b>($arForm["IMAGE_ID"]);	
  * }
  * ?&gt;
  * </pre>
  *
  *
  * <h4>See Also</h4> 
  * <ul> <li> <a href="http://dev.1c-bitrix.ru/api_help/main/functions/file/deletedirfiles.php">DeleteDirFiles</a> </li>
  * <li> <a href="http://dev.1c-bitrix.ru/api_help/main/functions/file/deletedirfilesex.php">DeleteDirFilesEx</a> </li>
  * </ul><a name="examples"></a>
  *
  *
  * @static
  * @link http://dev.1c-bitrix.ru/api_help/main/reference/cfile/delete.php
  * @author Bitrix
  */
 public static function Delete($ID)
 {
     global $DB;
     $io = CBXVirtualIo::GetInstance();
     $ID = intval($ID);
     if ($ID <= 0) {
         return;
     }
     $res = CFile::GetByID($ID);
     if ($res = $res->Fetch()) {
         $delete_size = 0;
         $upload_dir = COption::GetOptionString("main", "upload_dir", "upload");
         $dname = $_SERVER["DOCUMENT_ROOT"] . "/" . $upload_dir . "/" . $res["SUBDIR"];
         $fname = $dname . "/" . $res["FILE_NAME"];
         $file = $io->GetFile($fname);
         if ($file->isExists() && $file->unlink()) {
             $delete_size += $res["FILE_SIZE"];
         }
         $delete_size += CFile::ResizeImageDelete($res);
         $DB->Query("DELETE FROM b_file WHERE ID = " . $ID);
         $directory = $io->GetDirectory($dname);
         if ($directory->isExists() && $directory->isEmpty()) {
             $directory->rmdir();
         }
         CFile::CleanCache($ID);
         foreach (GetModuleEvents("main", "OnFileDelete", true) as $arEvent) {
             ExecuteModuleEventEx($arEvent, array($res));
         }
         /****************************** QUOTA ******************************/
         if ($delete_size > 0 && COption::GetOptionInt("main", "disk_space") > 0) {
             CDiskQuota::updateDiskQuota("file", $delete_size, "delete");
         }
         /****************************** QUOTA ******************************/
     }
 }
コード例 #2
0
function BXCreateSection(&$fileContent, &$sectionFileContent, &$absoluteFilePath, &$sectionPath)
{
    //Check quota
    $quota = new CDiskQuota();
    if (!$quota->CheckDiskQuota(array("FILE_SIZE" => strlen($fileContent) + strlen($sectionFileContent)))) {
        $GLOBALS["APPLICATION"]->ThrowException($quota->LAST_ERROR, "BAD_QUOTA");
        return false;
    }
    $io = CBXVirtualIo::GetInstance();
    //Create dir
    if (!$io->CreateDirectory($absoluteFilePath)) {
        $GLOBALS["APPLICATION"]->ThrowException(GetMessage("PAGE_NEW_FOLDER_CREATE_ERROR") . "<br /> (" . htmlspecialcharsbx($absoluteFilePath) . ")", "DIR_NOT_CREATE");
        return false;
    }
    //Create .section.php
    $f = $io->GetFile($absoluteFilePath . "/.section.php");
    if (!$GLOBALS["APPLICATION"]->SaveFileContent($absoluteFilePath . "/.section.php", $sectionFileContent)) {
        return false;
    }
    //Create index.php
    if (!$GLOBALS["APPLICATION"]->SaveFileContent($absoluteFilePath . "/index.php", $fileContent)) {
        return false;
    } else {
        if (COption::GetOptionString($module_id, "log_page", "Y") == "Y") {
            $res_log['path'] = $sectionPath . "/index.php";
            CEventLog::Log("content", "PAGE_ADD", "main", "", serialize($res_log));
        }
    }
    return true;
}
コード例 #3
0
ファイル: tar_gz.php プロジェクト: ASDAFF/open_bx
 public function __construct($strArchiveName, $bCompress = false, $start_time = -1, $max_exec_time = -1, $pos = 0, $stepped = false)
 {
     $this->io = CBXVirtualIo::GetInstance();
     $this->max_exec_time = $max_exec_time;
     $this->start_time = $start_time;
     $this->file_pos = $pos;
     $this->_bCompress = $bCompress;
     $this->stepped = $stepped;
     self::$bMbstring = extension_loaded("mbstring");
     if (!$bCompress) {
         if (@file_exists($this->io->GetPhysicalName($strArchiveName))) {
             if ($fp = @fopen($this->io->GetPhysicalName($strArchiveName), "rb")) {
                 $data = fread($fp, 2);
                 fclose($fp);
                 if ($data == "‹") {
                     $this->_bCompress = True;
                 }
             }
         } else {
             if (substr($strArchiveName, -2) == 'gz') {
                 $this->_bCompress = True;
             }
         }
     } else {
         $this->_bCompress = True;
     }
     $this->_strArchiveName = $strArchiveName;
     $this->_arErrors = array();
 }
コード例 #4
0
 function __get_folder_tree($path, $bCheckFolders = false)
 {
     static $io = false;
     if ($io === false) {
         $io = CBXVirtualIo::GetInstance();
     }
     $path = $io->CombinePath($path, '/');
     $arSection = array();
     $bCheckFolders = $bCheckFolders === true;
     $dir = $io->GetDirectory($path);
     if (!$dir->IsExists()) {
         return false;
     }
     $arChildren = $dir->GetChildren();
     foreach ($arChildren as $node) {
         if ($node->IsDirectory()) {
             if ($bCheckFolders) {
                 return true;
             }
             $filename = $node->GetName();
             if (preg_match("/^\\..*/", $filename)) {
                 continue;
             }
             $arSection[$filename] = array("NAME" => $filename, "HAS_DIR" => __get_folder_tree($node->GetPathWithName(), true));
         }
     }
     if ($bCheckFolders) {
         return false;
     }
     uasort($arSection, "__sort_array_folder");
     return $arSection;
 }
コード例 #5
0
 /**
  * Returns proxy class instance (singleton pattern)
  *
  * @static
  * @return CBXVirtualIo - Proxy class instance
  */
 public static function GetInstance()
 {
     if (!isset(self::$instance)) {
         $c = __CLASS__;
         self::$instance = new $c();
     }
     return self::$instance;
 }
コード例 #6
0
ファイル: file_temp.php プロジェクト: DarneoStudio/bitrix
 public static function GetAbsoluteRoot()
 {
     $io = CBXVirtualIo::GetInstance();
     if (defined('BX_TEMPORARY_FILES_DIRECTORY')) {
         return BX_TEMPORARY_FILES_DIRECTORY;
     } else {
         return $io->CombinePath($_SERVER["DOCUMENT_ROOT"], COption::GetOptionString("main", "upload_dir", "upload"), "tmp");
     }
 }
コード例 #7
0
ファイル: fileman_access.php プロジェクト: spas-viktor/books
function GetAccessArrTmp($path)
{
    global $DOC_ROOT;
    $io = CBXVirtualIo::GetInstance();
    if ($io->DirectoryExists($DOC_ROOT . $path)) {
        @(include $io->GetPhysicalName($DOC_ROOT . $path . "/.access.php"));
        return $PERM;
    }
    return array();
}
コード例 #8
0
ファイル: file_delete.php プロジェクト: ASDAFF/open_bx
function BXDeleteFromMenu($documentRoot, $path, $site)
{
	if (!CModule::IncludeModule("fileman"))
		return false;

	if (!$GLOBALS["USER"]->CanDoOperation("fileman_edit_menu_elements") || !$GLOBALS["USER"]->CanDoOperation("fileman_edit_existent_files"))
		return false;

	$arMenuTypes = GetMenuTypes($site);
	if (empty($arMenuTypes))
		return false;

	$currentPath = $path;
	$result = array();

	$io = CBXVirtualIo::GetInstance();

	while (true)
	{
		$currentPath = rtrim($currentPath, "/");

		if (strlen($currentPath) <= 0)
		{
			$currentPath = "/";
			$slash = "";
		}
		else
		{
			//Find parent folder
			$position = strrpos($currentPath, "/");
			if ($position === false)
				break;
			$currentPath = substr($currentPath, 0, $position);
			$slash = "/";
		}

		foreach ($arMenuTypes as $menuType => $menuDesc)
		{
			$menuFile = $currentPath.$slash.".".$menuType.".menu.php";

			if ($io->FileExists($documentRoot.$menuFile) && $GLOBALS["USER"]->CanDoFileOperation("fm_edit_existent_file", Array($site, $menuFile)))
			{
				$arFound = BXDeleteFromMenuFile($menuFile, $documentRoot, $site, $path);
				if ($arFound)
					$result[] = $arFound;
			}
		}

		if (strlen($currentPath)<=0)
			break;
	}

	return $result;
}
コード例 #9
0
 function IsCanDeletePage($currentFilePath, $documentRoot, $filemanExists)
 {
     $io = CBXVirtualIo::GetInstance();
     if (!$io->FileExists($documentRoot . $currentFilePath) || !$GLOBALS["USER"]->CanDoFileOperation("fm_delete_file", array(SITE_ID, $currentFilePath))) {
         return false;
     }
     if ($filemanExists) {
         return $GLOBALS["USER"]->CanDoOperation("fileman_admin_files");
     }
     return true;
 }
コード例 #10
0
ファイル: component.php プロジェクト: spas-viktor/books
 function findCorrectFile($path, &$strWarn, $warning = false)
 {
     $arUrl = CHTTP::ParseURL($path);
     if ($arUrl && is_array($arUrl)) {
         if (isset($arUrl['host'], $arUrl['scheme'])) {
             if (strpos($arUrl['host'], 'xn--') !== false) {
                 // Do nothing
             } else {
                 $originalPath = $path;
                 $path = $arUrl['scheme'] . '://' . $arUrl['host'];
                 $arErrors = array();
                 if (defined("BX_UTF")) {
                     $punicodedPath = CBXPunycode::ToUnicode($path, $arErrors);
                 } else {
                     $punicodedPath = CBXPunycode::ToASCII($path, $arErrors);
                 }
                 if ($pathPunicoded == $path) {
                     return $originalPath;
                 } else {
                     $path = $punicodedPath;
                 }
                 if ($arUrl['port'] && ($arUrl['scheme'] != 'http' || $arUrl['port'] != 80) && ($arUrl['scheme'] != 'https' || $arUrl['port'] != 443)) {
                     $path .= ':' . $arUrl['port'];
                 }
                 $path .= $arUrl['path_query'];
             }
         } else {
             $DOC_ROOT = $_SERVER["DOCUMENT_ROOT"];
             $path = Rel2Abs("/", $path);
             $path_ = $path;
             $io = CBXVirtualIo::GetInstance();
             if (!$io->FileExists($DOC_ROOT . $path)) {
                 if (CModule::IncludeModule('clouds')) {
                     $path = CCloudStorage::FindFileURIByURN($path, "component:player");
                     if ($path == "") {
                         if ($warning) {
                             $strWarn .= $warning . "<br />";
                         }
                         $path = $path_;
                     }
                 } else {
                     if ($warning) {
                         $strWarn .= $warning . "<br />";
                     }
                     $path = $path_;
                 }
             } elseif (strpos($_SERVER['HTTP_HOST'], 'xn--') !== false) {
                 $path = CHTTP::URN2URI($path);
             }
         }
     }
     return $path;
 }
コード例 #11
0
ファイル: zip.php プロジェクト: ASDAFF/entask.ru
 public function __construct($pzipname)
 {
     $this->io = CBXVirtualIo::GetInstance();
     $this->zipname = $this->_convertWinPath($pzipname, false);
     $this->step_time = 30;
     $this->arPackedFiles = array();
     $this->arPackedFilesData = array();
     $this->_errorReset();
     $this->fileSystemEncoding = $this->_getfileSystemEncoding();
     self::$bMbstring = extension_loaded("mbstring");
     return;
 }
コード例 #12
0
ファイル: smile.php プロジェクト: andy-profi/bxApiDocs
 private static function checkFields(&$arFields, $actionType = self::CHECK_TYPE_ADD)
 {
     global $APPLICATION;
     $aMsg = array();
     if (isset($arFields['TYPE']) && !in_array($arFields['TYPE'], array(self::TYPE_SMILE, self::TYPE_ICON))) {
         $aMsg[] = array("id" => "TYPE", "text" => GetMessage("MAIN_SMILE_TYPE_ERROR"));
     } else {
         if ($actionType == self::CHECK_TYPE_ADD && !isset($arFields['TYPE'])) {
             $arFields['TYPE'] = self::TYPE_SMILE;
         }
     }
     if ($actionType == self::CHECK_TYPE_ADD && (!isset($arFields['SET_ID']) || intval($arFields['SET_ID']) <= 0)) {
         $aMsg[] = array("id" => "SET_ID", "text" => GetMessage("MAIN_SMILE_SET_ID_ERROR"));
     }
     if ($actionType == self::CHECK_TYPE_ADD && (!isset($arFields['SORT']) || intval($arFields['SORT']) <= 0)) {
         $arFields['SORT'] = 300;
     }
     if ($actionType == self::CHECK_TYPE_ADD && $arFields['TYPE'] == self::TYPE_SMILE && (!isset($arFields['TYPING']) || strlen($arFields['TYPING']) <= 0)) {
         $aMsg[] = array("id" => "TYPING", "text" => GetMessage("MAIN_SMILE_TYPING_ERROR"));
     }
     if ($actionType == self::CHECK_TYPE_UPDATE && $arFields['TYPE'] == self::TYPE_SMILE && (isset($arFields['TYPING']) && strlen($arFields['TYPING']) <= 0)) {
         $aMsg[] = array("id" => "TYPING", "text" => GetMessage("MAIN_SMILE_TYPING_ERROR"));
     }
     if (isset($arFields['CLICKABLE']) && $arFields['CLICKABLE'] != 'N') {
         $arFields['CLICKABLE'] = 'Y';
     }
     if (isset($arFields['IMAGE_DEFINITION']) && !in_array($arFields['IMAGE_DEFINITION'], array(self::IMAGE_SD, self::IMAGE_HD, self::IMAGE_UHD))) {
         $arFields['IMAGE_DEFINITION'] = self::IMAGE_SD;
     }
     if (isset($arFields['HIDDEN']) && $arFields['HIDDEN'] != 'Y') {
         $arFields['HIDDEN'] = 'N';
     }
     if ($actionType == self::CHECK_TYPE_ADD && (!isset($arFields['IMAGE']) || strlen($arFields['IMAGE']) <= 0)) {
         $aMsg[] = array("id" => "IMAGE", "text" => GetMessage("MAIN_SMILE_IMAGE_ERROR"));
     }
     if (isset($arFields['IMAGE']) && (!in_array(strtolower(GetFileExtension($arFields['IMAGE'])), array('png', 'jpg', 'gif')) || !CBXVirtualIo::GetInstance()->ValidateFilenameString($arFields['IMAGE']))) {
         $aMsg[] = array("id" => "IMAGE", "text" => GetMessage("MAIN_SMILE_IMAGE_ERROR"));
     }
     if (isset($arFields['IMAGE']) && (!isset($arFields['IMAGE_WIDTH']) || intval($arFields['IMAGE_WIDTH']) <= 0)) {
         $aMsg["IMAGE_XY"] = array("id" => "IMAGE_XY", "text" => GetMessage("MAIN_SMILE_IMAGE_XY_ERROR"));
     }
     if (isset($arFields['IMAGE']) && (!isset($arFields['IMAGE_HEIGHT']) || intval($arFields['IMAGE_HEIGHT']) <= 0)) {
         $aMsg["IMAGE_XY"] = array("id" => "IMAGE_XY", "text" => GetMessage("MAIN_SMILE_IMAGE_XY_ERROR"));
     }
     if (!empty($aMsg)) {
         $e = new CAdminException($aMsg);
         $APPLICATION->ThrowException($e);
         return false;
     }
     return true;
 }
コード例 #13
0
ファイル: spellchecker.php プロジェクト: rasuldev/torino
 private function checkDicPath()
 {
     global $USER;
     $dics_path = $_SERVER["DOCUMENT_ROOT"] . COption::GetOptionString('fileman', "user_dics_path", "/bitrix/modules/fileman/u_dics");
     $custom_path = $dics_path . '/' . $this->lang;
     if (COption::GetOptionString('fileman', "use_separeted_dics", "Y") == "Y") {
         $custom_path = $custom_path . '/' . $USER->GetID();
     }
     $io = CBXVirtualIo::GetInstance();
     if (!$io->DirectoryExists($custom_path)) {
         $io->CreateDirectory($custom_path);
     }
     return $custom_path;
 }
コード例 #14
0
ファイル: utils.php プロジェクト: Satariall/izurit
 function PatchHtaccess($path)
 {
     if (strtoupper(substr(PHP_OS, 0, 3)) === "WIN") {
         $io = CBXVirtualIo::GetInstance();
         $fnhtaccess = $io->CombinePath($path, '.htaccess');
         if ($io->FileExists($fnhtaccess)) {
             $ffhtaccess = $io->GetFile($fnhtaccess);
             $ffhtaccessContent = $ffhtaccess->GetContents();
             if (strpos($ffhtaccessContent, "/bitrix/virtual_file_system.php") === false) {
                 $ffhtaccessContent = preg_replace('/RewriteEngine On/is', "RewriteEngine On\r\n\r\n" . "RewriteCond %{REQUEST_FILENAME} -f [OR]\r\n" . "RewriteCond %{REQUEST_FILENAME} -l [OR]\r\n" . "RewriteCond %{REQUEST_FILENAME} -d\r\n" . "RewriteCond %{REQUEST_FILENAME} [\\xC2-\\xDF][\\x80-\\xBF] [OR]\r\n" . "RewriteCond %{REQUEST_FILENAME} \\xE0[\\xA0-\\xBF][\\x80-\\xBF] [OR]\r\n" . "RewriteCond %{REQUEST_FILENAME} [\\xE1-\\xEC\\xEE\\xEF][\\x80-\\xBF]{2} [OR]\r\n" . "RewriteCond %{REQUEST_FILENAME} \\xED[\\x80-\\x9F][\\x80-\\xBF] [OR]\r\n" . "RewriteCond %{REQUEST_FILENAME} \\xF0[\\x90-\\xBF][\\x80-\\xBF]{2} [OR]\r\n" . "RewriteCond %{REQUEST_FILENAME} [\\xF1-\\xF3][\\x80-\\xBF]{3} [OR]\r\n" . "RewriteCond %{REQUEST_FILENAME} \\xF4[\\x80-\\x8F][\\x80-\\xBF]{2}\r\n" . "RewriteCond %{REQUEST_FILENAME} !/bitrix/virtual_file_system.php\$\r\n" . "RewriteRule ^(.*)\$ /bitrix/virtual_file_system.php [L]", $ffhtaccessContent);
                 $ffhtaccess->PutContents($ffhtaccessContent);
             }
         }
     }
 }
コード例 #15
0
ファイル: zip.php プロジェクト: spas-viktor/books
 public function __construct($pzipname)
 {
     $this->io = CBXVirtualIo::GetInstance();
     //protecting against creating malicious php file with gzdeflate
     $pzipname = GetDirPath($this->_convertWinPath($pzipname, false)) . $this->io->RandomizeInvalidFilename(GetFileName($pzipname));
     if (HasScriptExtension($pzipname)) {
         $pzipname = RemoveScriptExtension($pzipname) . ".zip";
     }
     $this->zipname = $pzipname;
     $this->step_time = 30;
     $this->arPackedFiles = array();
     $this->_errorReset();
     $this->fileSystemEncoding = $this->_getfileSystemEncoding();
     self::$bMbstring = extension_loaded("mbstring");
     return;
 }
コード例 #16
0
ファイル: step1.php プロジェクト: webgksupport/alpina
 public function __construct($arParams)
 {
     $this->SITE_ID = $arParams["SITE_ID"];
     $this->REWRITE = $arParams["REWRITE"];
     $this->ModuleBlogGroup = '[' . $this->SITE_ID . '] ' . GetMessage("IDEA_BLOG_GROUP_NAME");
     $this->ModuleBlogUrl .= "_" . $this->SITE_ID;
     //NULL CACHE
     BXClearCache(True, '/' . $this->SITE_ID . '/idea/');
     BXClearCache(True, '/' . SITE_ID . '/idea/');
     global $CACHE_MANAGER;
     if (CACHED_b_user_field_enum !== false) {
         $CACHE_MANAGER->CleanDir("b_user_field_enum");
     }
     //Statuses List (for demo)
     $this->arResult["SETTINGS"]["STATUS"] = CIdeaManagment::getInstance()->Idea()->GetStatusList();
     foreach ($this->arResult["SETTINGS"]["STATUS"] as $arStatus) {
         $this->arResult["SETTINGS"]["STATUS_ID"][$arStatus["XML_ID"]] = $arStatus["ID"];
     }
     //Lang List
     $l = CLanguage::GetList($by = "sort", $order = "asc");
     while ($r = $l->Fetch()) {
         $this->arResult["SETTINGS"]["LANG"][] = $r;
     }
     //Sites List
     $oSites = CSite::GetList($b = "", $o = "", array("ACTIVE" => "Y"));
     while ($site = $oSites->Fetch()) {
         $this->arResult["SETTINGS"]["SITE"][$site["LID"]] = array("LANGUAGE_ID" => $site["LANGUAGE_ID"], "ABS_DOC_ROOT" => $site["ABS_DOC_ROOT"], "DIR" => $site["DIR"], "SITE_ID" => $site["LID"], "SERVER_NAME" => $site["SERVER_NAME"], "NAME" => $site["NAME"]);
     }
     if (array_key_exists($this->SITE_ID, $this->arResult["SETTINGS"]["SITE"])) {
         $this->PublicDir = str_replace(array("#SITE_DIR#"), array($this->arResult["SETTINGS"]["SITE"][$this->SITE_ID]["DIR"]), $this->PublicDir);
     }
     $site = CFileMan::__CheckSite($this->SITE_ID);
     $this->DOCUMENT_ROOT = CSite::GetSiteDocRoot($site);
     $this->IO = CBXVirtualIo::GetInstance();
     //SetDefault
     $this->arResult["INSTALLATION"]["IBLOCK_TYPE_INSTALL"] = true;
     $this->arResult["INSTALLATION"]["IBLOCK_INSTALL"] = true;
     $this->arResult["INSTALLATION"]["BLOG_GROUP_INSTALL"] = true;
     $this->arResult["INSTALLATION"]["BLOG_INSTALL"] = true;
     $this->CheckParams();
 }
コード例 #17
0
 function __makeFileArray($data, $del = false)
 {
     global $APPLICATION;
     $emptyFile = array("name" => null, "type" => null, "tmp_name" => null, "error" => 4, "size" => 0);
     $result = false;
     if ($del) {
         $result = $emptyFile + array("del" => "Y");
     } elseif (is_null($data)) {
         $result = $emptyFile;
     } elseif (is_string($data)) {
         $io = CBXVirtualIo::GetInstance();
         $normPath = $io->CombinePath("/", $data);
         $absPath = $io->CombinePath($_SERVER["DOCUMENT_ROOT"], $normPath);
         if ($io->ValidatePathString($absPath) && $io->FileExists($absPath)) {
             $perm = $APPLICATION->GetFileAccessPermission($normPath);
             if ($perm >= "W") {
                 $result = CFile::MakeFileArray($io->GetPhysicalName($absPath));
             }
         }
         if ($result === false) {
             $result = $emptyFile;
         }
     } elseif (is_array($data)) {
         if (is_uploaded_file($data["tmp_name"])) {
             $result = $data;
         } else {
             $emptyFile = array("name" => null, "type" => null, "tmp_name" => null, "error" => 4, "size" => 0);
             if ($data == $emptyFile) {
                 $result = $emptyFile;
             }
         }
         if ($result === false) {
             $result = $emptyFile;
         }
     } else {
         $result = $emptyFile;
     }
     return $result;
 }
コード例 #18
0
ファイル: cml2.php プロジェクト: andy-profi/bxApiDocs
 public static function UnZip($file_name, $last_zip_entry = "", $start_time = 0, $interval = 0)
 {
     global $APPLICATION;
     $io = CBXVirtualIo::GetInstance();
     //Function and securioty checks
     if (!function_exists("zip_open")) {
         return false;
     }
     $dir_name = substr($file_name, 0, strrpos($file_name, "/") + 1);
     if (strlen($dir_name) <= strlen($_SERVER["DOCUMENT_ROOT"])) {
         return false;
     }
     $hZip = zip_open($file_name);
     if (!$hZip) {
         return false;
     }
     //Skip from last step
     if ($last_zip_entry) {
         while ($entry = zip_read($hZip)) {
             if (zip_entry_name($entry) == $last_zip_entry) {
                 break;
             }
         }
     }
     $io = CBXVirtualIo::GetInstance();
     //Continue unzip
     while ($entry = zip_read($hZip)) {
         $entry_name = zip_entry_name($entry);
         //Check for directory
         zip_entry_open($hZip, $entry);
         if (zip_entry_filesize($entry)) {
             $file_name = trim(str_replace("\\", "/", trim($entry_name)), "/");
             $file_name = $APPLICATION->ConvertCharset($file_name, "cp866", LANG_CHARSET);
             $file_name = preg_replace("#^import_files/tmp/webdata/\\d+/\\d+/import_files/#", "import_files/", $file_name);
             $bBadFile = HasScriptExtension($file_name) || IsFileUnsafe($file_name) || !$io->ValidatePathString("/" . $file_name);
             if (!$bBadFile) {
                 $file_name = $io->GetPhysicalName($dir_name . rel2abs("/", $file_name));
                 CheckDirPath($file_name);
                 $fout = fopen($file_name, "wb");
                 if (!$fout) {
                     return false;
                 }
                 while ($data = zip_entry_read($entry, 102400)) {
                     $data_len = function_exists('mb_strlen') ? mb_strlen($data, 'latin1') : strlen($data);
                     $result = fwrite($fout, $data);
                     if ($result !== $data_len) {
                         return false;
                     }
                 }
             }
         }
         zip_entry_close($entry);
         //Jump to next step
         if ($interval > 0 && time() - $start_time > $interval) {
             zip_close($hZip);
             return $entry_name;
         }
     }
     zip_close($hZip);
     return true;
 }
コード例 #19
0
ファイル: csv_new_run.php プロジェクト: mrdeadmouse/u136006
if (!isset($defCatalogAvailCurrencies)) {
    $defCatalogAvailCurrencies = CCatalogCSVSettings::getDefaultSettings(CCatalogCSVSettings::FIELDS_CURRENCY);
}
$NUM_CATALOG_LEVELS = intval(COption::GetOptionString("catalog", "num_catalog_levels"));
$max_execution_time = intval($max_execution_time);
if ($max_execution_time <= 0) {
    $max_execution_time = 0;
}
if (defined('BX_CAT_CRON') && true == BX_CAT_CRON) {
    $max_execution_time = 0;
}
if (defined("CATALOG_LOAD_NO_STEP") && CATALOG_LOAD_NO_STEP) {
    $max_execution_time = 0;
}
$bAllLinesLoaded = true;
$io = CBXVirtualIo::GetInstance();
if (!function_exists('CSVCheckTimeout')) {
    function CSVCheckTimeout($max_execution_time)
    {
        return $max_execution_time <= 0 || getmicrotime() - START_EXEC_TIME <= $max_execution_time;
    }
}
$DATA_FILE_NAME = "";
if (strlen($URL_DATA_FILE) > 0) {
    $URL_DATA_FILE = Rel2Abs("/", $URL_DATA_FILE);
    if (file_exists($_SERVER["DOCUMENT_ROOT"] . $URL_DATA_FILE) && is_file($_SERVER["DOCUMENT_ROOT"] . $URL_DATA_FILE)) {
        $DATA_FILE_NAME = $URL_DATA_FILE;
    }
}
if (strlen($DATA_FILE_NAME) <= 0) {
    $strImportErrorMessage .= GetMessage("CATI_NO_DATA_FILE") . "<br>";
コード例 #20
0
ファイル: menu.php プロジェクト: rasuldev/torino
 /**
  * <p>Инициализирует (заполняет пунктами) объект класса CMenu. Возвращает "true" если в каталоге сайта найден файл меню <nobr><b>.</b><i>тип меню</i><b>.menu.php</b></nobr> (поиск идет вверх по иерархии начиная с каталога <i>dir</i>), и "false" в противном случае.</p>
  *
  *
  *
  *
  * @param string $InitDir  Папка, начиная с которой, объект будет искать файл <nobr><b>.</b><i>тип
  * меню</i><b>.menu.php</b></nobr> (файл с параметрами и пунктами меню).
  *
  *
  *
  * @param bool $MenuExt = false Если значение - "true", то для формирования массива меню, помимо
  * файлов <nobr><b>.</b><i>тип меню</i><b>.menu.php</b></nobr> будут также подключаться
  * файлы с именами вида <nobr><b>.</b><i>тип меню</i><b>.menu_ext.php</b></nobr>. В которых
  * вы можете манипулировать массивом меню <b>$aMenuLinks</b> произвольно, по
  * вашему усмотрению (например, дополнять пункты меню значениями из
  * инфо-блоков).<br>Необязателен. По умолчанию - "false".
  *
  *
  *
  * @param string $template = false Шаблон для вывода меню. <br>Необязателен. По умолчанию - "false", что
  * означает искать шаблон меню сначала в файле <nobr><b>/bitrix/templates/</b><i>ID
  * текущего шаблона сайта</i><b>/</b><i>тип меню</i><b>.menu_template.php</b></nobr>, затем
  * если шаблон не будет найден, то искать в файле
  * <nobr><b>/bitrix/templates/.default/</b><i>тип меню</i><b>.menu_template.php</b></nobr>. В самом
  * шаблоне меню вам будут доступны следующие предустановленные
  * переменные: <ul> <li> <b>$arMENU</b> - копия массива меню </li> <li> <b>$arMENU_LINK</b> -
  * ссылка на текущий массив меню </li> <li> <b>$TEXT</b> - текст текущего
  * пункта меню </li> <li> <b>$LINK</b> - ссылка текущего пункта меню </li> <li>
  * <b>$SELECTED</b> - выбран ли пункт меню в данный момент </li> <li> <b>$PERMISSION</b> -
  * доступ на страницу указанную в $LINK, возможны следующие значения:
  * <ul> <li> <b>D</b> - доступ запрещён </li> <li> <b>R</b> - чтение (право просмотра
  * содержимого файла) </li> <li> <b>U</b> - документооборот (право на
  * редактирование файла в режиме документооборота) </li> <li> <b>W</b> -
  * запись (право на прямое редактирование) </li> <li> <b>X</b> - полный доступ
  * (право на прямое редактирование файла и право на изменение прав
  * доступа на данных файл) </li> </ul> </li> <li> <b>$ADDITIONAL_LINKS</b> -
  * дополнительные ссылки для подсветки меню </li> <li> <b>$ITEM_TYPE</b> - "D" -
  * директория (если $LINK заканчивается на "/"), иначе "P" - страница </li> <li>
  * <b>$ITEM_INDEX</b> - порядковый номер пункта меню </li> <li> <b>$PARAMS</b> -
  * параметры пунктов меню </li> </ul> При этом в шаблоне для построения
  * меню необходимо будет инициализировать следующие перменные: <ul>
  * <li> <b>$sMenuProlog</b> - HTML который будет добавлен перед пунктами меню </li>
  * <li> <b>$sMenuEpilog</b> - HTML который будет добавлен после пунктов меню </li> <li>
  * <b>$sMenuBody</b> - HTML представляющий из себя один пункт меню </li> <li>
  * <b>$sMenu</b> - HTML представляющий из себя все меню целиком (только для
  * функций GetMenuHtmlEx) </li> </ul>
  *
  *
  *
  * @param onlyCurrentDi $r = false Если значение - "true", то отключается поиск файла меню в
  * родительских каталогах.
  *
  *
  *
  * @return bool 
  *
  *
  * <h4>Example</h4> 
  * <pre>
  * &lt;?
  * $lm = new CMenu("left");
  * <b>$lm-&gt;Init</b>($APPLICATION-&gt;GetCurDir(), true);
  * $lm-&gt;template = "/bitrix/templates/demo/left.menu_template.php";
  * echo $lm-&gt;GetMenuHtml();
  * ?&gt;
  * </pre>
  *
  *
  *
  * <h4>See Also</h4> 
  * <ul> <li><a href="https://dev.1c-bitrix.ru/learning/course/index.php?COURSE_ID=43&amp;CHAPTER_ID=04708"
  * >Меню</a></li> <li> <a href="http://dev.1c-bitrix.ru/api_help/main/reference/cmain/getmenu.php">CMain::GetMenu</a>
  * </li> </ul></b<a name="examples"></a>
  *
  *
  * @static
  * @link http://dev.1c-bitrix.ru/api_help/main/reference/cmenu/init.php
  * @author Bitrix
  */
 public function Init($InitDir, $bMenuExt = false, $template = false, $onlyCurrentDir = false)
 {
     global $USER;
     if ($this->debug !== false && $_SESSION["SESS_SHOW_INCLUDE_TIME_EXEC"] == "Y" && ($USER->IsAdmin() || $_SESSION["SHOW_SQL_STAT"] == "Y")) {
         $this->debug = new CDebugInfo(false);
         $this->debug->Start();
     }
     $io = CBXVirtualIo::GetInstance();
     $aMenuLinks = array();
     $bFounded = false;
     if ($template === false) {
         $sMenuTemplate = '';
     } else {
         $sMenuTemplate = $template;
     }
     $InitDir = str_replace("\\", "/", $InitDir);
     $Dir = $InitDir;
     $site_dir = false;
     if (defined("SITE_DIR") && SITE_DIR != '') {
         $site_dir = SITE_DIR;
     } elseif (array_key_exists("site", $_REQUEST) && $_REQUEST["site"] != '') {
         $rsSites = CSite::GetByID($_REQUEST["site"]);
         if ($arSite = $rsSites->Fetch()) {
             $site_dir = $arSite["DIR"];
         }
     }
     while ($Dir != '') {
         if ($site_dir !== false && strlen(trim($Dir, "/")) < strlen(trim($site_dir, "/"))) {
             break;
         }
         $Dir = rtrim($Dir, "/");
         $menu_file_name = $io->CombinePath($_SERVER["DOCUMENT_ROOT"], $Dir, "." . $this->type . ".menu.php");
         if ($io->FileExists($menu_file_name)) {
             include $io->GetPhysicalName($menu_file_name);
             $this->MenuDir = $Dir . "/";
             $this->arMenu = $aMenuLinks;
             $this->template = $sMenuTemplate;
             $bFounded = true;
             break;
         }
         if ($Dir == "") {
             break;
         }
         $pos = strrpos($Dir, "/");
         if ($pos === false || $onlyCurrentDir == true) {
             break;
         }
         $Dir = substr($Dir, 0, $pos + 1);
     }
     if ($bMenuExt) {
         $Dir = $InitDir;
         while ($Dir != '') {
             if ($site_dir !== false && strlen(trim($Dir, "/")) < strlen(trim($site_dir, "/"))) {
                 break;
             }
             $Dir = rtrim($Dir, "/");
             $menu_file_name = $io->CombinePath($_SERVER["DOCUMENT_ROOT"], $Dir, "." . $this->type . ".menu_ext.php");
             if ($io->FileExists($menu_file_name)) {
                 include $io->GetPhysicalName($menu_file_name);
                 if (!$bFounded) {
                     $this->MenuDir = $Dir . "/";
                 }
                 $this->MenuExtDir = $Dir . "/";
                 $this->arMenu = $aMenuLinks;
                 $this->template = $sMenuTemplate;
                 $bFounded = true;
                 break;
             }
             if ($Dir == "") {
                 break;
             }
             $pos = strrpos($Dir, "/");
             if ($pos === false || $onlyCurrentDir == true) {
                 break;
             }
             $Dir = substr($Dir, 0, $pos + 1);
         }
     }
     return $bFounded;
 }
コード例 #21
0
 function DownloadToFile($arBucket, $arFile, $filePath)
 {
     $io = CBXVirtualIo::GetInstance();
     $obRequest = new CHTTP();
     $obRequest->follow_redirect = true;
     return $obRequest->Download($this->GetFileSRC($arBucket, $arFile), $io->GetPhysicalName($filePath));
 }
コード例 #22
0
ファイル: edit_area.php プロジェクト: ASDAFF/open_bx
 public function __construct($component, $componentName, $componentTemplate, $parentComponent, $bComponentEnabled)
 {
     $this->component = $component;
     $this->componentName = $componentName;
     $this->componentTemplate = $componentTemplate;
     $this->parentComponent = $parentComponent;
     $this->bComponentEnabled = $bComponentEnabled;
     $aTrace = Freetrix\Main\Diag\Helper::getBackTrace(2);
     $io = CBXVirtualIo::GetInstance();
     $this->sSrcFile = str_replace("\\", "/", $io->GetLogicalName($aTrace[1]["file"]));
     $this->iSrcLine = intval($aTrace[1]["line"]);
     if ($this->iSrcLine > 0 && $this->sSrcFile != "") {
         // try to convert absolute path to file within DOCUMENT_ROOT
         $doc_root = strtolower(str_replace("\\", "/", realpath($_SERVER["DOCUMENT_ROOT"])));
         if (strpos(strtolower($this->sSrcFile), $doc_root . "/") === 0) {
             //within
             $this->sSrcFile = substr($this->sSrcFile, strlen($doc_root));
             $this->bSrcFound = true;
         } else {
             //outside
             $sRealFreetrix = strtolower(str_replace("\\", "/", realpath($_SERVER["DOCUMENT_ROOT"] . "/freetrix")));
             if (strpos(strtolower($this->sSrcFile), substr($sRealFreetrix, 0, -6)) === 0) {
                 $this->sSrcFile = substr($this->sSrcFile, strlen($sRealFreetrix) - 7);
                 $this->bSrcFound = true;
             }
         }
     }
 }
コード例 #23
0
ファイル: iblockdocument.php プロジェクト: spas-viktor/books
 /**
  * ћетод восстанавливает указанный документ из массива. ћассив создаетс¤ методом RecoverDocumentFromHistory.
  *
  * @param string $documentId - код документа.
  * @param array $arDocument - массив.
  */
 public function RecoverDocumentFromHistory($documentId, $arDocument)
 {
     $documentId = intval($documentId);
     if ($documentId <= 0) {
         throw new CBPArgumentNullException("documentId");
     }
     $arFields = $arDocument["FIELDS"];
     if (strlen($arFields["PREVIEW_PICTURE"]) > 0) {
         $arFields["PREVIEW_PICTURE"] = CFile::MakeFileArray($arFields["PREVIEW_PICTURE"]);
     }
     if (strlen($arFields["DETAIL_PICTURE"]) > 0) {
         $arFields["DETAIL_PICTURE"] = CFile::MakeFileArray($arFields["DETAIL_PICTURE"]);
     }
     $arFields["PROPERTY_VALUES"] = array();
     $dbProperties = CIBlockProperty::GetList(array("sort" => "asc", "name" => "asc"), array("IBLOCK_ID" => $arFields["IBLOCK_ID"]));
     while ($arProperty = $dbProperties->Fetch()) {
         if (strlen(trim($arProperty["CODE"])) > 0) {
             $key = $arProperty["CODE"];
         } else {
             $key = $arProperty["ID"];
         }
         if (!array_key_exists($key, $arDocument["PROPERTIES"])) {
             continue;
         }
         $documentValue = $arDocument["PROPERTIES"][$key]["VALUE"];
         if (strlen($arProperty["USER_TYPE"]) <= 0 && $arProperty["PROPERTY_TYPE"] == "F") {
             $arFields["PROPERTY_VALUES"][$key] = array();
             //Mark files to be deleted
             $rsFiles = CIBlockElement::GetProperty($arFields["IBLOCK_ID"], $documentId, array("ID" => $arProperty["ID"], "EMPTY" => "N"));
             while ($arFile = $rsFiles->Fetch()) {
                 if ($arFile["PROPERTY_VALUE_ID"] > 0) {
                     $arFields["PROPERTY_VALUES"][$key][$arFile["PROPERTY_VALUE_ID"]] = array("VALUE" => array("del" => "Y"), "DESCRIPTION" => "");
                 }
             }
             //Restore from history
             $io = CBXVirtualIo::GetInstance();
             if (is_array($documentValue)) {
                 $n = 0;
                 foreach ($documentValue as $i => $v) {
                     if (strlen($v) > 0) {
                         $arFields["PROPERTY_VALUES"][$key]["n" . $n++] = array("VALUE" => CFile::MakeFileArray($io->GetPhysicalName($v)), "DESCRIPTION" => $arDocument["PROPERTIES"][$key]["DESCRIPTION"][$i]);
                     }
                 }
             } else {
                 if (strlen($documentValue) > 0) {
                     $arFields["PROPERTY_VALUES"][$key]["n0"] = array("VALUE" => CFile::MakeFileArray($io->GetPhysicalName($documentValue)), "DESCRIPTION" => $arDocument["PROPERTIES"][$key]["DESCRIPTION"]);
                 }
             }
         } else {
             if (is_array($documentValue)) {
                 $n = 0;
                 foreach ($documentValue as $i => $v) {
                     if (strlen($v) > 0) {
                         $arFields["PROPERTY_VALUES"][$key]["n" . $n++] = array("VALUE" => $v, "DESCRIPTION" => $arDocument["PROPERTIES"][$key]["DESCRIPTION"][$i]);
                     }
                 }
             } else {
                 if (strlen($documentValue) > 0) {
                     $arFields["PROPERTY_VALUES"][$key]["n0"] = array("VALUE" => $documentValue, "DESCRIPTION" => $arDocument["PROPERTIES"][$key]["DESCRIPTION"]);
                 }
             }
         }
     }
     $iblockElement = new CIBlockElement();
     $res = $iblockElement->Update($documentId, $arFields);
     if (intVal($arFields["WF_STATUS_ID"]) > 1 && intVal($arFields["WF_PARENT_ELEMENT_ID"]) <= 0) {
         self::UnpublishDocument($documentId);
     }
     if (!$res) {
         throw new Exception($iblockElement->LAST_ERROR);
     }
     return true;
 }
コード例 #24
0
ファイル: file.php プロジェクト: k-kalashnikov/geekcon_new
 function GetImageSize($path, $bPhysicalName = false)
 {
     $io = CBXVirtualIo::GetInstance();
     $pathX = $bPhysicalName ? $path : $io->GetPhysicalName($path);
     $file_handler = fopen($pathX, "rb");
     if (!is_resource($file_handler)) {
         return false;
     }
     $signature = fread($file_handler, 12);
     fclose($file_handler);
     if (preg_match("/^(\n\t\t\tGIF                    # php_sig_gif\n\t\t\t|\\xff\\xd8\\xff       # php_sig_jpg\n\t\t\t|\\x89\\x50\\x4e       # php_sig_png\n\t\t\t|FWS                   # php_sig_swf\n\t\t\t|CWS                   # php_sig_swc\n\t\t\t|8BPS                  # php_sig_psd\n\t\t\t|BM                    # php_sig_bmp\n\t\t\t|\\xff\\x4f\\xff       # php_sig_jpc\n\t\t\t|II\\x2a\\x00          # php_sig_tif_ii\n\t\t\t|MM\\x00\\x2a          # php_sig_tif_mm\n\t\t\t|FORM                  # php_sig_iff\n\t\t\t|\\x00\\x00\\x01\\x00  # php_sig_ico\n\t\t\t|\\x00\\x00\\x00\\x0c\n\t\t\t\\x6a\\x50\\x20\\x20\n\t\t\t\\x0d\\x0a\\x87\\x0a  # php_sig_jp2\n\t\t\t)/x", $signature)) {
         /*php_get_wbmp to be added*/
         return getimagesize($pathX);
     } else {
         return false;
     }
 }
コード例 #25
0
ファイル: virtual_file.php プロジェクト: andy-profi/bxApiDocs
 public function GetPath()
 {
     $io = CBXVirtualIo::GetInstance();
     return $io->ExtractPathFromPath($this->path);
 }
コード例 #26
0
ファイル: component_util.php プロジェクト: rasuldev/torino
 public static function __GetComponentsTree($filterNamespace = false, $arNameFilter = false)
 {
     $arTree = array();
     $io = CBXVirtualIo::GetInstance();
     $folders = array("/local/components", "/bitrix/components");
     foreach ($folders as $componentFolder) {
         if ($handle = @opendir($_SERVER["DOCUMENT_ROOT"] . $componentFolder)) {
             while (($file = readdir($handle)) !== false) {
                 if ($file == "." || $file == "..") {
                     continue;
                 }
                 if (is_dir($_SERVER["DOCUMENT_ROOT"] . $componentFolder . "/" . $file)) {
                     if (CComponentUtil::isComponent($componentFolder . "/" . $file)) {
                         // It's component
                         if ($filterNamespace !== false && strlen($filterNamespace) > 0) {
                             continue;
                         }
                         if ($arNameFilter !== false && !CComponentUtil::CheckComponentName($file, $arNameFilter)) {
                             continue;
                         }
                         if (file_exists($_SERVER["DOCUMENT_ROOT"] . $componentFolder . "/" . $file . "/.description.php")) {
                             CComponentUtil::__IncludeLang($componentFolder . "/" . $file, ".description.php");
                             $arComponentDescription = array();
                             include $_SERVER["DOCUMENT_ROOT"] . $componentFolder . "/" . $file . "/.description.php";
                             if (array_key_exists("PATH", $arComponentDescription) && array_key_exists("ID", $arComponentDescription["PATH"])) {
                                 $arComponent = array();
                                 $arComponent["NAME"] = $file;
                                 $arComponent["NAMESPACE"] = "";
                                 $arComponent["TITLE"] = trim($arComponentDescription["NAME"]);
                                 $arComponent["DESCRIPTION"] = $arComponentDescription["DESCRIPTION"];
                                 if (array_key_exists("ICON", $arComponentDescription)) {
                                     $arComponentDescription["ICON"] = ltrim($arComponentDescription["ICON"], "/");
                                     if ($arComponentDescription["ICON"] != "" && $io->FileExists($io->RelativeToAbsolutePath($componentFolder . "/" . $file . "/" . $arComponentDescription["ICON"]))) {
                                         $arComponent["ICON"] = $componentFolder . "/" . $file . "/" . $arComponentDescription["ICON"];
                                     } else {
                                         $arComponent["ICON"] = "/bitrix/images/fileman/htmledit2/component.gif";
                                     }
                                 }
                                 if (array_key_exists("COMPLEX", $arComponentDescription) && $arComponentDescription["COMPLEX"] == "Y") {
                                     $arComponent["COMPLEX"] = "Y";
                                 } else {
                                     $arComponent["COMPLEX"] = "N";
                                 }
                                 $arComponent["SORT"] = IntVal($arComponentDescription["SORT"]);
                                 if ($arComponent["SORT"] <= 0) {
                                     $arComponent["SORT"] = 100;
                                 }
                                 $arComponent["SCREENSHOT"] = array();
                                 if (array_key_exists("SCREENSHOT", $arComponentDescription)) {
                                     if (!is_array($arComponentDescription["SCREENSHOT"])) {
                                         $arComponentDescription["SCREENSHOT"] = array($arComponentDescription["SCREENSHOT"]);
                                     }
                                     for ($i = 0, $cnt = count($arComponentDescription["SCREENSHOT"]); $i < $cnt; $i++) {
                                         $arComponent["SCREENSHOT"][] = $componentFolder . "/" . $file . $arComponentDescription["SCREENSHOT"][$i];
                                     }
                                 }
                                 CComponentUtil::__BuildTree($arComponentDescription["PATH"], $arTree, $arComponent);
                             }
                         }
                     } else {
                         // It's not a component
                         if ($filterNamespace !== false && (strlen($filterNamespace) <= 0 || $filterNamespace != $file)) {
                             continue;
                         }
                         if ($handle1 = @opendir($_SERVER["DOCUMENT_ROOT"] . $componentFolder . "/" . $file)) {
                             while (($file1 = readdir($handle1)) !== false) {
                                 if ($file1 == "." || $file1 == "..") {
                                     continue;
                                 }
                                 if (is_dir($_SERVER["DOCUMENT_ROOT"] . $componentFolder . "/" . $file . "/" . $file1)) {
                                     if (CComponentUtil::isComponent($componentFolder . "/" . $file . "/" . $file1)) {
                                         if ($arNameFilter !== false && !CComponentUtil::CheckComponentName($file1, $arNameFilter)) {
                                             continue;
                                         }
                                         // It's component
                                         if (file_exists($_SERVER["DOCUMENT_ROOT"] . $componentFolder . "/" . $file . "/" . $file1 . "/.description.php")) {
                                             CComponentUtil::__IncludeLang($componentFolder . "/" . $file . "/" . $file1, ".description.php");
                                             $arComponentDescription = array();
                                             include $_SERVER["DOCUMENT_ROOT"] . $componentFolder . "/" . $file . "/" . $file1 . "/.description.php";
                                             if (array_key_exists("PATH", $arComponentDescription) && array_key_exists("ID", $arComponentDescription["PATH"])) {
                                                 $arComponent = array();
                                                 $arComponent["NAME"] = $file . ":" . $file1;
                                                 $arComponent["NAMESPACE"] = $file;
                                                 $arComponent["TITLE"] = trim($arComponentDescription["NAME"]);
                                                 $arComponent["DESCRIPTION"] = $arComponentDescription["DESCRIPTION"];
                                                 if (array_key_exists("ICON", $arComponentDescription)) {
                                                     $arComponentDescription["ICON"] = ltrim($arComponentDescription["ICON"], "/");
                                                     if ($arComponentDescription["ICON"] != "" && $io->FileExists($io->RelativeToAbsolutePath($componentFolder . "/" . $file . "/" . $file1 . "/" . $arComponentDescription["ICON"]))) {
                                                         $arComponent["ICON"] = $componentFolder . "/" . $file . "/" . $file1 . "/" . $arComponentDescription["ICON"];
                                                     } else {
                                                         $arComponent["ICON"] = "/bitrix/images/fileman/htmledit2/component.gif";
                                                     }
                                                 }
                                                 if (array_key_exists("COMPLEX", $arComponentDescription) && $arComponentDescription["COMPLEX"] == "Y") {
                                                     $arComponent["COMPLEX"] = "Y";
                                                 } else {
                                                     $arComponent["COMPLEX"] = "N";
                                                 }
                                                 $arComponent["SORT"] = IntVal($arComponentDescription["SORT"]);
                                                 if ($arComponent["SORT"] <= 0) {
                                                     $arComponent["SORT"] = 100;
                                                 }
                                                 $arComponent["SCREENSHOT"] = array();
                                                 if (array_key_exists("SCREENSHOT", $arComponentDescription)) {
                                                     if (!is_array($arComponentDescription["SCREENSHOT"])) {
                                                         $arComponentDescription["SCREENSHOT"] = array($arComponentDescription["SCREENSHOT"]);
                                                     }
                                                     for ($i = 0, $cnt = count($arComponentDescription["SCREENSHOT"]); $i < $cnt; $i++) {
                                                         $arComponent["SCREENSHOT"][] = $componentFolder . "/" . $file . "/" . $file1 . $arComponentDescription["SCREENSHOT"][$i];
                                                     }
                                                 }
                                                 CComponentUtil::__BuildTree($arComponentDescription["PATH"], $arTree, $arComponent);
                                             }
                                         }
                                     }
                                 }
                             }
                             @closedir($handle1);
                         }
                     }
                 }
             }
             @closedir($handle);
         }
     }
     return $arTree;
 }
コード例 #27
0
ファイル: medialib.php プロジェクト: andy-profi/bxApiDocs
 public static function Edit($Params)
 {
     global $DB;
     $source_id = false;
     $arFields = $Params['arFields'];
     $bNew = !isset($arFields['ID']) || $arFields['ID'] <= 0;
     $bFile_FD = $Params['path'] && strlen($Params['path']) > 0;
     $bFile_PC = $Params['file'] && strlen($Params['file']['name']) > 0 && $Params['file']['size'] > 0;
     $io = CBXVirtualIo::GetInstance();
     if ($bFile_FD || $bFile_PC) {
         if ($bFile_FD) {
             $DocRoot = CSite::GetSiteDocRoot(false);
             $tmp_name = $DocRoot . $Params['path'];
             if ($io->FileExists($tmp_name)) {
                 $flTmp = $io->GetFile($tmp_name);
                 $file_name = substr($Params['path'], strrpos($Params['path'], '/') + 1);
                 $arFile = array("name" => $file_name, "size" => $flTmp->GetFileSize(), "tmp_name" => $tmp_name, "type" => CFile::IsImage($file_name) ? 'image' : 'file');
             }
         } else {
             if ($bFile_PC) {
                 $arFile = $Params['file'];
             }
         }
         if (!CMedialib::CheckFileExtention($arFile["name"])) {
             return false;
         }
         if (!$bNew) {
             $arFile["old_file"] = CMedialibItem::GetSourceId($arFields['ID']);
             $arFile["del"] = "Y";
         }
         // Resizing Image
         if (CFile::IsImage($arFile["name"])) {
             $arSize = array('width' => COption::GetOptionInt('fileman', "ml_max_width", 1024), 'height' => COption::GetOptionInt('fileman', "ml_max_height", 1024));
             $res = CFile::ResizeImage($arFile, $arSize);
         }
         $arFile["MODULE_ID"] = "fileman";
         $source_id = CFile::SaveFile($arFile, "medialibrary");
         if ($source_id) {
             $r = CFile::GetByID($source_id);
             if ($arFile = $r->Fetch()) {
                 if (CFile::IsImage($arFile['FILE_NAME'])) {
                     CMedialibItem::GenerateThumbnail($arFile, array('width' => COption::GetOptionInt('fileman', "ml_thumb_width", 140), 'height' => COption::GetOptionInt('fileman', "ml_thumb_height", 105)));
                 }
                 $arFile['PATH'] = CMedialibItem::GetFullPath($arFile);
             }
         }
     }
     // TODO: Add error handling
     if ($bNew && !$source_id) {
         return false;
     }
     // 2. Add to b_medialib_item
     if (!isset($arFields['~DATE_UPDATE'])) {
         $arFields['~DATE_UPDATE'] = $DB->CurrentTimeFunction();
     }
     if (!CMedialibItem::CheckFields($arFields)) {
         return false;
     }
     if (CModule::IncludeModule("search")) {
         $arStem = stemming($arFields['NAME'] . ' ' . $arFields['DESCRIPTION'] . ' ' . $arFields['KEYWORDS'], LANGUAGE_ID);
         if (count($arStem) > 0) {
             $arFields['SEARCHABLE_CONTENT'] = '{' . implode('}{', array_keys($arStem)) . '}';
         } else {
             $arFields['SEARCHABLE_CONTENT'] = '';
         }
     }
     if ($bNew) {
         unset($arFields['ID']);
         $arFields['SOURCE_ID'] = $source_id;
         $arFields['~DATE_CREATE'] = $arFields['~DATE_UPDATE'];
         $arFields['ITEM_TYPE'] = '';
         $ID = CDatabase::Add("b_medialib_item", $arFields, array("DESCRIPTION", "SEARCHABLE_CONTENT"));
     } else {
         if ($source_id) {
             $arFields['SOURCE_ID'] = $source_id;
         }
         $ID = $arFields['ID'];
         unset($arFields['ID']);
         $strUpdate = $DB->PrepareUpdate("b_medialib_item", $arFields);
         $strSql = "UPDATE b_medialib_item SET " . $strUpdate . " WHERE ID=" . IntVal($ID);
         $DB->QueryBind($strSql, array("DESCRIPTION" => $arFields["DESCRIPTION"], "SEARCHABLE_CONTENT" => $arFields["SEARCHABLE_CONTENT"]), false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     }
     // 3. Set fields to b_medialib_collection_item
     if (!$bNew) {
         $strSql = "DELETE FROM b_medialib_collection_item WHERE ITEM_ID=" . IntVal($ID);
         $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
     }
     $strCollections = "0";
     for ($i = 0, $l = count($Params['arCollections']); $i < $l; $i++) {
         $strCollections .= "," . IntVal($Params['arCollections'][$i]);
     }
     $strSql = "INSERT INTO b_medialib_collection_item(ITEM_ID, COLLECTION_ID) " . "SELECT " . intVal($ID) . ", ID " . "FROM b_medialib_collection " . "WHERE ID in (" . $strCollections . ")";
     $res = $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
     if (!$arFields['ID']) {
         $arFields['ID'] = $ID;
     }
     if ($source_id) {
         $arFields = array_merge($arFile, $arFields);
     }
     return $arFields;
 }
コード例 #28
0
ファイル: uploader.php プロジェクト: DarneoStudio/bitrix
 protected function fillRequireData($requestType)
 {
     $this->mode = $this->getPost("mode", $requestType);
     $this->CID = FileInputUtility::instance()->registerControl($this->getPost("CID", $requestType), $this->controlId);
     if (in_array($this->mode, array("upload", "delete", "view"))) {
         $directory = \CBXVirtualIo::GetInstance()->GetDirectory($this->path);
         $directoryExists = $directory->IsExists();
         if ($this->mode != "view" && !check_bitrix_sessid()) {
             $this->status = new Status("BXU345.1");
         } else {
             if (!$directory->Create()) {
                 $this->status = new Status("BXU345.2");
             } else {
                 if ($this->getPost("packageIndex", $requestType)) {
                     $this->PID = $this->getPost("packageIndex");
                     $this->packLog->setPath($this->path . $this->getPost("packageIndex") . ".package");
                     $this->packLog->setValue("filesCount", $this->getPost("filesCount"));
                 } else {
                     if ($this->mode == "upload") {
                         $this->status = new Status("BXU344.1");
                     }
                 }
             }
         }
         $this->log->setPath($this->path . $this->CID . ".log");
         if (!$directoryExists) {
             $access = \CBXVirtualIo::GetInstance()->GetFile($directory->GetPath() . "/.access.php");
             $content = '<?$PERM["' . $directory->GetName() . '"]["*"]="X";?>';
             if (!$access->IsExists() || strpos($access->GetContents(), $content) === false) {
                 if (($fd = $access->Open('ab')) && $fd) {
                     fwrite($fd, $content);
                 }
                 fclose($fd);
             }
         }
         return true;
     }
     return false;
 }
コード例 #29
0
ファイル: xml.php プロジェクト: k-kalashnikov/geekcon_new
 /**
  * Opens file by it's absolute path. Returns true on success.
  *
  * @param string $filePath
  * @return bool
  *
  */
 public function openFile($filePath)
 {
     $this->fileHandler = null;
     $io = CBXVirtualIo::getInstance();
     $file = $io->getFile($filePath);
     $this->fileHandler = $file->open("rb");
     if (is_resource($this->fileHandler)) {
         if ($this->filePosition > 0) {
             fseek($this->fileHandler, $this->filePosition);
         }
         $this->elementStack = array();
         $this->positionStack = array();
         foreach (explode("/", $this->xmlPosition) as $pathPart) {
             @(list($elementPosition, $elementName) = explode("@", $pathPart, 2));
             $this->elementStack[] = $elementName;
             $this->positionStack[] = $elementPosition;
         }
         return true;
     } else {
         return false;
     }
 }
コード例 #30
0
 function BaseConvertToDB($value)
 {
     $io = CBXVirtualIo::GetInstance();
     $arRes = array("path" => "");
     if (!is_array($value)) {
         $value = array();
     }
     //In case of DB value just serialize it
     if (implode("|", array_keys($value)) === 'path|width|height|title|duration|author|date|desc') {
         return serialize($value);
     }
     if ($value["B_NEW_FILE"] != "N") {
         if (strlen($value["CUR_PATH"]) > 0 && $value["DEL_CUR_FILE"] == "Y" && CIBlockPropertyVideo::CheckFileInUploadDir($value["CUR_PATH"])) {
             // del current file
             $cur_path_ = $_SERVER["DOCUMENT_ROOT"] . Rel2Abs("/", $value["CUR_PATH"]);
             $flTmp = $io->GetFile($cur_path_);
             $flSzTmp = $flTmp->GetFileSize();
             if ($io->Delete($cur_path_)) {
                 // Quota
                 if (COption::GetOptionInt("main", "disk_space") > 0) {
                     CDiskQuota::updateDiskQuota("file", $flSzTmp, "delete");
                 }
             }
         }
         // Get video
         if (strlen($value["PATH"]) > 0) {
             $arRes["path"] = $value["PATH"];
         } else {
             if (isset($value["FILE"]) && strlen($value["FILE"]["tmp_name"]) > 0) {
                 $pathToDir = CIBlockPropertyVideo::GetUploadDirPath();
                 if (!$io->DirectoryExists($_SERVER["DOCUMENT_ROOT"] . $pathToDir)) {
                     CFileMan::CreateDir($pathToDir);
                 }
                 // 1. Convert name
                 $name = preg_replace("/[^a-zA-Z0-9_:\\.]/is", "_", $value["FILE"]["name"]);
                 $baseNamePart = substr($name, 0, strpos($name, '.'));
                 $ext = GetFileExtension($name);
                 if (strlen($ext) > 0 && !HasScriptExtension($name) && !substr($name, 0, 1) != ".") {
                     $ind = 0;
                     // 2. Check if file already exists
                     while ($io->FileExists($_SERVER["DOCUMENT_ROOT"] . Rel2Abs($pathToDir, $name))) {
                         $name = $baseNamePart . "_(" . ++$ind . ")." . $ext;
                     }
                     // 3. Rename
                     $pathto = Rel2Abs($pathToDir, $name);
                     if (is_uploaded_file($value["FILE"]["tmp_name"]) && $io->Copy($value["FILE"]["tmp_name"], $_SERVER["DOCUMENT_ROOT"] . $pathto)) {
                         $arRes["path"] = Rel2Abs("/", $pathto);
                         // Quota
                         if (COption::GetOptionInt("main", "disk_space") > 0) {
                             CDiskQuota::updateDiskQuota("file", $value["FILE"]["size"], "add");
                         }
                     }
                 }
             }
         }
     } elseif (strlen($value["CUR_PATH"]) > 0) {
         if (preg_match("/^(http|https):\\/\\//", $value["CUR_PATH"])) {
             $arRes["path"] = $value["CUR_PATH"];
         } else {
             $arRes["path"] = Rel2Abs("/", $value["CUR_PATH"]);
         }
     }
     // Width  & height
     $arRes["width"] = intVal($value["WIDTH"]);
     $arRes["height"] = intVal($value["HEIGHT"]);
     if ($arRes["width"] < 0) {
         $arRes["width"] = 400;
     }
     if ($arRes["height"] < 0) {
         $arRes["height"] = 300;
     }
     // Video info
     $arRes["title"] = $value["TITLE"];
     $arRes["duration"] = $value["DURATION"];
     $arRes["author"] = $value["AUTHOR"];
     $arRes["date"] = $value["DATE"];
     $arRes["desc"] = $value["DESC"];
     $strRes = serialize($arRes);
     if ($arRes["path"] == "" && $arRes["title"] == "" && $arRes["author"] == "") {
         return "";
     }
     return $strRes;
 }