コード例 #1
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;
 }
コード例 #2
0
ファイル: file_dialog.php プロジェクト: spas-viktor/books
 function MakeNewDir($Params)
 {
     if (CModule::IncludeModule("fileman")) {
         global $USER, $APPLICATION;
         $io = CBXVirtualIo::GetInstance();
         $path = $io->CombinePath("/", $APPLICATION->UnJSEscape($Params['path']));
         $site = $Params['site'];
         $arPath = array($site, $path);
         $DOC_ROOT = CSite::GetSiteDocRoot($site);
         $abs_path = $DOC_ROOT . $path;
         $dirname = str_replace("/", "_", $APPLICATION->UnJSEscape($Params['name']));
         $strWarning = '';
         //Check access to folder
         if (!$USER->CanDoFileOperation('fm_create_new_folder', $arPath)) {
             $strWarning = GetMessage("ACCESS_DENIED");
         } else {
             if (!$io->DirectoryExists($abs_path)) {
                 $strWarning = GetMessage("FD_FOLDER_NOT_FOUND", array('#PATH#' => addslashes(htmlspecialcharsbx($path))));
             } else {
                 if (strlen($dirname) > 0 && ($mess = self::CheckFileName($dirname)) !== true) {
                     $strWarning = $mess;
                 } else {
                     if (strlen($dirname) <= 0) {
                         $strWarning = GetMessage("FD_NEWFOLDER_ENTER_NAME");
                     } else {
                         $pathto = Rel2Abs($path, $dirname);
                         if ($io->DirectoryExists($DOC_ROOT . $pathto)) {
                             $strWarning = GetMessage("FD_NEWFOLDER_EXISTS");
                         } else {
                             $strWarning = CFileMan::CreateDir(array($site, $pathto));
                         }
                     }
                 }
             }
         }
     } else {
         $strWarning = GetMessage("BX_FD_NO_FILEMAN");
     }
     self::EchoActionStatus($strWarning);
     if ($strWarning == '') {
         self::LoadItems(array('path' => $path, 'site' => $site, 'bAddToMenu' => $Params['bAddToMenu'], 'loadRecursively' => false, 'getFiles' => $Params['getFiles']));
     }
 }
