<!--#include file="conn.asp"-->
<!--#include file="user_chkpass.asp"-->
<!--#include file="inc/function.asp"-->
<link href="Admin_STYLE.CSS" rel="stylesheet" type="text/css">
<title>更新blog数据</title>
<body leftmargin="2" topmargin="0" marginwidth="0" marginheight="0" class="bgcolor">
<%
if CheckUserLogined()=False then
	response.Redirect "user_login.asp"
end if

dim action,rs,sql,trs
action=request("action")
if action="DoUpdate" then
	Set rs=Server.CreateObject("Adodb.RecordSet")
	sql="select * from [user] where username='"&username&"'"
	rs.Open sql,Conn,1,3
	set trs=Conn.execute("select count(ID) from [blog] where username='"&username&"'")
	if isNull(trs(0)) then
		rs("logcount")=0
	else
		rs("logcount")=trs(0)
	end if
	set trs=Conn.execute("select count(ID) from comment where mainuser='"&username&"'")
	if isNull(trs(0)) then
		rs("commentcount")=0
	else
		rs("commentcount")=trs(0)
	end if
	set trs=Conn.execute("select count(ID) from message where mainuser='"&username&"'")
	if isNull(trs(0)) then
		rs("messagecount")=0
	else
		rs("messagecount")=trs(0)
	end if
	rs.update
	rs.close
	
	sql="select * from subject where username='"&username&"'"
	rs.open sql,conn,1,3
	while not rs.eof
		set trs=conn.execute("select count(id) from blog where subjectid="&rs("id"))
		if isnull(trs(0)) then
			rs("subjectlognum")=0
		else
			rs("subjectlognum")=trs(0)
		end if
		rs.update
		rs.movenext
	wend
	
	rs.close
	set rs=nothing
	set trs=nothing
	response.Write("<br>已经成功将blog数据进行了更新！")
	else
	%>

<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="25" colspan="2"><strong><font color="#FFFFFF">更 新 系 统 数 据</font></strong></td>
  </tr>
  <tr class="tdbg">
    <td colspan="2"><p>说明：<br>
        　　本操作将重新自己的日志数，评论数，留言数及专题文章数量，建议在统计数据不准的情况下使用。<br>
        </p></td>
  </tr>
  <tr class="tdbg">
    <td height="25">&nbsp;</td>
    <td height="25"><input name="Submit" type="submit" id="Submit" value="更新blog数据">
    <input name="Action" type="hidden" id="Action" value="DoUpdate"></td>
  </tr>
</table>
   </form>

<%
end if
%>
