Recomendado: Coleção útil de funções no desenvolvimento de ASP (2) Uma coleção de funções úteis no desenvolvimento do ASP é bastante útil, por favor, mantenha -o! '*****************************************
Uma coleção de funções úteis no desenvolvimento de ASP é bastante útil! Espero que todos os mantenham!
<%
'********************************************
'Prevê envios externos
'********************************************
função chkpost ()
Dim Server_v1, Server_v2
chkpost = false
server_v1 = cstr (request.Servervariables (http_referer))
server_v2 = cstr (request.Servervariables (server_name))
Se MID (server_v1,8, len (server_v2)) <> server_v2 então
chkpost = false
outro
chkpost = true
final se
Função final
'********************************************
'Filtragem IP
'********************************************
função matchip (IP)
em erro de erro em seguida
Matchip = false
Dim gole, dividida
para cada gole no filtroip
Sip = substituir (sip,*,/d*)
Dividido = divisão (gole,.)
Dim re, strmatchs, tira
Definir Re = novo regexp
re.IGNORECASE = true
re.global = true
re.Pattern = (& Splitip (0) |). (& SPLITIP (1) |). (& SPLITIP (2) |). (& SPLITIP (3) |)
Set strMatchs = re.execute (ip)
tira = strMatchs (0) .Submatches (0) &. & strMatchs (0) .Submatches (1) &. & strMatchs (0) .Submatches (2) &. & strMatchs (0) .Submatches (3)
Se tira = ip então matchip = true: função de saída
Defina strMatchs = nada
Definir re = nada
próximo
Função final
'********************************************
'Obtenha o código de registro
'********************************************
Função getCode ()
getCode = <img src = Common/getCode.asp alt = style = margem-direita: 40px;/>
Função final
'********************************************
'Tipos de arquivo limitados
'********************************************
Função isvalidfile (file_type)
IsValidFile = false
Dim Gname
Para cada gName em up_fileType
Se file_type = gname então
IsValidFile = true
Saída para
Final se
Próximo
Função final
'********************************************
'Detecção se apenas inglês e números estão incluídos
'********************************************
Função isvalidchars (str)
Dim RE, Chkstr
Definir Re = novo regexp
re.IGNORECASE = true
re.global = true
re.pattern = [^_/. a-za-z/d]
Isvalidchars = true
Chkstr = re.Replace (str,)
Se ChkStr <> str então isValidchars = false
Definir re = nada
Função final
'********************************************
'Detecção se apenas inglês e números estão incluídos
'********************************************
Função isValidValue (Arrayn, STR)
IsValidValue = false
Dim Gname
Para cada gName em Arrayn
Se str = gname então
IsValidValue = true
Saída para
Final se
Próximo
Função final
'********************************************
'Detecte se o número é válido
'********************************************
Função isinteger (parágrafo)
Isinteger = false
Se não (isnull (para) ou acabamento (para) = ou não é numérico (para)) então
Isinteger = true
Final se
Função final
'********************************************
Detecção de nome de usuário
'********************************************
Função isvalidusername (nome de usuário byval)
em erro de erro em seguida
Dim i, c
Dim VuSername
IsValidUserName = true
Para i = 1 a Len (nome de usuário)
c = lcase (Mid (nome de usuário, i, 1))
Se Instr (! <>?#^%@~ `&*();:+= ', C)> 0 então
IsValidUserName = false
Função de saída
Final se
Próximo
Para cada nome de vusengo em Register_username
Se nome de usuário = nome de vusengo então
IsValidUserName = false
Saída para
Final se
Próximo
Função final
'********************************************
'Verifique se o endereço de e-mail é válido
'********************************************
Função isvalidemail (email)
Nomes escuros, nome, i, c
IsValidemail = true
Nomes = Split (email, @)
Se ubound (nomes) <> 1 então
IsValidemail = false
Função de saída
Final se
Para cada nome em nomes
Se Len (nome) <= 0 então
IsValidemail = false
Função de saída
Final se
Para i = 1 a len (nome)
c = lcase (MID (nome, i, 1))
Se Instr (abcdefghijklmnopqrstuvwxyz_-., C) <= 0 e não é numérico (c) então
IsValidemail = false
Função de saída
Final se
Próximo
Se esquerdo (nome, 1) =. ou certo (nome, 1) =. Então
IsValidemail = false
Função de saída
Final se
Próximo
Se Instr (nomes (1) ,.) <= 0 então
IsValidemail = false
Função de saída
Final se
i = len (nomes (1)) - Instrrev (nomes (1) ,.)
Se eu <> 2 e eu <> 3 então
IsValidemail = false
Função de saída
Final se
Se Instr (email, ..)> 0 Então
IsValidemail = false
Final se
Função final
'********************************************
'Destaque palavras -chave
'********************************************
Função Destaque (Byval StrContent, Byref Arraywords)
Dim IntCounter, STRTemp, Intpos, IntTagLength, IntkeyWordLength, Bupdate
Se Len (Arraywords) <1 então destaque = strContent: Função de saída
Para intpos = 1 a len (strContent)
bupdate = false
Se MID (STRCONTENT, INTPOS, 1) = <então
Em erro de erro em seguida
inttagLength = (Instr (intpos, strContent,>, 1) - Intpos)
Se errar então
destaque = strContent
err.clear
final se
strTemp = strTemp & Mid (strContent, intpos, inttagLength)
intpos = intpos + inttagLength
Final se
Se as palavras de Array <> então
intkeywordLength = len (Arraywords)
Se lcase (médio (strContent, intpos, intkeywordLength)) = lcase (Arraywords) então
strTemp = strtemp & <span class = high1> & mid (strContent, intpos, intkeywordLength) & </span>
intpos = intpos + intkeywordLength - 1
bupdate = true
Final se
Final se
Se bupdate = false então
strTemp = strTemp & Mid (strContent, intpos, 1)
Final se
Próximo
destaque = strtemp
Função final
Compartilhar: Coleção útil de funções no desenvolvimento de ASP (3) Uma coleção de funções úteis no desenvolvimento do ASP é bastante útil, por favor, mantenha -o! '*****************************************