Consolidated ASP Classic MVC framework from best components
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

116 líneas
3.0KB

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

Powered by TurnKey Linux.