Exemplo n.º 1
0
/**
 * MyBB 1.8
 * Copyright 2014 MyBB Group, All Rights Reserved
 *
 * Website: http://www.mybb.com
 * License: http://www.mybb.com/about/license
 *
 */
function task_hourlycleanup($task)
{
    global $db, $lang, $plugins;
    $time = array('threads' => TIME_NOW, 'searchlog' => TIME_NOW - 60 * 60 * 24, 'captcha' => TIME_NOW - 60 * 60 * 24, 'question' => TIME_NOW - 60 * 60 * 24);
    if (is_object($plugins)) {
        $args = array('task' => &$task, 'time' => &$time);
        $plugins->run_hooks('task_hourlycleanup', $args);
    }
    require_once MYBB_ROOT . "inc/class_moderation.php";
    $moderation = new Moderation();
    // Delete moved threads with time limits
    $query = $db->simple_select('threads', 'tid', "deletetime != '0' AND deletetime < '" . (int) $time['threads'] . "'");
    while ($tid = $db->fetch_field($query, 'tid')) {
        $moderation->delete_thread($tid);
    }
    // Delete old searches
    $db->delete_query("searchlog", "dateline < '" . (int) $time['searchlog'] . "'");
    // Delete old captcha images
    $cut = TIME_NOW - 60 * 60 * 24 * 7;
    $db->delete_query("captcha", "dateline < '" . (int) $time['captcha'] . "'");
    // Delete old registration questions
    $cut = TIME_NOW - 60 * 60 * 24 * 7;
    $db->delete_query("questionsessions", "dateline < '" . (int) $time['question'] . "'");
    add_task_log($task, $lang->task_hourlycleanup_ran);
}
Exemplo n.º 2
0
     admin_redirect("index.php?module=user-banning");
 }
 $query = $db->simple_select("banned", "*", "uid='{$mybb->input['uid']}'");
 $ban = $db->fetch_array($query);
 if (!$ban['uid']) {
     flash_message($lang->error_invalid_ban, 'error');
     admin_redirect("index.php?module=user-banning");
 }
 $user = get_user($ban['uid']);
 if (is_super_admin($user['uid']) && ($mybb->user['uid'] != $user['uid'] && !is_super_admin($mybb->user['uid']))) {
     flash_message($lang->cannot_perform_action_super_admin_general, 'error');
     admin_redirect("index.php?module=user-banning");
 }
 if ($mybb->request_method == "post") {
     require_once MYBB_ROOT . "inc/class_moderation.php";
     $moderation = new Moderation();
     $query = $db->simple_select("threads", "tid", "uid='{$user['uid']}'");
     while ($thread = $db->fetch_array($query)) {
         $moderation->delete_thread($thread['tid']);
     }
     $query = $db->simple_select("posts", "pid", "uid='{$user['uid']}'");
     while ($post = $db->fetch_array($query)) {
         $moderation->delete_post($post['pid']);
     }
     $cache->update_reportedposts();
     $plugins->run_hooks("admin_user_banning_prune_commit");
     // Log admin action
     log_admin_action($mybb->input['uid'], $user['username']);
     flash_message($lang->success_pruned, 'success');
     admin_redirect("index.php?module=user-banning");
 } else {
Exemplo n.º 3
0
 /**
  * Provides a method to delete an users posts and threads
  *
  * @param array Array of user ids, false if they're already set (eg when using the delete_user function)
  */
 function delete_posts($delete_uids = false)
 {
     global $db, $plugins;
     if ($delete_uids != false) {
         $this->delete_uids = array_map('intval', (array) $delete_uids);
         foreach ($this->delete_uids as $key => $uid) {
             if (!$uid || is_super_admin($uid) || $uid == $mybb->user['uid']) {
                 // Remove super admins
                 unset($this->delete_uids[$key]);
             }
         }
         $this->delete_uids = implode(',', $this->delete_uids);
     }
     require_once MYBB_ROOT . 'inc/class_moderation.php';
     $moderation = new Moderation();
     $plugins->run_hooks('datahandler_user_delete_posts', $this);
     // Threads
     $query = $db->simple_select('threads', 'tid', "uid IN({$this->delete_uids})");
     while ($tid = $db->fetch_field($query, 'tid')) {
         $moderation->delete_thread($tid);
     }
     // Posts
     $pids = array();
     $query = $db->simple_select('posts', 'pid', "uid IN({$this->delete_uids})");
     while ($pid = $db->fetch_field($query, 'pid')) {
         $moderation->delete_post($pid);
         $pids[] = (int) $pid;
     }
     // Delete Reports made to users's posts/threads
     if (!empty($pids)) {
         $db->delete_query('reportedcontent', "type='posts' AND id IN(" . implode(',', $pids) . ")");
     }
 }
Exemplo n.º 4
0
            eval("\$announcements_global = \"" . $templates->get("modcp_no_announcements_global") . "\";");
        }
        eval("\$announcements_global = \"" . $templates->get("modcp_announcements_global") . "\";");
    }
    $announcements_forum = '';
    fetch_forum_announcements();
    if (!$announcements_forum) {
        eval("\$announcements_forum = \"" . $templates->get("modcp_no_announcements_forum") . "\";");
    }
    $plugins->run_hooks("modcp_announcements");
    eval("\$announcements = \"" . $templates->get("modcp_announcements") . "\";");
    output_page($announcements);
}
if ($mybb->input['action'] == "do_modqueue") {
    require_once MYBB_ROOT . "inc/class_moderation.php";
    $moderation = new Moderation();
    // Verify incoming POST request
    verify_post_check($mybb->get_input('my_post_key'));
    if ($mybb->usergroup['canmanagemodqueue'] == 0) {
        error_no_permission();
    }
    $plugins->run_hooks("modcp_do_modqueue_start");
    $mybb->input['threads'] = $mybb->get_input('threads', MyBB::INPUT_ARRAY);
    $mybb->input['posts'] = $mybb->get_input('posts', MyBB::INPUT_ARRAY);
    $mybb->input['attachments'] = $mybb->get_input('attachments', MyBB::INPUT_ARRAY);
    if (!empty($mybb->input['threads'])) {
        $threads = array_map("intval", array_keys($mybb->input['threads']));
        $threads_to_approve = $threads_to_delete = array();
        // Fetch threads
        $query = $db->simple_select("threads", "tid", "tid IN (" . implode(",", $threads) . "){$flist_queue_threads}");
        while ($thread = $db->fetch_array($query)) {
Exemplo n.º 5
0
 /**
  * Updates a post that is already in the database.
  *
  */
 function update_post()
 {
     global $db, $mybb, $plugins;
     // Yes, validating is required.
     if ($this->get_validated() != true) {
         die("The post needs to be validated before inserting it into the DB.");
     }
     if (count($this->get_errors()) > 0) {
         die("The post is not valid.");
     }
     $post =& $this->data;
     $post['pid'] = (int) $post['pid'];
     $existing_post = get_post($post['pid']);
     $post['tid'] = $existing_post['tid'];
     $post['fid'] = $existing_post['fid'];
     $forum = get_forum($post['fid']);
     $forumpermissions = forum_permissions($post['fid'], $post['uid']);
     // Check if this is the first post in a thread.
     $options = array("order_by" => "dateline", "order_dir" => "asc", "limit_start" => 0, "limit" => 1);
     $query = $db->simple_select("posts", "pid", "tid='" . (int) $post['tid'] . "'", $options);
     $first_post_check = $db->fetch_array($query);
     if ($first_post_check['pid'] == $post['pid']) {
         $first_post = true;
     } else {
         $first_post = false;
     }
     // Decide on the visibility of this post.
     $ismod = is_moderator($post['fid'], "", $post['uid']);
     // Keep visibility for unapproved and deleted posts
     if ($existing_post['visible'] == 0) {
         $visible = 0;
     } elseif ($existing_post['visible'] == -1) {
         $visible = -1;
     } elseif ($forumpermissions['mod_edit_posts'] == 1 && !$ismod) {
         $visible = 0;
         require_once MYBB_ROOT . "inc/class_moderation.php";
         $moderation = new Moderation();
         $moderation->unapprove_posts(array($post['pid']));
     } else {
         $visible = 1;
     }
     // Update the thread details that might have been changed first.
     if ($first_post) {
         $this->tid = $post['tid'];
         if (isset($post['prefix'])) {
             $this->thread_update_data['prefix'] = (int) $post['prefix'];
         }
         if (isset($post['subject'])) {
             $this->thread_update_data['subject'] = $db->escape_string($post['subject']);
         }
         if (isset($post['icon'])) {
             $this->thread_update_data['icon'] = (int) $post['icon'];
         }
         if (count($this->thread_update_data) > 0) {
             $plugins->run_hooks("datahandler_post_update_thread", $this);
             $db->update_query("threads", $this->thread_update_data, "tid='" . (int) $post['tid'] . "'");
         }
     }
     // Prepare array for post updating.
     $this->pid = $post['pid'];
     if (isset($post['subject'])) {
         $this->post_update_data['subject'] = $db->escape_string($post['subject']);
     }
     if (isset($post['message'])) {
         $this->post_update_data['message'] = $db->escape_string($post['message']);
     }
     if (isset($post['editreason']) && trim($post['editreason']) != '') {
         $this->post_update_data['editreason'] = $db->escape_string(trim($post['editreason']));
     }
     if (isset($post['icon'])) {
         $this->post_update_data['icon'] = (int) $post['icon'];
     }
     if (isset($post['options'])) {
         if (isset($post['options']['disablesmilies'])) {
             $this->post_update_data['smilieoff'] = $db->escape_string($post['options']['disablesmilies']);
         }
         if (isset($post['options']['signature'])) {
             $this->post_update_data['includesig'] = $db->escape_string($post['options']['signature']);
         }
     }
     // If we need to show the edited by, let's do so.
     if ($mybb->settings['showeditedby'] == 1 && !is_moderator($post['fid'], "caneditposts", $post['edit_uid']) || $mybb->settings['showeditedbyadmin'] == 1 && is_moderator($post['fid'], "caneditposts", $post['edit_uid'])) {
         $this->post_update_data['edituid'] = (int) $post['edit_uid'];
         $this->post_update_data['edittime'] = TIME_NOW;
     }
     $plugins->run_hooks("datahandler_post_update", $this);
     $db->update_query("posts", $this->post_update_data, "pid='" . (int) $post['pid'] . "'");
     // Automatic subscription to the thread
     if ($post['options']['subscriptionmethod'] != "" && $post['uid'] > 0) {
         switch ($post['options']['subscriptionmethod']) {
             case "pm":
                 $notification = 2;
                 break;
             case "email":
                 $notification = 1;
                 break;
             default:
                 $notification = 0;
         }
         require_once MYBB_ROOT . "inc/functions_user.php";
         add_subscribed_thread($post['tid'], $notification, $post['uid']);
     } else {
         $db->delete_query("threadsubscriptions", "uid='" . (int) $post['uid'] . "' AND tid='" . (int) $post['tid'] . "'");
     }
     update_forum_lastpost($post['fid']);
     update_last_post($post['tid']);
     // Return the thread's first post id and whether or not it is visible.
     $this->return_values = array('visible' => $visible, 'first_post' => $first_post);
     $plugins->run_hooks("datahandler_post_update_end", $this);
     return $this->return_values;
 }
 * $Id$
 */
define("IN_MYBB", 1);
define('THIS_SCRIPT', 'moderation.php');
$templatelist = 'changeuserbox,loginbox,moderation_delayedmoderation_custommodtool,moderation_delayedmodaction_notes,moderation_delayedmoderation_merge,moderation_delayedmoderation_move';
$templatelist .= ',moderation_delayedmoderation,moderation_deletethread,moderation_deletepoll,moderation_deleteposts_post,moderation_deleteposts,moderation_mergeposts_post,moderation_mergeposts';
$templatelist .= ',moderation_move,moderation_threadnotes_modaction,moderation_threadnotes_delayedmodaction,moderation_threadnotes,moderation_getip_modoptions,moderation_getip,moderation_merge';
$templatelist .= ',moderation_split_post,moderation_split,moderation_inline_deletethreads,moderation_inline_movethreads,moderation_inline_deleteposts,moderation_inline_mergeposts';
$templatelist .= ',moderation_inline_splitposts,forumjump_bit,forumjump_special,forumjump_advanced,forumdisplay_password_wrongpass,forumdisplay_password';
require_once "./global.php";
require_once MYBB_ROOT . "inc/functions_post.php";
require_once MYBB_ROOT . "inc/functions_upload.php";
require_once MYBB_ROOT . "inc/class_parser.php";
$parser = new postParser();
require_once MYBB_ROOT . "inc/class_moderation.php";
$moderation = new Moderation();
// Load global language phrases
$lang->load("moderation");
$plugins->run_hooks("moderation_start");
// Get some navigation if we need it
switch ($mybb->input['action']) {
    case "reports":
        add_breadcrumb($lang->reported_posts);
        break;
    case "allreports":
        add_breadcrumb($lang->all_reported_posts);
        break;
}
$tid = intval($mybb->input['tid']);
$pid = intval($mybb->input['pid']);
$fid = intval($mybb->input['fid']);
Exemplo n.º 7
0
/**
 * MyBB 1.8
 * Copyright 2014 MyBB Group, All Rights Reserved
 *
 * Website: http://www.mybb.com
 * License: http://www.mybb.com/about/license
 *
 */
function task_delayedmoderation($task)
{
    global $db, $lang, $plugins;
    require_once MYBB_ROOT . "inc/class_moderation.php";
    $moderation = new Moderation();
    require_once MYBB_ROOT . "inc/class_custommoderation.php";
    $custommod = new CustomModeration();
    // Iterate through all our delayed moderation actions
    $query = $db->simple_select("delayedmoderation", "*", "delaydateline <= '" . TIME_NOW . "'");
    while ($delayedmoderation = $db->fetch_array($query)) {
        if (is_object($plugins)) {
            $args = array('task' => &$task, 'delayedmoderation' => &$delayedmoderation);
            $plugins->run_hooks('task_delayedmoderation', $args);
        }
        $tids = explode(',', $delayedmoderation['tids']);
        $input = my_unserialize($delayedmoderation['inputs']);
        if (my_strpos($delayedmoderation['type'], "modtool") !== false) {
            list(, $custom_id) = explode('_', $delayedmoderation['type'], 2);
            $custommod->execute($custom_id, $tids);
        } else {
            switch ($delayedmoderation['type']) {
                case "openclosethread":
                    $closed_tids = $open_tids = array();
                    $query2 = $db->simple_select("threads", "tid,closed", "tid IN({$delayedmoderation['tids']})");
                    while ($thread = $db->fetch_array($query2)) {
                        if ($thread['closed'] == 1) {
                            $closed_tids[] = $thread['tid'];
                        } else {
                            $open_tids[] = $thread['tid'];
                        }
                    }
                    if (!empty($closed_tids)) {
                        $moderation->open_threads($closed_tids);
                    }
                    if (!empty($open_tids)) {
                        $moderation->close_threads($open_tids);
                    }
                    break;
                case "deletethread":
                    foreach ($tids as $tid) {
                        $moderation->delete_thread($tid);
                    }
                    break;
                case "move":
                    foreach ($tids as $tid) {
                        $moderation->move_thread($tid, $input['new_forum']);
                    }
                    break;
                case "stick":
                    $unstuck_tids = $stuck_tids = array();
                    $query2 = $db->simple_select("threads", "tid,sticky", "tid IN({$delayedmoderation['tids']})");
                    while ($thread = $db->fetch_array($query2)) {
                        if ($thread['sticky'] == 1) {
                            $stuck_tids[] = $thread['tid'];
                        } else {
                            $unstuck_tids[] = $thread['tid'];
                        }
                    }
                    if (!empty($stuck_tids)) {
                        $moderation->unstick_threads($stuck_tids);
                    }
                    if (!empty($unstuck_tids)) {
                        $moderation->stick_threads($unstuck_tids);
                    }
                    break;
                case "merge":
                    // $delayedmoderation['tids'] should be a single tid
                    if (count($tids) != 1) {
                        continue;
                    }
                    // explode at # sign in a url (indicates a name reference) and reassign to the url
                    $realurl = explode("#", $input['threadurl']);
                    $input['threadurl'] = $realurl[0];
                    // Are we using an SEO URL?
                    if (substr($input['threadurl'], -4) == "html") {
                        // Get thread to merge's tid the SEO way
                        preg_match("#thread-([0-9]+)?#i", $input['threadurl'], $threadmatch);
                        preg_match("#post-([0-9]+)?#i", $input['threadurl'], $postmatch);
                        if ($threadmatch[1]) {
                            $parameters['tid'] = $threadmatch[1];
                        }
                        if ($postmatch[1]) {
                            $parameters['pid'] = $postmatch[1];
                        }
                    } else {
                        // Get thread to merge's tid the normal way
                        $splitloc = explode(".php", $input['threadurl']);
                        $temp = explode("&", my_substr($splitloc[1], 1));
                        if (!empty($temp)) {
                            for ($i = 0; $i < count($temp); $i++) {
                                $temp2 = explode("=", $temp[$i], 2);
                                $parameters[$temp2[0]] = $temp2[1];
                            }
                        } else {
                            $temp2 = explode("=", $splitloc[1], 2);
                            $parameters[$temp2[0]] = $temp2[1];
                        }
                    }
                    if ($parameters['pid'] && !$parameters['tid']) {
                        $post = get_post($parameters['pid']);
                        $mergetid = $post['tid'];
                    } else {
                        if ($parameters['tid']) {
                            $mergetid = $parameters['tid'];
                        }
                    }
                    $mergetid = (int) $mergetid;
                    $mergethread = get_thread($mergetid);
                    if (!$mergethread['tid']) {
                        continue;
                    }
                    if ($mergetid == $delayedmoderation['tids']) {
                        // sanity check
                        continue;
                    }
                    if ($input['subject']) {
                        $subject = $input['subject'];
                    } else {
                        $query = $db->simple_select("threads", "subject", "tid='{$delayedmoderation['tids']}'");
                        $subject = $db->fetch_field($query, "subject");
                    }
                    $moderation->merge_threads($mergetid, $delayedmoderation['tids'], $subject);
                    break;
                case "removeredirects":
                    foreach ($tids as $tid) {
                        $moderation->remove_redirects($tid);
                    }
                    break;
                case "removesubscriptions":
                    $moderation->remove_thread_subscriptions($tids, true);
                    break;
                case "approveunapprovethread":
                    $approved_tids = $unapproved_tids = array();
                    $query2 = $db->simple_select("threads", "tid,visible", "tid IN({$delayedmoderation['tids']})");
                    while ($thread = $db->fetch_array($query2)) {
                        if ($thread['visible'] == 1) {
                            $approved_tids[] = $thread['tid'];
                        } else {
                            $unapproved_tids[] = $thread['tid'];
                        }
                    }
                    if (!empty($approved_tids)) {
                        $moderation->unapprove_threads($approved_tids);
                    }
                    if (!empty($unapproved_tids)) {
                        $moderation->approve_threads($unapproved_tids);
                    }
                    break;
                case "softdeleterestorethread":
                    $delete_tids = $restore_tids = array();
                    $query2 = $db->simple_select("threads", "tid,visible", "tid IN({$delayedmoderation['tids']})");
                    while ($thread = $db->fetch_array($query2)) {
                        if ($thread['visible'] == -1) {
                            $restore_tids[] = $thread['tid'];
                        } else {
                            $delete_tids[] = $thread['tid'];
                        }
                    }
                    if (!empty($restore_tids)) {
                        $moderation->restore_threads($restore_tids);
                    }
                    if (!empty($delete_tids)) {
                        $moderation->soft_delete_threads($delete_tids);
                    }
                    break;
            }
        }
        $db->delete_query("delayedmoderation", "did='{$delayedmoderation['did']}'");
    }
    add_task_log($task, $lang->task_delayedmoderation_ran);
}
Exemplo n.º 8
0
/**
 * Deletes a post from the database
 *
 * @param int The thread ID
 */
function delete_post($pid, $tid = "")
{
    global $moderation;
    if (!is_object($moderation)) {
        require_once MYBB_ROOT . "inc/class_moderation.php";
        $moderation = new Moderation();
    }
    return $moderation->delete_post($pid);
}
/**
 * MyBB 1.6
 * Copyright 2010 MyBB Group, All Rights Reserved
 *
 * Website: http://mybb.com
 * License: http://mybb.com/about/license
 *
 * $Id: userpruning.php 5297 2010-12-28 22:01:14Z Tomm $
 */
function task_userpruning($task)
{
    global $db, $lang, $mybb, $cache;
    if ($mybb->settings['enablepruning'] != 1) {
        return;
    }
    // Are we pruning by posts?
    if ($mybb->settings['enableprunebyposts'] == 1) {
        $in_usergroups = array();
        $users = array();
        $usergroups = $cache->read("usergroups");
        foreach ($usergroups as $gid => $usergroup) {
            // Exclude admin, moderators, super moderators, banned
            if ($usergroup['canmodcp'] == 1 || $usergroup['cancp'] == 1 || $usergroup['issupermod'] == 1 || $usergroup['isbannedgroup'] == 1) {
                continue;
            }
            $in_usergroups[] = $gid;
        }
        // If we're not pruning unactivated users, then remove them from the criteria
        if ($mybb->settings['pruneunactived'] == 0) {
            $key = array_search('5', $in_usergroups);
            unset($in_usergroups[$key]);
        }
        $regdate = TIME_NOW - intval($mybb->settings['dayspruneregistered']) * 24 * 60 * 60;
        $query = $db->simple_select("users", "uid", "regdate <= " . intval($regdate) . " AND postnum <= " . intval($mybb->settings['prunepostcount']) . " AND usergroup IN(" . $db->escape_string(implode(',', $in_usergroups)) . ")");
        while ($user = $db->fetch_array($query)) {
            $users[$user['uid']] = $user['uid'];
        }
    }
    // Are we pruning unactivated users?
    if ($mybb->settings['pruneunactived'] == 1) {
        $regdate = TIME_NOW - intval($mybb->settings['dayspruneunactivated']) * 24 * 60 * 60;
        $query = $db->simple_select("users", "uid", "regdate <= " . intval($regdate) . " AND usergroup='5'");
        while ($user = $db->fetch_array($query)) {
            $users[$user['uid']] = $user['uid'];
        }
    }
    if (!empty($users)) {
        $uid_list = $db->escape_string(implode(',', $users));
        // Delete the user
        $db->delete_query("userfields", "ufid IN({$uid_list})");
        $db->delete_query("privatemessages", "uid IN({$uid_list})");
        $db->delete_query("events", "uid IN({$uid_list})");
        $db->delete_query("moderators", "id IN({$uid_list}) AND isgroup='0'");
        $db->delete_query("forumsubscriptions", "uid IN({$uid_list})");
        $db->delete_query("threadsubscriptions", "uid IN({$uid_list})");
        $db->delete_query("sessions", "uid IN({$uid_list})");
        $db->delete_query("banned", "uid IN({$uid_list})");
        $db->delete_query("threadratings", "uid IN({$uid_list})");
        $db->delete_query("joinrequests", "uid IN({$uid_list})");
        $db->delete_query("awaitingactivation", "uid IN({$uid_list})");
        $query = $db->delete_query("users", "uid IN({$uid_list})");
        $num_deleted = $db->affected_rows($query);
        // Remove any of the user(s) uploaded avatars
        $query = $db->simple_select("users", "avatar", "uid IN ({$uid_list}) AND avatartype = 'upload'");
        if ($db->num_rows($query)) {
            while ($avatar = $db->fetch_field($query, "avatar")) {
                $avatar = substr($avatar, 2, -20);
                @unlink(MYBB_ROOT . $avatar);
            }
        }
        // Are we removing the posts/threads of a user?
        if ($mybb->settings['prunethreads'] == 1) {
            require_once MYBB_ROOT . "inc/class_moderation.php";
            $moderation = new Moderation();
            // Threads
            $query = $db->simple_select("threads", "tid", "uid IN({$uid_list})");
            while ($thread = $db->fetch_array($query)) {
                $moderation->delete_thread($thread['tid']);
            }
            // Posts
            $query = $db->simple_select("posts", "pid", "uid IN({$uid_list})");
            while ($post = $db->fetch_array($query)) {
                $moderation->delete_post($post['pid']);
            }
        } else {
            // We're just updating the UID
            $db->update_query("posts", array('uid' => 0), "uid IN({$uid_list})");
        }
        // Update forum stats
        update_stats(array('numusers' => '-' . intval($num_deleted)));
        $cache->update_moderators();
        $cache->update_banned();
    }
    add_task_log($task, $lang->task_userpruning_ran);
}
Exemplo n.º 10
0
             $moderation->restore_threads(array($tid));
             log_moderator_action($modlogdata, $lang->thread_restored);
             if ($mybb->input['ajax'] == 1) {
                 header("Content-type: application/json; charset={$lang->settings['charset']}");
                 echo json_encode(array("data" => '1'));
             } else {
                 redirect(get_forum_link($fid), $lang->redirect_threadrestored);
             }
         } else {
             error_no_permission();
         }
     } else {
         if (is_moderator($fid, "canrestoreposts")) {
             // Select the first post before this
             require_once MYBB_ROOT . "inc/class_moderation.php";
             $moderation = new Moderation();
             $moderation->restore_posts(array($pid));
             log_moderator_action($modlogdata, $lang->post_restored);
             $redirect = get_post_link($pid, $tid) . "#pid{$pid}";
             if ($mybb->input['ajax'] == 1) {
                 header("Content-type: application/json; charset={$lang->settings['charset']}");
                 echo json_encode(array("data" => '1'));
             } else {
                 redirect($redirect, $lang->redirect_postrestored);
             }
         } else {
             error_no_permission();
         }
     }
 } else {
     error($lang->redirect_norestore);
Exemplo n.º 11
0
 *
 */
define("IN_MYBB", 1);
define('THIS_SCRIPT', 'moderation.php');
$templatelist = 'changeuserbox,loginbox,moderation_delayedmoderation_custommodtool,moderation_delayedmodaction_notes,moderation_delayedmoderation_merge,moderation_delayedmoderation_move';
$templatelist .= ',moderation_delayedmoderation,moderation_deletethread,moderation_deletepoll,moderation_mergeposts_post,moderation_viewthreadnotes,moderation_confirmation';
$templatelist .= ',moderation_move,moderation_threadnotes_modaction,moderation_threadnotes_delayedmodaction,moderation_threadnotes,moderation_getip_modoptions,moderation_getip,moderation_getpmip,moderation_merge';
$templatelist .= ',moderation_split_post,moderation_split,moderation_inline_deletethreads,moderation_inline_movethreads,moderation_inline_deleteposts,moderation_inline_mergeposts,moderation_threadnotes_modaction_error';
$templatelist .= ',moderation_inline_splitposts,forumjump_bit,forumjump_special,forumjump_advanced,forumdisplay_password_wrongpass,forumdisplay_password,moderation_inline_moveposts,moderation_delayedmodaction_error,moderation_purgespammer,moderation_delayedmoderation_date_day,moderation_delayedmoderation_date_month';
require_once "./global.php";
require_once MYBB_ROOT . "inc/functions_post.php";
require_once MYBB_ROOT . "inc/functions_upload.php";
require_once MYBB_ROOT . "inc/class_parser.php";
$parser = new postParser();
require_once MYBB_ROOT . "inc/class_moderation.php";
$moderation = new Moderation();
// Load global language phrases
$lang->load("moderation");
$plugins->run_hooks("moderation_start");
$tid = $mybb->get_input('tid', MyBB::INPUT_INT);
$pid = $mybb->get_input('pid', MyBB::INPUT_INT);
$fid = $mybb->get_input('fid', MyBB::INPUT_INT);
$pmid = $mybb->get_input('pmid', MyBB::INPUT_INT);
if ($pid) {
    $post = get_post($pid);
    if (!$post) {
        error($lang->error_invalidpost);
    }
    $tid = $post['tid'];
}
if ($tid) {
Exemplo n.º 12
0
/**
 * Change the status of a thread.
 *
 * @param array Information about the thread.
 * @param int The new status.
 * @param bool If this is changing the status of multiple threads.
**/
function mysupport_change_status($thread_info, $status = 0, $multiple = false)
{
    global $mybb, $db, $lang, $cache;
    $status = intval($status);
    if ($status == 3) {
        // if it's 3, we're solving and closing, but we'll just check for regular solving in the list of things to log
        // saves needing to have a 3, for the solving and closing option, in the setting of what to log
        // then below it'll check if 1 is in the list of things to log; 1 is normal solving, so if that's in the list, it'll log this too
        $log_status = 1;
    } else {
        $log_status = $status;
    }
    if ($multiple) {
        $tid = -1;
        $old_status = -1;
    } else {
        $tid = intval($thread_info['tid']);
        $old_status = intval($thread_info['status']);
    }
    $move_fid = "";
    $forums = $cache->read("forums");
    foreach ($forums as $forum) {
        if (!empty($forum['mysupportmove']) && $forum['mysupportmove'] != 0) {
            $move_fid = intval($forum['fid']);
            break;
        }
    }
    // are we marking it as solved and is it being moved??
    if (!empty($move_fid) && ($status == 1 || $status == 3)) {
        if ($mybb->settings['mysupportmoveredirect'] == "none") {
            $move_type = "move";
            $redirect_time = 0;
        } else {
            $move_type = "redirect";
            if ($mybb->settings['mysupportmoveredirect'] == "forever") {
                $redirect_time = 0;
            } else {
                $redirect_time = intval($mybb->settings['mysupportmoveredirect']);
            }
        }
        if ($multiple) {
            $move_tids = $thread_info;
        } else {
            $move_tids = array($thread_info['tid']);
        }
        require_once MYBB_ROOT . "inc/class_moderation.php";
        $moderation = new Moderation();
        // the reason it loops through using move_thread is because move_threads doesn't give the option for a redirect
        // if it's not a multiple thread it will just loop through once as there'd only be one value in the array
        foreach ($move_tids as $move_tid) {
            $moderation->move_thread($move_tid, $move_fid, $move_type, $redirect_time);
        }
    }
    if ($multiple) {
        $tids = implode(",", array_map("intval", $thread_info));
        $where_sql = "tid IN (" . $db->escape_string($tids) . ")";
    } else {
        $where_sql = "tid = '" . intval($tid) . "'";
    }
    // we need to build an array of users who have been assigned threads before the assignment is removed
    if ($status == 1 || $status == 3) {
        $query = $db->simple_select("threads", "DISTINCT assign", $where_sql . " AND assign != '0'");
        $assign_users = array();
        while ($user = $db->fetch_field($query, "assign")) {
            $assign_users[] = $user;
        }
    }
    if ($status == 3 || $status == 1 && $mybb->settings['mysupportclosewhensolved'] == "always") {
        // the bit after || here is for if we're marking as solved via marking a post as the best answer, it will close if it's set to always close
        // the incoming status would be 1 but we need to close it if necessary
        $status_update = array("closed" => 1, "status" => 1, "statusuid" => intval($mybb->user['uid']), "statustime" => TIME_NOW, "assign" => 0, "assignuid" => 0, "priority" => 0, "closedbymysupport" => 1, "onhold" => 0);
    } elseif ($status == 0) {
        // if we're marking it as unsolved, a post may have been marked as the best answer when it was originally solved, best remove it, as well as rest everything else
        $status_update = array("status" => 0, "statusuid" => 0, "statustime" => 0, "bestanswer" => 0);
    } elseif ($status == 4) {
        /** if it's 4, it's because it was marked as being not technical after being marked technical
         ** basically put back to the original status of not solved (0)
         ** however it needs to be 4 so we can differentiate between this action (technical => not technical), and a user marking it as not solved
         ** because both of these options eventually set it back to 0
         ** so the mod log entry will say the correct action as the status was 4 and it used that
         ** now that the log has been inserted we can set it to 0 again for the thread update query so it's marked as unsolved **/
        $status_update = array("status" => 0, "statusuid" => 0, "statustime" => 0);
    } elseif ($status == 2) {
        $status_update = array("status" => 2, "statusuid" => intval($mybb->user['uid']), "statustime" => TIME_NOW);
    } else {
        $status_update = array("status" => 1, "statusuid" => intval($mybb->user['uid']), "statustime" => TIME_NOW, "assign" => 0, "assignuid" => 0, "priority" => 0, "onhold" => 0);
    }
    $db->update_query("threads", $status_update, $where_sql);
    // if the thread is being marked as technical, being marked as something else after being marked technical, or we're changing the status of multiple threads, recount the number of technical threads
    if ($status == 2 || $old_status == 2 || $multiple) {
        mysupport_recount_technical_threads();
    }
    // if the thread is being marked as solved, recount the number of assigned threads for any users who were assigned threads that are now being marked as solved
    if ($status == 1 || $status == 3) {
        foreach ($assign_users as $user) {
            mysupport_recount_assigned_threads($user);
        }
    }
    if ($status == 0) {
        // if we're marking a thread(s) as unsolved, re-open any threads that were closed when they were marked as solved, but not any that were closed by denying support
        $update = array("closed" => 0, "closedbymysupport" => 0);
        $db->update_query("threads", $update, $where_sql . " AND closed = '1' AND closedbymysupport = '1'");
    }
    // get the friendly version of the status for the redirect message and mod log
    $friendly_old_status = "'" . mysupport_get_friendly_status($old_status) . "'";
    $friendly_new_status = "'" . mysupport_get_friendly_status($status) . "'";
    if ($multiple) {
        mysupport_mod_log_action($log_status, $lang->sprintf($lang->status_change_mod_log_multi, count($thread_info), $friendly_new_status));
        mysupport_redirect_message($lang->sprintf($lang->status_change_success_multi, count($thread_info), htmlspecialchars_uni($friendly_new_status)));
    } else {
        mysupport_mod_log_action($log_status, $lang->sprintf($lang->status_change_mod_log, $friendly_new_status));
        mysupport_redirect_message($lang->sprintf($lang->status_change_success, htmlspecialchars_uni($friendly_old_status), htmlspecialchars_uni($friendly_new_status)));
    }
}
 function hook_newpoints_do_shop_start()
 {
     global $mybb, $db, $lang, $cache, $theme, $header, $templates, $plugins, $headerinclude, $footer, $options, $inline_errors;
     if ($mybb->get_input('shop_action') == 'buy_sticky') {
         $do = false;
     } elseif ($mybb->get_input('shop_action') == 'do_buy_sticky') {
         $do = true;
     } else {
         return false;
     }
     if ($do) {
         $plugins->run_hooks('newpoints_shop_do_buy_sticky_start');
     } else {
         $plugins->run_hooks('newpoints_shop_buy_sticky_start');
     }
     if (!($item = newpoints_shop_get_item($mybb->get_input('iid', 1)))) {
         error($lang->newpoints_shop_invalid_item);
     }
     if (!($cat = newpoints_shop_get_category($item['cid']))) {
         error($lang->newpoints_shop_invalid_cat);
     }
     if (!newpoints_shop_check_permissions($cat['usergroups'])) {
         error_no_permission();
     }
     if (!$item['visible'] || !$cat['visible']) {
         error_no_permission();
     }
     if (!$item['buy_sticky'] || $item['buy_sticky_time'] < 1) {
         error_no_permission();
     }
     $myitems = @unserialize($mybb->user['newpoints_items']);
     if (!$myitems) {
         error($lang->newpoints_shop_inventory_empty);
     }
     $key = array_search($item['iid'], $myitems);
     if ($key === false) {
         error($lang->newpoints_shop_selected_item_not_owned);
     }
     $this->load_language();
     if ($do) {
         // ~~~ @ https://github.com/PaulBender/Move-Posts/blob/master/inc/plugins/moveposts.php#L217 //
         if ($db->table_exists('google_seo')) {
             $regexp = "{$mybb->settings['bburl']}/{$mybb->settings['google_seo_url_threads']}";
             if ($regexp) {
                 $regexp = preg_quote($regexp, '#');
                 $regexp = str_replace('\\{\\$url\\}', '([^./]+)', $regexp);
                 $regexp = str_replace('\\{url\\}', '([^./]+)', $regexp);
                 $regexp = "#^{$regexp}\$#u";
             }
             $url = $mybb->get_input('threadurl');
             $url = preg_replace('/^([^#?]*)[#?].*$/u', '\\1', $url);
             $url = preg_replace($regexp, '\\1', $url);
             $url = urldecode($url);
             $query = $db->simple_select('google_seo', 'id', "idtype='4' AND url='{$db->escape_string($url)}'");
             $redeemtid = $db->fetch_field($query, 'id');
         }
         $realurl = explode('#', $mybb->get_input('threadurl'));
         $mybb->input['threadurl'] = $realurl[0];
         if (substr($mybb->get_input('threadurl'), -4) == 'html') {
             preg_match('#thread-([0-9]+)?#i', $mybb->get_input('threadurl'), $threadmatch);
             preg_match('#post-([0-9]+)?#i', $mybb->get_input('threadurl'), $postmatch);
             if ($threadmatch[1]) {
                 $parameters['tid'] = $threadmatch[1];
             }
             if ($postmatch[1]) {
                 $parameters['pid'] = $postmatch[1];
             }
         } else {
             $splitloc = explode('.php', $mybb->get_input('threadurl'));
             $temp = explode('&', my_substr($splitloc[1], 1));
             if (!empty($temp)) {
                 for ($i = 0; $i < count($temp); $i++) {
                     $temp2 = explode('=', $temp[$i], 2);
                     $parameters[$temp2[0]] = $temp2[1];
                 }
             } else {
                 $temp2 = explode('=', $splitloc[1], 2);
                 $parameters[$temp2[0]] = $temp2[1];
             }
         }
         if ($parameters['pid'] && !$parameters['tid']) {
             $query = $db->simple_select('posts', '*', "pid='" . (int) $parameters['pid'] . "'");
             $post = $db->fetch_array($query);
             $redeemtid = $post['tid'];
         } elseif ($parameters['tid']) {
             $redeemtid = $parameters['tid'];
         }
         $thread = get_thread($redeemtid);
         // ~~~ //
         if (!$thread['tid'] || !$thread['visible'] || $thread['deletetime']) {
             error($lang->newpoints_buy_sticky_redeem_error_invalid);
         }
         if ($thread['sticky']) {
             error($lang->newpoints_buy_sticky_redeem_error_alreadystickied);
         }
         if ($thread['closed']) {
             error($lang->newpoints_buy_sticky_redeem_error_closedthread);
         }
         if ($thread['uid'] != $mybb->user['uid']) {
             error($lang->newpoints_buy_sticky_redeem_error_wronguser);
         }
         // We need more extensive permission checkings here late on..
         require_once MYBB_ROOT . 'inc/class_moderation.php';
         $moderation = new Moderation();
         $lang->load('moderation');
         $moderation->stick_threads($thread['tid']);
         log_moderator_action(array('fid' => $thread['fid'], 'tid' => $thread['tid']), $lang->sprintf($lang->mod_process, $lang->stuck));
         newpoints_log('buy_sticky', $mybb->settings['bburl'] . '/' . get_thread_link($thread['tid']), $mybb->user['username'], $mybb->user['uid']);
         $rundate = TIME_NOW + $item['buy_sticky_time'] * 86400;
         $did = $db->insert_query("delayedmoderation", array('type' => $db->escape_string('stick'), 'delaydateline' => (int) $rundate, 'uid' => (int) $mybb->user['uid'], 'tids' => (int) $thread['tid'], 'fid' => (int) $thread['fid'], 'dateline' => TIME_NOW, 'inputs' => $db->escape_string(my_serialize(array('new_forum' => (int) $thread['fid'], 'method' => 'move', 'redirect_expire' => '')))));
         $plugins->run_hooks('moderation_do_delayedmoderation');
         // remove item from our inventory
         unset($myitems[$key]);
         sort($myitems);
         $db->update_query('users', array('newpoints_items' => serialize($myitems)), "uid='" . (int) $mybb->user['uid'] . "'");
         $plugins->run_hooks('newpoints_shop_do_buy_sticky_end');
         $message = $lang->sprintf($lang->newpoints_buy_sticky_redeem_done, my_date('relative', $rundate, '', 2));
         redirect($mybb->settings['bburl'] . '/newpoints.php?action=shop&amp;shop_action=myitems', $message, $lang->newpoints_buy_sticky_redeem_done_title);
     } else {
         $lang->newpoints_shop_action = $lang->newpoints_buy_sticky_redeem_title;
         $item['name'] = htmlspecialchars_uni($item['name']);
         global $shop_action, $data, $colspan;
         $colspan = 2;
         $shop_action = 'do_buy_sticky';
         $fields = '<input type="hidden" name="iid" value="' . $item['iid'] . '">';
         $data = "<td class=\"trow1\" width=\"50%\"><strong>" . $lang->newpoints_buy_sticky_redeem_thread . ":</strong><br /><small>" . $lang->newpoints_buy_sticky_redeem_message . "</small></td><td class=\"trow1\" width=\"50%\"><input type=\"text\" class=\"textbox\" name=\"threadurl\" value=\"\"></td>";
         $plugins->run_hooks('newpoints_shop_buy_sticky_end');
         $page = eval($templates->render('newpoints_shop_do_action'));
         output_page($page);
     }
     exit;
 }
Exemplo n.º 14
0
 /**
  * Provides a method to delete an users posts and threads
  *
  * @param array|bool $delete_uids Array of user ids, false if they're already set (eg when using the delete_user function)
  */
 function delete_posts($delete_uids = false)
 {
     global $db, $plugins, $mybb;
     if ($delete_uids != false) {
         $this->delete_uids = array_map('intval', (array) $delete_uids);
         foreach ($this->delete_uids as $key => $uid) {
             if (!$uid || is_super_admin($uid) || $uid == $mybb->user['uid']) {
                 // Remove super admins
                 unset($this->delete_uids[$key]);
             }
         }
         $this->delete_uids = implode(',', $this->delete_uids);
     }
     require_once MYBB_ROOT . 'inc/class_moderation.php';
     $moderation = new Moderation();
     $plugins->run_hooks('datahandler_user_delete_posts', $this);
     if (empty($this->delete_uids)) {
         return;
     }
     // Threads
     $query = $db->simple_select('threads', 'tid', "uid IN({$this->delete_uids})");
     while ($tid = $db->fetch_field($query, 'tid')) {
         $moderation->delete_thread($tid);
     }
     // Posts
     $query = $db->simple_select('posts', 'pid', "uid IN({$this->delete_uids})");
     while ($pid = $db->fetch_field($query, 'pid')) {
         $moderation->delete_post($pid);
     }
 }
Exemplo n.º 15
0
function spamalyser_unapprove_edit(&$ph)
{
    require_once MYBB_ROOT . 'inc/class_moderation.php';
    $moderation = new Moderation();
    $moderation->unapprove_posts(array($ph->data['pid']));
    $ph->post_update_data['visible'] = 0;
    $GLOBALS['plugins']->remove_hook('datahandler_post_update', 'spamalyser_unapprove_edit');
    // update lang messages
    global $lang;
    $lang->load('spamalyser');
    $lang->redirect_thread_moderation = $lang->spamalyser_redirect_newthread_spam_blocked;
    $lang->redirect_post_moderation = $lang->spamalyser_redirect_newreply_spam_blocked;
}