-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaicc.asp
183 lines (145 loc) · 4.73 KB
/
aicc.asp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<% Response.Expires = 0 %>
<%
Dim fso, f, loc, logstring, data, logfile, datafile, s
Const ForReading = 1, ForWriting = 2, ForAppending = 8
loc = Server.MapPath(Request.ServerVariables("SCRIPT_NAME"))
Set fso = CreateObject("Scripting.FileSystemObject")
logfile = "logs/log.txt"
datafile = "data/data.txt"
logstring = ""
logstring = logstring & "--------------------------------------------" & vbCrLf
logstring = logstring & "Date/Time: " & Now & vbCrLf
logstring = logstring & "--------------------------------------------" & vbCrLf
If LCase(Request.Form("command")) <> "" then
logstring = logstring & "command: " & LCase(Request.Form("command")) & vbCrLf
End If
If LCase(Request.Form("session_id")) <> "" then
logstring = logstring & "session_id: " & LCase(Request.Form("session_id")) & vbCrLf
End If
If LCase(Request.Form("aicc_data")) <> "" then
logstring = logstring & "aicc_data:" & vbCrLf & LCase(Request.Form("aicc_data")) & vbCrLf
End If
%>
<%
If LCase(Request.Form("command")) = "getparam" Then
s = ""
set df = fso.getFile(fso.GetParentFolderName(loc) + "\/" + datafile)
If df.size > 0 then
Set f = fso.OpenTextFile(fso.GetParentFolderName(loc) + "\/" + datafile, ForReading, True)
s = f.ReadAll
f.Close
Set f = Nothing
End If
If s = "" Then
s = s&"error=0" & vbCrLf
s = s&"error_text=Successful" & vbCrLf
s = s&"version=2.0" & vbCrLf
s = s&"aicc_data=[core]" & vbCrLf
s = s&"student_id=demo" & vbCrLf
s = s&"student_name=demo" & vbCrLf
s = s&"output_file=" & vbCrLf
s = s&"lesson_location=null" & vbCrLf
s = s&"credit=no-credit" & vbCrLf
s = s&"lesson_mode=" & vbCrLf
s = s&"lesson_status=N" & vbCrLf
s = s&"time=00:00:00" & vbCrLf
s = s&"score=" & vbCrLf
s = s&"[Core_Lesson]" & vbCrLf
s = s&""
End If
logstring = logstring & "Data Returned:" & vbCrLf
logstring = logstring & "--------------------------------------------" & vbCrLf
logstring = logstring & s
logstring = logstring & "--------------------------------------------" & vbCrLf & vbCrLf
Response.Write s
ElseIf LCase(Request.Form("command")) = "putparam" Or LCase(Request.Form("command")) = "exitau" Then
s = ""
s = s&"error=0" & vbCrLf
s = s&"version=2.0" & vbCrLf
s = s&"aicc_data=" & vbCrLf
If LCase(Request.Form("command")) = "putparam" Then
s = s&Request.Form("aicc_data")
Set f = fso.OpenTextFile(fso.GetParentFolderName(loc) + "\/" + datafile, ForWriting, True)
f.Write s
f.Close
Set f = Nothing
Else
s = ""
s = s&"error=0" & vbCrLf
s = s&"version=2.0" & vbCrLf
s = s&"aicc_data=" & vbCrLf
End If
Response.Write s
End If
If LCase(Request.Form("command")) <> "" then
Set f = fso.OpenTextFile(fso.GetParentFolderName(loc) + "\/" + logfile, ForAppending, True)
f.Write logstring
f.Close
Set f = Nothing
End If
%>
<% If LCase(Request.Form("command")) <> "getparam" And LCase(Request.Form("command")) <> "putparam" And LCase(Request.Form("command")) <> "exitau" And Request.QueryString("command") = "" then %>
error=1
error_text=Unknown command
version=2.0
aicc_data=
<% End If %>
<%
If LCase(Request.QueryString("command")) = "getlog" then
set lf = fso.getFile(fso.GetParentFolderName(loc) + "\/" + logfile)
If lf.size > 0 then
Set f = fso.OpenTextFile(fso.GetParentFolderName(loc) + "\/" + logfile, ForReading, True)
s = f.ReadAll
f.Close
Set f = Nothing
Else
s = "Log file is empty!"
End If
Response.Write s
End If
%>
<%
If LCase(Request.QueryString("command")) = "getdata" then
set lf = fso.getFile(fso.GetParentFolderName(loc) + "\/" + datafile)
If lf.size > 0 then
Set f = fso.OpenTextFile(fso.GetParentFolderName(loc) + "\/" + datafile, ForReading, True)
s = f.ReadAll
f.Close
Set f = Nothing
Else
s = "Data file is empty!"
End If
Response.Write s
End If
%>
<%
If LCase(Request.QueryString("command")) = "clearlog" then
Set f = fso.OpenTextFile(fso.GetParentFolderName(loc) + "\/" + logfile, ForWriting, True)
f.Write ""
f.Close
Set f = Nothing
Response.Write "SUCCESS"
End If
%>
<%
If LCase(Request.QueryString("command")) = "cleardata" then
Set f = fso.OpenTextFile(fso.GetParentFolderName(loc) + "\/" + datafile, ForWriting, True)
f.Write ""
f.Close
Set f = Nothing
Response.Write "SUCCESS"
End If
%>
<%
If LCase(Request.QueryString("command")) = "test" then
logstring = ""
logstring = logstring & "--------------------------------------------" & vbCrLf
logstring = logstring & "AICC Script Test: " & Now & vbCrLf
logstring = logstring & "--------------------------------------------" & vbCrLf
Set f = fso.OpenTextFile(fso.GetParentFolderName(loc) + "\/" + logfile, ForAppending, True)
f.Write logstring
f.Close
Set f = Nothing
Response.Write "SUCCESS"
End If
%>