[r1449]: branches / 2.6 / cgi-bin / yabb2 / Sources / Security.pm Maximize Restore History

Download this file

Security.pm    713 lines (661 with data), 25.2 kB

  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
###############################################################################
# Security.pm #
# $Date: 02.20.14 $ #
###############################################################################
# YaBB: Yet another Bulletin Board #
# Open-Source Community Software for Webmasters #
# Version: YaBB 2.6.0 #
# Packaged: February 20, 2014 #
# Distributed by: http://www.yabbforum.com #
# =========================================================================== #
# Copyright (c) 2000-2014 YaBB (www.yabbforum.com) - All Rights Reserved. #
# Software by: The YaBB Development Team #
# with assistance from the YaBB community. #
###############################################################################
# use strict;
# use warnings;
# no warnings qw(uninitialized once redefine);
use CGI::Carp qw(fatalsToBrowser);
our $VERSION = '2.6.0';
$securitypmver = 'YaBB 2.6.0 $Revision: 1449 $';
# Updates profile with current IP, if changed from last IP.
# Will only actually update the file when .vars is being updated anyway to save extra load on server.
if ( ${ $uid . $username }{'lastips'} !~ /^$user_ip\|/xsm ) {
${ $uid . $username }{'lastips'} = "$user_ip|${$uid.$username}{'lastips'}";
${ $uid . $username }{'lastips'} =~ s/^(.*?\|.*?\|.*?)\|.*/$1/xsm;
}
$scripturl = "$boardurl/$yyexec.$yyext";
$adminurl = "$boardurl/AdminIndex.$yyaext";
# BIG board check
if ( $INFO{'board'} =~ m{/}xsm ) {
( $INFO{'board'}, $INFO{'start'} ) = split /\//xsm, $INFO{'board'};
}
if ( $INFO{'num'} =~ m{/}xsm ) {
( $INFO{'num'}, $INFO{'start'} ) = split /\//xsm, $INFO{'num'};
}
if ( $INFO{'letter'} =~ m{/}xsm ) {
( $INFO{'letter'}, $INFO{'start'} ) = split /\//xsm, $INFO{'letter'};
}
if ( $INFO{'thread'} =~ m{/}xsm ) {
( $INFO{'thread'}, $INFO{'start'} ) = split /\//xsm, $INFO{'thread'};
}
# BIG thread check
$curnum = $INFO{'num'} || $INFO{'thread'} || $FORM{'threadid'};
if ( $curnum ne q{} ) {
if ( $curnum =~ /\D/xsm ) {
fatal_error( 'only_numbers_allowed', "Thread ID: '$curnum'" );
}
if ( !-e "$datadir/$curnum.txt" ) {
if ( eval { require Variables::Movedthreads; 1 } ) {
if ( !$moved_file{$curnum} ) {
fatal_error( 'not_found', "$datadir/$curnum.txt" );
}
while ( exists $moved_file{$curnum} ) {
$curnum = $moved_file{$curnum};
next if exists $moved_file{$curnum};
if ( !-e "$datadir/$curnum.txt" ) {
fatal_error( 'not_found', "$datadir/$curnum.txt" );
}
}
$INFO{'num'} = $INFO{'thread'} = $FORM{'threadid'} = $curnum;
}
}
MessageTotals( 'load', $curnum );
$currentboard = ${$curnum}{'board'};
}
else {
$currentboard = $INFO{'board'};
}
if ( $currentboard ne q{} ) {
if ( $currentboard !~ /\A[\s0-9A-Za-z#%+,-\.:=?@^_]+\Z/xsm ) {
fatal_error( 'invalid_character', "$maintxt{'board'}" );
}
if ( !-e "$boardsdir/$currentboard.txt" ) {
fatal_error( 'cannot_open', "$boardsdir/$currentboard.txt" );
}
( $boardname, $boardperms, $boardview ) =
split /\|/xsm, $board{"$currentboard"};
my $access = AccessCheck( $currentboard, q{}, $boardperms );
if ( !$iamadmin && $access ne 'granted' && $boardview != 1 ) {
fatal_error('no_access');
}
# Determine what category we are in.
$catid = ${ $uid . $currentboard }{'cat'};
( $cat, $catperms ) = split /\|/xsm, $catinfo{"$catid"};
$cataccess = CatAccess($catperms);
if ( $annboard eq q{} || $currentboard ne $annboard ) {
if ( !$cataccess ) { fatal_error('no_access'); }
}
$bdescrip = ${ $uid . $currentboard }{'description'};
# Create Hash %moderators and %moderatorgroups with all Moderators of the current board
foreach ( split /, ?/sm, ${ $uid . $currentboard }{'mods'} ) {
LoadUser($_);
$moderators{$_} = ${ $uid . $_ }{'realname'};
}
foreach ( split /, /sm, ${ $uid . $currentboard }{'modgroups'} ) {
$moderatorgroups{$_} = $_;
}
if ($staff) {
$iammod = is_moderator( $username, $currentboard );
if ( !$iammod && !$iamadmin && !$iamgmod && !$iamfmod ) { $staff = 0; }
}
if ( !$iamadmin ) {
my $accesstype = q{};
if ( $action eq 'post' ) {
if ( $INFO{'title'} eq 'CreatePoll' || $INFO{'title'} eq 'AddPoll' )
{
$accesstype = 3; # Post Poll
}
elsif ( $INFO{'num'} ) {
$accesstype = 2; # Post Reply
}
else {
$accesstype = 1; # Post Thread
}
}
$access = AccessCheck( $currentboard, $accesstype );
if ( $access ne 'granted' ) { fatal_error('no_access'); }
}
fopen( BOARDFILE, "$boardsdir/$currentboard.txt" )
|| fatal_error( 'not_found', "$boardsdir/$currentboard.txt", 1 );
while ( $yyThreadLine = <BOARDFILE> ) {
if ( $yyThreadLine =~ m{\A$curnum\|}oxsm ) { last; }
}
fclose(BOARDFILE);
chomp $yyThreadLine;
}
else {
### BIG category check
$currentcat = $INFO{'cat'} || $INFO{'catselect'};
if ( $currentcat ne q{} ) {
if ( $currentcat =~ m{/}xsm ) { fatal_error('no_cat_slash'); }
if ( $currentcat =~ m{\\}xsm ) { fatal_error('no_cat_backslash'); }
if ( $currentcat ne q{}
&& $currentcat !~ /\A[\s0-9A-Za-z#%+,-\.:=?@^_]+\Z/xsm )
{
fatal_error( 'invalid_character', "$maintxt{'cat'}" );
}
if ( !$cat{$currentcat} ) {
fatal_error( 'cannot_open', "$currentcat" );
}
# and need cataccess check!
$cataccess = CatAccess($catperms);
if ( !$cataccess ) { fatal_error('no_access'); }
}
}
sub is_admin {
if ( !$iamadmin ) { fatal_error('no_access'); }
return;
}
sub is_admin_or_gmod {
if ( !$iamadmin && !$iamgmod ) { fatal_error('no_access'); }
if ( $iamgmod && $action ne q{} ) {
require "$vardir/gmodsettings.txt";
if ( $gmod_access{"$action"} ne 'on'
&& $gmod_access2{"$action"} ne 'on' )
{
fatal_error('no_access');
}
}
return;
}
sub is_admin_or_gmod_or_fmod {
if ( !$iamadmin && !$iamgmod && !$iamfmod ) { fatal_error('no_access'); }
if ( $iamgmod && $action ne q{} ) {
require "$vardir/gmodsettings.txt";
if ( $gmod_access{"$action"} ne 'on'
&& $gmod_access2{"$action"} ne 'on' )
{
fatal_error('no_access');
}
}
return;
}
sub banning {
my @x = @_;
my $ban_user = $x[0] || $username;
my $ban_email = $x[1] || ${ $uid . $username }{'email'};
my $admincheck = $x[2];
if ( !$admincheck && ( $username eq 'admin' || $iamadmin ) ) { return; }
*write_banlog = sub {
my ($bantry) = @_;
if ($admincheck) {
fatal_error( 'banned',
"$register_txt{'678'}$register_txt{'430'}!" );
}
fopen( LOG, ">>$vardir/ban_log.txt" );
print {LOG} "$date|$bantry\n" or croak "$croak{'print'} LOG";
fclose(LOG);
UpdateCookie( 'delete', $ban_user );
$username = 'Guest';
$iamguest = 1;
fatal_error( 'banned', "$security_txt{'678'}$security_txt{'430'}!" );
};
my $tmb = 0;
$time = time;
*time_ban = sub {
for my $i ( 0 .. 3 ) {
if ( $banned[4] eq $timeban[$i] ) {
$tmb = $banned[2] + ( $bandays[$i] * 84_600 );
}
}
return $tmb;
};
fopen( BAN, "<$vardir/banlist.txt" )
|| fatal_error( 'cannot_open', "$vardir/banlist.txt", 1 );
@banlist = <BAN>;
for my $i (@banlist) {
chomp $i;
@banned = split /\|/xsm, $i;
$tmp = time_ban();
# IP BANNING
if ( $user_ip =~ /^$banned[1]/xsm ) { write_banlog("$user_ip"); }
if ( !$iamguest || $action eq 'register2' ) {
# EMAIL BANNING
if ( $ban_email =~ /$banned[1]/ixsm && ( $tmb > $time || $banned[4] eq 'p') ) {
write_banlog("$banned[1]($user_ip)");
}
# USERNAME BANNING
if ( $ban_user =~ m/^$banned[1]$/sm && ( $tmb > $time || $banned[4] eq 'p')) {
write_banlog("$banned[1]($user_ip)");
}
}
}
fclose(BAN);
return;
}
sub check_banlist {
# &check_banlist("email","IP","username"); - will return true if banned by any means
# This sub can be passed email address, IP, unencoded username or any combination thereof
# Returns E if banned by email address
# Returns I if banned by IP address
# Returns U if banned by username
# Returns all banning methods, unseparated (eg "EIU" if banned by all methods)
my ( $e_ban, $ip_ban, $u_ban ) = @_;
my $ban_rtn;
if ( !-e "$vardir/banlist.txt" ) {
if ( $e_ban && $email_banlist ) {
foreach ( split /,/xsm, $email_banlist ) {
if ( $_ eq $e_ban ) { $ban_rtn .= 'E'; last; }
}
}
if ( $ip_ban && $ip_banlist ) {
foreach ( split /,/xsm, $ip_banlist ) {
if ( $_ eq $ip_ban ) { $ban_rtn .= 'I'; last; }
}
}
if ( $u_ban && $user_banlist ) {
foreach ( split /,/xsm, $user_banlist ) {
if ( $_ eq $u_ban ) { $ban_rtn .= 'U'; last; }
}
}
}
else {
fopen( BAN, "$vardir/banlist.txt" )
|| fatal_error( 'cannot_open', "$vardir/banlist.txt", 1 );
@banlist = <BAN>;
fclose(BAN);
chomp @banlist;
my $tmb = 0;
$today = time;
*time_ban = sub {
for my $i ( 0 .. 3 ) {
if ( $banned[4] eq $timeban[$i] ) {
$tmb = $banned[2] + ( $bandays[$i] * 84_600 );
}
}
return $tmb;
};
for my $i (@banlist) {
@banned = split /\|/xsm, $i;
$tmb = time_ban();
if ( $banned[0] eq 'E' ) {
$banned[1] =~ s/\\@/@/xsm;
if (
(
$e_ban eq $banned[1]
&& $banned[4] ne 'p'
&& $tmb > $today
)
|| ( $e_ban eq $banned[1] && $banned[4] eq 'p' )
)
{
$ban_rtn .= $banned[0];
last;
}
}
}
for my $i (@banlist) {
@banned = split /\|/xsm, $i;
$tmb = time_ban();
if (
(
$banned[0] eq 'I'
&& $ip_ban eq $banned[1]
&& $banned[4] ne 'p'
&& $tmb > $today
)
|| $banned[0] eq 'I'
&& $ip_ban eq $banned[1]
&& $banned[4] eq 'p'
)
{
$ban_rtn .= $banned[0];
last;
}
}
for my $i (@banlist) {
@banned = split /\|/xsm, $i;
$tmb = time_ban();
if ( $banned[0] eq 'U' && $u_ban eq $banned[1] && ( ( $banned[4] ne 'p' && $tmb > $today ) || $banned[4] eq 'p' ) )
{
$ban_rtn .= $banned[0];
last;
}
}
}
return $ban_rtn;
}
sub CheckIcon {
# Check the icon so HTML cannot be exploited.
$icon =~ s/\Ahttp:\/\/.*\/(.*?)\..*?\Z/$1/xsm;
$icon =~ s/[^A-Za-z]//gxsm;
$icon =~ s/\\//gxsm;
$icon =~ s/\///gxsm;
my @iconlist =
qw( xx thumbup thumbdown exclamation question lamp smiley angry cheesy grin sad wink standard confidential urgent alert );
my $isicon = 0;
for my $x (@iconlist) {
if ( $icon eq $x ) {
$isicon = 1;
last;
}
}
if ( $isicon == 0 ) { $icon = 'xx'; }
else { $icon = $icon; }
return;
}
sub SearchAccess {
$advsearchaccess = q{};
$qcksearchaccess = q{};
if ( !exists $memberunfo{$username} ) { LoadUser($username); }
if ($iamguest) {
if ($enableguestsearch) { $advsearchaccess = 'granted'; }
if ($enableguestquicksearch) { $qcksearchaccess = 'granted'; }
return;
}
if ($iamadmin) {
$advsearchaccess = 'granted';
$qcksearchaccess = 'granted';
return;
}
@advsearch_groups = split /, /sm, $mgadvsearch;
if ( !$mgadvsearch ) { $advsearchaccess = 'granted'; }
@qcksearch_groups = split /, /sm, $mgqcksearch;
if ( !$mgqcksearch ) { $qcksearchaccess = 'granted'; }
$memberinform = $memberunfo{$username};
foreach my $advelement (@advsearch_groups) {
chomp $advelement;
if ( $advelement eq $memberinform ) { $advsearchaccess = 'granted'; }
foreach ( split /,/xsm, $memberaddgroup{$username} ) {
if ( $advelement eq $_ ) { $advsearchaccess = 'granted'; last; }
}
if ( $advsearchaccess eq 'granted' ) { last; }
}
foreach my $qckelement (@qcksearch_groups) {
chomp $qckelement;
if ( $qckelement eq $memberinform ) { $qcksearchaccess = 'granted'; }
foreach ( split /,/xsm, $memberaddgroup{$username} ) {
if ( $qckelement eq $_ ) { $qcksearchaccess = 'granted'; last; }
}
if ( $qcksearchaccess eq 'granted' ) { last; }
}
return;
}
sub AccessCheck {
my ( $curboard, $checktype, $boardperms ) = @_;
# Put whether it's a zero post count board in global variable
# to save need to reopen file many times.
if ( !exists $memberunfo{$username} ) { LoadUser($username); }
my $boardmod = 0;
foreach my $curuser ( split /, ?/sm, ${ $uid . $curboard }{'mods'} ) {
if ( $username eq $curuser ) { $boardmod = 1; }
}
@board_modgrps = split /, /sm, ${ $uid . $curboard }{'modgroups'};
@user_addgrps = split /,/xsm, ${ $uid . $username }{'addgroups'};
foreach my $curgroup (@board_modgrps) {
if ( ${ $uid . $username }{'position'} eq $curgroup ) { $boardmod = 1; }
foreach my $curaddgroup (@user_addgrps) {
if ( $curaddgroup eq $curgroup ) { $boardmod = 1; }
}
}
$INFO{'zeropost'} = ${ $uid . $curboard }{'zero'};
if ($iamadmin) { $access = 'granted'; return $access; }
my ( $viewperms, $topicperms, $replyperms, $pollperms, $attachperms );
if ( $username ne 'Guest' ) {
( $viewperms, $topicperms, $replyperms, $pollperms, $attachperms ) =
split /\|/xsm, ${ $uid . $username }{'perms'};
}
if ( $username eq 'Guest' && !$enable_guestposting ) {
$viewperms = 0;
$topicperms = 1;
$replyperms = 1;
$pollperms = 1;
$attachperms = 1;
}
my $access = 'denied';
if ( $checktype == 1 ) { # Post access check
@allowed_groups = split /, /sm, ${ $uid . $curboard }{'topicperms'};
if ( ${ $uid . $curboard }{'topicperms'} eq q{} ) {
$access = 'granted';
}
if ( $topicperms == 1 ) { $access = 'notgranted'; }
}
elsif ( $checktype == 2 ) { # Reply access check
if ( $iamgmod || $iamfmod || $boardmod ) { $access = 'granted'; }
else {
@allowed_groups =
split /, /sm, ${ $uid . $curboard }{'replyperms'};
if ( ${ $uid . $curboard }{'replyperms'} eq q{} ) {
$access = 'granted';
}
if ( $replyperms == 1 && !$topicstart{$username} ) {
$access = 'notgranted';
}
}
}
elsif ( $checktype == 3 ) { # Poll access check
@allowed_groups = split /, /sm, ${ $uid . $curboard }{'pollperms'};
if ( ${ $uid . $curboard }{'pollperms'} eq q{} ) {
$access = 'granted';
}
if ( $pollperms == 1 ) { $access = 'notgranted'; }
}
elsif ( $checktype == 4 ) { # Attachment access check
if ( ${ $uid . $curboard }{'attperms'} == 1 ) { $access = 'granted'; }
if ( $attachperms == 1 ) { $access = 'notgranted'; }
}
else { # Board access check
@allowed_groups = split /, /sm, $boardperms;
if ( $boardperms eq q{} ) { $access = 'granted'; }
if ( $viewperms == 1 ) { $access = 'notgranted'; }
}
# age and gender check
if ( !$iamadmin && !$iamgmod && !$iamfmod && !$boardmod ) {
if (
(
${ $uid . $curboard }{'minageperms'}
|| ${ $uid . $curboard }{'maxageperms'}
)
&& ( !$age || $age == 0 )
)
{
$access = 'notgranted';
}
elsif ( ${ $uid . $curboard }{'minageperms'}
&& $age < ${ $uid . $curboard }{'minageperms'} )
{
$access = 'notgranted';
}
elsif ( ${ $uid . $curboard }{'maxageperms'}
&& $age > ${ $uid . $curboard }{'maxageperms'} )
{
$access = 'notgranted';
}
if ( ${ $uid . $curboard }{'genderperms'}
&& !${ $uid . $username }{'gender'} )
{
$access = 'notgranted';
}
elsif (${ $uid . $curboard }{'genderperms'} eq 'M'
&& ${ $uid . $username }{'gender'} eq 'Female' )
{
$access = 'notgranted';
}
elsif (${ $uid . $curboard }{'genderperms'} eq 'F'
&& ${ $uid . $username }{'gender'} eq 'Male' )
{
$access = 'notgranted';
}
}
if ( $access ne 'granted' && $access ne 'notgranted' ) {
$memberinform = $memberunfo{$username};
foreach my $element (@allowed_groups) {
chomp $element;
if ( $element eq $memberinform ) { $access = 'granted'; }
foreach ( split /,/xsm, $memberaddgroup{$username} ) {
if ( $element eq $_ ) { $access = 'granted'; last; }
}
if ( $element eq $topicstart{$username} ) { $access = 'granted'; }
if ( $element eq 'Global Moderator' && ( $iamadmin || $iamgmod ) ) {
$access = 'granted';
}
if ( $element eq 'Mid Moderator'
&& ( $iamadmin || $iamgmod || $iamfmod ) )
{
$access = 'granted';
}
if ( $element eq 'Moderator'
&& ( $iamadmin || $iamgmod || $iamfmod || $boardmod ) )
{
$access = 'granted';
}
if ( $access eq 'granted' ) { last; }
}
}
return $access;
}
sub CatAccess {
my ($cataccess) = @_;
if ( $iamadmin || $cataccess eq q{} ) { return 1; }
my $access = 0;
@allow_groups = split /, /sm, $cataccess;
if ( !exists $memberunfo{$username} ) { LoadUser($username); }
$memberinform = $memberunfo{$username};
foreach my $element (@allow_groups) {
chomp $element;
if ( $element eq $memberinform ) { $access = 1; }
foreach ( split /,/xsm, $memberaddgroup{$username} ) {
if ( $element eq $_ ) { $access = 1; last; }
}
if ( $element eq 'Moderator'
&& ( $iamgmod || exists $moderators{$username} ) )
{
$access = 1;
}
if ( $element eq 'Global Moderator' && $iamgmod ) { $access = 1; }
if ( $element eq 'Mid Moderator' && $iamfmod ) { $access = 1; }
if ( $access == 1 ) { last; }
}
return $access;
}
sub email_domain_check {
### Based upon Distilled Email Domains mod by AstroPilot ###
my ($checkdomain) = @_;
if ($checkdomain) {
if ( -e "$vardir/email_domain_filter.txt" ) {
require "$vardir/email_domain_filter.txt";
}
if ($bdomains) {
foreach ( split /,/xsm, $bdomains ) {
$my_x = $_;
if ( $_ !~ /\@/xsm ) { $_ = "\@$_"; }
elsif ( $_ !~ /^\./xsm ) { $_ = ".$_"; }
@my_ch = split /\./xsm, $my_x;
@my_ch_e = split /\./xsm, $checkdomain;
if ( $checkdomain =~ m/$_/ism
|| ( $my_ch[0] eq q{} && $my_ch[-1] eq $my_ch_e[-1] ) )
{
fatal_error( 'domain_not_allowed', "$_" );
}
}
}
}
### Distilled Email Domains mod end ###
return;
}
sub GroupPerms {
my ( $groupAll, $groupCheck ) = @_;
if ( $groupAll && $groupCheck ) {
$allowGroups = 0;
foreach my $selectGroup ( split /,\ /xsm, $groupCheck ) {
if ( ( $selectGroup eq ${ $uid . $username }{'position'} )
|| ( $selectGroup eq $memberunfo{$username} ) )
{
$allowGroups = 1;
last;
}
foreach ( split /,/xsm, ${ $uid . $username }{'addgroups'} ) {
if ( $selectGroup eq $_ ) { $allowGroups = 1; last; }
}
}
}
else {
$allowGroups = 1;
}
return;
}
sub ipban_update {
# This is for quick updating for banning + unbanning
if ( $iamadmin || $iamgmod || $iamfmod ) {
my $ban = $INFO{'ban'};
my $lev = $INFO{'lev'};
my $ban_email = $INFO{'ban_email'};
my $ban_mem = $INFO{'ban_memname'};
my $unban = $INFO{'unban'};
my $user = $INFO{'username'};
$ban_mem = $do_scramble_id ? decloak($ban_mem) : $ban_mem;
$ban_email =~ s/@/\\@/xsm;
my $time = time;
fopen( BAN, "<$vardir/banlist.txt" ) || fatal_error( 'cannot_open', "$vardir/banlist.txt", 1 );
my @mybana = <BAN>;
chomp @mybana;
fclose(BAN);
if ( !@mybana ) {
fopen( BANA, ">$vardir/banlist.txt" ) || fatal_error( 'cannot_open', "$vardir/banlist.txt", 1 );
print {BANA} qq~1\n~;
fclose (BANA);
}
undef @mybana;
fopen( BAN, "<$vardir/banlist.txt" ) || fatal_error( 'cannot_open', "$vardir/banlist.txt", 1 );
my @myban = <BAN>;
chomp @myban;
fclose(BAN);
if ( $unban == 1 ) {
fopen( BAN2, ">$vardir/banlist.txt" ) || fatal_error( 'cannot_open', "$vardir/banlist.txt", 1 );
foreach my $i (@myban) {
@banned = split /\|/xsm, $i;
if ( $ban eq $banned[1]
|| $ban_email eq $banned[1]
|| $ban_mem eq $banned[1] )
{
$un_ban = q~~;
}
else {
$un_ban =
qq~$banned[0]|$banned[1]|$banned[2]|$banned[3]|$banned[4]|\n~;
}
print {BAN2} $un_ban or "$croak{'print'} UNBAN";
}
fclose(BAN2);
}
else {
$ihave = 0;
$tmb = $time;
for my $i (@myban) {
@banned = split /\|/xsm, $i;
for my $j ( 0 .. 3 ) {
if ( $banned[4] eq $timeban[$j] ) {
$tmb = $banned[2] + ( $bandays[$j] * 86_400 );
}
}
if ($ban) {
$type = 'I';
$banned = $ban;
}
elsif ($ban_email) {
$type = 'I';
$banned = $ban_email;
}
elsif ($ban_mem) {
$type = 'U';
$banned = $ban_mem;
}
if ( $banned eq $banned[1] && ( $banned[4] eq 'p' || $tmp > $time ) ) {
$ihave = 1;
}
}
if ( $banned && $ihave != 1 && $banned ne '127.0.0.1' ) {
$add_ban =
qq~$type|$banned|$time|${$uid.$username}{'realname'} ($username)|$lev|\n~;
}
fopen( BAN2, ">>$vardir/banlist.txt" ) || fatal_error( 'cannot_open', "$vardir/banlist.txt", 1 );
print {BAN2} $add_ban or croak "$croak{'print'} BAN2";
fclose(BAN2);
}
$yySetLocation = qq~$scripturl?action=viewprofile;username=$user~;
redirectexit();
}
return;
}
1;