%
dbpath = server.mappath("data/ibook.mdb")
connstr = "driver={microsoft access driver (*.mdb)};dbq="& dbpath
set conn = server.createobject("adodb.connection")
conn.open connstr
sql = "select * from config"
set rs = server.createobject("adodb.recordset")
rs.open sql,conn,1,1
iadmin = rs("admin")
ipassword = rs("password")
ititle = rs("title")
ihomepage = rs("homepage")
iurl = rs("url")
imax = rs("max")
ipagesize = rs("pagesize")
itoday = rs("today")
idate = rs("date")
ibottom = rs("bottom")
iimage = rs("image")
iqqshow = rs("qqshow")
icolor1 = rs("color1")
icolor2 = rs("color2")
icolor3 = rs("color3")
rs.close
set rs = nothing
%>
<%
function iem2html(str)
for i = 1 to 35
str = replace(str,"[iem" & i & "]","")
next
iem2html = str
end function
function inohtml(str)
if isnull(str) then
inohtml = ""
exit function
end if
ilen = len(str)
ihtml = ""
for i = 1 to ilen
select case mid(str,i,1)
case "<"
ihtml = ihtml + "<"
case ">"
ihtml = ihtml + ">"
case chr(13)
ihtml = ihtml + " "
case chr(34)
ihtml = ihtml + """
case "&"
ihtml = ihtml + "&"
case chr(32)
ihtml = ihtml + " "
if i + 1 <= ilen and i - 1 >0 then
if mid(str,i + 1,1) = chr(32) or mid(str,i + 1,1) = chr(9) or mid(str,i - 1,1) = chr(32) or mid(str,i - 1,1) = chr(9) then
ihtml = ihtml + " "
else
ihtml = ihtml + " "
end if
else
ihtml = ihtml + " "
end if
case chr(9)
ihtml = ihtml + " "
case else
ihtml = ihtml + mid(str,i,1)
end select
next
inohtml = ihtml
end function
function isvalidemail(email)
isvalidemail = true
names = split(email, "@")
if ubound(names) <> 1 then
isvalidemail = false
exit function
end if
for each name in names
if len(name) <= 0 then
isvalidemail = false
exit function
end if
for i = 1 to len(name)
c = lcase(mid(name, i, 1))
if instr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 and not isnumeric(c) then
isvalidemail = false
exit function
end if
next
if left(name, 1) = "." or right(name, 1) = "." then
isvalidemail = false
exit function
end if
next
if instr(names(1), ".") <= 0 then
isvalidemail = false
exit function
end if
i = len(names(1)) - instrrev(names(1), ".")
if i <> 2 and i <> 3 then
isvalidemail = false
exit function
end if
if instr(email, "..") > 0 then
isvalidemail = false
end if
end function
function isinteger(para)
if isnull(para) then
isinteger = false
exit function
end if
str = cstr(para)
if trim(str) = "" then
isinteger = false
exit function
end if
l = len(str)
for i = 1 to l
if mid(str,i,1) > "9" or mid(str,i,1) < "0" then
isinteger = false
exit function
end if
next
isinteger = true
if err.number <> 0 then err.clear
end function
%>
<%
function icode2html(str, showimg, nonewwindow)
on error resume next
if not str<>"" then exit function
tmpstr="icode"
str=icodestr(str,"url",nonewwindow)
str=icodestr(str,"email",nonewwindow)
if showimg then
str=icodestr(str,"img",nonewwindow)
end if
str=replace(str,"[b]","",1,-1,1)
str=replace(str,"[/b]","",1,-1,1)
str=replace(str,"[br]"," ",1,-1,1)
str=replace(str,"["&tmpstr,"[",1,-1,1)
str=replace(str,tmpstr&"]","]",1,-1,1)
str=replace(str,"/"&tmpstr,"/",1,-1,1)
icode2html=str
end function
function icodestr(icode_str,icodekeyword,nonewwindow)
on error resume next
tmpstr="icode"
beginstr=1
endstr=1
do while icodekeyword="url" or icodekeyword="email"
beginstr=instr(beginstr,icode_str,"["&icodekeyword&"=",1)
if beginstr=0 then exit do
endstr=instr(beginstr,icode_str,"]",1)
if endstr=0 then exit do
licodekeyword=icodekeyword
beginstr=beginstr+len(licodekeyword)+2
text=mid(icode_str,beginstr,endstr-beginstr)
codetext=replace(text,"[","["&tmpstr,1,-1,1)
codetext=replace(codetext,"]",tmpstr&"]",1,-1,1)
codetext=replace(codetext,"/","/"&tmpstr,1,-1,1)
select case icodekeyword
case "url"
icode_str=replace(icode_str,"[url="&text&"]","",1,1,1)
icode_str=replace(icode_str,"[/url]","",1,1,1)
case "email"
icode_str=replace(icode_str,"[email="&text&"]","",1,1,1)
icode_str=replace(icode_str,"[/email]","",1,1,1)
end select
loop
beginstr=1
do
beginstr=instr(beginstr,icode_str,"["&icodekeyword&"]",1)
if beginstr=0 then exit do
endstr=instr(beginstr,icode_str,"[/"&icodekeyword&"]",1)
if endstr=0 then exit do
licodekeyword=icodekeyword
beginstr=beginstr+len(licodekeyword)+2
text=mid(icode_str,beginstr,endstr-beginstr)
codetext=replace(text,"[","["&tmpstr,1,-1,1)
codetext=replace(codetext,"]",tmpstr&"]",1,-1,1)
codetext=replace(codetext,"/","/"&tmpstr,1,-1,1)
select case icodekeyword
case "url"
icode_str=replace(icode_str,"["&icodekeyword&"]"&text,""&codetext,1,1,1)
icode_str=replace(icode_str,""&codetext&"[/"&icodekeyword&"]",""&codetext&"",1,1,1)
case "email"
icode_str=replace(icode_str,"["&icodekeyword&"]"&text,""&codetext,1,1,1)
icode_str=replace(icode_str,""&codetext&"[/"&icodekeyword&"]",""&codetext&"",1,1,1)
case "img"
if nonewwindow then
icode_str=replace(icode_str,"[img]"&text,"
",1,1,1)
end if
end select
loop
icodestr=icode_str
end function
%>
<%
on error resume next
set rs = server.createobject("adodb.recordset")
sql = "select * from config"
rs.open sql,conn,1,1
if date <> idate then
rs("today") = 0
end if
rs("date") = date
rs.update
rs.close
iaction = request.form("action")
if iaction = "new" then
iname = inohtml(request.form("name"))
iemail = inohtml(request.form("email"))
iweb = inohtml(request.form("homepage"))
ioicq = inohtml(request.form("oicq"))
iicon = inohtml(request.form("icon"))
iface = inohtml(request.form("face"))
icontent = iem2html(icode2html(inohtml(request.form("content")), iimage, true))
ititle = inohtml(request.form("ititle"))
if iname = "" or icontent = "" or ititle = "" then
ierror = ierror & "有未填栏"
end if
if iemail <> "" and isvalidemail(iemail) = false then
ierror = ierror & "邮箱格式错误"
end if
if ioicq <> "" and ( isinteger(ioicq) = false or len(ioicq) < 4 or len(ioicq) > 11 ) then
ierror = ierror & "QQ格式错误"
end if
if iweb = "http://" or iweb = "" then
iweb = "http://www.i986.com"
end if
if iface = "" or iface > 6 then
iface = 1
end if
if iicon = "" or iicon > 26 then
iicon = 1
end if
if len(icontent) > imax then
ierror = ierror & "内容字数过多"
end if
if len(iname) > 20 or len(iemail) > 100 or len(iweb) > 100 or len(ititle) > 50 or len(iicon) > 10 or len(iface) > 10 then
ierror = ierror & "信息过长"
end if
if ierror = "" then
sql = "select * from content"
rs.open sql,conn,3,2
rs.addnew
rs("author") = iname
rs("email") = iemail
rs("oicq") = ioicq
rs("homepage") = iweb
rs("content") = icontent
rs("icon") = iicon
rs("face") = iface
rs("time") = now
rs("title") = ititle
rs.update
rs.close
sql = "select * from config"
rs.open sql,conn,3,2
if date <> idate then
rs("today") = 1
else
rs("today") = rs("today") + 1
end if
rs("date") = date
rs.update
rs.close
set rs = nothing
conn.close
set conn = nothing
response.redirect "index.asp"
response.end
end if
end if
%>
<%=ititle%>