コード例 #3
0
    public static function Init($Params)
    {
        global $USER;
        $arWarnings = array();
        if (!$USER->CanDoOperation('fileman_admin_files') && !$USER->CanDoOperation('fileman_admin_folders')) {
            $arWarnings[] = GetMessage('FM_UTIL_ACCESS_DENIED');
        }
        $io = CBXVirtualIo::GetInstance();
        if (count($arWarnings) == 0) {
            $pathTo = trim($Params['copyTo'], " /");
            $site = CFileMan::__CheckSite($_GET['site']);
            $siteTo = $Params['siteTo'] ? $Params['siteTo'] : $site;
            $pathTo = $pathTo == "" ? "/" : "/" . $pathTo . "/";
            $absPathTo = CSite::GetSiteDocRoot($siteTo) . $pathTo;
            $docRootFrom = CSite::GetSiteDocRoot($site);
            if (!$io->DirectoryExists($absPathTo)) {
                // Create destination directory
                $bAccess = $USER->CanDoOperation('fileman_admin_folders') && $USER->CanDoFileOperation('fm_create_new_folder', $pathTo);
                if ($Params['createCopyTo']) {
                    if ($bAccess) {
                        CFileMan::CreateDir(array($siteTo, $pathTo));
                    }
                } else {
                    ?>
<script>window.BXFM_NoCopyToDir = "<?php 
                    echo $bAccess ? "ask_user" : "access_denied";
                    ?>
";</script><?php 
                    return;
                }
            }
            foreach ($Params['arFiles'] as $file) {
                $filePath = $file['path'];
                $caseOption = $Params['caseOption'];
                if ($Params["userCaseLastPath"]) {
                    if ($Params["userCaseLastPath"] != $filePath) {
                        continue;
                    }
                    $caseOption = $Params['userCaseAnswer'];
                    if ($Params["userCaseToAll"]) {
                        $Params['caseOption'] = $caseOption;
                    }
                    $Params["userCaseLastPath"] = false;
                }
                $arPath_i = array($site, $filePath);
                $absPath_i = $docRootFrom . $filePath;
                $bDir_i = $io->DirectoryExists($absPath_i);
                $name_i = CFileman::GetFileName($filePath);
                $strWarn = "";
                // Check if file already exists in destination folder
                if ($io->FileExists($absPathTo . $name_i) || $bDir_i == $io->DirectoryExists($absPathTo . $name_i) && $bDir_i) {
                    $fTmp = $io->GetFile($absPathTo . $name_i);
                    $fTmp1 = $io->GetFile($absPath_i);
                    $altName = CFilemanCopy::GetAltFileName($absPathTo, $name_i, $bDir_i);
                    if ($caseOption == 'ask') {
                        ?>
<script>
						window.BXFM_fileExist = {
							fileOld: {
								name: "<?php 
                        echo CUtil::JSEscape($name_i);
                        ?>
",
								path: "<?php 
                        echo CUtil::JSEscape($pathTo . $name_i);
                        ?>
",
								site: "<?php 
                        echo CUtil::JSEscape($siteTo);
                        ?>
",
								bDir: <?php 
                        echo $bDir_i ? "true" : "false";
                        ?>
,
								size: "<?php 
                        echo $bDir_i ? '-' : CFile::FormatSize($fTmp->GetFileSize());
                        ?>
",
								date: "<?php 
                        echo date(CDatabase::DateFormatToPHP(CLang::GetDateFormat("FULL")), CFilemanUtils::GetModifyTime($absPathTo . $name_i) + CTimeZone::GetOffset());
                        ?>
"
							},
							fileNew: {
								alt_name: "<?php 
                        echo CUtil::JSEscape($altName);
                        ?>
",
								name: "<?php 
                        echo CUtil::JSEscape($name_i);
                        ?>
",
								path: "<?php 
                        echo CUtil::JSEscape($filePath);
                        ?>
",
								site: "<?php 
                        echo CUtil::JSEscape($site);
                        ?>
",
								bDir: <?php 
                        echo $bDir_i ? "true" : "false";
                        ?>
,
								size: "<?php 
                        echo $bDir_i ? '-' : CFile::FormatSize($fTmp1->GetFileSize());
                        ?>
",
								date: "<?php 
                        echo date(CDatabase::DateFormatToPHP(CLang::GetDateFormat("FULL")), CFilemanUtils::GetModifyTime($absPath_i) + CTimeZone::GetOffset());
                        ?>
"
							}
						};
						</script><?php 
                        return;
                    } elseif ($caseOption == 'replace') {
                        // We don't need to replace, couse it's one file
                        if (CFileMan::NormalizePath($pathTo . "/" . $name_i) == $filePath) {
                            continue;
                        }
                        $strWarn = CFileMan::CopyEx($arPath_i, array($siteTo, CFileMan::NormalizePath($pathTo . "/" . $name_i)), !$Params['bCopy'], true);
                        if ($strWarn != "") {
                            $arWarnings[] = $strWarn;
                            $log = false;
                        } elseif ($Params['bSearch'] && $Params['ssess'] && !$Params['bCopy']) {
                            CFilemanSearch::DelFromSearchResult($Params['ssess'], $filePath);
                        }
                    } elseif ($caseOption == 'auto_rename') {
                        $strWarn = CFileMan::CopyEx($arPath_i, array($siteTo, CFileMan::NormalizePath($pathTo . "/" . $altName)), !$Params['bCopy']);
                        if ($strWarn != "") {
                            $arWarnings[] = $strWarn;
                            $log = false;
                        } elseif ($Params['bSearch'] && $Params['ssess'] && !$Params['bCopy']) {
                            CFilemanSearch::DelFromSearchResult($Params['ssess'], $filePath);
                        }
                    } elseif ($caseOption == 'skip') {
                        continue;
                    }
                } else {
                    $strWarn = CFileMan::CopyEx($arPath_i, array($siteTo, CFileMan::NormalizePath($pathTo . "/" . $name_i)), !$Params['bCopy']);
                    if ($strWarn != "") {
                        $arWarnings[] = $strWarn;
                        $log = false;
                    } elseif ($Params['bSearch'] && $Params['ssess'] && !$Params['bCopy']) {
                        CFilemanSearch::DelFromSearchResult($Params['ssess'], $filePath);
                    }
                }
                $module_id = "fileman";
                if (COption::GetOptionString($module_id, "log_page", "Y") == "Y" && $log) {
                    $res_log['copy_to'] = substr($pathTo, 1);
                    $res_log['path'] = substr($filePath, 1);
                    if ($Params['bCopy'] == "copy") {
                        if (!$bDir_i) {
                            CEventLog::Log("content", "FILE_COPY", "fileman", "", serialize($res_log));
                        } else {
                            CEventLog::Log("content", "SECTION_COPY", "fileman", "", serialize($res_log));
                        }
                    } else {
                        if (!$bDir_i) {
                            CEventLog::Log("content", "FILE_MOVE", "fileman", "", serialize($res_log));
                        } else {
                            CEventLog::Log("content", "SECTION_MOVE", "fileman", "", serialize($res_log));
                        }
                    }
                }
            }
        }
        $arWarnings;
        ?>
<script>
		window.BXFM_result = {
			status: "<?php 
        echo count($arWarnings) > 0 ? 'errors' : 'ok';
        ?>
",
			errors: <?php 
        echo count($arWarnings) > 0 ? CUtil::PhpToJSObject($arWarnings) : '{}';
        ?>
		};
		</script><?php 
    }
