Example #1
0
    if (count(Ban::getActiveBans($_POST['target'])) > 0) {
        BootstrapSkin::displayAlertBox("This target is already banned!", "alert-error", "", false, false);
        BootstrapSkin::displayInternalFooter();
        die;
    }
    $database = gGetDb();
    $ban = new Ban();
    $currentUsername = User::getCurrent()->getUsername();
    $database->transactionally(function () use($database, $ban, $duration, $currentUsername) {
        $ban->setDatabase($database);
        $ban->setActive(1);
        $ban->setType($_POST['type']);
        $ban->setTarget($_POST['target']);
        $ban->setUser($currentUsername);
        $ban->setReason($_POST['banreason']);
        $ban->setDuration($duration);
        $ban->save();
        Logger::banned($database, $ban, $_POST['banreason']);
    });
    $smarty->assign("ban", $ban);
    BootstrapSkin::displayAlertBox($smarty->fetch("bans/bancomplete.tpl"), "alert-info", "", false, false);
    Notification::banned($ban);
    BootstrapSkin::displayInternalFooter();
    die;
} elseif ($action == "unban") {
    global $smarty;
    if (!isset($_GET['id']) || $_GET['id'] == "") {
        BootstrapSkin::displayAlertBox("The ID parameter appears to be missing! This is probably a bug.", "alert-error", "Ahoy There! Something's not right...", true, false);
        BootstrapSkin::displayInternalFooter();
        die;
    }