public function GetChildren()
	{
		$arResult = array();

		if (!$this->IsExists())
			return $arResult;

		if ($handle = opendir($this->GetPathWithNameEncoded()))
		{
			while (($file = readdir($handle)) !== false)
			{
				if ($file == "." || $file == "..")
					continue;

				$pathDecoded = CBXVirtualIoFileSystem::ConvertCharset($this->GetPathWithNameEncoded()."/".$file, CBXVirtualIoFileSystem::directionDecode);
				if (is_dir($this->GetPathWithNameEncoded()."/".$file))
					$arResult[] = new CBXVirtualDirectoryFileSystem($pathDecoded);
				else
					$arResult[] = new CBXVirtualFileFileSystem($pathDecoded);
			}
			closedir($handle);
		}

		return $arResult;
	}
Beispiel #2
0
 public static function GetModifyTime($path)
 {
     $path = CBXVirtualIoFileSystem::ConvertCharset($path);
     if (file_exists($path)) {
         $stat = stat($path);
         return $stat["mtime"];
     }
     return null;
 }
Beispiel #3
0
 function _mimetype($fspath)
 {
     $io = self::GetIo();
     if ($io->DirectoryExists($fspath)) {
         return 'httpd/unix-directory';
     } else {
         if (function_exists('mime_content_type') && $io->FileExists($fspath)) {
             $mime_type = mime_content_type(CBXVirtualIoFileSystem::ConvertCharset($fspath));
         }
     }
     if (empty($mime_type)) {
         $mime_type = $this->get_mime_type($fspath);
     }
     return $mime_type;
 }
if (strlen($strWarning) <= 0) {
    $flTmp = $io->GetFile($arFile["tmp_name"]);
    $fsize = $flTmp->GetFileSize();
    $bufSize = 4194304;
    //4M
    session_write_close();
    set_time_limit(0);
    header("Content-Type: application/force-download; name=\"" . $arFile["name"] . "\"");
    header("Content-Transfer-Encoding: binary");
    header("Content-Length: " . $fsize);
    header("Content-Disposition: attachment; filename=\"" . $arFile["name"] . "\"");
    header("Expires: 0");
    header("Cache-Control: no-cache, must-revalidate");
    header("Pragma: no-cache");
    header('Connection: close');
    $arFile["tmp_name"] = CBXVirtualIoFileSystem::ConvertCharset($arFile["tmp_name"], CBXVirtualIoFileSystem::directionEncode);
    $f = fopen($arFile["tmp_name"], 'rb');
    while (!feof($f)) {
        echo fread($f, $bufSize);
        ob_flush();
        flush();
        ob_end_clean();
    }
    fclose($f);
    die;
}
$APPLICATION->SetTitle(GetMessage("FILEMAN_FILEDOWNLOAD") . " \"" . $arFile["name"] . "\"");
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php";
?>
<font class="text"><?php 
echo $arFile["name"];
Beispiel #5
0
 function DeleteEx($path)
 {
     global $APPLICATION, $USER;
     CMain::InitPathVars($site, $path);
     if (strlen($path) <= 0) {
         return false;
     }
     $src = $_SERVER["DOCUMENT_ROOT"] . $path;
     $src = str_replace("//", "/", $src);
     if ($src == $_SERVER["DOCUMENT_ROOT"]) {
         return false;
     }
     $DOC_ROOT = CSite::GetSiteDocRoot($site);
     @set_time_limit(600);
     $io = CBXVirtualIo::GetInstance();
     if (is_link($linkPath = CBXVirtualIoFileSystem::ConvertCharset($DOC_ROOT . $path))) {
         if (@unlink($linkPath)) {
             return;
         } else {
             return GetMessage("FILEMAN_FILEMAN_SYMLINK_DEL_ERROR") . " \"" . $path . "\".\n";
         }
     } elseif ($io->DirectoryExists($DOC_ROOT . $path)) {
         //check rights
         if (!$USER->CanDoFileOperation('fm_delete_folder', array($site, $path))) {
             return GetMessage("FILEMAN_FILEMAN_FOLDER_DEL_DENY") . " \"" . $path . "\".\n";
         }
     } else {
         return CFileman::DeleteFile(array($site, $path));
     }
     $strWarning = "";
     //get folder content
     $d = $io->GetDirectory($DOC_ROOT . $path);
     $arChildren = $d->GetChildren();
     foreach ($arChildren as $child) {
         $fn = $child->GetName();
         if ($child->IsDirectory()) {
             $strWarning .= CFileman::DeleteEx(array($site, $path . "/" . $fn));
         } else {
             if ($fn == ".access.php") {
                 continue;
             }
             $strWarning .= CFileman::DeleteFile(array($site, $path . "/" . $fn));
         }
     }
     //delete first folder
     $strWarning .= CFileMan::DeleteDir(array($site, $path));
     return $strWarning;
 }
