⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 browser_jsp.java

📁 WAR - consists the JSP/Servlet & demo pages
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
      out.write("\t\t\tif(document.all && !OP) MS = 1;\r\n");
      out.write("\t\t\tb = 1;\r\n");
      out.write("\t\t}\r\n");
      out.write("\t}\r\n");
      out.write("\t");
// Allows the whole row to be selected 
      out.write("\r\n");
      out.write("\tfunction selrow (element, i){\r\n");
      out.write("\t\tvar erst;\r\n");
      out.write("\t\tCheckBrowser();\r\n");
      out.write("\t\tif ((OP==1)||(MS==1)) erst = element.firstChild.firstChild;\r\n");
      out.write("\t\telse if (DOM==1) erst = element.firstChild.nextSibling.firstChild;\r\n");
      out.write("\t\t");
// MouseIn 
      out.write("\r\n");
      out.write("\t\tif (i==0){\r\n");
      out.write("\t\t\tif (erst.checked == true) element.className='mousechecked';\r\n");
      out.write("\t\t\telse element.className='mousein';\r\n");
      out.write("\t\t}\r\n");
      out.write("\t\t");
// MouseOut 
      out.write("\r\n");
      out.write("\t\telse if (i==1){\r\n");
      out.write("\t\t\tif (erst.checked == true) element.className='checked';\r\n");
      out.write("\t\t\telse element.className='mouseout';\r\n");
      out.write("\t\t}\r\n");
      out.write("\t\t");
    // MouseClick 
      out.write("\r\n");
      out.write("\t\telse if ((i==2)&&(!check)){\r\n");
      out.write("\t\t\tif (erst.checked==true) element.className='mousein';\r\n");
      out.write("\t\t\telse element.className='mousechecked';\r\n");
      out.write("\t\t\terst.click();\r\n");
      out.write("\t\t}\r\n");
      out.write("\t\telse check=false;\r\n");
      out.write("\t}\r\n");
      out.write("\t");
