home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 23 / IOPROG_23.ISO / SOFT / TCPIP.EXE / trace.asp < prev    next >
Encoding:
Text File  |  1998-08-31  |  8.7 KB  |  223 lines

  1. <%
  2. server.scripttimeout=240
  3. on error resume next
  4. Dim Trace, DNS
  5. Set Trace = CreateObject("TCPIP.Trace")
  6. Set DNS = CreateObject("TCPIP.DNS")
  7.  
  8. Dim I, IP, RoundTripTime, Status, TTL, TracedHost, bDNS, Checked, Hops, Bytes
  9. TracedHost = request("Host")
  10. If TracedHost = "" And InStr(UCase(request.servervariables("QUERY_STRING")), "HOST") = 0 Then TracedHost = request.servervariables("QUERY_STRING")
  11. If TracedHost = "" Then TracedHost = request.servervariables("REMOTE_ADDR")
  12.  
  13. bDNS = request("DNS")
  14. If bDNS = "N" Then Checked = " checked"
  15. Hops = request("Hops")
  16. If IsNumeric(Hops) Then Hops = CLng(Hops) Else Hops = 0
  17. If Hops = 0 Then Hops = 20
  18. Bytes = request("Bytes")
  19. If IsNumeric(Bytes) Then Bytes = CLng(Bytes) Else Bytes = 0
  20. If Bytes = 0 Then Bytes = 0
  21. Timeout = request("TimeOut")
  22. If IsNumeric(Timeout) Then Timeout = CLng(Timeout) Else Timeout = 0
  23. If Timeout = 0 Then Timeout = 5000
  24.  
  25. function isIP(Co)
  26. dim C, xIs, OneC
  27. xIs=True
  28.     for c=1 to len(co)
  29.         OneC=mid(co,c,1)
  30.         if not ((onec>="0" and onec<="9") or (onec=".")) then xIs=False
  31.     next
  32. isIP = xIs
  33. end function
  34. LOCAL_ADDR = request.servervariables("LOCAL_ADDR")
  35. ShowFrom = LOCAL_ADDR & " (" & GetHost(LOCAL_ADDR) & ")"
  36.  
  37. 'response.write ":" & GetIP(TracedHost)
  38. if not isIP(TracedHost) then 
  39.     on error resume next
  40.     IP = dns.GetIPByHost(TracedHost)
  41.     if Err<>0 then None = True
  42.     on error goto 0
  43. end if
  44. if isIP(TracedHost) then ShowTo = TracedHost & " (" & GetHost(TracedHost) & ")" else ShowTo = GetIP(TracedHost) & " (" & TracedHost & ")" 
  45. Response.write "<html><head><title>TraceRoute from " & ShowFrom & " to " & ShowTo & "</title></head><body  BGPROPERTIES=FIXED BGCOLOR=WHITE LINK=RED VLINK=BLUE ALINK=GREEN>"
  46. Response.write "<center>"
  47. if None then'None
  48.     Response.write "<h4>Host not found - " & ShowTo  & "</h4>"
  49. else'None-OK
  50.     Response.write "<h4>TraceRoute from " & ShowFrom & " to " & ShowTo  & "</h4>"
  51.  
  52.  
  53. Response.write "<form>Trace to : <input name=Host value=""" & TracedHost & """>"
  54. Response.write "<input Value=Trace type=Submit><br>"
  55. Response.write "Maximum hops : <input size=3 name=Hops value=""" & Hops & """> "
  56. '  response.write "ytes : <input size=5 name=Bytes value=""" & Bytes & """>"
  57. Response.write "TimeOut [ms] : <input size=5 name=TimeOut value=""" & Timeout & """>"
  58. Response.write "<input name=DNS value=N type=checkbox" & Checked & "> No DNS "
  59.  
  60. Response.write "</form>"
  61.  
  62. Response.write "<pre>"
  63. '  response.write "<hr size=0>"
  64. Response.write OneStep("", "IP", "Time", "TTL", "Status", "Host")
  65. Trace.Timeout = Timeout
  66. Trace.RequestSize = 0
  67.  
  68. dim EndStep
  69. EndStep = 30
  70. For I = 1 To Hops
  71.     On Error Resume Next
  72.     IP = Trace.OneStep(I, TracedHost)
  73.     If Err Then
  74.       If Trace.Status = 11010 Then
  75.           Host = "Request timed out."
  76.         Desc = "*"
  77.       Else
  78.         Desc = Err.Description
  79.           Host = GetHost(IP)
  80.         I = 100
  81.       End If
  82.     
  83.       Response.write OneStep(I , IP, Desc, Trace.TTL, Trace.Status, Host)
  84.     Else
  85.       Response.write OneStep(I, IP, Trace.RoundTripTime, Trace.TTL, Trace.Status, GetHost(IP))
  86.     End If
  87.     If Trace.Status = 0 Then 
  88.       EndStep = I
  89.       I = 100
  90.     end if
  91.     On Error GoTo 0
  92. Next
  93.  
  94. Response.write "</pre>"
  95. dim vBandwidth
  96. vBandwidth = BandWidth(EndStep, TracedHost)
  97. if vBandwidth>0 then response.write "Bandwidth from " & ShowFrom & " to " & ShowTo & " : <b>" & formatnumber(vBandwidth,3)  & "</b> kb/s"
  98.  
  99.  
  100. dim BandWidthStep
  101. BandWidthStep = 0
  102. function BandWidth( Hop, TracedHost )
  103.   Trace.TimeOut = 30000
  104.  
  105.   dim IP
  106.   DIM ZeroTime, DataTime, DataSize
  107.   Trace.RequestSize = 0
  108.   IP = Trace.OneStep(Hop, TracedHost)
  109.   ZeroTime = Trace.RoundTripTime
  110.  
  111.   on error resume next
  112.   Trace.RequestSize = 2000
  113.   IP = Trace.OneStep(Hop, TracedHost)
  114.   DataTime = Trace.RoundTripTime
  115.   DataSize = Trace.DataSize
  116.   if Trace.RoundTripTime<1000 and Err=0 then
  117.     Trace.RequestSize = 10000
  118.     IP = Trace.OneStep(Hop, TracedHost)
  119.     if Err=0 then 
  120.       DataTime = Trace.RoundTripTime
  121.       DataSize = Trace.DataSize
  122.       if Trace.RoundTripTime<1000 and Err=0 then
  123.         Trace.RequestSize = 60000
  124.         IP = Trace.OneStep(Hop, TracedHost)
  125.         if Err=0 then 
  126.           DataTime = Trace.RoundTripTime
  127.           DataSize = Trace.DataSize
  128.         end if
  129.       end if
  130.     end if
  131.   end if
  132.   on error goto 0
  133.  
  134.   if ZeroTime<DataTime then DataTime = DataTime - ZeroTime
  135.   if "" & BandWidthStep="" then BandWidthStep=1
  136.   if (DataTime = 0) and (BandWidthStep < 3) then
  137.     BandWidthStep = BandWidthStep +1
  138.     BandWidth = BandWidth( Hop, TracedHost )
  139.   end if
  140.   if DataTime>0 then
  141.     BandWidth = (1000/1024) * DataSize/DataTime*2*8
  142.   end if
  143.   Trace.RequestSize = 0
  144. end function
  145.  
  146. Response.write "</CENTER>"
  147.  
  148.  
  149. end if'OK
  150.  
  151. Response.write "<hr color=silver size=0><font size=1>ActiveX TraceRoute from <a href=http://www.pstruh.cz target=_top>PSTRUH Software</a></font>"
  152. Response.write "</body></html>"
  153.  
  154.  
  155.  
  156. Function GetHost(IP)
  157.   If bDNS = "N" Then
  158.     GetHost = "-"
  159.   Else
  160.     On Error Resume Next
  161.       GetHost = DNS.GetHostByIP(IP)
  162.       If Err Then GetHost = Err.Description
  163.     On Error GoTo 0
  164.   End If
  165. End Function
  166.  
  167. Function GetIP(Host)
  168.   If bDNS = "N" Then
  169.     GetIP = "-"
  170.   Else
  171.     On Error Resume Next
  172.       GetIP = DNS.GetIPByHost(Host)
  173.       If Err Then GetHost = Err.Description
  174.     On Error GoTo 0
  175.   End If
  176. End Function
  177.  
  178. Function ToSize(Co, ByVal Size)
  179.   Dim Kolik
  180.   Kolik = Size - Len(Co)
  181.   If Kolik < 0 Then Kolik = 0
  182.   ToSize = String(Kolik, "á") & Co
  183. End Function
  184.  
  185. Function ToSizeR(Co, ByVal Size)
  186.   Dim Kolik
  187.   Kolik = Size - Len(Co)
  188.   If Kolik < 0 Then Kolik = 0
  189.   ToSizeR = Co & String(Kolik, "á")
  190. End Function
  191.  
  192. Function OneStep(Step, IP, RoundTripTime, TTL, Status, Host)
  193.   Dim HTML
  194.   ' HTML = HTML & "<pre>"
  195.   HTML = HTML & "<hr size=0>"
  196.   HTML = HTML & ToSize(Step, 3)
  197.   HTML = HTML & ToSize(ToSizeR(IP, 15), 17)
  198.   HTML = HTML & ToSize(RoundTripTime, 6)
  199.   HTML = HTML & ToSize(TTL, 6)
  200. '  HTML = HTML & ToSize(Status,6)
  201.   HTML = HTML & ToSize(Host, 50)
  202.   OneStep = HTML
  203. End Function
  204.  
  205.  
  206. '<center>
  207. '<table border=0 cellspacing=0 cellpadding=1 bgcolor="#0000FF"><tr><td> 
  208. '<table border=0 cellspacing=0 cellpadding=0><tr><td> 
  209. '<a href="http://banner.linkexchange.com/1/X566848/clickbanner" 
  210. 'target="_top"><img width=468 height=60 border=0 ismap src="http://banner.linkexchange.com/1/X566848/showbanner?free"></a></td>
  211. '</tr><tr><td><a href="http://banner.linkexchange.com/1/X566848/clickbar" 
  212. 'target="_top"><img width=468 height=16 border=0 ismap lowsrc="http://banner.linkexchange.com/blankbar.gif" 
  213. 'src="http://banner.linkexchange.com/1/X566848/showbar?free"></a></td>
  214. '</tr></table></td></tr></table>  
  215. '</center>
  216. '<TABLE BORDER=0 CELLPADDING=1 CELLSPACING=2 WIDTH="100%"><TR><TH ALIGN=LEFT NOWRAP width=20% bgcolor=silver>á<A HREF=http://www.pstruh.cz/help/usrmgr/library.htm>UserManager</A></TH><TD WIDTH="80%">á</TD></TR><TR><TD COLSPAN=2><BLOCKQUOTE>Contains simple objects for creating, deleting, managing and enumerating user accounts and groups. Allows remove and add users to a group and logon to the the Account Operator. <i>Samples for VB, IE and ASP.</i></BLOCKQUOTE></TD></TR></TABLE>
  217. '<TABLE BORDER=0 CELLPADDING=1 CELLSPACING=2 WIDTH="100%"><TR><TH ALIGN=LEFT NOWRAP width=20% bgcolor=silver>á<A HREF=http://www.pstruh.cz/help/RSConv/library.htm>RSConvert</A></TH><TD WIDTH="80%">á</TD></TR><TR><TD COLSPAN=2><BLOCKQUOTE>RSConvert is a control for converting DAO or ADO recordsets to DBF files. It allows direct output of DBF files from ASP pages. The format of the Currency, Double, and Single fields can be customized.</BLOCKQUOTE></TD></TR></TABLE>
  218.  
  219. '<TABLE BORDER=0 CELLPADDING=1 CELLSPACING=2 WIDTH="100%"><TR><TH ALIGN=LEFT NOWRAP width=20% bgcolor=silver>á<A HREF=http://www.pstruh.cz/el/enhlog.hqs>EnhancedLog for MS IIS</A></TH><TD WIDTH="80%">á</TD></TR><TR><TD COLSPAN=2><BLOCKQUOTE>IIS ISAPI addin - allow redirect/customize error messages (401 Access denied, 404 Not found, ... ), custom error for each file/directory, extended logging (HTTP_REFERER, HTTP_USER_AGENT, HTTP_COOKIE), RAW data logging (IN and OUT), POST data logging, unique cookie.</BLOCKQUOTE></TD></TR></TABLE>
  220. '<TABLE BORDER=0 CELLPADDING=1 CELLSPACING=2 WIDTH="100%"><TR><TH ALIGN=LEFT NOWRAP width=20% bgcolor=silver>á<A HREF=http://www.pstruh.cz/help/tcpip/library.htm>TCPIP</A></TH><TD WIDTH="80%">á</TD></TR><TR><TD COLSPAN=2><BLOCKQUOTE>Object for simple IP adress and host name resolution, ASP and VB TraceRoute.</BLOCKQUOTE></TD></TR></TABLE>
  221. '<TABLE BORDER=0 CELLPADDING=1 CELLSPACING=2 WIDTH="100%"><TR><TH ALIGN=LEFT NOWRAP width=20% bgcolor=silver>á<A HREF=http://www.akcie.cz/util/stat/Default.asp?x=&DateType=1&Server=2>Access statistics for www.pstruh.cz</A></TH><TD WIDTH="80%">á</TD></TR><TR><TD COLSPAN=2><BLOCKQUOTE> </BLOCKQUOTE></TD></TR></TABLE>
  222. %>
  223.