CanDoOperation('fileman_view_file_structure') || !$USER->CanDoFileOperation('fm_edit_existent_folder', array(SITE_ID, "/"))) $obJSPopup->ShowError(GetMessage("ACCESS_DENIED")); function __struct_file_sort($a, $b) { if($a["type"] == "D" && $b["type"] == "F") return -1; elseif($a["type"] == "F" && $b["type"] == "D") return 1; else { $name1 = ($a["name"] <> ''? $a["name"] : $a["file"]); $name2 = ($b["name"] <> ''? $b["name"] : $b["file"]); return strcmp(mb_strtoupper($name1), mb_strtoupper($name2)); } } function __struct_get_file_info($abs_path, $file) { static $arTextExt = array("php", "htm", "html"); $io = CBXVirtualIo::GetInstance(); $arFile = array("file"=>$file, "name"=>""); if($io->DirectoryExists($abs_path."/".$file)) { $arFile["type"] = "D"; if($io->FileExists($abs_path."/".$file."/.section.php")) { $sSectionName = ""; $arDirProperties = array(); include($io->GetPhysicalName($abs_path."/".$file."/.section.php")); $arFile["name"] = $sSectionName; $arFile["properties"] = $arDirProperties; } } else { $arFile["type"] = "F"; if(in_array(GetFileExtension($file), $arTextExt)) { $f = $io->GetFile($abs_path."/".$file); $sContent = $f->GetContents(); $arContent = ParseFileContent($sContent); $arFile["name"] = CUtil::ConvertToLangCharset($arContent["TITLE"]); $arFile["properties"] = $arContent["PROPERTIES"]; } } if($GLOBALS['arOptions']['show_file_info'] == true) { if ($io->DirectoryExists($abs_path."/".$file)) { $f = $io->GetDirectory($abs_path."/".$file); $arFile["time"] = $f->GetModificationTime(); } else { $f = $io->GetFile($abs_path."/".$file); $arFile["time"] = $f->GetModificationTime(); $arFile["size"] = $f->GetFileSize(); } } return $arFile; } function __struct_show_files($arFiles, $doc_root, $path, $open_path, $dirsonly=false) { global $USER; static $tzOffset = false; if($tzOffset === false) $tzOffset = CTimeZone::GetOffset(); $res = ''; $hintScript = ''; $scrDest = ''; $scrSrc = ''; foreach($arFiles as $arFile) { if($arFile["name"] == '' && $arFile["file"] <> "/" && $GLOBALS['arOptions']['show_all_files'] != true) continue; $full_path = rtrim($path, "/")."/".trim($arFile["file"], "/"); $encPath = urlencode($full_path); $name = ($arFile["name"] <> ''? htmlspecialcharsback($arFile["name"]):$arFile["file"]); $md5 = md5($full_path); if($dirsonly) $md5 = "_dirs".$md5; $itemID = 'item'.$md5; $item = ''; if($arFile["type"] == 'D') { $arPath = array($_GET['site'], $full_path); $arPerm = array( "create_file" => $USER->CanDoFileOperation("fm_create_new_file", $arPath), "create_folder" => $USER->CanDoFileOperation("fm_create_new_folder", $arPath), "edit_folder" => $USER->CanDoFileOperation("fm_edit_existent_folder", $arPath), "edit_perm" => $USER->CanDoFileOperation("fm_edit_permission", $arPath), "del_folder" => $USER->CanDoFileOperation("fm_delete_folder", $arPath), ); $bOpenSubdir = ($open_path <> "" && (mb_strpos($open_path."/", $full_path."/") === 0 || $arFile["file"] == "/")); $dirID = 'dir'.$md5; $item = '
'.htmlspecialcharsEx($name).'
'. ($bOpenSubdir? __struct_get_files($doc_root, $full_path, $open_path, $dirsonly):'').'
'; $scrDest .= ($scrDest <>''? ', ':'')."'".$itemID."'"; if($arFile["file"] <> '/') $scrSrc .= ($scrSrc <>''? ', ':'')."'".$itemID."', 'icon".$md5."'"; } elseif($dirsonly == false) { $arPath = array($_GET['site'], $full_path); $arPerm = array( "edit_file" => $USER->CanDoFileOperation("fm_edit_existent_file", $arPath), "edit_perm" => $USER->CanDoFileOperation("fm_edit_permission", $arPath), "del_file" => $USER->CanDoFileOperation("fm_delete_file", $arPath), ); if($GLOBALS['bFileman'] == true && $GLOBALS['arOptions']['show_all_files'] == true) $type = CFileMan::GetFileTypeEx($arFile["file"]); else $type = ""; $item = '
'.htmlspecialcharsEx($name).'
'; $scrSrc .= ($scrSrc <>''? ', ':'')."'".$itemID."', 'icon".$md5."'"; } if($item <> '') $res .= '
'.$item.'
'; if($GLOBALS['arOptions']['show_file_info'] == true) { $sHint = ''. ''. ''. ($arFile["type"] == 'F'? '':''). ''; if(is_array($arFile["properties"])) foreach($arFile["properties"] as $prop_name => $prop_val) $sHint .= ''; $sHint .= '
'.($arFile["type"] == 'D'? GetMessage("pub_struct_folder"):GetMessage("pub_struct_file")).'
'.GetMessage("pub_struct_name").''.htmlspecialcharsEx($arFile["file"]).'
'.GetMessage("pub_struct_size")."".number_format($arFile["size"], 0, ".", ",")." ".GetMessage("pub_struct_byte").'
'.GetMessage("pub_struct_modified").''.htmlspecialcharsEx(ConvertTimeStamp($arFile["time"]+$tzOffset, 'FULL', $_GET['site'])).'
'.htmlspecialcharsEx($prop_name).':'.htmlspecialcharsEx($prop_val).'
'; $hintScript .= 'window.structHint'.$itemID.' = new BXHint(\''.CUtil::JSEscape($sHint).'\', document.getElementById(\''.$itemID.'\')); '; } } if($hintScript <> '') $res .= ''; if($GLOBALS['bFileman'] == true) $res .= ''; return $res; } function __struct_get_files($doc_root, $path="", $open_path="", $dirsonly=false) { global $USER; if(!$USER->CanDoFileOperation('fm_view_listing', array($_GET['site'], $path))) return ''; $arFiles = array(); $abs_path = $doc_root."/".$path; $io = CBXVirtualIo::GetInstance(); $directory = $io->GetDirectory($abs_path); $arChildren = $directory->GetChildren(); foreach ($arChildren as $child) { $n = $child->GetName(); if (!$child->IsDirectory()) { if($n == '.section.php' || $n == '.access.php') continue; if(preg_match('/^\.(.*)?\.menu\.(php|html|php3|php4|php5|php6|phtml)$/', $n)) continue; } $arFile = __struct_get_file_info($abs_path, $n); $arFiles[] = $arFile; } usort($arFiles, "__struct_file_sort"); return __struct_show_files($arFiles, $doc_root, $path, $open_path, $dirsonly); } $bFileman = CModule::IncludeModule('fileman'); $strWarning = ""; $DOC_ROOT = CSite::GetSiteDocRoot($_GET["site"]); $arOptions = CUserOptions::GetOption("public_structure", "options", array()); if(!isset($arOptions['show_file_info'])) $arOptions['show_file_info'] = true; $io = CBXVirtualIo::GetInstance(); // ********************************************** //ajax requests if (isset($_GET['ajax']) && $_GET['ajax'] == 'Y') { if($_GET['action'] == 'delfolder' && check_bitrix_sessid() && $bFileman) { $normPath = $io->CombinePath("/", $_GET["path"]); if($normPath <> "") $strWarning = CFileMan::DeleteEx(array($_GET["site"], $normPath)); $module_id = "fileman"; if(COption::GetOptionString($module_id, "log_page", "Y")=="Y") { $res_log['path'] = mb_substr($_GET["path"], 1); CEventLog::Log( "content", "SECTION_DELETE", "main", "", serialize($res_log) ); } } elseif(($_GET['action'] == 'copy' || $_GET['action'] == 'move') && check_bitrix_sessid() && $bFileman) { $normFrom = $io->CombinePath("/", $_GET["from"]); $name = ""; if(($pos = mb_strrpos($normFrom, "/")) !== false) $name = mb_substr($normFrom, $pos + 1); $normTo = $io->CombinePath("/", $_GET["to"]."/".$name); if($normFrom <> "" && $normTo <> "") $strWarning = CFileMan::CopyEx(array($_GET["site"], $normFrom), array($_GET["site"], $normTo), ($_GET['action'] == "move"? true : false)); } if(isset($_GET['show_all_files'])) $arOptions['show_all_files'] = ($_GET['show_all_files'] == 'Y'); if(isset($_GET['show_file_info'])) $arOptions['show_file_info'] = ($_GET['show_file_info'] == 'Y'); if(isset($_GET['show_all_files']) || isset($_GET['show_file_info'])) CUserOptions::SetOption("public_structure", "options", $arOptions); if (!empty($_GET['load_path'])) { echo __struct_get_files($DOC_ROOT, _normalizePath($_GET['load_path']), "", ($_GET['dirsonly']=='Y')); } elseif (isset($_GET['reload']) && $_GET['reload'] == 'Y') { //display first level tree $arRoot = __struct_get_file_info($DOC_ROOT, "/"); echo __struct_show_files(array($arRoot), $DOC_ROOT, "", _normalizePath($_GET["path"]), ($_GET['dirsonly']=='Y')); } if($strWarning <> "") { $obJSPopup->ShowValidationError($strWarning); echo ''; } } ?>