Olá pessoal!
Acompanharemos nesta matéria um sisteminha
para busca e informações de qualquer domínio
.com.br ou dos internacionais (.com, .net e .org). Em ASP.
Todo o código do arquivo .ASP está
comentado abaixo e pronto para ser utilizado. O sistema, em funcionamento,
você pode acompanhar aqui.
O sistema foi enviado pelo usuário 1Sys
do Fórum ASP iMasters
Código:
<% Option Explicit %>
<%
‘Fixa a resposta True
ou false
Response.Buffer = False
‘ Fixa o intervalo do
script a 90 segundos
Server.ScriptTimeout = 90
‘funcionam para examinar
o servidor de buscas
Private Function whoisResult(whoisURL, strMethod, strResultsStart,
strResultsEnd)
‘Dimensões da variavél
Dim objXMLHTTP ‘Holds the XML HTTP Object
Dim strWhoisResultString ‘Holds the reult of the whois query
‘ Cria um objeto de XML
para examinar o servidor de buscas remoto
Set objXMLHTTP = Server.CreateObject("Microsoft.XMLHTTP")
‘componente alternativo,
para versão 3.0 de XMLHTTP
‘Set objXMLHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")
‘Abre uma conexão
com o servidor de busca
objXMLHTTP.Open strMethod, whoisURL, False
‘Envia o pedido e devolve
os dados
objXMLHTTP.Send
‘Coloca a resposta do
registro da busca
strWhoisResultString = objXMLHTTP.ResponseText
‘Se o nome do domínio
é curto fala que é inválido
If Len(strDomainName) < 3 Then
‘Não mostar o resultado
de retorno da função para válido
whoisResult = "O domínio não e válido
– deve ser pelo menos 3 caráters"
‘Outros erros
ElseIF InStr(1, strWhoisResultString, "Error", vbTextCompare)
Then
‘Mostra o resultado do
retorno da função
whoisResult = "Um erro ocorreu"
‘Else there was a result
Else
‘Strip the whois result leaving
the data we want
whoisResult = resultFormater(strWhoisResultString, strResultsStart,
strResultsEnd)
End If
‘Clean up
Set objXMLHTTP = Nothing
End Function
‘Function to strip all non estential returned input
Private Function resultFormater(strWhoisResultString, strResultsStart,
strResultsEnd)
‘Dimension variables
Dim lngResultsStartPos
Dim lngResultsEndPos
‘Find the start position
in the returned data of the result
lngResultsStartPos = InStr(1, strWhoisResultString, strResultsStart,
1) + Len(strResultsStart)
‘Find the end position in
the returned data of the result
lngResultsEndPos = InStr(lngResultsStartPos, strWhoisResultString,
strResultsEnd, 1)
‘Make sure the end position
is not in error
If lngResultsEndPos – lngResultsStartPos =< Len(strResultsStart)
Then lngResultsEndPos = lngResultsStartPos + Len(strResultsStart)
‘Now we know the start and
end position of the result, strip the rest and return the result
resultFormater = Trim(Mid(strWhoisResultString, lngResultsStartPos,
(lngResultsEndPos – lngResultsStartPos)))
End Function
‘Function to strip non alphanumeric characters
Private Function characterStrip(strTextInput)
‘Variáveis de dimensão
Dim intLoopCounter ‘Holds the loop counter
‘Loop through the ASCII characters
up to – hyphen
For intLoopCounter = 0 to 44
strTextInput = Replace(strTextInput, CHR(intLoopCounter), "",
1, -1, 0)
Next
‘Olha caráters
de ASCII para caracaters numéricos
For intLoopCounter = 46 to 47
strTextInput = Replace(strTextInput, CHR(intLoopCounter), "",
1, -1, 0)
Next
‘Loop through the ASCII characters
numeric characters to lower-case characters
For intLoopCounter = 58 to 96
strTextInput = Replace(strTextInput, CHR(intLoopCounter), "",
1, -1, 0)
Next
‘Olha os caráters
de ASCII estendidos
For intLoopCounter = 123 to 255
strTextInput = Replace(strTextInput, CHR(intLoopCounter), "",
1, -1, 0)
Next
‘Retorna a string
characterStrip = strTextInput
End Function
‘Variáveis de dimensão
Dim strDomainName ‘Holds the domain name to search for
Dim strSuffix ‘Holds the domain name suffix to search
‘Ler o nome do domínio
a ser procurarado
strDomainName = Trim(Request.QueryString("domain"))
strSuffix = Trim(Request.QueryString("suffix"))
‘Se um nome de domínio
foi colocado retira qualquer caráter não desejado
If strDomainName <> "" Then
‘Converte o nome de domínio
para conferir, para minúscula
strDomainName = LCase(strDomainName)
‘Remove o www e http da
frente
strDomainName = Replace(strDomainName, "http://", "",
1, -1, 1)
strDomainName = Replace(strDomainName, "www.", "",
1, -1, 1)
‘Remove os sufixos
strDomainName = Replace(strDomainName, ".com", "",
1, -1, 1)
strDomainName = Replace(strDomainName, ".net", "",
1, -1, 1)
strDomainName = Replace(strDomainName, ".org", "",
1, -1, 1)
strDomainName = Replace(strDomainName, ".com.br", "",
1, -1, 1)
‘Remove qualquer um dos
primeiro e últimos caráters
If Left(strDomainName, 1) = "-" Then strDomainName =
Mid(strDomainName, 2, Len(strDomainName))
If Right(strDomainName, 1) = "-" Then strDomainName
= Mid(strDomainName, 1, Len(strDomainName)-1)
‘Retira o caracters em
dobro
strDomainName = Replace(strDomainName, "–", "-",
1, -1, 1)
‘Retira todos os caracters
alphanumericos
strDomainName = characterStrip(strDomainName)
End If
%>
link="#0000CC" vlink="#0000CC" alink="#FF0000">
name="frmDomainCheck" action="busca.asp">
width="500" align="center">
rowspan="3" valign="middle">
rowspan="3" valign="middle">
Entre com o nome do domínio:
www.
size="20" value="<% = strDomainName %>">
name="submit">
valign="top">
<%
‘If a domain name is enterd check it
If strDomainName <> "" Then
‘Display the avialbility
Response.Write("O resultado da sua busca para o
domínio foi www." & strDomainName & strSuffix
& "")
‘Call the domain checking
function depending on domain suffix
‘Check for .com
If strSuffix = ".com" Then
Response.Write(whoisResult("http://reports.internic.net/cgi-bin/whois?whois_nic="
& strDomainName & ".com&type=domain", "GET",
"", "
"))
‘check for .net
ElseIf strSuffix = ".net" Then
Response.Write(whoisResult("http://reports.internic.net/cgi-bin/whois?whois_nic="
& strDomainName & ".net&type=domain", "GET",
"", "
"))
‘Check for .org
ElseIf strSuffix = ".org" Then
Response.Write(whoisResult("http://reports.internic.net/cgi-bin/whois?whois_nic="
& strDomainName & ".org&type=domain", "GET",
"", "
"))
ElseIf strSuffix = ".com.br"
Then
Response.Write(whoisResult("http://registro.br/cgi-bin/nicbr/whois?qr="
& strDomainName & ".com.br&type=domain",
"GET", "", "
"))
End If
‘Finsh the red span tag
Response.Write("")
End If
%>
Sistema retirado do site
href="http://www.webwizguide.info">
http://www.webwizguide.info
E modificado por 1sys