<!--#INCLUDE FILE="../HXINCLUDE/HXINCLUDEHEAD.ASP"-->
<%if WS_S.MemberPriv("WS_SystemSetWSOADATABASEMANAGE")<>1 then HX_GoBack "对不起,您的权限不够!",""
action=request("action")
select case action
case "compact"	
on error resume next   
msg="数据库优化成功!"
HX_ClosDB
CompactDB=Server.MapPath("WSOATEMP.MDB")
Call WS_S.CheckFile(CompactDB,True)
Dim fso, Engine
Set fso = CreateObject("Scripting.FileSystemObject")
Set Engine = CreateObject("JRO.JetEngine")
Engine.CompactDatabase ConnStr,"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&CompactDB
fso.CopyFile CompactDB,WS_S.DBPathAddress(Dir)
fso.DeleteFile(CompactDB)
Set fso = nothing
Set Engine = nothing
if err then msg="对不起，优化失败！原因：\n尝试打开的数据库已经被机器上的用户以排它的方式打开，请在当数据库可使用后请再试一次！"
HX_Conn Dir
call WS_S.SaveAdminLog(LOGINUSERNAME,LogAppointment,msg)
HX_GoBack msg,"WSOADATABASEMANAGE.ASP"
case "bak"
HX_ClosDB
set fso=Server.CreateOBject("Scripting.FileSystemObject")
if fso.fileexists(WS_S.DBPathAddress(Dir)) then
 fso.CopyFile WS_S.DBPathAddress(Dir),Server.MapPath("../Databak/WSOACOM.MDB")
end if
set fso=nothing
HX_Conn Dir
msg="数据库备份成功！"
call WS_S.SaveAdminLog(LOGINUSERNAME,LogAppointment,msg)
HX_GoBack msg,"WSOADATABASEMANAGE.ASP"
case "restore"
HX_ClosDB:msg="数据库恢复成功！"
set fso=Server.CreateOBject("Scripting.FileSystemObject")
if fso.fileexists(Server.MapPath("../Databak/WSOACOM.MDB")) then
fso.CopyFile Server.MapPath("../Databak/WSOACOM.MDB"),WS_S.DBPathAddress(Dir)
else
msg="数据库恢复失败：先备份数据库！"
end if
set fso=nothing
HX_Conn Dir
call WS_S.SaveAdminLog(LOGINUSERNAME,LogAppointment,msg)
HX_GoBack msg,"WSOADATABASEMANAGE.ASP" 
case "correction"
 set onliners=WS_S.HX_SetRSD("","HX_ManageLog","")
 if onliners.recordcount<>1 then HX_GoBack "建议先清空系统日志后再进行此操作！","Operation.asp?action=clear"
 WS_S.HX_RSClose onliners 
 conn.execute("delete * from HX_Online")
 set urs=WS_S.HX_SetRSD("","HX_CompanyUser"," where WS_leave=False")
 if urs.recordcount>0 then
  do until urs.eof   
   set onliners=WS_S.HX_SetRSD("","HX_ManageLog"," where WS_UserName='"&urs("WS_UserName")&"'")
   if onliners.recordcount>0 and onliners.recordcount mod 2 =1 then
     set Onrs=WS_S.HX_SetRSD("","HX_Online"," where WS_Userid="&urs("WS_Uid"))
     if Onrs.recordcount>0 then	
	 Onrs("WS_Userid")=urs("WS_Uid"):Onrs("WS_Name")=urs("WS_Name"):Onrs("WS_Viewip")=onliners("WS_UserIP"):Onrs("WS_Lasttime")=onliners("WS_LogTime"):Onrs.update 
	 else
	 Onrs.addnew:Onrs("WS_Userid")=urs("WS_Uid"):Onrs("WS_Name")=urs("WS_Name"):Onrs("WS_Viewip")=onliners("WS_UserIP"):Onrs("WS_Lasttime")=onliners("WS_LogTime"):Onrs.update
     end if
	 WS_S.HX_RSClose onliners
   else	
     conn.execute("delete * from HX_Online where WS_Userid="&urs("WS_Uid"))
   end if
  urs.movenext
  loop
 end if
 HX_GoBack "在线人数修正成功！","WSOADATABASEMANAGE.ASP" 
