文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>javascript+xmlhttp+dom写的一个统计小版主参与帖子和得分帖子数量的工具

javascript+xmlhttp+dom写的一个统计小版主参与帖子和得分帖子数量的工具

时间:2007-02-17  来源:PHP爱好者

因为版主工作的需要,需要统计小版主的工作,以前总是用版主管理的回复查询手工统计,累的受不了了,用javascript + xmlhttp + dom 写了个统计工具。
以下是代码,请在晚上或周末的时候进行统计,要不速度太慢统计不出来
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>版主统计</title>
<script language=javascript>var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.4.0");
xmlDoc.async = false;function getSmallRoomList(doc,bigRoomId)  //得到大版下的小版列表
{
var url = "http://expert.csdn.net/Expert/deeptree/rooms/" + bigRoomId + "/list.xml"
doc.load(url);
var nodeList = doc.documentElement.selectNodes("//Tree/TreeNode");
var listArray = new Array(nodeList.length);
for(var i=0;i<nodeList.length;i++)
{
listArray = new Array(nodeList.getAttribute("NodeId"),nodeList.getAttribute("Title"));
}
return listArray;
}
function getSmallMasterList(doc,smallRoomId)  //得到小版的版主列表
{
var url = "http://expert.csdn.net/Expert/Rooms/small/" + smallRoomId + "/Forum_" + smallRoomId + "_1.xml"
doc.load(url);
var line2 = doc.documentElement.selectSingleNode("//Forum/Top/Line2");
var tmpStr = line2.text;
var re=/">[Ss]*</ig;
var smallMasterList=tmpStr.match(re)
for(var i=0;i<smallMasterList.length;i++)
{
smallMasterList = smallMasterList.substr(2,smallMasterList.length-3);
}
return smallMasterList
}function streamtochar(StrStream)
{ var stream = new ActiveXObject("ADODB.Stream");
stream.type=1;
stream.Mode=3;
stream.Open() ;
stream.Write(StrStream);
stream.Position= 0;
stream.Type= 2;
stream.Charset="gb2312";
var result= stream.ReadText();
stream.Close();
stream = null;
return result;
}function getTopicslist(ReplyUserName,roomId,type,month,year)  //得到帖子数量列表
{
var url = "http://expert.csdn.net/xxx/xxx.aspx?room=" + roomId + "&type=" + type + "&ReplyUserName=" + ReplyUserName + "&month=" + month + "&year=" + year;  //这个地址CSDN还没有公开,所以我替换成xxx了,需要的朋友请找我要这个地址!
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.Open("GET",url, false); try
{
xmlhttp.Send();
var result = xmlhttp.status;
}
catch(e)
{
 return(false);
} if(result==200)
{
var tmp = streamtochar(xmlhttp.responseBody);
var re = /<td colspan="4" align="left">[Ss]*<font color=red>/ig;
try
{
tmp = tmp.match(re);
tmp = tmp[0]
tmp = tmp.split(":")[1]
tmp = tmp.split(",")[0]
return tmp;
}
catch(e)
{
//
}
} var xmlhttp = null;}
function drawTable(sRoomList)  //输出结果
{
var resultStr = "";
resultStr += "<table border=1 width="100%">";
for(var i = 0 ;i<sRoomList.length;i++)
{
resultStr += "<tr bgcolor="#00CCFF">";
resultStr += "<td>" + sRoomList[1] + "版</td>";
resultStr += "</tr>";  resultStr += "<tr>";
resultStr += "<td>";  resultStr += "<table width="100%"  border="1" cellpadding="0" cellspacing="0" bordercolor="#CCCCCC">";

resultStr += "<tr>";  resultStr += "<td>版主</td>";
  resultStr += "<td>参与的帖子</td>";
resultStr += "<td>得分的帖子</td>";  
resultStr += "</tr>";
var smallRoomId = sRoomList[0].substr(8,sRoomList[0].length)
var smallMasterList = getSmallMasterList(xmlDoc,smallRoomId)
for(var j = 0;j <smallMasterList.length;j++)
{
if(smallMasterList[j]=="我要申请")
continue;
resultStr += "<tr>";
resultStr += "<td>" + smallMasterList[j] + "</td>";
resultStr += "<td>" + getTopicslist(smallMasterList[j],smallRoomId,"2","12","2003") + "</td>";
resultStr += "<td>"+ getTopicslist(smallMasterList[j],smallRoomId,"1","12","2003") +"</td>";
resultStr += "</tr>";
}  resultStr += "</table>";
resultStr += "</td>";
resultStr += "</tr>";  
}
resultStr += "</table>"; 
return resultStr;
}function doIt()
{
if(bigRoomId.value=="")
{
alert("请输入大版ID");
return;
}
var smallRoomList = getSmallRoomList(xmlDoc,bigRoomId.value)
result.innerHTML = drawTable(smallRoomList);
}
</script>
</head><body>
<p align="center" class="style2">版主统计工具</p>
<p align="left">作者:awaysrain(绝对零度)<br>
时间:2004年1月2日<br>
版本:1.0测试版<br>
运行环境:IE6</p>
<p>请输入大版ID
<input type="text" name="bigRoomId" value="3">
<input type="submit" name="Submit" value="开始统计" onclick="doIt()">
<span class="style1">(建议在晚上或者周末人少的时候进行统计,速度太慢了统计不出来)</span></p>
<div id="result"></div>
</body>
</html>
php爱 好者站 http://www.phpfans.net 文章|教程|下载|源码|论坛.
相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载