Temporary Ban 2.0 SP1.1 This YaBB mod will allow you to set temporary bans to a day timer. When a temporarily-banned user visits the forum, he will be displayed a message such as this: Sorry, you have been banned from using this forum for 7 days. You have 5 days left until the ban will be lifted. After installing this mod, you can go to the "Ban Members" section of your YaBB Admin Center and set both temporary and permanent bans like this: IP NUMBER|NUMBER OF DAYS BANNED or EMAIL ADDRESS|NUMBER OF DAYS BANNED or USERNAME|NUMBER OF DAYS BANNED Example: 43.123|7 If you set the number of days banned to 0, the ban will be set as permanent. If you type in the IP address or e-mail address alone, the time banned will automatically be set to 0, a permanent ban. After you edit the ban list, if you re-enter, you will see a date and time at the end of each line, like this: 43.123|7|12/11/01 at 18:29:39 Do not touch the date/time unless you know what you are doing. If it is erased, the ban timer will be reset. V.2: - Works for SP1.1 - Username banning support added Shoeb Omar, RoyalRanger http://www.clickopedia.com, http://www.muslimteens.net, http://nessite.myrmid.com/ Sources\Admin.pl &is_admin; my( $l, $ban_user, $ban_time, $ban_date, @lines, @lines_email ); fopen(FILE, ">$vardir/ban.txt", 1); print FILE "$FORM{'ban'}"; fclose(FILE); fopen(FILE, ">$vardir/ban_email.txt", 1); print FILE "$FORM{'ban_email'}"; fclose(FILE); fopen(FILE, ">$vardir/ban_memname.txt", 1); print FILE "$FORM{'ban_memname'}"; fclose(FILE); my @lines = split( /\n/, $FORM{'ban'} ); fopen(FILE, ">$vardir/ban.txt", 1); foreach my $i (@lines) { ($ban_user, $ban_time, $ban_date) = split(/\|/,$i); if( $ban_time eq "" ) { $ban_time = 0; } if( $ban_date eq "" ) { $ban_date = $date; } print FILE qq~$ban_user|$ban_time|$ban_date\n~; } fclose(FILE); my @lines_email = split( /\n/, $FORM{'ban_email'} ); fopen(FILE, ">$vardir/ban_email.txt", 1); foreach my $i (@lines_email) { ($ban_user, $ban_time, $ban_date) = split(/\|/,$i); if( $ban_time eq "" ) { $ban_time = 0; } if( $ban_date eq "" ) { $ban_date = $date; } print FILE qq~$ban_user|$ban_time|$ban_date\n~; } fclose(FILE); my @lines_memname = split( /\n/, $FORM{'ban_memname'} ); fopen(FILE, ">$vardir/ban_memname.txt", 1); foreach my $i (@lines_memname) { ($ban_user, $ban_time, $ban_date) = split(/\|/,$i); if( $ban_time eq "" ) { $ban_time = 0; } if( $ban_date eq "" ) { $ban_date = $date; } print FILE qq~$ban_user|$ban_time|$ban_date\n~; } fclose(FILE); Sources\Security.pl sub banning { # IP BANNING fopen(BAN, "$vardir/ban.txt" ); @entries = ; fclose(BAN); foreach $ban_ip (@entries) { chomp $ban_ip; $str_len = length($ban_ip); $comp_ip = substr($user_ip,0,$str_len); if ($comp_ip eq $ban_ip) { fopen(LOG, ">>$vardir/ban_log.txt" ); print LOG "$user_ip\n"; fclose(LOG); $username = "Guest"; &fatal_error("$txt{'678'}$txt{'430'}!"); exit; } } # EMAIL BANNING if ($username ne 'Guest') { fopen(BAN, "$vardir/ban_email.txt" ); @entries = ; fclose(BAN); foreach $ban_email (@entries) { chomp $ban_email; if (lc $ban_email eq lc $settings[2]) { fopen(LOG, ">>$vardir/ban_log.txt" ); print LOG "$ban_email ($user_ip)\n"; fclose(LOG); $username = "Guest"; &fatal_error("$txt{'678'}$txt{'430'}!"); exit; } } # USERNAME BANNING if ($username ne 'Guest') { fopen(BAN, "$vardir/ban_memname.txt" ); @entries = ; fclose(BAN); foreach $ban_memname (@entries) { chomp $ban_memname; if (lc $ban_memname eq lc $settings[1]) { fopen(LOG, ">>$vardir/ban_log.txt" ); print LOG "$ban_memname ($user_ip)\n"; fclose(LOG); $username = "Guest"; &fatal_error("$txt{'678'}$txt{'430'}!"); exit; } } } } } sub banning { # IP BANNING my( $ban_user, $ban_time, $ban_date, $i, $ban_yes, $ban_total, $ban_left ); $remote_ip = $ENV{'REMOTE_ADDR'}; fopen(BAN, "$vardir/ban.txt" ); @entries = ; fclose(BAN); fopen(BAN, ">$vardir/ban.txt", 1); for( $i = 0; $i < @entries; $i++ ) { $ban_ip = $entries[$i]; chomp($ban_ip); ($ban_user, $ban_time, $ban_date) = split(/\|/,$ban_ip); if( $ban_time != 0 ) { $date1 = $ban_date; $date2 = $date; &calcdifference; if( $result >= $ban_time ) { next; } } $str_len = length($ban_user); $comp_ip = substr($remote_ip,0,$str_len); if ($comp_ip eq $ban_user) { fopen(LOG, ">>$vardir/ban_log.txt" ); print LOG "$remote_ip\n"; fclose(LOG); $username = "Guest"; $ban_total = $ban_time; if( $ban_time != 0 ) { $ban_left = $ban_total-$result; } $ban_yes = 1; } print BAN "$ban_ip\n"; } fclose(BAN); # EMAIL BANNING if ($username ne 'Guest') { $remote_ip = "$ENV{'REMOTE_ADDR'}"; fopen(BAN, "$vardir/ban_email.txt" ); @entries_email = ; fclose(BAN); fopen(BAN, ">$vardir/ban_email.txt", 1); for( $i = 0; $i < @entries_email; $i++ ) { $ban_email = $entries_email[$i]; chomp($ban_email); ($ban_user, $ban_time, $ban_date) = split(/\|/,$ban_email); if( $ban_time != 0 ) { $date1 = $ban_date; $date2 = $date; &calcdifference; if( $result >= $ban_time ) { next; } } if (lc $ban_user eq lc $settings[2]) { fopen(LOG, ">>$vardir/ban_log.txt" ); print LOG "$ban_email ($remote_ip)\n"; fclose(LOG); $username = "Guest"; $ban_total = $ban_time; if( $ban_time != 0 ) { $ban_left = $ban_total-$result; } $ban_yes = 1; } print BAN "$ban_email\n"; } fclose(BAN); } # USERNAME BANNING if ($username ne 'Guest') { fopen(BAN, "$vardir/ban_memname.txt" ); @entries = ; fclose(BAN); fopen(BAN, ">$vardir/ban_memname.txt", 1); foreach $ban_memname (@entries) { chomp $ban_memname; ($ban_user, $ban_time, $ban_date) = split(/\|/,$ban_memname); if( $ban_time != 0 ) { $date1 = $ban_date; $date2 = $date; &calcdifference; if( $result >= $ban_time ) { next; } } if ($ban_user eq $username) { fopen(LOG, ">>$vardir/ban_log.txt" ); print LOG "$ban_memname ($remote_ip)\n"; fclose(LOG); $username = "Guest"; $ban_total = $ban_time; if( $ban_time != 0 ) { $ban_left = $ban_total-$result; } $ban_yes = 1; } print BAN "$ban_memname\n"; } fclose(BAN); } if( $ban_yes == 1 ) { if( $ban_total == 0 ) { &fatal_error("$txt{'678'}$txt{'430'}!"); } else { &fatal_error("$txt{'678'}$tempban{'1'} $ban_total $tempban{'2'} $ban_left $tempban{'3'}"); } exit; } } english.lng if($MenuType == 1) { $tempban{'1'} = ", you have been banned from using this forum for"; $tempban{'2'} = "days.
You have"; $tempban{'3'} = "days left until the ban will be lifted.";
$txt{'724'} = "IP banning: (e.g. 192.168.12.213 or 128.0.*.*) - one entry per line"; $txt{'725'} = "Email banning: (e.g. badguy\@somewhere.com) - one entry per line"; $txt{'725a'} = "Username banning: (e.g. super_dude13) - one entry per line"; $txt{'724'} = "IP banning:

Put in form: IP Number|# of days to be banned -- 0 means permanent
(e.g. 192.168.12.213|7 or 192.168|14) - one entry per line.

You do not have to write the date/time of banning, it will be taken care of. If you do see the date/time of a current banning displayed, do not delete it, else the ban timer will be reset.
"; $txt{'725'} = "Email banning:

Put in Form: E-mail Address|# of days to be banned -- 0 mean permanent
(e.g. badguy\@somewhere.com|0) - one entry per line.

You do not have to write the date/time of banning, it will be taken care of. If you do see the date/time of a current banning displayed, do not delete it, else the ban timer will be reset.
"; $txt{'725a'} = "Username banning:

Put in Form: username|# of days to be banned -- 0 mean permanent
(e.g. bob|0) - one entry per line.

You do not have to write the date/time of banning, it will be taken care of. If you do see the date/time of a current banning displayed, do not delete it, else the ban timer will be reset.
";