Recomendado: a função geral da ASP para determinar se o valor do banco de dados está vazio Devido a diferentes propriedades de vários campos, os métodos para determinar se um campo está vazio também são diferentes. A seguir, é apresentada uma função geral, que evita a dor do tipo de campo. 'Verifique uma variável não é a função vazia isblank (byref tempvar)' por padrão, suponha que não esteja em branco isblank = false 'agora verifique por variável t
Uma coleção de funções úteis no desenvolvimento do ASP é bastante útil, por favor, mantenha -o!
'********************************************
'Conteúdo de corte - dividido por linha
'********************************************
Funções de função (conteúdo BYVAL, BYVAL Contentnums)
Dim ts, i, l
ContentNums = int (Contentnums)
Se isNull (conteúdo), então a função de saída
i = 1
ts = 0
Para i = 1 a len (conteúdo)
l = lcase (MID (conteúdo, i, 5))
Se l = <br/> então
ts = ts+1
Final se
l = lcase (MID (conteúdo, i, 4))
Se l = <br> Então
ts = ts+1
Final se
l = lcase (MID (conteúdo, i, 3))
Se l = <p> então
ts = ts+1
Final se
Se ts> contentnums, então saia para
Próximo
Se ts> contentNums, então
Content = esquerda (conteúdo, i-1)
Final se
Splitlines = Conteúdo
Função final
'********************************************
'Conteúdo de corte - dividido por personagem
'********************************************
Função cutstr (byval str, byval strlen)
Dim L, T, C, i
Se isNull (str), então Cutstr =: Função de saída
l = len (str)
Strlen = int (strlen)
t = 0
Para i = 1 a l
C = ASC (MID (STR, I, 1))
Se c <0 ou c> 255, então t = t+2 else t = t+1
Se t> = strlen então
Cutstr = esquerda (str, i) ...
Saída para
Outro
Cutstr = str
Final se
Próximo
Função final
'********************************************
'Exclua a etiqueta de referência
'********************************************
Função delquote (strContent)
Se IsNull (strContent), então a função de saída
Dim re
Definir Re = novo regexp
re.IGNORECASE = true
re.global = true
re.Pattern =/[CITAÇÃO/].G.
strContent = re.Replace (strContent,)
re.pattern =/[QUOTE = (. [^/]]*)/] (.
strContent = re.Replace (strContent,)
Definir re = nada
Delquote = strContent
Função final
'********************************************
'Obtenha IP do cliente
'********************************************
função getip ()
Dim Strip, ip_ary, Strip_list
strip_list = substituir (request.servervariables (http_x_forwarded_for), ',),)
Se Instr (Strip_list ,,) <> 0 então
Ip_ary = split (Strip_list ,,)
tira = ip_ary (0)
Outro
tira = strip_list
Final se
Se tira = vazio então tira = substituir (request.Servervariables (remote_addr), ',)
getip = tira
Função final
Este artigo é coletado e compilado pela casa de design
'********************************************
'Obtenha informações do navegador do cliente
'********************************************
função getBrowser (strua)
Dim Arrinfo, Strtype, Temp1, Temp2
strtype =
stua = lcase (strua)
Arrinfo = Array (Unkown, Unkown)
'Julgamento do navegador
Se Instr (Strua, Mozilla)> 0 então arrinfo (0) = mozilla
Se Instr (Strua, ICAB)> 0 então arrinfo (0) = icAB
Se Instr (Strua, Lynx)> 0 então arrinfo (0) = lynx
Se Instr (Strua, Links)> 0 então arrinfo (0) = links
Se Instr (Strua, ELinks)> 0 então arrinfo (0) = elinks
Se Instr (Strua, JBrowser)> 0 então arrinfo (0) = jbrowser
Se Instr (Strua, Konqueror)> 0 então arrinfo (0) = KonQueror
Se Instr (Strua, Wget)> 0 então Arrinfo (0) = wget
Se Instr (Strua, pergunte a Jeeves)> 0 ou Instr (Strua, Teoma)> 0 Então arrinfo (0) = Ask Jeeves/Teoma
Se Instr (Strua, Wget)> 0 então Arrinfo (0) = wget
Se Instr (Strua, Opera)> 0 então arrinfo (0) = ópera
Se Instr (Strua, Gecko)> 0 então
strtype = [Gecko]
Arrinfo (0) = Mozilla
Se Instr (Strua, AOL)> 0 então arrinfo (0) = AOL
Se Instr (Strua, Netscape)> 0 então arrinfo (0) = Netscape
Se Instr (Strua, Firefox)> 0 então arrinfo (0) = Firefox
Se Instr (Strua, Chimera)> 0 então arrinfo (0) = Chimera
Se Instr (Strua, Camino)> 0 então arrinfo (0) = Camineo
Se Instr (Strua, Galeon)> 0 então Arrinfo (0) = Galeon
Se Instr (Strua, K-Meleon)> 0 então arrinfo (0) = k-meleon
Arrinfo (0) = arrinfo (0)+strtype
final se
Se Instr (Strua, Bot)> 0 ou Instr (Strua, Crawl)> 0 Então
strtype = [bot/rastreador]
Arrinfo (0) =
Se Instr (Strua, Grub)> 0 então arrinfo (0) = Grub
Se Instr (Strua, Googlebot)> 0 então Arrinfo (0) = Googlebot
Se Instr (Strua, MSNBOT)> 0 Então Arrinfo (0) = Msn Bot
Se Instr (Strua, Slurp)> 0 então arrinfo (0) = Yahoo! Slurp
Arrinfo (0) = arrinfo (0)+strtype
final se
Se Instr (Strua, Applewebkit)> 0 então
strtype = [Applewebkit]
Arrinfo (0) =
Se Instr (Strua, Omniweb)> 0 então arrinfo (0) = Omniweb
Se Instr (Strua, Safari)> 0 então arrinfo (0) = safari
Arrinfo (0) = arrinfo (0)+strtype
final se
Se Instr (Strua, MSIE)> 0 Então
strtype = [msie
Temp1 = Mid (Strua, (Instr (Strua, MSIE) +4), 6)
Temp2 = Instr (Temp1;)
temp1 = esquerda (temp1, temp2-1)
strtype = strtype & temp1]
Arrinfo (0) = Internet Explorer
Se Instr (Strua, MSN)> 0 então arrinfo (0) = msn
Se Instr (Strua, AOL)> 0 então arrinfo (0) = AOL
Se Instr (Strua, Webtv)> 0 então arrinfo (0) = webtv
Se Instr (Strua, Myie2)> 0 então arrinfo (0) = myie2
Se Instr (Strua, Maxthon)> 0 então arrinfo (0) = maxthon
Se Instr (Strua, Gosurf)> 0 então arrinfo (0) = Gosurf
Se Instr (Strua, NetCaptor)> 0 então arrinfo (0) = NetCaptor
Se Instr (Strua, Sleipnir)> 0 então arrinfo (0) = sleipnir
Se Instr (Strua, navegador de vanguarda)> 0 então Arrinfo (0) = Avantbrowser
Se Instr (Strua, Greenbrowser)> 0 então arrinfo (0) = GreenBrowser
Se Instr (Strua, Slimbrowser)> 0 então arrinfo (0) = slimbrowser
Arrinfo (0) = arrinfo (0)+strtype
final se
'Julgamento do sistema operacional
Se Instr (Strua, Windows)> 0 Então Arrinfo (1) = Windows
Se Instr (Strua, Windows CE)> 0 então arrinfo (1) = Windows CE
Se Instr (Strua, Windows 95)> 0 Então Arrinfo (1) = Windows 95
Se Instr (Strua, Win98)> 0 Então Arrinfo (1) = Windows 98
Se Instr (Strua, Windows 98)> 0 Então Arrinfo (1) = Windows 98
Se Instr (Strua, Windows 2000)> 0 Então Arrinfo (1) = Windows 2000
Se Instr (Strua, Windows XP)> 0 Então Arrinfo (1) = Windows XP
Se Instr (Strua, Windows NT)> 0 então
Arrinfo (1) = Windows nt
Se Instr (Strua, Windows NT 5.0)> 0 Então Arrinfo (1) = Windows 2000
Se Instr (Strua, Windows NT 5.1)> 0 Então Arrinfo (1) = Windows XP
Se Instr (Strua, Windows NT 5.2)> 0 Então Arrinfo (1) = Windows 2003
final se
Se Instr (Strua, X11)> 0 ou Instr (Strua, UNIX)> 0 Então Arrinfo (1) = Unix
Se Instr (Strua, Sunos)> 0 ou Instr (Strua, Sun OS)> 0 Então Arrinfo (1) = Sun OS
Se Instr (Strua, PowerPC)> 0 ou Instr (Strua, PPC)> 0 então arrinfo (1) = PowerPC
Se Instr (Strua, Macintosh)> 0 então Arrinfo (1) = Mac
Se Instr (Strua, Mac OSX)> 0 então arrinfo (1) = Macosx
Se Instr (Strua, FreeBSD)> 0 então arrinfo (1) = FreeBSD
Se Instr (Strua, Linux)> 0 então arrinfo (1) = Linux
Se Instr (Strua, Palmsource)> 0 ou Instr (Strua, Palmos)> 0 Então Arrinfo (1) = Palmos
Se Instr (Strua, WAP)> 0 então arrinfo (1) = wap
'Arrinfo (0) = Strua
getBrowser = arrinfo
Função final
'********************************************
'Computando números aleatórios
'********************************************
Função Randomstr (Intlength)
Strseed escuro, comprimento das mudas, pos, str, i
strseed = abcdefghijklmnopqrstuvwxyz1234567890
comprimento de alteração = len (strseed)
str =
Randomizar
para i = 1 para o comprimento
STR = STR+MID (Strseed, int (comprimento das mudas*rnd) +1,1)
próximo
Randomstr = str
Função final
'********************************************
'Fechado automaticamente o UBB
'********************************************
função closeubb (strcontent)
Dim Arrtags, I, OpenPos, Closepos, Re, Strmatchs, J, Match
Definir Re = novo regexp
re.IGNORECASE = true
re.global = true
Arrtags = Array (código, citação, lista, cor, alinhamento, fonte, tamanho, b, i, u, html)
para i = 0 para ubund (artags)
OpenPos = 0
Closepos = 0
re.pattern =/[+arrTags (i)+(= [^/[/]]+|)/]
Set strMatchs = re.execute (strContent)
Para cada partida em strmatchs
OpenPos = OpenPos+1
próximo
re.pattern =/[/+artags (i)+/]
Set strMatchs = re.execute (strContent)
Para cada partida em strmatchs
Closepos = Closepos+1
próximo
Para J = 1 para o OpenPos-Closepos
strContent = strContent+[/+artags (i)+]
próximo
próximo
Closeubb = strContent
Função final
'********************************************
'Feche automaticamente HTML
'********************************************
função closehtml (strContent)
Dim Arrtags, I, OpenPos, Closepos, Re, Strmatchs, J, Match
Definir Re = novo regexp
re.IGNORECASE = true
re.global = true
Arrtags = Array (P, Div, Span, Tabela, Ul, Fonte, B, U, I, H1, H2, H3, H4, H5, H6)
para i = 0 para ubund (artags)
OpenPos = 0
Closepos = 0
re.pattern =/<+arrTags (i)+([^/</>]+|)/
Set strMatchs = re.execute (strContent)
Para cada partida em strmatchs
OpenPos = OpenPos+1
próximo
re.pattern =/</+artags (i)+//>
Set strMatchs = re.execute (strContent)
Para cada partida em strmatchs
Closepos = Closepos+1
próximo
Para J = 1 para o OpenPos-Closepos
strContent = strContent+</+artags (i)+>
próximo
próximo
closehtml = strContent
Função final
'********************************************
'Leia o arquivo
'********************************************
Função loadfromfile (arquivo byval)
ObjStream dim
Dim Rtext
Rtext = matriz (0)
Em erro de erro em seguida
Set objStream = server.createObject (adodb.stream)
Se errar então
Rtext = array (err.number, err.description)
Loadfromfile = rtext
Err.clear
função de saída
Final se
Com objstream
.Type = 2
.Mode = 3
.Abrir
.CharSet = UTF-8
.Position = objStream.size
.Loadfromfile server.mappath (arquivo)
Se err.number <> 0 então
Rtext = array (err.number, err.description)
Loadfromfile = rtext
Err.clear
função de saída
Final se
Rtext = matriz (0, .readText)
.Fechar
Termine com
Loadfromfile = rtext
Definir objstream = nada
Função final
'********************************************
'Salve o arquivo
'********************************************
Função Savetofile (Byval Strbody, arquivo BYVAL)
ObjStream dim
Dim Rtext
Rtext = matriz (0)
Em erro de erro em seguida
Set objStream = server.createObject (adodb.stream)
Se errar então
Rtext = array (err.number, err.description)
Err.clear
função de saída
Final se
Com objstream
.Type = 2
.Abrir
.CharSet = UTF-8
.Position = objStream.size
.WriteText = strbody
.Savetofile Server.Mappath (arquivo), 2
.Fechar
Termine com
Rtext = array (0, salve o arquivo com sucesso!)
Savetofile = rtext
Definir objstream = nada
Função final
'********************************************
'Operação de modificação de adição de domínio
'********************************************
função dbQuest (tabela, dBarray, ação)
Dim addCount, tempdb, i, v
Se ação <> inserir ou ação <> atualizar então action = insert
se action = inserir então v = 2 else v = 3
se não isarray (dBarray) então
DbQuest = -1
função de saída
outro
Set tempdb = server.createObject (adodb.recordset)
Em erro de erro em seguida
Tabela tempdb.open, Conn, 1, v
Se errar então
DbQuest = -2
função de saída
final se
se action = inserir então tempdb.addnew
AddCount = ubound (dBarray, 1)
para i = 0 para addCount
Tempdb (dBarray (i) (0)) = dBarray (i) (1)
próximo
Tempdb.update
Tempdb.close
Defina tempdb = nada
DbQuest = 0
final se
Função final
'********************************************
'Verifique se os componentes do sistema estão instalados
'********************************************
Função checkObjInstalled (strclassString)
Em erro de erro em seguida
Dim temp
Err = 0
Dim tmpobj
Definir tmpobj = server.createObject (strclassString)
Temp = err
Se temp = 0 ou temp = -2147221477 Então
CheckObjInstalled = true
Elsef temp = 1 ou temp = -2147221005 então
CheckObjInstalled = false
Final se
Err.clear
Definir tmpobj = nada
Err = 0
Função final
'********************************************
'Judge Server Microsoft.xmldom
'********************************************
Função getxmldom
Em erro de erro em seguida
Dim temp
getxmldom = microsoft.xmldom
Err = 0
Dim tmpobj
Definir tmpobj = server.createObject (getxmldom)
Temp = err
Se temp = 1 ou temp = -2147221005 Então
getxmldom = msxml2.domdocument.5.0
Final se
Err.clear
Definir tmpobj = nada
Err = 0
Função final
'********************************************
'Judge Server MSXML2.ServerxMlHttp
'********************************************
Função getxmlHttp
Em erro de erro em seguida
Dim temp
getxmlHttp = msxml2.ServerxMlHttp
Err = 0
Dim tmpobj
Definir tmpobj = server.createObject (getxmlHttp)
Temp = err
Se temp = 1 ou temp = -2147221005 Então
getxmlHttp = msxml2.ServerxMlHttp.5.0
Final se
Err.clear
Definir tmpobj = nada
Err = 0
Função final
'********************************************
'Filtragem de palavras -chave de lixo
'********************************************
FUNÇÃO FILTERSPAM (STR, PATH)
em erro de erro em seguida
filterspam = false
Dim Spamxml, Spamitem
Definir spamxml = server.createObject (getxmldom)
Se errar então
Err.clear
função de saída
final se
spamxml.async = false
spamxml.load (server.mappath (caminho))
se spamxml.parseerror.errorcode = 0 então
Para cada spamitem em spamxml.selectnodes (// chave)
Se Instr (lcase (str), lcase (spamitem.text)) <> 0 então
filterspam = true
função de saída
final se
próximo
final se
Definir spamxml = nada
Função final
'*******************************************************************
'Objetivo: verifique o formulário regular
'Digite: id
'Retorno: o sucesso é verdadeiro
'*******************************************************************
Função checkRegexp (fonte, parágrafo)
Se para = [nome de usuário] então
para =^[. a-za-z0-9/u4e00-/u9fa5]+
Final se
Se para = [senha] então
para =^[a-z0-9]+
Final se
Se para = [email] então
para =^([0-9a-za-z] ([-./w]*[0-9a-za-z])*@([0-9a-za-z] [-/w]*/.)+[a-za-z]*)
Final se
Se para = [página inicial] então
para =^[a-za-z]+: // [a -za-z0-9 /-/./]+?/*
Final se
Se para = [nojapan] então
para = [/u3040-/u30ff]+
Final se
Se para = [GUID] então
para =^/w {8}/-/w {4}/-/w {4}/-/w {4}/-/w {4}/-/w {12}
Final se
Dim re
Definir re = novo regexp
re.global = true
re.pattern = parágrafo
re.IGNORECASE = FALSE
CheckRegexp = re.test (fonte)
Função final
'*****************************************************
'Pegue o número de pessoas online
'*****************************************************
função getOnline
getOnline = 1
Se Len (Application (Space_Cookiename_onlineCount))> 0 então
Se datdiff (S, Application (Space_Cookiename_UseronLineCountTime), agora ())> 60 então
Application.lock ()
APLICAÇÃO (SPACE_COOKIENAME_ONLINE) = APLICAÇÃO (SPACE_COOKIENAME_ONLINECOUNT)
APLICAÇÃO (SPACE_COOKIENAME_ONLINECOUNT) = 1
APLICAÇÃO (SPACE_COOKIENAME_ONLINECOUNTKEY) = Randstr (2)
APLICAÇÃO (SPACE_COOKIENAME_USERONLINECOUNTTIME) = agora ()
Application.unlock ()
outro
Se session (Space_CookienameUseRonlineKey) <> Application (Space_Cookiename_OnlineCountKey) então
Application.lock ()
Application (Space_Cookiename_onlineCount) = Application (Space_Cookiename_onlineCount) +1
Application.unlock ()
Session (Space_CookienameUseRonLineKey) = Application (Space_Cookiename_onLineCountKey)
final se
final se
outro
Application.lock
APLICAÇÃO (SPACE_COOKIENAME_ONLINE) = 1
APLICAÇÃO (SPACE_COOKIENAME_ONLINECOUNT) = 1
APLICAÇÃO (SPACE_COOKIENAME_ONLINECOUNTKEY) = Randstr (2)
APLICAÇÃO (SPACE_COOKIENAME_USERONLINECOUNTTIME) = agora ()
Application.unlock
final se
getOnline = Application (Space_cookiename_online)
Função final
%>
Este artigo é coletado e compilado pela casa de design
Compartilhar: asp exporta dados do banco de dados para a tabela Excel O código da instância do ASP exporta diretamente os dados no banco de dados para a planilha do Excel. !-#inclua arquivo = ../Conn.asp-- % Dim S, SQL, nome do arquivo, FS, MyFile, X Set FS = Server.CreateObject (scripting.filesystemoBject) '----você deseja que o arquivo excel generoso seja armazenado da seguinte forma Filename = Server.