Consolidated ASP Classic MVC framework from best components
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

115 lines
3.0KB

  1. <%
  2. 'protocol = IIf(LCase(Request.ServerVariables("HTTPS")) = "1", "https", "http")
  3. protocol = "https"
  4. Dim timeZones
  5. timeZones = Array( _
  6. Array("America/New_York", "Eastern (New York)"), _
  7. Array("America/Chicago", "Central (Chicago)"), _
  8. Array("America/Denver", "Mountain (Denver)"), _
  9. Array("America/Los_Angeles", "Pacific (Los Angeles)"), _
  10. Array("Europe/London", "London (UK)") _
  11. )
  12. Function RequestBinary()
  13. On Error Resume Next
  14. Dim stream, rawData
  15. If Request.TotalBytes = 0 Then
  16. RequestBinary = ""
  17. Exit Function
  18. End If
  19. Set stream = Server.CreateObject("ADODB.Stream")
  20. stream.Type = 1 ' adTypeBinary
  21. stream.Open
  22. stream.Write Request.BinaryRead(Request.TotalBytes)
  23. stream.Position = 0
  24. stream.Type = 2 ' adTypeText
  25. stream.Charset = "utf-8"
  26. rawData = stream.ReadText
  27. stream.Close
  28. Set stream = Nothing
  29. If Err.Number <> 0 Then
  30. rawData = ""
  31. Err.Clear
  32. End If
  33. On Error GoTo 0
  34. RequestBinary = rawData
  35. End Function
  36. Function ArrayContains(arr, val)
  37. Dim i
  38. ArrayContains = False
  39. If IsArray(arr) Then
  40. For i = LBound(arr) To UBound(arr)
  41. If arr(i) = val Then
  42. ArrayContains = True
  43. Exit Function
  44. End If
  45. Next
  46. End If
  47. End Function
  48. Function RenderPOBOArrayAsJson(pobo)
  49. Dim i, j, obj, propList, propName, json, propVal, line,poboArray
  50. if IsLinkedList(pobo) Then
  51. poboArray = pobo.TO_Array()
  52. End If
  53. json = "["
  54. If IsEmpty(poboArray) Then
  55. RenderPOBOArrayAsJson = "[]"
  56. Exit Function
  57. End If
  58. For i = 0 To UBound(poboArray)
  59. Set obj = poboArray(i)
  60. propList = obj.Properties
  61. line = "{"
  62. For j = 0 To UBound(propList)
  63. propName = propList(j)
  64. ' Dynamically get value using Execute
  65. Execute "propVal = obj." & propName
  66. Select Case VarType(propVal)
  67. Case vbString
  68. line = line & """" & propName & """:""" & JsonEscape(propVal) & """"
  69. Case vbBoolean
  70. line = line & """" & propName & """:" & LCase(CStr(propVal))
  71. Case vbDate
  72. line = line & """" & propName & """:""" & Replace(CStr(propVal), """", "") & """"
  73. Case vbNull
  74. line = line & """" & propName & """:null"
  75. Case Else
  76. line = line & """" & propName & """:" & CStr(propVal)
  77. End Select
  78. If j < UBound(propList) Then
  79. line = line & ","
  80. End If
  81. Next
  82. line = line & "}"
  83. If i < UBound(poboArray) Then line = line & ","
  84. json = json & line
  85. Next
  86. json = json & "]"
  87. RenderPOBOArrayAsJson = json
  88. End Function
  89. Function JsonEscape(str)
  90. str = Replace(str, "\", "\\")
  91. str = Replace(str, """", "\""")
  92. str = Replace(str, vbCrLf, "\n")
  93. str = Replace(str, vbLf, "\n")
  94. str = Replace(str, vbCr, "\n")
  95. str = Replace(str, Chr(9), "\t")
  96. JsonEscape = str
  97. End Function
  98. %>

Powered by TurnKey Linux.