|
|
@ -1,11 +1,12 @@ |
|
|
|
package com.fr.design.extra.ucenter; |
|
|
|
package com.fr.design.extra.ucenter; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.fr.base.FRContext; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.BufferedReader; |
|
|
|
import java.io.BufferedReader; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.io.InputStreamReader; |
|
|
|
import java.io.InputStreamReader; |
|
|
|
import java.io.OutputStream; |
|
|
|
import java.io.OutputStream; |
|
|
|
import java.net.MalformedURLException; |
|
|
|
|
|
|
|
import java.net.Socket; |
|
|
|
import java.net.Socket; |
|
|
|
import java.net.URL; |
|
|
|
import java.net.URL; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashMap; |
|
|
@ -16,320 +17,238 @@ import java.util.Map; |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class Client extends PHPFunctions{ |
|
|
|
public class Client extends PHPFunctions{ |
|
|
|
|
|
|
|
|
|
|
|
public static boolean IN_UC = true; |
|
|
|
|
|
|
|
public static String UC_IP = "211.149.195.54"; |
|
|
|
public static String UC_IP = "211.149.195.54"; |
|
|
|
public static String UC_API = "http://bbs.fanruan.com/uc_server"; |
|
|
|
public static String UC_API = "http://bbs.fanruan.com/uc_server"; |
|
|
|
public static String UC_CONNECT = ""; |
|
|
|
public static String UC_CONNECT = ""; |
|
|
|
public static String UC_KEY = "Rc85U37411p4zdvcedm8D4t4D3l9Sa42H0kd98Gbd82aA99a61S2Z5LbQ9u430M0"; |
|
|
|
public static String UC_KEY = "Rc85U37411p4zdvcedm8D4t4D3l9Sa42H0kd98Gbd82aA99a61S2Z5LbQ9u430M0"; |
|
|
|
public static String UC_APPID = "4"; |
|
|
|
public static String UC_APPID = "4"; |
|
|
|
public static String UC_CLIENT_VERSION = "1.0"; |
|
|
|
|
|
|
|
public static String UC_CLIENT_RELEASE = "20090212"; |
|
|
|
public static String UC_CLIENT_RELEASE = "20090212"; |
|
|
|
public static String UC_ROOT = ""; |
|
|
|
public static String UC_ROOT = ""; |
|
|
|
public static String UC_DATADIR = UC_ROOT + "./data/"; |
|
|
|
|
|
|
|
public static String UC_DATAURL = "UC_API" + "/data"; |
|
|
|
|
|
|
|
public static String UC_API_FUNC = UC_CONNECT.equals("mysql") ? "uc_api_mysql" : "uc_api_post"; |
|
|
|
public static String UC_API_FUNC = UC_CONNECT.equals("mysql") ? "uc_api_mysql" : "uc_api_post"; |
|
|
|
public static String[] uc_controls = {}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected String uc_serialize(String $arr, int $htmlon) { |
|
|
|
|
|
|
|
return $arr; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected String uc_unserialize(String $s) { |
|
|
|
|
|
|
|
return $s; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected String uc_addslashes(String $string, int $force, boolean $strip) { |
|
|
|
public String uc_user_login(String username, String password) { |
|
|
|
return $string; |
|
|
|
return uc_user_login(username, password, 0, 0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected String daddslashes(String $string, int $force) { |
|
|
|
public String uc_user_login(String username, String password, int isuid, int checkques) { |
|
|
|
return uc_addslashes($string, $force, false); |
|
|
|
return uc_user_login(username, password, isuid, checkques, "", ""); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected String uc_stripslashes(String $string) { |
|
|
|
/** |
|
|
|
return $string; |
|
|
|
* 用户登录 |
|
|
|
|
|
|
|
* @param username 用户名 |
|
|
|
|
|
|
|
* @param password 密码 |
|
|
|
|
|
|
|
* @param isuid 是否为uid |
|
|
|
|
|
|
|
* @param checkques 是否使用安全问题 |
|
|
|
|
|
|
|
* @param questionid 安全提问 |
|
|
|
|
|
|
|
* @param answer 安全提问答案 |
|
|
|
|
|
|
|
* @return array (uid/status, username, password, email) |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public String uc_user_login(String username, String password, int isuid, int checkques, String questionid, String answer) { |
|
|
|
|
|
|
|
Map<String, Object> args = new HashMap<>(); |
|
|
|
|
|
|
|
args.put("username", username); |
|
|
|
|
|
|
|
args.put("password", password); |
|
|
|
|
|
|
|
args.put("isuid", isuid); |
|
|
|
|
|
|
|
args.put("checkques", checkques); |
|
|
|
|
|
|
|
args.put("questionid", questionid); |
|
|
|
|
|
|
|
args.put("answer", answer); |
|
|
|
|
|
|
|
String $return = call_user_func(UC_API_FUNC, "user", "login", args); |
|
|
|
|
|
|
|
return UC_CONNECT.equals("mysql") ? $return : $return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String uc_api_post(String $module, String $action, Map<String, Object> $arg) { |
|
|
|
/** |
|
|
|
StringBuffer $s = new StringBuffer(); |
|
|
|
* 拼接发送的post请求 |
|
|
|
String $sep = ""; |
|
|
|
* @param module 模块 |
|
|
|
for (String $k : $arg.keySet()) { |
|
|
|
* @param action 操作模式 |
|
|
|
Object $v = $arg.get($k); |
|
|
|
* @param arg 参数 |
|
|
|
$k = urlencode($k); |
|
|
|
* @return 发送的请求加密内容 |
|
|
|
|
|
|
|
*/ |
|
|
|
if ($v.getClass().isAssignableFrom(Map.class)) { |
|
|
|
public String uc_api_post(String module, String action, Map<String, Object> arg) { |
|
|
|
String $s2 = ""; |
|
|
|
StringBuffer str = new StringBuffer(); |
|
|
|
String $sep2 = ""; |
|
|
|
String sep = ""; |
|
|
|
for (String $k2 : ((Map<String, Object>) $v).keySet()) { |
|
|
|
for (String k : arg.keySet()) { |
|
|
|
Object $v2 = ((Map<String, Object>) $v).get($k2); |
|
|
|
Object v = arg.get(k); |
|
|
|
$k2 = urlencode($k2); |
|
|
|
k = urlencode(k); |
|
|
|
$s2 += $sep2 + "{" + $k + "}[" + $k2 + "]=" + urlencode(uc_stripslashes(String.valueOf($v2))); |
|
|
|
if (v.getClass().isAssignableFrom(Map.class)) { |
|
|
|
$sep2 = "&"; |
|
|
|
String s2 = ""; |
|
|
|
} |
|
|
|
String sep2 = ""; |
|
|
|
$s.append($sep).append($s2); |
|
|
|
for (String k2 : ((Map<String, Object>) v).keySet()) { |
|
|
|
|
|
|
|
Object v2 = ((Map<String, Object>) v).get(k2); |
|
|
|
|
|
|
|
k2 = urlencode(k2); |
|
|
|
|
|
|
|
s2 += sep2 + "{" + k + "}[" + k2 + "]=" + urlencode(String.valueOf(v2)); |
|
|
|
|
|
|
|
sep2 = "&"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
str.append(sep).append(s2); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$s.append($sep).append($k).append("=").append(urlencode(uc_stripslashes(String.valueOf($v)), "GBK")); |
|
|
|
str.append(sep).append(k).append("=").append(urlencode(String.valueOf(v), "GBK")); |
|
|
|
} |
|
|
|
} |
|
|
|
$sep = "&"; |
|
|
|
sep = "&"; |
|
|
|
} |
|
|
|
} |
|
|
|
String $postdata = uc_api_requestdata($module, $action, $s.toString(), ""); |
|
|
|
String $postdata = uc_api_requestdata(module, action, str.toString(), ""); |
|
|
|
return uc_fopen2(UC_API + "/index.php", 500000, $postdata, "", true, UC_IP, 20, true); |
|
|
|
return uc_fopen2(UC_API + "/index.php", 500000, $postdata, "", true, UC_IP, 20, true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected String uc_api_requestdata(String $module, String $action, String $arg, String $extra) { |
|
|
|
public String uc_api_mysql(String model, String action, Map args) { |
|
|
|
String $input = uc_api_input($arg); |
|
|
|
|
|
|
|
String $post = "m=" + $module + "&a=" + $action + "&inajax=2&release=" + UC_CLIENT_RELEASE + "&input=" + $input + "&appid=" + UC_APPID + $extra; |
|
|
|
|
|
|
|
return $post; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected String uc_api_url(String $module, String $action, String $arg, String $extra) { |
|
|
|
|
|
|
|
String $url = UC_API + "/index.php?" + uc_api_requestdata($module, $action, $arg, $extra); |
|
|
|
|
|
|
|
return $url; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String uc_api_input(String $data) { |
|
|
|
|
|
|
|
String $s = urlencode(uc_authcode($data + "&agent=" + md5("") + "&time=" + time(), "ENCODE", UC_KEY), "GBK"); |
|
|
|
|
|
|
|
return $s; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String uc_api_mysql(String $model, String $action, Map $args) { |
|
|
|
|
|
|
|
if ($action.charAt(0) != '_') { |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return ""; |
|
|
|
return ""; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String uc_authcode(String $string, String $operation) { |
|
|
|
public String uc_api_input(String data) { |
|
|
|
return uc_authcode($string, $operation, null); |
|
|
|
String str = urlencode(uc_authcode(data + "&agent=" + md5("") + "&time=" + time(), "ENCODE", UC_KEY), "GBK"); |
|
|
|
|
|
|
|
return str; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String uc_authcode(String $string, String $operation, String $key) { |
|
|
|
protected String uc_api_requestdata(String module, String action, String arg, String extra) { |
|
|
|
return uc_authcode($string, $operation, $key, 0); |
|
|
|
String input = uc_api_input(arg); |
|
|
|
} |
|
|
|
String post = "m=" + module + "&a=" + action + "&inajax=2&release=" + UC_CLIENT_RELEASE + "&input=" + input + "&appid=" + UC_APPID + extra; |
|
|
|
|
|
|
|
return post; |
|
|
|
public String uc_authcode(String $string, String $operation, String $key, int $expiry) { |
|
|
|
|
|
|
|
int $ckey_length = 4; |
|
|
|
|
|
|
|
$key = md5($key != null ? $key : UC_KEY); |
|
|
|
|
|
|
|
String $keya = md5(substr($key, 0, 16)); |
|
|
|
|
|
|
|
String $keyb = md5(substr($key, 16, 16)); |
|
|
|
|
|
|
|
String $keyc = $ckey_length > 0 ? ($operation.equals("DECODE") ? substr($string, 0, $ckey_length) : substr(md5(microtime()), -$ckey_length)) : ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String $cryptkey = $keya + md5($keya + $keyc); |
|
|
|
|
|
|
|
int $key_length = $cryptkey.length(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$string = $operation.equals("DECODE") ? base64_decode(substr($string, $ckey_length)) : sprintf("%010d", $expiry > 0 ? $expiry + time() : 0) + substr(md5($string + $keyb), 0, 16) + $string; |
|
|
|
|
|
|
|
int $string_length = $string.length(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StringBuffer $result1 = new StringBuffer(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int[] $box = new int[256]; |
|
|
|
|
|
|
|
for (int i = 0; i < 256; i++) { |
|
|
|
|
|
|
|
$box[i] = i; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int[] $rndkey = new int[256]; |
|
|
|
public String uc_authcode(String string, String operation, String key) { |
|
|
|
for (int $i = 0; $i <= 255; $i++) { |
|
|
|
return uc_authcode(string, operation, key, 0); |
|
|
|
$rndkey[$i] = (int) $cryptkey.charAt($i % $key_length); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int $j = 0; |
|
|
|
/** |
|
|
|
for (int $i = 0; $i < 256; $i++) { |
|
|
|
* 内容加密 |
|
|
|
$j = ($j + $box[$i] + $rndkey[$i]) % 256; |
|
|
|
* @param string 原文 |
|
|
|
int $tmp = $box[$i]; |
|
|
|
* @param operation decode或者encode |
|
|
|
$box[$i] = $box[$j]; |
|
|
|
* @param key 密钥 |
|
|
|
$box[$j] = $tmp; |
|
|
|
* @param expiry 密文有效时限 |
|
|
|
|
|
|
|
* @return 加密之后的原文 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public String uc_authcode(String string, String operation, String key, int expiry) { |
|
|
|
|
|
|
|
int ckey_length = 4; |
|
|
|
|
|
|
|
key = md5(key != null ? key : UC_KEY); |
|
|
|
|
|
|
|
String keya = md5(substr(key, 0, 16)); |
|
|
|
|
|
|
|
String keyb = md5(substr(key, 16, 16)); |
|
|
|
|
|
|
|
String keyc = ckey_length > 0 ? (operation.equals("DECODE") ? substr(string, 0, ckey_length) : substr(md5(microtime()), - ckey_length)) : ""; |
|
|
|
|
|
|
|
String cryptkey = keya + md5(keya + keyc); |
|
|
|
|
|
|
|
int key_length = cryptkey.length(); |
|
|
|
|
|
|
|
string = operation.equals("DECODE") ? base64_decode(substr(string, ckey_length)) : sprintf("%010d", expiry > 0 ? expiry + time() : 0) + substr(md5(string + keyb), 0, 16) + string; |
|
|
|
|
|
|
|
int string_length = string.length(); |
|
|
|
|
|
|
|
StringBuffer result1 = new StringBuffer(); |
|
|
|
|
|
|
|
int[] box = new int[256]; |
|
|
|
|
|
|
|
for (int i = 0; i < 256; i++) { |
|
|
|
|
|
|
|
box[i] = i; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
int[] rndkey = new int[256]; |
|
|
|
$j = 0; |
|
|
|
for (int i = 0; i <= 255; i++) { |
|
|
|
int $a = 0; |
|
|
|
rndkey[i] = (int) cryptkey.charAt(i % key_length); |
|
|
|
for (int $i = 0; $i < $string_length; $i++) { |
|
|
|
|
|
|
|
$a = ($a + 1) % 256; |
|
|
|
|
|
|
|
$j = ($j + $box[$a]) % 256; |
|
|
|
|
|
|
|
int $tmp = $box[$a]; |
|
|
|
|
|
|
|
$box[$a] = $box[$j]; |
|
|
|
|
|
|
|
$box[$j] = $tmp; |
|
|
|
|
|
|
|
$result1.append((char) (((int) $string.charAt($i)) ^ ($box[($box[$a] + $box[$j]) % 256]))); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if ($operation.equals("DECODE")) { |
|
|
|
int j = 0; |
|
|
|
String $result = $result1.toString(); |
|
|
|
for (int i = 0; i < 256; i++) { |
|
|
|
|
|
|
|
j = (j + box[i] + rndkey[i]) % 256; |
|
|
|
|
|
|
|
int tmp = box[i]; |
|
|
|
|
|
|
|
box[i] = box[j]; |
|
|
|
|
|
|
|
box[j] = tmp; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
j = 0; |
|
|
|
|
|
|
|
int a = 0; |
|
|
|
|
|
|
|
for (int i = 0; i < string_length; i++) { |
|
|
|
|
|
|
|
a = (a + 1) % 256; |
|
|
|
|
|
|
|
j = (j + box[a]) % 256; |
|
|
|
|
|
|
|
int tmp = box[a]; |
|
|
|
|
|
|
|
box[a] = box[j]; |
|
|
|
|
|
|
|
box[j] = tmp; |
|
|
|
|
|
|
|
result1.append((char) (((int) string.charAt(i)) ^ (box[(box[a] + box[j]) % 256]))); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (operation.equals("DECODE")) { |
|
|
|
|
|
|
|
String result = result1.toString(); |
|
|
|
try { |
|
|
|
try { |
|
|
|
$result = new String($result.getBytes("iso-8859-1"), "gbk"); |
|
|
|
result = new String(result.getBytes("iso-8859-1"), "gbk"); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
$result = $result1.substring(0, $result1.length()); |
|
|
|
result = result1.substring(0, result1.length()); |
|
|
|
} |
|
|
|
} |
|
|
|
if ((Integer.parseInt(substr($result.toString(), 0, 10)) == 0 || Long.parseLong(substr($result.toString(), 0, 10)) - time() > 0) && substr($result.toString(), 10, 16).equals(substr(md5(substr($result.toString(), 26) + $keyb), 0, 16))) { |
|
|
|
if ((Integer.parseInt(substr(result.toString(), 0, 10)) == 0 || Long.parseLong(substr(result.toString(), 0, 10)) - time() > 0) && substr(result.toString(), 10, 16).equals(substr(md5(substr(result.toString(), 26) + keyb), 0, 16))) { |
|
|
|
return substr($result.toString(), 26); |
|
|
|
return substr(result.toString(), 26); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
return ""; |
|
|
|
return ""; |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
return $keyc + base64_encode($result1.toString()).replaceAll("=", ""); |
|
|
|
return keyc + base64_encode(result1.toString()).replaceAll("=", ""); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected String uc_fopen2(String $url, int $limit, String $post, String $cookie, boolean $bysocket, String $ip, int $timeout, boolean $block) { |
|
|
|
protected String uc_fopen2(String url, int limit, String post, String cookie, boolean bysocket, String ip, int timeout, boolean block) { |
|
|
|
$url += $url.indexOf("?") > 0 ? "&" : "?" + "__times__=1"; |
|
|
|
url += url.indexOf("?") > 0 ? "&" : "?" + "__times__=1"; |
|
|
|
return uc_fopen($url, $limit, $post, $cookie, $bysocket, $ip, $timeout, $block); |
|
|
|
return uc_fopen(url, limit, post, cookie, bysocket, ip, timeout, block); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected String uc_fopen(String $url, int $limit, String $post, String $cookie, boolean $bysocket, String $ip, int $timeout, boolean $block) { |
|
|
|
/** |
|
|
|
String $return = ""; |
|
|
|
* 本地模网络请求取数据 |
|
|
|
|
|
|
|
* @param url 打开的url |
|
|
|
URL $matches; |
|
|
|
* @param limit 取返回的数据的长度 |
|
|
|
String $host = ""; |
|
|
|
* @param post 要发送的 POST 数据,如uid=1&password=1234 |
|
|
|
String $path = ""; |
|
|
|
* @param cookie 要模拟的 COOKIE 数据,如uid=123&auth=a2323sd2323 |
|
|
|
int $port = 80; |
|
|
|
* @param bysocket TRUE/FALSE 是否通过SOCKET打开 |
|
|
|
|
|
|
|
* @param ip IP地址 |
|
|
|
|
|
|
|
* @param timeout 连接超时时间 |
|
|
|
|
|
|
|
* @param block 是否为阻塞模式 defaul valuet:true |
|
|
|
|
|
|
|
* @return 取到的字符串 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
protected String uc_fopen(String url, int limit, String post, String cookie, boolean bysocket, String ip, int timeout, boolean block) { |
|
|
|
|
|
|
|
String result = ""; |
|
|
|
|
|
|
|
URL matches; |
|
|
|
|
|
|
|
String host = ""; |
|
|
|
|
|
|
|
String path = ""; |
|
|
|
|
|
|
|
int port = 80; |
|
|
|
try { |
|
|
|
try { |
|
|
|
$matches = new URL($url); |
|
|
|
matches = new URL(url); |
|
|
|
$host = $matches.getHost(); |
|
|
|
host = matches.getHost(); |
|
|
|
$path = $matches.getPath() != null ? $matches.getPath() + ($matches.getQuery() != null ? "?" + $matches.getQuery() : "") : "/"; |
|
|
|
path = matches.getPath() != null ? matches.getPath() + (matches.getQuery() != null ? "?" + matches.getQuery() : "") : "/"; |
|
|
|
if ($matches.getPort() > 0) $port = $matches.getPort(); |
|
|
|
if (matches.getPort() > 0) port = matches.getPort(); |
|
|
|
} catch (MalformedURLException e1) { |
|
|
|
} catch (Exception e1) { |
|
|
|
} |
|
|
|
FRContext.getLogger().info(e1.getMessage()); |
|
|
|
StringBuffer $out = new StringBuffer(); |
|
|
|
} |
|
|
|
if ($post != null && $post.length() > 0) { |
|
|
|
StringBuffer out = new StringBuffer(); |
|
|
|
$out.append("POST ").append($path).append(" HTTP/1.0\r\n"); |
|
|
|
if (post != null && post.length() > 0) { |
|
|
|
$out.append("Accept: */*\r\n"); |
|
|
|
out.append("POST ").append(path).append(" HTTP/1.0\r\n"); |
|
|
|
$out.append("Accept-Language: zh-cn\r\n"); |
|
|
|
out.append("Accept: */*\r\n"); |
|
|
|
$out.append("Content-Type: application/x-www-form-urlencoded\r\n"); |
|
|
|
out.append("Accept-Language: zh-cn\r\n"); |
|
|
|
$out.append("User-Agent: \r\n"); |
|
|
|
out.append("Content-Type: application/x-www-form-urlencoded\r\n"); |
|
|
|
$out.append("Host: ").append($host).append("\r\n"); |
|
|
|
out.append("User-Agent: \r\n"); |
|
|
|
$out.append("Content-Length: ").append($post.length()).append("\r\n"); |
|
|
|
out.append("Host: ").append(host).append("\r\n"); |
|
|
|
$out.append("Connection: Close\r\n"); |
|
|
|
out.append("Content-Length: ").append(post.length()).append("\r\n"); |
|
|
|
$out.append("Cache-Control: no-cache\r\n"); |
|
|
|
out.append("Connection: Close\r\n"); |
|
|
|
$out.append("Cookie: \r\n\r\n"); |
|
|
|
out.append("Cache-Control: no-cache\r\n"); |
|
|
|
$out.append($post); |
|
|
|
out.append("Cookie: \r\n\r\n"); |
|
|
|
|
|
|
|
out.append(post); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$out.append("GET $path HTTP/1.0\r\n"); |
|
|
|
out.append("GET $path HTTP/1.0\r\n"); |
|
|
|
$out.append("Accept: */*\r\n"); |
|
|
|
out.append("Accept: */*\r\n"); |
|
|
|
$out.append("Accept-Language: zh-cn\r\n"); |
|
|
|
out.append("Accept-Language: zh-cn\r\n"); |
|
|
|
$out.append("User-Agent: Java/1.5.0_01\r\n"); |
|
|
|
out.append("User-Agent: Java/1.5.0_01\r\n"); |
|
|
|
$out.append("Host: $host\r\n"); |
|
|
|
out.append("Host: $host\r\n"); |
|
|
|
$out.append("Connection: Close\r\n"); |
|
|
|
out.append("Connection: Close\r\n"); |
|
|
|
$out.append("Cookie: $cookie\r\n\r\n"); |
|
|
|
out.append("Cookie: $cookie\r\n\r\n"); |
|
|
|
} |
|
|
|
} |
|
|
|
try { |
|
|
|
try { |
|
|
|
Socket $fp = new Socket($ip != null && $ip.length() > 10 ? $ip : $host, $port); |
|
|
|
Socket fp = new Socket(ip != null && ip.length() > 10 ? ip : host, port); |
|
|
|
if (!$fp.isConnected()) { |
|
|
|
if (!fp.isConnected()) { |
|
|
|
return ""; |
|
|
|
return ""; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
OutputStream os = $fp.getOutputStream(); |
|
|
|
OutputStream os = fp.getOutputStream(); |
|
|
|
os.write($out.toString().getBytes()); |
|
|
|
os.write(out.toString().getBytes()); |
|
|
|
InputStream ins = $fp.getInputStream(); |
|
|
|
InputStream ins = fp.getInputStream(); |
|
|
|
BufferedReader reader = new BufferedReader(new InputStreamReader(ins, "iso-8859-1")); |
|
|
|
BufferedReader reader = new BufferedReader(new InputStreamReader(ins, "iso-8859-1")); |
|
|
|
while (true) { |
|
|
|
while (true) { |
|
|
|
String $header = reader.readLine(); |
|
|
|
String header = reader.readLine(); |
|
|
|
if ($header == null || $header.equals("") || $header == "\r\n" || $header == "\n") { |
|
|
|
if (header == null || header.equals("") || header == "\r\n" || header == "\n") { |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
while (true) { |
|
|
|
while (true) { |
|
|
|
String $data = reader.readLine(); |
|
|
|
String data = reader.readLine(); |
|
|
|
if ($data == null || $data.equals("")) { |
|
|
|
if (data == null || data.equals("")) { |
|
|
|
break; |
|
|
|
break; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$return += $data; |
|
|
|
result += data; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
$fp.close(); |
|
|
|
fp.close(); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (IOException e) { |
|
|
|
} catch (IOException e) { |
|
|
|
|
|
|
|
FRContext.getLogger().info(e.getMessage()); |
|
|
|
} |
|
|
|
|
|
|
|
return $return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String uc_app_ls() { |
|
|
|
|
|
|
|
String $return = call_user_func(UC_API_FUNC, "app", "ls", null); |
|
|
|
|
|
|
|
return UC_CONNECT.equals("mysql") ? $return : uc_unserialize($return); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String uc_user_register(String $username, String $password, String $email) { |
|
|
|
|
|
|
|
return uc_user_register($username, $password, $email, "", ""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String uc_user_register(String $username, String $password, String $email, String $questionid, String $answer) { |
|
|
|
|
|
|
|
Map<String, Object> args = new HashMap<String, Object>(); |
|
|
|
|
|
|
|
args.put("username", $username); |
|
|
|
|
|
|
|
args.put("password", $password); |
|
|
|
|
|
|
|
args.put("email", $email); |
|
|
|
|
|
|
|
args.put("questionid", $questionid); |
|
|
|
|
|
|
|
args.put("answer", $answer); |
|
|
|
|
|
|
|
return call_user_func(UC_API_FUNC, "user", "register", args); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String uc_user_login(String $username, String $password) { |
|
|
|
|
|
|
|
return uc_user_login($username, $password, 0, 0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String uc_user_login(String $username, String $password, int $isuid, int $checkques) { |
|
|
|
|
|
|
|
return uc_user_login($username, $password, $isuid, $checkques, "", ""); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return result; |
|
|
|
/** |
|
|
|
|
|
|
|
* 获取登录信息 |
|
|
|
|
|
|
|
* @param $username |
|
|
|
|
|
|
|
* @param $password |
|
|
|
|
|
|
|
* @param $isuid |
|
|
|
|
|
|
|
* @param $checkques |
|
|
|
|
|
|
|
* @param $questionid |
|
|
|
|
|
|
|
* @param $answer |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public String uc_user_login(String $username, String $password, int $isuid, int $checkques, String $questionid, String $answer) { |
|
|
|
|
|
|
|
Map<String, Object> args = new HashMap<String, Object>(); |
|
|
|
|
|
|
|
args.put("username", $username); |
|
|
|
|
|
|
|
args.put("password", $password); |
|
|
|
|
|
|
|
args.put("isuid", $isuid); |
|
|
|
|
|
|
|
args.put("checkques", $checkques); |
|
|
|
|
|
|
|
args.put("questionid", $questionid); |
|
|
|
|
|
|
|
args.put("answer", $answer); |
|
|
|
|
|
|
|
String $return = call_user_func(UC_API_FUNC, "user", "login", args); |
|
|
|
|
|
|
|
return UC_CONNECT.equals("mysql") ? $return : uc_unserialize($return); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String uc_user_synlogin(int $uid) { |
|
|
|
|
|
|
|
Map<String, Object> args = new HashMap<String, Object>(); |
|
|
|
|
|
|
|
args.put("uid", $uid); |
|
|
|
|
|
|
|
String $return = uc_api_post("user", "synlogin", args); |
|
|
|
|
|
|
|
return $return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String uc_user_synlogout() { |
|
|
|
|
|
|
|
String $return = uc_api_post("user", "synlogout", new HashMap<String, Object>()); |
|
|
|
|
|
|
|
return $return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String uc_get_user(String $username, int $isuid) { |
|
|
|
|
|
|
|
Map<String, Object> args = new HashMap<String, Object>(); |
|
|
|
|
|
|
|
args.put("username", $username); |
|
|
|
|
|
|
|
args.put("isuid", $isuid); |
|
|
|
|
|
|
|
String $return = call_user_func(UC_API_FUNC, "user", "get_user", args); |
|
|
|
|
|
|
|
return UC_CONNECT.equals("mysql") ? $return : uc_unserialize($return); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String uc_user_edit(String $username, String $oldpw, String $newpw, String $email, int $ignoreoldpw, String $questionid, String $answer) { |
|
|
|
|
|
|
|
Map<String, Object> args = new HashMap<String, Object>(); |
|
|
|
|
|
|
|
args.put("username", $username); |
|
|
|
|
|
|
|
args.put("oldpw", $oldpw); |
|
|
|
|
|
|
|
args.put("newpw", $newpw); |
|
|
|
|
|
|
|
args.put("email", $email); |
|
|
|
|
|
|
|
args.put("ignoreoldpw", $ignoreoldpw); |
|
|
|
|
|
|
|
args.put("questionid", $questionid); |
|
|
|
|
|
|
|
args.put("answer", $answer); |
|
|
|
|
|
|
|
return call_user_func(UC_API_FUNC, "user", "edit", args); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String uc_user_delete(String $uid) { |
|
|
|
|
|
|
|
Map<String, Object> args = new HashMap<String, Object>(); |
|
|
|
|
|
|
|
args.put("uid", $uid); |
|
|
|
|
|
|
|
return call_user_func(UC_API_FUNC, "user", "delete", args); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String uc_user_deleteavatar(String $uid) { |
|
|
|
|
|
|
|
Map<String, Object> args = new HashMap<String, Object>(); |
|
|
|
|
|
|
|
args.put("uid", $uid); |
|
|
|
|
|
|
|
return uc_api_post("user", "deleteavatar", args); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |