Optimization Management :
<%
if request("done")<>"" then response.write " Optimization Successful. "
Dim strSQL,completion,objCommand, turnonoroff, objRS,arrUpfiles,objFSO,deletefile,iFile
server.scripttimeout = 2000
SELECT CASE request("DO")
case "recounttotalreply"
strSQL = "spRecountTotalReply"
case "updatefulltextindex"
strSQL = "spUpdateFullTextIndex"
case "cleanattach"
strSQL = "spCleanAttachment"
case "rebuildfastsort"
strSQL = "sprebuildfastsort"
case "defragfastsort"
strSQL = "spdefragfastsort"
case "recountpost"
strSQL = "spUpdatePostCount"
case "cleansubscription"
strSQL = "spSubCleanUp"
case "recountforum"
strSQL = "spRecountAllForums"
case "On"
Application.lock
Application(dbName&"boarddown") = 0
Application.unlock
strSQL = "spTurnOnOff (0)"
case "Off"
Application.lock
Application(dbName&"boarddown") = 1
Application.unlock
strSQL = "spTurnOnOff (1)"
end select
if Application(dbName&"boarddown") = 0 then turnonoroff = "Off" else turnonoroff = "On"
if strSQL<>"" then
set objCommand = Server.CreateObject("ADODB.Command")
with objCommand
.ActiveConnection= datastore
.commandTimeout = 200
.CommandText = dbOwnerPrefix&strSQL
.CommandType = adCmdStoredProc
if request("DO") = "cleanattach" then
set objRS = .execute
if not (objRS.EOF AND objRS.BOF) then
arrUpfiles = objRS.getRows
end if
objRS.close
set objRS = nothing
else
.execute , ,adExecuteNoRecords
end if
end with
set objCommand=nothing
if request("DO") = "recountforum" then call updateForum
if request("DO") = "cleanattach" then
if isArray(arrUpfiles) then
set objFSO = Server.CreateObject("Scripting.FileSystemObject")
with objFSO
for iFile = 0 to ubound(arrUpfiles,2)
Dim i, arrUps:arrUps=split(arrUpfiles(0,iFile),"|")
for i = 0 to ubound(arrUps)
deletefile = server.mappath("upfiles/"&arrUpfiles(1,iFile)&"/"&arrUps(i))
if .fileexists(deletefile) then .DeleteFile deletefile, true
next
next
end with
set objFSO = nothing
end if
end if
response.redirect("admin_defrag_rebuild.asp?done=yes")
end if
%>