case "clearonline"
  conn.execute("update HX_CompanyUser set WS_LoginIn=0 where WS_Uid<>"&loginuid)
  ColumnName="":Tablename="HX_ManageLog":Orderby=" where WS_UserName='"&LOGINUSERNAME&"' and WS_LogContent='登录成功!' ORDER BY WS_LogTime DESC"
  set rs=WS_S.HX_SetRSD(ColumnName,Tablename,Orderby)
   if rs.recordcount>0 then conn.execute("delete from HX_ManageLog where WS_Mid<>"&rs("WS_Mid")) else conn.execute("delete from HX_ManageLog")
   conn.execute("delete * from HX_Online where WS_Userid<>"&loginuid)
   HX_GoBack "操作成功！",""
case "systemscan"
  dim DimFileExt,f,f1,fc,fc2,myfile,Ext,TheTime,SumFiles,SumFolders,SumShell
  	SumFiles = 0:SumFolders = 1:SumShell=-5
  	server.ScriptTimeout = 9999
	DimFileExt = "asp,cer,asa,cdx"
	StartTime = timer
	WS_S.HX_ShowAllFile Server.MapPath("../")
	EndTime = timer
	TheTime=(cstr(int(((EndTime-StartTime)*10000 )+0.5)/10))/1000
	msg="扫描结束！\n共搜索了"&SumFiles&"个文件,"&SumFolders&"个文件夹！共发现可疑"&SumShell&"个程序，共计用时"&thetime&"秒！"
    HX_GoBack msg,""
