-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.lib
268 lines (201 loc) · 6.68 KB
/
functions.lib
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
expand file="/system/clearimage/DLL.lib" /expand
if reload="REQUEST" then
if companyid="ERROR" then companyid="Welcome.<br>Please wait while a customer service representative is contacted." /if
# These may be overwritten with values from chat_vars /#
typingmsg='[csrname] is typing a response.'
connectedtomsg='You have been connected to [csrname].'
disconnectedfrommsg='You have been disconnected from [csrname].'
notconnectedmsg='You are not in a chat session. Attempting to connect now.'
closestring='Disconnected - [now]'
mycomment=""
if chatid<>"" and chatid<>"ERROR" then
temp=breakconnect()
mydb='chats/comments'+chatid
if not(isfile(mydb+'.txt')) then
append '<div class="userinfo">'+companyid+'</div>'+lf to file=mydb+'.txt' /append
temp=sysfixprivate(mydb+'.txt')
/if
/if
copy file="/apps/livetalk/csrlist.csv" ts="," to csrlist /copy
copy file="/apps/livetalk/webbots.csv" ts="," to webbots /copy
copy file="/apps/livetalk/chat_vars.csv" ts="," to chat_vars /copy
for name=chat_vars rowname=x do
if x[1]<>'-' and x[1]<>'' and x[1]<>'ERROR' then
temp=indirectionset(aestivafilename(x[1]),x[2])
/if
/for
reload="TRUE"
elif reload="ERROR" then
copy file="/apps/livetalk/chat_vars.csv" ts="," to chat_vars /copy
for name=chat_vars rowname=x do
temp=indirectionset(x[1],x[2])
/for
/if
function lh_version() do
return '2.4' /return
/function
function insertimages(text,ldel,rdel,keepdel) locals L,LLD,LRD,a,b do
return replaceall(text,'<a ','<a target="new" ') /return
if count(text,ldel)=0 then return text /return /if
L=length(text)
LRD=length(rdel)
LLD=length(ldel)
a=locate(text,ldel)
b=right(text,L-a)
if count(b,rdel)=0 then return text /return /if
b=a+locate(b,rdel)
if keepdel=1 or keepdel='TRUE' then
tag=middle(text,a,b+LRD-1)
else
tag=middle(text,a+LLD,b-1)
/if
return left(text,a-1)+parsetag(tag)+insertimages(right(text,L-b-LRD+1),ldel,rdel,keepdel) /return
/function
function parsetag(text) locals upid,upid_record do
if left(text,10)='p8ste.com/' then text='www'+right(text,length(text)-10) /if
upid=text
return '*'+text+'*' /return
if upid='' or upid='ERROR' then
return text /return
else
upid_record=dbsearch('/pasteboard/database/upid','upid="'+upid+'"',1,1000)
if upid_record[3,1]='/pasteboard/sessions/'+upid_record[2,1] then
return text /return
else
text='<div class="img">'+upid_record[3,1]+'</div>'
return text /return
/if
/if
/function
function breakconnect() locals temp,a,b do
temp=sysfixprivate("chats/comments"+chatid+".txt")
a=fileinfo("chats/comments"+chatid+".txt")
b=timefrom(adddays(left(a[3,1],14),0),"MINUTES")
if b>60 then
copy file="/apps/livetalk/chats/comments"+chatid+".txt" to temp /copy
if isfile("chatsarchive/comments"+chatid+".txt") then
append temp+lf+fillin('<div class="userinfo">'+closestring+'</div>')+lf to file="chatsarchive/comments"+chatid+".txt" /append
/if
temp=sysfixprivate("chatsarchive/comments"+chatid+".txt")
temp=fileremove("chats/comments"+chatid+".txt")
/if
reload="ERROR"
return temp /return
/function
function fillin(text) do
text=replaceall(text,'[csrname]',csrname)
text=replaceall(text,'[now]',getdate(now,"short")+" at "+gettime(now,"short"))
text=replaceall(text,'[chat]','<a href="chat.html">chat</a>')
text=replaceall(text,'[email]','<a href="email.html">email</a>')
text=replaceall(text,lf+lf,'<br> <br>')
text=replaceall(text,lf,'<br>')
return text /return
/function
function displaymenu(id) locals temp,a,editit do
a[1,1]='Status'
a[1,2]='Archives'
a[1,3]='Links'
a[1,4]='Sites'
a[1,5]='Server'
a[1,6]='Update'
if iconpage<>"ERROR" then
editit=''
if 1=0 then
if domainname="clearimageonline.com" then ei=ci_edit(page,800,600,'edit this page','','TRUE')+' | ' else ei='' /if
editit=ei+'<a href="'+iconpage+'">Desktop</a><br> <br>'
/if
else
editit=""
/if
temp=^
<div style="background-color: #FFFFFF; padding: 10px; padding-bottom: 0; margin: 0;">
^+editit+^
<table cellpadding="3" cellspacing="0" border="0">
<tr>^
for name=a rowname=x do
if id="LOGIN" then
temp=temp+^ <td align="center" bgcolor="#ffffff"> ^+x[1]+^ </td>^
else
if x[1]=id then
temp=temp+^ <td align="center" bgcolor="#dddddd"> <a href="^+page+^"><img src="images/reload.gif" width="12" height="12" border="0"></a>^+x[1]+^ </td>^
else
temp=temp+^ <td align="center" bgcolor="#ffffff"> <a href="^+lower(x[1])+^.html">^+x[1]+^</a> </td>^
/if
/if
/for
temp=temp+^
</tr>
</table>
</div>^
return temp /return
/function
function getchatid() locals temp do
copy file="/apps/livetalk/chatid.txt" to temp /copy
temp=temp+1
if isinteger(temp) then else temp="990000" /if
copy temp to file="/apps/livetalk/chatid.txt" /copy
return temp /return
/function
function JSONescape(text) do
text=replaceall(text,'\','\\')
text=replaceall(text,'"','\"')
text=replaceall(text,'/','\/')
text=replaceall(text,lf,'\n')
text=replaceall(text,cr,'\r')
return text /return
/function
function toggle(a,t,f) do
if a=0 or a="TRUE" or a="Y" or a="yes" then
return f /return
elif a=1 or a="FALSE" or a="N" or a="no" then
return t /return
else
return "ERROR" /return
/if
/function
function sendcommand(command) locals temp,path,t,x,tr do
securitycode=encrypt(domainname,"livetalk")
x=netsockopen(0,"localhost",portnumber,100)
if x[1,1]<>'TRUE' then x=netsockclose(0) return 'ERROR Connecting to AIM RELAY server' /return /if
x=netsockwrite(0,securitycode+" "+command+cr+lf)
if x[1,1]<>'TRUE' then x=netsockclose(0) return 'ERROR Writing command to AIM RELAY server' /return /if
x=""
temp=""
while x<>"CLOSE" do
x=netsockread(0,500)
if x="CLOSE" then else temp=temp+x+lf /if
/while
x=netsockclose(0)
if left(command,7)="BRIDGES" then
temp=replaceall(temp,'"','')
if right(temp,1)=lf then temp=left(temp,length(temp)-1) /if
temp=ci_deltexttovar(temp,lf,",")
/if
return temp /return
/function
function getstat() locals temp,st,x do
temp=sendcommand("BRIDGES "+chatid)
if cols(temp)=1 and rows(temp)=1 then return temp /return /if
st="DISCONNECTED"
for name=temp rowname=x do
if x[4]=chatid then st="CONNECTED" csrtyping=x[9] csrname=x[1] csrid=x[1] /if
if count(x[5],chatid)>0 then st="CONNECTING" csrtyping=x[9] csrname=x[1] csrid=x[1] /if
/for
for name=csrlist rowname=x do
if x[1]=csrid then csrname=x[2] /if
/for
return st /return
/function
function unpostprep(v) locals x,y,t,a do
x=split(v,'%')
t='ERROR'
for name=x rowname=y do
if t<>'ERROR' then
a=y[1]
t=t+ascii(ci_hextodec(middle(a,1,1))*16+ci_hextodec(middle(a,2,2)))+right(a,length(a)-2)
else
t=y[1]
/if
/for
return t /return
/function