Beispiel #6
0
}
// Building list
while ($Elem = $db_DirContent->NavNext(true, "f_")) {
    $arPath = array($site, $Elem['ABS_PATH']);
    $fpath = $bSearch ? $Elem['ABS_PATH'] : ($path == "/" ? "" : $path) . "/" . $Elem["NAME"];
    $fpathUrl = urlencode($fpath);
    for ($i = 0; $i < $cnt_resSites; $i++) {
        $dir = trim($resSites[$i]["DIR"], "/");
        if (substr(trim($fpath, "/"), 0, strlen($dir)) == $dir) {
            $site = $resSites[$i]["ID"];
            break;
        }
    }
    //$fname = $documentRoot.$path."/".$Elem["NAME"];
    $fname = $documentRoot . $fpath;
    $fnameConverted = CBXVirtualIoFileSystem::ConvertCharset($fname);
    //http://www.jabber.bx/view.php?id=26893
    $bIsDir = $io->DirectoryExists($fname);
    $arrIsDir[$fpath] = $bIsDir;
    if (!file_exists($fnameConverted)) {
        $lAdmin->AddGroupError(GetMessage("FILEMAN_ADMIN_FLIST_ERROR"));
        break;
    }
    if ($bSearch) {
        $f_NAME = $Elem['ABS_PATH'];
    }
    $showFieldIcon = "";
    $showFieldText = "";
    if ($Elem["TYPE"] == "D") {
        $showFieldIcon = "<a href=\"fileman_admin.php?" . $addUrl_s . "&site=" . urlencode($site) . "&path=" . $fpathUrl . "&show_perms_for=" . IntVal($show_perms_for) . "\" onclick=\"" . $sTableID . ".GetAdminList('fileman_admin.php?" . $addUrl_s . "&site=" . urlencode($site) . "&path=" . $fpathUrl . "&show_perms_for=" . IntVal($show_perms_for) . "', GALCallBack);return false;\"><span class='adm-submenu-item-link-icon fileman_icon_folder'></span></a>";
        $showFieldText = "<a href=\"fileman_admin.php?" . $addUrl_s . "&site=" . urlencode($site) . "&path=" . $fpathUrl . "&show_perms_for=" . IntVal($show_perms_for) . "\" onclick=\"" . $sTableID . ".GetAdminList('fileman_admin.php?" . $addUrl_s . "&site=" . urlencode($site) . "&path=" . $fpathUrl . "&show_perms_for=" . IntVal($show_perms_for) . "', GALCallBack);return false;\">" . $f_NAME . "</a>";
Beispiel #7
0
    $path = str_replace(array("///", "//"), "/", $path);
    if (!$ob->CheckName($name)) {
        $arFileError[] = array("id" => "bad_element_name", "text" => str_replace(array("#NAME#", "#SIZE#"), array($arFile["name"], $arParams["UPLOAD_MAX_FILESIZE"]), GetMessage("WD_ERROR_BAD_ELEMENT_NAME")));
    } elseif ($arParams["UPLOAD_MAX_FILESIZE_BYTE"] > 0 && $arFile["size"] > $arParams["UPLOAD_MAX_FILESIZE_BYTE"]) {
        $arFileError[] = array("id" => "max_file_size", "text" => str_replace(array("#NAME#", "#SIZE#"), array($arFile["name"], $arParams["UPLOAD_MAX_FILESIZE"]), GetMessage("WD_ERROR_UPLOAD_MAX_FILE_SIZE")));
    } elseif ($ob::GetIo()->DirectoryExists($path)) {
        $arFileError[] = array("id" => "double_name_section", "text" => str_replace("#NAME#", $arFile["name"], GetMessage("WD_ERROR_DOUBLE_NAME_SECTION")));
    } elseif ($_REQUEST["overview"] != "Y" && $ob::GetIo()->FileExists($path)) {
        if ($name != $arFile["name"]) {
            $arFileError[] = array("id" => "double_name_element", "text" => str_replace(array("#NAME#", "#TITLE#"), array($arFile["name"], $name), GetMessage("WD_ERROR_DOUBLE_NAME_TITLE")));
        } else {
            $arFileError[] = array("id" => "double_name_element", "text" => str_replace("#NAME#", $arFile["name"], GetMessage("WD_ERROR_DOUBLE_NAME_ELEMENT")));
        }
    } else {
        $options = array("path" => $path, "fopen" => "N");
        $arFile['tmp_name'] = CBXVirtualIoFileSystem::ConvertCharset($arFile['tmp_name'], CBXVirtualIoFileSystem::directionDecode);
        if (!$ob->PUT($options)) {
            $err = $GLOBALS["APPLICATION"]->GetException();
            $arFileError[] = array("id" => "bad_permission", "text" => is_object($err) ? $err->GetString() : "File has forbidden extention.");
        } elseif (!$ob::GetIo()->Copy($arFile["tmp_name"], $path)) {
            $arFileError[] = array("id" => "bad_upload", "text" => GetMessage("WD_ERROR_UPLOAD_FILE_NOT_LOAD"));
        } elseif (method_exists($ob, 'put_commit')) {
            $ob->put_commit($options);
        }
    }
    if (!empty($arFileError)) {
        $result = array("status" => "error", "error" => $arFileError);
    } else {
        $result = array("status" => "success");
    }
}
Beispiel #8
0
     $val = $arItem["PROPERTY_" . $arParams["PATH_TO_FILE"] . "_VALUE"];
     if (is_array($val)) {
         if (isset($val['path'])) {
             $PathToFile = $val['path'];
         }
         if (isset($val['duration'])) {
             $Duration = $val['duration'];
         }
     } else {
         $PathToFile = $arItem["PROPERTY_" . $arParams["PATH_TO_FILE"] . "_VALUE"];
     }
 }
 if ($PathToFile == "") {
     continue;
 }
 if ($PathToFile && file_exists(CBXVirtualIoFileSystem::ConvertCharset($_SERVER["DOCUMENT_ROOT"] . "/" . $PathToFile)) && is_file(CBXVirtualIoFileSystem::ConvertCharset($_SERVER["DOCUMENT_ROOT"] . "/" . $PathToFile))) {
     $FileSize = filesize($_SERVER["DOCUMENT_ROOT"] . "/" . $PathToFile);
     if ($FileSize) {
         $FileSize = round(sprintf("%u", $FileSize) / 1024 / 1024, 2);
     }
     if ($FileSize <= 0) {
         $FileSize = "";
     }
     $ext = strtolower(substr($PathToFile, -4));
     if ($ext == ".wmv" || $ext == ".wma") {
         $FileType = "wmv";
     } else {
         $FileType = "flv";
     }
 } elseif (CModule::IncludeModule("clouds") && ($uri = CCloudStorage::FindFileURIByURN($PathToFile, "component:iblock.tv, iblock:" . $arParams["IBLOCK_ID"] . ", element: " . $arItem["ID"])) !== "") {
     $PathToFile = $uri;
 function _processFileCallback($matches)
 {
     static $sImageAlign = '';
     $bLink = false;
     if ($matches[1] == ':') {
         $bLink = true;
     }
     // if the internal file then get it
     $sFile = $sFileName = $sPath = trim($matches[3]);
     $bOur = false;
     if (is_numeric($sFile) && in_array($sFile, $this->arFile)) {
         $arFile = CFile::GetFileArray($sFile);
         if ($arFile != false) {
             $bOur = true;
             $sPath = $arFile['SRC'];
             $sFileName = $arFile['ORIGINAL_NAME'];
         }
     } else {
         if (isset($this->arVersionFile[strtolower($sFile)])) {
             $sPath = $this->arVersionFile[strtolower($sFile)];
             $sFileName = $sFile;
         } else {
             if (!empty($this->arFile)) {
                 $arFilter = array('@ID' => implode(',', $this->arFile));
                 $rsFile = CFile::GetList(array(), $arFilter);
                 while ($arFile = $rsFile->Fetch()) {
                     if ($arFile['ORIGINAL_NAME'] == $sFile) {
                         $bOur = true;
                         $sFile = $arFile['ID'];
                         $sPath = CFile::GetFileSRC($arFile);
                         $sFileName = $arFile['ORIGINAL_NAME'];
                         break;
                     }
                 }
             }
         }
     }
     // if the image is processed as a picture
     $sName = bx_basename($sPath);
     if (CFile::IsImage($sName)) {
         if ($bOur) {
             $tmpName = $_SERVER["DOCUMENT_ROOT"] . $sPath;
             $imageFile = array("name" => $sFileName, "tmp_name" => CBXVirtualIoFileSystem::ConvertCharset($tmpName), "type" => CFile::GetContentType($tmpName));
             $checkRes = CFile::CheckImageFile($imageFile);
             if ($checkRes != null) {
                 return $checkRes;
             }
             if ($bLink) {
                 $sReturn = '<a href="' . htmlspecialcharsbx($sPath) . '" title="' . ($s = htmlspecialcharsbx($sFileName)) . '">' . $s . '</a>';
             } else {
                 $sReturn = CFile::ShowImage($sFile, COption::GetOptionString('wiki', 'image_max_width', 600), COption::GetOptionString('wiki', 'image_max_height', 600), 'border="0" align="' . $sImageAlign . '"');
             }
         } else {
             if ($bLink) {
                 $sReturn = '<a href="' . htmlspecialcharsbx($sPath) . '" title="' . ($s = htmlspecialcharsbx($sName)) . '">' . $s . '</a>';
             } else {
                 $sReturn = '<img src="' . htmlspecialcharsbx($sPath) . '" alt="' . htmlspecialcharsbx($sFileName) . '"/>';
             }
         }
     } else {
         if (strpos($sPath, 'http://') === 0) {
             $sReturn = ' [ <a href="' . htmlspecialcharsbx($sFile) . '" title="' . GetMessage('FILE_FILE_DOWNLOAD') . '">' . GetMessage('FILE_DOWNLOAD') . '</a> ] ';
         } else {
             $sReturn = '[' . GetMessage('FILE_NAME') . ':' . htmlspecialcharsbx(is_numeric($sFile) || empty($sFileName) ? $sFile : $sFileName) . ']';
         }
     }
     return $sReturn;
 }
Beispiel #10
0
		"DEFAULT" => true,
		"ACTION" => "javascript:".$sTableID.".GetAdminList('fileman_admin.php?".$addUrl_s."&site=".$site."&path=".urlencode($arParsedPath["PREV"])."&show_perms_for=".IntVal($show_perms_for)."', GALCallBack);"
	);

	$row->AddActions($arActions);
}

