Exemplo n.º 1
0
function mod_ban_post($board, $delete, $post, $token = false)
{
    global $config, $mod;
    if (!openBoard($board)) {
        error($config['error']['noboard']);
    }
    if (!hasPermission($config['mod']['delete'], $board)) {
        error($config['error']['noaccess']);
    }
    $security_token = make_secure_link_token($board . '/ban/' . $post);
    $query = prepare(sprintf('SELECT ' . ($config['ban_show_post'] ? '*' : '`ip`, `thread`') . ' FROM ``posts_%s`` WHERE `id` = :id', $board));
    $query->bindValue(':id', $post);
    $query->execute() or error(db_error($query));
    if (!($_post = $query->fetch(PDO::FETCH_ASSOC))) {
        error($config['error']['404']);
    }
    $thread = $_post['thread'];
    $ip = $_post['ip'];
    if (isset($_POST['new_ban'], $_POST['reason'], $_POST['length'], $_POST['board'])) {
        require_once 'inc/mod/ban.php';
        if (isset($_POST['ip'])) {
            $ip = $_POST['ip'];
        }
        Bans::new_ban($_POST['ip'], $_POST['reason'], $_POST['length'], $_POST['board'] == '*' ? false : $_POST['board'], false, $config['ban_show_post'] ? $_post : false);
        if (isset($_POST['public_message'], $_POST['message'])) {
            // public ban message
            $length_english = Bans::parse_time($_POST['length']) ? 'for ' . until(Bans::parse_time($_POST['length'])) : 'permanently';
            $_POST['message'] = preg_replace('/[\\r\\n]/', '', $_POST['message']);
            $_POST['message'] = str_replace('%length%', $length_english, $_POST['message']);
            $_POST['message'] = str_replace('%LENGTH%', strtoupper($length_english), $_POST['message']);
            $query = prepare(sprintf('UPDATE ``posts_%s`` SET `body_nomarkup` = CONCAT(`body_nomarkup`, :body_nomarkup) WHERE `id` = :id', $board));
            $query->bindValue(':id', $post);
            $query->bindValue(':body_nomarkup', sprintf("\n<tinyboard ban message>%s</tinyboard>", utf8tohtml($_POST['message'])));
            $query->execute() or error(db_error($query));
            rebuildPost($post);
            modLog("Attached a public ban message to post #{$post}: " . utf8tohtml($_POST['message']));
            buildThread($thread ? $thread : $post);
            buildIndex();
        } elseif (isset($_POST['delete']) && (int) $_POST['delete']) {
            // Delete post
            deletePost($post);
            modLog("Deleted post #{$post}");
            // Rebuild board
            buildIndex();
            // Rebuild themes
            rebuildThemes('post-delete', $board);
        }
        header('Location: ?/' . sprintf($config['board_path'], $board) . $config['file_index'], true, $config['redirect_http']);
    }
    $args = array('ip' => $ip, 'hide_ip' => !hasPermission($config['mod']['show_ip'], $board), 'post' => $post, 'board' => $board, 'delete' => (bool) $delete, 'boards' => listBoards(), 'token' => $security_token);
    mod_page(_('New ban'), 'mod/ban_form.html', $args);
}
Exemplo n.º 2
0
 public function action()
 {
     global $board;
     switch ($this->action) {
         case 'reject':
             error(isset($this->message) ? $this->message : 'Posting throttled by filter.');
         case 'ban':
             if (!isset($this->reason)) {
                 error('The ban action requires a reason.');
             }
             $this->expires = isset($this->expires) ? $this->expires : false;
             $this->reject = isset($this->reject) ? $this->reject : true;
             $this->all_boards = isset($this->all_boards) ? $this->all_boards : false;
             Bans::new_ban($_SERVER['REMOTE_ADDR'], $this->reason, $this->expires, $this->all_boards ? false : $board['uri'], -1);
             if ($this->reject) {
                 if (isset($this->message)) {
                     error($message);
                 }
                 checkBan($board['uri']);
                 exit;
             }
             break;
         default:
             error('Unknown filter action: ' . $this->action);
     }
 }
Exemplo n.º 3
0
 public function action()
 {
     global $board;
     $this->add_note = isset($this->add_note) ? $this->add_note : false;
     if ($this->add_note) {
         $query = prepare('INSERT INTO ``ip_notes`` VALUES (NULL, :ip, :mod, :time, :body)');
         $query->bindValue(':ip', $_SERVER['REMOTE_ADDR']);
         $query->bindValue(':mod', -1);
         $query->bindValue(':time', time());
         $query->bindValue(':body', "Autoban message: " . $this->post['body']);
         $query->execute() or error(db_error($query));
     }
     if (isset($this->action)) {
         switch ($this->action) {
             case 'reject':
                 error(isset($this->message) ? $this->message : 'Posting throttled by filter.');
             case 'ban':
                 if (!isset($this->reason)) {
                     error('The ban action requires a reason.');
                 }
                 $this->expires = isset($this->expires) ? $this->expires : false;
                 $this->reject = isset($this->reject) ? $this->reject : true;
                 $this->all_boards = isset($this->all_boards) ? $this->all_boards : false;
                 Bans::new_ban($_SERVER['REMOTE_ADDR'], $this->reason, $this->expires, $this->all_boards ? false : $board['uri'], -1);
                 if ($this->reject) {
                     if (isset($this->message)) {
                         error($message);
                     }
                     checkBan($board['uri']);
                     exit;
                 }
                 break;
             default:
                 error('Unknown filter action: ' . $this->action);
         }
     }
 }