-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathConfig.xxm
255 lines (246 loc) · 7.84 KB
/
Config.xxm
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
[[@DataLank,xxmSession,fCommon]][[!var
db:TDataConnection;
qr:TQueryResult;
i,tz,c:integer;
s,t:string;
]][[
Context.Include('dHead.xxmi');
<<div style="position:fixed;top:0;left:0em;background-color:gold;padding:4pt;user-select:none;">
<a href="."><img src="img_l.png" width="16" height="16" border="0" alt="Back" /></a>
<a href="Feeds.xxm"><img src="img_l.png" width="16" height="16" border="0" alt="Back" /></a>
<b>Settings</b>
</div>
<div style="height:1.5em;"> </div>>
db:=Session.Connection;
case Context['x'].AsInteger of
0:
begin
qr:=TQueryResult.Create(db,'select * from "User" where id=$1',[Session.UserID]);
try
tz:=qr.GetInt('timezone');
<<form method="post">
<input type="hidden" name="x" value="1" />
<dl>
<dt>time zone</dt>
<dd>
<select name="z1">>
for i:=-14 to +12 do
begin
if i<0 then s:='' else s:='+';
if i=tz div 100 then t:=' selected="1"' else t:='';
<<option[[#t]]>>=s+Format('%.2d',[i])<</option>>
end;
<</select>
:
<select name="z2">>
for i:=0 to 3 do
begin
if (i*15=tz mod 100) or (-i*15=tz mod 100) then t:=' selected="1"' else t:='';
<<option[[#t]]>>=Format('%.2d',[i*15])<</option>>
end;
<</select>
//TODO: full list, DST support
</dd>
<dt>default post load batch size</dt>
[[
if qr.IsNull('batchsize') then i:=Session.DefaultBatchSize else i:=qr.GetInt('batchsize');
]]
<dd><input type="text" name="batchsize" value="[[=i]]" /></dd>
<p><input type="submit" value=" Apply " /></p>
</form>>
finally
qr.Free;
end;
<<p><b>block specific URL’s</b></p>>
qr:=TQueryResult.Create(db,'select * from "UserBlock" where user_id=$1 order by lower(url)',[Session.UserID]);
try
if not qr.EOF then
begin
<<script>
function rURL(){
return confirm('Are you sure to remove this URL block prefix?');
}
</script>>
end;
while qr.Read do
begin
<<div class="post">
<div class="date">>=FormatDateTime('ddd yyyy-mm-dd hh:nn',double(qr['created'])+Session.TimeBias)<</div>
[[=qr['url']]]
<a href="[[?'x',4,'id',qr['id']]]" style="color:#0000CC;" onclick="return rURL();">[remove]</a>
</div>>
end;
finally
qr.Free;
end;
<<p><form method="post">
<input type="hidden" name="x" value="3" />
<input type="text" name="url" style="width:12em;" autocomplete="off" />
<input type="submit" value="Add" />
</form></p>
<p><b>previous logins:</b></p>>
c:=0;
s:=Context.Cookie['feederAutoLogon'];
qr:=TQueryResult.Create(db,'select * from "UserLogon" where user_id=$1 order by last desc',[Session.UserID]);
try
while qr.Read do
begin
<<div class="post">
<div class="date">>=FormatDateTime('ddd yyyy-mm-dd hh:nn',double(qr['last'])+Session.TimeBias)<</div>
[[=qr['address']]]
"[[=qr['useragent']]]"
[[
if s=qr.GetStr('key') then
begin
<<img src="img_l.png" width="16" height="16" alt="current session" />>
c:=qr.GetInt('chart');
end;
]]
<a href="[[?'x',2,'id',qr['id']]]" style="color:#0000CC;">[revoke]</a>
</div>>
end;
finally
qr.Free;
end;
<<p><b>badge on my website:</b></p>
<p>Copy and paste this HTML code to somewhere suitable on your homepage:</p>>
<<textarea style="width:75vw;height:2em;" id="badge1" onmouseup="document.getElementById('badge1').select();"><iframe src="[[=PublicURL]]Badge.xxm?x=[[=Copy(Context.Cookie['feederAutoLogon'],1,12)
]]" style="border:1px solid black;width:100pt;height:20pt;"></iframe></textarea>>
<<p><b>post volume chart</b></p>>
if c=0 then
begin
<<form method="post">
<input type="hidden" name="x" value="5" />
<p>
Generate post volume chart (generated by the feed loading schedule)
<br />
<input type="submit" value="Enable" />
</p>
</form>>
end
else
begin
<<form method="post">
<input type="hidden" name="x" value="6" />
<p>
<img src="charts/[[=StringReplace(Copy(s,1,14),'/','=',[rfReplaceAll])]].png" width="80" height="40" style="border:1px solid black;" />
(generated by the feed loading schedule)
<br />
<textarea style="width:75vw;height:2em;" id="badge2" onmouseup="document.getElementById('badge2').select();"><a href="[[=PublicURL]]"><img src="[[=PublicURL+'charts/'+StringReplace(Copy(s,1,14),'/','=',[rfReplaceAll])+'.png']]" width="80" height="40" border="0" style="border:1px solid black;" /></a></textarea>
<br />
<input type="submit" value="Disable" />
</p>
</form>>
end;
qr:=TQueryResult.Create(db,'select version()',[]);
try
<<p style="color:silver;">>=Context.ContextString(csVersion)<<br />>=qr[0]<</p>>
finally
qr.Free;
end;
end;
1://update
begin
db.BeginTrans;
try
tz:=Context['z1'].AsInteger;
i:=Context['batchsize'].AsInteger;
if tz<0 then tz:=tz*100-Context['z2'].AsInteger else tz:=tz*100+Context['z2'].AsInteger;
db.Execute('update "User" set timezone=$1, batchsize=$2 where id=$3',
[tz
,i
,Session.UserID
]);
Session.TimeBias:=(tz div 100)/24.0+(tz mod 100)/1440.0;
Session.DefaultBatchSize:=i;
db.CommitTrans;
except
db.RollbackTrans;
raise;
end;
<<p>Settings updated</p>
<p><a href="Feeds.xxm">back</a></p>>
end;
2://revoke
begin
db.BeginTrans;
try
db.Execute('delete from "UserLogon" where user_id=$1 and id=$2',[Session.UserID,Context['id'].AsInteger]);
db.CommitTrans;
except
db.RollbackTrans;
raise;
end;
//TODO: kill live sessions
<<p>Auto-logon revoked</p>
<p><a href="?">Continue...</a></p>
<script>document.location.replace('?');</script>>
end;
3://add user block URL
begin
s:=Context['url'].Value;
if (Length(s)<8) or not((Copy(s,1,4)='http')
or (Copy(s,1,4)='tag:') or (Copy(s,1,9)='category:')) then
raise Exception.Create('Invalid Block URL prefix');
db.BeginTrans;
try
db.Insert('UserBlock',['user_id',Session.UserID,'url',s,'created',double(UtcNow)],'id');
db.CommitTrans;
except
db.RollbackTrans;
raise;
end;
<<script>document.location.replace('?');</script>
<p><a href="?">continue...</a></p>>
end;
4://remove user block URL
begin
db.BeginTrans;
try
db.Execute('delete from "UserBlock" where user_id=$1 and id=$2',[Session.UserID,Context['id'].AsInteger]);
db.CommitTrans;
except
db.RollbackTrans;
raise;
end;
<<p>URL block removed</p>
<p><a href="?">Continue...</a></p>
<script>document.location.replace('?');</script>>
end;
5://enable post volume chart
begin
s:=Context.Cookie['feederAutoLogon'];
db.BeginTrans;
try
db.Execute('update "UserLogon" set chart=$1 where user_id=$2 and key=$3',[1{??},Session.UserID,s]);
db.CommitTrans;
except
db.RollbackTrans;
raise;
end;
<<p>Post volume chart enabled</p>
<p><a href="?">Continue...</a></p>
<script>document.location.replace('?');</script>>
end;
6://disable post volume chart
begin
s:=Context.Cookie['feederAutoLogon'];
db.BeginTrans;
try
db.Execute('update "UserLogon" set chart=null where user_id=$1 and key=$2',[Session.UserID,s]);
db.CommitTrans;
except
db.RollbackTrans;
raise;
end;
ClearChart(StringReplace(Copy(s,1,14),'/','=',[rfReplaceAll]));
<<p>Post volume chart disabled</p>
<p><a href="?">Continue...</a></p>
<script>document.location.replace('?');</script>>
end;
//7:
else raise Exception.Create('Unknown action');
end;
Context.Include('dFoot.xxmi');