//(De)select all checkboxes
      out.write("\r\n");
      out.write("\tfunction AllFiles(){\r\n");
      out.write("\t\tfor(var x=0;x<document.FileList.elements.length;x++){\r\n");
      out.write("\t\t\tvar y = document.FileList.elements[x];\r\n");
      out.write("\t\t\tvar ytr = y.parentNode.parentNode;\r\n");
      out.write("\t\t\tvar check = document.FileList.selall.checked;\r\n");
      out.write("\t\t\tif(y.name == 'selfile'){\r\n");
      out.write("\t\t\t\tif (y.disabled != true){\r\n");
      out.write("\t\t\t\t\ty.checked = check;\r\n");
      out.write("\t\t\t\t\tif (y.checked == true) ytr.className = 'checked';\r\n");
      out.write("\t\t\t\t\telse ytr.className = 'mouseout';\r\n");
      out.write("\t\t\t\t}\r\n");
      out.write("\t\t\t}\r\n");
      out.write("\t\t}\r\n");
      out.write("\t}\r\n");
      out.write("//-->\r\n");
      out.write("</script>\r\n");
      out.write("<title>");
      out.print(request.getAttribute("dir"));
      out.write("</title>\r\n");
      out.write("</head>\r\n");
      out.write("<body>\r\n");

		//Output message
		if (request.getAttribute("message")!=null){
			out.println("<table border=\"0\" width=\"100%\"><tr><td class=\"message\">");
			out.println(request.getAttribute("message"));
			out.println("</td></tr></table>");
		}
		//Output error
		if (request.getAttribute("error")!=null){
			out.println("<table border=\"0\" width=\"100%\"><tr><td class=\"error\">");
			out.println(request.getAttribute("error"));
			out.println("</td></tr></table>");
		}

      out.write("\r\n");
      out.write("\t<form action=\"");
      out.print( browser_name );
      out.write("\" method=\"Post\" name=\"FileList\">\r\n");
      out.write("\t<table class=\"filelist\" cellspacing=\"1px\" cellpadding=\"0px\">\r\n");

		// Output the table, starting with the headers.
		String dir = URLEncoder.encode("" + request.getAttribute("dir"));
		String cmd = browser_name + "?dir=" + dir;
		int sortMode=1;
		if (request.getParameter("sort")!=null) sortMode = Integer.parseInt(request.getParameter("sort"));
		int[] sort = new int[]{1,2,3,4};
		for (int i = 0;i<sort.length;i++)
			if (sort[i] == sortMode) sort[i] = -sort[i];
		out.println("<tr><th>&nbsp;</th><th title=\"Sort files by name\" align=left><a href=\""+cmd+"&amp;sort="+sort[0]+"\">Name</a></th>"+
				"<th title=\"Sort files by size\" align=\"right\"><a href=\"" + cmd + "&amp;sort="+sort[1]+"\">Size</a></th>" +
				"<th title=\"Sort files by type\" align=\"center\"><a href=\"" + cmd + "&amp;sort="+sort[3]+"\">Type</a></th>"+
				"<th title=\"Sort files by date\" align=\"left\"><a href=\"" + cmd + "&amp;sort="+sort[2]+"\">Date</a></th>"+
				"<th>&nbsp;</th><th>&nbsp;</th></tr>");
		char trenner = File.separatorChar;
		// Output the Root-Dirs, without FORBIDDEN_DRIVES
		File[] entry = File.listRoots();
		for (int i = 0; i < entry.length; i++){
			boolean forbidden = false;
			for (int i2 = 0;i2<FORBIDDEN_DRIVES.length;i2++){
				if (entry[i].getAbsolutePath().toLowerCase().equals(FORBIDDEN_DRIVES[i2])) forbidden = true;
			}
			if (!forbidden){
				out.println("<tr class=\"mouseout\" onmouseover=\"this.className='mousein'\""
						+ "onmouseout=\"this.className='mouseout'\">");
				out.println("<td>&nbsp;</td><td align=left >");
				String name = URLEncoder.encode(entry[i].getAbsolutePath());
				String buf = entry[i].getAbsolutePath();
				out.println(" &nbsp;<a href=\""+browser_name+"?sort="+sortMode
					+"&amp;dir="+name+"\">["+buf+"]</a>");
				out.println("</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>");
			}
		}
		// Output the parent directory link ".."
		if (f.getParent()!=null){
			out.println("<tr class=\"mouseout\" onmouseover=\"this.className='mousein'\""
					+ "onmouseout=\"this.className='mouseout'\">");
			out.println("<td></td><td align=left>");
			out.println(" &nbsp;<a href=\""+browser_name+"?sort="+sortMode+"&amp;dir="
				+URLEncoder.encode(f.getParent())+"\">"+FOL_IMG+"[..]</a>");
			out.println("</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>");
		}
		// Output all files and dirs and calculate the number of files and total size
		entry = f.listFiles();
		if (entry == null) entry = new File[]{};
		long totalSize = 0; // The total size of the files in the current directory
		long fileCount = 0; // The count of files in the current working directory
		if (entry != null && entry.length > 0){
			Arrays.sort(entry, new FileComp(sortMode));
			for (int i = 0; i < entry.length; i++){
				String name = URLEncoder.encode(entry[i].getAbsolutePath());
				String type = "File"; // This String will tell the extension of the file
				if (entry[i].isDirectory()) type = "DIR"; // It's a DIR
				else {
					String tempName = entry[i].getName().replace(' ','_');
					if (tempName.lastIndexOf('.') != -1) type = tempName.substring(tempName.lastIndexOf('.')).toLowerCase();
				}
				String ahref = "<a onmousedown=\"dis()\" href=\"" + browser_name + "?sort="+sortMode+"&amp;";
				String dlink = "&nbsp;"; // The "Download" link
				String elink = "&nbsp;"; // The "Edit" link
				String buf = conv2Html(entry[i].getName());
				if (!entry[i].canWrite()) buf = "<i>"+buf+"</i>";
				String link = buf;        // The standard view link, uses Mime-type
				if (entry[i].isDirectory()){
					if (entry[i].canRead()&&USE_DIR_PREVIEW){
						//Show the first DIR_PREVIEW_NUMBER directory entries in a tooltip
						File[] fs = entry[i].listFiles();
						if (fs == null) fs = new File[]{};
						Arrays.sort(fs, new FileComp());
						StringBuffer filenames =new StringBuffer();
						for (int i2 = 0;(i2<fs.length)&&(i2<10);i2++) {
							String fname = conv2Html(fs[i2].getName());
							if (fs[i2].isDirectory()) filenames.append ("["+fname+"];");
							else filenames.append (fname+";");
						}
						if (fs.length>DIR_PREVIEW_NUMBER) filenames.append("...");
						else if (filenames.length()>0) filenames.setLength(filenames.length()-1);
						link = ahref + "dir=" + name + "\" title=\"" + filenames + "\">"
								+ FOL_IMG + "[" + buf + "]</a>";
					}
					else if (entry[i].canRead()){
						link = ahref + "dir=" + name + "\">" + FOL_IMG + "[" + buf + "]</a>";
					}
					else link = FOL_IMG + "[" + buf + "]";
				}
				else if (entry[i].isFile()){ //Entry is file
					totalSize = totalSize + entry[i].length();
					fileCount = fileCount + 1;
					if (entry[i].canRead()){
						dlink = ahref + "downfile=" + name + "\">Download</a>";
						//If you click at the filename
						if (USE_POPUP)
							link = ahref + "file=" + name + "\" target=\"_blank\">" + buf + "</a>";
						else link = ahref + "file=" + name + "\">" + buf + "</a>";
						if (entry[i].canWrite()){ // The file can be edited
							//If it is a zip or jar File you can unpack it
							if (isPacked(name, true))
								elink = ahref + "unpackfile=" + name + "\">Unpack</a>";
							else elink = ahref + "editfile=" + name + "\">Edit</a>";
						}
						else{ // If the file cannot be edited
							//If it is a zip or jar File you can unpack it
							if (isPacked(name, true))
								elink = ahref + "unpackfile=" + name + "\">Unpack</a>";
							else elink = ahref + "editfile=" + name + "\">View</a>";
						}
					}
					else{
						link = buf;
					}
				}
				String date = dateFormat.format(new Date(entry[i].lastModified()));
				out.println("<tr class=\"mouseout\" onmouseup=\"selrow(this, 2)\" " +
						"onmouseover=\"selrow(this, 0);\" onmouseout=\"selrow(this, 1)\">");
				if (entry[i].canRead()){
					out.println("<td align=center><input type=\"checkbox\" name=\"selfile\" value=\"" + name
							+ "\" onmousedown=\"dis()\"></td>");
				}
				else{
					out.println("<td align=center><input type=\"checkbox\" name=\"selfile\" disabled></td>");
				}
				out.print("<td align=left> &nbsp;" + link + "</td>");
				if (entry[i].isDirectory()) out.print("<td>&nbsp;</td>");
				else{
					out.print("<td align=right title=\""+entry[i].length()+" bytes\">"
							+convertFileSize(entry[i].length())+"</td>");
				}
				out.println("<td align=\"center\">" + type + "</td><td align=left> &nbsp;" + // The file type (extension)
						date + "</td><td>" + // The date the file was created
						dlink + "</td><td>" + // The download link
						elink + "</td></tr>"); // The edit link (or view, depending)
			}
		}
      out.write("\r\n");
      out.write("\t</table>\r\n");
      out.write("\t<input type=\"checkbox\" name=\"selall\" onClick=\"AllFiles(this.form)\">Select all\r\n");
      out.write("\t<p align=center>\r\n");
      out.write("\t\t<b title=\"");
      out.print(totalSize);
      out.write(" bytes\">\r\n");
      out.write("\t\t");
      out.print(convertFileSize(totalSize));
      out.write("</b><b> in ");
      out.print(fileCount);
      out.write(" files in ");
      out.print( dir2linkdir((String)request.getAttribute("dir"), browser_name, sortMode));
      out.write("\r\n");
      out.write("\t\t</b>\r\n");
      out.write("\t</p>\r\n");
      out.write("\t<p>\r\n");
      out.write("\t\t<input type=\"hidden\" name=\"dir\" value=\"");
      out.print(request.getAttribute("dir"));
      out.write("\">\r\n");
      out.write("\t\t<input type=\"hidden\" name=\"sort\" value=\"");
      out.print(sortMode);
      out.write("\">\r\n");
      out.write("\t\t<input title=\"Download selected files and directories as one zip file\" class=\"button\" type=\"Submit\" name=\"Submit\" value=\"");
      out.print(SAVE_AS_ZIP);
      out.write("\">\r\n");
      out.write("\t\t<input title=\"Delete all selected files and directories incl. subdirs\" class=\"button\" type=\"Submit\" name=\"Submit\" value=\"");
      out.print(DELETE_FILES);
      out.write("\"\r\n");
      out.write("\t\tonclick=\"return confirm('Do you really want to delete the entries?')\">\r\n");
      out.write("\t</p>\r\n");
      out.write("\t<p>\r\n");
      out.write("\t\t<input title=\"Enter new dir or filename or the relative or absolute path\" type=\"text\" name=\"cr_dir\">\r\n");
      out.write("\t\t<input title=\"Create a new directory with the given name\" class=\"button\" type=\"Submit\" name=\"Submit\" value=\"");
      out.print(CREATE_DIR);
      out.write("\">\r\n");
      out.write("\t\t<input title=\"Create a new empty file with the given name\" class=\"button\" type=\"Submit\" name=\"Submit\" value=\"");
      out.print(CREATE_FILE);
      out.write("\">\r\n");
      out.write("\t\t<input title=\"Move selected files and directories to the entered path\" class=\"button\" type=\"Submit\" name=\"Submit\" value=\"");
      out.print(MOVE_FILES);
      out.write("\">\r\n");
      out.write("\t\t<input title=\"Copy selected files and directories to the entered path\" class=\"button\" type=\"Submit\" name=\"Submit\" value=\"");
      out.print(COPY_FILES);
      out.write("\">\r\n");
      out.write("\t\t<input title=\"Rename selected file or directory to the entered name\" class=\"button\" type=\"Submit\" name=\"Submit\" value=\"");
      out.print(RENAME_FILE);
      out.write("\">\r\n");
      out.write("\t</p>\r\n");
      out.write("\t</form>\r\n");
      out.write("\t<form action=\"");
      out.print( browser_name);
      out.write("\" enctype=\"multipart/form-data\" method=\"POST\">\r\n");
      out.write("\t\t<input type=\"hidden\" name=\"dir\" value=\"");
      out.print(request.getAttribute("dir"));
      out.write("\">\r\n");
      out.write("\t\t<input type=\"hidden\" name=\"sort\" value=\"");
      out.print(sortMode);
      out.write("\">\r\n");
      out.write("\t\t<input type=\"file\" name=\"myFile\">\r\n");
      out.write("\t\t<input title=\"Upload selected file to the current working directory\" type=\"Submit\" class=\"button\" name=\"Submit\" value=\"Upload\">\r\n");
      out.write("\t</form>\r\n");
      out.write("\t<form action=\"");
      out.print( browser_name);
      out.write("\" method=\"POST\">\r\n");
      out.write("\t\t<input type=\"hidden\" name=\"dir\" value=\"");
      out.print(request.getAttribute("dir"));
      out.write("\">\r\n");
      out.write("\t\t<input type=\"hidden\" name=\"sort\" value=\"");
      out.print(sortMode);
      out.write("\">\r\n");
      out.write("\t\t<input type=\"hidden\" name=\"command\" value=\"\">\r\n");
      out.write("\t\t<input title=\"Launch command in current directory\" type=\"Submit\" class=\"button\" name=\"Submit\" value=\"Launch command\">\r\n");
      out.write("\t</form>\r\n");
      out.write("\t<hr>\r\n");
      out.write("\t<center>\r\n");
      out.write("\t\t<small>jsp File Browser version ");
      out.print( VERSION_NR);
      out.write(" by <a href=\"http://www.vonloesch.de\">www.vonloesch.de</a></small>\r\n");
      out.write("\t</center>\r\n");
      out.write("</body>\r\n");
      out.write("</html>");

	}

    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          out.clearBuffer();
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -