<!--#include file="conn.asp"-->
<!--#include file="Admin_Chkpass.asp"-->
<link href="Admin_STYLE.CSS" rel="stylesheet" type="text/css">
<body leftmargin="2" topmargin="0" marginwidth="0" marginheight="0" class="bgcolor">
<%
dim action,rs,sql,trs
action=request("action")
if action="DoUpdate" then
	Set rs=Server.CreateObject("Adodb.RecordSet")
	sql="select * from bloginfo"
	rs.Open sql,Conn,1,3
	set trs=Conn.execute("select count(ID) from [blog]")
	if isNull(trs(0)) then
		rs("logcount")=0
	else
		rs("logcount")=trs(0)
	end if
	set trs=Conn.execute("select count(ID) from comment")
	if isNull(trs(0)) then
		rs("commentcount")=0
	else
		rs("commentcount")=trs(0)
	end if
	set trs=Conn.execute("select count(ID) from message")
	if isNull(trs(0)) then
		rs("messagecount")=0
	else
		rs("messagecount")=trs(0)
	end if
	set trs=Conn.execute("select count(userID) from [user]")
	if isNull(trs(0)) then
		rs("usercount")=0
	else
		rs("usercount")=trs(0)
	end if
	rs.update
	rs.close

	sql="select * from classname"
	rs.open sql,conn,1,3
	while not rs.eof
		set trs=conn.execute("select count(id) from blog where classid="&rs("id"))
		if isnull(trs(0)) then
			rs("classlognum")=0
		else
			rs("classlognum")=trs(0)
		end if
		rs.update
		rs.movenext
	wend
	rs.close
	
	'sql="select id,commentnum from blog"
	'rs.open sql,conn,1,3
	'while not rs.eof
	'	set trs=conn.execute("select count(id) from comment where mainid="&rs(0))
	'	if isnull(trs(0)) then
	'		rs(1)=0
	'	else
	'		rs(1)=trs(0)
	'	end if
	'	rs.update
	'	rs.movenext
	'wend
	'rs.close
	
	set rs=nothing
	set trs=nothing
	call PutApplicationValue()
	call closeconn
	response.Write("<br>已经成功将系统数据进行了更新！")
	else
	%>
	
<title>更新系统数据</title><form name="form1" method="post" action="">
<br>
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#FFFFFF" class="border">
  <tr align="center" class="title">
    <td height="22" colspan="2"><strong><font color="#FFFFFF">更 新 系 统 数 据</font></strong></td>
  </tr>
  <tr class="tdbg">
    <td colspan="2"><p>说明：<br>
        1、本操作将重新计算系统的日志，评论，留言数。<br>
        2、本操作可能将非常消耗服务器资源，而且更新时间很长，请仔细确认每一步操作后执行。</p></td>
  </tr>
  <tr class="tdbg">
    <td height="25">&nbsp;</td>
    <td height="25"><input name="Submit" type="submit" id="Submit" value="更新系统数据">
    <input name="Action" type="hidden" id="Action" value="DoUpdate"></td>
  </tr>
</table>
   </form>
<%
end if
%>

