-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathuser.c
875 lines (762 loc) · 21.1 KB
/
user.c
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
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
/*-------------------------------------------------------*/
/* user.c ( NTHU CS MapleBBS Ver 2.36 ) */
/*-------------------------------------------------------*/
/* author : opus.bbs@bbs.cs.nthu.edu.tw */
/* target : user configurable setting routines */
/* create : 95/03/29 */
/* update : 95/12/15 */
/*-------------------------------------------------------*/
#define _USER_C_
#include "bbs.h"
#undef MAXMONEY
#define MAXMONEY ((u->totaltime*10) + (u->numlogins*100) + (u->numposts*1000))
extern int numboards;
extern boardheader *bcache;
extern void resolve_boards();
char *sex[8] = { MSG_BIG_BOY, MSG_BIG_GIRL, MSG_LITTLE_BOY, MSG_LITTLE_GIRL,
MSG_MAN, MSG_WOMAN, MSG_PLANT, MSG_MIME };
/* ------------------- */
/* password encryption */
/* ------------------- */
int chkpasswd(char *passwd, char *test)
{
extern char *crypt();
static char pwbuf[14];
char *pw;
strncpy(pwbuf, test, 14);
pw = crypt(pwbuf, passwd);
return (!strncmp(pw, passwd, 14));
}
int bad_user_id(char *userid)
{
register char ch;
if (belong("etc/baduser",userid))
return 1;
if (strlen(userid) < 2)
return 1;
if (not_alpha(*userid))
return 1;
if (!ci_strcmp(userid, str_new))
return 1;
while (ch = *(++userid))
{
if (not_alnum(ch))
return 1;
}
return 0;
}
void user_display(userec *u, int real)
{
int diff;
int day = 0, hour = 0, min = 0;
char genbuf[128];
if (u->sex >= 8)
u->sex = 7;
clrtobot();
sethomedir(genbuf, u->userid);
outs("[1;33m●────────────[42m 使用者資料 [40m────────────●\n");
prints("\
[32m英文代號:[37m%-16.16s[32m暱稱:[37m%-20.20s[32m性別:[37m%-8.8s
[32m真實姓名:[37m%-16.16s[32m
[32m出生日期:[37m19%02i年%02i月%02i日 [32mEMail:[37m%-40s\n",
u->userid,u->username,sex[u->sex],
u->realname,
u->year, u->month, u->day, u->email);
prints(" [32m上站次數:[37m%-16d[32m註冊日期:[37m%s"
,u->numlogins,ctime(&u->firstlogin));
prints(" [32m文章數目:[37m%-16d[32m前次上站:[37m%s"
,u->numposts,ctime(&u->lastlogin));
prints(" [32m私人信箱:[37m%-4d 封 [32m利息發放:[37m%s"
,rec_num(genbuf, sizeof(fileheader)),ctime(&u->dtime));
prints(
" [32m金幣數量:[37m%-16ld[32m銀幣數量:[37m%-16ld[32m\n"
" [32m銀幣上限:[37m%-16ld[32m信箱上限:[37m%d 封\n"
" [32m人氣指數:[37m%-16ld[32m好奇指數:[37m%-16ld[32m心情:[37m%-4.4s\n"
" [32m發訊息數:[37m%-16d[32m收訊息數:[37m%d\n"
" [32m上站地點:[37m%s \n"
,u->goldmoney,u->silvermoney
,MAXMONEY,(u->exmailbox+MAXKEEPMAIL)
,u->bequery,u->toquery,u->feeling,u->sendmsg,u->receivemsg
,u->lasthost
);
if (real)
{
strcpy(genbuf, "bTCPRp#@XWBA#VSA?crFG??????????");
for (diff = 0; diff < 31; diff++)
if (!(u->userlevel & (1 << diff)))
genbuf[diff] = '-';
prints(" [32m認證資料:[37m%-50.50s\n",u->justify);
prints(" [32m使用權限:[37m%-32s\n",genbuf);
}
diff = u->totaltime / 60;
day = diff / 1440;
hour = (diff/60)%24;
min = diff%60;
prints(" [32m上站時間:[37m%d天 %d小時 %d分\n",day,hour,min);
if (u->userlevel >= PERM_BM)
{
int i;
boardheader *bhdr;
resolve_boards();
outs(" [32m擔任板主:[37m");
for (i = 0, bhdr = bcache; i < numboards; i++, bhdr++)
{
if(userid_is_BM(u->userid, bhdr->BM))
{
outs(bhdr->brdname);
outc(' ');
}
}
outc('\n');
}
outs("[33m●────────────────────────────────●[m\n");
if (!real)
outs((u->userlevel & PERM_LOGINOK) ?
"您的註冊程序已經完成,歡迎加入本站" :
"如果要提昇權限,請參考本站公佈欄辦理註冊");
#ifdef NEWUSER_LIMIT
if (!real)
if ((u->lastlogin - u->firstlogin < 3 * 86400) && !HAS_PERM(PERM_POST))
outs("新手上路,三天後開放權限");
#endif
}
void uinfo_query(userec *u, int real, int unum)
{
userec x;
register int i, fail, mail_changed;
char ans, buf[STRLEN];
char genbuf[200];
int flag=0,temp;
user_display(u, real);
fail = mail_changed = 0;
memcpy(&x, u, sizeof(userec));
{
char *choose[6] = {msg_choose_cancel ,"11)修改資料","22)設定密碼","33)設定權限","44)清除帳號","55)改ID"};
ans = getans2(b_lines, 0, real ? "" : "請選擇 ", choose, real ? 6 : 3, 0);
}
if (ans > '2' && !real)
ans = '0';
if (ans == '1' || ans == '3')
{
clear();
i = 2;
move(i++, 0);
outs(msg_uid);
outs(x.userid);
}
switch (ans)
{
case '1': /*這裡有寫入到 .PASSWDS 所以改越少越好..hialan.020729*/
move(0, 0);
outs("請逐項修改。");
getdata(i++, 0,"您的暱稱:",x.username, 24, DOECHO,x.username);
strip_ansi(x.username,x.username,STRIP_ALL);
getdata(i++, 0,"現在心情:",x.feeling, 5, DOECHO,x.feeling);
x.feeling[4] = '\0';
getdata(i++, 0,"電子信箱:",buf, 50, DOECHO,x.email);
if(belong_spam(BBSHOME"/etc/spam-list",x.email))
{
pressanykey("抱歉,本站不接受你的 E-Mail 信箱位置");
strcpy(buf,x.email);
}
if (strcmp(buf,x.email) && !not_addr(buf))
{
strcpy(x.email,buf);
mail_changed = 1 - real;
}
strip_ansi(x.email,x.email,STRIP_ALL);
//修改性別的地方
{
char *choose_sex[8]={"11)葛格","22)姐接","33)底迪","44)美眉","55)薯叔","66)阿姨","77)植物","88)礦物"};
buf[0] = getans2(i++, 0, "性別 ", choose_sex, 8, u->sex + '1');
if (buf[0] >= '1' && buf[0] <= '8')
x.sex = buf[0] - '1';
}
while (1)
{
sprintf(genbuf,"%02i/%02i/%02i",u->year,u->month,u->day);
getdata(i, 0, "出生年份 19", buf, 3, DOECHO, genbuf);
x.year = (buf[0] - '0') * 10 + (buf[1] - '0');
getdata(i, 0, "出生月份 ", buf, 3, DOECHO, genbuf+3);
x.month = (buf[0] - '0') * 10 + (buf[1] - '0');
getdata(i, 0, "出生日期 ", buf, 3, DOECHO, genbuf+6);
x.day = (buf[0] - '0') * 10 + (buf[1] - '0');
if (!real && (x.month > 12 || x.month < 1 ||
x.day > 31 || x.day < 1 || x.year > 90 || x.year < 40))
continue;
i++;
break;
}
if (real)
{
unsigned long int l;
// wildcat:不要讓 user 註冊完亂改名字?
getdata(i++, 0,"真實姓名:",x.realname, 20, DOECHO,x.realname);
strip_ansi(x.realname,x.realname,STRIP_ALL);
sprintf(genbuf, "%d", x.numlogins);
if (getdata(i, 0,"上線次數:", buf, 10, DOECHO,genbuf))
if ((l = atoi(buf)) >= 0)
x.numlogins = (int) l;
sprintf(genbuf,"%d", u->numposts);
if (getdata(i++, 25, "文章數目:", buf, 10, DOECHO,genbuf))
if ((l = atoi(buf)) >= 0)
x.numposts = l;
sprintf(genbuf, "%ld", x.silvermoney);
if (getdata(i, 0,"身上銀幣:", buf, 10, DOECHO,genbuf))
if ((l = atol(buf)) >= 0)
x.silvermoney = l;
sprintf(genbuf, "%ld", x.goldmoney);
if (getdata(i, 25,"身上金幣:", buf, 10, DOECHO,genbuf))
if ((l = atol(buf)) >= 0)
x.goldmoney = l;
sprintf(genbuf, "%ld", x.sendmsg);
if (getdata(i, 0,"發水球數:", buf, 10, DOECHO,genbuf))
if ((l = atol(buf)) >= 0)
x.sendmsg = l;
sprintf(genbuf, "%ld", x.receivemsg);
if (getdata(i++, 25,"收水球數:", buf, 10, DOECHO,genbuf))
if ((l = atol(buf)) >= 0)
x.receivemsg = l;
sprintf(genbuf, "%ld", x.bequery);
if (getdata(i, 0,"人氣度:", buf, 10, DOECHO,genbuf))
if ((l = atol(buf)) >= 0)
x.bequery = l;
sprintf(genbuf, "%ld", x.toquery);
if (getdata(i++, 25,"好奇度:", buf, 10, DOECHO,genbuf))
if ((l = atol(buf)) >= 0)
x.toquery = l;
sprintf(genbuf, "%ld", x.totaltime);
if (getdata(i++, 0,"上站時數:", buf, 10, DOECHO,genbuf))
if ((l = atol(buf)) >= 0)
x.totaltime = l;
sprintf(genbuf, "%d", x.exmailbox);
if (getdata(i++, 0,"購買信箱數:", buf, 4, DOECHO,genbuf))
if ((l = atol(buf)) >= 0)
x.exmailbox = (int) l;
sprintf(genbuf, "%d", x.songtimes);
if (getdata(i++, 0,"點歌次數:", buf, 4, DOECHO, genbuf))
if ((l = atol(buf)) >= 0)
x.songtimes = (int) l;
getdata(i++, 0,"認證資料:", x.justify, 39, DOECHO, x.justify);
getdata(i++, 0,"最近光臨機器:", x.lasthost, 24, DOECHO,x.lasthost);
fail = 0;
}
break;
case '2':
i = 19;
if (!real)
{
if (!getdata(i++, 0, "請輸入原密碼:", buf, PASSLEN, PASS,0) ||
!chkpasswd(u->passwd, buf))
{
outs("\n\n您輸入的密碼不正確\n");
fail++;
break;
}
}
if (!getdata(i++, 0, "請設定新密碼:", buf, PASSLEN, PASS,0))
{
outs("\n\n密碼設定取消, 繼續使用舊密碼\n");
fail++;
break;
}
strncpy(genbuf, buf, PASSLEN);
getdata(i++, 0, "請檢查新密碼:", buf, PASSLEN, PASS,0);
if (strncmp(buf, genbuf, PASSLEN))
{
outs("\n\n新密碼確認失敗, 無法設定新密碼\n");
fail++;
break;
}
buf[8] = '\0';
strncpy(x.passwd, genpasswd(buf), PASSLEN);
break;
case '3':
i = DL_func("SO/admin.so:va_setperms",x.userlevel);
//i = setperms(x.userlevel);
if (i == x.userlevel)
fail++;
else {
flag=1;
temp=x.userlevel;
x.userlevel = i;
}
break;
case '4':
i = QUIT;
break;
case '5':
if (getdata(b_lines - 3, 0, "新的使用者代號:", genbuf, IDLEN + 1,
DOECHO,x.userid))
{
if (searchuser(genbuf))
{
outs("錯誤! 已經有同樣 ID 的使用者");
fail++;
}
else
{
strcpy(x.userid, genbuf);
}
}
break;
default:
return;
}
if (fail)
{
pressanykey(NULL);
return;
}
// if (getans(msg_sure_ny) == 'y')
if (getans2(b_lines-1, 0, msg_sure, 0, 2, 'n') == 'y')
{
if (flag)
DL_func("SO/admin.so:va_Security",temp,i,cuser.userid,x.userid);
if (strcmp(u->userid, x.userid))
{
char src[STRLEN], dst[STRLEN];
sethomepath(src, u->userid);
sethomepath(dst, x.userid);
f_mv(src, dst);
setuserid(unum, x.userid);
}
memcpy(u, &x, sizeof(x));
substitute_record(fn_passwd, u, sizeof(userec), unum);
if (mail_changed)
{
#ifdef REG_EMAIL
x.userlevel &= ~PERM_LOGINOK;
mail_justify(cuser);
#endif
}
if (i == QUIT)
{
char src[STRLEN], dst[STRLEN];
sprintf(src, "home/%s", x.userid);
sprintf(dst, "tmp/%s", x.userid);
// wildcat : 簡單多了 , 不要用 rm home/userid
if(dashd(src))
f_mv(src , dst);
/*
woju
*/
log_usies("KILL", x.userid);
x.userid[0] = '\0';
setuserid(unum, x.userid);
}
else
log_usies("SetUser", x.userid);
substitute_record(fn_passwd, &x, sizeof(userec), unum);
}
}
int u_info()
{
move(1, 0);
update_data();
uinfo_query(&cuser, 0, usernum);
strcpy(currutmp->username, cuser.username);
strcpy(currutmp->feeling, cuser.feeling);
return 0;
}
int u_cloak()
{
pressanykey((currutmp->invisible ^= 1) ? MSG_CLOAKED : MSG_UNCLOAK);
return XEASY;
}
unsigned u_habit()
{
unsigned fbits;
register int i;
int ch;
char *choice[2]={"ˇ","X"};
fbits = cuser.habit;
stand_title("使用者喜好設定");
move(2, 0);
outs("請依照使用習慣自行調整(ˇ為開, X為關):\n");
move(4, 0);
for (i = 0; i < NUMHABITS; i++)
{
prints("%4s%c. %-28s %-7s\n"
, " ", 'A' + i, habitstrings[i],((fbits >> i) & 1 ? choice[0] : choice[1]));
if(i == 4) /*看板列表顯示在第 5 項 , 覆蓋掉*/
{
move( i%NUMHABITS + 4, i <= 14 ? 36 : 72);
prints((fbits >> i) & 1 ? "文章數" : "編號 ");
outs("\n");
}
}
clrtobot();
move(b_lines, 0);
outs("\033[1;37;46m [↑/↓]上下 [Enter/q]離開 [空白鍵] 切換 \033[m");
i = ch = 0;
while( ch != 'q' && ch != 'Q' && ch != '\r')
{
move(i + 4, 0);
outs("→");
move(b_lines-3, 4);
prints("\033[1m選項:\033[1;36m%s\033[m", habitstrings[i]);
move(b_lines-2, 4);
prints("\033[1m說明:\033[1;36m%s\033[m", habit_help_strings[i]);
ch = igetkey();
move(i + 4, 0);
outs(" ");
move(b_lines-3, 4);
prints("%50s", " ");
move(b_lines-2, 4);
prints("%80s", " ");
switch(ch)
{
case KEY_UP:
i--;
if(i < 0) i = NUMHABITS - 1;
break;
case KEY_DOWN:
i++;
if(i >= NUMHABITS) i = 0;
break;
case ' ':
if (i < 0 || i >= NUMHABITS)
bell();
else
{
fbits ^= (1 << i);
move( i%NUMHABITS + 4, i <= 14 ? 36 : 72);
if(i == 4) /*看板列表顯示在第 5 項*/
prints((fbits >> i) & 1 ? "文章數" : "編號 ");
else
prints((fbits >> i) & 1 ? choice[0] : choice[1]);
}
/* for HABIT_COLOR, 專為了彩色模式設的, i==1是表示第二個HABIT,
當HABIT_COLOR不在第二個HABIT時, 這邊也要相應調整.
- add by wisely - */
if( i == 1) showansi ^= 1;
}
}
update_data(); /* SiE: sync data prev bug user */
cuser.habit = fbits;
substitute_record(fn_passwd, &cuser, sizeof(userec), usernum); /* 記錄 */
return RC_FULL;
}
static void showsig(char *uid, int i)
{
char genbuf[STRLEN];
clear();
sethomefile(genbuf, uid, "sig.0");
genbuf[strlen(genbuf) - 1] = i + '0';
move(3, 0);
prints(" [1;33m●────────────[42m 簽名檔 %d [40m────────────●\033[m", i);
show_file(genbuf, 4, MAXSIGLINES, ONLY_COLOR);
move(4 + MAXSIGLINES, 0);
prints(" [1;33m●───────────────────────────────●\033[m", i);
}
void showplans(char* uid)
{
char genbuf[200];
char *choose_plans[5] = {"11)基本資料","22)簽名檔","33)精華文章","44)留言給(他/她)", msg_choose_cancel};
if (!strcmp(uid, STR_GUEST)) /* alan.000330: guest不須要有個人精華區 */
{
pressanykey("guest 無此功\能!");
return;
}
sethomefile(genbuf, uid, fn_plans);
if (dashf(genbuf))
more(genbuf,YEA);
else
{
clear();
sprintf(genbuf,"%s 目前沒有名片", uid);
move(0,0);
clrtoeol();
outs(genbuf);
}
switch (getans2(b_lines, 0, "", choose_plans, 5, 0))
{
case '1':
my_query(uid);
break;
case '2':
{
char *choose[10]={"11", "22", "33", "44", "55", "66", "77", "88", "99", msg_choose_cancel};
char *choose_tmp[10];
int i,n=0; //有幾個 簽名檔
for(i=0;i<9;i++)
{
sethomefile(genbuf, uid, "sig.0");
genbuf[strlen(genbuf) - 1] = i + '1';
if(dashf(genbuf))
{
choose_tmp[n++] = choose[i];
showsig(uid, i+1);
pressanykey_old(NULL);
}
}
if(n==0)
{
pressanykey("%s 沒有任何簽名檔", uid);
break;
}
choose_tmp[n++] = choose[9];
do
{
i = getans2(b_lines, 0, "請選擇簽名檔:", choose_tmp, n, 'q');;
if(i >= '1' && i <= '9') showsig(uid, i-'0');
}while(i>='1' && i<='9');
}
break;
case '3':
user_gem(uid);
break;
case '4':
if (!strcmp(cuser.userid, STR_GUEST))
pressanykey("guest 無此功\能!");
else
DL_func("SO/pnote.so:va_do_pnote",uid);
default:
break;
}
return;
}
int u_editfile()
{
int mode;
char ans, ans2, buf[128], msg1[64], msg2[16];
char *choose[13]={"11)簽名檔 一",
"22)簽名檔 二",
"33)簽名檔 三",
"44)簽名檔 四",
"55)簽名檔 五",
"66)簽名檔 六",
"77)簽名檔 七",
"88)簽名檔 八",
"99)簽名檔 九",
"00)名片檔",
"cC)自訂游標唷!!",
"sS)拒收郵件名單",
msg_choose_cancel};
char *choose2[3]={"eE)編輯", "dD)刪除", msg_choose_cancel};
ans = win_select("使用者檔案", "要看哪個檔案 ?", choose , 13, 'q');
switch(ans)
{
case '0':
clear();
sethomefile(buf, cuser.userid, fn_plans);
more(buf, YEA);
mode = EDITPLAN;
strcpy(msg2, "名片檔");
break;
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
showsig(cuser.userid, ans-'0');
sethomefile(buf, cuser.userid, "sig.0");
buf[strlen(buf) - 1] = ans;
mode = EDITSIG;
strcpy(msg2, "簽名檔");
break;
case 'c':
{
char buf[51];
int unum;
unum = do_getuser(cuser.userid, &xuser);
clear();
move(2,0);
outs("你原先的游標 : ");
outs(xuser.cursor);
getdata(3, 0, "請輸入新游標:", buf, 51, DOECHO, xuser.cursor);
if(buf[0] != '\0')
strcpy(xuser.cursor, buf);
if(buf[0] != '\0')
{
pressanykey("修改游標成功\!!");
substitute_record(fn_passwd, &xuser, sizeof(userec), unum);
}
else
pressanykey("游標未修改!!");
return 0;
}
/*
case 's':
sethomefile(buf, cuser.userid, "spam-list");
clear();
show_file(buf, 2, 2, STRIP_ALL);
strcpy(msg2, "拒收郵件名單");
break;
*/
case 's':
sethomefile(buf, cuser.userid, "spam-list");
clear();
ListEdit(buf);
return 0;
default:
return;
}
ans2= getans2(b_lines, 0, msg1, choose2, 3, 'q');
if (ans2 == 'e')
{
setutmpmode(mode);
if (vedit(buf, NA) == -1)
pressanykey("%s 沒有更動", msg2);
else
pressanykey("%s 更新完畢", msg2);
}
else if (ans2 == 'd')
unlink(buf);
return 0;
}
/* --------------------------------------------- */
/* 列出所有註冊使用者 */
/* --------------------------------------------- */
extern struct UCACHE *uidshm;
int usercounter, totalusers, showrealname;
ushort u_list_special;
static int
u_list_CB(uentp)
userec *uentp;
{
static int i;
char permstr[8], *ptr;
register int level;
if (uentp == NULL)
{
move(2, 0);
clrtoeol();
prints("[7m 使用者代號 %-25s 上站 文章 %s 最近光臨日期 [0m\n",
showrealname ? "真實姓名" : "綽號暱稱"
,HAS_PERM(PERM_SEEULEVELS) ? "等級" : "");
i = 3;
return 0;
}
if (bad_user_id(uentp->userid)) /* Ptt */
return 0;
if (uentp->userlevel < u_list_special)
return 0;
if (i == b_lines)
{
prints(COLOR1" 已顯示 %d/%d 人(%d%%) "COLOR2" (Space)[30m 看下一頁 [32m(Q)[30m 離開 [0m",
usercounter, totalusers, usercounter * 100 / totalusers);
i = igetch();
if (i == 'q' || i == 'Q')
return QUIT;
i = 3;
}
if (i == 3)
{
move(3, 0);
clrtobot();
}
level = uentp->userlevel;
strcpy(permstr, "----");
if (level & PERM_SYSOP)
permstr[0] = 'S';
else if (level & PERM_ACCOUNTS)
permstr[0] = 'A';
else if (level & PERM_DENYPOST)
permstr[0] = 'p';
if (level & (PERM_BOARD))
permstr[1] = 'B';
else if (level & (PERM_BM))
permstr[1] = 'b';
if (level & (PERM_XEMPT))
permstr[2] = 'X';
else if (level & (PERM_LOGINOK))
permstr[2] = 'R';
if (level & (PERM_CLOAK | PERM_SEECLOAK))
permstr[3] = 'C';
ptr = (char *) Etime(&uentp->lastlogin);
ptr[18] = '\0';
prints("%-14s %-27.27s%5d %5d %s %s\n",
uentp->userid, showrealname ? uentp->realname : uentp->username
,uentp->numlogins, uentp->numposts,
HAS_PERM(PERM_SEEULEVELS) ? permstr : "", ptr);
usercounter++;
i++;
return 0;
}
int u_list()
{
setutmpmode(LAUSERS);
showrealname = u_list_special = usercounter = 0;
totalusers = uidshm->number;
if (HAS_PERM(PERM_SEEULEVELS))
{
char *choose[2]={"11)特殊等級", "22)全部"};
if (getans2(b_lines, 0, "觀看?", choose, 2, '1') != '2')
u_list_special = 32;
}
if (HAS_PERM(PERM_CHATROOM) || HAS_PERM(PERM_SYSOP))
{
char *choose[2]={"11)真實姓名", "22)暱稱"};
if (getans2(b_lines, 0, "顯示?", choose, 2, '1') != '2')
showrealname = 1;
}
u_list_CB(NULL);
if (rec_apply(fn_passwd, u_list_CB, sizeof(userec)) == -1)
{
outs(msg_nobody);
return XEASY;
}
move(b_lines, 0);
clrtoeol();
prints(COLOR1" 已顯示 %d/%d 的使用者(系統容量無上限) "COLOR2" (請按任意鍵繼續) [m",
usercounter, totalusers);
igetkey();
return 0;
}
#ifdef REG_MAGICKEY
/* shakalaca.000712: new justify */
int u_verify()
{
char keyfile[80], buf[80], inbuf[15], *key;
FILE *fp;
if (HAS_PERM(PERM_LOGINOK))
{
pressanykey("您已經通過認證, 不須要輸入 MagicKey");
return XEASY;
}
sethomefile(keyfile, cuser.userid, fn_magickey);
if (!dashf(keyfile))
{
if(win_select("認證碼", "您還未發認證信, 要發出嗎?", 0, 2, 'y') == 'y')
mail_justify(cuser);
return XEASY;
}
if (!(fp = fopen(keyfile, "r")))
{
pressanykey("開啟檔案有問題, 請通知站長");
fclose(fp);
return XEASY;
}
fgets(buf, 80, fp);
fclose(fp);
for(key=buf;*key;key++)
if(*key == '\n')
{
*key='\0';
break;
}
key = buf;
getdata(b_lines, 0, "請輸入 MagicKey:", inbuf, 14, DOECHO, 0);
if (*inbuf)
{
if (strcmp(key, inbuf))
pressanykey("錯誤, 請重新輸入.");
else
{
int unum = getuser(cuser.userid);
unlink(keyfile);
pressanykey("恭喜您通過認證, 歡迎加入 :)");
cuser.userlevel |= (PERM_PAGE | PERM_POST | PERM_CHAT | PERM_LOGINOK);
mail2user(cuser.userid, "[註冊成功\囉]", BBSHOME"/etc/registered", 0);
substitute_record (fn_passwd, &cuser, sizeof (cuser), unum);
}
}
return RC_FULL;
}
#endif