📄 const.asp
字号:
if inStr(str,badwords(i))>0 then
if i > UBound(rebadwords) then
str = replace(str,badwords(i),"*")
else
str = replace(str,badwords(i),rebadwords(i))
end if
end if
next
chkBadWords = str
end function
' 日期格式化
public function formatDate(dateStr,types)
dim y,m,d,h,f,s
if dateStr="" then exit function
y=year(dateStr)
m=month(dateStr)
d=day(dateStr)
h=hour(dateStr)
f=minute(dateStr)
s=second(dateStr)
if m<10 then m="0"&m
if d<10 then d="0"&d
if h<10 then h="0"&h
if f<10 then f="0"&f
if s<10 then s="0"&s
select case types
case 1 formatDate=y&"-"&m&"-"&d
case 2 formatDate=y&"/"&m&"/"&d
case 3 formatDate=m&"-"&d
case 4 formatDate=m&"-"&d&" "&h&":"&f
case 5 formatDate=y&"年"&m&"月"&d&"日"
case 6 formatDate=y&"-"&m&"-"&d&" "&h&":"&f&":"&s
end select
end function
' 获取值(表,值,编号)
public function getValue(table,content,ID)
dim rs
if ID<>"" then
set rs=conn.execute("select "&content&" from "&table&" where "&ID)
else
set rs=conn.execute("select "&content&" from "&table)
end if
if not (rs.eof and rs.bof) then
getValue=rs(0)
end if
rs.close : set rs=nothing
end function
'setValue(表,值,条件,编号,编号值)
public function setValue(table,content,ID,n,nValue)
dim values,i,okValue
values=getValue(table,content,ID)
values=split(values,"|||")
okValue=""
for i=0 to Ubound(values)
if i=cint(n) then
okValue=okValue & nValue
else
okValue=okValue & values(i)
end if
if i<ubound(values) then
okValue=okValue&"|||"
end if
next
if ID<>"" then
conn.execute("update "&table&" set "&content&"='"&okValue&"' where "&ID)
else
conn.execute("update "&table&" set "&content&"='"&okValue&"'")
end if
end function
public function setMoney(money,ID)
dim rs,myMoney
conn.execute("update as_user set [money]=[money]+"&clng(money)&" where "&ID)
myMoney=getValue("as_user","[money]",ID)
set rs=conn.execute("select groupsID,[money] from as_groups where parentID=0 order by orders desc")
if not(rs.bof and rs.eof) then
do while not rs.eof
if clng(myMoney)>=clng(rs(1)) then
conn.execute("update as_user set [level]="&cint(rs(0))&" where "&ID)
exit function
end if
rs.movenext
loop
end if
rs.close:set rs=nothing
end function
'ID选择(表,父级编号,组编号,用户编号,选中编号)
public function IDSelect(table,parentID,groups,isuser,editID)
dim rs,sql,i
sql="select "&table&"ID,"&table&"Name,depth,child from as_"&table&" where parentID="&parentID
if groups>0 then
sql=sql+" and groups="&groups
end if
if isuser=1 then
sql=sql+" and userID="&anysale.userID
end if
sql=sql+" order by orders,rootID"
set rs=conn.execute(sql)
do while not rs.eof
response.write " <option value="""&rs(0)&""""
if editID = rs(0) then response.write " selected=""selected"" " end if
response.write ">"
if rs("depth")>0 then
for i=1 to rs("depth")
response.write "-"
next
end if
response.write ""&rs(1)&""
response.write "</option>"
IDSelect table,rs(0),groups,isuser,editID
rs.moveNext
loop
rs.close
set rs=nothing
end function
'列表(表,父级编号,链接)
public function list(table,parentID,groups,isuser,asLink)
dim rs,sql,i,subRs,subSql,subi,gID,uID
if groups>0 then gID=" and groups="&groups end if
if isuser>0 then uID=" and userID="&anysale.userID end if
set rs=conn.execute("select "&table&"ID,"&table&"Name,child from as_"&table&" where parentID="&parentID&gID&uID&" order by orders,"&table&"ID")
if not (rs.eof and rs.bof) then
sql=rs.getRows(-1)
rs.close:set rs=nothing
for i=0 to Ubound(sql,2)
response.write"<li><h5><a class=""links"" href="""&asLink+table&"ID="&replace(sql(0,i)," ","")&""">"&sql(1,i)&"</a></h5><p>"
set subRs=conn.execute("select "&table&"ID,"&table&"Name,child from as_"&table&" where parentID="&sql(0,i)&" order by orders,"&table&"ID")
if not (subRs.eof and subRs.bof) then
subSql=subRs.getRows(-1)
subRs.close:set subRs=nothing
for subi=0 to Ubound(subSql,2)
response.write"<a href="""&asLink+table&"ID="&replace(subSql(0,subi)," ","")&""">"&subSql(1,subi)&"</a> | "
next
end if
if sql(2,i)>0 then response.write"<a href="""&asLink+table&"ID="&replace(sql(0,i)," ","")&""">更多</a>" end if
response.write"</p></li>"
next
end if
end function
'子列表(表,编号,链接)
public function subList(table,ID,groups,isuser,asLink)
dim rs,sql,i,gID,uID
if groups>0 then gID=" and groups="&groups end if
if isuser>0 then uID=" and userID="&anysale.userID end if
if ID>0 then
set rs=conn.execute("select child,parentID from as_"&table&" where "&table&"ID="&ID&gID&uID)
if not (rs.eof and rs.bof) then
if rs(0)>0 then
sql="select "&table&"ID,"&table&"Name from as_"&table&" where parentID="&ID&gID&uID&" order by orders,"&table&"ID"
else
sql="select "&table&"ID,"&table&"Name from as_"&table&" where parentID="&rs(1)&gID&uID&" order by orders,"&table&"ID"
end if
end if
rs.close:set rs=nothing
end if
if sql="" then
sql="select "&table&"ID,"&table&"Name from as_"&table&" where parentID=0 "&gID&uID&" order by orders,"&table&"ID"
end if
set rs=conn.execute(sql)
if not rs.Eof then
sql=rs.getRows(-1)
rs.close:set rs=nothing
for i=0 to Ubound(sql,2)
response.write"<li><a href="""&asLink+table&"ID="&(sql(0,i))&""">"&server.htmlencode(sql(1,i))&"</a></li>"
next
end if
end function
'导航(表,编号,类别0:导航1:有链接文字2:导航文字3:文字,链接)
public function nav(table,ID,types,asLink)
dim rs,rsnav,parentStr,i
set rs=conn.execute("select "&table&"ID,"&table&"Name,parentStr from as_"&table&" where "&table&"ID="&ID)
if not (rs.eof and rs.bof) then
parentStr=split(rs(2),",")
for i=0 to UBound(parentStr)
set rsnav=conn.execute("select "&table&"Name from as_"&table&" where "&table&"ID="&parentStr(i))
if not (rsnav.eof and rsnav.bof) then
if types=0 then
response.write"»<a href="""&asLink+table&"ID="&parentStr(i)&""">"&rsnav(0)&"</a>"
elseif types=1 then
response.write" <a href="""&asLink+table&"ID="&parentStr(i)&""">"&rsnav(0)&"</a>"
elseif types=2 then
nav= rsnav(0) &" - "& nav
else
response.write rsnav(0)
end if
end if
next
rsnav.close
set rsnav=nothing
if types=0 then
response.write"»<a href="""&asLink+table&"ID="&ID&""">"&rs(1)&"</a>"
elseif types=1 then
response.write" <a href="""&asLink+table&"ID="&ID&""">"&rs(1)&"</a>"
elseif types=2 then
nav= rs(1) &" - "& nav
else
response.write rs(1)
end if
end if
rs.close
set rs=nothing
end function
'下级ID列表(表,编号)
public function IDList(table,ID)
dim parentStr, iParentStr
dim parentID, rootID
dim rs,i
set rs=conn.execute("select parentStr,"&table&"ID,parentID,rootID from as_"&table&" where "&table&"ID="&ID)
if not (rs.eof and rs.bof) then
if rs(0)="0" then
parentStr=rs(1)
parentID=0
else
parentStr=rs(0) & "," & rs(1)
parentID=rs(2)
end if
iParentStr=rs(1)
rootID=rs(3)
'得到当前版面下频道ID
i=0
set rs=conn.execute("select "&table&"ID from as_"&table&" where rootID="&rootID&" and parentStr like '%"&parentStr&"%'")
if not (rs.eof and rs.bof) then
do while not rs.eof
if i=0 then
iParentStr=rs(0)
else
iParentStr=iParentStr & "," & rs(0)
end if
i=i+1
rs.movenext
loop
end if
if i>0 then
parentStr=iParentStr & "," & ID
else
parentStr=ID
end if
IDList= " and "&table&"ID in ("&parentStr&")"
end if
rs.close
set rs=nothing
end function
'删除上传文件
public function delfile(isdel,groups,userID,id)
if cint(isdel)=1 then
dim rs,filePath,objFSO,num
set rs = conn.execute("select fileName,viewName from as_upfile where [group]="&cint(groups)&" and userID="&clng(userID)&" and ID="&clng(id))
if not rs.eof then
filePath = server.mapPath("../upfile/"&rs(0))
set objFSO = server.createObject("scripting.fileSystemObject")
if objFSO.fileExists(filePath) then
objFSO.deleteFile filePath
if err<>0 then err.clear
end if
if objFSO.fileExists(server.mapPath("../"&rs(1))) then
objFSO.deleteFile(server.mapPath("../"&rs(1)))
if err<>0 then err.clear
end if
set objFSO = nothing
end if
rs.close
set rs=nothing
conn.execute("delete from as_upfile where [group]="&cint(groups)&" and userID="&clng(userID)&" and ID="&clng(id))
'文件统计
num=getValue("as_upfile","count(*)","userID="&clng(userID))
call setValue("as_user","userInfo","userID="&clng(userID),13,clng(num))
else
conn.execute("update as_upfile set ID=0,[group]=14 where [group]="&cint(groups)&" and userID="&clng(userID)&" and ID="&clng(id))
end if
end function
'广告(广告位编号)
public function ad(groupsID,style)
dim rsg,rs,i,link,url,title,target,content
set rsg=conn.execute("select adgroupsID,adType,number,width,height,istransparent,target,readme from as_adgroups where isactive=1 and adgroupsID="&clng(groupsID))
if not (rsg.eof and rsg.bof) then
set rs=conn.execute("select top "&clng(rsg("number"))&" * from as_ad where ispay=1 and islock=0 and adgroupsID="&clng(rsg("adgroupsID"))&" and starttime<"&anysaleNow&" and endtime>"&anysaleNow&" order by price desc,adID desc")
if not (rs.eof and rs.bof) then
content= "<div "&style&">"
select case rsg("adType")
case 0 '文字
content=content+"<ul>"
do while not rs.eof
if rsg("target")=1 then
target="window.open('validator.asp?action=viewme&id="&rs("adID")&"');"
else
target="location.href='validator.asp?action=viewme&id="&rs("adID")&"';"
end if
conn.execute("update as_ad set views=views+1 where adID="&rs("adID"))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -