⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 function.asp

📁 C2C二手交易网SMRUC v2.0 全部实现了C2C电子商务功能。 特别适合高校、组织、社区实现自己的C2C电子商务。 C2C二手交易网SMRUC v2.0具有强大的用户自主发布和管理信息功能
💻 ASP
字号:
<%
function gotTopic(str,strlen)
	if str="" then
		gotTopic=""
		exit function
	end if
	dim l,t,c, i
	str=replace(replace(replace(replace(str,"&nbsp;"," "),"&quot;",chr(34)),"&gt;",">"),"&lt;","<")
	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
			gotTopic=left(str,i) & "…"
			exit for
		else
			gotTopic=str
		end if
	next
	gotTopic=replace(replace(replace(replace(gotTopic," ","&nbsp;"),chr(34),"&quot;"),">","&gt;"),"<","&lt;")
end function
'**************************************************

'函数名:ReplaceBadChar
'作  用:过滤非法的SQL字符

'参  数:strChar-----要过滤的字符
'返回值:过滤后的字符

'**************************************************

function ReplaceBadChar(strChar)
	
	if strChar="" then
		
		ReplaceBadChar=""
	
	else

		ReplaceBadChar=replace(replace(replace(replace(replace(replace(replace(strChar,"'",""),"*",""),"?",""),"(",""),")",""),"<",""),".","")
	
	end if

end function 

'检查E-mail是否合法
function IsValidEmail(user_mail)

dim names, name, i, c

'Check for valid syntax in an email address.

IsValidEmail = true
names = Split(user_mail, "@")
if UBound(names) <> 1 then
   IsValidEmail = false
   exit function
end if
for each name in names
   if Len(name) <= 0 then
     IsValidEmail = false
     exit function
   end if
   for i = 1 to Len(name)
     c = Lcase(Mid(name, i, 1))
     if InStr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 and not IsNumeric(c) then
       IsValidEmail = false
       exit function
     end if
   next
   if Left(name, 1) = "." or Right(name, 1) = "." then
      IsValidEmail = false
      exit function
   end if
next
if InStr(names(1), ".") <= 0 then
   IsValidEmail = false
   exit function
end if
i = Len(names(1)) - InStrRev(names(1), ".")
if i <> 2 and i <> 3 then
   IsValidEmail = false
   exit function
end if
if InStr(email, "..") > 0 then
   IsValidEmail = false
end if

end function

'检查IP段
function checkip(ip,allowip1,allowip2)
dim check(4)
checkip=false
ipstr=split(ip,".")
allow1=split(allowip1,".")
allow2=split(allowip2,".")
if cint(allow1(0))>cint(allow2(0)) then ''判断IP地址段是否合法
response.write "禁止访问"
exit function
end if
for i=0 to ubound(ipstr)
if cint(allow1(i))<cint(allow2(i)) then
if cint(allow1(i))=cint(ipstr(i)) then
check(i)=true
checkip=true
exit for
else
if cint(ipstr(i))<cint(allow2(i)) then
check(i)=true
checkip=true
exit for
else
if cint(ipstr(i))>cint(allow2(i)) then
check(i)=false
checkip=false
exit for
else
check(i)=true
checkip=true
end if
end if
end if
else
if cint(allow1(i))>cint(ipstr(i)) or cint(allow1(i))<cint(ipstr(i)) then
check(i)=false
checkip=false
if i<>ubound(ipstr) then
exit for
end if
else
check(i)=true
end if
end if
next
if (check(0)=true and check(1)=true and check(2)=true and check(3)=false) and (cint(allow2(2))>cint(ipstr(2))) then
checkip=true
end if
end function

'**************************************************
'比较两个字符串函数 : correlation
'参数是两个被比较的字符串 : string1,string2
'如果有关联词语则返回1,否则返回0,有字符串为空返回-1
'**************************************************

function correlation(string1,string2)

	if string1="" or string2="" then	'如果参数中有空字符串为空返回-1
		correlation = -1
		exit function
	end if

	dim i,flag
	dim str1,str2,temp
	str1 = trim(string1)
	str2 = trim(string2)

	for i = 1 to len(str1)				'看是否匹配
		temp = mid(str1,i,2)
		if temp <> "求购" and temp <> "二手" and temp <> "出售" then				'过滤一些词语
			flag = instr(str2,temp)
			if flag <> 0 then
				correlation = 1
				exit function
			end if
		end if
	next

	correlation = 0					'不匹配返回0

end function

function  deletefiles(path)  
       'on  error  resume  next  
       Set  fs1=Server.CreateObject("Scripting.FileSystemObject")    
       if  fs1.FileExists  (path)  then  
       fs1.DeleteFile  path,True    
       else  
           response.write  "文件不存在!"  
       end  if  
       Set  fs1=nothing                     
end  function
%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -