<!--#include file="user_top.asp"-->
<!--#include file="inc/class_blog.asp"-->
<div id="main">
  <div class="submenu">
  	<div class="side_c1 side11"></div>
    <div class="side_c2 side21"></div>
	<div class="submenu_content">
	</div>
  </div>
  <div class="content">
  	<div class="content_top">
		  	<div class="side_d1 side11"></div>
		    <div class="side_d2 side21"></div>
			发布更新
	</div>
	
    <div class="content_body">
<%
dim action,blog
Dim totalPut,TotalPages,MaxPerPage,strFileName
action=request("action")
set blog=new class_blog
Server.ScriptTimeOut=999999999
select case action
	case "update_message"
		Call update_message
	case "update_blog"
		Call update_blog
	case "update_alllog"
		Call update_alllog 
	case else
	call main()
end select
set blog=nothing
%>
	</div>
	
    <div class="content_bot">
		  	<div class="side_e1 side12"></div>
   			<div class="side_e2 side22"></div>
 	</div>
	
  </div>
</div>   
  
  <div id="bottom"><%=oblog.user_copyright%></div>

</body>
</html>
<%
sub main
%>
<h1>发布更新静态页面</h1>
<div id="list">
	<ul class="list_edit">
	当数据和静态页面不同步时，可以手动更新首页文件或统计数据。<hr />
	<form>
	<input type="button" value="更新整站首页" onClick="window.location='user_update.asp?action=update_blog'" />
	　<input type="button" value="更新留言板"  onclick="window.location='user_update.asp?action=update_message'" />
	　<input type="button" value="更新统计数据" onClick="window.location='user_update.asp?action=update_blog'" /></form>
	<br /><br />
	重新发布全站较耗费系统资源，请谨慎使用!<br />
	<%If CLNG(oblog.setup(26,0))>0 Then %>
	(每天只能进行<%=oblog.setup(26,0)%>次!)<hr />
	<%End If%>
	<form><input type="button" value="重新发布全站" onClick="window.location='user_update.asp?action=update_alllog'" /></form>
	</ul>
</div>
<%end sub

sub update_message()
	const p=4
	response.Write("<div id=""prompt""><ul>")
	blog.progress_init
	blog.progress int(1/p*100),"读取用户数据..."
	blog.userid=oblog.logined_uid
	blog.progress int(2/p*100),"更新留言板..."
	'blog.update_message 1,0,0,""
	blog.update_message 1
	blog.progress int(3/p*100),"更新最新留言..."
	blog.update_newmessage oblog.logined_uid
	blog.progress int(4/p*100),"更新留言完成!"
	response.Write("<li><a href='javascript:history.go(-1)'>&lt;&lt; 返回上一页</a></li></ul></div>")
end sub

sub update_blog()
	dim rsu,rst,n_log,n_comment,n_message	
	const p=10
	response.Write("<div id=""prompt""><ul>")
	blog.progress_init
	blog.progress int(1/p*100),"更新全站统计数据..."
	set rsu=oblog.execute("select count(logid) from oblog_log where userid="&oblog.logined_uid)
	if not rsu.eof then n_log=rsu(0) else n_log=0
	set rsu=oblog.execute("select count(commentid) from oblog_comment where userid="&oblog.logined_uid)
	if not rsu.eof then n_comment=rsu(0) else n_comment=0
	set rsu=oblog.execute("select count(messageid) from oblog_message where userid="&oblog.logined_uid)
	if not rsu.eof then n_message=rsu(0) else n_message=0
	oblog.execute("update oblog_user set log_count="&n_log&",comment_count="&n_comment&",message_count="&n_message&" where userid="&oblog.logined_uid)
	
	blog.progress int(2/p*100),"更新分类统计数据..."
	set rst=server.createobject("adodb.recordset")
	rst.open "select subjectid,subjectlognum from oblog_subject where userid="&oblog.logined_uid,conn,2,2
	while not rst.eof
		set rsu=oblog.execute("select count(logid) from oblog_log where subjectid="&rst("subjectid"))
		if not rsu.eof then rst("subjectlognum")=rsu(0) else rst("subjectlognum")=0
		rst.update
		rst.movenext		
	wend
	rst.close
	set rst=nothing
	set rsu=nothing	
	
	blog.progress int(3/p*100),"读取用户数据..."
	blog.userid=oblog.logined_uid
	blog.progress int(4/p*100),"更新首页..."
	blog.update_index 1
	blog.progress int(5/p*100),"更新站点信息文件..."
	blog.update_info oblog.logined_uid
	blog.progress int(6/p*100),"生成新日志列表文件..."
	blog.update_newblog(oblog.logined_uid)
	blog.progress int(7/p*100),"更新最新留言..."
	blog.update_newmessage oblog.logined_uid
	blog.progress int(8/p*100),"生成首页日志分类文件..."
	blog.update_subject(oblog.logined_uid)
	blog.progress int(9/p*100),"生成功能页面..."
	blog.CreateFunctionPage
	blog.progress int(10/p*100),"更新整站首页完成!"
	response.Write("<li><a href='javascript:history.go(-1)'>&lt;&lt; 返回上一页</a></li></ul></div>")
