Пример #1
0
function replyban_run()
{
    global $db, $mybb, $lang, $templates, $theme, $headerinclude, $header, $footer, $replyban, $moderation;
    $lang->load("replyban");
    if ($mybb->input['action'] != "replyban" && $mybb->input['action'] != "do_replyban" && $mybb->input['action'] != "liftreplyban") {
        return;
    }
    if ($mybb->input['action'] == "replyban") {
        $tid = $mybb->get_input('tid', MyBB::INPUT_INT);
        $thread = get_thread($tid);
        if (!is_moderator($thread['fid'], "canmanagethreads")) {
            error_no_permission();
        }
        if (!$thread['tid']) {
            error($lang->error_invalidthread);
        }
        $thread['subject'] = htmlspecialchars_uni($thread['subject']);
        $lang->reply_bans_for = $lang->sprintf($lang->reply_bans_for, $thread['subject']);
        check_forum_password($thread['fid']);
        build_forum_breadcrumb($thread['fid']);
        add_breadcrumb($thread['subject'], get_thread_link($thread['tid']));
        add_breadcrumb($lang->reply_bans);
        $query = $db->query("\r\n\t\t\tSELECT r.*, u.username\r\n\t\t\tFROM " . TABLE_PREFIX . "replybans r\r\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (r.uid=u.uid)\r\n\t\t\tWHERE r.tid='{$thread['tid']}'\r\n\t\t\tORDER BY r.dateline DESC\r\n\t\t");
        while ($ban = $db->fetch_array($query)) {
            $ban['reason'] = htmlspecialchars_uni($ban['reason']);
            $ban['username'] = build_profile_link($ban['username'], $ban['uid']);
            if ($ban['lifted'] == 0) {
                $ban['lifted'] = $lang->permanent;
            } else {
                $ban['lifted'] = my_date('relative', $ban['lifted'], '', 2);
            }
            $alt_bg = alt_trow();
            eval("\$ban_bit .= \"" . $templates->get("moderation_replyban_bit") . "\";");
        }
        if (!$ban_bit) {
            eval("\$ban_bit = \"" . $templates->get("moderation_replyban_no_bans") . "\";");
        }
        // Generate the banned times dropdown
        $liftlist = '';
        $bantimes = fetch_ban_times();
        foreach ($bantimes as $time => $title) {
            $selected = '';
            if (isset($banned['bantime']) && $banned['bantime'] == $time) {
                $selected = " selected=\"selected\"";
            }
            $thattime = '';
            if ($time != '---') {
                $dateline = TIME_NOW;
                if (isset($banned['dateline'])) {
                    $dateline = $banned['dateline'];
                }
                $thatime = my_date("D, jS M Y @ g:ia", ban_date2timestamp($time, $dateline));
                $thattime = " ({$thatime})";
            }
            eval("\$liftlist .= \"" . $templates->get("moderation_replyban_liftlist") . "\";");
        }
        eval("\$replyban = \"" . $templates->get("moderation_replyban") . "\";");
        output_page($replyban);
    }
    if ($mybb->input['action'] == "do_replyban" && $mybb->request_method == "post") {
        // Verify incoming POST request
        verify_post_check($mybb->get_input('my_post_key'));
        $tid = $mybb->get_input('tid', MyBB::INPUT_INT);
        $thread = get_thread($tid);
        if (!is_moderator($thread['fid'], "canmanagethreads")) {
            error_no_permission();
        }
        if (!$thread['tid']) {
            error($lang->error_invalidthread);
        }
        $user = get_user_by_username($mybb->input['username'], array('fields' => array('username')));
        if (!$user['uid']) {
            error($lang->error_invaliduser);
        }
        $mybb->input['reason'] = $mybb->get_input('reason');
        if (!trim($mybb->input['reason'])) {
            error($lang->error_missing_reason);
        }
        $query = $db->simple_select('replybans', 'rid', "uid='{$user['uid']}' AND tid='{$thread['tid']}'");
        $existingban = $db->fetch_field($query, 'rid');
        if ($existingban > 0) {
            error($lang->error_alreadybanned);
        }
        if ($mybb->get_input('liftban') == '---') {
            $lifted = 0;
        } else {
            $lifted = ban_date2timestamp($mybb->get_input('liftban'), 0);
        }
        $reason = my_substr($mybb->input['reason'], 0, 240);
        $insert_array = array('uid' => $user['uid'], 'tid' => $thread['tid'], 'dateline' => TIME_NOW, 'reason' => $db->escape_string($reason), 'lifted' => $db->escape_string($lifted));
        $db->insert_query('replybans', $insert_array);
        log_moderator_action(array("tid" => $thread['tid'], "fid" => $thread['fid'], "uid" => $user['uid'], "username" => $user['username']), $lang->user_reply_banned);
        moderation_redirect("moderation.php?action=replyban&tid={$thread['tid']}", $lang->redirect_user_banned_replying);
    }
    if ($mybb->input['action'] == "liftreplyban") {
        // Verify incoming POST request
        verify_post_check($mybb->get_input('my_post_key'));
        $rid = $mybb->get_input('rid', MyBB::INPUT_INT);
        $query = $db->simple_select("replybans", "*", "rid='{$rid}'");
        $ban = $db->fetch_array($query);
        if (!$ban['rid']) {
            error($lang->error_invalidreplyban);
        }
        $thread = get_thread($ban['tid']);
        $user = get_user($ban['uid']);
        if (!$thread['tid']) {
            error($lang->error_invalidthread);
        }
        if (!is_moderator($thread['fid'], "canmanagethreads")) {
            error_no_permission();
        }
        $db->delete_query("replybans", "rid='{$ban['rid']}'");
        log_moderator_action(array("tid" => $thread['tid'], "fid" => $thread['fid'], "uid" => $user['uid'], "username" => $user['username']), $lang->user_reply_banned_lifted);
        moderation_redirect("moderation.php?action=replyban&tid={$thread['tid']}", $lang->redirect_reply_ban_lifted);
    }
    exit;
}
                $ret = $custommod->execute(intval($mybb->input['action']), $tids, $pids);
                $lang->custom_tool = $lang->sprintf($lang->custom_tool, $tool['name']);
                log_moderator_action($modlogdata, $lang->custom_tool);
                if ($mybb->input['inlinetype'] == 'search') {
                    clearinline($mybb->input['searchid'], 'search');
                    $lang->redirect_customtool_search = $lang->sprintf($lang->redirect_customtool_search, $tool['name']);
                    $return_url = htmlspecialchars_uni($mybb->input['url']);
                    redirect($return_url, $lang->redirect_customtool_search);
                } else {
                    clearinline($tid, 'thread');
                    if ($ret == 'forum') {
                        $lang->redirect_customtool_forum = $lang->sprintf($lang->redirect_customtool_forum, $tool['name']);
                        moderation_redirect(get_forum_link($fid), $lang->redirect_customtool_forum);
                    } else {
                        $lang->redirect_customtool_thread = $lang->sprintf($lang->redirect_customtool_thread, $tool['name']);
                        moderation_redirect(get_thread_link($tid), $lang->redirect_customtool_thread);
                    }
                }
                break;
            }
        }
        error_no_permission();
        break;
}
// Some little handy functions for our inline moderation
function getids($id, $type)
{
    global $mybb;
    $newids = array();
    $cookie = "inlinemod_" . $type . $id;
    $cookie_ids = explode("|", $mybb->cookies[$cookie]);
Пример #3
0
function lockposts_moderation()
{
    global $mybb, $lang, $db;
    if ($mybb->input['modtype'] != 'inlinepost') {
        return;
    }
    $lang->load('lockposts');
    $tid = intval($mybb->input['tid']);
    $fid = intval($mybb->input['fid']);
    $posts = getids($tid, 'thread');
    if (count($posts) < 1) {
        $mybb->input['action'] = 'multiunapprovethreads';
        // Display correct error
        return;
    }
    $lockpost = 0;
    if ($mybb->input['action'] == 'lockposts') {
        $lockpost = 1;
    } else {
        if ($mybb->input['action'] != 'unlockposts') {
            return;
        }
    }
    foreach ($posts as $pid) {
        $post = get_post($pid);
        if ($post['pid'] > 0) {
            $locked = array("locked" => intval($lockpost));
            $db->update_query("posts", $locked, "pid='{$post['pid']}'");
        }
    }
    clearinline($tid, 'thread');
    if ($lockpost) {
        moderation_redirect(get_post_link($posts[0]) . "#pid{$posts[0]}", $lang->redirect_inline_postslocked);
    } else {
        moderation_redirect(get_post_link($posts[0]) . "#pid{$posts[0]}", $lang->redirect_inline_postsunlocked);
    }
}