<!--#include file="conn.asp"-->
<!--#include file="inc/Dv_ClsMain.asp"-->
<!--#include file="inc/Dv_LoadCache.asp"-->
<%
Set MyBoardOnline=new Cls_UserOnlne 
Dim ComeUrl,updateing
ComeUrl=Session("LoadCache")
Application.Lock
If ComeUrl&"" <>"" Then 
	Dvbbs.Name="update"
	If Dvbbs.ObjIsEmpty() Then
		Dvbbs.value=1
		Forum_Startup()
		Session("LoadCache")=""
		Dvbbs.Name="update"
		Dvbbs.value=0
		Application.UnLock
		Response.Redirect ComeUrl
	Else
		updateing=Dvbbs.value
		If updateing=0 Then	
		Dvbbs.value=1
			DoCheck()
			Session("LoadCache")=""
			Dvbbs.Name="update"
			Dvbbs.value=0
			Application.UnLock
			Response.Redirect ComeUrl
		Else
			Session("LoadCache")=""
			Dvbbs.Name="update"
			Dvbbs.value=0	'避免死循环 by Dv.ADRX
			Application.UnLock
			Response.Write "<META http-equiv=Content-Type content=text/html; charset=gb2312>"
			Response.Write "<meta http-equiv=""refresh"" content=""10;URL="&ComeUrl&""">"
			Response.Write "<br>正在更新论坛数据,请稍等...."				
			Response.End
		End If
	End If
Else
	Dvbbs.GetForum_Setting
	Dvbbs.CheckUserLogin
	If Dvbbs.GroupSetting(70)="1" Then
		Dvbbs.LoadTemplates("")
		Dvbbs.Stats="论坛重启动完毕"
		Dvbbs.Nav()
		Forum_Startup()
		Dvbbs.Head_var 0,0,"论坛重启动","LoadCache.asp"
		Response.Write "论坛重启动完毕!"
		Dvbbs.Footer	
	End If
End If
Application.UnLock
'论坛零时执行一次的过程,只更新每日信息,
Sub DoCheck()
	'不管三七二十一重载一次设置
	Dvbbs.Name="Date"
	Dvbbs.value=Date()
	ReloadSetup()
	Dvbbs.GetForum_Setting
	'开始常规检查
	Dim XMLDOM
	Set XMLDOM=Server.CreateObject("Microsoft.FreeThreadedXMLDOM")
	If Not IsObject(Application(Dvbbs.CacheName&"_sBoradlist")) Then
		If Not XMLDOM.loadxmL(Dvbbs.CacheData(27,0)&"") Then '如果板面XML数据有问题,则重写数据
			MakXMLBoardList 0,0
		Else
			Application.Lock
			Set Application(Dvbbs.CacheName&"_sBoradlist")= XMLDOM.cloneNode(True)
			Application.UnLock
		End If
	End If
	If Not IsObject(Application(Dvbbs.CacheName&"_sBoradlist")) Then
		If Not XMLDOM.loadxmL(Dvbbs.CacheData(34,0)&"") Then '如果板面XML数据有问题,则重写数据
			MakXMLBoardInfo 0
		Else
			Application.Lock
			Set Application(Dvbbs.CacheName&"_Boradlist")= XMLDOM.cloneNode(True)
			Application.UnLock
		End If
	End If
	MakXMLBoardInfo 0
	LoadBoardNews_Paper()'更新一下全部的小字报和公告
	Set XMLDOM=Nothing
	If Not IsObject(Application(Dvbbs.CacheName&"_BoardlistXMLOBj")) Then
		Maktopiclist()'创建贴子列表使用的XML文档
	End If
	'其他的检查..................
	'开始每日更新
	ReloadAllForumInfo()
End Sub
'IIS重启动后论坛第一次运行
Sub Forum_Startup()
	ReloadSetup()
	Dim XMLDOM,Rs
	Dvbbs.Name="Date"
	Dvbbs.value=Date()
	Set XMLDOM=Server.CreateObject("Microsoft.FreeThreadedXMLDOM")
	If Not XMLDOM.loadxmL(Dvbbs.CacheData(27,0)&"") Then '如果板面XML数据有问题,则重写数据
		MakXMLBoardList 0,0
	Else
		Application.Lock
		Set Application(Dvbbs.CacheName&"_sBoradlist")= XMLDOM.cloneNode(True)
		Application.UnLock
	End If
	If Not XMLDOM.loadxmL(Dvbbs.CacheData(34,0)&"") Then '如果板面XML数据有问题,则重写数据
		MakXMLBoardInfo 0
	Else
		Application.Lock
		Set Application(Dvbbs.CacheName&"_Boradlist")= XMLDOM.cloneNode(True)
		Application.UnLock
	End If
	Set XMLDOM=Nothing
	Maktopiclist()'创建贴子列表使用的XML文档
	'产生所有法规数据
	TemplatesToCache()
	ReloadTemplateslist()
	LoadGroupSetting()
	Dvbbs.GetForum_Setting
	LoadBoardNews_Paper()'更新一下全部的小字报和公告
	Index_news
	iGroupSetting_UserName()
	If Dvbbs.Forum_setting(29)="1" Then Forum_BirUser()
	Show_Index_GetGroupTitle()
	LoadStyleList_All()
	GetGroupTitlePic()
	ReloadAllForumInfo()
	MakXMLBoardInfo 0
End Sub
Sub ReloadAllForumInfo()'每日更新
	Dvbbs.Name="Date"
	If Dvbbs.value <> "1900-1-1" Then 
		Dvbbs.value="1900-1-1"
		Dim Rs,LastPostInfo,TempStr,i
		Dim Forum_YesterdayNum,Forum_TodayNum,Forum_LastPost,Forum_MaxPostNum,Forum_MaxPostDate
		Set Rs=Dvbbs.Execute("Select Top 1 Forum_YesterdayNum,Forum_TodayNum,Forum_LastPost,Forum_MaxPostNum From Dv_Setup")
		Forum_YesterdayNum=Rs(0)
		Forum_TodayNum=Rs(1)
		Forum_LastPost=Rs(2)
		Forum_MaxPostNum=Rs(3)
		Set Rs=Nothing
		LastPostInfo = Split(Forum_LastPost,"$")
		If Not IsDate(LastPostInfo(2)) Then LastPostInfo(2)=Now()	
		If DateDiff("d",CDate(LastPostInfo(2)),Now())<>0 Then'最后发帖时间不是今天，	
			TempStr=LastPostInfo(0)&"$"&LastPostInfo(1)&"$"&Now()&"$"&LastPostInfo(3)&"$"&LastPostInfo(4)&"$"&LastPostInfo(5)&"$"&LastPostInfo(6)&"$"&LastPostInfo(7)
			Dvbbs.Execute("Update Dv_Setup Set Forum_YesterdayNum="&Forum_TodayNum&",Forum_LastPost='"&TempStr&"',Forum_TodayNum=0")
			Dvbbs.ReloadSetupCache 0,9
			Dvbbs.ReloadSetupCache Forum_TodayNum,11
			Dvbbs.ReloadSetupCache TempStr,15
		End If
		If Forum_TodayNum >Forum_MaxPostNum Then
			Dvbbs.Execute("Update Dv_Setup Set Forum_MaxPostNum=Forum_TodayNum,Forum_MaxPostDate="&SqlNowString)
			Dvbbs.ReloadSetupCache Forum_TodayNum,12'日最高发帖
			Dvbbs.ReloadSetupCache Now(),13 '最高发帖日期
		End If
		LoadBoardsInfo 0
	End If
	Dvbbs.Name="Date"
	Dvbbs.value=Date()
End Sub
%>