📄 function.asp
字号:
<%
function Searchkey(str,getstr)
strkey="<span style='background-color:red;'>"&getstr&"</span>"
Searchkey=replace(str,getstr,strkey)
end function
'*******************************************
'函数名:CheckTwoStr
'作用:用于检查某字符串是否是2个,否则加‘0’
'参数设置:Str:等待检测的字符串
'2005-6-4 guo
'*******************************************
function CheckTwoStr(str)
if len(str)<2 then
CheckTwoStr="0"&str
else
CheckTwoStr=str
end if
end function
'******************************************
'函数名:Cutstr
'作用:用于切除某段时间过长字符,一个中文算2个字符
'参数说明:str--字符串 strlen --要显示的长度
'******************************************
function cutStr(str,strlen)
dim l,t,c
l=len(str)
t=0
for i=1 to l
c=Asc(Mid(str,i,1))
if c>255 or c<0 then
t=t+2
else
t=t+1
end if
if t>=strlen then
cutStr=left(str,i)&"..."
exit for
else
cutstr=str
end if
next
end function
Function CheckStringLength(str)
str=trim(str)
length=len(str)
j=0
for i=1 to length
if asc(mid(str,i,1))<0 or asc(mid(str,i,1))>255 then
j=j+2
else
j=j+1
end if
next
CheckStringLength=j
end Function
'**********************************************************
'过程名:showpage
'作 用:显示“上一页 下一页”等信息
'参 数:sfilename ----链接地址
' totalnumber ----总数量
' maxperpage ----每页数量
' ShowTotal ----是否显示总数量
' ShowAllPages ---是否用下拉列表或文本框显示所有页面以供跳转。有某些页面不能使用,否则会出现JS错误。
' strUnit ----计数单位
'**********************************************************
function showpage(sfilename,totalnumber,maxperpage,ShowTotal,ShowAllPages,strUnit,currentpage)
dim n, i,strTemp,strUrl
if totalnumber mod maxperpage=0 then
n= totalnumber \ maxperpage
else
n= totalnumber \ maxperpage+1
end if
strTemp= "<table align='center'><tr><td style='font-size:12px;text-decoration:none'>"
if ShowTotal=true then
strTemp=strTemp & "共 <b>" & totalnumber & "</b> " & strUnit & " "
end if
strUrl=JoinChar(sfilename)
'strurl=sfilename
if CurrentPage<2 then
strTemp=strTemp & "首页 上一页 "
else
strTemp=strTemp & "<a href='" & strUrl & "page=1'>首页</a> "
strTemp=strTemp & "<a href='" & strUrl & "page=" & (CurrentPage-1) & "'>上一页</a> "
end if
if n-currentpage<1 then
strTemp=strTemp & "下一页 尾页"
else
strTemp=strTemp & "<a href='" & strUrl & "page=" & (CurrentPage+1) & "'>下一页</a> "
strTemp=strTemp & "<a href='" & strUrl & "page=" & n & "'>尾页</a>"
end if
strTemp=strTemp & " 页次:<strong><font color=red>" & CurrentPage & "</font>/" & n & "</strong>页 "
strTemp=strTemp & " <b>" & maxperpage & "</b>" & strUnit & "/页"
if ShowAllPages=True then
'strTemp=strTemp & " 转到:<select name='page' size='1' onchange=""javascript:window.location='" & strUrl & "page=" & "'+this.options[this.selectedIndex].value;"">"
strtemp=strtemp&" 转到:<input type='text' size=3 name='page'>"
strtemp=strtemp&" <input type='submit' name='submit' value='GO' onclick=""javascript:window.location='" & strUrl & "page=" & "'+page.value;"">"
end if
strTemp=strTemp & "</td></tr></table>"
response.write strTemp
end function
function showpage_eng(sfilename,totalnumber,maxperpage,ShowTotal,ShowAllPages,strUnit,currentpage)
dim n, i,strTemp,strUrl
if totalnumber mod maxperpage=0 then
n= totalnumber \ maxperpage
else
n= totalnumber \ maxperpage+1
end if
strTemp= "<table align='center'><tr><td style='font-size:12px;text-decoration:none'>"
if ShowTotal=true then
strTemp=strTemp & "Total <b>" & totalnumber & "</b> " & strUnit & " "
end if
strUrl=JoinChar(sfilename)
'strurl=sfilename
if CurrentPage<2 then
strTemp=strTemp & "Home Former "
else
strTemp=strTemp & "<a href='" & strUrl & "page=1'>Home</a> "
strTemp=strTemp & "<a href='" & strUrl & "page=" & (CurrentPage-1) & "'>Former</a> "
end if
if n-currentpage<1 then
strTemp=strTemp & "Next End"
else
strTemp=strTemp & "<a href='" & strUrl & "page=" & (CurrentPage+1) & "'>Next</a> "
strTemp=strTemp & "<a href='" & strUrl & "page=" & n & "'>End</a>"
end if
strTemp=strTemp & " Page:<strong><font color=red>" & CurrentPage & "</font>/" & n & "</strong> "
strTemp=strTemp & " <b>" & maxperpage & "</b>" & strUnit
if ShowAllPages=True then
'strTemp=strTemp & " 转到:<select name='page' size='1' onchange=""javascript:window.location='" & strUrl & "page=" & "'+this.options[this.selectedIndex].value;"">"
strtemp=strtemp&" Turn to:<input type='text' size=3 name='page'>"
strtemp=strtemp&" <input type='submit' name='submit' value='GO' onclick=""javascript:window.location='" & strUrl & "page=" & "'+page.value;"">"
end if
strTemp=strTemp & "</td></tr></table>"
response.write strTemp
end function
'**************************************************
'函数名:JoinChar
'作 用:向地址中加入 ? 或 &
'参 数:strUrl ----网址
'返回值:加了 ? 或 & 的网址
'**************************************************
function JoinChar(strUrl)
if strUrl="" then
JoinChar=""
exit function
end if
if InStr(strUrl,"?")<len(strUrl) then
if InStr(strUrl,"?")>1 then
if InStr(strUrl,"&")<len(strUrl) then
if instr(strurl,"&page=")>1 then
arrstr=split(strurl,"&page=")
joinchar=arrstr(0)&"&"
else
JoinChar=strUrl & "&"
end if
else
JoinChar=strUrl
end if
if instr(strurl,"?page=")>1 then
arrstr=split(strurl,"?page=")
joinchar=arrstr(0)&"?"
'else
'JoinChar=strUrl & "?"
end if
else
JoinChar=strUrl & "?"
end if
else
JoinChar=strUrl
end if
end function
'******************************************
'过程名:CheckClassMaster
'作 用:检测某一行字符串是否存在某字符(利用某分割)
'参数设置:AllMaster ---所有字符
' Mastername --所检测的字符
'******************************************
function CheckClassMaster(AllMaster,MasterName)
if isNull(AllMaster) or AllMaster="" or MasterName="" then
CheckClassMaster=False
exit function
end if
CheckClassMaster=False
if instr(AllMaster,"|")>0 then
dim arrMaster,i
arrMaster=split(AllMaster,"|")
for i=0 to ubound(arrMaster)
if trim(arrMaster(i))=MasterName then
CheckClassMaster=True
exit for
end if
next
else
if AllMaster=MasterName then
CheckClassMaster=True
end if
end if
end function
'*****************************************
'函数:ToHtml
'作用:用于文本域写进数据库前或后处理
'*****************************************
function ToHtml(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, CHR(10) & CHR(10), "</P><P> ")
fString = Replace(fString, CHR(10), "<BR> ")
ToHtml = fString
end if
end function
function HTMLCodeto(fString)
if not isnull(fString) then
fString = replace(fString, ">", ">")
fString = replace(fString, "<", "<")
fString = Replace(fString, " "," ")
fString = Replace(fString, """, CHR(34))
fString = Replace(fString, "'", CHR(39))
fString = Replace(fString, "</P><P> ",CHR(10) & CHR(10))
fString = Replace(fString, "<BR> ", CHR(10))
HTMLCodeto = fString
end if
end function
function nohtml(str)
dim re
Set re=new RegExp
re.IgnoreCase =true
re.Global=True
re.Pattern="(\<.[^\<]*\>)"
str=re.replace(str," ")
re.Pattern="(\<\/[^\<]*\>)"
str=re.replace(str," ")
nohtml=str
set re=nothing
end function
'***********************************************
'过程名:Admin_showClass_option
'作 用:用于显示下拉菜单里的option
'参数说明:showtype:显示模式
' currentid:接收的ID
' tablename:表名
'***********************************************
sub Admin_ShowClass_Option(ShowType,CurrentID,TableName)
currentid=cint(currentid)
if ShowType=0 then
response.write "<option value='0'"
if CurrentID=0 then response.write " selected"
response.write ">无(作为一级类别)</option>"
end if
if ShowType=4 then
response.write "<option value='0'"
if CurrentID=0 then response.write " selected"
response.write ">--全部类别--</option>"
end if
if ShowType=5 then
response.write "<option value='0'"
if CurrentID=0 then response.write " selected"
response.write ">--All types--</option>"
end if
dim rsClass,sqlClass,strTemp,tmpDepth,i
dim arrShowLine(20)
for i=0 to ubound(arrShowLine)
arrShowLine(i)=False
next
if showtype=8 then
response.write "<option value='0'"
if CurrentID=0 then response.write " selected"
response.write ">--All types--</option>"
sqlClass="Select * From "&TableName&" where depth<2 order by RootID,OrderID"
else
sqlClass="Select * From "&TableName&" order by RootID,OrderID"
end if
set rsClass=server.CreateObject("adodb.recordset")
rsClass.open sqlClass,conn,1,1
if not rsClass.eof then
do while not rsClass.eof
tmpDepth=rsClass("Depth")
if rsClass("NextID")>0 then
arrShowLine(tmpDepth)=True
else
arrShowLine(tmpDepth)=False
end if
if ShowType=1 then
strTemp="<option value='" & rsClass("ClassID") & "'"
elseif ShowType=2 then
strTemp="<option value=''"
strTemp="<option value='" & rsClass("ClassID") & "'"
if session("type")<>1 then
if CheckClassMaster(rsClass("Classinputer"),session("AdminName"))=True then
strTemp=strTemp & "style='background-color:#ff0000'"
end if
end if
elseif ShowType=3 then
strTemp="<option value=''"
strTemp="<option value='" & rsClass("ClassID") & "'"
if session("type")<>1 then
if CheckClassMaster(rsClass("ClassMaster"),session("AdminName"))=True then
strTemp=strTemp & "style='background-color:#ff0000'"
end if
end if
else
strTemp="<option value='" & rsClass("ClassID") & "'"
end if
if CurrentID>0 and CurrentID=rsClass("classid") then
strtemp=strtemp&"selected>"
else
strtemp=strtemp&">"
end if
if tmpDepth>0 then
for i=1 to tmpDepth
'strTemp=strTemp & " "
if i=tmpDepth then
if rsClass("NextID")>0 then
strTemp=strTemp & "├ "
else
strTemp=strTemp & "└ "
end if
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -