aCGI: WhoIs Example
Used in conjunction with the aSocks TCP/IP Library by Apareon

Return

  • This example of the aCGI Library uses the aSocks TCP/IP Library to contact the desired WhoIs provider and return the results to the User via a Results Web page.
Sample WhoIs Search:
Who Is Server:
Search For:

Source Code for the Search.      Bolded items are specific to the Library
//**********************************
Function Main( )
//**********************************
  Local oCGI := aprCGI():New()
  Local cRet := "", cTitle := ""
  Local nPort := 43, nBeg := 0, nEnd := 0
  Local SrvrWhoIs := oCGI:getVar( "cServer" )
  Local cString   := oCGI:getVar( "cDomain" )
  Local oWhoIs := aprWhoIs():New(ASOCKS_LICENSE_KEY, CSTOOLS_LICENSE_KEY)
  If ":"$SrvrWhoIs                                           // :Port Passed
    nPort     := Val(Substr(SrvrWhoIs,RAt(":",SrvrWhoIs)+1)) // Get PORT
    SrvrWhoIs := Substr(SrvrWhoIs,1,RAt(":",SrvrWhoIs)-1)    // Strip PORT
  EndIF
  nPort := iif(ValType(nPort) <> "N", 43, nPort)
  nBeg  := Seconds()
  if oWhoIs:Connect(SrvrWhoIs,nPort,15) <> -1
    If oWhoIs:Search(cString)
      cRet = oWhoIs:Read()
    else
      cRet := "Who Is Search Failed with "+oWhoIs:cErr
    Endif
  Else
    cRet := "Who Is Server Connection Failed with "+oWhoIs:cErr
  Endif
  nEnd := Seconds()
  oWhoIs:Destroy()
  cTitle := "aCGI WhoIs Demo:"+cString
  oCGI:Start("text/html")
  oCGI:Header(cTitle)
  oCGI:Body()
  oCGI:TableStart("Center",,,0,10,0)
  oCGI:Row(oCGI:BackLink("Go Back", "#660000",.F.,.F.),"RIGHT")
  oCGI:Row('<font color="#669900" size="3">'+cTitle+'</font>')
  oCGI:Row(StrTran(StrTran(cRet,CR_LF,Chr(10)),Chr(10),"<br>"+CR_LF))
  oCGI:Row(oCGI:BackLink("Go Back", "#660000",.F.,.F.),"Center")
  oCGI:TableEnd()
  oCGI:Footer()
  oCGI:Destroy()
Return (.T.)

Home | aCGI Library | Examples | Contact Info


for Questions or Comments about this Web Site, Send mail to Webmaster@Hou-Pro.com
Copyright 1995-2013 Houston Area Professionals