%
sub ResetSystem()
Application.lock
SQL="select * from setup where type=1 OR type=2"
set rs=db.execute(SQL)
while not rs.EOF
Application(rs("name"))=rs("value")
rs.MoveNext
wend
rs.close
Application.unlock
end sub
function IsToMaster(id)
SQL = "select to_master from message where id="&id&" and to_master=1"
set rs=db.execute(SQL)
if not rs.EOF then
rs.close()
IsToMaster = true
else
rs.close()
IsToMaster = false
end if
end function
function CheckADMode()
if Session("ADMode") = "true" then
CheckADMode=1
else
CheckADMode=0
end if
end function
sub ProtectPage(error_page)
if CheckADMode()=0 then
Response.Redirect error_page
end if
end sub
sub DeleteFile(FilePath)
set FS = CreateObject("Scripting.FileSystemObject")
if FS.FileExists(Server.Mappath(FilePath)) then
FS.DeleteFile(Server.Mappath(FilePath))
end if
end sub
function ReadFile(FileName)
set FS = CreateObject("Scripting.FileSystemObject")
if FS.FileExists(Server.Mappath(FileName)) then
set TextFile = FS.OpenTextFile(Server.Mappath(FileName))
ReadFile = TextFile.ReadAll()
TextFile.Close()
else
ReadFile = ""
end if
End function
Function ReadFileWithHeader(FileName,header)
set FS = CreateObject("Scripting.FileSystemObject")
if FS.FileExists(Server.Mappath(FileName)) then
set TextFile = FS.OpenTextFile(Server.Mappath(FileName))
else
set TextFile = FS.OpenTextFile(Server.Mappath("message\error.txt"))
end if
TempText = header&TextFile.ReadAll()
header=vbCRLF+header
ReadFileWithHeader=Replace(TempText,vbCRLF,header)
TextFile.Close()
End Function
Sub NewFile(FileName,Content)
set FS = CreateObject("Scripting.FileSystemObject")
set TextFile = FS.CreateTextFile(Server.Mappath(FileName))
TextFile.Write(Content)
TextFile.Close()
End Sub
sub BuildCustomTheme()
FileName = "style/custom.tmp"
TempText = ReadFile(FileName)
'get a list of color from database
SQL="select * from setup where type = 3"
set rs=db.execute(SQL)
while not rs.EOF
TempText = Replace(TempText,trim(rs("name")),trim(rs("value")))
rs.MoveNext()
wend
rs.close()
NewFile "style/custom.css",TempText
end sub
sub SelectTheme(theme_name)
FileName="style/"
'依名字取得對應的檔名
SQL="select * from setup where type = 4 and name='"&theme_name&"'"
set rs=db.execute(SQL)
if not rs.EOF then
FileName = FileName&trim(rs("value"))
else
FileName = FileName&"custom.css"
end if
rs.close()
NewFile "style.css",ReadFile(FileName)
end sub
sub SetSysValue(type_,name,value)
SQL="update setup set setup.value='"&value&"' where setup.type= "&type_&" and setup.name='"&name&"'"
db.execute(SQL)
end sub
sub ADModeLogin(id,pw,error_page)
SQL="select * from operator where id='"&id&"'"
set rs=db.execute(SQL)
if not rs.EOF then
'此版主存在
if pw=rs("password") then
Session("ADMode") = "true"
Session("AD") = id
Session("ADColor") = rs("color")
Session("ADSex") = rs("sex")
else
Session("ADMode") = "false"
rs.close()
Response.Redirect error_page
end if
end if
rs.close()
end sub
function AddMessage(id,author,sex,title,color,email,h_address,h_title,face,to_master)
SQL="insert into message (id,author,sex,title,color,email,homepage,homepage_title,face,to_master) "
SQL=SQL&"values ("&id&",'"&author&"',"&sex&",'"&title&"','"&color&"','"&email&"','"&h_address&"','"&h_title&"','"&face&"',"&to_master&")"
db.execute(SQL)
end function
sub DelMessage(head,id)
SQL="delete from message where id="&id
db.execute(SQL)
NewFile head&"deleted/"&id&".txt",ReadFile(head&"message/"&id&".txt")
DeleteFile(head&"message/"&id&".txt")
set FS = CreateObject("Scripting.FileSystemObject")
if FS.FileExists(Server.Mappath(head&"message/"&id&"_"&Session("AD")&"_reply.txt")) then
NewFile head&"deleted/"&id&"_"&Session("AD")&"_reply.txt",ReadFile(head&"message/"&id&"_"&Session("AD")&"_reply.txt")
DeleteFile(head&"message/"&id&"_"&Session("AD")&"_reply.txt")
end if
end sub
sub DelMessageByAuthor(head,author)
SQL="select id from message where author='"&author&"'"
set rs=db.execute(SQL)
while not rs.EOF
DelMessage head,rs("id")
rs.MoveNext()
wend
rs.close()
end sub
sub AddMaster(id,sex,color,pw)
SQL="insert into operator (id,sex,color,password) "
SQL=SQL&"values ('"&id&"',"&sex&",'"&color&"','"&pw&"')"
db.execute(SQL)
end sub
sub DelMaster(id,opw)
SQL="delete from operator where id='"&id&"' and password='"&opw&"'"
db.execute(SQL)
end sub
sub UpdateMaster(sex,color,newpw)
SQL="update operator set operator.sex="&sex&",operator.color='"&color&"',operator.password='"&newpw&"' where id='"&Session("AD")&"'"
db.execute(SQL)
end sub
sub AddMasterReplyMessage(head,reply_to_id,content)
SQL="update message set operator_id='"&Session("AD")&"',master_replied=1,operator_color='"&Session("ADColor")&"' where id="&reply_to_id
db.execute(SQL)
NewFile head&"message/"&reply_to_id&"_"&Session("AD")&"_reply.txt",content
end sub
sub SendPageLinkInfo(function_name,total_page,useless_page,all_message_count)
O= ""
Response.Write O
end sub
sub ListMessageToMaster()
SQL="select * from message where to_master=1"
set rs=db.execute(SQL)
O= ""
Response.Write O
end sub
function CountTotalMessage()
SQL="select id from message"
set rs=Server.CreateObject("ADODB.Recordset")
rs.Open SQL,db,1,2,adCmdTable
K=rs.RecordCount
rs.close()
CountTotalMessage=K
end function
function CountTotalPage()
TotalCount = CountTotalMessage()
PerPage = cint(Application("PerPage"))
if TotalCount = 0 then
CountTotalPage = 0
else
NowHavePage = int(TotalCount/PerPage)
if ((TotalCount/PerPage)-NowHavePage) > 0 then
NowHavePage = NowHavePage + 1
end if
CountTotalPage = NowHavePage
end if
end function
sub ListMessageByPage(page_num)
if page_num > 0 then '防錯
SQL="select * from message order by message.id desc"
set rs=db.execute(SQL)
O= ""
Response.Write O
end if
end sub
sub SendFaceGraph()
SQL="select * from setup where type=0"
set rs=db.execute(SQL)
O= ""
Response.Write O
end sub
sub ListMaster(variable)
SQL = "select id,sex from operator"
set rs=db.execute(SQL)
O= ""
Response.Write O
end sub
%>