Пример #1
0
function unban($ipAddressArray)
{
    // Remove bans by id
    $bans = ban_list();
    if ($bans !== FALSE) {
        // Remove ip addresses from ban list
        foreach ($ipAddressArray as $ipaddress) {
            $idx = array_search(trim($ipaddress), $bans);
            if ($idx !== FALSE) {
                unset($bans[$idx]);
            } else {
                die("An invalid IP address was specified.");
            }
        }
        // Create flat data for file
        $raw_bans_flat = implode("\n", $bans);
        if (!empty($raw_bans_flat)) {
            $raw_bans_flat .= "\n";
        }
        // Rewrite data to file
        $ban_fp = @fopen(ban_file_path(), "w");
        if ($ban_fp === FALSE) {
            die("Unable to open ban file for writing.");
        }
        @flock($ban_fp, LOCK_EX);
        fputs($ban_fp, $raw_bans_flat);
        @flock($ban_fp, LOCK_UN);
        @fclose($ban_fp);
    } else {
        die("Unable to get list of current bans.");
    }
}
Пример #2
0
function show_bans()
{
    $list = ban_list();
    if ($list !== FALSE) {
        foreach ($list as $bannedip) {
            ?>
<p>
<input type="checkbox" name="id[]" value="<?php 
            echo htmlspecialchars_default($bannedip);
            ?>
" /> <?php 
            echo htmlspecialchars_default($bannedip);
            ?>
</p>
<?php 
        }
    }
}
Пример #3
0
                if ($mode == $LANG_BAN00['save'] && !empty($LANG_BAN00['save'])) {
                    $display = ban_save(COM_applyFilter($_POST['id'], true), COM_applyFilter($_POST['type']), COM_applyFilter($_POST['status'], true), COM_applyFilter($_POST['data']), $_POST['note']);
                } else {
                    $display .= COM_siteHeader('menu', $LANG_BAN00['ban_list']);
                    if (isset($_REQUEST['msg'])) {
                        $msg = COM_applyFilter($_REQUEST['msg'], true);
                        if ($msg > 0) {
                            $display .= COM_showMessage($msg, 'ban');
                        }
                    }
                    if ($_BAN_CONF['stopforumspam']) {
                        $db_location = $_CONF['path'] . 'plugins/ban/files/' . $_BAN_CONF['stopforumspam_database_name'];
                        if (file_exists($db_location)) {
                            $stats = stat($db_location);
                            $database_age = $stats[9];
                            if ($database_age > time() - 86400 * $_BAN_CONF['stopforumspam_file_date']) {
                                // db file is less than stop forum spam old date
                            } else {
                                //$display .= COM_showMessage ($msg, 'ban');
                                $display .= COM_showMessageText($LANG_BAN00['stopforumspam_note']);
                            }
                        }
                    }
                    $display .= ban_list($database_age);
                    $display .= COM_siteFooter();
                }
            }
        }
    }
}
echo $display;