Skip to content

Latest commit

 

History

History
390 lines (351 loc) · 9.53 KB

mail2.pas

File metadata and controls

390 lines (351 loc) · 9.53 KB
 
Nov 18, 2000
Nov 18, 2000
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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
{$A+,B+,D-,E+,F+,I+,L+,N-,O+,R-,S+,V-}
unit mail2;
interface
uses
crt, dos,
{rcg11172000 no overlay under Linux.}
{overlay,}
common, timejunk, mail0, mail1;
procedure ssmail(mstr:astr);
procedure smail(massmail:boolean);
procedure email1(x:integer; ftit:string);
procedure email(x:integer);
procedure imail(x:integer);
function maxage(x:integer):integer;
implementation
uses misc3, miscx;
procedure ssmail(mstr:astr);
begin
if (mstr='') then smail(FALSE)
else begin
if (pos(';',mstr)=0) then irt:='Feedback' else
irt:=copy(mstr,pos(';',mstr)+1,length(mstr));
imail(value(mstr));
end;
end;
procedure smail(massmail:boolean);
var u,u2:userrec;
mheader:mheaderrec;
mixr:msgindexrec;
na:array[1..20] of word;
massacs,s:string;
i,nac,x:integer;
stype:byte;
abort,next,ok:boolean;
procedure checkitout(var x:integer; showit:boolean);
var i,ox:integer;
b:boolean;
procedure unote(s:string);
begin
if (showit) then
print('[> '+caps(u.name)+' #'+cstr(x)+': '+s);
end;
begin
{x:=value(s);} ox:=x;
if ((x<1) or (x>filesize(uf)-1)) then begin x:=0; exit; end;
seek(uf,x); read(uf,u);
i:=0; b:=TRUE;
while ((i<4) and (b)) do begin
inc(i); b:=moremail(u,x,i);
if (not b) then
case i of
1:unote('Mailbox is full.');
2:unote('Mailbox is closed.');
3:x:=0;
4:unote('Can''t send mail to yourself!');
end;
end;
if (not b) then begin x:=0; exit; end;
i:=u.forusr; if ((i<1) or (i>filesize(uf)-1)) then i:=0;
if (i<>0) then begin
seek(uf,i); read(uf,u2);
unote('Mail forwarded to '+caps(u2.name)+' #'+cstr(i)+'.');
x:=i;
end;
if (showit) then
for i:=1 to 20 do
if (na[i]=x) then begin
unote('Can''t send more than once.');
x:=0; exit;
end;
if (ox<>x) then
if ((ox>=1) and (ox<=filesize(uf)-1)) then begin
seek(uf,ox); read(uf,u);
end;
end;
procedure sendit(x:integer);
begin
checkitout(x,FALSE);
if (x=0) then exit;
if ((x>=1) and (x<=filesize(uf)-1)) then begin
seek(uf,x); read(uf,u);
if (x=1) then begin
inc(thisuser.feedback);
inc(ftoday);
end else begin
inc(thisuser.emailsent);
inc(etoday);
end;
inc(u.waiting);
seek(uf,x); write(uf,u);
if (x=usernum) then inc(thisuser.waiting);
end;
with mheader.toi do begin
anon:=0;
usernum:=x;
as:=allcaps(u.name)+' #'+cstr(x);
real:=allcaps(u.realname);
alias:=allcaps(u.name);
end;
with mixr do begin
messagenum:=x;
msgid:=0;
hdrptr:=filesize(brdf);
msgindexstat:=msgindexstat+[mimassmail];
end;
seek(brdf,mixr.hdrptr);
savemhead(mheader);
newmix(mixr);
end;
procedure doit;
var s:string;
i,x:integer;
begin
initbrd(-1);
if (not inmsg(FALSE,FALSE,'',mixr,mheader)) then exit;
case stype of
0:begin
nl; print('Sending mass-mail to:');
sysoplog('Mass-mail sent to:');
for i:=1 to nac do begin
sendit(na[i]); s:=' '+caps(u.name)+' #'+cstr(na[i]);
sysoplog(s); print(s);
end;
end;
1:begin
nl; print('Sending mass-mail to:');
sysoplog('Mass-mail sent to: (by ACS "'+massacs+'")');
seek(uf,1);
for i:=1 to filesize(uf)-1 do begin
read(uf,u);
if (aacs1(u,i,massacs)) then begin
sendit(i); s:=' '+caps(u.name)+' #'+cstr(i);
sysoplog(s); print(s);
end;
end;
end;
2:begin
print('Sending mass-mail to ALL USERS.');
sysoplog('Mass-mail sent to ALL USERS.');
for i:=1 to filesize(uf)-1 do sendit(i);
end;
end;
end;
begin
nl;
if ((remail in thisuser.ac) or (not (aacs(systat.normprivpost)))) then begin
print('Your access privledges do not include sending mail.');
exit;
end else
if ((etoday>=systat.maxprivpost) and (not mso)) then begin
print('Too much mail send today already.');
exit;
end;
if (not massmail) then begin
print('Enter user number, user name, or partial search string:');
prt(':'); finduserws(x);
if (x>0) then imail(x);
end else begin
print('Mass mail: send mail to more than one user.');
print('Enter a max of 20 user NUMBERS, seperated by commas.');
if (cso) then begin
print('CoSysOps:');
print(' ALL: Send to every user.');
print(' ACS: Send to an ACS group of users.');
end;
prt(':'); input(s,78); if (s='') then exit;
reset(uf);
ok:=FALSE; nac:=0; stype:=0;
for i:=1 to 20 do na[i]:=0;
nl;
if (cso) then
if (s='ACS') then begin
ok:=TRUE;
stype:=1;
prt('Enter ACS: '); inputl(massacs,160);
if (massacs='') then begin close(uf); exit; end;
seek(uf,1); i:=1;
nl;
print('Users marked by ACS "'+massacs+'":');
abort:=FALSE; next:=FALSE;
while ((i<=filesize(uf)-1) and (not abort)) do begin
read(uf,u);
if (aacs1(u,i,massacs)) then
print(' '+caps(u.name)+' #'+cstr(i));
inc(i); wkey(abort,next);
end;
end else
if (s='ALL') then begin
ok:=FALSE;
print('ALL USERS marked for mass-mail.');
stype:=2;
end;
if (not ok) then begin
print('Users marked:');
while ((s<>'') and (nac<20)) do begin
x:=value(s); checkitout(x,TRUE);
if (x<>0) then begin
inc(nac); na[nac]:=x;
print(' '+caps(u.name)+' #'+cstr(x));
end;
i:=pos(',',s); if (i=0) then s:='';
if (s<>'') then s:=copy(s,i+1,length(s)-i);
end;
end;
nl;
if pynq('Is this OK? ') then begin doit; closebrd; end;
close(uf);
end;
end;
procedure email1(x:integer; ftit:string);
var u:userrec;
pinfo:pinforec;
mheader:mheaderrec;
mixr:msgindexrec;
fto:string;
i,t,e,cp:integer;
a:anontyp;
s,tousers:astr;
us:userrec;
bb:byte;
b,ok,wasanon:boolean;
procedure nope(s:astr);
begin
if ok then begin nl; print(s); end;
ok:=FALSE;
end;
begin
ok:=TRUE;
reset(uf);
if ((x<0) or (x>filesize(uf)-1)) then begin close(uf); exit; end;
if (copy(ftit,1,1)<>'\') then begin
seek(uf,x); read(uf,u); close(uf);
nl;
if ((remail in thisuser.ac) or (not aacs(systat.normprivpost))) and
(not mso) then
nope('Your access privledges do not include sending mail.');
if (etoday>=systat.maxprivpost) and (not mso) then
nope('Too much mail sent today.');
if ((x=1) and (ftoday>=systat.maxfback) and (not mso)) then
nope('Too much feedback sent today.');
i:=0; b:=TRUE;
while ((i<4) and (b)) do begin
inc(i); b:=moremail(u,x,i);
if (not b) then
case i of
1:nope('That user''s mailbox is full.');
2:nope('That user''s mailbox is closed.');
3:nope('That user has been deleted.');
4:nope('Why do you want to send mail to yourself!??!');
end;
end;
if ((cso) and (not b) and (i<>3)) then ok:=TRUE;
if (not ok) then exit;
end;
savepinfo(pinfo);
initbrd(-1);
if (inmsg(FALSE,FALSE,ftit,mixr,mheader)) then begin
reset(uf);
if ((x>=1) and (x<=filesize(uf)-1)) then begin
seek(uf,x); read(uf,u);
if (x=1) then begin
inc(thisuser.feedback);
inc(ftoday);
end else begin
inc(thisuser.emailsent);
inc(etoday);
end;
inc(u.waiting);
seek(uf,x); write(uf,u);
if (x=usernum) then inc(thisuser.waiting);
end;
close(uf);
with mheader.toi do begin
anon:=0;
usernum:=x;
as:=allcaps(u.name)+' #'+cstr(x);
real:=allcaps(u.realname);
alias:=allcaps(u.name);
end;
mixr.msgid:=0;
mixr.messagenum:=x;
seek(brdf,mixr.hdrptr);
savemhead(mheader);
newmix(mixr);
s:=caps(u.name)+' #'+cstr(x);
if (useron) then sysoplog('Mail sent to '+s);
print('Mail sent to '+s);
topscr;
end;
loadpinfo(pinfo);
end;
procedure email(x:integer);
begin email1(x,''); end;
procedure imail(x:integer);
var u:userrec;
i:integer;
b,xx:boolean;
procedure nope(s:string);
begin
if (not xx) then begin
print(s);
xx:=TRUE;
end;
end;
begin
xx:=FALSE;
reset(uf);
if ((x<1) or (x>filesize(uf)-1)) then begin close(uf); exit; end;
seek(uf,x); read(uf,u);
nl;
i:=0; b:=TRUE;
while ((i<4) and (b)) do begin
inc(i); b:=moremail(u,x,i);
if (not b) then
case i of
1:nope('That user''s mailbox is full.');
2:nope('That user''s mailbox is closed.');
3:nope('That user has been deleted.');
4:nope('Why do you want to send mail to yourself!??!');
end;
end;
if (xx) then begin close(uf); exit; end;
if (u.forusr<>0) then begin
x:=forwardm(x);
if ((x<1) or (x>filesize(uf)-1)) then x:=0;
if (x>0) then begin
seek(uf,x); read(uf,u); close(uf);
print('That user is forwarding his mail to '+caps(u.name)+'.');
if pynq('Send mail to ['+caps(u.name)+' #'+cstr(x)+'] ? ') then email(x);
end else begin
print('Can''t send mail to that user.');
close(uf);
end;
end else begin
close(uf);
if pynq('Send mail to ['+caps(u.name)+' #'+cstr(x)+']? ') then email(x);
end;
end;
function maxage(x:integer):integer;
begin
case x of
0..19:maxage:=5;
20..29:maxage:=14;
30..39:maxage:=90;
40..59:maxage:=120;
else
maxage:=255;
end;
end;
end.
end.