newasp中main类
程序员文章站
2022-04-14 20:33:11
<% const isdebug = 1 class newaspmain_cls &nb...
<%
const isdebug = 1
class newaspmain_cls
public membername, memberpass, membergrade, membergroup, memberid
public memberclass, menbernickname, cookies_name, checkpassword
public sitename, siteurl, mastermail, keywords, copyright
public installdir, indexname, istopsite, stopreadme, isclosemail
public sendmailtype, mailfrom, mailserver, mailusername, mailpassword, mailinformpass, chksamemail
public checkuserreg, admincheckreg, adduserpoint, sendregmessage, fullcontquery, actiontime
public isruntime, uploadclass, uploadfilesize, uploadfiletype, contentkeyword, previewsetting
public stopapplylink, fso_scriptname, inittitlecolor, stopbankpay
public chinaebank, versionid, badwords, badwordr, serialcode, passedcode
public channelname, channeldir, stopchannel, channeltype
public modules, channelskin, htmlpath, htmlform, htmlprefix
public iscreatehtml, htmlextname, stopupload, maxfilesize, upfiletype
public isauditing, appeargrade, modulename, binddomain, domainname
public postgrade, leaststring, maxstring, paginalnum, leasthothist, channel_setting
public channelsetting,channeldata,channelpath
public channelmodule,channelhtmlpath,channelhtmlform,channelusehtml,channelhtmlext,channelprefix
public thisedition, copyrightstr, version, values, startime
public sqlquerynum, getuserip, cachename, reloadtime
public scriptname, admin_page, skinid, skinpath, htmlcss, htmltop, htmlfoot, htmlcontent, shtmlcontent
private main_style, main_setting, mainstyle, html_setting
private localcachename, cache_data
private cachechannel, cachedata
private arrgroupsetting, blngroupsetting, binuserlong
private sub class_initialize()
on error resume next
reloadtime = 28800
sqlquerynum = 0
'--缓存名称
cachename = "newasp"
cookies_name = "newasp_net"
binuserlong = false
blngroupsetting = false
getuserip = request.servervariables("http_x_forwarded_for")
if len(getuserip) = 0 then getuserip = request.servervariables("remote_addr")
getuserip = checkstr(getuserip)
membername = checkstr(request.cookies(cookies_name)("username"))
memberpass = checkstr(request.cookies(cookies_name)("password"))
menbernickname = checkstr(request.cookies(cookies_name)("nickname"))
membergrade = chknumeric(request.cookies(cookies_name)("usergrade"))
membergroup = checkstr(request.cookies(cookies_name)("usergroup"))
memberclass = chknumeric(request.cookies(cookies_name)("userclass"))
memberid = chknumeric(request.cookies(cookies_name)("userid"))
checkpassword = checkstr(request.cookies(cookies_name)("checkpassword"))
dim tmpstr, i
tmpstr = request.servervariables("path_info")
tmpstr = split(tmpstr, "/")
i = ubound(tmpstr)
scriptname = lcase(tmpstr(i))
admin_page = false
if instr(scriptname, "showerr") > 0 or instr(scriptname, "login") > 0 or instr(scriptname, "admin_") > 0 then admin_page = true
end sub
private sub class_terminate()
if isobject(conn) then conn.close : set conn = nothing
end sub
'===================服务器缓存部分函数开始===================
public property let name(byval vnewvalue)
localcachename = lcase(vnewvalue)
cache_data = application(cachename & "_" & localcachename)
end property
public property let value(byval vnewvalue)
if localcachename <> "" then
redim cache_data(2)
cache_data(0) = vnewvalue
cache_data(1) = now()
application.lock
application(cachename & "_" & localcachename) = cache_data
application.unlock
else
err.raise vbobjecterror + 1, "newaspcacheserver", " please change the cachename."
end if
end property
public property get value()
if localcachename <> "" then
if isarray(cache_data) then
value = cache_data(0)
else
'err.raise vbobjecterror + 1, "newaspcacheserver", " the cache_data("&localcachename&") is empty."
end if
else
err.raise vbobjecterror + 1, "newaspcacheserver", " please change the cachename."
end if
end property
public function objisempty()
objisempty = true
if not isarray(cache_data) then exit function
if not isdate(cache_data(1)) then exit function
if datediff("s", cdate(cache_data(1)), now()) < (60 * reloadtime) then objisempty = false
end function
public sub delcahe(mycahename)
application.lock
application.contents.remove (cachename & "_" & mycahename)
application.unlock
end sub
public sub delcache(mycahename)
application.lock
application.contents.remove ("mynewasp_" & mycahename)
application.unlock
end sub
'===================服务器缓存部分函数结束===================
public function chkboolean(byval values)
if typename(values) = "boolean" or isnumeric(values) or lcase(values) = "false" or lcase(values) = "true" then
chkboolean = cbool(values)
else
chkboolean = false
end if
end function
public function checknumeric(byval check_id)
if check_id <> "" and isnumeric(check_id) then
check_id = ccur(check_id)
else
check_id = 0
end if
checknumeric = check_id
end function
public function chknumeric(byval check_id)
if check_id <> "" and isnumeric(check_id) then
check_id = clng(check_id)
if check_id < 0 then check_id = 0
else
check_id = 0
end if
chknumeric = check_id
end function
public function checkstr(byval str)
if isnull(str) then
checkstr = ""
exit function
end if
str = replace(str, chr(0), "")
checkstr = replace(str, "'", "''")
end function
'================================================
'过程名:checknull
'作 用:是否有效值
'================================================
public function checknull(byval svalue)
on error resume next
if isnull(svalue) then
checknull = false
exit function
end if
if trim(svalue) <> "" and lcase(trim(svalue)) <> "http://" then
checknull = true
else
checknull = false
end if
end function
public function chknull(byval str)
on error resume next
if isnull(str) then
chknull = ""
exit function
end if
if trim(str) <> "" and lcase(trim(str)) <> "http://" then
chknull = trim(str)
else
chknull = ""
end if
end function
'=============================================================
'函数名:chkformstr
'作 用:过滤表单字符
'参 数:str ----原字符串
'返回值:过滤后的字符串
'=============================================================
public function chkformstr(byval str)
dim fstring
fstring = str
if isnull(fstring) then
chkformstr = ""
exit function
end if
fstring = replace(fstring, "'", "'")
fstring = replace(fstring, chr(34), """)
fstring = replace(fstring, chr(13), "")
fstring = replace(fstring, chr(10), "")
fstring = replace(fstring, chr(9), "")
fstring = replace(fstring, ">", ">")
fstring = replace(fstring, "<", "<")
fstring = replace(fstring, "%", "%")
chkformstr = trim(japencode(fstring))
end function
'=============================================================
'函数作用:过滤sql非法字符
'=============================================================
public function checkrequest(byval str,byval strlen)
on error resume next
str = trim(str)
str = replace(str, chr(0), "")
str = replace(str, "'", "")
str = replace(str, "%", "")
str = replace(str, "^", "")
str = replace(str, ";", "")
str = replace(str, "*", "")
str = replace(str, "<", "")
str = replace(str, ">", "")
str = replace(str, "|", "")
str = replace(str, "and", "")
str = replace(str, "chr", "")
if len(str) > 0 and strlen > 0 then
str = left(str, strlen)
end if
checkrequest = str
end function
'-- 移除有害字符
public function removebadcharacters(byval strtemp)
dim re
on error resume next
set re = new regexp
re.pattern = "[^\s\w]"
re.global = true
removebadcharacters = re.replace(strtemp, "")
set re = nothing
end function
'-- 去掉html标记
public function removehtml(byval textstr)
dim str,re
str = textstr
on error resume next
set re = new regexp
re.ignorecase = true
re.global = true
re.pattern = "<(.[^>]*)>"
str = re.replace(str, "")
set re = nothing
removehtml=str
end function
'-- 数据库连接
public function execute(command)
if not isobject(conn) then connectiondatabase
if isdebug = 0 then
on error resume next
set execute = conn.execute(command)
if err then
err.clear
set conn = nothing
response.write "查询数据的时候发现错误,请检查您的查询代码是否正确。<br /><li>"
response.write command
response.end
end if
else
set execute = conn.execute(command)
end if
sqlquerynum = sqlquerynum+1
end function
public sub readconfig()
on error resume next
name = "config"
if objisempty() then reloadconfig
cachedata = value
'第一次起用系统或者重启iis的时候加载缓存
name = "date"
if objisempty() then
value = date
else
if cstr(value) <> cstr(date) then
name = "config"
call reloadconfig
cachedata = value
end if
end if
sitename = cachedata(1, 0): siteurl = cachedata(2, 0): mastermail = cachedata(3, 0): keywords = cachedata(4, 0): copyright = cachedata(5, 0): installdir = cachedata(6, 0)
indexname = cachedata(7, 0): istopsite = cachedata(8, 0): stopreadme = cachedata(9, 0): isclosemail = cachedata(10, 0): sendmailtype = cachedata(11, 0): mailfrom = cachedata(12, 0)
mailserver = cachedata(13, 0): mailusername = cachedata(14, 0): mailpassword = cachedata(15, 0): checkuserreg = cachedata(16, 0): admincheckreg = cachedata(17, 0): mailinformpass = cachedata(18, 0)
chksamemail = cachedata(19, 0): adduserpoint = cachedata(20, 0): sendregmessage = cachedata(21, 0): fullcontquery = cachedata(22, 0): actiontime = cachedata(23, 0): isruntime = cachedata(24, 0)
uploadclass = cachedata(25, 0): uploadfilesize = cachedata(26, 0): uploadfiletype = cachedata(27, 0): contentkeyword = cachedata(28, 0): stopapplylink = cachedata(29, 0): fso_scriptname = cachedata(30, 0)
inittitlecolor = cachedata(31, 0): stopbankpay = cachedata(32, 0): chinaebank = cachedata(33, 0): versionid = cachedata(34, 0): badwords = cachedata(35, 0): badwordr = cachedata(36, 0)
serialcode = cachedata(37, 0): passedcode = cachedata(38, 0) : previewsetting = cachedata(39, 0)
thisedition = "免费版 (free edition)"
version = "powered by:<a href=""http://www.newasp.net"" target=""_blank"" class=""navmenu"">newcloud sitemanagesystem version 2.0.0 sp1</a>"
copyrightstr = "<!--" & vbcrlf
copyrightstr = copyrightstr & "┌─────────────────newasp──┐" & vbcrlf
copyrightstr = copyrightstr & "│newcloud sitemanagesystem version 2.0.0 sp1 │" & vbcrlf
copyrightstr = copyrightstr & "│版权所有: 新云网络 (newasp.net) │" & vbcrlf
copyrightstr = copyrightstr & "│官方主页: http://www.newasp.net │" & vbcrlf
copyrightstr = copyrightstr & "│论坛地址: http://bbs.newasp.net │" & vbcrlf
copyrightstr = copyrightstr & "│e-mail: webenvoy@163.com qq: 94022511 │" & vbcrlf
copyrightstr = copyrightstr & "└────────────────────.net┘" & vbcrlf
copyrightstr = copyrightstr & "-->" & vbcrlf
if cint(istopsite) = 1 and not admin_page then response.redirect ("" & siteurl & installdir & "showerr.asp?action=stop")
end sub
public sub reloadconfig()
dim sql, rs
on error resume next
sql = "select * from [nc_config] "
set rs = execute(sql)
value = rs.getrows(1)
set rs = nothing
end sub
'=============================================================
'过程名:reloadchannel
'作 用:再装频道设置
'参 数:channelid ----频道id
'=============================================================
private sub reloadchannel(channelid)
dim sql, rs
on error resume next
sql = "select channelid,channelname,channeldir,stopchannel,channeltype,modules,modulename,binddomain,domainname,channelskin,htmlpath,htmlform,iscreatehtml,htmlextname,htmlprefix,stopupload,maxfilesize,upfiletype,isauditing,appeargrade,postgrade,leaststring,maxstring,paginalnum,leasthothist,channel_setting from nc_channel where channeltype <= 1 and channelid = " & clng(channelid)
set rs = execute(sql)
if rs.bof and rs.eof then
response.write "错误的频道参数!"
exit sub
end if
value = rs.getrows(1)
set rs = nothing
end sub
'=============================================================
'过程名:readchannel
'作 用:读取频道设置
'参 数:channelid ----频道id
'=============================================================
public sub readchannel(channelid)
on error resume next
if not isnumeric(channelid) then channelid = 1
channelid = clng(channelid)
name = "channel" & channelid
if objisempty() then call reloadchannel(channelid)
cachechannel = value
if clng(cachechannel(0, 0)) <> channelid then
call reloadchannel(channelid)
cachechannel = value
end if
channelname = cachechannel(1, 0): channeldir = cachechannel(2, 0): stopchannel = cachechannel(3, 0): channeltype = cachechannel(4, 0): modules = cachechannel(5, 0): modulename = cachechannel(6, 0): binddomain = cachechannel(7, 0): domainname = cachechannel(8, 0): channelskin = cachechannel(9, 0): htmlpath = cachechannel(10, 0)
htmlform = cachechannel(11, 0): iscreatehtml = cachechannel(12, 0): htmlextname = cachechannel(13, 0): htmlprefix = cachechannel(14, 0): stopupload = cachechannel(15, 0): maxfilesize = cachechannel(16, 0): upfiletype = cachechannel(17, 0): isauditing = cachechannel(18, 0): appeargrade = cachechannel(19, 0)
postgrade = cachechannel(20, 0): leaststring = cachechannel(21, 0): maxstring = cachechannel(22, 0): paginalnum = cachechannel(23, 0): leasthothist = cachechannel(24, 0): channel_setting = cachechannel(25, 0)
if cint(stopchannel) = 1 and not admin_page then response.redirect (installdir & "showerr.asp?action=chanstop")
end sub
public sub loadchannel(chanid)
on error resume next
dim rs,sql,tmpdata
chanid = clng(chanid)
name = "mychannel" & chanid
if objisempty() then
sql = "select channelname,channeldir,modulename,htmlpath,htmlform,iscreatehtml,htmlextname,htmlprefix,stopupload,leaststring,maxstring,leasthothist from nc_channel where channeltype<=1 and channelid= " & clng(chanid)
set rs = execute(sql)
tmpdata = rs.getstring(, , "|||", "@@@", "")
tmpdata = left(tmpdata, len(tmpdata) - 3)
set rs = nothing
value = tmpdata
end if
channeldata = split(value, "|||")
channelpath = installdir & channeldata(1)
channelmodule = channeldata(2)
channelhtmlpath = channeldata(3)
channelhtmlform = channeldata(4)
channelusehtml = channeldata(5)
channelhtmlext = channeldata(6)
channelprefix = channeldata(7)
end sub
'=============================================================
'过程名:loadtemplates
'作 用:载入模板
'参 数:page_mark ----styleid
'=============================================================
public sub loadtemplates(channelid, pageid, styleid)
dim rstmp, tempskinid
on error resume next
channelid = clng(channelid)
pageid = cint(pageid)
name = "defaultskinid"
if objisempty() then
set rstmp = execute("select skinid from [nc_template] where pageid = 0 and isdefault = 1")
value = rstmp(0)
set rstmp = nothing
end if
tempskinid = value
if styleid = 0 or styleid = "" then
skinid = tempskinid
else
set rstmp = execute("select skinid from [nc_template] where pageid = 0 and skinid = " & styleid)
if not rstmp.eof then
skinid = rstmp(0)
else
skinid = tempskinid
end if
set rstmp = nothing
end if
skinid = clng(skinid)
name = "mainstyle" & skinid
if objisempty() then templatesmaincache (skinid)
main_style = value
skinpath = main_style(0, 0)
main_setting = split(main_style(2, 0), "|||")
mainstyle = main_style(1, 0)
'mainstyle = replace(mainstyle, "{$installdir}", readinstalldir(binddomain))
mainstyle = replace(mainstyle, "{$skinpath}", skinpath)
mainstyle = split(mainstyle, "|||")
htmlcss = mainstyle(0)
htmltop = mainstyle(1)
htmlfoot = mainstyle(2)
if pageid <> 0 then
name = "templates" & channelid & skinid & pageid
if objisempty() then
templatestocache channelid, pageid
end if
byvalue = value
end if
end sub
private sub templatestocache(channelid, pageid)
on error resume next
dim rs, sql, rstmp
sql = "select skinid,page_content,page_setting from [nc_template] where channelid = " & channelid & " and skinid = " & skinid & " and pageid = " & pageid
set rs = execute(sql)
if not rs.eof then
value = rs.getrows(1)
else
set rstmp = execute("select skinid,page_content,page_setting from [nc_template] where channelid = " & channelid & " and isdefault = 1 and pageid = " & pageid)
value = rstmp.getrows(1)
set rstmp = nothing
end if
set rs = nothing
end sub
private sub templatesmaincache(skinid)
on error resume next
dim rs, sql, rstmp
sql = "select templatedir,page_content,page_setting from [nc_template] where pageid = 0 and skinid = " & skinid & " and channelid = 0"
set rs = execute(sql)
if not rs.eof then
value = rs.getrows(1)
else
set rstmp = execute("select templatedir,page_content,page_setting from [nc_template] where pageid = 0 and isdefault = 1 and channelid = 0")
value = rstmp.getrows(1)
set rstmp = nothing
end if
set rs = nothing
end sub
public property let byvalue(byval vnewvalue)
dim tmpstr
tmpstr = vnewvalue
html_setting = tmpstr(2, 0)
html_setting = split(html_setting, "|||")
htmlcontent = tmpstr(1, 0)
if cint(html_setting(0)) <> 0 then
htmlcontent = htmltop & htmlcontent & htmlfoot
end if
htmlcontent = replace(htmlcontent, "{$style_css}", htmlcss)
htmlcontent = replace(htmlcontent, "{$skinpath}", skinpath)
htmlcontent = replace(htmlcontent, "{$width}", main_setting(0))
htmlcontent = replace(htmlcontent, "{$channelmenu}", channelmenu)
htmlcontent = replace(htmlcontent, "{$websitename}", sitename)
htmlcontent = replace(htmlcontent, "{$websiteurl}", siteurl)
htmlcontent = replace(htmlcontent, "{$mastermail}", mastermail)
htmlcontent = replace(htmlcontent, "{$keyword}", keywords)
htmlcontent = replace(htmlcontent, "{$copyright}", copyright)
htmlcontent = replace(htmlcontent, "{$indexname}", indexname)
htmlcontent = replace(htmlcontent, "{$version}", "")
htmlcontent = htmlcontent
end property
public property get byvalue()
byvalue = htmlcontent
end property
public property let htmlvalue(byval vnewvalue)
dim tempstr
tempstr = vnewvalue
tempstr = replace(tempstr, "{$style_css}", htmlcss)
tempstr = replace(tempstr, "{$skinpath}", skinpath)
tempstr = replace(tempstr, "{$width}", main_setting(0))
tempstr = replace(tempstr, "{$channelmenu}", channelmenu)
tempstr = replace(tempstr, "{$websitename}", sitename)
tempstr = replace(tempstr, "{$websiteurl}", siteurl)
tempstr = replace(tempstr, "{$mastermail}", mastermail)
tempstr = replace(tempstr, "{$keyword}", keywords)
tempstr = replace(tempstr, "{$copyright}", copyright)
tempstr = replace(tempstr, "{$indexname}", indexname)
tempstr = replace(tempstr, "{$version}", "")
shtmlcontent = tempstr
end property
public property get htmlvalue()
htmlvalue = shtmlcontent
end property
public property get htmlsetting(n)
htmlsetting = html_setting(n)
end property
public property get mainsetting(n)
mainsetting = main_setting(n)
end property
'================================================
'过程名:getsiteurl
'作 用:取得带端口的url
'================================================
public property get getsiteurl()
if request.servervariables("server_port") = "80" then
getsiteurl = "http://" & request.servervariables("server_name")
else
getsiteurl = "http://" & request.servervariables("server_name") & ":" & request.servervariables("server_port")
end if
end property
'================================================
'函数名:formencode
'作 用:过虑提交的表单数据
'参 数:str ----原字符串 n ----字符长度
'================================================
public function formencode(byval str, byval n)
if not isnull(str) and trim(str) <> "" then
str = left(str, n)
str = replace(str, ">", ">")
str = replace(str, "<", "<")
str = replace(str, ">", ">")
str = replace(str, "<", "<")
str = replace(str, "'", "'")
str = replace(str, chr(34), """)
str = replace(str, "%", "%")
str = replace(str, vbnewline, "")
formencode = trim(str)
else
formencode = ""
end if
end function
'================================================
'函数名:chkkeyword
'作 用:过滤关键字
'参 数:keyword ----关键字
'================================================
public function chkkeyword(byval keyword)
dim fobwords, i
on error resume next
fobwords = array(91, 92, 304, 305, 430, 431, 437, 438, 12460, 12461, 12462, 12463, 12464, 12465, 12466, 12467, 12468, 12469, 12470, 12471, 12472, 12473, 12474, 12475, 12476, 12477, 12478, 12479, 12480, 12481, 12482, 12483, 12485, 12486, 12487, 12488, 12489, 12490, 12496, 12497, 12498, 12499, 12500, 12501, 12502, 12503, 12504, 12505, 12506, 12507, 12508, 12509, 12510, 12521, 12532, 12533, 65339, 65340)
for i = 1 to ubound(fobwords, 1)
if instr(keyword, chrw(fobwords(i))) > 0 then
keyword = replace(keyword, chrw(fobwords(i)), "")
end if
next
keyword = left(keyword, 100)
fobwords = array("~", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "+", "=", "`", "[", "]", "{", "}", ";", ":", """", "'", ",", "<", ">", ".", "/", "\", "?", "_")
for i = 0 to ubound(fobwords, 1)
if instr(keyword, fobwords(i)) > 0 then
keyword = replace(keyword, fobwords(i), "")
end if
next
chkkeyword = keyword
end function
'================================================
'函数名:japencode
'作 用:日文片假名编码
'参 数:str ----原字符
'================================================
public function japencode(byval str)
dim fobwords, i
on error resume next
if isnull(str) or trim(str) = "" then
japencode = ""
exit function
end if
fobwords = array(92, 304, 305, 430, 431, 437, 438, 12460, 12461, 12462, 12463, 12464, 12465, 12466, 12467, 12468, 12469, 12470, 12471, 12472, 12473, 12474, 12475, 12476, 12477, 12478, 12479, 12480, 12481, 12482, 12483, 12485, 12486, 12487, 12488, 12489, 12490, 12496, 12497, 12498, 12499, 12500, 12501, 12502, 12503, 12504, 12505, 12506, 12507, 12508, 12509, 12510, 12521, 12532, 12533, 65340)
for i = 1 to ubound(fobwords, 1)
if instr(str, chrw(fobwords(i))) > 0 then
str = replace(str, chrw(fobwords(i)), "" & fobwords(i) & ";")
end if
next
japencode = str
end function
'================================================
'函数名:japuncode
'作 用:日文片假名解码
'参 数:str ----原字符
'================================================
public function japuncode(byval str)
dim fobwords, i
on error resume next
if isnull(str) or trim(str) = "" then
japuncode = ""
exit function
end if
fobwords = array(92, 304, 305, 430, 431, 437, 438, 12460, 12461, 12462, 12463, 12464, 12465, 12466, 12467, 12468, 12469, 12470, 12471, 12472, 12473, 12474, 12475, 12476, 12477, 12478, 12479, 12480, 12481, 12482, 12483, 12485, 12486, 12487, 12488, 12489, 12490, 12496, 12497, 12498, 12499, 12500, 12501, 12502, 12503, 12504, 12505, 12506, 12507, 12508, 12509, 12510, 12521, 12532, 12533, 65340)
for i = 1 to ubound(fobwords, 1)
if instr(str, "" & fobwords(i) & ";") > 0 then
str = replace(str, "" & fobwords(i) & ";", chrw(fobwords(i)))
end if
next
str = replace(str, chr(0), "")
str = replace(str, "'", "''")
japuncode = str
end function
'=============================================================
'函数作用:带脏话过滤
'=============================================================
public function chkbadwords(byval str)
if isnull(str) then exit function
dim i, bwords, bwordr
bwords = split(badwords, "|")
bwordr = split(badwordr, "|")
for i = 0 to ubound(bwords)
if i > ubound(bwordr) then
str = replace(str, bwords(i), "*")
else
str = replace(str, bwords(i), bwordr(i))
end if
next
chkbadwords = str
end function
'=============================================================
'函数作用:过滤html代码,带脏话过滤
'=============================================================
public function htmlencode(byval fstring)
if not isnull(fstring) then
fstring = replace(fstring, ">", ">")
fstring = replace(fstring, "<", "<")
fstring = replace(fstring, chr(32), " ")
fstring = replace(fstring, chr(9), " ")
fstring = replace(fstring, chr(34), """)
fstring = replace(fstring, chr(39), "'")
fstring = replace(fstring, chr(13), "")
fstring = replace(fstring, " ", " ")
fstring = replace(fstring, chr(10), "<br /> ")
fstring = chkbadwords(fstring)
htmlencode = fstring
end if
end function
'=============================================================
'函数作用:过滤html代码,不带脏话过滤
'=============================================================
public function htmlencodes(byval fstring)
if not isnull(fstring) then
fstring = replace(fstring, "'", "'")
fstring = replace(fstring, ">", ">")
fstring = replace(fstring, "<", "<")
fstring = replace(fstring, chr(32), " ")
fstring = replace(fstring, chr(9), " ")
fstring = replace(fstring, chr(34), """)
fstring = replace(fstring, chr(39), "'")
fstring = replace(fstring, chr(13), "")
fstring = replace(fstring, chr(10), "<br /> ")
fstring = replace(fstring, " ", " ")
htmlencodes = fstring
end if
end function
'=============================================================
'函数作用:判断发言是否来自外部
'=============================================================
public function checkpost()
on error resume next
dim server_v1, server_v2
checkpost = false
server_v1 = cstr(request.servervariables("http_referer"))
server_v2 = cstr(request.servervariables("server_name"))
if mid(server_v1, 8, len(server_v2)) = server_v2 then
checkpost = true
end if
end function
'=============================================================
'函数作用:判断来源url是否来自外部
'=============================================================
public function checkouterurl()
on error resume next
dim server_v1, server_v2
server_v1 = replace(lcase(trim(request.servervariables("http_referer"))), "http://", "")
server_v2 = lcase(trim(request.servervariables("server_name")))
if server_v1 <> "" and left(server_v1, len(server_v2)) <> server_v2 then
checkouterurl = false
else
checkouterurl = true
end if
end function
'================================================
'函数名:gottopic
'作 用:显示字符串长度
'参 数:str ----原字符串
' strlen ----显示字符长度
'================================================
public function gottopic(byval str, byval strlen)
dim l, t, c, i
dim strtemp
on error resume next
str = trim(str)
str = replace(str, " ", " ")
str = replace(str, ">", ">")
str = replace(str, "<", "<")
str = replace(str, ">", ">")
str = replace(str, "<", "<")
str = replace(str, "'", "'")
str = replace(str, """, chr(34))
str = replace(str, vbnewline, "")
l = len(str)
t = 0
for i = 1 to l
c = abs(asc(mid(str, i, 1)))
if c > 255 then
t = t + 2
else
t = t + 1
end if
if t >= strlen then
strtemp = left(str, i) & "..."
exit for
else
strtemp = str & " "
end if
next
gottopic = checktopic(strtemp)
end function
public function checktopic(byval strcontent)
dim re
on error resume next
set re = new regexp
re.ignorecase = true
re.global = true
re.pattern = "(<s+cript(.+?)<\/s+cript>)"
strcontent = re.replace(strcontent, "")
re.pattern = "(<iframe(.+?)<\/iframe>)"
strcontent = re.replace(strcontent, "")
re.pattern = "(>)"
strcontent = re.replace(strcontent, ">")
re.pattern = "(<)"
strcontent = re.replace(strcontent, "<")
set re = nothing
strcontent = replace(strcontent, ">", ">")
strcontent = replace(strcontent, "<", "<")
strcontent = replace(strcontent, "'", "'")
strcontent = replace(strcontent, chr(34), """)
strcontent = replace(strcontent, "%", "%")
strcontent = replace(strcontent, vbnewline, "")
checktopic = trim(strcontent)
end function
'================================================
'函数名:readtopic
'作 用:显示字符串长度
'参 数:str ----原字符串
' strlen ----显示字符长度
'================================================
public function readtopic(byval str, byval strlen)
dim l, t, c, i
on error resume next
str = replace(str, " ", " ")
if len(str) < strlen then
str = str & string(strlen - len(str), ".")
else
str = str
end if
l = len(str)
t = 0
for i = 1 to l
c = abs(asc(mid(str, i, 1)))
if c > 255 then
t = t + 2
else
t = t + 1
end if
if t >= strlen then
readtopic = left(str, i) & "..."
exit for
else
readtopic = str & "..."
end if
next
end function
'================================================
'函数名:strlength
'作 用:计字符串长度
'参 数:str ----字符串
'================================================
public function strlength(byval str)
on error resume next
if isnull(str) or str = "" then
strlength = 0
exit function
end if
dim winnt_chinese
winnt_chinese = (len("例子") = 2)
if winnt_chinese then
dim l, t
dim i, c
l = len(str)
t = l
for i = 1 to l
c = asc(mid(str, i, 1))
if c < 0 then c = c + 65536
if c > 255 then t = t + 1
next
strlength = t
else
strlength = len(str)
end if
end function
'=================================================
'函数名:isinteger
'作 用:判断数字是否整型
'参 数:para ----参数
'=================================================
public function isinteger(byval para)
on error resume next
dim str
dim l, i
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
public function cutstring(byval str, byval strlen)
on error resume next
dim htmlstr, l, re, strcontent
htmlstr = str
htmlstr = replace(htmlstr, " ", " ")
htmlstr = replace(htmlstr, """, chr(34))
htmlstr = replace(htmlstr, "'", chr(39))
htmlstr = replace(htmlstr, "{", chr(123))
htmlstr = replace(htmlstr, "}", chr(125))
htmlstr = replace(htmlstr, "$", chr(36))
htmlstr = replace(htmlstr, vbcrlf, "")
htmlstr = replace(htmlstr, "====", "")
htmlstr = replace(htmlstr, "----", "")
htmlstr = replace(htmlstr, "////", "")
htmlstr = replace(htmlstr, "\\\\", "")
htmlstr = replace(htmlstr, "####", "")
htmlstr = replace(htmlstr, "@@@@", "")
htmlstr = replace(htmlstr, "****", "")
htmlstr = replace(htmlstr, "~~~~", "")
set re = new regexp
re.ignorecase = true
re.global = true
re.pattern = "\[br\]"
htmlstr = re.replace(htmlstr, "")
re.pattern = "\[align=right\](.*)\[\/align\]"
htmlstr = re.replace(htmlstr, "")
re.pattern = "<(.[^>]*)>"
htmlstr = re.replace(htmlstr, "")
set re = nothing
htmlstr = replace(htmlstr, ">", ">")
htmlstr = replace(htmlstr, "<", "<")
l = len(htmlstr)
if l >= strlen then
strcontent = left(htmlstr, strlen) & "..."
else
strcontent = htmlstr & " "
end if
strcontent = replace(strcontent, chr(34), """)
strcontent = replace(strcontent, chr(39), "'")
strcontent = replace(strcontent, chr(36), "$")
strcontent = replace(strcontent, chr(123), "{")
strcontent = replace(strcontent, chr(125), "}")
strcontent = replace(strcontent, ">", ">")
strcontent = replace(strcontent, "<", "<")
cutstring = strcontent
end function
'================================================
'函数名:checkinfuse
'作 用:防止sql注入
'参 数:str ----原字符串
' strlen ----提交字符串长度
'================================================
public function checkinfuse(byval str, byval strlen)
dim strunsafe, arrunsafe
dim i
if trim(str) = "" then
checkinfuse = ""
exit function
end if
str = left(str, strlen)
on error resume next
strunsafe = "'|^|;|and|exec|insert|select|delete|update|count|*|%|chr|mid|master|truncate|char|declare"
if trim(str) <> "" then
if len(str) > strlen then
response.write "<script language=javascript>alert('安全系统提示↓\n\n您提交的字符数超过了限制!');history.back(-1)</script>"
checkinfuse = ""
response.end
end if
arrunsafe = split(strunsafe, "|")
for i = 0 to ubound(arrunsafe)
if instr(1, str, arrunsafe(i), 1) > 0 then
response.write "<script language=javascript>alert('安全系统提示↓\n\n请不要在参数中包含非法字符!');history.back(-1)</script>"
checkinfuse = ""
response.end
end if
next
end if
checkinfuse = trim(str)
exit function
if err.number <> 0 then
err.clear
response.write "<script language=javascript>alert('安全系统提示↓\n\n请不要在参数中包含非法字符!');history.back(-1)</script>"
checkinfuse = ""
response.end
end if
end function
public sub preventinfuse()
on error resume next
dim sql_nonlicet, arrnonlicet
dim postrefer, getrefer, sql_data
sql_nonlicet = "'|;|^|and|exec|insert|select|delete|update|count|*|%|chr|mid|master|truncate|char|declare"
arrnonlicet = split(sql_nonlicet, "|")
if request.form <> "" then
for each postrefer in request.form
for sql_data = 0 to ubound(arrnonlicet)
if instr(1, request.form(postrefer), arrnonlicet(sql_data), 1) > 0 then
response.write "<script language=javascript>alert('安全系统提示↓\n\n请不要在参数中包含非法字符!');history.back(-1)</script>"
response.end
end if
next
next
end if
if request.querystring <> "" then
for each getrefer in request.querystring
for sql_data = 0 to ubound(arrnonlicet)
if instr(1, request.querystring(getrefer), arrnonlicet(sql_data), 1) > 0 then
response.write "<script language=javascript>alert('安全系统提示↓\n\n请不要在参数中包含非法字符!');history.back(-1)</script>"
response.end
end if
next
next
end if
end sub
'================================================
'函数名:chkquerystr
'作 用:过虑查询的非法字符
'参 数:str ----原字符串
'返回值:过滤后的字符
'================================================
public function chkquerystr(byval str)
on error resume next
if isnull(str) then
chkquerystr = ""
exit function
end if
str = replace(str, "!", "")
str = replace(str, "]", "")
str = replace(str, "[", "")
str = replace(str, ")", "")
str = replace(str, "(", "")
str = replace(str, "|", "")
str = replace(str, "+", "")
str = replace(str, "=", "")
str = replace(str, "'", "''")
str = replace(str, "%", "")
str = replace(str, "&", "")
str = replace(str, "#", "")
str = replace(str, "^", "")
str = replace(str, " ", " ")
str = replace(str, chr(37), "")
str = replace(str, chr(0), "")
chkquerystr = str
end function
'================================================
'过程名:checkquery
'作 用:限制搜索的关键字
'参 数:str ----搜索的字符串
'返回值:true; false
'================================================
public function checkquery(byval str)
dim fobwords, i, keyword
keyword = str
on error resume next
fobwords = array(91, 92, 304, 305, 430, 431, 437, 438, 12460, 12461, 12462, 12463, 12464, 12465, 12466, 12467, 12468, 12469, 12470, 12471, 12472, 12473, 12474, 12475, 12476, 12477, 12478, 12479, 12480, 12481, 12482, 12483, 12485, 12486, 12487, 12488, 12489, 12490, 12496, 12497, 12498, 12499, 12500, 12501, 12502, 12503, 12504, 12505, 12506, 12507, 12508, 12509, 12510, 12532, 12533, 65339, 65340)
for i = 1 to ubound(fobwords, 1)
if instr(keyword, chrw(fobwords(i))) > 0 then
checkquery = false
exit function
end if
next
fobwords = array("~", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "+", "=", "`", "[", "]", "{", "}", ";", ":", """", "'", "<", ">", ".", "/", "\", "|", "?", "about", "after", "all", "also", "an", "and", "another", "any", "are", "as", "at", "be", "because", "been", "before", "being", "between", "both", "but", "by", "came", "can", "come", "could", "did", "do", "each", "for", "from", "get", "got", "had", "has", "have", "he", "her", "here", "him", "himself", "his", "how", "if", "in", "into", "is", "it", "like", "make", "many", "me", "might", "more", "most", "much", "must", "my", "never", "now", "of", "on", "only", "or", "other", "our", "out", "over", "said", "same", "see", "should", "since", "some", "still", "such", "take", "than", "that", "the", "their", "them", "then", "there", "these", "they", "this")
keyword = left(keyword, 100)
keyword = replace(keyword, "!", " ")
keyword = replace(keyword, "]", " ")
keyword = replace(keyword, "[", " ")
keyword = replace(keyword, ")", " ")
keyword = replace(keyword, "(", " ")
keyword = replace(keyword, " ", " ")
keyword = replace(keyword, "-", " ")
keyword = replace(keyword, "/", " ")
keyword = replace(keyword, "+", " ")
keyword = replace(keyword, "=", " ")
keyword = replace(keyword, ",", " ")
keyword = replace(keyword, "'", " ")
for i = 0 to ubound(fobwords, 1)
if keyword = fobwords(i) then
checkquery = false
exit function
end if
next
checkquery = true
end function
'================================================
'函数名:isvalidstr
'作 用:判断字符串中是否含有非法字符
'参 数:str ----原字符串
'返回值:false,true -----布尔值
'================================================
public function isvalidstr(byval str)
isvalidstr = false
on error resume next
if isnull(str) then exit function
if trim(str) = empty then exit function
dim forbidstr, i
forbidstr = "and|chr|:|=|%|&|$|#|@|+|-|*|/|\|<|>|;|,|^|" & chr(32) & "|" & chr(34) & "|" & chr(39) & "|" & chr(9)
forbidstr = split(forbidstr, "|")
for i = 0 to ubound(forbidstr)
if instr(1,str, forbidstr(i),1) > 0 then
isvalidstr = false
exit function
end if
next
isvalidstr = true
end function
'================================================
'函数名:isvalidpassword
'作 用:判断密码中是否含有非法字符
'参 数:str ----原字符串
'返回值:false,true -----布尔值
'================================================
public function isvalidpassword(byval str)
isvalidpassword = false
on error resume next
if isnull(str) then exit function
if trim(str) = empty then exit function
dim forbidstr, i
forbidstr = "=and|chr|*|^|%|&|;|,|" & chr(32) & "|" & chr(34) & "|" & chr(39) & "|" & chr(9)
forbidstr = split(forbidstr, "|")
for i = 0 to ubound(forbidstr)
if instr(1, str, forbidstr(i), 1) > 0 then
isvalidpassword = false
exit function
end if
next
isvalidpassword = true
end function
'================================================
'函数名:isvalidchar
'作 用:判断字符串中是否含有非法字符和中文
'参 数:str ----原字符串
'返回值:false,true -----布尔值
'================================================
public function isvalidchar(byval str)
isvalidchar = false
on error resume next
if isnull(str) then exit function
if trim(str) = empty then exit function
dim validstr
dim i, l, s, c
validstr = "abcdefghijklmnopqrstuvwxyz.-_:~\/0123456789"
l = len(str)
s = ucase(str)
for i = 1 to l
c = mid(s, i, 1)
if instr(validstr, c) = 0 then
isvalidchar = false
exit function
end if
next
isvalidchar = true
end function
'================================================
'函数名:formatdate
'作 用:格式化日期
'参 数:dateandtime ----原日期和时间
' para ----日期格式
'返回值:格式化后的日期
'================================================
public function formatdate(dateandtime, para)
on error resume next
dim y, m, d, h, mi, s, strdatetime
formatdate = dateandtime
if not isnumeric(para) then exit function
if not isdate(dateandtime) then exit function
y = cstr(year(dateandtime))
m = cstr(month(dateandtime))
if len(m) = 1 then m = "0" & m
d = cstr(day(dateandtime))
if len(d) = 1 then d = "0" & d
h = cstr(hour(dateandtime))
if len(h) = 1 then h = "0" & h
mi = cstr(minute(dateandtime))
if len(mi) = 1 then mi = "0" & mi
s = cstr(second(dateandtime))
if len(s) = 1 then s = "0" & s
select case para
case "1"
strdatetime = y & "-" & m & "-" & d & " " & h & ":" & mi & ":" & s
case "2"
strdatetime = y & "-" & m & "-" & d
case "3"
strdatetime = y & "/" & m & "/" & d
case "4"
strdatetime = y & "年" & m & "月" & d & "日"
case "5"
strdatetime = m & "-" & d
case "6"
strdatetime = m & "/" & d
case "7"
strdatetime = m & "月" & d & "日"
case "8"
strdatetime = y & "年" & m & "月"
case "9"
strdatetime = y & "-" & m
case "10"
strdatetime = y & "/" & m
case else
strdatetime = dateandtime
end select
formatdate = strdatetime
end function
'================================================
'函数名:readfontmode
'作 用:读取字体模式
'参 数:str ----原字符串
' vcolor -----颜色的值
' vfont -----字体的值
'返回值:新字符串
'================================================
public function readfontmode(str, vcolor, vfont)
dim fontstr, tcolor
dim colorstr, arrcolor
if isnull(str) then
readfontmode = ""
exit function
end if
readfontmode = str
on error resume next
if not isnumeric(vcolor) then exit function
if not isnumeric(vfont) then exit function
select case cint(vfont)
case 1
fontstr = "<b>" & str & "</b>"
case 2
fontstr = "<em>" & str & "</em>"
case 3
fontstr = "<u>" & str & "</u>"
case 4
fontstr = "<b><em>" & str & "</em></b>"
case 5
fontstr = "<b><u>" & str & "</u></b>"
case 6
fontstr = "<em><u>" & str & "</u></em>"
case 7
fontstr = "<b><em><u>" & str & "</u></em></b>"
case else
fontstr = str
end select
readfontmode = fontstr
if vcolor = "" or vcolor = 0 then exit function
colorstr = "," & inittitlecolor
arrcolor = split(colorstr, ",")
if vcolor > ubound(arrcolor) then exit function
tcolor = trim(arrcolor(vcolor))
readfontmode = "<font color=" & tcolor & ">" & fontstr & "</font>"
end function
'=============================================================
'函数名:showdatetime
'作 用:读取日期格式
'参 数:dateandtime ---- 当前时间
' para ---- 时间格式
'=============================================================
public function showdatetime(dateandtime, para)
showdatetime = ""
dim strdate
if not isdate(dateandtime) then exit function
if dateandtime >= date then
strdate = "<font color='" & main_setting(1) & "'>"
strdate = strdate & formatdate(dateandtime, para)
strdate = strdate & "</font>"
else
strdate = "<font color='" & main_setting(2) & "'>"
strdate = strdate & formatdate(dateandtime, para)
strdate = strdate & "</font>"
end if
showdatetime = strdate
end function
public function showdatepath(strval, n)
showdatepath = ""
if trim(strval) = "" then exit function
dim strtemppath, strtime
dim y, m, d
strtime = left(strval, 8)
y = left(strtime, 4)
m = mid(strtime, 5, 2)
d = right(strtime, 2)
select case cint(n)
case 1
strtemppath = y & "/" & m & "/" & d & "/"
case 2
strtemppath = y & "/" & m & "/"
case 3
strtemppath = y & m & "/"
case 4
strtemppath = y & "/"
case 5
strtemppath = y & "-" & m & "-" & d & "/"
case 6
strtemppath = y & "-" & m & "/"
case 7
strtemppath = "html/"
case 8
strtemppath = "show/"
case else
strtemppath = ""
end select
strtemppath = replace(strtemppath, " ", "")
showdatepath = cstr(strtemppath)
end function
'=============================================================
'函数名:readbrieftopicffd
'作 用:读取简短标题
'参 数:para
'返回值:简短标题
'=============================================================
public function readbrieftopic(byval para)
dim sbrieftopic
readbrieftopic = ""
if not isnumeric(para) then exit function
if para = 0 then exit function
select case para
case "1"
sbrieftopic = "<font color='blue'>[图文]</font>"
case "2"
sbrieftopic = "<font color='red'>[组图]</font>"
case "3"
sbrieftopic = "<font color='green'>[新闻]</font>"
case "4"
sbrieftopic = "<font color='blue'>[推荐]</font>"
case "5"
sbrieftopic = "<font color='red'>[注意]</font>"
case "6"
sbrieftopic = "<font color='green'>[转载]</font>"
case else
sbrieftopic = ""
end select
readbrieftopic = sbrieftopic
end function
'=============================================================
'函数名:readpictopic
'作 用:读取简短标题
'参 数:para
'返回值:简短标题
'=============================================================
public function readpictopic(byval para)
dim sbrieftopic
readpictopic = ""
if not isnumeric(para) then exit function
if para = 0 then exit function
select case para
case "1"
sbrieftopic = "<font color='" & main_setting(4) & "'>[图文]</font>"
case "2"
sbrieftopic = "<font color='" & main_setting(5) & "'>[组图]</font>"
case "3"
sbrieftopic = "<font color='" & main_setting(6) & "'>[新闻]</font>"
case "4"
sbrieftopic = "<font color='" & main_setting(4) & "'>[推荐]</font>"
case "5"
sbrieftopic = "<font color='" & main_setting(5) & "'>[注意]</font>"
case "6"
sbrieftopic = "<font color='" & main_setting(6) & "'>[转载]</font>"
case else
sbrieftopic = ""
end select
readpictopic = sbrieftopic
end function
'=============================================================
'函数名:readpaymoney
'作 用:读取要支付的金钱
'参 数:money ----实际金钱
'返回值:加上手续费后的金钱
'=============================================================
public function readpaymoney(byval money, byval reduce)
on error resume next
if money = 0 then
readpaymoney = 0
exit function
end if
dim arrchinaebank, valpercent, percents
arrchinaebank = split(chinaebank, "|||")
percents = ccur(arrchinaebank(2) / 100)
if percents = 0 then
readpaymoney = ccur(money)
else
if cbool(reduce) = true then
valpercent = round(ccur(money) / (1 + 1 * percents), 2)
readpaymoney = ccur(valpercent)
else
valpercent = round(ccur(money) * percents, 2)
readpaymoney = ccur(money + valpercent)
end if
end if
end function
'=============================================================
'函数名:rebatemoney
'作 用:读取打折的后金钱
'参 数:money ----实际金钱
' discount ----折扣
'=============================================================
public function rebatemoney(byval money, byval discount)
on error resume next
dim rebate
money = checknumeric(money)
discount = checknumeric(discount)
if discount > 0 and discount < 10 then
rebate = round(money * (discount / 10), 2)
rebatemoney = ccur(rebate)
else
rebatemoney = ccur(money)
end if
end function
'================================================
'函数名:supplemental
'作 用:补足参数
'参 数:para ----原参数
' n ----增补的位数
'================================================
public function supplemental(para, n)
supplemental = ""
if not isnumeric(para) then exit function
if len(para) < n then
supplemental = string(n - len(para), "0") & para
else
supplemental = para
end if
end function
'-----------------------------------------------------------------
public function getchanneldir(byval chanid)
on error resume next
if not isnumeric(chanid) then chanid = 1
name = "channel" & chanid
if objisempty() then reloadchannel (chanid)
cachechannel = value
getchanneldir = installdir & cachechannel(2,0)
end function
'================================================
'函数名:getimageurl
'作 用:获取图片url
'================================================
public function getimageurl(byval url, byval channeldir)
on error resume next
dim strtempurl, strimageurl
if not isnull(url) and trim(url) <> "" and lcase(url) <> "http://" then
strtempurl = installdir & channeldir
if checkurl(url) = 1 then
strimageurl = trim(url)
elseif checkurl(url) = 2 then
strimageurl = url
else
strimageurl = replace(url, "../", "")
strimageurl = trim(strtempurl & strimageurl)
end if
else
strimageurl = installdir & "images/no_pic.gif"
end if
getimageurl = strimageurl
end function
'-----------------------------------------------------------------
'================================================
'作 用:读取图片或者flash
'参 数:url ----文件url
' height ----高度
' width ----宽度
'================================================
function getflashandpic(byval url, byval height, byval width)
on error resume next
dim sextname, extname, strtemp
dim strheight, strwidth
if not isnumeric(height) or height < 1 then
strheight = ""
else
strheight = " height=" & height
end if
if not isnumeric(width) or width < 1 then
strwidth = ""
else
strwidth = " width=" & width
end if
sextname = split(url, ".")
extname = sextname(ubound(sextname))
if lcase(extname) = "swf" then
strtemp = "<embed src=""" & url & """" & strwidth & strheight & ">"
else
strtemp = "<img src=""" & url & """" & strwidth & strheight & " border=0>"
end if
getflashandpic = strtemp
end function
'================================================
'函数名:readfileurl
'作 用:读取文件url
'================================================
public function readfileurl(url)
on error resume next
readfileurl = ""
if url = "" then exit function
dim strtemp
if checkurl(url) = 1 then
strtemp = trim(url)
elseif checkurl(url) = 2 then
strtemp = trim(url)
else
strtemp = replace(url, "../", "")
strtemp = trim(installdir & strtemp)
end if
readfileurl = strtemp
end function
public function checkurl(byval url)
dim strurl
if left(url, 1) = "/" then
checkurl = 1
exit function
end if
strurl = lcase(left(url, 6))
select case trim(strurl)
case "http:/", "https:", "ftp://", "rtsp:/", "mms://"
checkurl = 2
exit function
case else
checkurl = 0
end select
end function
'================================================
'函数名:readfilename
'作 用:读取html文件名
'参 数:strname ----文件名称
' id ----数据id
' extname ----html扩展名
' prefixstr ----html名称前缀
' htmlform ----html文件格式
' n ----html分页
'================================================
public function readfilename(byval strname, byval id, byval extname, byval prefixstr, byval htmlform, byval n)
dim strfilename, strextname, currentpage
if trim(strname) = "" then exit function
if trim(extname) = "" then extname = ".html"
if not isnumeric(n) then n = 0
on error resume next
if cint(n) <= 1 then
currentpage = ""
else
currentpage = "_" & n
end if
if left(extname, 1) <> "." then
strextname = "." & trim(extname)
else
strextname = trim(extname)
end if
select case trim(htmlform)
case "1"
strfilename = trim(id)
case "2"
strfilename = trim(prefixstr) & trim(supplemental(id, 3))
case "3"
strfilename = left(strname, 8)
strfilename = strfilename & trim(supplemental(id, 3))
case "4"
strfilename = right(strname, 7)
strfilename = strfilename & trim(supplemental(id, 3))
case else
strfilename = strname
end select
strfilename = replace(strfilename & currentpage & strextname, " ", "")
readfilename = cstr(strfilename)
end function
'================================================
'过程名:htmlrndfilename
'作 用:取html的随机文件名
'================================================
function htmlrndfilename()
dim srnd
randomize
srnd = int(90 * rnd) + 10
htmlrndfilename = replace(replace(replace(formatdate(now(), 1), "-", ""), ":", ""), " ", "") & srnd
end function
'================================================
'函数名:classfilename
'作 用:读取html文件列表名
'参 数:classid ----分类id
'================================================
public function classfilename(byval classid, byval extname, byval prefixstr, byval n)
dim strfilename, strextname, strclassid
if trim(extname) = "" then extname = ".html"
if not isnumeric(n) then n = 0
if left(extname, 1) <> "." then
strextname = "." & trim(extname)
else
strextname = trim(extname)
end if
if cint(n) <= 1 then
strfilename = "index" & strextname
else
strclassid = supplemental(classid, 3)
strfilename = prefixstr & strclassid & "_" & n & strextname
end if
strfilename = replace(strfilename, " ", "")
classfilename = cstr(strfilename)
end function
'================================================
'函数名:specialfilename
'作 用:读取专题html文件名
'参 数:specid ----专题id
'================================================
public function specialfilename(byval specid, byval extname, byval n)
dim strfilename, strextname, strspecialid
if trim(extname) = "" then extname = ".html"
if not isnumeric(n) then n = 0
if left(extname, 1) <> "." then
strextname = "." & trim(extname)
else
strextname = trim(extname)
end if
if cint(n) <= 1 then
strfilename = "index" & strextname
else
strspecialid = supplemental(specid, 3)
strfilename = "special" & strspecialid & "_" & n & strextname
end if
strfilename = replace(strfilename, " ", "")
specialfilename = cstr(strfilename)
end function
'================================================
'函数名:channelmenu
'作 用:显示频道菜单
'================================================
public function channelmenu()
dim sql, rs, i, totalnumber,strtop
dim strcontent, linktarget, channelname
dim channelurl, htmlcontent, scaption
name = "channelmenu"
if objisempty() then
if chknumeric(main_setting(7)) = 0 then
strtop = vbnullstring
else
strtop = "top " & cint(main_setting(7))
end if
sql = "select " & strtop & " channelid,orders,colormodes,fontmodes,channelname,caption,channeldir,stopchannel,ishidden,binddomain,domainname,linktarget,channeltype,channelurl,ishidden from [nc_channel] where ishidden = 0 order by orders"
set rs = execute(sql)
if rs.bof and rs.eof then
strcontent = ""
else
i = 0
totalnumber = rs.recordcount
do while not rs.eof
i = i + 1
if rs("linktarget") <> 0 then
linktarget = " target=""_blank"""
else
linktarget = ""
end if
htmlcontent = htmlcontent & main_setting(9)
channelname = readfontmode(rs("channelname"), rs("colormodes"), rs("fontmodes"))
if rs("channeltype") < 2 then
channelurl = installdir & rs("channeldir")
else
channelurl = rs("channelurl")
end if
if rs("stopchannel") <> 0 then
scaption = "此频道暂时关闭,不能访问!"
else
scaption = rs("caption")
end if
strcontent = "<a href=""" & channelurl & """" & linktarget & " title=""" & scaption & """ class=navmenu>" & channelname & "</a>"
if i mod cint(main_setting(8)) = 0 then strcontent = strcontent & "<br>"
htmlcontent = replace(htmlcontent, "{$channelmenu}", strcontent)
rs.movenext
loop
end if
rs.close: set rs = nothing
'value = strcontent
end if
'strcontent = value
channelmenu = htmlcontent
end function
'=============================================================
'函数名:loadselectclass
'作 用:载入缓存下拉分类列表
'参 数:channelid ----频道id
'返回值:下拉分类列表
'=============================================================
public function loadselectclass(channelid)
dim cacheselclass, sql, rs1, i
name = "selectclass" & channelid
if objisempty() then
sql = "select classid,classname,depth,turnlink,child from nc_classify where channelid = " & channelid & " order by rootid,orders"
set rs1 = execute(sql)
if rs1.bof and rs1.eof then
cacheselclass = cacheselclass & "<option>没有添加分类</option>"
end if
do while not rs1.eof
if rs1("turnlink") <> 0 then
cacheselclass = cacheselclass & "<option value=""0"""
else
if rs1("depth") = 0 and rs1("child") <> 0 then
cacheselclass = cacheselclass & "<option"
else
cacheselclass = cacheselclass & "<option value=""" & rs1("classid") & """"
end if
end if
cacheselclass = cacheselclass & " {classid=" & rs1("classid") & "}>"
if rs1("depth") = 1 then cacheselclass = cacheselclass & " ├ "
if rs1("depth") > 1 then
for i = 2 to rs1("depth")
cacheselclass = cacheselclass & " "
next
cacheselclass = cacheselclass & " ├ "
end if
cacheselclass = cacheselclass & rs1("classname") & "</option>" & vbcrlf
rs1.movenext
loop
rs1.close
set rs1 = nothing
value = cacheselclass
end if
loadselectclass = value
end function
public function classjumpmenu(channelid)
dim cachejumpmenu
dim rs1
dim i
name = "classjumpmenu" & channelid
if objisempty() then
set rs1 = execute("select classid,channelid,classname,depth,turnlink,turnlinkurl from [nc_classify] where channelid = " & channelid & " order by rootid,orders")
do while not rs1.eof
if rs1("turnlink") <> 0 then
cachejumpmenu = cachejumpmenu & "<option value=""" & rs1("turnlinkurl") & """ {classid=" & rs1("classid") & "}"
else
cachejumpmenu = cachejumpmenu & "<option value=""?channelid=" & rs1("channelid") & "&sortid=" & rs1("classid") & """ {classid=" & rs1("classid") & "}"
end if
if trim(request("sortid")) <> "" then
if clng(request("sortid")) = rs1("classid") then cachejumpmenu = cachejumpmenu & " selected"
end if
cachejumpmenu = cachejumpmenu & ">"
if rs1("depth") = 1 then cachejumpmenu = cachejumpmenu & " ├ "
if rs1("depth") > 1 then
for i = 2 to rs1("depth")
cachejumpmenu = cachejumpmenu & " "
next
cachejumpmenu = cachejumpmenu & " ├ "
end if
cachejumpmenu = cachejumpmenu & rs1("classname") & "</option>" & vbcrlf
rs1.movenext
loop
rs1.close
set rs1 = nothing
value = cachejumpmenu
end if
classjumpmenu = value
end function
'================================================
'函数名:getrandomcode
'作 用:系统分配随机代码
'================================================
public function getrandomcode()
dim ran, i, lengthnum
lengthnum = 16
getrandomcode = ""
for i = 1 to lengthnum
randomize
ran = cint(rnd * 2)
randomize
if ran = 0 then
ran = cint(rnd * 25) + 97
getrandomcode = getrandomcode & ucase(chr(ran))
elseif ran = 1 then
ran = cint(rnd * 9)
getrandomcode = getrandomcode & ran
elseif ran = 2 then
ran = cint(rnd * 25) + 97
getrandomcode = getrandomcode & chr(ran)
end if
next
end function
'================================================
' 函数名:codeistrue
' 作 用:检查验证码是否正确
'================================================
public function codeistrue()
dim codestr
codestr = trim(request("codestr"))
on error resume next
if cstr(session("getcode")) = cstr(codestr) and codestr <> "" then
codeistrue = true
session("getcode") = empty
else
codeistrue = false
session("getcode") = empty
end if
end function
public function checkadmin(byval flag)
dim rs, sql
dim i, tempadmin, adminflag, admingrade
checkadmin = false
on error resume next
sql = "select admingrade,adminflag from nc_admin where username='" & replace(session("adminname"), "'", "''") & "' and password='" & replace(session("adminpass"), "'", "''") & "' and islock=0 and id=" & clng(session("adminid"))
set rs = execute(sql)
if rs.bof and rs.eof then
checkadmin = false
set rs = nothing
exit function
else
adminflag = rs("adminflag")
admingrade = rs("admingrade")
end if
rs.close: set rs = nothing
if cint(admingrade) = 999 then
checkadmin = true
exit function
else
if trim(flag) = "" then exit function
if adminflag = "" then
checkadmin = false
exit function
else
tempadmin = split(adminflag, ",")
for i = 0 to ubound(tempadmin)
if trim(lcase(tempadmin(i))) = trim(lcase(flag)) then
checkadmin = true
exit for
end if
next
end if
end if
end function
'================================================
'函数名:readalpha
'作 用:读取字符串的第一个字母
'参 数:str ----字符
'返回值:返回第一个字母
'================================================
public function readalpha(byval str)
dim strtemp
if isnull(str) or trim(str) = "" then
readalpha = "a-9"
exit function
end if
str = trim(str)
strtemp = 65536 + asc(str)
if (strtemp >= 45217 and strtemp <= 45252) or (strtemp = 65601) or (strtemp = 65633) or (strtemp = 37083) then
readalpha = "a-z"
elseif (strtemp >= 45253 and strtemp <= 45760) or (strtemp = 65602) or (strtemp = 65634) or (strtemp = 39658) then
readalpha = "b-z"
elseif (strtemp >= 45761 and strtemp <= 46317) or (strtemp = 65603) or (strtemp = 65635) or (strtemp = 33405) then
readalpha = "c-z"
elseif (strtemp >= 46318 and strtemp <= 46930) or (strtemp >= 61884 and strtemp <= 61884) or (strtemp = 65604) or (strtemp >= 36820 and strtemp <= 38524) or (strtemp = 65636) then
readalpha = "d-z"
elseif (strtemp >= 46931 and strtemp <= 47009) or (strtemp = 65605) or (strtemp = 65637) or (strtemp = 61513) then
readalpha = "e-z"
elseif (strtemp >= 47010 and strtemp <= 47296) or (strtemp = 65606) or (strtemp = 65638) or (strtemp = 61320) or (strtemp = 63568) or (strtemp = 36281) then
readalpha = "f-z"
elseif (strtemp >= 47297 and strtemp <= 47613) or (strtemp = 65607) or (strtemp = 65639) or (strtemp = 35949) or (strtemp = 36089) or (strtemp = 36694) or (strtemp = 34808) then
readalpha = "g-z"
elseif (strtemp >= 47614 and strtemp <= 48118) or (strtemp >= 59112 and strtemp <= 59112) or (strtemp = 65608) or (strtemp = 65640) then
readalpha = "h-z"
elseif (strtemp = 65641) or (strtemp = 65609) or (strtemp = 65641) then
readalpha = "i-z"
elseif (strtemp >= 48119 and strtemp <= 49061 and strtemp <> 48739) or (strtemp >= 62430 and strtemp <= 62430) or (strtemp = 65610) or (strtemp = 65642) or (strtemp = 39048) then
readalpha = "j-z"
elseif (strtemp >= 49062 and strtemp <= 49323) or (strtemp = 65611) or (strtemp = 65643) then
readalpha = "k-z"
elseif (strtemp >= 49324 and strtemp <= 49895) or (strtemp >= 58838 and strtemp <= 58838) or (strtemp = 65612) or (strtemp = 65644) or (strtemp = 62418) or (strtemp = 48739) then
readalpha = "l-z"
elseif (strtemp >= 49896 and strtemp <= 50370) or (strtemp = 65613) or (strtemp = 65645) then
readalpha = "m-z"
elseif (strtemp >= 50371 and strtemp <= 50613) or (strtemp = 65614) or (strtemp = 65646) then
readalpha = "n-z"
elseif (strtemp >= 50614 and strtemp <= 50621) or (strtemp = 65615) or (strtemp = 65647) then
readalpha = "o-z"
elseif (strtemp >= 50622 and strtemp <= 50905) or (strtemp = 65616) or (strtemp = 65648) then
readalpha = "p-z"
elseif (strtemp >= 50906 and strtemp <= 51386) or (strtemp >= 62659 and strtemp <= 63172) or (strtemp = 65617) or (strtemp = 65649) then
readalpha = "q-z"
elseif (strtemp >= 51387 and strtemp <= 51445) or (strtemp = 65618) or (strtemp = 65650) then
readalpha = "r-z"
elseif (strtemp >= 51446 and strtemp <= 52217) or (strtemp = 65619) or (strtemp = 65651) or (strtemp = 34009) then
readalpha = "s-z"
elseif (strtemp >= 52218 and strtemp <= 52697) or (strtemp = 65620) or (strtemp = 65652) then
readalpha = "t-z"
elseif (strtemp = 65621) or (strtemp = 65653) then
readalpha = "u-z"
elseif (strtemp = 65622) or (strtemp = 65654) then
readalpha = "v-z"
elseif (strtemp >= 52698 and strtemp <= 52979) or (strtemp = 65623) or (strtemp = 65655) then
readalpha = "w-z"
elseif (strtemp >= 52980 and strtemp <= 53688) or (strtemp = 65624) or (strtemp = 65656) then
readalpha = "x-z"
elseif (strtemp >= 53689 and strtemp <= 54480) or (strtemp = 65625) or (strtemp = 65657) then
readalpha = "y-z"
elseif (strtemp >= 54481 and strtemp <= 62383 and strtemp <> 59112 and strtemp <> 58838) or (strtemp = 65626) or (strtemp = 65658) or (strtemp = 38395) or (strtemp = 39783) then
readalpha = "z-z"
else
readalpha = "a-9"
end if
if (strtemp >= 65633 and strtemp <= 65658) or (strtemp >= 65601 and strtemp <= 65626) then readalpha = ucase(left(str, 1))
if (strtemp >= 65584 and strtemp <= 65593) then readalpha = "0-9"
end function
'-- 修正文件路径
public function checkpath(byval spath)
spath = trim(spath)
if right(spath, 1) <> "\" and spath <> "" then
spath = spath & "\"
end if
checkpath = spath
end function
'-- 生成目录
public function creatpathex(byval spath)
spath = replace(spath, "/", "\")
spath = replace(spath, "\\", "\")
on error resume next
dim strhostpath,strpath
dim spathitem,stemppath
dim i,fso
set fso = server.createobject(fso_scriptname)
strhostpath = server.mappath("/")
if instr(spath, ":") = 0 then spath = server.mappath(spath)
if fso.folderexists(spath) or len(spath) < 3 then
creatpathex = true
exit function
end if
strpath = replace(spath, strhostpath, vbnullstring,1,-1,1)
spathitem = split(strpath, "\")
if instr(lcase(spath), lcase(strhostpath)) = 0 then
stemppath = spathitem(0)
else
stemppath = strhostpath
end if
for i = 1 to ubound(spathitem)
if spathitem(i) <> "" then
stemppath = stemppath & "\" & spathitem(i)
if fso.folderexists(stemppath) = false then
fso.createfolder stemppath
end if
end if
next
set fso = nothing
if err.number <> 0 then err.clear
creatpathex = true
end function
'================================================
'函数名:filesdelete
'作 用:fso删除文件
'参 数:filepath ----文件路径
'返回值:false ---- true
'================================================
public function filedelete(byval filepath)
on error resume next
filedelete = false
dim fso
set fso = server.createobject(fso_scriptname)
if filepath = "" then exit function
if instr(filepath, ":") = 0 then filepath = server.mappath(filepath)
if fso.fileexists(filepath) then
fso.deletefile filepath, true
filedelete = true
end if
set fso = nothing
if err.number <> 0 then err.clear
end function
'================================================
'函数名:folderdelete
'作 用:fso删除目录
'参 数:folderpath ----目录路径
'返回值:false ---- true
'================================================
public function folderdelete(byval folderpath)
folderdelete = false
on error resume next
dim fso
set fso = server.createobject(fso_scriptname)
if folderpath = "" then exit function
if instr(folderpath, ":") = 0 then folderpath = server.mappath(folderpath)
if fso.folderexists(folderpath) then
fso.deletefolder folderpath, true
folderdelete = true
end if
set fso = nothing
if err.number <> 0 then err.clear
end function
'================================================
'函数名:copytofile
'作 用:复制文件
'参 数:sourefile ----原文件路径
' newfile ----目标文件路径
'================================================
public function copytofile(byval sourefile, byval newfile)
on error resume next
if sourefile = "" then exit function
if newfile = "" then exit function
if instr(sourefile, ":") = 0 then sourefile = server.mappath(sourefile)
if instr(newfile, ":") = 0 then newfile = server.mappath(newfile)
dim fso
set fso = server.createobject(fso_scriptname)
if fso.fileexists(sourefile) then
fso.copyfile sourefile, newfile
end if
set fso = nothing
if err.number <> 0 then err.clear
end function
'================================================
'函数名:copytofolder
'作 用:复制文件夹
'参 数:sourefolder ----原路径
' newfolder ----目标路径
'================================================
public function copytofolder(byval sourefolder, byval newfolder)
on error resume next
if sourefolder = "" then exit function
if newfolder = "" then exit function
if instr(sourefolder, ":") = 0 then sourefolder = server.mappath(sourefolder)
if instr(newfolder, ":") = 0 then newfolder = server.mappath(newfolder)
dim fso
set fso = server.createobject(fso_scriptname)
if fso.folderexists(sourefolder) then
fso.copyfolder sourefolder, newfolder
end if
set fso = nothing
if err.number <> 0 then err.clear
end function
'=============================================================
'过程名:createdtextfile
'作 用:创建文本文件
'参 数:filename ----文件名
' body ----主要内容
'=============================================================
public function createdtextfile(byval filename, byval body)
on error resume next
if instr(filename, ":") = 0 then filename = server.mappath(filename)
dim fso,f
set fso = server.createobject(fso_scriptname)
set f = fso.createtextfile(filename)
f.writeline body
f.close
set f = nothing
set fso = nothing
if err.number <> 0 then err.clear
end function
'================================================
'函数名:readfile
'作 用:读取文件内容
'参 数:frompath ----来源文件路径
'================================================
public function readfile(byval frompath)
on error resume next
dim strtemp,fso,f
if instr(frompath, ":") = 0 then frompath = server.mappath(frompath)
set fso = server.createobject(fso_scriptname)
if fso.fileexists(frompath) then
set f = fso.opentextfile(frompath, 1, true)
strtemp = f.readall
f.close
set f = nothing
end if
set fso = nothing
readfile = strtemp
if err.number <> 0 then err.clear
end function
'================================================
'函数名:cutmatchcontent
'作 用:截取相匹配的内容
'参 数:str ----原字符串
' patstr ----符合条件字符
'================================================
public function cutmatchcontent(byval str, byval start, byval last, byval condition)
dim match,s,re
dim filterstr,matchstr
dim strcontent,arrayfilter
dim i, n,brepeat
if len(start) = 0 or len(last) = 0 then exit function
on error resume next
matchstr = "(" & correctpattern(start) & ")(.+?)(" & correctpattern(last) & ")"
set re = new regexp
re.ignorecase = true
re.global = true
re.pattern = matchstr
set s = re.execute(str)
n = 0
for each match in s
if n = 0 then
n = n + 1
redim arrayfilter(n)
arrayfilter(n) = match
else
brepeat = false
for i = 0 to ubound(arrayfilter)
if ucase(match) = ucase(arrayfilter(i)) then
brepeat = true
exit for
end if
next
if brepeat = false then
n = n + 1
redim preserve arrayfilter(n)
arrayfilter(n) = match
end if
end if
next
set s = nothing
set re = nothing
if cbool(condition) then
strcontent = join(arrayfilter, "|||")
else
strcontent = join(arrayfilter, "|||")
strcontent = replace(strcontent, start, "")
strcontent = replace(strcontent, last, "")
end if
cutmatchcontent = replace(strcontent, "|||", vbnullstring, 1, 1)
end function
function cutfixcontent(byval str, byval start, byval last, byval n)
dim strtemp
on error resume next
if instr(str, start) > 0 then
select case n
case 0 '左右都截取(都取前面)(去处关键字)
strtemp = right(str, len(str) - instr(str, start) - len(start) + 1)
strtemp = left(strtemp, instr(strtemp, last) - 1)
case else '左右都截取(都取前面)(保留关键字)
strtemp = right(str, len(str) - instr(str, start) + 1)
strtemp = left(strtemp, instr(strtemp, last) + len(last) - 1)
end select
else
strtemp = ""
end if
cutfixcontent = strtemp
end function
private function correctpattern(byval str)
str = replace(str, "\", "\\")
str = replace(str, "~", "\~")
str = replace(str, "!", "\!")
str = replace(str, "@", "\@")
str = replace(str, "#", "\#")
str = replace(str, "%", "\%")
str = replace(str, "^", "\^")
str = replace(str, "&", "\&")
str = replace(str, "*", "\*")
str = replace(str, "(", "\(")
str = replace(str, ")", "\)")
str = replace(str, "-", "\-")
str = replace(str, "+", "\+")
str = replace(str, "[", "\[")
str = replace(str, "]", "\]")
str = replace(str, "<", "\<")
str = replace(str, ">", "\>")
str = replace(str, ".", "\.")
str = replace(str, "/", "\/")
str = replace(str, "?", "\?")
str = replace(str, "=", "\=")
str = replace(str, "|", "\|")
str = replace(str, "$", "\$")
correctpattern = str
end function
'=============================================================
'函数名:usergroupsetting
'作 用:取用户级权限设置
'参 数:gradeid ----等级id
'=============================================================
public function usergroupsetting(byval gradeid)
if not isnumeric(gradeid) then
gradeid = 0
end if
on error resume next
dim rs, sql
name = "groupsetting" & gradeid
if objisempty() then
sql = "select groupname,groupset from [nc_usergroup] where grades =" & gradeid
set rs = execute(sql)
if rs.bof and rs.eof then
usergroupsetting = ""
set rs = nothing
exit function
end if
value = rs("groupset") & rs("groupname")
set rs = nothing
end if
usergroupsetting = value
end function
private sub loadgroupsetting()
dim strgroupsetting
dim rs, sql
dim grades
grades = cint(membergrade)
on error resume next
if grades > 0 and memberid > 0 then
if binuserlong = false then
set rs = execute("select userid from [nc_user] where password='" & checkrequest(memberpass, 45) & "' and usergrade=" & grades & " and userlock=0 and userid =" & memberid)
if rs.bof and rs.eof then
grades = 0
response.cookies(cookies_name) = ""
binuserlong = false
else
binuserlong = true
end if
set rs = nothing
end if
end if
name = "groupsetting" & grades
if objisempty() then
sql = "select groupname,groupset from [nc_usergroup] where grades =" & grades
set rs = execute(sql)
if rs.bof and rs.eof then
response.cookies(cookies_name) = ""
set rs = nothing
exit sub
end if
value = rs("groupset") & rs("groupname")
set rs = nothing
end if
blngroupsetting = true
strgroupsetting = value
arrgroupsetting = split(strgroupsetting, "|||")
end sub
public property get groupsetting(i)
if not blngroupsetting then loadgroupsetting
groupsetting = arrgroupsetting(i)
end property
public function readcontent(byval strcontent)
on error resume next
dim re, i
dim scontentkeyword, strkeyword
set re = new regexp
re.ignorecase = true
re.global = true
'过滤危险脚本
re.pattern = "(<s+cript(.[^>]*)>)"
strcontent = re.replace(strcontent, "<Script$2>")
re.pattern = "(<\/s+cript>)"
strcontent = re.replace(strcontent, "</Script>")
re.pattern = "(<body(.[^>]*)>)"
strcontent = re.replace(strcontent, "<body>")
re.pattern = "(<\!(.[^>]*)>)"
strcontent = re.replace(strcontent, "<$2>")
re.pattern = "(<\!)"
strcontent = re.replace(strcontent, "<!")
re.pattern = "(-->)"
strcontent = re.replace(strcontent, "-->")
re.pattern = "(javascript:)"
strcontent = re.replace(strcontent, "<i>javascript</i>:")
if trim(contentkeyword) <> "" then
scontentkeyword = split(contentkeyword, "@@@")
for i = 0 to ubound(scontentkeyword) - 1
strkeyword = split(scontentkeyword(i), "$$$")
re.pattern = "(" & strkeyword(0) & ")"
strcontent = re.replace(strcontent, "<a target=""_blank"" href=""" & strkeyword(1) & """ class=""wordstyle"">$1</a>")
next
end if
re.pattern = "(\[i\])(.[^\[]*)(\[\/i\])"
strcontent = re.replace(strcontent, "<i>$2</i>")
re.pattern = "(\[u\])(.[^\[]*)(\[\/u\])"
strcontent = re.replace(strcontent, "<u>$2</u>")
re.pattern = "(\[b\])(.[^\[]*)(\[\/b\])"
strcontent = re.replace(strcontent, "<b>$2</b>")
re.pattern = "(\[fly\])(.*)(\[\/fly\])"
strcontent = re.replace(strcontent, "<marquee>$2</marquee>")
re.pattern = "\[size=([1-9])\](.[^\[]*)\[\/size\]"
strcontent = re.replace(strcontent, "<font size=$1>$2</font>")
re.pattern = "(\[center\])(.[^\[]*)(\[\/center\])"
strcontent = re.replace(strcontent, "<center>$2</center>")
're.pattern = "<img.[^>]*src(=| )(.[^>]*)>"
'strcontent = re.replace(strcontent, "<img src=$2 border=""0"">")
re.pattern = "<img(.[^>]*)>"
strcontent = re.replace(strcontent, "<img$1 onload=""return imgzoom(this,550)"">")
re.pattern = "\[dir=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/dir]"
strcontent = re.replace(strcontent, "<embed src=$3 pluginspage=http://www.macromedia.com/shockwave/download/ width=$1 height=$2></embed>")
re.pattern = "\[qt=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/qt]"
strcontent = re.replace(strcontent, "<embed src=$3 width=$1 height=$2 autoplay=true loop=false controller=true playeveryframe=false cache=false scale=tofit bgcolor=#000000 kioskmode=false targetcache=false pluginspage=http://www.apple.com/quicktime/>")
re.pattern = "\[mp=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/mp]"
strcontent = re.replace(strcontent, "<embed type=application/x-oleobject codebase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#version=5,1,52,701 flename=mp src=$3 width=$1 height=$2></embed>")
re.pattern = "\[rm=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/rm]"
strcontent = re.replace(strcontent, "<object classid=clsid:cfcdaa03-8be4-11cf-b84b-0020afbbccfa class=object id=raocx width=$1 height=$2><param name=src value=$3><param name=console value=clip1><param name=controls value=imagewindow><param name=autostart value=true></object><br><object classid=clsid:cfcdaa03-8be4-11cf-b84b-0020afbbccfa height=32 id=video2 width=$1><param name=src value=$3><param name=autostart value=-1><param name=controls value=controlpanel><param name=console value=clip1></object>")
re.pattern = "(\[flash\])(.[^\[]*)(\[\/flash\])"
strcontent = re.replace(strcontent, "<embed src=""$2"" quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?p1_prod_version=shockwaveflash' type='application/x-shockwave-flash' width=500 height=400>$2</embed>")
re.pattern = "(\[flash=*([0-9]*),*([0-9]*)\])(.[^\[]*)(\[\/flash\])"
strcontent = re.replace(strcontent, "<embed src=""$4"" quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?p1_prod_version=shockwaveflash' type='application/x-shockwave-flash' width=$2 height=$3>$4</embed>")
re.pattern = "\[upload=(gif|jpg|jpeg|bmp|png)\](.[^\[]*)(gif|jpg|jpeg|bmp|png)\[\/upload\]"
strcontent = re.replace(strcontent, "<br><a href=""$2$1"" target=_blank><img src=""$2$1"" border=0 alt=按此在新窗口浏览图片 onload=""javascript:if(this.width>screen.width-333)this.width=screen.width-333""></a>")
re.pattern = "(\[upload=(.[^\[]*)\])(.[^\[]*)(\[\/upload\])"
strcontent = re.replace(strcontent, "<br><a href=""$3"">点击浏览该文件</a>")
re.pattern = "(\[url\])(.[^\[]*)(\[\/url\])"
strcontent = re.replace(strcontent, "<a href=""$2"" target=_blank>$2</a>")
re.pattern = "(\[url=(.[^\[]*)\])(.[^\[]*)(\[\/url\])"
strcontent = re.replace(strcontent, "<a href=""$2"" target=_blank>$3</a>")
re.pattern = "(\[email\])(.[^\[]*)(\[\/email\])"
strcontent = re.replace(strcontent, "<a href=""mailto:$2"">$2</a>")
re.pattern = "(\[email=(.[^\[]*)\])(.[^\[]*)(\[\/email\])"
strcontent = re.replace(strcontent, "<a href=""mailto:$2"" target=_blank>$3</a>")
re.pattern = "(\[html\])(.[^\[]*)(\[\/html\])"
strcontent = re.replace(strcontent, "<table width='100%' border='0' cellspacing='0' cellpadding='6' bgcolor='#f6f6f6'><td><b>以下内容为程序代码:</b><br>$2</td></table>")
re.pattern = "(\[code\])(.[^\[]*)(\[\/code\])"
strcontent = re.replace(strcontent, "<table width='100%' border='0' cellspacing='0' cellpadding='6' bgcolor='#f6f6f6'><td><b>以下内容为程序代码:</b><br>$2</td></table>")
re.pattern = "(\[color=(.[^\[]*)\])(.[^\[]*)(\[\/color\])"
strcontent = re.replace(strcontent, "<font color=$2>$3</font>")
re.pattern = "(\[face=(.[^\[]*)\])(.[^\[]*)(\[\/face\])"
strcontent = re.replace(strcontent, "<font face=$2>$3</font>")
re.pattern = "\[align=(center|left|right)\](.*)\[\/align\]"
strcontent = re.replace(strcontent, "<div align=$1>$2</div>")
re.pattern = "(\[quote\])(.*)(\[\/quote\])"
strcontent = re.replace(strcontent, "<table cellpadding=0 cellspacing=0 border=1 width=94% bordercolor=#000000 bgcolor=#f2f8ff align=center ><tr><td ><table width=100% cellpadding=5 cellspacing=1 border=0><tr><td bgcolor='#f6f6f6'>$2</table></table><br>")
re.pattern = "(\[move\])(.*)(\[\/move\])"
strcontent = re.replace(strcontent, "<marquee scrollamount=3>$2</marquee>")
re.pattern = "\[glow=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\](.[^\[]*)\[\/glow]"
strcontent = re.replace(strcontent, "<table width=$1 style=""filter:glow(color=$2, strength=$3)"">$4</table>")
re.pattern = "\[shadow=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\](.[^\[]*)\[\/shadow]"
strcontent = re.replace(strcontent, "<table width=$1 style=""filter:shadow(color=$2, strength=$3)"">$4</table>")
set re = nothing
strcontent = replace(strcontent, "[installdir_channeldir]", installdir & "/" & channeldir)
strcontent = replace(strcontent, "{", "{")
strcontent = replace(strcontent, "}", "}")
strcontent = replace(strcontent, "$", "$")
readcontent = strcontent
end function
end class
%>
const isdebug = 1
class newaspmain_cls
public membername, memberpass, membergrade, membergroup, memberid
public memberclass, menbernickname, cookies_name, checkpassword
public sitename, siteurl, mastermail, keywords, copyright
public installdir, indexname, istopsite, stopreadme, isclosemail
public sendmailtype, mailfrom, mailserver, mailusername, mailpassword, mailinformpass, chksamemail
public checkuserreg, admincheckreg, adduserpoint, sendregmessage, fullcontquery, actiontime
public isruntime, uploadclass, uploadfilesize, uploadfiletype, contentkeyword, previewsetting
public stopapplylink, fso_scriptname, inittitlecolor, stopbankpay
public chinaebank, versionid, badwords, badwordr, serialcode, passedcode
public channelname, channeldir, stopchannel, channeltype
public modules, channelskin, htmlpath, htmlform, htmlprefix
public iscreatehtml, htmlextname, stopupload, maxfilesize, upfiletype
public isauditing, appeargrade, modulename, binddomain, domainname
public postgrade, leaststring, maxstring, paginalnum, leasthothist, channel_setting
public channelsetting,channeldata,channelpath
public channelmodule,channelhtmlpath,channelhtmlform,channelusehtml,channelhtmlext,channelprefix
public thisedition, copyrightstr, version, values, startime
public sqlquerynum, getuserip, cachename, reloadtime
public scriptname, admin_page, skinid, skinpath, htmlcss, htmltop, htmlfoot, htmlcontent, shtmlcontent
private main_style, main_setting, mainstyle, html_setting
private localcachename, cache_data
private cachechannel, cachedata
private arrgroupsetting, blngroupsetting, binuserlong
private sub class_initialize()
on error resume next
reloadtime = 28800
sqlquerynum = 0
'--缓存名称
cachename = "newasp"
cookies_name = "newasp_net"
binuserlong = false
blngroupsetting = false
getuserip = request.servervariables("http_x_forwarded_for")
if len(getuserip) = 0 then getuserip = request.servervariables("remote_addr")
getuserip = checkstr(getuserip)
membername = checkstr(request.cookies(cookies_name)("username"))
memberpass = checkstr(request.cookies(cookies_name)("password"))
menbernickname = checkstr(request.cookies(cookies_name)("nickname"))
membergrade = chknumeric(request.cookies(cookies_name)("usergrade"))
membergroup = checkstr(request.cookies(cookies_name)("usergroup"))
memberclass = chknumeric(request.cookies(cookies_name)("userclass"))
memberid = chknumeric(request.cookies(cookies_name)("userid"))
checkpassword = checkstr(request.cookies(cookies_name)("checkpassword"))
dim tmpstr, i
tmpstr = request.servervariables("path_info")
tmpstr = split(tmpstr, "/")
i = ubound(tmpstr)
scriptname = lcase(tmpstr(i))
admin_page = false
if instr(scriptname, "showerr") > 0 or instr(scriptname, "login") > 0 or instr(scriptname, "admin_") > 0 then admin_page = true
end sub
private sub class_terminate()
if isobject(conn) then conn.close : set conn = nothing
end sub
'===================服务器缓存部分函数开始===================
public property let name(byval vnewvalue)
localcachename = lcase(vnewvalue)
cache_data = application(cachename & "_" & localcachename)
end property
public property let value(byval vnewvalue)
if localcachename <> "" then
redim cache_data(2)
cache_data(0) = vnewvalue
cache_data(1) = now()
application.lock
application(cachename & "_" & localcachename) = cache_data
application.unlock
else
err.raise vbobjecterror + 1, "newaspcacheserver", " please change the cachename."
end if
end property
public property get value()
if localcachename <> "" then
if isarray(cache_data) then
value = cache_data(0)
else
'err.raise vbobjecterror + 1, "newaspcacheserver", " the cache_data("&localcachename&") is empty."
end if
else
err.raise vbobjecterror + 1, "newaspcacheserver", " please change the cachename."
end if
end property
public function objisempty()
objisempty = true
if not isarray(cache_data) then exit function
if not isdate(cache_data(1)) then exit function
if datediff("s", cdate(cache_data(1)), now()) < (60 * reloadtime) then objisempty = false
end function
public sub delcahe(mycahename)
application.lock
application.contents.remove (cachename & "_" & mycahename)
application.unlock
end sub
public sub delcache(mycahename)
application.lock
application.contents.remove ("mynewasp_" & mycahename)
application.unlock
end sub
'===================服务器缓存部分函数结束===================
public function chkboolean(byval values)
if typename(values) = "boolean" or isnumeric(values) or lcase(values) = "false" or lcase(values) = "true" then
chkboolean = cbool(values)
else
chkboolean = false
end if
end function
public function checknumeric(byval check_id)
if check_id <> "" and isnumeric(check_id) then
check_id = ccur(check_id)
else
check_id = 0
end if
checknumeric = check_id
end function
public function chknumeric(byval check_id)
if check_id <> "" and isnumeric(check_id) then
check_id = clng(check_id)
if check_id < 0 then check_id = 0
else
check_id = 0
end if
chknumeric = check_id
end function
public function checkstr(byval str)
if isnull(str) then
checkstr = ""
exit function
end if
str = replace(str, chr(0), "")
checkstr = replace(str, "'", "''")
end function
'================================================
'过程名:checknull
'作 用:是否有效值
'================================================
public function checknull(byval svalue)
on error resume next
if isnull(svalue) then
checknull = false
exit function
end if
if trim(svalue) <> "" and lcase(trim(svalue)) <> "http://" then
checknull = true
else
checknull = false
end if
end function
public function chknull(byval str)
on error resume next
if isnull(str) then
chknull = ""
exit function
end if
if trim(str) <> "" and lcase(trim(str)) <> "http://" then
chknull = trim(str)
else
chknull = ""
end if
end function
'=============================================================
'函数名:chkformstr
'作 用:过滤表单字符
'参 数:str ----原字符串
'返回值:过滤后的字符串
'=============================================================
public function chkformstr(byval str)
dim fstring
fstring = str
if isnull(fstring) then
chkformstr = ""
exit function
end if
fstring = replace(fstring, "'", "'")
fstring = replace(fstring, chr(34), """)
fstring = replace(fstring, chr(13), "")
fstring = replace(fstring, chr(10), "")
fstring = replace(fstring, chr(9), "")
fstring = replace(fstring, ">", ">")
fstring = replace(fstring, "<", "<")
fstring = replace(fstring, "%", "%")
chkformstr = trim(japencode(fstring))
end function
'=============================================================
'函数作用:过滤sql非法字符
'=============================================================
public function checkrequest(byval str,byval strlen)
on error resume next
str = trim(str)
str = replace(str, chr(0), "")
str = replace(str, "'", "")
str = replace(str, "%", "")
str = replace(str, "^", "")
str = replace(str, ";", "")
str = replace(str, "*", "")
str = replace(str, "<", "")
str = replace(str, ">", "")
str = replace(str, "|", "")
str = replace(str, "and", "")
str = replace(str, "chr", "")
if len(str) > 0 and strlen > 0 then
str = left(str, strlen)
end if
checkrequest = str
end function
'-- 移除有害字符
public function removebadcharacters(byval strtemp)
dim re
on error resume next
set re = new regexp
re.pattern = "[^\s\w]"
re.global = true
removebadcharacters = re.replace(strtemp, "")
set re = nothing
end function
'-- 去掉html标记
public function removehtml(byval textstr)
dim str,re
str = textstr
on error resume next
set re = new regexp
re.ignorecase = true
re.global = true
re.pattern = "<(.[^>]*)>"
str = re.replace(str, "")
set re = nothing
removehtml=str
end function
'-- 数据库连接
public function execute(command)
if not isobject(conn) then connectiondatabase
if isdebug = 0 then
on error resume next
set execute = conn.execute(command)
if err then
err.clear
set conn = nothing
response.write "查询数据的时候发现错误,请检查您的查询代码是否正确。<br /><li>"
response.write command
response.end
end if
else
set execute = conn.execute(command)
end if
sqlquerynum = sqlquerynum+1
end function
public sub readconfig()
on error resume next
name = "config"
if objisempty() then reloadconfig
cachedata = value
'第一次起用系统或者重启iis的时候加载缓存
name = "date"
if objisempty() then
value = date
else
if cstr(value) <> cstr(date) then
name = "config"
call reloadconfig
cachedata = value
end if
end if
sitename = cachedata(1, 0): siteurl = cachedata(2, 0): mastermail = cachedata(3, 0): keywords = cachedata(4, 0): copyright = cachedata(5, 0): installdir = cachedata(6, 0)
indexname = cachedata(7, 0): istopsite = cachedata(8, 0): stopreadme = cachedata(9, 0): isclosemail = cachedata(10, 0): sendmailtype = cachedata(11, 0): mailfrom = cachedata(12, 0)
mailserver = cachedata(13, 0): mailusername = cachedata(14, 0): mailpassword = cachedata(15, 0): checkuserreg = cachedata(16, 0): admincheckreg = cachedata(17, 0): mailinformpass = cachedata(18, 0)
chksamemail = cachedata(19, 0): adduserpoint = cachedata(20, 0): sendregmessage = cachedata(21, 0): fullcontquery = cachedata(22, 0): actiontime = cachedata(23, 0): isruntime = cachedata(24, 0)
uploadclass = cachedata(25, 0): uploadfilesize = cachedata(26, 0): uploadfiletype = cachedata(27, 0): contentkeyword = cachedata(28, 0): stopapplylink = cachedata(29, 0): fso_scriptname = cachedata(30, 0)
inittitlecolor = cachedata(31, 0): stopbankpay = cachedata(32, 0): chinaebank = cachedata(33, 0): versionid = cachedata(34, 0): badwords = cachedata(35, 0): badwordr = cachedata(36, 0)
serialcode = cachedata(37, 0): passedcode = cachedata(38, 0) : previewsetting = cachedata(39, 0)
thisedition = "免费版 (free edition)"
version = "powered by:<a href=""http://www.newasp.net"" target=""_blank"" class=""navmenu"">newcloud sitemanagesystem version 2.0.0 sp1</a>"
copyrightstr = "<!--" & vbcrlf
copyrightstr = copyrightstr & "┌─────────────────newasp──┐" & vbcrlf
copyrightstr = copyrightstr & "│newcloud sitemanagesystem version 2.0.0 sp1 │" & vbcrlf
copyrightstr = copyrightstr & "│版权所有: 新云网络 (newasp.net) │" & vbcrlf
copyrightstr = copyrightstr & "│官方主页: http://www.newasp.net │" & vbcrlf
copyrightstr = copyrightstr & "│论坛地址: http://bbs.newasp.net │" & vbcrlf
copyrightstr = copyrightstr & "│e-mail: webenvoy@163.com qq: 94022511 │" & vbcrlf
copyrightstr = copyrightstr & "└────────────────────.net┘" & vbcrlf
copyrightstr = copyrightstr & "-->" & vbcrlf
if cint(istopsite) = 1 and not admin_page then response.redirect ("" & siteurl & installdir & "showerr.asp?action=stop")
end sub
public sub reloadconfig()
dim sql, rs
on error resume next
sql = "select * from [nc_config] "
set rs = execute(sql)
value = rs.getrows(1)
set rs = nothing
end sub
'=============================================================
'过程名:reloadchannel
'作 用:再装频道设置
'参 数:channelid ----频道id
'=============================================================
private sub reloadchannel(channelid)
dim sql, rs
on error resume next
sql = "select channelid,channelname,channeldir,stopchannel,channeltype,modules,modulename,binddomain,domainname,channelskin,htmlpath,htmlform,iscreatehtml,htmlextname,htmlprefix,stopupload,maxfilesize,upfiletype,isauditing,appeargrade,postgrade,leaststring,maxstring,paginalnum,leasthothist,channel_setting from nc_channel where channeltype <= 1 and channelid = " & clng(channelid)
set rs = execute(sql)
if rs.bof and rs.eof then
response.write "错误的频道参数!"
exit sub
end if
value = rs.getrows(1)
set rs = nothing
end sub
'=============================================================
'过程名:readchannel
'作 用:读取频道设置
'参 数:channelid ----频道id
'=============================================================
public sub readchannel(channelid)
on error resume next
if not isnumeric(channelid) then channelid = 1
channelid = clng(channelid)
name = "channel" & channelid
if objisempty() then call reloadchannel(channelid)
cachechannel = value
if clng(cachechannel(0, 0)) <> channelid then
call reloadchannel(channelid)
cachechannel = value
end if
channelname = cachechannel(1, 0): channeldir = cachechannel(2, 0): stopchannel = cachechannel(3, 0): channeltype = cachechannel(4, 0): modules = cachechannel(5, 0): modulename = cachechannel(6, 0): binddomain = cachechannel(7, 0): domainname = cachechannel(8, 0): channelskin = cachechannel(9, 0): htmlpath = cachechannel(10, 0)
htmlform = cachechannel(11, 0): iscreatehtml = cachechannel(12, 0): htmlextname = cachechannel(13, 0): htmlprefix = cachechannel(14, 0): stopupload = cachechannel(15, 0): maxfilesize = cachechannel(16, 0): upfiletype = cachechannel(17, 0): isauditing = cachechannel(18, 0): appeargrade = cachechannel(19, 0)
postgrade = cachechannel(20, 0): leaststring = cachechannel(21, 0): maxstring = cachechannel(22, 0): paginalnum = cachechannel(23, 0): leasthothist = cachechannel(24, 0): channel_setting = cachechannel(25, 0)
if cint(stopchannel) = 1 and not admin_page then response.redirect (installdir & "showerr.asp?action=chanstop")
end sub
public sub loadchannel(chanid)
on error resume next
dim rs,sql,tmpdata
chanid = clng(chanid)
name = "mychannel" & chanid
if objisempty() then
sql = "select channelname,channeldir,modulename,htmlpath,htmlform,iscreatehtml,htmlextname,htmlprefix,stopupload,leaststring,maxstring,leasthothist from nc_channel where channeltype<=1 and channelid= " & clng(chanid)
set rs = execute(sql)
tmpdata = rs.getstring(, , "|||", "@@@", "")
tmpdata = left(tmpdata, len(tmpdata) - 3)
set rs = nothing
value = tmpdata
end if
channeldata = split(value, "|||")
channelpath = installdir & channeldata(1)
channelmodule = channeldata(2)
channelhtmlpath = channeldata(3)
channelhtmlform = channeldata(4)
channelusehtml = channeldata(5)
channelhtmlext = channeldata(6)
channelprefix = channeldata(7)
end sub
'=============================================================
'过程名:loadtemplates
'作 用:载入模板
'参 数:page_mark ----styleid
'=============================================================
public sub loadtemplates(channelid, pageid, styleid)
dim rstmp, tempskinid
on error resume next
channelid = clng(channelid)
pageid = cint(pageid)
name = "defaultskinid"
if objisempty() then
set rstmp = execute("select skinid from [nc_template] where pageid = 0 and isdefault = 1")
value = rstmp(0)
set rstmp = nothing
end if
tempskinid = value
if styleid = 0 or styleid = "" then
skinid = tempskinid
else
set rstmp = execute("select skinid from [nc_template] where pageid = 0 and skinid = " & styleid)
if not rstmp.eof then
skinid = rstmp(0)
else
skinid = tempskinid
end if
set rstmp = nothing
end if
skinid = clng(skinid)
name = "mainstyle" & skinid
if objisempty() then templatesmaincache (skinid)
main_style = value
skinpath = main_style(0, 0)
main_setting = split(main_style(2, 0), "|||")
mainstyle = main_style(1, 0)
'mainstyle = replace(mainstyle, "{$installdir}", readinstalldir(binddomain))
mainstyle = replace(mainstyle, "{$skinpath}", skinpath)
mainstyle = split(mainstyle, "|||")
htmlcss = mainstyle(0)
htmltop = mainstyle(1)
htmlfoot = mainstyle(2)
if pageid <> 0 then
name = "templates" & channelid & skinid & pageid
if objisempty() then
templatestocache channelid, pageid
end if
byvalue = value
end if
end sub
private sub templatestocache(channelid, pageid)
on error resume next
dim rs, sql, rstmp
sql = "select skinid,page_content,page_setting from [nc_template] where channelid = " & channelid & " and skinid = " & skinid & " and pageid = " & pageid
set rs = execute(sql)
if not rs.eof then
value = rs.getrows(1)
else
set rstmp = execute("select skinid,page_content,page_setting from [nc_template] where channelid = " & channelid & " and isdefault = 1 and pageid = " & pageid)
value = rstmp.getrows(1)
set rstmp = nothing
end if
set rs = nothing
end sub
private sub templatesmaincache(skinid)
on error resume next
dim rs, sql, rstmp
sql = "select templatedir,page_content,page_setting from [nc_template] where pageid = 0 and skinid = " & skinid & " and channelid = 0"
set rs = execute(sql)
if not rs.eof then
value = rs.getrows(1)
else
set rstmp = execute("select templatedir,page_content,page_setting from [nc_template] where pageid = 0 and isdefault = 1 and channelid = 0")
value = rstmp.getrows(1)
set rstmp = nothing
end if
set rs = nothing
end sub
public property let byvalue(byval vnewvalue)
dim tmpstr
tmpstr = vnewvalue
html_setting = tmpstr(2, 0)
html_setting = split(html_setting, "|||")
htmlcontent = tmpstr(1, 0)
if cint(html_setting(0)) <> 0 then
htmlcontent = htmltop & htmlcontent & htmlfoot
end if
htmlcontent = replace(htmlcontent, "{$style_css}", htmlcss)
htmlcontent = replace(htmlcontent, "{$skinpath}", skinpath)
htmlcontent = replace(htmlcontent, "{$width}", main_setting(0))
htmlcontent = replace(htmlcontent, "{$channelmenu}", channelmenu)
htmlcontent = replace(htmlcontent, "{$websitename}", sitename)
htmlcontent = replace(htmlcontent, "{$websiteurl}", siteurl)
htmlcontent = replace(htmlcontent, "{$mastermail}", mastermail)
htmlcontent = replace(htmlcontent, "{$keyword}", keywords)
htmlcontent = replace(htmlcontent, "{$copyright}", copyright)
htmlcontent = replace(htmlcontent, "{$indexname}", indexname)
htmlcontent = replace(htmlcontent, "{$version}", "")
htmlcontent = htmlcontent
end property
public property get byvalue()
byvalue = htmlcontent
end property
public property let htmlvalue(byval vnewvalue)
dim tempstr
tempstr = vnewvalue
tempstr = replace(tempstr, "{$style_css}", htmlcss)
tempstr = replace(tempstr, "{$skinpath}", skinpath)
tempstr = replace(tempstr, "{$width}", main_setting(0))
tempstr = replace(tempstr, "{$channelmenu}", channelmenu)
tempstr = replace(tempstr, "{$websitename}", sitename)
tempstr = replace(tempstr, "{$websiteurl}", siteurl)
tempstr = replace(tempstr, "{$mastermail}", mastermail)
tempstr = replace(tempstr, "{$keyword}", keywords)
tempstr = replace(tempstr, "{$copyright}", copyright)
tempstr = replace(tempstr, "{$indexname}", indexname)
tempstr = replace(tempstr, "{$version}", "")
shtmlcontent = tempstr
end property
public property get htmlvalue()
htmlvalue = shtmlcontent
end property
public property get htmlsetting(n)
htmlsetting = html_setting(n)
end property
public property get mainsetting(n)
mainsetting = main_setting(n)
end property
'================================================
'过程名:getsiteurl
'作 用:取得带端口的url
'================================================
public property get getsiteurl()
if request.servervariables("server_port") = "80" then
getsiteurl = "http://" & request.servervariables("server_name")
else
getsiteurl = "http://" & request.servervariables("server_name") & ":" & request.servervariables("server_port")
end if
end property
'================================================
'函数名:formencode
'作 用:过虑提交的表单数据
'参 数:str ----原字符串 n ----字符长度
'================================================
public function formencode(byval str, byval n)
if not isnull(str) and trim(str) <> "" then
str = left(str, n)
str = replace(str, ">", ">")
str = replace(str, "<", "<")
str = replace(str, ">", ">")
str = replace(str, "<", "<")
str = replace(str, "'", "'")
str = replace(str, chr(34), """)
str = replace(str, "%", "%")
str = replace(str, vbnewline, "")
formencode = trim(str)
else
formencode = ""
end if
end function
'================================================
'函数名:chkkeyword
'作 用:过滤关键字
'参 数:keyword ----关键字
'================================================
public function chkkeyword(byval keyword)
dim fobwords, i
on error resume next
fobwords = array(91, 92, 304, 305, 430, 431, 437, 438, 12460, 12461, 12462, 12463, 12464, 12465, 12466, 12467, 12468, 12469, 12470, 12471, 12472, 12473, 12474, 12475, 12476, 12477, 12478, 12479, 12480, 12481, 12482, 12483, 12485, 12486, 12487, 12488, 12489, 12490, 12496, 12497, 12498, 12499, 12500, 12501, 12502, 12503, 12504, 12505, 12506, 12507, 12508, 12509, 12510, 12521, 12532, 12533, 65339, 65340)
for i = 1 to ubound(fobwords, 1)
if instr(keyword, chrw(fobwords(i))) > 0 then
keyword = replace(keyword, chrw(fobwords(i)), "")
end if
next
keyword = left(keyword, 100)
fobwords = array("~", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "+", "=", "`", "[", "]", "{", "}", ";", ":", """", "'", ",", "<", ">", ".", "/", "\", "?", "_")
for i = 0 to ubound(fobwords, 1)
if instr(keyword, fobwords(i)) > 0 then
keyword = replace(keyword, fobwords(i), "")
end if
next
chkkeyword = keyword
end function
'================================================
'函数名:japencode
'作 用:日文片假名编码
'参 数:str ----原字符
'================================================
public function japencode(byval str)
dim fobwords, i
on error resume next
if isnull(str) or trim(str) = "" then
japencode = ""
exit function
end if
fobwords = array(92, 304, 305, 430, 431, 437, 438, 12460, 12461, 12462, 12463, 12464, 12465, 12466, 12467, 12468, 12469, 12470, 12471, 12472, 12473, 12474, 12475, 12476, 12477, 12478, 12479, 12480, 12481, 12482, 12483, 12485, 12486, 12487, 12488, 12489, 12490, 12496, 12497, 12498, 12499, 12500, 12501, 12502, 12503, 12504, 12505, 12506, 12507, 12508, 12509, 12510, 12521, 12532, 12533, 65340)
for i = 1 to ubound(fobwords, 1)
if instr(str, chrw(fobwords(i))) > 0 then
str = replace(str, chrw(fobwords(i)), "" & fobwords(i) & ";")
end if
next
japencode = str
end function
'================================================
'函数名:japuncode
'作 用:日文片假名解码
'参 数:str ----原字符
'================================================
public function japuncode(byval str)
dim fobwords, i
on error resume next
if isnull(str) or trim(str) = "" then
japuncode = ""
exit function
end if
fobwords = array(92, 304, 305, 430, 431, 437, 438, 12460, 12461, 12462, 12463, 12464, 12465, 12466, 12467, 12468, 12469, 12470, 12471, 12472, 12473, 12474, 12475, 12476, 12477, 12478, 12479, 12480, 12481, 12482, 12483, 12485, 12486, 12487, 12488, 12489, 12490, 12496, 12497, 12498, 12499, 12500, 12501, 12502, 12503, 12504, 12505, 12506, 12507, 12508, 12509, 12510, 12521, 12532, 12533, 65340)
for i = 1 to ubound(fobwords, 1)
if instr(str, "" & fobwords(i) & ";") > 0 then
str = replace(str, "" & fobwords(i) & ";", chrw(fobwords(i)))
end if
next
str = replace(str, chr(0), "")
str = replace(str, "'", "''")
japuncode = str
end function
'=============================================================
'函数作用:带脏话过滤
'=============================================================
public function chkbadwords(byval str)
if isnull(str) then exit function
dim i, bwords, bwordr
bwords = split(badwords, "|")
bwordr = split(badwordr, "|")
for i = 0 to ubound(bwords)
if i > ubound(bwordr) then
str = replace(str, bwords(i), "*")
else
str = replace(str, bwords(i), bwordr(i))
end if
next
chkbadwords = str
end function
'=============================================================
'函数作用:过滤html代码,带脏话过滤
'=============================================================
public function htmlencode(byval fstring)
if not isnull(fstring) then
fstring = replace(fstring, ">", ">")
fstring = replace(fstring, "<", "<")
fstring = replace(fstring, chr(32), " ")
fstring = replace(fstring, chr(9), " ")
fstring = replace(fstring, chr(34), """)
fstring = replace(fstring, chr(39), "'")
fstring = replace(fstring, chr(13), "")
fstring = replace(fstring, " ", " ")
fstring = replace(fstring, chr(10), "<br /> ")
fstring = chkbadwords(fstring)
htmlencode = fstring
end if
end function
'=============================================================
'函数作用:过滤html代码,不带脏话过滤
'=============================================================
public function htmlencodes(byval fstring)
if not isnull(fstring) then
fstring = replace(fstring, "'", "'")
fstring = replace(fstring, ">", ">")
fstring = replace(fstring, "<", "<")
fstring = replace(fstring, chr(32), " ")
fstring = replace(fstring, chr(9), " ")
fstring = replace(fstring, chr(34), """)
fstring = replace(fstring, chr(39), "'")
fstring = replace(fstring, chr(13), "")
fstring = replace(fstring, chr(10), "<br /> ")
fstring = replace(fstring, " ", " ")
htmlencodes = fstring
end if
end function
'=============================================================
'函数作用:判断发言是否来自外部
'=============================================================
public function checkpost()
on error resume next
dim server_v1, server_v2
checkpost = false
server_v1 = cstr(request.servervariables("http_referer"))
server_v2 = cstr(request.servervariables("server_name"))
if mid(server_v1, 8, len(server_v2)) = server_v2 then
checkpost = true
end if
end function
'=============================================================
'函数作用:判断来源url是否来自外部
'=============================================================
public function checkouterurl()
on error resume next
dim server_v1, server_v2
server_v1 = replace(lcase(trim(request.servervariables("http_referer"))), "http://", "")
server_v2 = lcase(trim(request.servervariables("server_name")))
if server_v1 <> "" and left(server_v1, len(server_v2)) <> server_v2 then
checkouterurl = false
else
checkouterurl = true
end if
end function
'================================================
'函数名:gottopic
'作 用:显示字符串长度
'参 数:str ----原字符串
' strlen ----显示字符长度
'================================================
public function gottopic(byval str, byval strlen)
dim l, t, c, i
dim strtemp
on error resume next
str = trim(str)
str = replace(str, " ", " ")
str = replace(str, ">", ">")
str = replace(str, "<", "<")
str = replace(str, ">", ">")
str = replace(str, "<", "<")
str = replace(str, "'", "'")
str = replace(str, """, chr(34))
str = replace(str, vbnewline, "")
l = len(str)
t = 0
for i = 1 to l
c = abs(asc(mid(str, i, 1)))
if c > 255 then
t = t + 2
else
t = t + 1
end if
if t >= strlen then
strtemp = left(str, i) & "..."
exit for
else
strtemp = str & " "
end if
next
gottopic = checktopic(strtemp)
end function
public function checktopic(byval strcontent)
dim re
on error resume next
set re = new regexp
re.ignorecase = true
re.global = true
re.pattern = "(<s+cript(.+?)<\/s+cript>)"
strcontent = re.replace(strcontent, "")
re.pattern = "(<iframe(.+?)<\/iframe>)"
strcontent = re.replace(strcontent, "")
re.pattern = "(>)"
strcontent = re.replace(strcontent, ">")
re.pattern = "(<)"
strcontent = re.replace(strcontent, "<")
set re = nothing
strcontent = replace(strcontent, ">", ">")
strcontent = replace(strcontent, "<", "<")
strcontent = replace(strcontent, "'", "'")
strcontent = replace(strcontent, chr(34), """)
strcontent = replace(strcontent, "%", "%")
strcontent = replace(strcontent, vbnewline, "")
checktopic = trim(strcontent)
end function
'================================================
'函数名:readtopic
'作 用:显示字符串长度
'参 数:str ----原字符串
' strlen ----显示字符长度
'================================================
public function readtopic(byval str, byval strlen)
dim l, t, c, i
on error resume next
str = replace(str, " ", " ")
if len(str) < strlen then
str = str & string(strlen - len(str), ".")
else
str = str
end if
l = len(str)
t = 0
for i = 1 to l
c = abs(asc(mid(str, i, 1)))
if c > 255 then
t = t + 2
else
t = t + 1
end if
if t >= strlen then
readtopic = left(str, i) & "..."
exit for
else
readtopic = str & "..."
end if
next
end function
'================================================
'函数名:strlength
'作 用:计字符串长度
'参 数:str ----字符串
'================================================
public function strlength(byval str)
on error resume next
if isnull(str) or str = "" then
strlength = 0
exit function
end if
dim winnt_chinese
winnt_chinese = (len("例子") = 2)
if winnt_chinese then
dim l, t
dim i, c
l = len(str)
t = l
for i = 1 to l
c = asc(mid(str, i, 1))
if c < 0 then c = c + 65536
if c > 255 then t = t + 1
next
strlength = t
else
strlength = len(str)
end if
end function
'=================================================
'函数名:isinteger
'作 用:判断数字是否整型
'参 数:para ----参数
'=================================================
public function isinteger(byval para)
on error resume next
dim str
dim l, i
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
public function cutstring(byval str, byval strlen)
on error resume next
dim htmlstr, l, re, strcontent
htmlstr = str
htmlstr = replace(htmlstr, " ", " ")
htmlstr = replace(htmlstr, """, chr(34))
htmlstr = replace(htmlstr, "'", chr(39))
htmlstr = replace(htmlstr, "{", chr(123))
htmlstr = replace(htmlstr, "}", chr(125))
htmlstr = replace(htmlstr, "$", chr(36))
htmlstr = replace(htmlstr, vbcrlf, "")
htmlstr = replace(htmlstr, "====", "")
htmlstr = replace(htmlstr, "----", "")
htmlstr = replace(htmlstr, "////", "")
htmlstr = replace(htmlstr, "\\\\", "")
htmlstr = replace(htmlstr, "####", "")
htmlstr = replace(htmlstr, "@@@@", "")
htmlstr = replace(htmlstr, "****", "")
htmlstr = replace(htmlstr, "~~~~", "")
set re = new regexp
re.ignorecase = true
re.global = true
re.pattern = "\[br\]"
htmlstr = re.replace(htmlstr, "")
re.pattern = "\[align=right\](.*)\[\/align\]"
htmlstr = re.replace(htmlstr, "")
re.pattern = "<(.[^>]*)>"
htmlstr = re.replace(htmlstr, "")
set re = nothing
htmlstr = replace(htmlstr, ">", ">")
htmlstr = replace(htmlstr, "<", "<")
l = len(htmlstr)
if l >= strlen then
strcontent = left(htmlstr, strlen) & "..."
else
strcontent = htmlstr & " "
end if
strcontent = replace(strcontent, chr(34), """)
strcontent = replace(strcontent, chr(39), "'")
strcontent = replace(strcontent, chr(36), "$")
strcontent = replace(strcontent, chr(123), "{")
strcontent = replace(strcontent, chr(125), "}")
strcontent = replace(strcontent, ">", ">")
strcontent = replace(strcontent, "<", "<")
cutstring = strcontent
end function
'================================================
'函数名:checkinfuse
'作 用:防止sql注入
'参 数:str ----原字符串
' strlen ----提交字符串长度
'================================================
public function checkinfuse(byval str, byval strlen)
dim strunsafe, arrunsafe
dim i
if trim(str) = "" then
checkinfuse = ""
exit function
end if
str = left(str, strlen)
on error resume next
strunsafe = "'|^|;|and|exec|insert|select|delete|update|count|*|%|chr|mid|master|truncate|char|declare"
if trim(str) <> "" then
if len(str) > strlen then
response.write "<script language=javascript>alert('安全系统提示↓\n\n您提交的字符数超过了限制!');history.back(-1)</script>"
checkinfuse = ""
response.end
end if
arrunsafe = split(strunsafe, "|")
for i = 0 to ubound(arrunsafe)
if instr(1, str, arrunsafe(i), 1) > 0 then
response.write "<script language=javascript>alert('安全系统提示↓\n\n请不要在参数中包含非法字符!');history.back(-1)</script>"
checkinfuse = ""
response.end
end if
next
end if
checkinfuse = trim(str)
exit function
if err.number <> 0 then
err.clear
response.write "<script language=javascript>alert('安全系统提示↓\n\n请不要在参数中包含非法字符!');history.back(-1)</script>"
checkinfuse = ""
response.end
end if
end function
public sub preventinfuse()
on error resume next
dim sql_nonlicet, arrnonlicet
dim postrefer, getrefer, sql_data
sql_nonlicet = "'|;|^|and|exec|insert|select|delete|update|count|*|%|chr|mid|master|truncate|char|declare"
arrnonlicet = split(sql_nonlicet, "|")
if request.form <> "" then
for each postrefer in request.form
for sql_data = 0 to ubound(arrnonlicet)
if instr(1, request.form(postrefer), arrnonlicet(sql_data), 1) > 0 then
response.write "<script language=javascript>alert('安全系统提示↓\n\n请不要在参数中包含非法字符!');history.back(-1)</script>"
response.end
end if
next
next
end if
if request.querystring <> "" then
for each getrefer in request.querystring
for sql_data = 0 to ubound(arrnonlicet)
if instr(1, request.querystring(getrefer), arrnonlicet(sql_data), 1) > 0 then
response.write "<script language=javascript>alert('安全系统提示↓\n\n请不要在参数中包含非法字符!');history.back(-1)</script>"
response.end
end if
next
next
end if
end sub
'================================================
'函数名:chkquerystr
'作 用:过虑查询的非法字符
'参 数:str ----原字符串
'返回值:过滤后的字符
'================================================
public function chkquerystr(byval str)
on error resume next
if isnull(str) then
chkquerystr = ""
exit function
end if
str = replace(str, "!", "")
str = replace(str, "]", "")
str = replace(str, "[", "")
str = replace(str, ")", "")
str = replace(str, "(", "")
str = replace(str, "|", "")
str = replace(str, "+", "")
str = replace(str, "=", "")
str = replace(str, "'", "''")
str = replace(str, "%", "")
str = replace(str, "&", "")
str = replace(str, "#", "")
str = replace(str, "^", "")
str = replace(str, " ", " ")
str = replace(str, chr(37), "")
str = replace(str, chr(0), "")
chkquerystr = str
end function
'================================================
'过程名:checkquery
'作 用:限制搜索的关键字
'参 数:str ----搜索的字符串
'返回值:true; false
'================================================
public function checkquery(byval str)
dim fobwords, i, keyword
keyword = str
on error resume next
fobwords = array(91, 92, 304, 305, 430, 431, 437, 438, 12460, 12461, 12462, 12463, 12464, 12465, 12466, 12467, 12468, 12469, 12470, 12471, 12472, 12473, 12474, 12475, 12476, 12477, 12478, 12479, 12480, 12481, 12482, 12483, 12485, 12486, 12487, 12488, 12489, 12490, 12496, 12497, 12498, 12499, 12500, 12501, 12502, 12503, 12504, 12505, 12506, 12507, 12508, 12509, 12510, 12532, 12533, 65339, 65340)
for i = 1 to ubound(fobwords, 1)
if instr(keyword, chrw(fobwords(i))) > 0 then
checkquery = false
exit function
end if
next
fobwords = array("~", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "+", "=", "`", "[", "]", "{", "}", ";", ":", """", "'", "<", ">", ".", "/", "\", "|", "?", "about", "after", "all", "also", "an", "and", "another", "any", "are", "as", "at", "be", "because", "been", "before", "being", "between", "both", "but", "by", "came", "can", "come", "could", "did", "do", "each", "for", "from", "get", "got", "had", "has", "have", "he", "her", "here", "him", "himself", "his", "how", "if", "in", "into", "is", "it", "like", "make", "many", "me", "might", "more", "most", "much", "must", "my", "never", "now", "of", "on", "only", "or", "other", "our", "out", "over", "said", "same", "see", "should", "since", "some", "still", "such", "take", "than", "that", "the", "their", "them", "then", "there", "these", "they", "this")
keyword = left(keyword, 100)
keyword = replace(keyword, "!", " ")
keyword = replace(keyword, "]", " ")
keyword = replace(keyword, "[", " ")
keyword = replace(keyword, ")", " ")
keyword = replace(keyword, "(", " ")
keyword = replace(keyword, " ", " ")
keyword = replace(keyword, "-", " ")
keyword = replace(keyword, "/", " ")
keyword = replace(keyword, "+", " ")
keyword = replace(keyword, "=", " ")
keyword = replace(keyword, ",", " ")
keyword = replace(keyword, "'", " ")
for i = 0 to ubound(fobwords, 1)
if keyword = fobwords(i) then
checkquery = false
exit function
end if
next
checkquery = true
end function
'================================================
'函数名:isvalidstr
'作 用:判断字符串中是否含有非法字符
'参 数:str ----原字符串
'返回值:false,true -----布尔值
'================================================
public function isvalidstr(byval str)
isvalidstr = false
on error resume next
if isnull(str) then exit function
if trim(str) = empty then exit function
dim forbidstr, i
forbidstr = "and|chr|:|=|%|&|$|#|@|+|-|*|/|\|<|>|;|,|^|" & chr(32) & "|" & chr(34) & "|" & chr(39) & "|" & chr(9)
forbidstr = split(forbidstr, "|")
for i = 0 to ubound(forbidstr)
if instr(1,str, forbidstr(i),1) > 0 then
isvalidstr = false
exit function
end if
next
isvalidstr = true
end function
'================================================
'函数名:isvalidpassword
'作 用:判断密码中是否含有非法字符
'参 数:str ----原字符串
'返回值:false,true -----布尔值
'================================================
public function isvalidpassword(byval str)
isvalidpassword = false
on error resume next
if isnull(str) then exit function
if trim(str) = empty then exit function
dim forbidstr, i
forbidstr = "=and|chr|*|^|%|&|;|,|" & chr(32) & "|" & chr(34) & "|" & chr(39) & "|" & chr(9)
forbidstr = split(forbidstr, "|")
for i = 0 to ubound(forbidstr)
if instr(1, str, forbidstr(i), 1) > 0 then
isvalidpassword = false
exit function
end if
next
isvalidpassword = true
end function
'================================================
'函数名:isvalidchar
'作 用:判断字符串中是否含有非法字符和中文
'参 数:str ----原字符串
'返回值:false,true -----布尔值
'================================================
public function isvalidchar(byval str)
isvalidchar = false
on error resume next
if isnull(str) then exit function
if trim(str) = empty then exit function
dim validstr
dim i, l, s, c
validstr = "abcdefghijklmnopqrstuvwxyz.-_:~\/0123456789"
l = len(str)
s = ucase(str)
for i = 1 to l
c = mid(s, i, 1)
if instr(validstr, c) = 0 then
isvalidchar = false
exit function
end if
next
isvalidchar = true
end function
'================================================
'函数名:formatdate
'作 用:格式化日期
'参 数:dateandtime ----原日期和时间
' para ----日期格式
'返回值:格式化后的日期
'================================================
public function formatdate(dateandtime, para)
on error resume next
dim y, m, d, h, mi, s, strdatetime
formatdate = dateandtime
if not isnumeric(para) then exit function
if not isdate(dateandtime) then exit function
y = cstr(year(dateandtime))
m = cstr(month(dateandtime))
if len(m) = 1 then m = "0" & m
d = cstr(day(dateandtime))
if len(d) = 1 then d = "0" & d
h = cstr(hour(dateandtime))
if len(h) = 1 then h = "0" & h
mi = cstr(minute(dateandtime))
if len(mi) = 1 then mi = "0" & mi
s = cstr(second(dateandtime))
if len(s) = 1 then s = "0" & s
select case para
case "1"
strdatetime = y & "-" & m & "-" & d & " " & h & ":" & mi & ":" & s
case "2"
strdatetime = y & "-" & m & "-" & d
case "3"
strdatetime = y & "/" & m & "/" & d
case "4"
strdatetime = y & "年" & m & "月" & d & "日"
case "5"
strdatetime = m & "-" & d
case "6"
strdatetime = m & "/" & d
case "7"
strdatetime = m & "月" & d & "日"
case "8"
strdatetime = y & "年" & m & "月"
case "9"
strdatetime = y & "-" & m
case "10"
strdatetime = y & "/" & m
case else
strdatetime = dateandtime
end select
formatdate = strdatetime
end function
'================================================
'函数名:readfontmode
'作 用:读取字体模式
'参 数:str ----原字符串
' vcolor -----颜色的值
' vfont -----字体的值
'返回值:新字符串
'================================================
public function readfontmode(str, vcolor, vfont)
dim fontstr, tcolor
dim colorstr, arrcolor
if isnull(str) then
readfontmode = ""
exit function
end if
readfontmode = str
on error resume next
if not isnumeric(vcolor) then exit function
if not isnumeric(vfont) then exit function
select case cint(vfont)
case 1
fontstr = "<b>" & str & "</b>"
case 2
fontstr = "<em>" & str & "</em>"
case 3
fontstr = "<u>" & str & "</u>"
case 4
fontstr = "<b><em>" & str & "</em></b>"
case 5
fontstr = "<b><u>" & str & "</u></b>"
case 6
fontstr = "<em><u>" & str & "</u></em>"
case 7
fontstr = "<b><em><u>" & str & "</u></em></b>"
case else
fontstr = str
end select
readfontmode = fontstr
if vcolor = "" or vcolor = 0 then exit function
colorstr = "," & inittitlecolor
arrcolor = split(colorstr, ",")
if vcolor > ubound(arrcolor) then exit function
tcolor = trim(arrcolor(vcolor))
readfontmode = "<font color=" & tcolor & ">" & fontstr & "</font>"
end function
'=============================================================
'函数名:showdatetime
'作 用:读取日期格式
'参 数:dateandtime ---- 当前时间
' para ---- 时间格式
'=============================================================
public function showdatetime(dateandtime, para)
showdatetime = ""
dim strdate
if not isdate(dateandtime) then exit function
if dateandtime >= date then
strdate = "<font color='" & main_setting(1) & "'>"
strdate = strdate & formatdate(dateandtime, para)
strdate = strdate & "</font>"
else
strdate = "<font color='" & main_setting(2) & "'>"
strdate = strdate & formatdate(dateandtime, para)
strdate = strdate & "</font>"
end if
showdatetime = strdate
end function
public function showdatepath(strval, n)
showdatepath = ""
if trim(strval) = "" then exit function
dim strtemppath, strtime
dim y, m, d
strtime = left(strval, 8)
y = left(strtime, 4)
m = mid(strtime, 5, 2)
d = right(strtime, 2)
select case cint(n)
case 1
strtemppath = y & "/" & m & "/" & d & "/"
case 2
strtemppath = y & "/" & m & "/"
case 3
strtemppath = y & m & "/"
case 4
strtemppath = y & "/"
case 5
strtemppath = y & "-" & m & "-" & d & "/"
case 6
strtemppath = y & "-" & m & "/"
case 7
strtemppath = "html/"
case 8
strtemppath = "show/"
case else
strtemppath = ""
end select
strtemppath = replace(strtemppath, " ", "")
showdatepath = cstr(strtemppath)
end function
'=============================================================
'函数名:readbrieftopicffd
'作 用:读取简短标题
'参 数:para
'返回值:简短标题
'=============================================================
public function readbrieftopic(byval para)
dim sbrieftopic
readbrieftopic = ""
if not isnumeric(para) then exit function
if para = 0 then exit function
select case para
case "1"
sbrieftopic = "<font color='blue'>[图文]</font>"
case "2"
sbrieftopic = "<font color='red'>[组图]</font>"
case "3"
sbrieftopic = "<font color='green'>[新闻]</font>"
case "4"
sbrieftopic = "<font color='blue'>[推荐]</font>"
case "5"
sbrieftopic = "<font color='red'>[注意]</font>"
case "6"
sbrieftopic = "<font color='green'>[转载]</font>"
case else
sbrieftopic = ""
end select
readbrieftopic = sbrieftopic
end function
'=============================================================
'函数名:readpictopic
'作 用:读取简短标题
'参 数:para
'返回值:简短标题
'=============================================================
public function readpictopic(byval para)
dim sbrieftopic
readpictopic = ""
if not isnumeric(para) then exit function
if para = 0 then exit function
select case para
case "1"
sbrieftopic = "<font color='" & main_setting(4) & "'>[图文]</font>"
case "2"
sbrieftopic = "<font color='" & main_setting(5) & "'>[组图]</font>"
case "3"
sbrieftopic = "<font color='" & main_setting(6) & "'>[新闻]</font>"
case "4"
sbrieftopic = "<font color='" & main_setting(4) & "'>[推荐]</font>"
case "5"
sbrieftopic = "<font color='" & main_setting(5) & "'>[注意]</font>"
case "6"
sbrieftopic = "<font color='" & main_setting(6) & "'>[转载]</font>"
case else
sbrieftopic = ""
end select
readpictopic = sbrieftopic
end function
'=============================================================
'函数名:readpaymoney
'作 用:读取要支付的金钱
'参 数:money ----实际金钱
'返回值:加上手续费后的金钱
'=============================================================
public function readpaymoney(byval money, byval reduce)
on error resume next
if money = 0 then
readpaymoney = 0
exit function
end if
dim arrchinaebank, valpercent, percents
arrchinaebank = split(chinaebank, "|||")
percents = ccur(arrchinaebank(2) / 100)
if percents = 0 then
readpaymoney = ccur(money)
else
if cbool(reduce) = true then
valpercent = round(ccur(money) / (1 + 1 * percents), 2)
readpaymoney = ccur(valpercent)
else
valpercent = round(ccur(money) * percents, 2)
readpaymoney = ccur(money + valpercent)
end if
end if
end function
'=============================================================
'函数名:rebatemoney
'作 用:读取打折的后金钱
'参 数:money ----实际金钱
' discount ----折扣
'=============================================================
public function rebatemoney(byval money, byval discount)
on error resume next
dim rebate
money = checknumeric(money)
discount = checknumeric(discount)
if discount > 0 and discount < 10 then
rebate = round(money * (discount / 10), 2)
rebatemoney = ccur(rebate)
else
rebatemoney = ccur(money)
end if
end function
'================================================
'函数名:supplemental
'作 用:补足参数
'参 数:para ----原参数
' n ----增补的位数
'================================================
public function supplemental(para, n)
supplemental = ""
if not isnumeric(para) then exit function
if len(para) < n then
supplemental = string(n - len(para), "0") & para
else
supplemental = para
end if
end function
'-----------------------------------------------------------------
public function getchanneldir(byval chanid)
on error resume next
if not isnumeric(chanid) then chanid = 1
name = "channel" & chanid
if objisempty() then reloadchannel (chanid)
cachechannel = value
getchanneldir = installdir & cachechannel(2,0)
end function
'================================================
'函数名:getimageurl
'作 用:获取图片url
'================================================
public function getimageurl(byval url, byval channeldir)
on error resume next
dim strtempurl, strimageurl
if not isnull(url) and trim(url) <> "" and lcase(url) <> "http://" then
strtempurl = installdir & channeldir
if checkurl(url) = 1 then
strimageurl = trim(url)
elseif checkurl(url) = 2 then
strimageurl = url
else
strimageurl = replace(url, "../", "")
strimageurl = trim(strtempurl & strimageurl)
end if
else
strimageurl = installdir & "images/no_pic.gif"
end if
getimageurl = strimageurl
end function
'-----------------------------------------------------------------
'================================================
'作 用:读取图片或者flash
'参 数:url ----文件url
' height ----高度
' width ----宽度
'================================================
function getflashandpic(byval url, byval height, byval width)
on error resume next
dim sextname, extname, strtemp
dim strheight, strwidth
if not isnumeric(height) or height < 1 then
strheight = ""
else
strheight = " height=" & height
end if
if not isnumeric(width) or width < 1 then
strwidth = ""
else
strwidth = " width=" & width
end if
sextname = split(url, ".")
extname = sextname(ubound(sextname))
if lcase(extname) = "swf" then
strtemp = "<embed src=""" & url & """" & strwidth & strheight & ">"
else
strtemp = "<img src=""" & url & """" & strwidth & strheight & " border=0>"
end if
getflashandpic = strtemp
end function
'================================================
'函数名:readfileurl
'作 用:读取文件url
'================================================
public function readfileurl(url)
on error resume next
readfileurl = ""
if url = "" then exit function
dim strtemp
if checkurl(url) = 1 then
strtemp = trim(url)
elseif checkurl(url) = 2 then
strtemp = trim(url)
else
strtemp = replace(url, "../", "")
strtemp = trim(installdir & strtemp)
end if
readfileurl = strtemp
end function
public function checkurl(byval url)
dim strurl
if left(url, 1) = "/" then
checkurl = 1
exit function
end if
strurl = lcase(left(url, 6))
select case trim(strurl)
case "http:/", "https:", "ftp://", "rtsp:/", "mms://"
checkurl = 2
exit function
case else
checkurl = 0
end select
end function
'================================================
'函数名:readfilename
'作 用:读取html文件名
'参 数:strname ----文件名称
' id ----数据id
' extname ----html扩展名
' prefixstr ----html名称前缀
' htmlform ----html文件格式
' n ----html分页
'================================================
public function readfilename(byval strname, byval id, byval extname, byval prefixstr, byval htmlform, byval n)
dim strfilename, strextname, currentpage
if trim(strname) = "" then exit function
if trim(extname) = "" then extname = ".html"
if not isnumeric(n) then n = 0
on error resume next
if cint(n) <= 1 then
currentpage = ""
else
currentpage = "_" & n
end if
if left(extname, 1) <> "." then
strextname = "." & trim(extname)
else
strextname = trim(extname)
end if
select case trim(htmlform)
case "1"
strfilename = trim(id)
case "2"
strfilename = trim(prefixstr) & trim(supplemental(id, 3))
case "3"
strfilename = left(strname, 8)
strfilename = strfilename & trim(supplemental(id, 3))
case "4"
strfilename = right(strname, 7)
strfilename = strfilename & trim(supplemental(id, 3))
case else
strfilename = strname
end select
strfilename = replace(strfilename & currentpage & strextname, " ", "")
readfilename = cstr(strfilename)
end function
'================================================
'过程名:htmlrndfilename
'作 用:取html的随机文件名
'================================================
function htmlrndfilename()
dim srnd
randomize
srnd = int(90 * rnd) + 10
htmlrndfilename = replace(replace(replace(formatdate(now(), 1), "-", ""), ":", ""), " ", "") & srnd
end function
'================================================
'函数名:classfilename
'作 用:读取html文件列表名
'参 数:classid ----分类id
'================================================
public function classfilename(byval classid, byval extname, byval prefixstr, byval n)
dim strfilename, strextname, strclassid
if trim(extname) = "" then extname = ".html"
if not isnumeric(n) then n = 0
if left(extname, 1) <> "." then
strextname = "." & trim(extname)
else
strextname = trim(extname)
end if
if cint(n) <= 1 then
strfilename = "index" & strextname
else
strclassid = supplemental(classid, 3)
strfilename = prefixstr & strclassid & "_" & n & strextname
end if
strfilename = replace(strfilename, " ", "")
classfilename = cstr(strfilename)
end function
'================================================
'函数名:specialfilename
'作 用:读取专题html文件名
'参 数:specid ----专题id
'================================================
public function specialfilename(byval specid, byval extname, byval n)
dim strfilename, strextname, strspecialid
if trim(extname) = "" then extname = ".html"
if not isnumeric(n) then n = 0
if left(extname, 1) <> "." then
strextname = "." & trim(extname)
else
strextname = trim(extname)
end if
if cint(n) <= 1 then
strfilename = "index" & strextname
else
strspecialid = supplemental(specid, 3)
strfilename = "special" & strspecialid & "_" & n & strextname
end if
strfilename = replace(strfilename, " ", "")
specialfilename = cstr(strfilename)
end function
'================================================
'函数名:channelmenu
'作 用:显示频道菜单
'================================================
public function channelmenu()
dim sql, rs, i, totalnumber,strtop
dim strcontent, linktarget, channelname
dim channelurl, htmlcontent, scaption
name = "channelmenu"
if objisempty() then
if chknumeric(main_setting(7)) = 0 then
strtop = vbnullstring
else
strtop = "top " & cint(main_setting(7))
end if
sql = "select " & strtop & " channelid,orders,colormodes,fontmodes,channelname,caption,channeldir,stopchannel,ishidden,binddomain,domainname,linktarget,channeltype,channelurl,ishidden from [nc_channel] where ishidden = 0 order by orders"
set rs = execute(sql)
if rs.bof and rs.eof then
strcontent = ""
else
i = 0
totalnumber = rs.recordcount
do while not rs.eof
i = i + 1
if rs("linktarget") <> 0 then
linktarget = " target=""_blank"""
else
linktarget = ""
end if
htmlcontent = htmlcontent & main_setting(9)
channelname = readfontmode(rs("channelname"), rs("colormodes"), rs("fontmodes"))
if rs("channeltype") < 2 then
channelurl = installdir & rs("channeldir")
else
channelurl = rs("channelurl")
end if
if rs("stopchannel") <> 0 then
scaption = "此频道暂时关闭,不能访问!"
else
scaption = rs("caption")
end if
strcontent = "<a href=""" & channelurl & """" & linktarget & " title=""" & scaption & """ class=navmenu>" & channelname & "</a>"
if i mod cint(main_setting(8)) = 0 then strcontent = strcontent & "<br>"
htmlcontent = replace(htmlcontent, "{$channelmenu}", strcontent)
rs.movenext
loop
end if
rs.close: set rs = nothing
'value = strcontent
end if
'strcontent = value
channelmenu = htmlcontent
end function
'=============================================================
'函数名:loadselectclass
'作 用:载入缓存下拉分类列表
'参 数:channelid ----频道id
'返回值:下拉分类列表
'=============================================================
public function loadselectclass(channelid)
dim cacheselclass, sql, rs1, i
name = "selectclass" & channelid
if objisempty() then
sql = "select classid,classname,depth,turnlink,child from nc_classify where channelid = " & channelid & " order by rootid,orders"
set rs1 = execute(sql)
if rs1.bof and rs1.eof then
cacheselclass = cacheselclass & "<option>没有添加分类</option>"
end if
do while not rs1.eof
if rs1("turnlink") <> 0 then
cacheselclass = cacheselclass & "<option value=""0"""
else
if rs1("depth") = 0 and rs1("child") <> 0 then
cacheselclass = cacheselclass & "<option"
else
cacheselclass = cacheselclass & "<option value=""" & rs1("classid") & """"
end if
end if
cacheselclass = cacheselclass & " {classid=" & rs1("classid") & "}>"
if rs1("depth") = 1 then cacheselclass = cacheselclass & " ├ "
if rs1("depth") > 1 then
for i = 2 to rs1("depth")
cacheselclass = cacheselclass & " "
next
cacheselclass = cacheselclass & " ├ "
end if
cacheselclass = cacheselclass & rs1("classname") & "</option>" & vbcrlf
rs1.movenext
loop
rs1.close
set rs1 = nothing
value = cacheselclass
end if
loadselectclass = value
end function
public function classjumpmenu(channelid)
dim cachejumpmenu
dim rs1
dim i
name = "classjumpmenu" & channelid
if objisempty() then
set rs1 = execute("select classid,channelid,classname,depth,turnlink,turnlinkurl from [nc_classify] where channelid = " & channelid & " order by rootid,orders")
do while not rs1.eof
if rs1("turnlink") <> 0 then
cachejumpmenu = cachejumpmenu & "<option value=""" & rs1("turnlinkurl") & """ {classid=" & rs1("classid") & "}"
else
cachejumpmenu = cachejumpmenu & "<option value=""?channelid=" & rs1("channelid") & "&sortid=" & rs1("classid") & """ {classid=" & rs1("classid") & "}"
end if
if trim(request("sortid")) <> "" then
if clng(request("sortid")) = rs1("classid") then cachejumpmenu = cachejumpmenu & " selected"
end if
cachejumpmenu = cachejumpmenu & ">"
if rs1("depth") = 1 then cachejumpmenu = cachejumpmenu & " ├ "
if rs1("depth") > 1 then
for i = 2 to rs1("depth")
cachejumpmenu = cachejumpmenu & " "
next
cachejumpmenu = cachejumpmenu & " ├ "
end if
cachejumpmenu = cachejumpmenu & rs1("classname") & "</option>" & vbcrlf
rs1.movenext
loop
rs1.close
set rs1 = nothing
value = cachejumpmenu
end if
classjumpmenu = value
end function
'================================================
'函数名:getrandomcode
'作 用:系统分配随机代码
'================================================
public function getrandomcode()
dim ran, i, lengthnum
lengthnum = 16
getrandomcode = ""
for i = 1 to lengthnum
randomize
ran = cint(rnd * 2)
randomize
if ran = 0 then
ran = cint(rnd * 25) + 97
getrandomcode = getrandomcode & ucase(chr(ran))
elseif ran = 1 then
ran = cint(rnd * 9)
getrandomcode = getrandomcode & ran
elseif ran = 2 then
ran = cint(rnd * 25) + 97
getrandomcode = getrandomcode & chr(ran)
end if
next
end function
'================================================
' 函数名:codeistrue
' 作 用:检查验证码是否正确
'================================================
public function codeistrue()
dim codestr
codestr = trim(request("codestr"))
on error resume next
if cstr(session("getcode")) = cstr(codestr) and codestr <> "" then
codeistrue = true
session("getcode") = empty
else
codeistrue = false
session("getcode") = empty
end if
end function
public function checkadmin(byval flag)
dim rs, sql
dim i, tempadmin, adminflag, admingrade
checkadmin = false
on error resume next
sql = "select admingrade,adminflag from nc_admin where username='" & replace(session("adminname"), "'", "''") & "' and password='" & replace(session("adminpass"), "'", "''") & "' and islock=0 and id=" & clng(session("adminid"))
set rs = execute(sql)
if rs.bof and rs.eof then
checkadmin = false
set rs = nothing
exit function
else
adminflag = rs("adminflag")
admingrade = rs("admingrade")
end if
rs.close: set rs = nothing
if cint(admingrade) = 999 then
checkadmin = true
exit function
else
if trim(flag) = "" then exit function
if adminflag = "" then
checkadmin = false
exit function
else
tempadmin = split(adminflag, ",")
for i = 0 to ubound(tempadmin)
if trim(lcase(tempadmin(i))) = trim(lcase(flag)) then
checkadmin = true
exit for
end if
next
end if
end if
end function
'================================================
'函数名:readalpha
'作 用:读取字符串的第一个字母
'参 数:str ----字符
'返回值:返回第一个字母
'================================================
public function readalpha(byval str)
dim strtemp
if isnull(str) or trim(str) = "" then
readalpha = "a-9"
exit function
end if
str = trim(str)
strtemp = 65536 + asc(str)
if (strtemp >= 45217 and strtemp <= 45252) or (strtemp = 65601) or (strtemp = 65633) or (strtemp = 37083) then
readalpha = "a-z"
elseif (strtemp >= 45253 and strtemp <= 45760) or (strtemp = 65602) or (strtemp = 65634) or (strtemp = 39658) then
readalpha = "b-z"
elseif (strtemp >= 45761 and strtemp <= 46317) or (strtemp = 65603) or (strtemp = 65635) or (strtemp = 33405) then
readalpha = "c-z"
elseif (strtemp >= 46318 and strtemp <= 46930) or (strtemp >= 61884 and strtemp <= 61884) or (strtemp = 65604) or (strtemp >= 36820 and strtemp <= 38524) or (strtemp = 65636) then
readalpha = "d-z"
elseif (strtemp >= 46931 and strtemp <= 47009) or (strtemp = 65605) or (strtemp = 65637) or (strtemp = 61513) then
readalpha = "e-z"
elseif (strtemp >= 47010 and strtemp <= 47296) or (strtemp = 65606) or (strtemp = 65638) or (strtemp = 61320) or (strtemp = 63568) or (strtemp = 36281) then
readalpha = "f-z"
elseif (strtemp >= 47297 and strtemp <= 47613) or (strtemp = 65607) or (strtemp = 65639) or (strtemp = 35949) or (strtemp = 36089) or (strtemp = 36694) or (strtemp = 34808) then
readalpha = "g-z"
elseif (strtemp >= 47614 and strtemp <= 48118) or (strtemp >= 59112 and strtemp <= 59112) or (strtemp = 65608) or (strtemp = 65640) then
readalpha = "h-z"
elseif (strtemp = 65641) or (strtemp = 65609) or (strtemp = 65641) then
readalpha = "i-z"
elseif (strtemp >= 48119 and strtemp <= 49061 and strtemp <> 48739) or (strtemp >= 62430 and strtemp <= 62430) or (strtemp = 65610) or (strtemp = 65642) or (strtemp = 39048) then
readalpha = "j-z"
elseif (strtemp >= 49062 and strtemp <= 49323) or (strtemp = 65611) or (strtemp = 65643) then
readalpha = "k-z"
elseif (strtemp >= 49324 and strtemp <= 49895) or (strtemp >= 58838 and strtemp <= 58838) or (strtemp = 65612) or (strtemp = 65644) or (strtemp = 62418) or (strtemp = 48739) then
readalpha = "l-z"
elseif (strtemp >= 49896 and strtemp <= 50370) or (strtemp = 65613) or (strtemp = 65645) then
readalpha = "m-z"
elseif (strtemp >= 50371 and strtemp <= 50613) or (strtemp = 65614) or (strtemp = 65646) then
readalpha = "n-z"
elseif (strtemp >= 50614 and strtemp <= 50621) or (strtemp = 65615) or (strtemp = 65647) then
readalpha = "o-z"
elseif (strtemp >= 50622 and strtemp <= 50905) or (strtemp = 65616) or (strtemp = 65648) then
readalpha = "p-z"
elseif (strtemp >= 50906 and strtemp <= 51386) or (strtemp >= 62659 and strtemp <= 63172) or (strtemp = 65617) or (strtemp = 65649) then
readalpha = "q-z"
elseif (strtemp >= 51387 and strtemp <= 51445) or (strtemp = 65618) or (strtemp = 65650) then
readalpha = "r-z"
elseif (strtemp >= 51446 and strtemp <= 52217) or (strtemp = 65619) or (strtemp = 65651) or (strtemp = 34009) then
readalpha = "s-z"
elseif (strtemp >= 52218 and strtemp <= 52697) or (strtemp = 65620) or (strtemp = 65652) then
readalpha = "t-z"
elseif (strtemp = 65621) or (strtemp = 65653) then
readalpha = "u-z"
elseif (strtemp = 65622) or (strtemp = 65654) then
readalpha = "v-z"
elseif (strtemp >= 52698 and strtemp <= 52979) or (strtemp = 65623) or (strtemp = 65655) then
readalpha = "w-z"
elseif (strtemp >= 52980 and strtemp <= 53688) or (strtemp = 65624) or (strtemp = 65656) then
readalpha = "x-z"
elseif (strtemp >= 53689 and strtemp <= 54480) or (strtemp = 65625) or (strtemp = 65657) then
readalpha = "y-z"
elseif (strtemp >= 54481 and strtemp <= 62383 and strtemp <> 59112 and strtemp <> 58838) or (strtemp = 65626) or (strtemp = 65658) or (strtemp = 38395) or (strtemp = 39783) then
readalpha = "z-z"
else
readalpha = "a-9"
end if
if (strtemp >= 65633 and strtemp <= 65658) or (strtemp >= 65601 and strtemp <= 65626) then readalpha = ucase(left(str, 1))
if (strtemp >= 65584 and strtemp <= 65593) then readalpha = "0-9"
end function
'-- 修正文件路径
public function checkpath(byval spath)
spath = trim(spath)
if right(spath, 1) <> "\" and spath <> "" then
spath = spath & "\"
end if
checkpath = spath
end function
'-- 生成目录
public function creatpathex(byval spath)
spath = replace(spath, "/", "\")
spath = replace(spath, "\\", "\")
on error resume next
dim strhostpath,strpath
dim spathitem,stemppath
dim i,fso
set fso = server.createobject(fso_scriptname)
strhostpath = server.mappath("/")
if instr(spath, ":") = 0 then spath = server.mappath(spath)
if fso.folderexists(spath) or len(spath) < 3 then
creatpathex = true
exit function
end if
strpath = replace(spath, strhostpath, vbnullstring,1,-1,1)
spathitem = split(strpath, "\")
if instr(lcase(spath), lcase(strhostpath)) = 0 then
stemppath = spathitem(0)
else
stemppath = strhostpath
end if
for i = 1 to ubound(spathitem)
if spathitem(i) <> "" then
stemppath = stemppath & "\" & spathitem(i)
if fso.folderexists(stemppath) = false then
fso.createfolder stemppath
end if
end if
next
set fso = nothing
if err.number <> 0 then err.clear
creatpathex = true
end function
'================================================
'函数名:filesdelete
'作 用:fso删除文件
'参 数:filepath ----文件路径
'返回值:false ---- true
'================================================
public function filedelete(byval filepath)
on error resume next
filedelete = false
dim fso
set fso = server.createobject(fso_scriptname)
if filepath = "" then exit function
if instr(filepath, ":") = 0 then filepath = server.mappath(filepath)
if fso.fileexists(filepath) then
fso.deletefile filepath, true
filedelete = true
end if
set fso = nothing
if err.number <> 0 then err.clear
end function
'================================================
'函数名:folderdelete
'作 用:fso删除目录
'参 数:folderpath ----目录路径
'返回值:false ---- true
'================================================
public function folderdelete(byval folderpath)
folderdelete = false
on error resume next
dim fso
set fso = server.createobject(fso_scriptname)
if folderpath = "" then exit function
if instr(folderpath, ":") = 0 then folderpath = server.mappath(folderpath)
if fso.folderexists(folderpath) then
fso.deletefolder folderpath, true
folderdelete = true
end if
set fso = nothing
if err.number <> 0 then err.clear
end function
'================================================
'函数名:copytofile
'作 用:复制文件
'参 数:sourefile ----原文件路径
' newfile ----目标文件路径
'================================================
public function copytofile(byval sourefile, byval newfile)
on error resume next
if sourefile = "" then exit function
if newfile = "" then exit function
if instr(sourefile, ":") = 0 then sourefile = server.mappath(sourefile)
if instr(newfile, ":") = 0 then newfile = server.mappath(newfile)
dim fso
set fso = server.createobject(fso_scriptname)
if fso.fileexists(sourefile) then
fso.copyfile sourefile, newfile
end if
set fso = nothing
if err.number <> 0 then err.clear
end function
'================================================
'函数名:copytofolder
'作 用:复制文件夹
'参 数:sourefolder ----原路径
' newfolder ----目标路径
'================================================
public function copytofolder(byval sourefolder, byval newfolder)
on error resume next
if sourefolder = "" then exit function
if newfolder = "" then exit function
if instr(sourefolder, ":") = 0 then sourefolder = server.mappath(sourefolder)
if instr(newfolder, ":") = 0 then newfolder = server.mappath(newfolder)
dim fso
set fso = server.createobject(fso_scriptname)
if fso.folderexists(sourefolder) then
fso.copyfolder sourefolder, newfolder
end if
set fso = nothing
if err.number <> 0 then err.clear
end function
'=============================================================
'过程名:createdtextfile
'作 用:创建文本文件
'参 数:filename ----文件名
' body ----主要内容
'=============================================================
public function createdtextfile(byval filename, byval body)
on error resume next
if instr(filename, ":") = 0 then filename = server.mappath(filename)
dim fso,f
set fso = server.createobject(fso_scriptname)
set f = fso.createtextfile(filename)
f.writeline body
f.close
set f = nothing
set fso = nothing
if err.number <> 0 then err.clear
end function
'================================================
'函数名:readfile
'作 用:读取文件内容
'参 数:frompath ----来源文件路径
'================================================
public function readfile(byval frompath)
on error resume next
dim strtemp,fso,f
if instr(frompath, ":") = 0 then frompath = server.mappath(frompath)
set fso = server.createobject(fso_scriptname)
if fso.fileexists(frompath) then
set f = fso.opentextfile(frompath, 1, true)
strtemp = f.readall
f.close
set f = nothing
end if
set fso = nothing
readfile = strtemp
if err.number <> 0 then err.clear
end function
'================================================
'函数名:cutmatchcontent
'作 用:截取相匹配的内容
'参 数:str ----原字符串
' patstr ----符合条件字符
'================================================
public function cutmatchcontent(byval str, byval start, byval last, byval condition)
dim match,s,re
dim filterstr,matchstr
dim strcontent,arrayfilter
dim i, n,brepeat
if len(start) = 0 or len(last) = 0 then exit function
on error resume next
matchstr = "(" & correctpattern(start) & ")(.+?)(" & correctpattern(last) & ")"
set re = new regexp
re.ignorecase = true
re.global = true
re.pattern = matchstr
set s = re.execute(str)
n = 0
for each match in s
if n = 0 then
n = n + 1
redim arrayfilter(n)
arrayfilter(n) = match
else
brepeat = false
for i = 0 to ubound(arrayfilter)
if ucase(match) = ucase(arrayfilter(i)) then
brepeat = true
exit for
end if
next
if brepeat = false then
n = n + 1
redim preserve arrayfilter(n)
arrayfilter(n) = match
end if
end if
next
set s = nothing
set re = nothing
if cbool(condition) then
strcontent = join(arrayfilter, "|||")
else
strcontent = join(arrayfilter, "|||")
strcontent = replace(strcontent, start, "")
strcontent = replace(strcontent, last, "")
end if
cutmatchcontent = replace(strcontent, "|||", vbnullstring, 1, 1)
end function
function cutfixcontent(byval str, byval start, byval last, byval n)
dim strtemp
on error resume next
if instr(str, start) > 0 then
select case n
case 0 '左右都截取(都取前面)(去处关键字)
strtemp = right(str, len(str) - instr(str, start) - len(start) + 1)
strtemp = left(strtemp, instr(strtemp, last) - 1)
case else '左右都截取(都取前面)(保留关键字)
strtemp = right(str, len(str) - instr(str, start) + 1)
strtemp = left(strtemp, instr(strtemp, last) + len(last) - 1)
end select
else
strtemp = ""
end if
cutfixcontent = strtemp
end function
private function correctpattern(byval str)
str = replace(str, "\", "\\")
str = replace(str, "~", "\~")
str = replace(str, "!", "\!")
str = replace(str, "@", "\@")
str = replace(str, "#", "\#")
str = replace(str, "%", "\%")
str = replace(str, "^", "\^")
str = replace(str, "&", "\&")
str = replace(str, "*", "\*")
str = replace(str, "(", "\(")
str = replace(str, ")", "\)")
str = replace(str, "-", "\-")
str = replace(str, "+", "\+")
str = replace(str, "[", "\[")
str = replace(str, "]", "\]")
str = replace(str, "<", "\<")
str = replace(str, ">", "\>")
str = replace(str, ".", "\.")
str = replace(str, "/", "\/")
str = replace(str, "?", "\?")
str = replace(str, "=", "\=")
str = replace(str, "|", "\|")
str = replace(str, "$", "\$")
correctpattern = str
end function
'=============================================================
'函数名:usergroupsetting
'作 用:取用户级权限设置
'参 数:gradeid ----等级id
'=============================================================
public function usergroupsetting(byval gradeid)
if not isnumeric(gradeid) then
gradeid = 0
end if
on error resume next
dim rs, sql
name = "groupsetting" & gradeid
if objisempty() then
sql = "select groupname,groupset from [nc_usergroup] where grades =" & gradeid
set rs = execute(sql)
if rs.bof and rs.eof then
usergroupsetting = ""
set rs = nothing
exit function
end if
value = rs("groupset") & rs("groupname")
set rs = nothing
end if
usergroupsetting = value
end function
private sub loadgroupsetting()
dim strgroupsetting
dim rs, sql
dim grades
grades = cint(membergrade)
on error resume next
if grades > 0 and memberid > 0 then
if binuserlong = false then
set rs = execute("select userid from [nc_user] where password='" & checkrequest(memberpass, 45) & "' and usergrade=" & grades & " and userlock=0 and userid =" & memberid)
if rs.bof and rs.eof then
grades = 0
response.cookies(cookies_name) = ""
binuserlong = false
else
binuserlong = true
end if
set rs = nothing
end if
end if
name = "groupsetting" & grades
if objisempty() then
sql = "select groupname,groupset from [nc_usergroup] where grades =" & grades
set rs = execute(sql)
if rs.bof and rs.eof then
response.cookies(cookies_name) = ""
set rs = nothing
exit sub
end if
value = rs("groupset") & rs("groupname")
set rs = nothing
end if
blngroupsetting = true
strgroupsetting = value
arrgroupsetting = split(strgroupsetting, "|||")
end sub
public property get groupsetting(i)
if not blngroupsetting then loadgroupsetting
groupsetting = arrgroupsetting(i)
end property
public function readcontent(byval strcontent)
on error resume next
dim re, i
dim scontentkeyword, strkeyword
set re = new regexp
re.ignorecase = true
re.global = true
'过滤危险脚本
re.pattern = "(<s+cript(.[^>]*)>)"
strcontent = re.replace(strcontent, "<Script$2>")
re.pattern = "(<\/s+cript>)"
strcontent = re.replace(strcontent, "</Script>")
re.pattern = "(<body(.[^>]*)>)"
strcontent = re.replace(strcontent, "<body>")
re.pattern = "(<\!(.[^>]*)>)"
strcontent = re.replace(strcontent, "<$2>")
re.pattern = "(<\!)"
strcontent = re.replace(strcontent, "<!")
re.pattern = "(-->)"
strcontent = re.replace(strcontent, "-->")
re.pattern = "(javascript:)"
strcontent = re.replace(strcontent, "<i>javascript</i>:")
if trim(contentkeyword) <> "" then
scontentkeyword = split(contentkeyword, "@@@")
for i = 0 to ubound(scontentkeyword) - 1
strkeyword = split(scontentkeyword(i), "$$$")
re.pattern = "(" & strkeyword(0) & ")"
strcontent = re.replace(strcontent, "<a target=""_blank"" href=""" & strkeyword(1) & """ class=""wordstyle"">$1</a>")
next
end if
re.pattern = "(\[i\])(.[^\[]*)(\[\/i\])"
strcontent = re.replace(strcontent, "<i>$2</i>")
re.pattern = "(\[u\])(.[^\[]*)(\[\/u\])"
strcontent = re.replace(strcontent, "<u>$2</u>")
re.pattern = "(\[b\])(.[^\[]*)(\[\/b\])"
strcontent = re.replace(strcontent, "<b>$2</b>")
re.pattern = "(\[fly\])(.*)(\[\/fly\])"
strcontent = re.replace(strcontent, "<marquee>$2</marquee>")
re.pattern = "\[size=([1-9])\](.[^\[]*)\[\/size\]"
strcontent = re.replace(strcontent, "<font size=$1>$2</font>")
re.pattern = "(\[center\])(.[^\[]*)(\[\/center\])"
strcontent = re.replace(strcontent, "<center>$2</center>")
're.pattern = "<img.[^>]*src(=| )(.[^>]*)>"
'strcontent = re.replace(strcontent, "<img src=$2 border=""0"">")
re.pattern = "<img(.[^>]*)>"
strcontent = re.replace(strcontent, "<img$1 onload=""return imgzoom(this,550)"">")
re.pattern = "\[dir=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/dir]"
strcontent = re.replace(strcontent, "<embed src=$3 pluginspage=http://www.macromedia.com/shockwave/download/ width=$1 height=$2></embed>")
re.pattern = "\[qt=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/qt]"
strcontent = re.replace(strcontent, "<embed src=$3 width=$1 height=$2 autoplay=true loop=false controller=true playeveryframe=false cache=false scale=tofit bgcolor=#000000 kioskmode=false targetcache=false pluginspage=http://www.apple.com/quicktime/>")
re.pattern = "\[mp=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/mp]"
strcontent = re.replace(strcontent, "<embed type=application/x-oleobject codebase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#version=5,1,52,701 flename=mp src=$3 width=$1 height=$2></embed>")
re.pattern = "\[rm=*([0-9]*),*([0-9]*)\](.[^\[]*)\[\/rm]"
strcontent = re.replace(strcontent, "<object classid=clsid:cfcdaa03-8be4-11cf-b84b-0020afbbccfa class=object id=raocx width=$1 height=$2><param name=src value=$3><param name=console value=clip1><param name=controls value=imagewindow><param name=autostart value=true></object><br><object classid=clsid:cfcdaa03-8be4-11cf-b84b-0020afbbccfa height=32 id=video2 width=$1><param name=src value=$3><param name=autostart value=-1><param name=controls value=controlpanel><param name=console value=clip1></object>")
re.pattern = "(\[flash\])(.[^\[]*)(\[\/flash\])"
strcontent = re.replace(strcontent, "<embed src=""$2"" quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?p1_prod_version=shockwaveflash' type='application/x-shockwave-flash' width=500 height=400>$2</embed>")
re.pattern = "(\[flash=*([0-9]*),*([0-9]*)\])(.[^\[]*)(\[\/flash\])"
strcontent = re.replace(strcontent, "<embed src=""$4"" quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?p1_prod_version=shockwaveflash' type='application/x-shockwave-flash' width=$2 height=$3>$4</embed>")
re.pattern = "\[upload=(gif|jpg|jpeg|bmp|png)\](.[^\[]*)(gif|jpg|jpeg|bmp|png)\[\/upload\]"
strcontent = re.replace(strcontent, "<br><a href=""$2$1"" target=_blank><img src=""$2$1"" border=0 alt=按此在新窗口浏览图片 onload=""javascript:if(this.width>screen.width-333)this.width=screen.width-333""></a>")
re.pattern = "(\[upload=(.[^\[]*)\])(.[^\[]*)(\[\/upload\])"
strcontent = re.replace(strcontent, "<br><a href=""$3"">点击浏览该文件</a>")
re.pattern = "(\[url\])(.[^\[]*)(\[\/url\])"
strcontent = re.replace(strcontent, "<a href=""$2"" target=_blank>$2</a>")
re.pattern = "(\[url=(.[^\[]*)\])(.[^\[]*)(\[\/url\])"
strcontent = re.replace(strcontent, "<a href=""$2"" target=_blank>$3</a>")
re.pattern = "(\[email\])(.[^\[]*)(\[\/email\])"
strcontent = re.replace(strcontent, "<a href=""mailto:$2"">$2</a>")
re.pattern = "(\[email=(.[^\[]*)\])(.[^\[]*)(\[\/email\])"
strcontent = re.replace(strcontent, "<a href=""mailto:$2"" target=_blank>$3</a>")
re.pattern = "(\[html\])(.[^\[]*)(\[\/html\])"
strcontent = re.replace(strcontent, "<table width='100%' border='0' cellspacing='0' cellpadding='6' bgcolor='#f6f6f6'><td><b>以下内容为程序代码:</b><br>$2</td></table>")
re.pattern = "(\[code\])(.[^\[]*)(\[\/code\])"
strcontent = re.replace(strcontent, "<table width='100%' border='0' cellspacing='0' cellpadding='6' bgcolor='#f6f6f6'><td><b>以下内容为程序代码:</b><br>$2</td></table>")
re.pattern = "(\[color=(.[^\[]*)\])(.[^\[]*)(\[\/color\])"
strcontent = re.replace(strcontent, "<font color=$2>$3</font>")
re.pattern = "(\[face=(.[^\[]*)\])(.[^\[]*)(\[\/face\])"
strcontent = re.replace(strcontent, "<font face=$2>$3</font>")
re.pattern = "\[align=(center|left|right)\](.*)\[\/align\]"
strcontent = re.replace(strcontent, "<div align=$1>$2</div>")
re.pattern = "(\[quote\])(.*)(\[\/quote\])"
strcontent = re.replace(strcontent, "<table cellpadding=0 cellspacing=0 border=1 width=94% bordercolor=#000000 bgcolor=#f2f8ff align=center ><tr><td ><table width=100% cellpadding=5 cellspacing=1 border=0><tr><td bgcolor='#f6f6f6'>$2</table></table><br>")
re.pattern = "(\[move\])(.*)(\[\/move\])"
strcontent = re.replace(strcontent, "<marquee scrollamount=3>$2</marquee>")
re.pattern = "\[glow=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\](.[^\[]*)\[\/glow]"
strcontent = re.replace(strcontent, "<table width=$1 style=""filter:glow(color=$2, strength=$3)"">$4</table>")
re.pattern = "\[shadow=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\](.[^\[]*)\[\/shadow]"
strcontent = re.replace(strcontent, "<table width=$1 style=""filter:shadow(color=$2, strength=$3)"">$4</table>")
set re = nothing
strcontent = replace(strcontent, "[installdir_channeldir]", installdir & "/" & channeldir)
strcontent = replace(strcontent, "{", "{")
strcontent = replace(strcontent, "}", "}")
strcontent = replace(strcontent, "$", "$")
readcontent = strcontent
end function
end class
%>
上一篇: ASP实现URL编码
推荐阅读
-
windows 中 \r\n 区别于 类unix中的\n 疑问理解(crlf回车换行)
-
【转载】 C#中ArrayList集合类的使用
-
【转载】C#中ArrayList集合类使用Add方法添加元素
-
Java日期时间API系列8-----Jdk8中java.time包中的新的日期时间API类的LocalDate源码分析
-
Java中数组操作 java.util.Arrays 类常用方法的使用
-
如何简单地理解Python中的if __name__ == '__main__'
-
Dart基础语法<八> 类(中)
-
asp.net core 3.1 入口:Program.cs中的Main函数
-
Javascript中类式继承和原型式继承的实现方法和区别之处
-
C#中Dictionary类使用实例