You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

docs.asp 2.2KB

8 months ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <%
  2. Option Explicit
  3. Sub Main
  4. ShowFileList
  5. If Len(Request.Form("filename")) > 0 then
  6. ShowDocs
  7. End If
  8. End Sub
  9. Sub ShowFileList
  10. %>
  11. <h1>Select File</h1>
  12. <form action="docs.asp" method="POST">
  13. <select name="filename">
  14. <%
  15. dim fso : set fso = Server.CreateObject("Scripting.FileSystemObject")
  16. dim files : set files = fso.GetFolder(Server.MapPath(".")).Files
  17. dim file
  18. For Each file in files
  19. If fso.GetExtensionName(file.Path) = "asp" and file.Name <> "docs.asp" and InStr(file.Name, "_old") = 0 then
  20. response.write "<option value='" & file.Name & "'>" & file.Name & "</option>"
  21. End If
  22. Next
  23. %>
  24. </select>
  25. <input type="submit" value="Get Docs">
  26. </form>
  27. <hr>
  28. <%
  29. End Sub
  30. Sub ShowDocs
  31. dim fso : set fso = Server.CreateObject("Scripting.FileSystemObject")
  32. dim path : path = fso.GetFolder(Server.MapPath(".")).Path
  33. dim file : set file = fso.OpenTextFile(path & "\" & Request.Form("filename"))
  34. dim re : set re = new RegExp
  35. With re
  36. .Pattern = "Public Property|Public Sub|Public Function"
  37. .Global = true
  38. .IgnoreCase = true
  39. End With
  40. dim line, matches, result
  41. Do Until file.AtEndOfStream
  42. line = file.ReadLine()
  43. set matches = re.Execute(line)
  44. If matches.Count > 0 then
  45. result = line
  46. result = Replace(result, "Public Property", "<span class='subdued'>Property</span>")
  47. result = Replace(result, "Public Sub", "<span class='subdued'>Sub</span>")
  48. result = Replace(result, "Public Function", "<span class='subdued'>Function</span>")
  49. response.write "<p>" & result & "</p>"
  50. End If
  51. Loop
  52. End Sub
  53. %>
  54. <!doctype html>
  55. <html>
  56. <head>
  57. <style>
  58. body { font-family: calibri; }
  59. p { font-weight: bold; }
  60. .subdued { font-weight: normal; color: #999; }
  61. </style>
  62. </head>
  63. <body>
  64. <% Call Main %>
  65. </body>
  66. </html>

Powered by TurnKey Linux.