function checkrights($el, $rec = false) { $perms = show_perms($el); if (is_readable($el) && is_writeable($el)) { $color = 'green'; } else { $color = 'red'; } echo ' <tr> <td width="100%" class="row1" style="color: ' . $color . '">' . $el . '</td> <td class="row2" nowrap>' . show_perms($el) . '</td> </tr>'; if (is_dir($el) && $rec) { $dir = rcms_scandir($el); foreach ($dir as $del) { checkrights($el . '/' . $del, true); } } }
function dir_list_form() { global $fm_current_root, $current_dir, $quota_mb, $resolveIDs, $order_dir_list_by, $islinux, $cmd_name, $ip, $path_info, $fm_color; $ti = getmicrotime(); clearstatcache(); $out = "<table border=0 cellspacing=1 cellpadding=4 width=\"100%\" bgcolor=\"#eeeeee\">\n"; if ($opdir = @opendir($current_dir)) { $has_files = false; $entry_count = 0; $total_size = 0; $entry_list = array(); while ($file = readdir($opdir)) { if ($file != "." && $file != "..") { $entry_list[$entry_count]["size"] = 0; $entry_list[$entry_count]["sizet"] = 0; $entry_list[$entry_count]["type"] = "none"; if (is_file($current_dir . $file)) { $ext = lowercase(strrchr($file, ".")); $entry_list[$entry_count]["type"] = "file"; // Função filetype() returns only "file"... $entry_list[$entry_count]["size"] = filesize($current_dir . $file); $entry_list[$entry_count]["sizet"] = format_size($entry_list[$entry_count]["size"]); if (strstr($ext, ".")) { $entry_list[$entry_count]["ext"] = $ext; $entry_list[$entry_count]["extt"] = $ext; } else { $entry_list[$entry_count]["ext"] = ""; $entry_list[$entry_count]["extt"] = " "; } $has_files = true; } elseif (is_dir($current_dir . $file)) { // Recursive directory size disabled // $entry_list[$entry_count]["size"] = total_size($current_dir.$file); $entry_list[$entry_count]["size"] = 0; $entry_list[$entry_count]["sizet"] = " "; $entry_list[$entry_count]["type"] = "dir"; } $entry_list[$entry_count]["name"] = $file; $entry_list[$entry_count]["date"] = date("Ymd", filemtime($current_dir . $file)); $entry_list[$entry_count]["time"] = date("his", filemtime($current_dir . $file)); $entry_list[$entry_count]["datet"] = date("d/m/y h:i", filemtime($current_dir . $file)); if ($islinux && $resolveIDs) { $entry_list[$entry_count]["p"] = show_perms(fileperms($current_dir . $file)); $entry_list[$entry_count]["u"] = get_user(fileowner($current_dir . $file)); $entry_list[$entry_count]["g"] = get_group(filegroup($current_dir . $file)); } else { $entry_list[$entry_count]["p"] = base_convert(fileperms($current_dir . $file), 10, 8); $entry_list[$entry_count]["p"] = substr($entry_list[$entry_count]["p"], strlen($entry_list[$entry_count]["p"]) - 3); $entry_list[$entry_count]["u"] = fileowner($current_dir . $file); $entry_list[$entry_count]["g"] = filegroup($current_dir . $file); } $total_size += $entry_list[$entry_count]["size"]; $entry_count++; } } @closedir($opdir); if ($entry_count) { $or1 = "1A"; $or2 = "2D"; $or3 = "3A"; $or4 = "4A"; $or5 = "5A"; $or6 = "6D"; $or7 = "7D"; switch ($order_dir_list_by) { case "1A": $entry_list = array_csort($entry_list, "type", SORT_STRING, SORT_ASC, "name", SORT_STRING, SORT_ASC); $or1 = "1D"; break; case "1D": $entry_list = array_csort($entry_list, "type", SORT_STRING, SORT_ASC, "name", SORT_STRING, SORT_DESC); $or1 = "1A"; break; case "2A": $entry_list = array_csort($entry_list, "type", SORT_STRING, SORT_ASC, "p", SORT_STRING, SORT_ASC, "g", SORT_STRING, SORT_ASC, "u", SORT_STRING, SORT_ASC); $or2 = "2D"; break; case "2D": $entry_list = array_csort($entry_list, "type", SORT_STRING, SORT_ASC, "p", SORT_STRING, SORT_DESC, "g", SORT_STRING, SORT_ASC, "u", SORT_STRING, SORT_ASC); $or2 = "2A"; break; case "3A": $entry_list = array_csort($entry_list, "type", SORT_STRING, SORT_ASC, "u", SORT_STRING, SORT_ASC, "g", SORT_STRING, SORT_ASC); $or3 = "3D"; break; case "3D": $entry_list = array_csort($entry_list, "type", SORT_STRING, SORT_ASC, "u", SORT_STRING, SORT_DESC, "g", SORT_STRING, SORT_ASC); $or3 = "3A"; break; case "4A": $entry_list = array_csort($entry_list, "type", SORT_STRING, SORT_ASC, "g", SORT_STRING, SORT_ASC, "u", SORT_STRING, SORT_DESC); $or4 = "4D"; break; case "4D": $entry_list = array_csort($entry_list, "type", SORT_STRING, SORT_ASC, "g", SORT_STRING, SORT_DESC, "u", SORT_STRING, SORT_DESC); $or4 = "4A"; break; case "5A": $entry_list = array_csort($entry_list, "type", SORT_STRING, SORT_ASC, "size", SORT_NUMERIC, SORT_ASC); $or5 = "5D"; break; case "5D": $entry_list = array_csort($entry_list, "type", SORT_STRING, SORT_ASC, "size", SORT_NUMERIC, SORT_DESC); $or5 = "5A"; break; case "6A": $entry_list = array_csort($entry_list, "type", SORT_STRING, SORT_ASC, "date", SORT_STRING, SORT_ASC, "time", SORT_STRING, SORT_ASC, "name", SORT_STRING, SORT_ASC); $or6 = "6D"; break; case "6D": $entry_list = array_csort($entry_list, "type", SORT_STRING, SORT_ASC, "date", SORT_STRING, SORT_DESC, "time", SORT_STRING, SORT_DESC, "name", SORT_STRING, SORT_ASC); $or6 = "6A"; break; case "7A": $entry_list = array_csort($entry_list, "type", SORT_STRING, SORT_ASC, "ext", SORT_STRING, SORT_ASC, "name", SORT_STRING, SORT_ASC); $or7 = "7D"; break; case "7D": $entry_list = array_csort($entry_list, "type", SORT_STRING, SORT_ASC, "ext", SORT_STRING, SORT_DESC, "name", SORT_STRING, SORT_ASC); $or7 = "7A"; break; } } $out .= "\r\n <script language=\"Javascript\" type=\"text/javascript\">\r\n <!--\r\n function go(arg) {\r\n document.location.href='" . addslashes($path_info["basename"]) . "?frame=3¤t_dir=" . addslashes($current_dir) . "'+arg+'/';\r\n }\r\n function resolveIDs() {\r\n document.location.href='" . addslashes($path_info["basename"]) . "?frame=3&set_resolveIDs=1¤t_dir=" . addslashes($current_dir) . "';\r\n }\r\n var entry_list = new Array();\r\n // Custom object constructor\r\n function entry(name, type, size, selected){\r\n this.name = name;\r\n this.type = type;\r\n this.size = size;\r\n this.selected = false;\r\n }\r\n // Declare entry_list for selection procedures"; foreach ($entry_list as $i => $data) { $out .= "\nentry_list['entry{$i}'] = new entry('" . addslashes($data["name"]) . "', '" . $data["type"] . "', " . $data["size"] . ", false);"; } $out .= "\r\n // Select/Unselect Rows OnClick/OnMouseOver\r\n var lastRows = new Array(null,null);\r\n function selectEntry(Row, Action){\r\n if (multipleSelection){\r\n // Avoid repeated onmouseover events from same Row ( cell transition )\r\n if (Row != lastRows[0]){\r\n if (Action == 'over') {\r\n if (entry_list[Row.id].selected){\r\n if (unselect(entry_list[Row.id])) {\r\n Row.className = 'entryUnselected';\r\n }\r\n // Change the last Row when you change the movement orientation\r\n if (lastRows[0] != null && lastRows[1] != null){\r\n var LastRowID = lastRows[0].id;\r\n if (Row.id == lastRows[1].id){\r\n if (unselect(entry_list[LastRowID])) {\r\n lastRows[0].className = 'entryUnselected';\r\n }\r\n }\r\n }\r\n } else {\r\n if (select(entry_list[Row.id])){\r\n Row.className = 'entrySelected';\r\n }\r\n // Change the last Row when you change the movement orientation\r\n if (lastRows[0] != null && lastRows[1] != null){\r\n var LastRowID = lastRows[0].id;\r\n if (Row.id == lastRows[1].id){\r\n if (select(entry_list[LastRowID])) {\r\n lastRows[0].className = 'entrySelected';\r\n }\r\n }\r\n }\r\n }\r\n lastRows[1] = lastRows[0];\r\n lastRows[0] = Row;\r\n }\r\n }\r\n } else {\r\n if (Action == 'click') {\r\n var newClassName = null;\r\n if (entry_list[Row.id].selected){\r\n if (unselect(entry_list[Row.id])) newClassName = 'entryUnselected';\r\n } else {\r\n if (select(entry_list[Row.id])) newClassName = 'entrySelected';\r\n }\r\n if (newClassName) {\r\n lastRows[0] = lastRows[1] = Row;\r\n Row.className = newClassName;\r\n }\r\n }\r\n }\r\n return true;\r\n }\r\n // Disable text selection and bind multiple selection flag\r\n var multipleSelection = false;\r\n if (is.ie) {\r\n document.onselectstart=new Function('return false');\r\n document.onmousedown=switch_flag_on;\r\n document.onmouseup=switch_flag_off;\r\n // Event mouseup is not generated over scrollbar.. curiously, mousedown is.. go figure.\r\n window.onscroll=new Function('multipleSelection=false');\r\n window.onresize=new Function('multipleSelection=false');\r\n } else {\r\n if (document.layers) window.captureEvents(Event.MOUSEDOWN);\r\n if (document.layers) window.captureEvents(Event.MOUSEUP);\r\n window.onmousedown=switch_flag_on;\r\n window.onmouseup=switch_flag_off;\r\n }\r\n // Using same function and a ternary operator couses bug on double click\r\n function switch_flag_on(e) {\r\n if (is.ie){\r\n multipleSelection = (event.button == 1);\r\n } else {\r\n multipleSelection = (e.which == 1);\r\n }\r\n\t\t\tvar type = String(e.target.type);\r\n\t\t\treturn (type.indexOf('select') != -1 || type.indexOf('button') != -1 || type.indexOf('input') != -1 || type.indexOf('radio') != -1);\r\n }\r\n function switch_flag_off(e) {\r\n if (is.ie){\r\n multipleSelection = (event.button != 1);\r\n } else {\r\n multipleSelection = (e.which != 1);\r\n }\r\n lastRows[0] = lastRows[1] = null;\r\n update_sel_status();\r\n return false;\r\n }\r\n var total_dirs_selected = 0;\r\n var total_files_selected = 0;\r\n function unselect(Entry){\r\n if (!Entry.selected) return false;\r\n Entry.selected = false;\r\n sel_totalsize -= Entry.size;\r\n if (Entry.type == 'dir') total_dirs_selected--;\r\n else total_files_selected--;\r\n return true;\r\n }\r\n function select(Entry){\r\n if(Entry.selected) return false;\r\n Entry.selected = true;\r\n sel_totalsize += Entry.size;\r\n if(Entry.type == 'dir') total_dirs_selected++;\r\n else total_files_selected++;\r\n return true;\r\n }\r\n function is_anything_selected(){\r\n var selected_dir_list = new Array();\r\n var selected_file_list = new Array();\r\n for(var x=0;x<" . (int) count($entry_list) . ";x++){\r\n if(entry_list['entry'+x].selected){\r\n if(entry_list['entry'+x].type == 'dir') selected_dir_list.push(entry_list['entry'+x].name);\r\n else selected_file_list.push(entry_list['entry'+x].name);\r\n }\r\n }\r\n document.form_action.selected_dir_list.value = selected_dir_list.join('<|*|>');\r\n document.form_action.selected_file_list.value = selected_file_list.join('<|*|>');\r\n return (total_dirs_selected>0 || total_files_selected>0);\r\n }\r\n function format_size (arg) {\r\n var resul = '';\r\n if (arg>0){\r\n var j = 0;\r\n var ext = new Array(' bytes',' Kb',' Mb',' Gb',' Tb');\r\n while (arg >= Math.pow(1024,j)) ++j;\r\n resul = (Math.round(arg/Math.pow(1024,j-1)*100)/100) + ext[j-1];\r\n } else resul = 0;\r\n return resul;\r\n }\r\n var sel_totalsize = 0;\r\n function update_sel_status(){\r\n var t = total_dirs_selected+' " . et('Dir_s') . " " . et('And') . " '+total_files_selected+' " . et('File_s') . " " . et('Selected_s') . " = '+format_size(sel_totalsize);\r\n //document.getElementById(\"sel_status\").innerHTML = t;\r\n window.status = t;\r\n }\r\n // Select all/none/inverse\r\n function selectANI(Butt){\r\n \tcancel_copy_move();\r\n for(var x=0;x<" . (int) count($entry_list) . ";x++){\r\n var Row = document.getElementById('entry'+x);\r\n var newClassName = null;\r\n switch (Butt.value){\r\n case '" . et('SelAll') . "':\r\n if (select(entry_list[Row.id])) newClassName = 'entrySelected';\r\n break;\r\n case '" . et('SelNone') . "':\r\n if (unselect(entry_list[Row.id])) newClassName = 'entryUnselected';\r\n break;\r\n case '" . et('SelInverse') . "':\r\n if (entry_list[Row.id].selected){\r\n if (unselect(entry_list[Row.id])) newClassName = 'entryUnselected';\r\n } else {\r\n if (select(entry_list[Row.id])) newClassName = 'entrySelected';\r\n }\r\n break;\r\n }\r\n if (newClassName) {\r\n Row.className = newClassName;\r\n }\r\n }\r\n if (Butt.value == '" . et('SelAll') . "'){\r\n for(var i=0;i<2;i++){\r\n document.getElementById('ANI'+i).value='" . et('SelNone') . "';\r\n }\r\n } else if (Butt.value == '" . et('SelNone') . "'){\r\n for(var i=0;i<2;i++){\r\n document.getElementById('ANI'+i).value='" . et('SelAll') . "';\r\n }\r\n }\r\n update_sel_status();\r\n return true;\r\n }\r\n function download(arg){\r\n parent.frame1.location.href='" . addslashes($path_info["basename"]) . "?action=3¤t_dir=" . addslashes($current_dir) . "&filename='+escape(arg);\r\n }\r\n function upload(){\r\n var w = 400;\r\n var h = 250;\r\n window.open('" . addslashes($path_info["basename"]) . "?action=10¤t_dir=" . addslashes($current_dir) . "', '', 'width='+w+',height='+h+',fullscreen=no,scrollbars=no,resizable=yes,status=no,toolbar=no,menubar=no,location=no');\r\n }\r\n function execute_cmd(){\r\n var arg = prompt('" . et('TypeCmd') . ".');\r\n if(arg.length>0){\r\n if(confirm('" . et('ConfExec') . " \\' '+arg+' \\' ?')) {\r\n var w = 800;\r\n var h = 600;\r\n window.open('" . addslashes($path_info["basename"]) . "?action=6¤t_dir=" . addslashes($current_dir) . "&cmd='+escape(arg), '', 'width='+w+',height='+h+',fullscreen=no,scrollbars=yes,resizable=yes,status=no,toolbar=no,menubar=no,location=no');\r\n }\r\n }\r\n }\r\n function decompress(arg){\r\n if(confirm('" . uppercase(et('Decompress')) . " \\' '+arg+' \\' ?')) {\r\n document.form_action.action.value = 72;\r\n document.form_action.cmd_arg.value = arg;\r\n document.form_action.submit();\r\n }\r\n }\r\n function execute_file(arg){\r\n if(arg.length>0){\r\n if(confirm('" . et('ConfExec') . " \\' '+arg+' \\' ?')) {\r\n var w = 800;\r\n var h = 600;\r\n window.open('" . addslashes($path_info["basename"]) . "?action=11¤t_dir=" . addslashes($current_dir) . "&filename='+escape(arg), '', 'width='+w+',height='+h+',fullscreen=no,scrollbars=yes,resizable=yes,status=no,toolbar=no,menubar=no,location=no');\r\n }\r\n }\r\n }\r\n function edit_file(arg){\r\n var w = 1024;\r\n var h = 768;\r\n // if(confirm('" . uppercase(et('Edit')) . " \\' '+arg+' \\' ?'))\r\n window.open('" . addslashes($path_info["basename"]) . "?action=7¤t_dir=" . addslashes($current_dir) . "&filename='+escape(arg), '', 'width='+w+',height='+h+',fullscreen=no,scrollbars=no,resizable=yes,status=no,toolbar=no,menubar=no,location=no');\r\n }\r\n function config(){\r\n var w = 650;\r\n var h = 400;\r\n window.open('" . addslashes($path_info["basename"]) . "?action=2', 'win_config', 'width='+w+',height='+h+',fullscreen=no,scrollbars=yes,resizable=yes,status=no,toolbar=no,menubar=no,location=no');\r\n }\r\n function server_info(arg){\r\n var w = 800;\r\n var h = 600;\r\n window.open('" . addslashes($path_info["basename"]) . "?action=5', 'win_serverinfo', 'width='+w+',height='+h+',fullscreen=no,scrollbars=yes,resizable=yes,status=no,toolbar=no,menubar=no,location=no');\r\n }\r\n function shell(){\r\n var w = 800;\r\n var h = 600;\r\n window.open('" . addslashes($path_info["basename"]) . "?action=9', '', 'width='+w+',height='+h+',fullscreen=no,scrollbars=yes,resizable=yes,status=no,toolbar=no,menubar=no,location=no');\r\n }\r\n function view(arg){\r\n var w = 800;\r\n var h = 600;\r\n if(confirm('" . uppercase(et('View')) . " \\' '+arg+' \\' ?')) window.open('" . addslashes($path_info["basename"]) . "?action=4¤t_dir=" . addslashes($current_dir) . "&filename='+escape(arg), '', 'width='+w+',height='+h+',fullscreen=no,scrollbars=yes,resizable=yes,status=yes,toolbar=no,menubar=no,location=yes');\r\n }\r\n function rename(arg){\r\n var nome = '';\r\n if (nome = prompt('" . uppercase(et('Ren')) . " \\' '+arg+' \\' " . et('To') . " ...')) document.location.href='" . addslashes($path_info["basename"]) . "?frame=3&action=3¤t_dir=" . addslashes($current_dir) . "&old_name='+escape(arg)+'&new_name='+escape(nome);\r\n }\r\n function set_dir_dest(arg){\r\n document.form_action.dir_dest.value=arg;\r\n if (document.form_action.action.value.length>0) test(document.form_action.action.value);\r\n else alert('" . et('JSError') . ".');\r\n }\r\n function sel_dir(arg){\r\n document.form_action.action.value = arg;\r\n document.form_action.dir_dest.value='';\r\n if (!is_anything_selected()) alert('" . et('NoSel') . ".');\r\n else {\r\n if (!getCookie('sel_dir_warn')) {\r\n //alert('" . et('SelDir') . ".');\r\n document.cookie='sel_dir_warn'+'='+escape('true')+';';\r\n }\r\n set_sel_dir_warn(true);\r\n parent.frame2.set_flag(true);\r\n }\r\n }\r\n\t\tfunction set_sel_dir_warn(b){\r\n \tdocument.getElementById(\"sel_dir_warn\").style.display=(b?'':'none');\r\n\t\t}\r\n\t\tfunction cancel_copy_move(){\r\n \tset_sel_dir_warn(false);\r\n \tparent.frame2.set_flag(false);\r\n\t\t}\r\n function chmod_form(){\r\n cancel_copy_move();\r\n document.form_action.dir_dest.value='';\r\n document.form_action.chmod_arg.value='';\r\n if (!is_anything_selected()) alert('" . et('NoSel') . ".');\r\n else {\r\n var w = 280;\r\n var h = 180;\r\n window.open('" . addslashes($path_info["basename"]) . "?action=8', '', 'width='+w+',height='+h+',fullscreen=no,scrollbars=no,resizable=yes,status=no,toolbar=no,menubar=no,location=no');\r\n }\r\n }\r\n function set_chmod_arg(arg){\r\n cancel_copy_move();\r\n if (!is_anything_selected()) alert('" . et('NoSel') . ".');\r\n else {\r\n \tdocument.form_action.dir_dest.value='';\r\n \tdocument.form_action.chmod_arg.value=arg;\r\n \ttest(9);\r\n\t\t\t}\r\n }\r\n function test_action(){\r\n if (document.form_action.action.value != 0) return true;\r\n else return false;\r\n }\r\n function test_prompt(arg){\r\n \tcancel_copy_move();\r\n\t\t\tvar erro='';\r\n var conf='';\r\n if (arg == 1){\r\n document.form_action.cmd_arg.value = prompt('" . et('TypeDir') . ".');\r\n } else if (arg == 2){\r\n document.form_action.cmd_arg.value = prompt('" . et('TypeArq') . ".');\r\n } else if (arg == 71){\r\n if (!is_anything_selected()) erro = '" . et('NoSel') . ".';\r\n else document.form_action.cmd_arg.value = prompt('" . et('TypeArqComp') . "');\r\n }\r\n if (erro!=''){\r\n document.form_action.cmd_arg.focus();\r\n alert(erro);\r\n } else if(document.form_action.cmd_arg.value.length>0) {\r\n document.form_action.action.value = arg;\r\n document.form_action.submit();\r\n }\r\n }\r\n function strstr(haystack,needle){\r\n var index = haystack.indexOf(needle);\r\n return (index==-1)?false:index;\r\n }\r\n function valid_dest(dest,orig){\r\n return (strstr(dest,orig)==false)?true:false;\r\n }\r\n // ArrayAlert - Selection debug only\r\n function aa(){\r\n var str = 'selected_dir_list:\\n';\r\n for (x=0;x<selected_dir_list.length;x++){\r\n str += selected_dir_list[x]+'\\n';\r\n }\r\n str += '\\nselected_file_list:\\n';\r\n for (x=0;x<selected_file_list.length;x++){\r\n str += selected_file_list[x]+'\\n';\r\n }\r\n alert(str);\r\n }\r\n function test(arg){\r\n \tcancel_copy_move();\r\n var erro='';\r\n var conf='';\r\n if (arg == 4){\r\n if (!is_anything_selected()) erro = '" . et('NoSel') . ".\\n';\r\n conf = '" . et('RemSel') . " ?\\n';\r\n } else if (arg == 5){\r\n if (!is_anything_selected()) erro = '" . et('NoSel') . ".\\n';\r\n else if(document.form_action.dir_dest.value.length == 0) erro = '" . et('NoDestDir') . ".';\r\n else if(document.form_action.dir_dest.value == document.form_action.current_dir.value) erro = '" . et('DestEqOrig') . ".';\r\n else if(!valid_dest(document.form_action.dir_dest.value,document.form_action.current_dir.value)) erro = '" . et('InvalidDest') . ".';\r\n conf = '" . et('CopyTo') . " \\' '+document.form_action.dir_dest.value+' \\' ?\\n';\r\n } else if (arg == 6){\r\n if (!is_anything_selected()) erro = '" . et('NoSel') . ".';\r\n else if(document.form_action.dir_dest.value.length == 0) erro = '" . et('NoDestDir') . ".';\r\n else if(document.form_action.dir_dest.value == document.form_action.current_dir.value) erro = '" . et('DestEqOrig') . ".';\r\n else if(!valid_dest(document.form_action.dir_dest.value,document.form_action.current_dir.value)) erro = '" . et('InvalidDest') . ".';\r\n conf = '" . et('MoveTo') . " \\' '+document.form_action.dir_dest.value+' \\' ?\\n';\r\n } else if (arg == 9){\r\n if (!is_anything_selected()) erro = '" . et('NoSel') . ".';\r\n else if(document.form_action.chmod_arg.value.length == 0) erro = '" . et('NoNewPerm') . ".';\r\n //conf = '" . et('AlterPermTo') . " \\' '+document.form_action.chmod_arg.value+' \\' ?\\n';\r\n }\r\n if (erro!=''){\r\n document.form_action.cmd_arg.focus();\r\n alert(erro);\r\n } else if(conf!='') {\r\n if(confirm(conf)) {\r\n document.form_action.action.value = arg;\r\n document.form_action.submit();\r\n } else {\r\n set_sel_dir_warn(false);\r\n\t\t\t\t}\r\n } else {\r\n document.form_action.action.value = arg;\r\n document.form_action.submit();\r\n }\r\n }\r\n //-->\r\n </script>"; $out .= "\r\n <form name=\"form_action\" action=\"" . $path_info["basename"] . "\" method=\"post\" onsubmit=\"return test_action();\">\r\n <input type=hidden name=\"frame\" value=3>\r\n <input type=hidden name=\"action\" value=0>\r\n <input type=hidden name=\"dir_dest\" value=\"\">\r\n <input type=hidden name=\"chmod_arg\" value=\"\">\r\n <input type=hidden name=\"cmd_arg\" value=\"\">\r\n <input type=hidden name=\"current_dir\" value=\"{$current_dir}\">\r\n <input type=hidden name=\"dir_before\" value=\"{$dir_before}\">\r\n <input type=hidden name=\"selected_dir_list\" value=\"\">\r\n <input type=hidden name=\"selected_file_list\" value=\"\">"; $out .= "\r\n <tr>\r\n <td bgcolor=\"#DDDDDD\" colspan=50><nobr>\r\n <input type=button onclick=\"config()\" value=\"" . et('Config') . "\">\r\n <input type=button onclick=\"server_info()\" value=\"" . et('ServerInfo') . "\">\r\n <input type=button onclick=\"test_prompt(1)\" value=\"" . et('CreateDir') . "\">\r\n <input type=button onclick=\"test_prompt(2)\" value=\"" . et('CreateArq') . "\">\r\n <input type=button onclick=\"execute_cmd()\" value=\"" . et('ExecCmd') . "\">\r\n <input type=button onclick=\"upload()\" value=\"" . et('Upload') . "\">\r\n <input type=button onclick=\"shell()\" value=\"" . et('Shell') . "\">\r\n <b>{$ip}</b>\r\n </nobr>"; $uplink = ""; if ($current_dir != $fm_current_root) { $mat = explode("/", $current_dir); $dir_before = ""; for ($x = 0; $x < count($mat) - 2; $x++) { $dir_before .= $mat[$x] . "/"; } $uplink = "<a href=\"" . $path_info["basename"] . "?frame=3¤t_dir={$dir_before}\"><<</a> "; } if ($entry_count) { $out .= "\r\n <tr bgcolor=\"#DDDDDD\"><td colspan=50><nobr>{$uplink} <a href=\"" . $path_info["basename"] . "?frame=3¤t_dir={$current_dir}\">{$current_dir}</a></nobr>\r\n <tr>\r\n <td bgcolor=\"#DDDDDD\" colspan=50><nobr>\r\n <input type=\"button\" style=\"width:80\" onclick=\"selectANI(this)\" id=\"ANI0\" value=\"" . et('SelAll') . "\">\r\n <input type=\"button\" style=\"width:80\" onclick=\"selectANI(this)\" value=\"" . et('SelInverse') . "\">\r\n <input type=\"button\" style=\"width:80\" onclick=\"test(4)\" value=\"" . et('Rem') . "\">\r\n <input type=\"button\" style=\"width:80\" onclick=\"sel_dir(5)\" value=\"" . et('Copy') . "\">\r\n <input type=\"button\" style=\"width:80\" onclick=\"sel_dir(6)\" value=\"" . et('Move') . "\">\r\n <input type=\"button\" style=\"width:100\" onclick=\"test_prompt(71)\" value=\"" . et('Compress') . "\">"; if ($islinux) { $out .= "\r\n <input type=\"button\" style=\"width:100\" onclick=\"resolveIDs()\" value=\"" . et('ResolveIDs') . "\">"; } $out .= "\r\n <input type=\"button\" style=\"width:100\" onclick=\"chmod_form()\" value=\"" . et('Perms') . "\">"; $out .= "\r\n </nobr></td>\r\n </tr>\r\n\t\t\t\t<tr>\r\n <td bgcolor=\"#DDDDDD\" colspan=50 id=\"sel_dir_warn\" style=\"display:none\"><nobr><font color=\"red\">" . et('SelDir') . "...</font></nobr></td>\r\n </tr>"; $file_count = 0; $dir_count = 0; $dir_out = array(); $file_out = array(); $max_opt = 0; foreach ($entry_list as $ind => $dir_entry) { $file = $dir_entry["name"]; if ($dir_entry["type"] == "dir") { $dir_out[$dir_count] = array(); $dir_out[$dir_count][] = "\r\n <tr ID=\"entry{$ind}\" class=\"entryUnselected\" onmouseover=\"selectEntry(this, 'over');\" onmousedown=\"selectEntry(this, 'click');\">\r\n <td><nobr><a href=\"JavaScript:go('" . addslashes($file) . "')\">{$file}</a></nobr></td>"; $dir_out[$dir_count][] = "<td>" . $dir_entry["p"] . "</td>"; if ($islinux) { $dir_out[$dir_count][] = "<td><nobr>" . $dir_entry["u"] . "</nobr></td>"; $dir_out[$dir_count][] = "<td><nobr>" . $dir_entry["g"] . "</nobr></td>"; } $dir_out[$dir_count][] = "<td><nobr>" . $dir_entry["sizet"] . "</nobr></td>"; $dir_out[$dir_count][] = "<td><nobr>" . $dir_entry["datet"] . "</nobr></td>"; if ($has_files) { $dir_out[$dir_count][] = "<td> </td>"; } // Opções de diretório if (is_writable($current_dir . $file)) { $dir_out[$dir_count][] = "\r\n <td align=center><a href=\"JavaScript:if(confirm('" . et('ConfRem') . " \\'" . addslashes($file) . "\\' ?')) document.location.href='" . addslashes($path_info["basename"]) . "?frame=3&action=8&cmd_arg=" . addslashes($file) . "¤t_dir=" . addslashes($current_dir) . "'\">" . et('Rem') . "</a>"; } if (is_writable($current_dir . $file)) { $dir_out[$dir_count][] = "\r\n <td align=center><a href=\"JavaScript:rename('" . addslashes($file) . "')\">" . et('Ren') . "</a>"; } if (count($dir_out[$dir_count]) > $max_opt) { $max_opt = count($dir_out[$dir_count]); } $dir_count++; } else { $file_out[$file_count] = array(); $file_out[$file_count][] = "\r\n <tr ID=\"entry{$ind}\" class=\"entryUnselected\" onmouseover=\"selectEntry(this, 'over');\" onmousedown=\"selectEntry(this, 'click');\">\r\n <td><nobr><a href=\"JavaScript:download('" . addslashes($file) . "')\">{$file}</a></nobr></td>"; $file_out[$file_count][] = "<td>" . $dir_entry["p"] . "</td>"; if ($islinux) { $file_out[$file_count][] = "<td><nobr>" . $dir_entry["u"] . "</nobr></td>"; $file_out[$file_count][] = "<td><nobr>" . $dir_entry["g"] . "</nobr></td>"; } $file_out[$file_count][] = "<td><nobr>" . $dir_entry["sizet"] . "</nobr></td>"; $file_out[$file_count][] = "<td><nobr>" . $dir_entry["datet"] . "</nobr></td>"; $file_out[$file_count][] = "<td>" . $dir_entry["extt"] . "</td>"; // Opções de arquivo if (is_writable($current_dir . $file)) { $file_out[$file_count][] = "\r\n <td align=center><a href=\"javascript:if(confirm('" . uppercase(et('Rem')) . " \\'" . addslashes($file) . "\\' ?')) document.location.href='" . addslashes($path_info["basename"]) . "?frame=3&action=8&cmd_arg=" . addslashes($file) . "¤t_dir=" . addslashes($current_dir) . "'\">" . et('Rem') . "</a>"; } else { $file_out[$file_count][] = "<td> </td>"; } if (is_writable($current_dir . $file)) { $file_out[$file_count][] = "\r\n <td align=center><a href=\"javascript:rename('" . addslashes($file) . "')\">" . et('Ren') . "</a>"; } else { $file_out[$file_count][] = "<td> </td>"; } if (is_readable($current_dir . $file) && strpos(".wav#.mp3#.mid#.avi#.mov#.mpeg#.mpg#.rm#.iso#.bin#.img#.dll#.psd#.fla#.swf#.class#.ppt#.tif#.tiff#.pcx#.jpg#.gif#.png#.wmf#.eps#.bmp#.msi#.exe#.com#.rar#.tar#.zip#.bz2#.tbz2#.bz#.tbz#.bzip#.gzip#.gz#.tgz#", $dir_entry["ext"] . "#") === false) { $file_out[$file_count][] = "\r\n <td align=center><a href=\"javascript:edit_file('" . addslashes($file) . "')\">" . et('Edit') . "</a>"; } else { $file_out[$file_count][] = "<td> </td>"; } if (is_readable($current_dir . $file) && strpos(".txt#.sys#.bat#.ini#.conf#.swf#.php#.php3#.asp#.html#.htm#.jpg#.gif#.png#.bmp#", $dir_entry["ext"] . "#") !== false) { $file_out[$file_count][] = "\r\n <td align=center><a href=\"javascript:view('" . addslashes($file) . "');\">" . et('View') . "</a>"; } else { $file_out[$file_count][] = "<td> </td>"; } if (is_readable($current_dir . $file) && strlen($dir_entry["ext"]) && strpos(".tar#.zip#.bz2#.tbz2#.bz#.tbz#.bzip#.gzip#.gz#.tgz#", $dir_entry["ext"] . "#") !== false) { $file_out[$file_count][] = "\r\n <td align=center><a href=\"javascript:decompress('" . addslashes($file) . "')\">" . et('Decompress') . "</a>"; } else { $file_out[$file_count][] = "<td> </td>"; } if (is_readable($current_dir . $file) && strlen($dir_entry["ext"]) && strpos(".exe#.com#.sh#.bat#", $dir_entry["ext"] . "#") !== false) { $file_out[$file_count][] = "\r\n <td align=center><a href=\"javascript:execute_file('" . addslashes($file) . "')\">" . et('Exec') . "</a>"; } else { $file_out[$file_count][] = "<td> </td>"; } if (count($file_out[$file_count]) > $max_opt) { $max_opt = count($file_out[$file_count]); } $file_count++; } } if ($dir_count) { $out .= "\r\n <tr>\r\n <td bgcolor=\"#DDDDDD\"><nobr><a href=\"" . $path_info["basename"] . "?frame=3&or_by={$or1}¤t_dir={$current_dir}\">" . et('Name') . "</a></nobr></td>\r\n <td bgcolor=\"#DDDDDD\"><nobr><a href=\"" . $path_info["basename"] . "?frame=3&or_by={$or2}¤t_dir={$current_dir}\">" . et('Perm') . "</a></nobr></td>"; if ($islinux) { $out .= "\r\n <td bgcolor=\"#DDDDDD\"><nobr><a href=\"" . $path_info["basename"] . "?frame=3&or_by={$or3}¤t_dir={$current_dir}\">" . et('Owner') . "</a></td>\r\n <td bgcolor=\"#DDDDDD\"><nobr><a href=\"" . $path_info["basename"] . "?frame=3&or_by={$or4}¤t_dir={$current_dir}\">" . et('Group') . "</a></nobr></td>"; } $out .= "\r\n <td bgcolor=\"#DDDDDD\"><nobr><a href=\"" . $path_info["basename"] . "?frame=3&or_by={$or5}¤t_dir={$current_dir}\">" . et('Size') . "</a></nobr></td>\r\n <td bgcolor=\"#DDDDDD\"><nobr><a href=\"" . $path_info["basename"] . "?frame=3&or_by={$or6}¤t_dir={$current_dir}\">" . et('Date') . "</a></nobr></td>"; if ($file_count) { $out .= "\r\n <td bgcolor=\"#DDDDDD\"><nobr><a href=\"" . $path_info["basename"] . "?frame=3&or_by={$or7}¤t_dir={$current_dir}\">" . et('Type') . "</a></nobr></td>"; } $out .= "\r\n <td bgcolor=\"#DDDDDD\" colspan=50> </td>\r\n </tr>"; } foreach ($dir_out as $k => $v) { while (count($dir_out[$k]) < $max_opt) { $dir_out[$k][] = "<td> </td>"; } $out .= implode($dir_out[$k]); $out .= "</tr>"; } if ($file_count) { $out .= "\r\n <tr>\r\n <td bgcolor=\"#DDDDDD\"><nobr><a href=\"" . $path_info["basename"] . "?frame=3&or_by={$or1}¤t_dir={$current_dir}\">" . et('Name') . "</a></nobr></td>\r\n <td bgcolor=\"#DDDDDD\"><nobr><a href=\"" . $path_info["basename"] . "?frame=3&or_by={$or2}¤t_dir={$current_dir}\">" . et('Perm') . "</a></nobr></td>"; if ($islinux) { $out .= "\r\n <td bgcolor=\"#DDDDDD\"><nobr><a href=\"" . $path_info["basename"] . "?frame=3&or_by={$or3}¤t_dir={$current_dir}\">" . et('Owner') . "</a></td>\r\n <td bgcolor=\"#DDDDDD\"><nobr><a href=\"" . $path_info["basename"] . "?frame=3&or_by={$or4}¤t_dir={$current_dir}\">" . et('Group') . "</a></nobr></td>"; } $out .= "\r\n <td bgcolor=\"#DDDDDD\"><nobr><a href=\"" . $path_info["basename"] . "?frame=3&or_by={$or5}¤t_dir={$current_dir}\">" . et('Size') . "</a></nobr></td>\r\n <td bgcolor=\"#DDDDDD\"><nobr><a href=\"" . $path_info["basename"] . "?frame=3&or_by={$or6}¤t_dir={$current_dir}\">" . et('Date') . "</a></nobr></td>\r\n <td bgcolor=\"#DDDDDD\"><nobr><a href=\"" . $path_info["basename"] . "?frame=3&or_by={$or7}¤t_dir={$current_dir}\">" . et('Type') . "</a></nobr></td>\r\n <td bgcolor=\"#DDDDDD\" colspan=50> </td>\r\n </tr>"; } foreach ($file_out as $k => $v) { while (count($file_out[$k]) < $max_opt) { $file_out[$k][] = "<td> </td>"; } $out .= implode($file_out[$k]); $out .= "</tr>"; } $out .= "\r\n <tr>\r\n <td bgcolor=\"#DDDDDD\" colspan=50><nobr>\r\n <input type=\"button\" style=\"width:80\" onclick=\"selectANI(this)\" id=\"ANI1\" value=\"" . et('SelAll') . "\">\r\n <input type=\"button\" style=\"width:80\" onclick=\"selectANI(this)\" value=\"" . et('SelInverse') . "\">\r\n <input type=\"button\" style=\"width:80\" onclick=\"test(4)\" value=\"" . et('Rem') . "\">\r\n <input type=\"button\" style=\"width:80\" onclick=\"sel_dir(5)\" value=\"" . et('Copy') . "\">\r\n <input type=\"button\" style=\"width:80\" onclick=\"sel_dir(6)\" value=\"" . et('Move') . "\">\r\n <input type=\"button\" style=\"width:100\" onclick=\"test_prompt(71)\" value=\"" . et('Compress') . "\">"; if ($islinux) { $out .= "\r\n <input type=\"button\" style=\"width:100\" onclick=\"resolveIDs()\" value=\"" . et('ResolveIDs') . "\">"; } $out .= "\r\n <input type=\"button\" style=\"width:100\" onclick=\"chmod_form()\" value=\"" . et('Perms') . "\">"; $out .= "\r\n </nobr></td>\r\n </tr>"; $out .= "\r\n </form>"; $out .= "\r\n <tr><td bgcolor=\"#DDDDDD\" colspan=50><b>{$dir_count} " . et('Dir_s') . " " . et('And') . " {$file_count} " . et('File_s') . " = " . format_size($total_size) . "</td></tr>"; if ($quota_mb) { $out .= "\r\n <tr><td bgcolor=\"#DDDDDD\" colspan=50><b>" . et('Partition') . ": " . format_size($quota_mb * 1024 * 1024) . " " . et('Total') . " - " . format_size($quota_mb * 1024 * 1024 - total_size($fm_current_root)) . " " . et('Free') . "</td></tr>"; } else { $out .= "\r\n <tr><td bgcolor=\"#DDDDDD\" colspan=50><b>" . et('Partition') . ": " . format_size(disk_total_space($current_dir)) . " " . et('Total') . " - " . format_size(disk_free_space($current_dir)) . " " . et('Free') . "</td></tr>"; } $tf = getmicrotime(); $tt = $tf - $ti; $out .= "\r\n <tr><td bgcolor=\"#DDDDDD\" colspan=50><b>" . et('RenderTime') . ": " . substr($tt, 0, strrpos($tt, ".") + 5) . " " . et('Seconds') . "</td></tr>"; $out .= "\r\n <script language=\"Javascript\" type=\"text/javascript\">\r\n <!--\r\n update_sel_status();\r\n //-->\r\n </script>"; } else { $out .= "\r\n <tr>\r\n <td bgcolor=\"#DDDDDD\" width=\"1%\">{$uplink}<td bgcolor=\"#DDDDDD\" colspan=50><nobr><a href=\"" . $path_info["basename"] . "?frame=3¤t_dir={$current_dir}\">{$current_dir}</a></nobr>\r\n <tr><td bgcolor=\"#DDDDDD\" colspan=50>" . et('EmptyDir') . ".</tr>"; } } else { $out .= "<tr><td><font color=red>" . et('IOError') . ".<br>{$current_dir}</font>"; } $out .= "</table>"; echo $out; }
function Showbrowse_Img($spec) { extract($GLOBALS); $s = ""; $directory = ServerMapPath($spec); // if the path has a slash at the end we remove it here if (substr($directory, -1) == '/') { $directory = substr($directory, 0, -1); } $s = $s . "<table border=\"0\" cellspacing=\"1\" cellpadding=\"1\" valign=\"top\" id=\"FoldersAndFiles\" style=\"width:100%\" class=sortable>"; $s = $s . "<tr onMouseOver=\"row_over(this)\" onMouseOut=\"row_out(this)\" bgcolor=\"#f0f0f0\">"; $s = $s . "<td width=16 nowrap><img src=\"../Images/refresh.gif\" title=\"refresh\" onclick=\"parent.Refresh('" . $folpath . "');\" onMouseOver=\"parent.CuteEditor_ColorPicker_ButtonOver(this);\" style=\"VERTICAL-ALIGN: middle\"></td>"; $s = $s . "<td width=\"220\" Class=\"filelistHeadCol\"><b>Name</b></td>"; $s = $s . "<td width=50 nowrap Class=\"filelistHeadCol\"><b>Size</b></td>"; $s = $s . "<td width=50 nowrap Class=\"filelistHeadCol\"><b>Modified</b></td>"; // $s=$s."<td width=50 nowrap Class=\"filelistHeadCol\"><b>Created</b></td>"; $s = $s . "<td width=15 nowrap Class=\"filelistHeadCol\"><b>Attributes</b></td>"; $s = $s . "<td width=50 nowrap Class=\"filelistHeadCol\"><b>Type</b></td>"; if ($AllowDelete == "true") { $s = $s . "<td nowrap></td>"; } if ($AllowRename == "true") { $s = $s . "<td nowrap></td>"; } if ($AllowDelete == "true") { $s = $s . "<td nowrap></td>"; } $s = $s . "</tr>"; $s = $s . "<tr onMouseOver=\"row_over(this)\" onMouseOut=\"row_out(this)\" onclick=\"Editor_upfolder();\">"; $s = $s . "<td><img src=\"../Images/parentfolder.gif\" title=\"Go up one level\" style=\"VERTICAL-ALIGN: middle\"></td>"; $s = $s . "<td>...</td>"; $s = $s . "<td></td>"; $s = $s . "<td></td>"; $s = $s . "<td></td>"; $s = $s . "<td></td>"; if ($AllowDelete == "true") { $s = $s . "<td nowrap></td>"; } if ($AllowRename == "true") { $s = $s . "<td nowrap></td>"; } if ($AllowDelete == "true") { $s = $s . "<td nowrap></td>"; } $s = $s . "</tr>"; $dirlist = array(); $filelist = array(); // we open the directory if ($f = opendir($directory)) { while (($file = readdir($f)) !== false) { if ($file != "." && $file != "..") { $path = $directory . '/' . $file; if (is_file($path)) { $filelist[] = $file; } elseif (is_dir($path)) { $dirlist[] = $file; } } } closedir($f); } if ($dirlist) { asort($dirlist); while (list($key, $file) = each($dirlist)) { $file_stat = ServerMapPath($current_Path . $folpath . $file); $lastmod = date("m/d/Y", filemtime($file_stat)); $p; if (!(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')) { $p = show_perms(fileperms($file_stat)); } else { $p = base_convert(fileperms($file_stat), 10, 8); $p = substr($p, strlen($p) - 3); } //add the html for the folders $str_openfolderEvent = "onclick=\"parent.SetUpload_FolderPath('" . $current_Path . $folpath . $file . "');location.href='browse_Document.php?" . $setting . "&loc=" . $folpath . $file . "&Theme=" . $Theme . "&DP=" . $current_Path . "';\""; $s = $s . "<tr onMouseOver=\"row_over(this)\" onMouseOut=\"row_out(this)\">"; $s = $s . "<td " . $str_openfolderEvent . "><img vspace=\"0\" hspace=\"0\" src=\"../Images/closedfolder.gif\" style=\"VERTICAL-ALIGN: middle\"></td>" . "\r\n"; $s = $s . "<td valign=\"top\" style=\"cursor:pointer\" " . $str_openfolderEvent . ">" . "\r\n"; $s = $s . $file . " </td>" . "\r\n"; $s = $s . "<td nowrap style=\"cursor:pointer;\"></td>"; $s = $s . "<td nowrap>" . $lastmod . "</td>"; // $s=$s."<td nowrap>".$lastmod."</td>"; $s = $s . "<td nowrap>" . $p . "</td>"; $s = $s . "<td nowrap>Directory</td>"; if ($AllowDelete == "true") { $s = $s . "<td nowrap style=\"cursor:pointer; border:1px\" ><img vspace=\"0\" hspace=\"0\" src=\"../Images/delete.gif\" onclick=\"deletefolder('" . $current_Path . $folpath . $file . "')\" title=\"Delete\"></td>"; } if ($AllowRename == "true") { $s = $s . "<td nowrap style=\"cursor:pointer; border:1px\" ><img vspace=\"0\" hspace=\"0\" src=\"../Images/edit.gif\" title=\"Rename\" onclick=\"renamefolder('" . $current_Path . $folpath . $file . "')\"></td>"; } if ($AllowDelete == "true") { $s = $s . "<td ></td>"; } $s = $s . "</tr>" . "\r\n"; } } if ($filelist) { asort($filelist); while (list($key, $file) = each($filelist)) { if (ValidImage($file)) { $file_stat = stat(ServerMapPath($current_Path . $folpath . $file)); $size = FormatSize($file_stat[7]); $lastmod = date("m/d/Y", $file_stat[10]); //$created = date("m/d/Y",$file_stat[8]); //add the html for the folders $p; if (!(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')) { $p = show_perms(fileperms(ServerMapPath($current_Path . $folpath . $file))); } else { $p = base_convert(fileperms(ServerMapPath($current_Path . $folpath . $file)), 10, 8); $p = substr($p, strlen($p) - 3); } $f_Tooltip = ""; $f_Tooltip = $f_Tooltip . "<nobr>Name: " . $file . "</nobr><br>"; $f_Tooltip = $f_Tooltip . "<nobr>Size: " . $size . "</nobr><br>"; $f_Tooltip = $f_Tooltip . "<nobr>Date modified: " . $lastmod . "</nobr><br>"; $f_Tooltip = $f_Tooltip . "<nobr>Attributes: " . $p . "</nobr><br>"; $s = $s . "<tr onclick=\"parent.row_click('" . $current_Path . $folpath . $file . "','" . $f_Tooltip . "'); \" onMouseOver=\"row_over(this)\" onMouseOut=\"row_out(this)\">"; $s = $s . "<td><img vspace=\"0\" hspace=\"0\" src=\"../Images/" . strtolower(substr(strrchr($file, '.'), 1)) . ".gif\" style=\"VERTICAL-ALIGN: middle\"></td>" . "\r\n"; $s = $s . "<td valign=\"top\" style=\"cursor:pointer\" >" . "\r\n"; $s = $s . $file . " </td>" . "\r\n"; $s = $s . "<td nowrap style=\"cursor:pointer;\">" . $size . "</td>"; $s = $s . "<td nowrap>" . $lastmod . "</td>"; // $s=$s."<td nowrap>".$created."</td>"; $s = $s . "<td nowrap>" . $p . "</td>"; $s = $s . "<td nowrap>" . FindType(GetExtension($file)) . "</td>"; if ($AllowDelete == "true") { $s = $s . "<td nowrap style=\"cursor:pointer; border:1px\" ><img vspace=\"0\" hspace=\"0\" src=\"../Images/delete.gif\" onclick=\"deletefile('" . $current_Path . $folpath . $file . "')\" title=\"Delete\"></td>"; } if ($AllowRename == "true") { $s = $s . "<td nowrap style=\"cursor:pointer; border:1px\" ><img vspace=\"0\" hspace=\"0\" src=\"../Images/edit.gif\" title=\"Rename\" onclick=\"renamefile('" . $current_Path . $folpath . $file . "','{$file}')\"></td>"; } if ($AllowDelete == "true") { $s = $s . "<td nowrap style=\"cursor:pointer; border:1px\" ><img vspace=\"0\" hspace=\"0\" src=\"../Images/download.gif\" onclick=\"downloadfile('" . $current_Path . $folpath . $file . "')\" title=\"Download\"></td>"; } $s = $s . "</tr>" . "\r\n"; } } } $s = $s . "</table>"; return $s; }
function dir_list_form() { global $fm_root_atual, $dir_atual, $quota_mb, $resolveIDs, $order_dir_list_by, $islinux, $cmd_name, $ip, $is_reachable, $path_info, $fm_color; $ti = getmicrotime(); clearstatcache(); $out = "<table border=0 cellspacing=1 cellpadding=4 width=\"100%\" bgcolor=\"#eeeeee\">\n"; if ($opdir = @opendir($dir_atual)) { $entry_count = 0; $file_count = 0; $dir_count = 0; $total_size = 0; $uplink = ""; $entry_list = array(); $highlight_cols = 0; while ($file = readdir($opdir)) { if ($file != "." && $file != "..") { if (is_file($dir_atual . $file)) { $ext = strtolower(strrchr($file, ".")); $entry_list[$entry_count]["type"] = "file"; // Função filetype() returns only "file"... $entry_list[$entry_count]["size"] = filesize($dir_atual . $file); $entry_list[$entry_count]["sizet"] = getsize($dir_atual . $file); if (strstr($ext, ".")) { $entry_list[$entry_count]["ext"] = $ext; $entry_list[$entry_count]["extt"] = $ext; } else { $entry_list[$entry_count]["ext"] = ""; $entry_list[$entry_count]["extt"] = " "; } $file_count++; } elseif (is_dir($dir_atual . $file)) { // Recursive directory size disabled // $entry_list[$entry_count]["size"] = total_size($dir_atual.$file); $entry_list[$entry_count]["size"] = 0; $entry_list[$entry_count]["sizet"] = 0; $entry_list[$entry_count]["type"] = "dir"; $dir_count++; } $entry_list[$entry_count]["name"] = $file; $entry_list[$entry_count]["date"] = date("Ymd", filemtime($dir_atual . $file)); $entry_list[$entry_count]["time"] = date("his", filemtime($dir_atual . $file)); $entry_list[$entry_count]["datet"] = date("d/m/Y h:i:s", filemtime($dir_atual . $file)); if ($islinux && $resolveIDs) { $entry_list[$entry_count]["p"] = show_perms(fileperms($dir_atual . $file)); $entry_list[$entry_count]["u"] = getuser(fileowner($dir_atual . $file)); $entry_list[$entry_count]["g"] = getgroup(filegroup($dir_atual . $file)); } else { $entry_list[$entry_count]["p"] = base_convert(fileperms($dir_atual . $file), 10, 8); $entry_list[$entry_count]["p"] = substr($entry_list[$entry_count]["p"], strlen($entry_list[$entry_count]["p"]) - 3); $entry_list[$entry_count]["u"] = fileowner($dir_atual . $file); $entry_list[$entry_count]["g"] = filegroup($dir_atual . $file); } $total_size += $entry_list[$entry_count]["size"]; $entry_count++; } } closedir($opdir); if ($file_count) { $highlight_cols = $islinux ? 7 : 5; } else { $highlight_cols = $islinux ? 6 : 4; } if ($entry_count) { $or1 = "1A"; $or2 = "2D"; $or3 = "3A"; $or4 = "4A"; $or5 = "5A"; $or6 = "6D"; $or7 = "7D"; switch ($order_dir_list_by) { case "1A": $entry_list = array_csort($entry_list, "type", SORT_STRING, SORT_ASC, "name", SORT_STRING, SORT_ASC); $or1 = "1D"; break; case "1D": $entry_list = array_csort($entry_list, "type", SORT_STRING, SORT_ASC, "name", SORT_STRING, SORT_DESC); $or1 = "1A"; break; case "2A": $entry_list = array_csort($entry_list, "type", SORT_STRING, SORT_ASC, "p", SORT_STRING, SORT_ASC, "g", SORT_STRING, SORT_ASC, "u", SORT_STRING, SORT_ASC); $or2 = "2D"; break; case "2D": $entry_list = array_csort($entry_list, "type", SORT_STRING, SORT_ASC, "p", SORT_STRING, SORT_DESC, "g", SORT_STRING, SORT_ASC, "u", SORT_STRING, SORT_ASC); $or2 = "2A"; break; case "3A": $entry_list = array_csort($entry_list, "type", SORT_STRING, SORT_ASC, "u", SORT_STRING, SORT_ASC, "g", SORT_STRING, SORT_ASC); $or3 = "3D"; break; case "3D": $entry_list = array_csort($entry_list, "type", SORT_STRING, SORT_ASC, "u", SORT_STRING, SORT_DESC, "g", SORT_STRING, SORT_ASC); $or3 = "3A"; break; case "4A": $entry_list = array_csort($entry_list, "type", SORT_STRING, SORT_ASC, "g", SORT_STRING, SORT_ASC, "u", SORT_STRING, SORT_DESC); $or4 = "4D"; break; case "4D": $entry_list = array_csort($entry_list, "type", SORT_STRING, SORT_ASC, "g", SORT_STRING, SORT_DESC, "u", SORT_STRING, SORT_DESC); $or4 = "4A"; break; case "5A": $entry_list = array_csort($entry_list, "type", SORT_STRING, SORT_ASC, "size", SORT_NUMERIC, SORT_ASC); $or5 = "5D"; break; case "5D": $entry_list = array_csort($entry_list, "type", SORT_STRING, SORT_ASC, "size", SORT_NUMERIC, SORT_DESC); $or5 = "5A"; break; case "6A": $entry_list = array_csort($entry_list, "type", SORT_STRING, SORT_ASC, "date", SORT_STRING, SORT_ASC, "time", SORT_STRING, SORT_ASC, "name", SORT_STRING, SORT_ASC); $or6 = "6D"; break; case "6D": $entry_list = array_csort($entry_list, "type", SORT_STRING, SORT_ASC, "date", SORT_STRING, SORT_DESC, "time", SORT_STRING, SORT_DESC, "name", SORT_STRING, SORT_ASC); $or6 = "6A"; break; case "7A": $entry_list = array_csort($entry_list, "type", SORT_STRING, SORT_ASC, "ext", SORT_STRING, SORT_ASC, "name", SORT_STRING, SORT_ASC); $or7 = "7D"; break; case "7D": $entry_list = array_csort($entry_list, "type", SORT_STRING, SORT_ASC, "ext", SORT_STRING, SORT_DESC, "name", SORT_STRING, SORT_ASC); $or7 = "7A"; break; } } $out .= "\r\n <script language=\"Javascript\" type=\"text/javascript\">\r\n <!--\r\n function getCookieVal (offset) {\r\n var endstr = document.cookie.indexOf (';', offset);\r\n if (endstr == -1) endstr = document.cookie.length;\r\n return unescape(document.cookie.substring(offset, endstr));\r\n }\r\n function getCookie (name) {\r\n var arg = name + '=';\r\n var alen = arg.length;\r\n var clen = document.cookie.length;\r\n var i = 0;\r\n while (i < clen) {\r\n var j = i + alen;\r\n if (document.cookie.substring(i, j) == arg) return getCookieVal (j);\r\n i = document.cookie.indexOf(' ', i) + 1;\r\n if (i == 0) break;\r\n }\r\n return null;\r\n }\r\n function setCookie (name, value) {\r\n var argv = SetCookie.arguments;\r\n var argc = SetCookie.arguments.length;\r\n var expires = (argc > 2) ? argv[2] : null;\r\n var path = (argc > 3) ? argv[3] : null;\r\n var domain = (argc > 4) ? argv[4] : null;\r\n var secure = (argc > 5) ? argv[5] : false;\r\n document.cookie = name + '=' + escape (value) +\r\n ((expires == null) ? '' : ('; expires=' + expires.toGMTString())) +\r\n ((path == null) ? '' : ('; path=' + path)) +\r\n ((domain == null) ? '' : ('; domain=' + domain)) +\r\n ((secure == true) ? '; secure' : '');\r\n }\r\n function delCookie (name) {\r\n var exp = new Date();\r\n exp.setTime (exp.getTime() - 1);\r\n var cval = GetCookie (name);\r\n document.cookie = name + '=' + cval + '; expires=' + exp.toGMTString();\r\n }\r\n function go(arg) {\r\n document.location.href='" . $path_info["basename"] . "?frame=3&dir_atual={$dir_atual}'+arg+'/';\r\n }\r\n function resolveIDs() {\r\n document.location.href='" . $path_info["basename"] . "?frame=3&set_resolveIDs=1&dir_atual={$dir_atual}';\r\n }\r\n var entry_list = new Array();\r\n // Custom object constructor\r\n function entry(name, type, size, selected){\r\n this.name = name;\r\n this.type = type;\r\n this.size = size;\r\n this.selected = false;\r\n }\r\n // Declare entry_list for selection procedures"; foreach ($entry_list as $i => $data) { $out .= "\nentry_list['entry{$i}'] = new entry('" . $data["name"] . "', '" . $data["type"] . "', " . $data["size"] . ", false);"; } $out .= "\r\n // Select/Unselect Rows OnClick/OnMouseOver\r\n var lastRows = new Array(null,null);\r\n function selectEntry(Row, Action){\r\n var MarkColor = '#" . $fm_color['Mark'] . "';\r\n var Cells = Row.getElementsByTagName('td');\r\n if (multipleSelection){\r\n // Avoid repeated onmouseover events from same Row ( cell transition )\r\n if (Row != lastRows[0]){\r\n if (Action == 'over') {\r\n if (entry_list[Row.id].selected){\r\n if (entry_list[Row.id].type == 'dir') DefaultColor = '#" . $fm_color['Dir'] . "';\r\n else DefaultColor = '#" . $fm_color['File'] . "';\r\n if (unselect(entry_list[Row.id])) {\r\n for (var c=0; c < " . (int) $highlight_cols . "; c++) {\r\n if (c == 0 && entry_list[Row.id].type=='file' && !entry_list[Row.id].selected) Cells[c].style.backgroundColor = '#" . $fm_color['FileFirstCell'] . "';\r\n else Cells[c].style.backgroundColor = DefaultColor;\r\n }\r\n }\r\n // Change the last Row when you change the movement orientation\r\n if (lastRows[0] != null && lastRows[1] != null){\r\n var LastRowID = lastRows[0].id;\r\n var LastRowDefaultColor;\r\n if (entry_list[LastRowID].type == 'dir') LastRowDefaultColor = '#" . $fm_color['Dir'] . "';\r\n else LastRowDefaultColor = '#" . $fm_color['File'] . "';\r\n if (Row.id == lastRows[1].id){\r\n var LastRowCells = lastRows[0].getElementsByTagName('td');\r\n if (unselect(entry_list[LastRowID])) {\r\n for (var c=0; c < " . (int) $highlight_cols . "; c++) {\r\n if (c == 0 && entry_list[LastRowID].type=='file' && !entry_list[LastRowID].selected) LastRowCells[c].style.backgroundColor = '#" . $fm_color['FileFirstCell'] . "';\r\n else LastRowCells[c].style.backgroundColor = LastRowDefaultColor;\r\n }\r\n }\r\n }\r\n }\r\n } else {\r\n if (select(entry_list[Row.id])){\r\n for (var c=0; c < " . (int) $highlight_cols . "; c++) {\r\n if (c == 0 && entry_list[Row.id].type=='file' && !entry_list[Row.id].selected) Cells[c].style.backgroundColor = '#" . $fm_color['FileFirstCell'] . "';\r\n else Cells[c].style.backgroundColor = MarkColor;\r\n }\r\n }\r\n // Change the last Row when you change the movement orientation\r\n if (lastRows[0] != null && lastRows[1] != null){\r\n var LastRowID = lastRows[0].id;\r\n if (Row.id == lastRows[1].id){\r\n var LastRowCells = lastRows[0].getElementsByTagName('td');\r\n if (select(entry_list[LastRowID])) {\r\n for (var c=0; c < " . (int) $highlight_cols . "; c++) {\r\n if (c == 0 && entry_list[LastRowID].type=='file' && !entry_list[LastRowID].selected) LastRowCells[c].style.backgroundColor = '#" . $fm_color['FileFirstCell'] . "';\r\n else LastRowCells[c].style.backgroundColor = MarkColor;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n lastRows[1] = lastRows[0];\r\n lastRows[0] = Row;\r\n }\r\n }\r\n } else {\r\n if (Action == 'click') {\r\n var newColor = null;\r\n if (entry_list[Row.id].selected){\r\n var DefaultColor;\r\n if (entry_list[Row.id].type == 'dir') DefaultColor = '#" . $fm_color['Dir'] . "';\r\n else DefaultColor = '#" . $fm_color['File'] . "';\r\n if (unselect(entry_list[Row.id])) newColor = DefaultColor;\r\n } else {\r\n if (select(entry_list[Row.id])) newColor = MarkColor;\r\n }\r\n if (newColor) {\r\n lastRows[0] = lastRows[1] = Row;\r\n for (var c=0; c < " . (int) $highlight_cols . "; c++) {\r\n if (c == 0 && entry_list[Row.id].type=='file' && !entry_list[Row.id].selected) Cells[c].style.backgroundColor = '#" . $fm_color['FileFirstCell'] . "';\r\n else Cells[c].style.backgroundColor = newColor;\r\n }\r\n }\r\n }\r\n }\r\n return true;\r\n }\r\n // Disable text selection and bind multiple selection flag\r\n var multipleSelection = false;\r\n if (is.ie) {\r\n document.onselectstart=new Function('return false');\r\n document.onmousedown=switch_flag_on;\r\n document.onmouseup=switch_flag_off;\r\n // Event mouseup is not generated over scrollbar.. curiously, mousedown is.. go figure.\r\n window.onscroll=new Function('multipleSelection=false');\r\n } else {\r\n if (document.layers) window.captureEvents(Event.MOUSEDOWN);\r\n if (document.layers) window.captureEvents(Event.MOUSEUP);\r\n window.onmousedown=switch_flag_on;\r\n window.onmouseup=switch_flag_off;\r\n }\r\n // Using same function and a ternary operator couses bug on double click\r\n function switch_flag_on(e) {\r\n lastRows[0] = lastRows[1] = null;\r\n if (is.ie){\r\n multipleSelection = (event.button == 1);\r\n } else {\r\n multipleSelection = (e.which == 1);\r\n }\r\n return false;\r\n }\r\n function switch_flag_off(e) {\r\n if (is.ie){\r\n multipleSelection = (event.button != 1);\r\n } else {\r\n multipleSelection = (e.which != 1);\r\n }\r\n return false;\r\n }\r\n var total_dirs_selected = 0;\r\n var total_files_selected = 0;\r\n function unselect(Entry){\r\n if (!Entry.selected) return false;\r\n Entry.selected = false;\r\n sel_totalsize -= Entry.size;\r\n if (Entry.type == 'dir') total_dirs_selected--;\r\n else total_files_selected--;\r\n update_sel_status();\r\n return true;\r\n }\r\n function select(Entry){\r\n if(Entry.selected) return false;\r\n Entry.selected = true;\r\n sel_totalsize += Entry.size;\r\n if(Entry.type == 'dir') total_dirs_selected++;\r\n else total_files_selected++;\r\n update_sel_status();\r\n return true;\r\n }\r\n function is_anything_selected(){\r\n var selected_dir_list = new Array();\r\n var selected_file_list = new Array();\r\n for(var x=0;x<" . (int) count($entry_list) . ";x++){\r\n if(entry_list['entry'+x].selected){\r\n if(entry_list['entry'+x].type == 'dir') selected_dir_list.push(entry_list['entry'+x].name);\r\n else selected_file_list.push(entry_list['entry'+x].name);\r\n }\r\n }\r\n document.form_action.selected_dir_list.value = selected_dir_list.join('<|*|>');\r\n document.form_action.selected_file_list.value = selected_file_list.join('<|*|>');\r\n return (total_dirs_selected>0 || total_files_selected>0);\r\n }\r\n function formatsize (arg) {\r\n var resul = '';\r\n if (arg>0){\r\n var j = 0;\r\n var ext = new Array(' bytes',' Kb',' Mb',' Gb',' Tb');\r\n while (arg >= Math.pow(1024,j)) ++j;\r\n resul = (Math.round(arg/Math.pow(1024,j-1)*100)/100) + ext[j-1];\r\n } else resul = '0 Mb';\r\n return resul;\r\n }\r\n var sel_totalsize = 0;\r\n function update_sel_status(){\r\n var t = total_dirs_selected+' " . et('Dir_s') . " " . et('And') . " '+total_files_selected+' " . et('File_s') . " " . et('Selected_s') . " = '+formatsize(sel_totalsize);\r\n document.getElementById(\"sel_status\").innerHTML = t;\r\n }\r\n // Select all/none/inverse\r\n function selectANI(Butt){\r\n var MarkColor = '#" . $fm_color['Mark'] . "';\r\n for(var x=0;x<" . (int) count($entry_list) . ";x++){\r\n if (entry_list['entry'+x].type == 'dir'){\r\n var DefaultColor = '#" . $fm_color['Dir'] . "';\r\n } else {\r\n var DefaultColor = '#" . $fm_color['File'] . "';\r\n }\r\n var Row = document.getElementById('entry'+x);\r\n var Cells = Row.getElementsByTagName('td');\r\n var newColor = null;\r\n switch (Butt.value){\r\n case '" . et('SelAll') . "':\r\n if (select(entry_list[Row.id])) newColor = MarkColor;\r\n break;\r\n case '" . et('SelNone') . "':\r\n if (unselect(entry_list[Row.id])) newColor = DefaultColor;\r\n break;\r\n case '" . et('SelInverse') . "':\r\n if (entry_list[Row.id].selected){\r\n if (unselect(entry_list[Row.id])) newColor = DefaultColor;\r\n } else {\r\n if (select(entry_list[Row.id])) newColor = MarkColor;\r\n }\r\n break;\r\n }\r\n if (newColor) {\r\n for (var c=0; c < " . (int) $highlight_cols . "; c++) {\r\n if (entry_list[Row.id].type=='file' && c==0 && !entry_list[Row.id].selected) Cells[c].style.backgroundColor = '#" . $fm_color['FileFirstCell'] . "';\r\n else Cells[c].style.backgroundColor = newColor;\r\n }\r\n }\r\n }\r\n if (Butt.value == '" . et('SelAll') . "'){\r\n Butt.value = '" . et('SelNone') . "';\r\n } else if (Butt.value == '" . et('SelNone') . "'){\r\n Butt.value = '" . et('SelAll') . "';\r\n }\r\n return true;\r\n }\r\n function download(arg){\r\n parent.frame1.location.href='" . $path_info["basename"] . "?action=3&dir_atual={$dir_atual}&filename='+escape(arg);\r\n }\r\n function upload(){\r\n var w = 400;\r\n var h = 200;\r\n window.open('" . $path_info["basename"] . "?action=10&dir_atual={$dir_atual}', '', 'width='+w+',height='+h+',fullscreen=no,scrollbars=no,resizable=yes,status=no,toolbar=no,menubar=no,location=no');\r\n }\r\n function execute(){\r\n document.form_action.cmd_arg.value = prompt('" . et('TypeCmd') . ".');\r\n if(document.form_action.cmd_arg.value.length>0){\r\n if(confirm('" . et('ConfExec') . " \\' '+document.form_action.cmd_arg.value+' \\' ?')) {\r\n var w = 800;\r\n var h = 600;\r\n window.open('" . $path_info["basename"] . "?action=6&dir_atual={$dir_atual}&cmd='+escape(document.form_action.cmd_arg.value), '', 'width='+w+',height='+h+',fullscreen=no,scrollbars=yes,resizable=yes,status=no,toolbar=no,menubar=no,location=no');\r\n }\r\n }\r\n }\r\n function decompress(arg){\r\n if(confirm('" . strtoupper(et('Decompress')) . " \\' '+arg+' \\' ?')) {\r\n document.form_action.action.value = 72;\r\n document.form_action.cmd_arg.value = arg;\r\n document.form_action.submit();\r\n }\r\n }\r\n function edit_file(arg){\r\n var w = 800;\r\n var h = 600;\r\n if(confirm('" . strtoupper(et('Edit')) . " \\' '+arg+' \\' ?')) window.open('" . $path_info["basename"] . "?action=7&dir_atual={$dir_atual}&filename='+escape(arg), '', 'width='+w+',height='+h+',fullscreen=no,scrollbars=no,resizable=yes,status=no,toolbar=no,menubar=no,location=no');\r\n }\r\n function config(){\r\n var w = 600;\r\n var h = 400;\r\n window.open('" . $path_info["basename"] . "?action=2', 'win_config', 'width='+w+',height='+h+',fullscreen=no,scrollbars=yes,resizable=yes,status=no,toolbar=no,menubar=no,location=no');\r\n }\r\n function server_info(arg){\r\n var w = 800;\r\n var h = 600;\r\n window.open('" . $path_info["basename"] . "?action=5', 'win_serverinfo', 'width='+w+',height='+h+',fullscreen=no,scrollbars=yes,resizable=yes,status=no,toolbar=no,menubar=no,location=no');\r\n }\r\n function shell(){\r\n var w = 800;\r\n var h = 600;\r\n window.open('" . $path_info["basename"] . "?action=9', '', 'width='+w+',height='+h+',fullscreen=no,scrollbars=yes,resizable=yes,status=no,toolbar=no,menubar=no,location=no');\r\n }\r\n function view(arg){\r\n var w = 800;\r\n var h = 600;\r\n if(confirm('" . strtoupper(et('View')) . " \\' '+arg+' \\' ?')) window.open('" . $path_info["basename"] . "?action=4&dir_atual={$dir_atual}&filename='+escape(arg), '', 'width='+w+',height='+h+',fullscreen=no,scrollbars=yes,resizable=yes,status=yes,toolbar=no,menubar=no,location=yes');\r\n }\r\n function rename(arg){\r\n var nome = '';\r\n if (nome = prompt('" . strtoupper(et('Ren')) . " \\' '+arg+' \\' " . et('To') . " ...')) document.location.href='" . $path_info["basename"] . "?frame=3&action=3&dir_atual={$dir_atual}&old_name='+escape(arg)+'&new_name='+escape(nome);\r\n }\r\n function set_dir_dest(arg){\r\n document.form_action.dir_dest.value=arg;\r\n if (document.form_action.action.value.length>0) test(document.form_action.action.value);\r\n else alert('" . et('JSError') . ".');\r\n }\r\n function sel_dir(arg){\r\n document.form_action.action.value = arg;\r\n document.form_action.dir_dest.value='';\r\n if (!is_anything_selected()) alert('" . et('NoSel') . ".');\r\n else {\r\n if (!getCookie('sel_dir_warn')) {\r\n alert('" . et('SelDir') . ".');\r\n document.cookie='sel_dir_warn'+'='+escape('true')+';';\r\n }\r\n parent.frame2.set_flag(true);\r\n }\r\n }\r\n function set_chmod_arg(arg){\r\n document.form_action.chmod_arg.value=arg;\r\n if (document.form_action.action.value.length>0) test(document.form_action.action.value);\r\n else alert('" . et('JSError') . "');\r\n }\r\n function chmod(arg){\r\n document.form_action.action.value = arg;\r\n document.form_action.dir_dest.value='';\r\n document.form_action.chmod_arg.value='';\r\n if (!is_anything_selected()) alert('" . et('NoSel') . ".');\r\n else {\r\n var w = 280;\r\n var h = 180;\r\n window.open('" . $path_info["basename"] . "?action=8', '', 'width='+w+',height='+h+',fullscreen=no,scrollbars=no,resizable=yes,status=no,toolbar=no,menubar=no,location=no');\r\n }\r\n }\r\n function test_action(){\r\n if (document.form_action.action.value != 0) return true;\r\n else return false;\r\n }\r\n function test_prompt(arg){\r\n var erro='';\r\n var conf='';\r\n if (arg == 1){\r\n document.form_action.cmd_arg.value = prompt('" . et('TypeDir') . ".');\r\n } else if (arg == 2){\r\n document.form_action.cmd_arg.value = prompt('" . et('TypeArq') . ".');\r\n } else if (arg == 71){\r\n if (!is_anything_selected()) erro = '" . et('NoSel') . ".';\r\n else document.form_action.cmd_arg.value = prompt('" . et('TypeArqComp') . "');\r\n }\r\n if (erro!=''){\r\n document.form_action.cmd_arg.focus();\r\n alert(erro);\r\n } else if(document.form_action.cmd_arg.value.length>0) {\r\n document.form_action.action.value = arg;\r\n document.form_action.submit();\r\n }\r\n }\r\n function strstr(haystack,needle){\r\n var index = haystack.indexOf(needle);\r\n return (index==-1)?false:index;\r\n }\r\n function valid_dest(dest,orig){\r\n return (strstr(dest,orig)==false)?true:false;\r\n }\r\n // ArrayAlert - Selection debug only\r\n function aa(){\r\n var str = 'selected_dir_list:\\n';\r\n for (x=0;x<selected_dir_list.length;x++){\r\n str += selected_dir_list[x]+'\\n';\r\n }\r\n str += '\\nselected_file_list:\\n';\r\n for (x=0;x<selected_file_list.length;x++){\r\n str += selected_file_list[x]+'\\n';\r\n }\r\n alert(str);\r\n }\r\n function test(arg){\r\n var erro='';\r\n var conf='';\r\n if (arg == 4){\r\n if (!is_anything_selected()) erro = '" . et('NoSel') . ".\\n';\r\n conf = '" . et('RemSel') . " ?\\n';\r\n } else if (arg == 5){\r\n if (!is_anything_selected()) erro = '" . et('NoSel') . ".\\n';\r\n else if(document.form_action.dir_dest.value.length == 0) erro = '" . et('NoDestDir') . ".';\r\n else if(document.form_action.dir_dest.value == document.form_action.dir_atual.value) erro = '" . et('DestEqOrig') . ".';\r\n else if(!valid_dest(document.form_action.dir_dest.value,document.form_action.dir_atual.value)) erro = '" . et('InvalidDest') . ".';\r\n conf = '" . et('CopyTo') . " \\' '+document.form_action.dir_dest.value+' \\' ?\\n';\r\n } else if (arg == 6){\r\n if (!is_anything_selected()) erro = '" . et('NoSel') . ".';\r\n else if(document.form_action.dir_dest.value.length == 0) erro = '" . et('NoDestDir') . ".';\r\n else if(document.form_action.dir_dest.value == document.form_action.dir_atual.value) erro = '" . et('DestEqOrig') . ".';\r\n else if(!valid_dest(document.form_action.dir_dest.value,document.form_action.dir_atual.value)) erro = '" . et('InvalidDest') . ".';\r\n conf = '" . et('MoveTo') . " \\' '+document.form_action.dir_dest.value+' \\' ?\\n';\r\n } else if (arg == 9){\r\n if (!is_anything_selected()) erro = '" . et('NoSel') . ".';\r\n else if(document.form_action.chmod_arg.value.length == 0) erro = '" . et('NoNewPerm') . ".';\r\n conf = '" . et('AlterPermTo') . " \\' '+document.form_action.chmod_arg.value+' \\' ?\\n';\r\n }\r\n if (erro!=''){\r\n document.form_action.cmd_arg.focus();\r\n alert(erro);\r\n } else if(conf!='') {\r\n if(confirm(conf)) {\r\n document.form_action.action.value = arg;\r\n document.form_action.submit();\r\n }\r\n } else {\r\n document.form_action.action.value = arg;\r\n document.form_action.submit();\r\n }\r\n }\r\n //-->\r\n </script>"; $out .= "\r\n <form name=\"form_action\" action=\"" . $path_info["basename"] . "\" method=\"post\" onsubmit=\"return test_action();\">\r\n <input type=hidden name=\"frame\" value=3>\r\n <input type=hidden name=\"action\" value=0>\r\n <input type=hidden name=\"dir_dest\" value=\"\">\r\n <input type=hidden name=\"chmod_arg\" value=\"\">\r\n <input type=hidden name=\"cmd_arg\" value=\"\">\r\n <input type=hidden name=\"dir_atual\" value=\"{$dir_atual}\">\r\n <input type=hidden name=\"dir_antes\" value=\"{$dir_antes}\">\r\n <input type=hidden name=\"selected_dir_list\" value=\"\">\r\n <input type=hidden name=\"selected_file_list\" value=\"\">"; $out .= "\r\n <tr>\r\n <td bgcolor=\"#DDDDDD\" colspan=20><nobr>\r\n <input type=button onclick=\"config()\" value=\"" . et('Config') . "\">\r\n <input type=button onclick=\"server_info()\" value=\"" . et('ServerInfo') . "\">\r\n <input type=button onclick=\"test_prompt(1)\" value=\"" . et('CreateDir') . "\">\r\n <input type=button onclick=\"test_prompt(2)\" value=\"" . et('CreateArq') . "\">\r\n <input type=button onclick=\"execute()\" value=\"" . et('ExecCmd') . "\">\r\n <input type=button onclick=\"upload()\" value=\"" . et('Upload') . "\">\r\n <input type=button onclick=\"shell()\" value=\"" . et('Shell') . "\">\r\n <b>{$ip}</b>\r\n </nobr>"; if ($dir_atual != $fm_root_atual) { $mat = explode("/", $dir_atual); $dir_antes = ""; for ($x = 0; $x < count($mat) - 2; $x++) { $dir_antes .= $mat[$x] . "/"; } $uplink = "<a href=\"" . $path_info["basename"] . "?frame=3&dir_atual={$dir_antes}\"><<</a> "; } if ($entry_count) { $out .= "\r\n <tr><td bgcolor=\"#DDDDDD\" colspan=20><nobr>{$uplink} <a href=\"" . $path_info["basename"] . "?frame=3&dir_atual={$dir_atual}\">{$dir_atual}</a></nobr>\r\n <tr>\r\n <td bgcolor=\"#DDDDDD\" colspan=20><nobr>\r\n <input type=\"button\" style=\"width:60\" onclick=\"selectANI(this)\" value=\"" . et('SelAll') . "\">\r\n <input type=\"button\" style=\"width:60\" onclick=\"selectANI(this)\" value=\"" . et('SelInverse') . "\">\r\n <input type=\"button\" style=\"width:60\" onclick=\"test(4)\" value=\"" . et('Rem') . "\">\r\n <input type=\"button\" style=\"width:60\" onclick=\"sel_dir(5)\" value=\"" . et('Copy') . "\">\r\n <input type=\"button\" style=\"width:60\" onclick=\"sel_dir(6)\" value=\"" . et('Move') . "\">\r\n <input type=\"button\" style=\"width:100\" onclick=\"test_prompt(71)\" value=\"" . et('Compress') . "\">"; if ($islinux) { $out .= "\r\n <input type=\"button\" style=\"width:100\" onclick=\"resolveIDs()\" value=\"" . et('ResolveIDs') . "\">"; } $out .= "\r\n <input type=\"button\" style=\"width:100\" onclick=\"chmod(9)\" value=\"" . et('Perms') . "\">"; $out .= "\r\n </nobr>\r\n <tr><td bgcolor=\"#DDDDDD\" colspan=20><DIV ID=\"sel_status\"></DIV></td></tr>"; $dir_out = ""; $file_out = ""; foreach ($entry_list as $ind => $dir_entry) { $file = $dir_entry["name"]; if ($dir_entry["type"] == "dir") { $dir_out .= "\r\n <tr ID=\"entry{$ind}\" onmouseover=\"selectEntry(this, 'over');\" onmousedown=\"selectEntry(this, 'click');\">\r\n <td align=left bgcolor=\"#" . $fm_color['Dir'] . "\"><nobr><a href=\"JavaScript:go('{$file}')\">{$file}</a></nobr>\r\n <td bgcolor=\"#" . $fm_color['Dir'] . "\">" . $dir_entry["p"]; if ($islinux) { $dir_out .= "<td bgcolor=\"#" . $fm_color['Dir'] . "\">" . $dir_entry["u"] . "<td bgcolor=\"#" . $fm_color['Dir'] . "\">" . $dir_entry["g"]; } $dir_out .= "\r\n <td bgcolor=\"#" . $fm_color['Dir'] . "\">" . $dir_entry["sizet"] . "\r\n <td bgcolor=\"#" . $fm_color['Dir'] . "\">" . $dir_entry["datet"]; if ($file_count) { $dir_out .= "\r\n <td bgcolor=\"#" . $fm_color['Dir'] . "\" align=center>"; } // Opções de diretório if (is_writable($dir_atual . $file)) { $dir_out .= "\r\n <td bgcolor=\"#FFFFFF\" align=center><a href=\"JavaScript:if(confirm('" . et('ConfRem') . " \\'" . $file . "\\' ?')) document.location.href='" . $path_info["basename"] . "?frame=3&action=8&cmd_arg=" . $file . "&dir_atual={$dir_atual}'\">" . et('Rem') . "</a>\r\n <td bgcolor=\"#FFFFFF\" align=center><a href=\"JavaScript:rename('{$file}')\">" . et('Ren') . "</a>"; } $dir_out .= "\r\n </tr>"; } else { $file_out .= "\r\n <tr ID=\"entry{$ind}\" onmouseover=\"selectEntry(this, 'over');\" onmousedown=\"selectEntry(this, 'click');\">\r\n <td align=left bgcolor=\"#FFFFFF\"><nobr><a href=\"JavaScript:download('{$file}')\">{$file}</a></nobr>\r\n <td bgcolor=\"#" . $fm_color['File'] . "\">" . $dir_entry["p"]; if ($islinux) { $file_out .= "<td bgcolor=\"#" . $fm_color['File'] . "\">" . $dir_entry["u"] . "<td bgcolor=\"#" . $fm_color['File'] . "\">" . $dir_entry["g"]; } $file_out .= "\r\n <td bgcolor=\"#" . $fm_color['File'] . "\">" . $dir_entry["sizet"] . "\r\n <td bgcolor=\"#" . $fm_color['File'] . "\">" . $dir_entry["datet"] . "\r\n <td bgcolor=\"#" . $fm_color['File'] . "\">" . $dir_entry["extt"]; // Opções de arquivo if (is_writable($dir_atual . $file)) { $file_out .= "\r\n <td bgcolor=\"#FFFFFF\" align=center><a href=\"javascript:if(confirm('" . strtoupper(et('Rem')) . " \\'" . $file . "\\' ?')) document.location.href='" . $path_info["basename"] . "?frame=3&action=8&cmd_arg=" . $file . "&dir_atual={$dir_atual}'\">" . et('Rem') . "</a>\r\n <td bgcolor=\"#FFFFFF\" align=center><a href=\"javascript:rename('{$file}')\">" . et('Ren') . "</a>"; } if (is_readable($dir_atual . $file) && strpos(".wav#.mp3#.mid#.avi#.mov#.mpeg#.mpg#.rm#.iso#.bin#.img#.dll#.psd#.fla#.swf#.class#.ppt#.jpg#.gif#.png#.wmf#.eps#.bmp#.msi#.exe#.com#.rar#.tar#.zip#.bz2#.tbz2#.bz#.tbz#.bzip#.gzip#.gz#.tgz#", $dir_entry["ext"] . "#") === false) { $file_out .= "\r\n <td bgcolor=\"#FFFFFF\" align=center><a href=\"javascript:edit_file('{$file}')\">" . et('Edit') . "</a>"; } if (is_readable($dir_atual . $file) && strlen($dir_entry["ext"]) && strpos(".tar#.zip#.bz2#.tbz2#.bz#.tbz#.bzip#.gzip#.gz#.tgz#", $dir_entry["ext"] . "#") !== false) { $file_out .= "\r\n <td bgcolor=\"#FFFFFF\" align=center><a href=\"javascript:decompress('{$file}')\">" . et('Decompress') . "</a>"; } if ($is_reachable && is_readable($dir_atual . $file) && strpos(".txt#.sys#.bat#.ini#.conf#.swf#.php#.php3#.asp#.html#.htm#.jpg#.gif#.png#.bmp#", $dir_entry["ext"] . "#") !== false) { $file_out .= "\r\n <td bgcolor=\"#FFFFFF\" align=center><a href=\"javascript:view('{$file}');\">" . et('View') . "</a>"; } $file_out .= "</tr>"; } } $out .= $dir_out; if ($entry_count) { $out .= "\r\n <tr>\r\n <td bgcolor=\"#DDDDDD\"><a href=\"" . $path_info["basename"] . "?frame=3&or_by={$or1}&dir_atual={$dir_atual}\">" . et('Name') . "</a>\r\n <td bgcolor=\"#DDDDDD\"><a href=\"" . $path_info["basename"] . "?frame=3&or_by={$or2}&dir_atual={$dir_atual}\">" . et('Perms') . "</a>"; if ($islinux) { $out .= "<td bgcolor=\"#DDDDDD\"><a href=\"" . $path_info["basename"] . "?frame=3&or_by={$or3}&dir_atual={$dir_atual}\">" . et('Owner') . "</a><td bgcolor=\"#DDDDDD\"><a href=\"" . $path_info["basename"] . "?frame=3&or_by={$or4}&dir_atual={$dir_atual}\">" . et('Group') . "</a>"; } $out .= "\r\n <td bgcolor=\"#DDDDDD\"><a href=\"" . $path_info["basename"] . "?frame=3&or_by={$or5}&dir_atual={$dir_atual}\">" . et('Size') . "</a>\r\n <td bgcolor=\"#DDDDDD\"><a href=\"" . $path_info["basename"] . "?frame=3&or_by={$or6}&dir_atual={$dir_atual}\">" . et('Date') . "</a>"; if ($file_count) { $out .= "\r\n <td bgcolor=\"#DDDDDD\"><a href=\"" . $path_info["basename"] . "?frame=3&or_by={$or7}&dir_atual={$dir_atual}\">" . et('Type') . "</a>"; } $out .= "\r\n <td bgcolor=\"#DDDDDD\" colspan=20>"; } $out .= $file_out; $out .= "\r\n <tr>\r\n <td bgcolor=\"#DDDDDD\" colspan=20><nobr>\r\n <input type=\"button\" style=\"width:60\" onclick=\"selectANI(this)\" value=\"" . et('SelAll') . "\">\r\n <input type=\"button\" style=\"width:60\" onclick=\"selectANI(this)\" value=\"" . et('SelInverse') . "\">\r\n <input type=\"button\" style=\"width:60\" onclick=\"test(4)\" value=\"" . et('Rem') . "\">\r\n <input type=\"button\" style=\"width:60\" onclick=\"sel_dir(5)\" value=\"" . et('Copy') . "\">\r\n <input type=\"button\" style=\"width:60\" onclick=\"sel_dir(6)\" value=\"" . et('Move') . "\">\r\n <input type=\"button\" style=\"width:100\" onclick=\"test_prompt(71)\" value=\"" . et('Compress') . "\">"; if ($islinux) { $out .= "\r\n <input type=\"button\" style=\"width:100\" onclick=\"resolveIDs()\" value=\"" . et('ResolveIDs') . "\">"; } $out .= "\r\n <input type=\"button\" style=\"width:100\" onclick=\"chmod(9)\" value=\"" . et('Perms') . "\">"; $out .= "\r\n </nobr></td>\r\n </tr>"; $out .= "\r\n </form>"; $out .= "\r\n <tr><td bgcolor=\"#DDDDDD\" colspan=20>{$dir_count} " . et('Dir_s') . " " . et('And') . " {$file_count} " . et('File_s') . " = " . formatsize($total_size) . "</td></tr>"; if ($quota_mb) { $out .= "\r\n <tr><td bgcolor=\"#DDDDDD\" colspan=20>" . et('Partition') . ": " . formatsize($quota_mb * 1024 * 1024) . " " . et('Total') . " - " . formatsize($quota_mb * 1024 * 1024 - total_size($fm_root_atual)) . " " . et('Free') . "</td></tr>"; } else { $out .= "\r\n <tr><td bgcolor=\"#DDDDDD\" colspan=20>" . et('Partition') . ": " . formatsize(disk_total_space($dir_atual)) . " " . et('Total') . " - " . formatsize(disk_free_space($fm_root_atual)) . " " . et('Free') . "</td></tr>"; } $tf = getmicrotime(); $tt = $tf - $ti; $out .= "\r\n <tr><td bgcolor=\"#DDDDDD\" colspan=20>" . et('RenderTime') . ": " . substr($tt, 0, strrpos($tt, ".") + 5) . " " . et('Seconds') . "</td></tr>"; $out .= "\r\n <script language=\"Javascript\" type=\"text/javascript\">\r\n <!--\r\n update_sel_status();\r\n //-->\r\n </script>"; } else { $out .= "\r\n <tr>\r\n <td bgcolor=\"#DDDDDD\" width=\"1%\">{$uplink}<td bgcolor=\"#DDDDDD\" colspan=20><nobr><a href=\"" . $path_info["basename"] . "?frame=3&dir_atual={$dir_atual}\">{$dir_atual}</a></nobr>\r\n <tr><td bgcolor=\"#DDDDDD\" colspan=20>" . et('EmptyDir') . ".</tr>"; } } else { $out .= "<tr><td><font color=red>" . et('IOError') . ".<br>{$dir_atual}</font>"; } $out .= "</table>"; echo $out; }
function Showbrowse_Img($spec) { extract($GLOBALS); $s = ""; $directory = ServerMapPath($spec); // if the path has a slash at the end we remove it here if (substr($directory, -1) == '/') { $directory = substr($directory, 0, -1); } $dirlist = array(); $imglist = array(); // we open the directory if ($f = opendir($directory)) { while (($file = readdir($f)) !== false) { if ($file != "." && $file != "..") { $path = $directory . '/' . $file; if (is_file($path)) { if (ValidImage($file)) { $imglist[] = $file; } } elseif (is_dir($path)) { $dirlist[] = $file; } } } closedir($f); } if ($dirlist) { $s = $s . "<div style='overflow: auto; HEIGHT: 120px;'>"; $s = $s . "<table border='0' cellspacing='0' cellpadding='1' width='100%' align='center' valign='top'>"; asort($dirlist); while (list($key, $file) = each($dirlist)) { //add the html for the folders $str_openfolderEvent = "onclick=\"parent.SetUpload_imagePath('" . $current_Path . $folpath . $file . "');location.href='browse_Img_gallery.php?" . $setting . "&loc=" . $folpath . $file . "&Theme=" . $Theme . "&GP=" . $current_Path . "';\""; $s = $s . "<tr>"; $s = $s . "<td " . $str_openfolderEvent . "><img vspace=\"0\" hspace=\"0\" src=\"../Images/closedfolder.gif\" style=\"VERTICAL-ALIGN: middle\"> " . "\r\n"; $s = $s . $file . " </td>" . "\r\n"; $s = $s . "<td nowrap style=\"cursor:pointer;\" " . $str_openfolderEvent . "></td>"; $s = $s . "</tr>" . "\r\n"; } $s = $s . "</table></div>"; } $imgcnt = sizeof($imglist); $max_per_page = TABLE_COLS * TABLE_ROWS; $currpage = isset($_GET['page']) ? (int) $_GET['page'] : 1; // set index of page's first image in image list array $first_image_index = ($currpage - 1) * $max_per_page; // set index of page's last image in image list array $last_image_index = $imgcnt < $currpage * $max_per_page ? $last_image_index = $imgcnt : $currpage * $max_per_page; $s = $s . "<div style='HEIGHT: 280px;'><table width='100%' CellSpacing='0' valign='top'>"; // loop control var $column_cnt = 1; // loop through current page images for ($i = $first_image_index; $i < $last_image_index; $i++) { # build path to thumb $thumburl = $current_Path . $folpath . $imglist[$i]; $size = getimagesize(ServerMapPath($thumburl)); $height = $size[1]; $width = $size[0]; if ($width > 80) { $width = 80; $percent = $size[0] / $width; $height = (int) ($size[1] / $percent); } if ($height > 64) { $height = 64; $percent = $size[1] / $height; $width = (int) ($size[0] / $percent); } $p; if (!(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')) { $p = show_perms(fileperms(ServerMapPath($thumburl))); } else { $p = base_convert(fileperms(ServerMapPath($thumburl)), 10, 8); $p = substr($p, strlen($p) - 3); } $file_stat = stat(ServerMapPath($thumburl)); $filesize = FormatSize($file_stat[7]); $lastmod = date("m/d/Y", $file_stat[10]); $f_Tooltip = ""; $f_Tooltip = $f_Tooltip . "<nobr>Name: " . $imglist[$i] . "</nobr><br>"; $f_Tooltip = $f_Tooltip . "<nobr>Size: " . $filesize . "</nobr><br>"; $f_Tooltip = $f_Tooltip . "<nobr>Width: " . $size[0] . "</nobr><br>"; $f_Tooltip = $f_Tooltip . "<nobr>Height: " . $size[1] . "</nobr><br>"; $f_Tooltip = $f_Tooltip . "<nobr>Date modified: " . $lastmod . "</nobr><br>"; $f_Tooltip = $f_Tooltip . "<nobr>Attributes: " . $p . "</nobr><br>"; // insert row tag if this is the first column if ($column_cnt == 1) { $s .= "<tr>\n"; } // insert thumbnail, and surrounding html $s .= "<td>"; $s .= "<img src=\"{$thumburl}\" border=\"0\" width=\"" . $width . "\" height=\"" . $height . "\" onclick=\"parent.insert(this.src)\""; $s .= " onMouseover=\"Check(this,1); showTooltip('" . $f_Tooltip . "', this, event);\""; $s .= " onMouseout=\"Check(this,0); delayhidetip()\" "; $s .= " style=\"BORDER: white 1px solid\" align=\"center\"/>"; $s .= "</td>\n"; if ($column_cnt == TABLE_COLS) { $s .= "</tr>\n\n"; $column_cnt = 1; } else { $column_cnt++; } } $s = $s . "</table></div>"; $pagecnt = (int) (($imgcnt - 1) / (TABLE_COLS * TABLE_ROWS)) + 1; $self = $_SERVER['PHP_SELF']; $s = $s . "<center>"; // Show paging indicator if multiple pages: $s = $s . "Pages: "; if ($currpage > 1) { $s = $s . "<a href=\"" . $self . "?" . $setting . "&Theme=" . $Theme . "&GP=" . $current_Path . $folpath . "&page=" . ($currpage - 1) . "\"><< Prev</a> "; } // You can also show page numbers: for ($I = 1; $I <= $pagecnt; $I = $I + 1) { if ($I == $currpage) { $s = $s . $I . " "; } else { $s = $s . "<a href=\"" . $self . "?" . $setting . "&Theme=" . $Theme . "&GP=" . $current_Path . $folpath . "&page=" . $I . "\">" . $I . "</a> "; } } if ($currpage < $pagecnt) { $s = $s . "<a href=\"?" . $setting . "&Theme=" . $Theme . "&GP=" . $current_Path . $folpath . "&page=" . ($currpage + 1) . "\">Next >></a>"; } $s = $s . "</center>"; return $s; }