// Building list
while($Elem = $db_DirContent->NavNext(true, "f_"))
{
	$arPath = Array($site, $Elem['ABS_PATH']);
	$fpath = $bSearch ? $Elem['ABS_PATH'] : $path."/".$Elem["NAME"];
	$fpathUrl = urlencode($fpath);
	//$fname = $documentRoot.$path."/".$Elem["NAME"];
	$fname = $documentRoot.$fpath;
	$fnameConverted = CBXVirtualIoFileSystem::ConvertCharset($fname); //http://www.jabber.bx/view.php?id=26893

	if(!file_exists($fnameConverted))
	{
		$lAdmin->AddGroupError(GetMessage("FILEMAN_ADMIN_FLIST_ERROR"));
		break;
	}

	if ($bSearch)
		$f_NAME = $Elem['ABS_PATH'];

	$showFieldIcon = "";
	$showFieldText = "";
	if($Elem["TYPE"] == "D")
	{
		$showFieldIcon = "<a href=\"fileman_admin.php?".$addUrl_s."&site=".urlencode($site)."&path=".$fpathUrl."&show_perms_for=".IntVal($show_perms_for)."\" onclick=\"".$sTableID.".GetAdminList('fileman_admin.php?".$addUrl_s."&site=".urlencode($site)."&path=".$fpathUrl."&show_perms_for=".IntVal($show_perms_for)."', GALCallBack);return false;\"><span class='adm-submenu-item-link-icon fileman_icon_folder'></span></a>";