Note: This is not the complete source code--just the main source file.
You can download the full source (with include files) from our sample code archive by clicking on the diskette icons.
<%@ EnableSessionState=False LANGUAGE="VBSCRIPT" %> <% '// AspLookup sample script '// '// Demonstrates use of HexLookup '// (but not necessarily good programming style :) '// '// Copyright (C) 1998 Hexillion Technologies. All rights reserved. '// Option explicit Response.Buffer = false %> <!-- #include file="AuxFuncs.asp" --> <html> <head> <title>Hexillion AspLookup sample</title> </head> <body bgcolor="#FFFFFF" text="#000000" vlink="#808080" link="#0000FF"> <% dim oLkup, oTcpq, sAddr, sDefaultAddr set oLkup = Server.CreateObject( "Hexillion.HexLookup" ) sAddr = request( "addr" ) if "" <> sAddr then sDefaultAddr = sAddr else sDefaultAddr = oLkup.HostName end if %> <table cellpadding="5" width="100%"><tr> <td colspan="2" bgcolor="#E1EFFF"><font face="Arial" size="5"><strong>AspLookup sample</strong></font><br> Looks up IP addresses, both forward and reverse </td></tr> <tr> <td valign="top" bgcolor="#E1EFFF"> <form name="hostentry" method="POST" action="<%= request( "SCRIPT_NAME" ) %>"> <table cellpadding="5"> <tr><td align="right">address</td> <td><input type="text" name="addr" size="27" value="<%= Server.HtmlEncode( sDefaultAddr ) %>"> <input type="submit" value="Go" name="B1"></td></tr> </table> </form> </td> <td valign="top" bgcolor="#E1EFFF"> <table border="0" cellspacing="0" cellpadding="7"> <tr> <td colspan="2">powered by <b><a href="http://www.hexillion.com/software/" target="_top">HexGadgets</a></b> <br><font size="-1"> <a href="http://www.hexillion.com/samples/view_src.asp?name=AspLookup.asp" target="_blank">view source</a> | <a href="http://www.hexillion.com/samples/" target="_top">download</a> </font></td> </tr> <% WriteLicenseRow "HexLookup", oLkup %> </table> </td> </tr></table> <% if "" <> sAddr then Dim lAddr, bReverse, s '// Try forward lookup first lAddr = oLkup.LookUp( sAddr ) if 0 <> lAddr then '// If there aren't any domain aliases... if 0 = oLkup.Aliases.Count then '// The address must have been a dotted numeric address '// Do a reverse lookup instead s = oLkup.ReverseLookUp( lAddr ) bReverse = true end if if hexTcpqErrSuccess = oLkup.Error then dim sCname, sAliases, sAddrs dim l, lCount lCount = oLkup.Aliases.Count sCname = oLkup.Aliases( 1 ) for l = 2 to lCount sAliases = sAliases & Server.HtmlEncode( oLkup.Aliases( l ) ) & "<br>" next for each lAddr in oLkup.Addrs sAddrs = sAddrs & oLkup.AddrToString( lAddr ) & "<br>" next end if end if if hexTcpqErrSuccess <> oLkup.Error then %> <table cellpadding="5"> <tr> <td valign="baseline" align="right">lookup failed</td> <td valign="baseline"><tt><strong><%= Server.HtmlEncode( sAddr ) %></strong></tt></td> </tr> <tr> <td valign="baseline" align="right"> </td> <td valign="baseline"><tt><strong><%= Server.HtmlEncode( GetLkupErrorString( oLkup.Error ) ) %></strong></tt></td> </tr> </table> <% else %> <table border="0" cellpadding="5" cellspacing="0"> <tr> <td valign="baseline" align="right">canonical name</td> <td valign="baseline"><tt><strong><%= Server.HtmlEncode( sCname ) %></strong></tt></td> </tr> <tr> <td valign="baseline" align="right">aliases</td> <td valign="baseline"><tt><strong><%= sAliases %></strong></tt></td> </tr> <tr> <td valign="baseline" align="right">addresses</td> <td valign="baseline"><tt><strong><%= sAddrs %></strong></tt></td> </tr> </table> <% end if end if %> </body> </html>