|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
×
ASP代码
<%
dim objXMLHTTP, qq, pwd
qq = "100000"
pwd = "123456"
set objXMLHTTP = Server.CreateObject("MSXML2.XMLHTTP.5.0")
objXMLHTTP.open "OST", "http://211.139.167.71/waptest/TW ... /updateuserinfo.jsp", false
objXMLHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
objXMLHTTP.setRequestHeader "Connection", "Keep-Alive"
objXMLHTTP.send("qq="&qq&"&pwd="&pwd&"&FromWhere=register")
if InStr(objXMLHTTP.responseText, "验证失败") then
response.write "登录失败"
else
response.write "登录成功"
end if
set objXMLHTTP = nothing
%>
JS代码:<p><span id="msg"></span><p><input type="button" onclick="doIt()" id="btn" value="登录" />
<script type="text/javascript">
var qq = "100000";
var pwd = "123456";
var sessionid = "";
var online = false;
var re;
if (window.XMLHttpRequest) {
var x = new XMLHttpRequest();
} else {
var MSXML = new Array('MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'Microsoft.XMLHTTP');
for(var n = 0; n < MSXML.length; n ++) {
try {
var objXMLHTTP = new ActiveXObject(MSXML[n]);
break;
} catch(e) {
}
}
}
function sendReq(method, url, data, callback) {
with (objXMLHTTP) {
open(method, url, false);
setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
setRequestHeader("Connection", "Keep-Alive");
send(data);
}
setTimeout(callback, 1);
}
function checkLogin() {
if (objXMLHTTP.responseText.indexOf("postfield") > 0) {
setMsg("密码错误或者号码不正确");
} else {
sessionid = objXMLHTTP.getResponseHeader("Set-Cookie").match(/JSESSIONID=([^;]+);/i)[1];
sendReq("GET", "http://211.139.167.71/waptest/TW ... ait.jsp;jsessionid=" + sessionid + "?changestatus=40&random=" + Math.random()+ "&FromWhere=qqchatChangestatus", "", "setMsg('wait...');");
online = true;
setStatus();
setBtn();
re = setInterval("changeStatus();", 10000);
}
}
function changeStatus() {
sendReq("GET", "http://211.139.167.71/waptest/server;jsessionid=" + sessionid + "?productid=qqportal&actionid=qqchatChangestatus&saveURL=0&changestatus=40&random=" + Math.random(), "", "setMsg('wait');");
sendReq("GET", "http://211.139.167.71/waptest/TW ... ion.jsp;jsessionid=" + sessionid + "?qqlogout=1", "", "setStatus();");
}
function setStatus() {
if (objXMLHTTP.responseText.match(/[d+]((d+))/i)) {
setMsg("QQ隐身,并有" + objXMLHTTP.responseText.match(/[d+]((d+))/i)[1] + "条新消息");
online = true;
} else if ( objXMLHTTP.responseText.match(/qqlogout=first">(.*)\[\d+\]/i)) {
setMsg(objXMLHTTP.responseText.match(/qqlogout=first">(.*)[d+]/i)[1]);
online = true;
} else {
setMsg("QQ离线");
online = false;
}
setBtn();
}
function logout() {
sendReq("GET", "http://211.139.167.71/waptest/server;jsessionid=" + sessionid + "?productid=qqportal&actionid=qqchatChangestatus&saveURL=0&changestatus=20&random=" + Math.random(), "", "setMsg('qq离线');");
clearInterval(re);
online = false;
setBtn();
}
function setBtn() {
if (online) {
btn.value = "断开";
btn.onclick = logout;
} else {
btn.value = "登录";
btn.onclick = doIt;
}
}
function setMsg(str) {
document.getElementById("msg").innerHTML = str;
}
function doIt() {
sendReq("OST", "http://211.139.167.71/waptest/TW ... /updateuserinfo.jsp", "qq=" + qq + "&pwd=" + pwd + "&FromWhere=register", "checkLogin();");
}
</script> |
|