コード例 #4
0
ファイル: fileman.php プロジェクト: Satariall/izurit
 function CopyEx($path_from, $path_to, $bDeleteAfterCopy = false, $bOverride = false)
 {
     global $APPLICATION, $USER;
     CMain::InitPathVars($site_from, $path_from);
     $DOC_ROOT_FROM = CSite::GetSiteDocRoot($site_from);
     CMain::InitPathVars($site_to, $path_to);
     $DOC_ROOT_TO = CSite::GetSiteDocRoot($site_to);
     $strWarning = '';
     //check: if we copy to the same directory
     if (strpos($DOC_ROOT_TO . $path_to . "/", $DOC_ROOT_FROM . $path_from . "/") === 0) {
         return GetMessage("FILEMAN_LIB_BAD_FOLDER") . ": \"" . $path_from . "\".\n";
     }
     $io = CBXVirtualIo::GetInstance();
     if ($io->DirectoryExists($DOC_ROOT_FROM . $path_from)) {
         // Minimal access - read/listing for copying files
         if (!$USER->CanDoFileOperation('fm_view_listing', array($site_from, $path_from))) {
             return GetMessage("FILEMAN_FILEMAN_FOLDER_READ_DENY") . " \"" . $path_from . "\".\n";
         }
         if ($bDeleteAfterCopy && !$USER->CanDoFileOperation('fm_delete_folder', array($site_from, $path_from))) {
             return GetMessage("FILEMAN_FILEMAN_FOLDER_DEL_DENY") . " \"" . $path_from . "\".\n";
         }
         //Check: folder exist or not
         $strWarTmp = CFileMan::CreateDir(array($site_to, $path_to));
         if (strlen($strWarTmp) > 0) {
             return $strWarTmp;
         }
         $APPLICATION->CopyFileAccessPermission(array($site_from, $path_from), array($site_to, $path_to));
     } else {
         // If we can write this file
         if (!$USER->CanDoFileOperation('fm_create_new_file', array($site_to, $path_to))) {
             return GetMessage("FILEMAN_FILEMAN_FILE_WRITE_DENY") . " \"" . $path_to . "\".\n";
         }
         // If we can't read source-file
         if (!$USER->CanDoFileOperation('fm_view_file', array($site_from, $path_from))) {
             return GetMessage("FILEMAN_FILEMAN_FILE_READ_DENY") . " \"" . $path_from . "\".\n";
         }
         // Copying php or system file without PHP or LPA access
         if (!($USER->CanDoOperation('edit_php') || $USER->CanDoFileOperation('fm_lpa', $arPath) || !(HasScriptExtension($Elem["NAME"]) || substr($Elem["NAME"], 0, 1) == "."))) {
             return GetMessage("FILEMAN_FILEMAN_FILE_READ_DENY") . " \"" . $path_from . "\".\n";
         }
         // If we can't move source-file
         if ($bDeleteAfterCopy && !$USER->CanDoFileOperation('fm_delete_file', array($site_from, $path_from))) {
             return GetMessage("FILEMAN_FILEMAN_FILE_DEL_DENY") . " \"" . $path_from . "\".\n";
         }
         //Check if folder already exist and trying to create if not
         $p = strrpos($path_to, "/");
         $path_to_dir = substr($path_to, 0, $p);
         $strWarTmp = CFileMan::CreateDir(array($site_to, $path_to_dir));
         if (strlen($strWarTmp) > 0) {
             return $strWarTmp;
         }
         if ($io->FileExists($DOC_ROOT_TO . $path_to) || $io->DirectoryExists($DOC_ROOT_TO . $path_to)) {
             if ($bOverride) {
                 $strWarn = CFileMan::DeleteEx(array($site_to, $path_to));
                 if ($strWarn != "") {
                     return $strWarn;
                 }
             } else {
                 return GetMessage("FILEMAN_FILEMAN_FILE_WITH_NAME") . " \"" . $path_to . "\" " . GetMessage("FILEMAN_FILEMAN_ALREADY_EXISTS") . "!\n";
             }
         }
         $APPLICATION->CopyFileAccessPermission(array($site_from, $path_from), array($site_to, $path_to));
         //************************** Quota **************************//
         if (COption::GetOptionInt("main", "disk_space") > 0) {
             $f = $io->GetFile($DOC_ROOT_FROM . $path_from);
             $size = $f->GetFileSize();
             $quota = new CDiskQuota();
             if (!$quota->checkDiskQuota(array("FILE_SIZE" => $size))) {
                 return $quota->LAST_ERROR;
             }
         }
         //************************** Quota **************************//
         // Copy file
         if (DEBUG_FILE_MAN) {
             echo "copy(" . $DOC_ROOT_FROM . $path_from . "," . $DOC_ROOT_TO . $path_to . ");<br>";
         }
         if (!$io->Copy($DOC_ROOT_FROM . $path_from, $DOC_ROOT_TO . $path_to)) {
             $strWarning .= GetMessage('FILEMAN_COPY_ERROR', array('#PATH_FROM#' => htmlspecialcharsex($path_from), '#PATH_TO#' => htmlspecialcharsex($path_to)));
         }
         //************************** Quota **************************//
         if (COption::GetOptionInt("main", "disk_space") > 0) {
             $quota->updateDiskQuota("file", $size, "copy");
         }
         //************************** Quota **************************//
         if (CModule::IncludeModule("search")) {
             $site = CSite::GetSiteByFullPath($DOC_ROOT_TO . $path_to);
             CSearch::ReIndexFile(array($site_to, $path_to), $site);
         }
         if ($bDeleteAfterCopy && strlen($strWarning) <= 0) {
             // If was command "delete after copy"?
             $strWarning .= CFileMan::DeleteFile(array($site_from, $path_from));
         }
         return $strWarning;
     }
     // Recursive
     $d = $io->GetDirectory($DOC_ROOT_FROM . $path_from);
     $arChildren = $d->GetChildren();
     foreach ($arChildren as $child) {
         $fn = $child->GetName();
         if ($child->IsDirectory()) {
             //go to recursion
             $strWarning .= CFileMan::CopyEx(array($site_from, $path_from . "/" . $fn), array($site_to, $path_to . "/" . $fn), $bDeleteAfterCopy, $bOverride);
             //back from recursion, in this subfolder all right
             //if($bDeleteAfterCopy) //necessary delete this subfolder
             //	$strWarning .= CFileMan::DeleteDir($path_from."/".$file);
         } else {
             if ($fn == ".access.php") {
                 continue;
             }
             //let's check, if we can to write there
             if (!$USER->CanDoFileOperation('fm_create_new_file', array($site_to, $path_to . "/" . $fn))) {
                 $strWarning .= GetMessage("FILEMAN_FILEMAN_FILE_WRITE_DENY") . " \"" . $path_to . "/" . $fn . "\".\n";
             } elseif (!$USER->CanDoFileOperation('fm_view_file', array($site_from, $path_from . "/" . $fn))) {
                 $strWarning .= GetMessage("FILEMAN_FILEMAN_FILE_READ_DENY") . " \"" . $path_from . "/" . $fn . "\".\n";
             } elseif (!($USER->CanDoOperation('edit_php') || $USER->CanDoFileOperation('fm_lpa', array($site_from, $path_from . "/" . $fn)) || !(HasScriptExtension($fn) || substr($fn, 0, 1) == "."))) {
                 $strWarning .= GetMessage("FILEMAN_FILEMAN_FILE_READ_DENY") . " \"" . $path_from . "/" . $fn . "\".\n";
             } else {
                 if ($io->FileExists($DOC_ROOT_TO . $path_to . "/" . $fn)) {
                     if ($bOverride) {
                         $strWarn = CFileMan::DeleteEx(array($site_to, $path_to . "/" . $fn));
                         if ($strWarn != "") {
                             $strWarning .= $strWarn . "\n";
                         }
                     } else {
                         $strWarning .= GetMessage("FILEMAN_FILEMAN_FILE_WITH_NAME") . " \"" . $path_to . "/" . $fn . "\" " . GetMessage("FILEMAN_FILEMAN_ALREADY_EXISTS") . "!\n";
                     }
                 }
                 if ($strWarning == "") {
                     //it means we can copy, if we found here
                     $APPLICATION->CopyFileAccessPermission(array($site_from, $path_from . "/" . $fn), array($site_to, $path_to . "/" . $fn));
                     if (DEBUG_FILE_MAN) {
                         echo "copy(" . $DOC_ROOT_FROM . $path_from . "/" . $fn . "," . $DOC_ROOT_TO . $path_to . "/" . $fn . ");<br>";
                     }
                     if (!$io->Copy($DOC_ROOT_FROM . $path_from . "/" . $fn, $DOC_ROOT_TO . $path_to . "/" . $fn)) {
                         $strWarning .= GetMessage('FILEMAN_COPY_ERROR', array('#PATH_FROM#' => htmlspecialcharsex($path_from . "/" . $fn), '#PATH_TO#' => htmlspecialcharsex($path_to . "/" . $fn)));
                     }
                     //************************** Quota **************************//
                     if (COption::GetOptionInt("main", "disk_space") > 0) {
                         $f = $io->GetFile($DOC_ROOT_TO . $path_to . "/" . $fn);
                         $quota = new CDiskQuota();
                         $quota->updateDiskQuota("file", $f->GetFileSize(), "copy");
                     }
                     //************************** Quota **************************//
                     if (CModule::IncludeModule("search")) {
                         $site = CSite::GetSiteByFullPath($DOC_ROOT_TO, $path_to . "/" . $fn);
                         CSearch::ReindexFile($path_to . "/" . $fn, $site);
                     }
                     if ($bDeleteAfterCopy && strlen($strWarning) <= 0) {
                         $strWarning .= CFileMan::DeleteFile(array($site_from, $path_from . "/" . $fn));
                     }
                 }
             }
         }
     }
     //we may be need, to delete our initial folder
     if ($bDeleteAfterCopy) {
         $strWarning .= CFileMan::DeleteDir(array($site_from, $path_from));
     }
     return $strWarning;
 }
コード例 #5
0
ファイル: fileman_rename.php プロジェクト: spas-viktor/books
     $strWarning .= GetMessage("FILEMAN_RENAME_NEW_NAME") . " \"" . $file . "\"!\n";
 } elseif (($mess = CFileMan::CheckFileName($newfilename)) !== true) {
     $strWarning = $mess;
 } else {
     $pathto = Rel2Abs($path, $newfilename);
     if (!$USER->CanDoFileOperation('fm_create_new_file', array($site, $pathto))) {
         $strWarning .= GetMessage("FILEMAN_RENAME_ACCESS_ERROR") . "\n";
     } elseif (!$USER->CanDoOperation('edit_php') && (substr(CFileman::GetFileName($file), 0, 1) == "." || substr(CFileman::GetFileName($pathto), 0, 1) == "." || !HasScriptExtension($file) && HasScriptExtension($pathto))) {
         // if not admin and renaming from non PHP to PHP
         $strWarning .= GetMessage("FILEMAN_RENAME_TOPHPFILE_ERROR") . "\n";
     } elseif (!$USER->CanDoOperation('edit_php') && HasScriptExtension($file) && !HasScriptExtension($pathto)) {
         // if not admin and renaming from PHP to non PHP
         $strWarning .= GetMessage("FILEMAN_RENAME_FROMPHPFILE_ERROR") . "\n";
     } else {
         $pathparsedtmp = CFileMan::ParsePath(array($site, $pathto), false, false, "", $logical == "Y");
         $strWarningTmp = CFileMan::CreateDir($pathparsedtmp["PREV"]);
         if (strlen($strWarningTmp) > 0) {
             $strWarning .= $strWarningTmp;
         } else {
             if (!$io->FileExists($DOC_ROOT . $path . "/" . $file)) {
                 $strWarning .= GetMessage("FILEMAN_RENAME_FILE") . " \"" . $path . "/" . $file . "\" " . GetMessage("FILEMAN_RENAME_NOT_FOUND") . "!\n";
             } elseif (!$io->Rename($DOC_ROOT . $path . "/" . $file, $DOC_ROOT . $pathto)) {
                 $strWarning .= GetMessage("FILEMAN_RENAME_ERROR") . " \"" . $path . "/" . $file . "\" " . GetMessage("FILEMAN_RENAME_IN") . " \"" . $pathto . "\"!\n";
             } else {
                 $APPLICATION->CopyFileAccessPermission(array($site, $path . "/" . $file), array($site, $pathto));
                 $APPLICATION->RemoveFileAccessPermission(array($site, $path . "/" . $file));
                 $arParsedPathTmp = CFileMan::ParsePath(array($site, $pathto), false, false, "", $logical == "Y");
                 $arFiles[$ind] = $arParsedPathTmp["LAST"];
                 $pathTmp = $arParsedPathTmp["PREV"];
             }
         }
コード例 #6
0
    $strWarning = '<img src="/bitrix/images/fileman/deny.gif" width="28" height="28" border="0" align="left" alt="">' . GetMessage("ACCESS_DENIED");
} else {
    if (!$io->DirectoryExists($abs_path)) {
        $strWarning = GetMessage("FILEMAN_FOLDER_NOT_FOUND");
    } else {
        if ($REQUEST_METHOD == "POST" && strlen($save) > 0 && check_bitrix_sessid()) {
            if (strlen($foldername) <= 0) {
                $strWarning = GetMessage("FILEMAN_NEWFOLDER_ENTER_NAME");
            } elseif (($mess = CFileMan::CheckFileName($foldername)) !== true) {
                $strWarning = $mess;
            } else {
                $pathto = $io->CombinePath("/", $path, $foldername);
                if ($io->FileExists($DOC_ROOT . $pathto) || $io->DirectoryExists($DOC_ROOT . $pathto)) {
                    $strWarning = GetMessage("FILEMAN_NEWFOLDER_EXISTS");
                } else {
                    $strWarning = CFileMan::CreateDir(array($site, $pathto));
                    if (strlen($strWarning) <= 0) {
                        if ($USER->CanDoFileOperation('fm_add_to_menu', $arPath) && $USER->CanDoOperation('fileman_add_element_to_menu') && $mkmenu == "Y" && $bMenuTypeExists) {
                            $arParsedPathTmp = CFileMan::ParsePath(array($site, $pathto), true, false, "", $logical == "Y");
                            $menu_path = $arParsedPathTmp["PREV"] . "/." . $menutype . ".menu.php";
                            if ($USER->CanDoFileOperation('fm_view_file', array($site, $menu_path))) {
                                $res = CFileMan::GetMenuArray($DOC_ROOT . $menu_path);
                                $aMenuLinksTmp = $res["aMenuLinks"];
                                $sMenuTemplateTmp = $res["sMenuTemplate"];
                                $aMenuLinksTmp[] = array($menuname, $arParsedPathTmp["PREV"] . "/" . $arParsedPathTmp["LAST"] . "/", array(), array(), "");
                                CFileMan::SaveMenu(array($site, $menu_path), $aMenuLinksTmp, $sMenuTemplateTmp);
                                if (COption::GetOptionString($module_id, "log_menu", "Y") == "Y") {
                                    $mt = COption::GetOptionString("fileman", "menutypes", $default_value, $site);
                                    $mt = unserialize(str_replace("\\", "", $mt));
                                    $res_log['menu_name'] = $mt[$menutype];
                                    $res_log['path'] = substr($path, 1);