end sub

sub update_alllog()
	dim updateblognum,lastlogid
	Dim NowUsers
	NowUsers=Application(oblog.cache_name&"Sequence_Users_Now")
	If NowUsers="" Then NowUsers=0
	If C_Sequence_Max<>0 And IsNumeric(C_Sequence_Max) Then
		If CLNG(NowUsers)>CLNG(C_Sequence_Max) Then
			oblog.adderrstr("网站更新数目已经达到系统限制,请稍后进行更新")
			oblog.showusererr
			Exit Sub
		End If
		
		If Application(oblog.cache_name&"Sequence_Admin")="1" Then
			oblog.adderrstr("系统正在进行自动更新，请稍后进行更新")
			oblog.showusererr
			Exit Sub
		End If
	End If
	
	lastlogid=trim(request("lastlogid"))
	if lastlogid<>"" then lastlogid=clng(lastlogid) else lastlogid=0
	updateblognum=request.Cookies(cookies_name&"uplognum")("updateblognum")
	if updateblognum="" or isnull(updateblognum) then updateblognum=0
	'updateblognum=0
	If clng(oblog.setup(26,0))=0 Then 
		updateblognum=0
	Else
		if clng(updateblognum)>=clng(oblog.setup(26,0)) and lastlogid=0 then
			oblog.adderrstr("整站更新每天只能进行"&oblog.setup(26,0)&"次!")
			oblog.showusererr
			exit sub
		end if
	End if
	'进行计数
	If Application(oblog.cache_name&"Sequence_Users_Now")="" Or CLNG(Application(oblog.cache_name&"Sequence_Users_Now"))<=0 Then Application(oblog.cache_name&"Sequence_Users_Now")=0
	Application(oblog.cache_name&"Sequence_Users_Now")=CLNG(Application(oblog.cache_name&"Sequence_Users_Now"))+1
	if lastlogid=0 then
		if cookies_domain<>"" then Response.Cookies(cookies_name).Domain=cookies_domain
		Response.Cookies(cookies_name&"uplognum")("updateblognum")=updateblognum+1
		Response.Cookies(cookies_name&"uplognum").Expires=Date+1
	end if
	response.Write("<div id=""prompt""><ul>")
	blog.progress_init
	blog.update_alllog oblog.logined_uid,lastlogid
	'清理计数
	If Application(oblog.cache_name&"Sequence_Users_Now")="" Or Application(oblog.cache_name&"Sequence_Users_Now")="0" Then
		Application(oblog.cache_name&"Sequence_Users_Now")=0
	Else
		Application(oblog.cache_name&"Sequence_Users_Now")=CLNG(Application(oblog.cache_name&"Sequence_Users_Now"))-1
	End If
	
	response.Write("<li><a href='user_update.asp'>&lt;&lt; 返回上一页</a></li></ul></div>")
end sub

%>