end select
WSOASCOMSTR="<html><head><meta http-equiv='Content-Type' content='text/html; charset=gb2312'><title>数据库管理</title><link rel=stylesheet type=text/css href='../HXinclude/HX_Style.css'></head><body topmargin='20' leftmargin='0' bottommargin='0'>"
WSOASCOMSTR=WSOASCOMSTR&"<script src='../HXINCLUDE/HX_function.js'></script><script language='javascript'>function mysub(){if(!confirm('执行此操作，会占用大量系统资源\n需要继续吗？')){return false;}else{esave.style.visibility='visible';location.href='WSOADATABASEMANAGE.ASP?action=systemscan';}return true;}</script><div id='esave' style='position:absolute; top:260px; left:50px; z-index:200; visibility:hidden'><TABLE WIDTH=340 BORDER=0 CELLSPACING=0 CELLPADDING=0><TR><td width=20% ></td><TD bgcolor=#ff0000 width='60%'><TABLE WIDTH=100% height=120 BORDER=0 CELLSPACING=1 CELLPADDING=0><TR><td bgcolor=#FFFBE8 align=center><font color=red>正在扫描系统程序，请稍候...</font><br><input name='stop' type='button' value=' 停止扫描 ' onclick=""location.href='WSOADATABASEMANAGE.ASP'""></div><img src='../hximages/loading.gif'></td></tr></table></td><td width=20% ></td></tr></table></div>"
WSOASCOMSTR=WSOASCOMSTR&"<table width='596'  border='0' cellspacing='1' cellpadding='0' align=center bgcolor='#613c25'><tr><td colspan='2' bgcolor=FFFBE8><table width='100%'  border='0' cellspacing='0' cellpadding='0'><tr><td height='25' background='../hximages/titleline.gif'><font class='fontmenu'>数据库管理</font></td></tr></table><table width='100%'  border='0' cellspacing='1' cellpadding='6' bgcolor='#FFFBE8'><tr bgcolor='#BF9B73' class='td4'><td>执行以下操作前建议先备份</td></tr><tr bgcolor='#FFFBE8'><td align='left' height='30'><input type='button' name='Submit' value='数据库优化' onclick=""location.href='?action=compact';"">"
dim objFTemp
set fso=Server.CreateOBject("Scripting.FileSystemObject")
if fso.fileexists(WS_S.DBPathAddress(Dir)) then
Set objFTemp=FSO.GetFile(WS_S.DBPathAddress(Dir))
WSOASCOMSTR=WSOASCOMSTR&"数据库大小："&WS_S.GetSize(objFTemp.size,"b")
WSOASCOMSTR=WSOASCOMSTR&" <font color=blue>数据库建立或上次优化时间："&WS_S.Format_Time(objFTemp.DateLastModified,2)&"</font>"
end if
set fso=nothing
WSOASCOMSTR=WSOASCOMSTR&"<br>当系统长时间使用后，可以对数据库进一次优化，可以适当的提高数据库的执行效率！</td></tr><tr bgcolor='#FFFBE8'><td align='left' height='30'><input type='button' name='Submit' value='数据库恢复' onclick=""location.href='?action=restore';""><br>当某些模块出现非正常的现象时（比如出现警告或错误等），可以合数据库恢复功能！</td></tr><tr bgcolor='#FFFBE8'><td align='left' height='30'><input type='button' name='Submit' value='数据库备份' onclick=""location.href='?action=bak';"">"
set fso=Server.CreateOBject("Scripting.FileSystemObject")
if fso.fileexists(Server.MapPath("../Databak/WSOACOM.MDB")) then
Set objFTemp=FSO.GetFile(Server.MapPath("../Databak/WSOACOM.MDB"))
WSOASCOMSTR=WSOASCOMSTR&"<a href='../Databak/WSOACOM.MDB' target='_bank'><font color=red>下载备份数据库</font></a>（"&WS_S.GetSize(objFTemp.size,"b")&"）"
WSOASCOMSTR=WSOASCOMSTR&"<font color=blue>上次备份时间："&WS_S.Format_Time(objFTemp.DateLastModified,2)&"</font>"
end if
set fso=nothing
WSOASCOMSTR=WSOASCOMSTR&"<br>将当前数据库中的数据备份到来以便日后修复数据库！</td></tr><tr bgcolor='#FFFBE8'><td align='left' height='30'><input type='button' name='Submit' value='数据库升级' onclick=""alert('此版本是最新版本，无需升级！');""><br>低版本升级到高版本时，可以使用数据库升级功能将低版本中数据导入高版本中！</td></tr>"
WSOASCOMSTR=WSOASCOMSTR&"<tr bgcolor='#FFFBE8'><td align='left' height='30'><input type='button' name='Submit' value='修正在线人数' onclick=""location.href='?action=correction';""><br>当在线人数与实际在线人数不相符时，可以使用此功能！<font color=red>建议先清空<a href='Operation.asp?action=clear'>系统日志</a>，后进行此操作！</font></td></tr>"
WSOASCOMSTR=WSOASCOMSTR&"<tr bgcolor='#FFFBE8'><td align='left' height='30'><input type='button' name='Submit' value='清空在线人数' onclick=""location.href='?action=clearonline'""><br><font color=red>强行清空在线人数，会导致所有在线员工自动退出系统！当系统在线人数的数据不正确且又无法修正时使用！</font></td></tr>"
WSOASCOMSTR=WSOASCOMSTR&"<tr bgcolor='#FFFBE8'><td align='left' height='30'><input type='button' name='Submit' value='ASP木马检测' onclick=""return mysub();""><br>为了保证系统的安全，请定期对系统进行此操作！<font color=red>注意：此操作不会清除含有木马的文件！请在检测到含有木马程序后利用分析工具进行分析！</font></td></tr></table></td></tr></table>"
response.Write WSOASCOMSTR%>