-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathban.cpp
910 lines (809 loc) · 26 KB
/
ban.cpp
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
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
/**************************************************************************/
// ban.cpp - code related to banning players, pretty much a rewrite by Kal
/***************************************************************************
* The Dawn of Time v1.69r (c)1997-2004 Michael Garratt *
* >> A number of people have contributed to the Dawn codebase, with the *
* majority of code written by Michael Garratt - www.dawnoftime.org *
* >> To use this source code, you must fully comply with all the licenses *
* in licenses.txt... In particular, you may not remove this copyright *
* notice. *
***************************************************************************
* >> Original Diku Mud copyright (c)1990, 1991 by Sebastian Hammer, *
* Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, & Katja Nyboe. *
* >> Merc Diku Mud improvements copyright (C) 1992, 1993 by Michael *
* Chastain, Michael Quan, and Mitchell Tse. *
* >> ROM 2.4 is copyright 1993-1995 Russ Taylor and has been brought to *
* you by the ROM consortium: Russ Taylor([email protected]), *
* Gabrielle Taylor([email protected]) & Brian Moore([email protected]) *
* >> Oblivion 1.2 is copyright 1996 Wes Wagner *
**************************************************************************/
#include "include.h" // dawn standard includes
#include "ban.h"
// prototypes
extern const struct flag_type ban_types[];
char *flag_string( const struct flag_type *flag_table, int bits );
char *getline( char *str, char *buf, int bufsize); // string.cpp
int wild_match(register unsigned char *m, register unsigned char *n);
// globals
BAN_DATA *ban_list;
/**************************************************************************/
// create ban_type GIO lookup table
GIO_START(ban_data)
GIO_STR(sitemasks)
GIO_STR(intended_people)
GIO_WFLAG(type, ban_types)
GIO_INT(ban_date)
GIO_STR(reason)
GIO_STR(by)
GIO_INT(expire_date)
GIO_STR(custom_disconnect_message)
GIO_STR(always_allowed_email_masks)
GIO_STR(allowed_email_masks)
GIO_STR(disallowed_email_masks)
GIO_STR(disallowed_email_custom_message)
GIO_SHINT(level)
GIO_BOOL(enabled)
GIO_FINISH_NOCLEAR
/**************************************************************************/
void save_bans(void)
{
BAN_DATA *pban;
FILE *fp;
bool found = false;
int count=0;
fclose( fpReserve );
if ( ( fp = fopen( BAN_FILE, "w" ) ) == NULL )
{
bugf("save_bans(): fopen for write '%s' - error %d (%s)",
BAN_FILE, errno, strerror( errno));
fpReserve = fopen( NULL_FILE, "r" );
assert(fpReserve!=NULL);
return;
}
logf("Saving bans to %s.", BAN_FILE);
for (pban = ban_list; pban != NULL; pban = pban->next)
{
if (pban->permanent)
{
found = true;
fprintf( fp, "BAN%d~\n", count++);
GIO_SAVE_RECORD(ban_data, pban, fp, NULL);
}
}
fprintf( fp, "EOF~\n" );
fclose(fp);
fpReserve = fopen( NULL_FILE, "r" );
if (!found){
unlink(BAN_FILE);
}
}
/**************************************************************************/
void load_bans(void)
{
FILE *fp;
BAN_DATA *ban_last;
char *input=&str_empty[0];
int count=0;
if ( ( fp = fopen( BAN_FILE, "r" ) ) == NULL )
return;
logf("Loading bans from %s...", BAN_FILE);
ban_last = NULL;
for ( ; ; )
{
BAN_DATA *pban;
if ( feof(fp) )
{
fclose( fp );
logf("%d ban%s loaded.", count, count==1?"":"s");
return;
}
// check for end of file system
free_string(input); // recycle memory
input = fread_string(fp);
if (!str_cmp(input, "EOF")){
fclose( fp );
logf("%d ban%s loaded.", count, count==1?"":"s");
return;
}
pban = new_ban();
GIO_LOAD_RECORD(ban_data, pban, fp);
if(!IS_NULLSTR(pban->sitemasks)){
pban->permanent=true;
count++;
// check expire date - disable ban if appropriate
if(pban->enabled
&& pban->expire_date>0
&& pban->expire_date<current_time)
{
logf("BAN: %s set on: %.24s (lvl=%d ban, banflags=%s)\n"
"was disabled due to expiring %.24s.\n",
fix_string(pban->sitemasks),
((char*)ctime(&pban->ban_date)),
pban->level,
flag_string( ban_types, pban->type),
((char*)ctime(&pban->expire_date)));
pban->enabled=false;
pban->expire_date=0;
};
// add to linked list
if (ban_list == NULL){
ban_list = pban;
}else{
ban_last->next = pban;
}
ban_last = pban;
}
}
}
/**************************************************************************/
// returns true if 'matchto' can be matched by any of the multiple_masks
bool match_multiline_masks( char *multiple_masks, char *matchto)
{
char tmpb[MSL*4];
char *t;
char *banmask;
if(IS_NULLSTR(multiple_masks)){
return false;
}
while ( *multiple_masks)
{
multiple_masks = getline( multiple_masks, tmpb, MSL*4);
// find we the ban mask starts
banmask=tmpb;
while(is_space(*banmask)){
banmask++;
}
// terminate the ban mask at the first whitespace character
for (t=banmask; *t; t++){
if (is_space(*t)){
*t='\0';
break;
}
}
if(IS_NULLSTR(banmask))
continue;
if (wild_match((unsigned char*)banmask, (unsigned char*)matchto)){
return true;
}
}
return false;
}
/**************************************************************************/
BAN_DATA *check_ban_for_site(char *site,int type)
{
BAN_DATA *pban;
char host[MSL];
int i;
// get hostname and make sure it is lowercase
strcpy(host,site);
for ( i = 0; host[i] != '\0'; i++ ){
host[i] = LOWER(host[i]);
}
for ( pban = ban_list; pban; pban = pban->next )
{
// check ban is enabled
if(!pban->enabled)
continue;
// check ban type
if(pban->type!=type)
continue;
// check expire date - disable ban if appropriate
if(pban->enabled
&& pban->expire_date>0
&& pban->expire_date<current_time)
{
logf("BAN: %s set on: %.24s (lvl=%d ban, banflags=%s)\n"
"was disabled due to expiring %.24s.\n",
pban->sitemasks,
((char*)ctime(&pban->ban_date)),
pban->level,
flag_string( ban_types, pban->type),
((char*)ctime(&pban->expire_date)));
pban->enabled=false;
pban->expire_date=0;
};
// do wildcard mask pattern matching
if (match_multiline_masks( pban->sitemasks, host)){
return pban;
}
}
return NULL;
}
/**************************************************************************/
BAN_DATA *check_ban(connection_data *c,int type)
{
BAN_DATA *result;
result=check_ban_for_site(c->remote_hostname, type);
if(!result){
result=check_ban_for_site(c->remote_ip, type);
}
return result;
}
/**************************************************************************/
bool email_descriptor_unlock_id(connection_data *d)
{
#ifdef unix
char unlockname[MIL];
sprintf(unlockname, "emailunlockfile_%d_%d.tmp", getpid(), (int)current_time);
char buf[MSL];
unlink(unlockname);
sprintf(buf,
"Hello %s,\n"
"This email is an automated email message from %s \n"
"mud... This email is only sent\n"
"after someone creates a character on the game and requests for an unlock\n"
"code to be sent. The ip address of the person who requested the email is\n"
"%s\n"
"\n"
" Unlock details:\n"
" Character name: %s\n"
" Unlock code: %s\n"
"\n", CH(d)->pcdata->email, MUD_NAME,
d->remote_ip, CH(d)->name, CH(d)->pcdata->unlock_id);
append_string_to_file( unlockname, buf, true);
sprintf(buf,"mail %s -s \"%s dawn unlock code\" < %s ; sleep 10; rm %s &",
CH(d)->pcdata->email, CH(d)->name, unlockname, unlockname);
log_string(buf);
system(buf);
#else
CH(d)->wraplnf("Unlocking codes automatically "
"emailed is currently supported only by servers that run unix... your unlock "
"code is %s", CH(d)->pcdata->unlock_id);
#endif
return true;
}
/**************************************************************************/
// returns NULL if the email is okay, and a text message if the email isn't
char *is_invalid_email(char *email)
{
static char result[MSL];
unsigned char *newemail= (unsigned char*)email;
char *bad_characters=";<>{}[]`'\\/$|";
if (has_whitespace(email)){
sprintf(result,"The email address you enter can not have any whitespace "
"characters in it!`1reenter:`1");
return result;
}
if (!wild_match((unsigned char*)"*?@?*", newemail)){
sprintf(result,"The email address must have a @ in the middle somewhere...`1"
"e.g. [email protected]`1reenter:`1");
return result;
}
if (!wild_match((unsigned char*)"*?@?*.?*", newemail)){
sprintf(result,"The email address must have a @ in the middle "
"somewhere and at least one . in the domain name to the right of "
"the @ symbol..`1"
"e.g. [email protected]`1reenter:`1");
return result;
}
if (wild_match((unsigned char*)"*@*@*", newemail)){
sprintf(result,"The email address must not have more than "
"one @ symbol in it."
"`1e.g. [email protected] is valid... smith@[email protected] is invalid."
"`1reenter:`1");
return result;
}
logf("check_email_ban(): Doing Badcharacter checks.");
{ // check for the bad characters
int i;
char buf[MSL];
for(i=0; bad_characters[i];i++){
sprintf(result,"*%c*", bad_characters[i]);
if (wild_match((unsigned char*)buf, newemail)){
sprintf(result,"%c is not an allowed character to have in an email address.`1"
"reenter:`1", bad_characters[i]);
return result;
}
}
}
return NULL;
}
/**************************************************************************/
// ** This function explains to the user what happened, and what they **
// ** need to do... the returned values tell the calling function how **
// ** to handle the connection. **
//
// 0 accepted email, and id code emailed to them.
// 1 email rejected, they need another attempt.
// 2 if they should be disconnected - currently not used
int check_email_ban(connection_data *c, char *email_addy)
{
BAN_DATA *pban;
char host[MSL];
char *message;
unsigned char newemail[MSL];
int i;
bool foundallowedemail=false;
bool found_a_ban_with_an_invalid_email=false;
// get hostname and make sure it is lowercase
strcpy(host,c->remote_hostname);
logf("Starting check_email_ban(): host='%s', email addy='%s'",
host, email_addy);
for ( i = 0; host[i] != '\0'; i++ ){
host[i] = LOWER(host[i]);
}
// get the potential email and make sure it is lowercase
strcpy((char*)newemail,email_addy);
for ( i = 0; newemail[i] != '\0'; i++ ){
newemail[i] = LOWER(newemail[i]);
}
// validate the email addy is formatted okay
message=is_invalid_email((char*)&newemail[0]);
if(message){
// email wasnt okay, display the message why not
CH(c)->wrapln(message);
return 1;
}
logf("check_email_ban(): Doing ban checks.");
for ( pban = ban_list; pban; pban = pban->next )
{
// check ban is enabled
if(!pban->enabled)
continue;
// check ban type
if(pban->type!=BAN_EMAIL_REQ)
continue;
// do wildcard mask pattern matching
if (match_multiline_masks( pban->sitemasks, host)){
// matched... now check all email addies, start with always_allowed
logf("Found match with pban->sitemasks='%s', checking always allowed.", pban->sitemasks);
if(match_multiline_masks(pban->always_allowed_email_masks,
(char *)newemail)){
foundallowedemail=true;
}else{
// disallowed emails
logf("checking disallowed.");
if(match_multiline_masks(pban->disallowed_email_masks,
(char *)newemail)){
if(IS_NULLSTR(pban->disallowed_email_custom_message)){
logf("check_email_ban(): disallowed email address "
"'%s' from '%s'!", newemail, CH(c)->name);
CH(c)->wraplnf("The email address you supplied "
"'%s' is marked as a disallowed email address..."
"`1try another or disconnect:", newemail);
return 1;
}else{
CH(c)->println(pban->disallowed_email_custom_message);
}
return 1;
};
logf("Checking allowed.");
if(match_multiline_masks(pban->allowed_email_masks,
(char *)newemail)){
foundallowedemail=true;
}else{
found_a_ban_with_an_invalid_email=true;
}
}
}
}
logf("Found allowed = %s, found_a_ban_with_an_invalid_email=%s, %s - %s.",
foundallowedemail==true?"true":"false",
found_a_ban_with_an_invalid_email==true?"true":"false",
host,
(char*)newemail
);
if(foundallowedemail && !found_a_ban_with_an_invalid_email){
if(str_cmp(CH(c)->pcdata->email, (char*)newemail)){
replace_string(CH(c)->pcdata->email, (char*)newemail);
};
return 0;
}else{
if(c->newbie_creating){
CH(c)->wraplnf("The email address you supplied "
"'%s' was not found to be on the list of potentially "
"accepted email address (e.g. *@aol.com in the case of aol.com)"
"`1If dont have a valid email account, then you are unable to "
"create a character sorry."
"`1try another or disconnect:", newemail);
}else{
CH(c)->wraplnf("The email address you supplied "
"'%s' was not found to be on the list of potentially "
"accepted email address (e.g. *@aol.com in the case of aol.com)"
"`1try another or disconnect:", newemail);
}
return 1;
}
}
/**************************************************************************/
void ban_site(char_data *ch, char *argument, bool fPerm)
{
char buf[MSL];
char arg1[MIL], arg2[MIL];
char *sitemask;
BUFFER *buffer;
BAN_DATA *pban, *prev;
int type=0;
int count=0;
smash_tilde(argument);
// must have some pcdata to use the command
if(!TRUE_CH(ch)->pcdata){
do_huh(ch,"");
return;
}
// permbans - the adding of bans by a select group
if (fPerm
&& !IS_TRUSTED(ch,MAX_LEVEL-2)
&& !IS_SET(TRUE_CH(ch)->pcdata->council, COUNCIL_HEADLAW))
{
do_huh(ch,"");
return;
}
if(!fPerm){
if (ban_list == NULL)
{
ch->println( "No sites banned at this time." );
return;
}
buffer = new_buf();
add_buf(buffer,"`=t-================================== `=TBANS `=t===================================-\r\n");
count=-1;
for (pban = ban_list;pban != NULL;pban = pban->next)
{
count++;
if(!IS_NULLSTR(argument) &&
str_infix(argument,pban->sitemasks))
continue;
sprintf(buf,"%s%d)%-2.2s%-3.3s%-2.2s=============level: %3d, duration: %s, type: %s\r\n`c",
(pban->enabled?"`x":"`S"),
count,
((char*)ctime(&pban->ban_date))+8, // quick hack
((char*)ctime(&pban->ban_date))+4,
((char*)ctime(&pban->ban_date))+22,
pban->level,
pban->permanent?"perm":"temp",
flag_string( ban_types, pban->type));
add_buf(buffer,buf);
add_buf(buffer,pban->sitemasks);
int l=str_len(pban->sitemasks);
if(pban->sitemasks[l-1]!='\r' && pban->sitemasks[l-1]!='\n'){
add_buf(buffer,"\r\n");
}
add_buf(buffer,"`=t-===========================================================================-`x\r\n");
}
ch->sendpage(buf_string(buffer));
free_buf(buffer);
return;
}
argument = one_argument(argument,arg1);
argument = one_argument(argument,arg2);
if ( arg1[0] == '\0' )
{
if (ban_list == NULL)
{
ch->println( "No sites banned at this time." );
return;
}
buffer = new_buf();
add_buf(buffer,"==- Banned sites date lvl status type\r\n");
for (pban = ban_list;pban != NULL;pban = pban->next)
{
sprintf(buf,"%s%2d) %-40s %-2.2s%-3.3s%-2.2s %3d %s %s\n",
(pban->enabled?"`x":"`S"),
count++,
pban->sitemasks,
((char*)ctime(&pban->ban_date))+8, // quick hack
((char*)ctime(&pban->ban_date))+4,
((char*)ctime(&pban->ban_date))+22,
pban->level,
pban->permanent?"perm":"temp",
flag_string( ban_types, pban->type));
add_buf(buffer,buf);
}
ch->sendpage(buf_string(buffer));
free_buf(buffer);
return;
}
// find out what type of ban
if (arg2[0] == '\0' || !str_prefix(arg2,"all"))
type = BAN_ALL;
else if (!str_prefix(arg2,"newbies"))
type = BAN_NEWBIE;
else if (!str_prefix(arg2,"email"))
type = BAN_EMAIL_REQ;
else if (!str_prefix(arg2,"permit"))
type = BAN_PERMIT;
else
{
ch->println( "Acceptable ban types are all, newbies, email and permit." );
return;
}
sitemask = arg1;
if (str_len(sitemask) == 0)
{
ch->println( "You have to ban SOMETHING." );
return;
}
// check for a banning of themselves
if(IS_UNSWITCHED_MOB(ch)){
ch->println( "Players only!" );
return;
}
if(!TRUE_CH(ch)->desc){
ch->println( "You can't be doing this while linkdead." );
return;
}
if(wild_match((unsigned char*)sitemask, (unsigned char*)TRUE_CH(ch)->desc->remote_hostname)){
ch->printlnf( "Cant use a siteban mask ('%s') that bans yourself!", sitemask);
return;
};
prev = NULL;
for ( pban = ban_list; pban != NULL; prev = pban, pban = pban->next )
{
if (!str_cmp(sitemask,pban->sitemasks))
{
if (pban->level > get_trust(ch))
{
ch->println( "That ban was set by a higher power." );
return;
}
else
{
if (prev == NULL)
ban_list = pban->next;
else
prev->next = pban->next;
free_ban(pban);
}
}
}
pban = new_ban();
pban->by = str_dup(TRUE_CH(ch)->name);
pban->sitemasks=str_dup(sitemask);
if(type){
pban->type=type;
pban->enabled=true;
}
// a default level (97) unless atlevel is used
pban->level = IS_SET(ch->dyn,DYN_USING_ATLEVEL)?get_trust(ch):MAX_LEVEL-3;
// set ban type
//pban->ban_flags = type;
if (fPerm){
pban->permanent=true;
}
// add to the linked list of bans
pban->next = ban_list;
ban_list = pban;
// save the ban file
save_bans();
ch->printlnf("'%s' has been banned.",pban->sitemasks);
return;
}
/**************************************************************************/
void do_ban(char_data *ch, char *argument)
{
ban_site(ch,argument,false);
}
/**************************************************************************/
void do_permban(char_data *ch, char *argument)
{
ban_site(ch,argument,true);
}
/**************************************************************************/
void do_allow( char_data *ch, char *argument )
{
char arg[MIL];
BAN_DATA *prev;
BAN_DATA *curr;
one_argument( argument, arg );
if ( arg[0] == '\0' )
{
ch->println( "Remove which site from the ban list?" );
return;
}
prev = NULL;
for ( curr = ban_list; curr != NULL; prev = curr, curr = curr->next )
{
if ( !str_cmp( arg, curr->sitemasks) )
{
if (curr->level > get_trust(ch)){
ch->println( "You are not powerful enough to lift that ban." );
return;
}
if ( prev == NULL )
ban_list = ban_list->next;
else
prev->next = curr->next;
free_ban(curr);
ch->printlnf("Ban on %s lifted.",arg);
save_bans();
return;
}
}
ch->println( "Site is not banned." );
return;
}
/**************************************************************************/
// returns true if the connection was disconnected
bool check_connection_ban(connection_data *c)
{
BAN_DATA *pBan;
char *msg;
// check unconditional bans
if ( (pBan=check_ban(c,BAN_ALL)) )
{
if(IS_NULLSTR(pBan->custom_disconnect_message)){
c->write_colour("`1`1`WYour site has been `Rbanned`W from this mud!!!`1",0);
}else{
msg=note_format_string(str_dup(pBan->custom_disconnect_message));
c->write_colour(msg, 0);
free_string(msg);
}
logf("%s %s (%d) dropped due to complete siteban on their site.",
CH(c)?CH(c)->name:"(unknown name)", c->remote_hostname, c->connected_socket);
c->outtop=0;// empty output buffer
connection_close(c);
return true;
}
if ( c->newbie_creating && (pBan=check_ban(c,BAN_LOGNEWBIE)) )
{
logf("Autolog turned on for newbie '%s' from '%s'",
c->character->name, c->remote_hostname);
SET_BIT(c->character->act,PLR_LOG);
}
if ( c->newbie_creating && (pBan=check_ban(c,BAN_NEWBIE)) )
{
if(IS_NULLSTR(pBan->custom_disconnect_message)){
msg=note_format_string(str_dup(
"`1`1Due to abuse or potential abuse of this mud, we have "
"disabled newbie creation from your site. This will be in "
"place to maintain some control of who creates from your "
"site... If you are new here, "
"you are welcome to play, we can lift this for you to create "
"or maybe even permantly :) If you would like to talk with us "
"regarding this matter, email the administation of "
"this mud.`1`1"));
}else{
msg=note_format_string(str_dup(pBan->custom_disconnect_message));
}
c->write_colour(msg, 0);
free_string(msg);
connection_close(c);
logf("%s %s (%d) dropped due to being a newbie creating and from newbie banned site.",
CH(c)?CH(c)->name:"(unknown name)", c->remote_hostname, c->connected_socket);
return true;
}
// check bans with permits - only applied to those who have logged in
if ( CH(c) && (pBan=check_ban(c,BAN_PERMIT)) )
{
if (!IS_SET(CH(c)->act,PLR_PERMIT))
{
if(IS_NULLSTR(pBan->custom_disconnect_message)){
msg=note_format_string(str_dup(
"`1`1Due to abuse or potential abuse of this mud, we have "
"disabled access from your site. If you are new here, "
"you are welcome to play, we can lift this siteban for "
"individual players... If you would like to talk with us "
"regarding this matter, email the administation of "
"this mud.`1`1"));
}else{
msg=note_format_string(str_dup(pBan->custom_disconnect_message));
}
c->write_colour(msg, 0);
free_string(msg);
if (IS_IRCCON(c)){
sprintf( log_buf, "NONPERMITED PLAYER DROPPED DUE TO BAN\r\n"
"was %s@%s (connected via IRC). (socket = %d)",
CH(c)?CH(c)->name:"(unknown name)", c->remote_hostname, c->connected_socket);
}else{
sprintf( log_buf, "NONPERMITED PLAYER DROPPED DUE TO BAN\r\n"
"was %s@%s (socket = %d)",
CH(c)?CH(c)->name:"(unknown name)", c->remote_hostname, c->connected_socket);
}
wiznet(log_buf,NULL,NULL,WIZ_SECURE,0,get_trust(CH(c)) );
log_string(log_buf);
connection_close(c);
return true;
}
else
{
if (IS_IRCCON(c)){
sprintf( log_buf, "PERMITED PLAYER FROM BANNED SITE ACCEPTED\r\n"
"(%s@%s connected via IRC). (socket = %d)",
CH(c)?CH(c)->name:"(unknown name)", c->remote_hostname, c->connected_socket);
}else{
sprintf( log_buf, "PERMITED PLAYER FROM BANNED SITE ACCEPTED\r\n"
"(%s@%s connected via IRC). (socket = %d)",
CH(c)?CH(c)->name:"(unknown name)", c->remote_hostname, c->connected_socket);
}
wiznet(log_buf,NULL,NULL,WIZ_SECURE,0,get_trust(CH(c)));
log_string(log_buf);
}
}
return false;
}
/**************************************************************************/
bool banedit_show (char_data *ch, char *);
int wild_match(register unsigned char *m, register unsigned char *n);
/**************************************************************************/
void display_bans(char_data *ch, char *site,int type)
{
BAN_DATA *pban;
char host[MSL];
int i;
// get hostname and make sure it is lowercase
strcpy(host,site);
for ( i = 0; host[i] != '\0'; i++ ){
host[i] = LOWER(host[i]);
}
i=-1;
for ( pban = ban_list; pban; pban = pban->next )
{
i++;
// check ban is enabled
if(!pban->enabled)
continue;
// check ban type
if(pban->type!=type)
continue;
// do wildcard mask pattern matching
if (match_multiline_masks( pban->sitemasks, host)){
ch->desc->pEdit = (void *)pban;
ch->printlnf("Ban #%d", i);
banedit_show( ch, "");
}
}
}
/**************************************************************************/
void do_checkban( char_data *ch, char * argument)
{
void * pTemp = NULL;
BAN_DATA *pBan;
if(IS_NULLSTR(argument)){
ch->println( "syntax: checkban <ispaddy of player>");
return;
}
if(str_len(argument)<4){
ch->println( "syntax: checkban <ispaddy of player>");
ch->println( "Must be longer than 4 characters");
return;
}
pTemp = ch->desc->pEdit;
ch->printlnf( "==- CHECK BAN ON: '%s'",argument);
ch->printlnf( "- Newbies: %s",
(pBan=check_ban_for_site(argument,BAN_NEWBIE))?"`Rdenied`x":"`Gallowed`x");
if(pBan){
display_bans(ch, argument,BAN_NEWBIE);
}
ch->printlnf( "- Permit/Letgained check: %s",
(pBan=check_ban_for_site(argument,BAN_PERMIT))?"`Rdenied`x":"`Gallowed`x");
if(pBan){
display_bans(ch, argument,BAN_PERMIT);
}
ch->printlnf( "- Email check: %s",
(pBan=check_ban_for_site(argument,BAN_EMAIL_REQ))?"`Rdenied`x":"`Gallowed`x");
if(pBan){
display_bans(ch, argument,BAN_EMAIL_REQ);
}
ch->printlnf( "- All: %s",
(pBan=check_ban_for_site(argument,BAN_ALL))?"`Rdenied`x":"`Gallowed`x");
if(pBan){
display_bans(ch, argument,BAN_ALL);
}
ch->desc->pEdit = pTemp;
}
/**************************************************************************/
void do_showban( char_data *ch, char * argument)
{
void * pTemp = NULL;
BAN_DATA *pBan;
int count;
if(IS_NULLSTR(argument)){
ch->println( "syntax: showban <number of ban in the ban list>");
return;
}
count=atoi(argument);
for ( pBan = ban_list; pBan; pBan = pBan->next ){
if(--count<0)
break;
}
if(!pBan){
ch->println( "There aren't that many bans.");
return;
}
pTemp = ch->desc->pEdit;
ch->desc->pEdit = (void *)pBan;
banedit_show( ch, "");
ch->desc->pEdit = pTemp;
}
/**************************************************************************/