Beispiel #1
0
         }
     }
 }
 // Set up posthandler.
 require_once MYBB_ROOT . "inc/datahandlers/post.php";
 $posthandler = new PostDataHandler("update");
 $posthandler->action = "post";
 // Set the post data that came from the input to the $post array.
 $updatepost = array("pid" => $post['pid'], "message" => $message, "editreason" => $editreason, "edit_uid" => $mybb->user['uid']);
 $posthandler->set_data($updatepost);
 // Now let the post handler do all the hard work.
 if (!$posthandler->validate_post()) {
     $post_errors = $posthandler->get_friendly_errors();
     xmlhttp_error($post_errors);
 } else {
     $postinfo = $posthandler->update_post();
     $visible = $postinfo['visible'];
     if ($visible == 0 && !is_moderator($post['fid'], "canviewunapprove")) {
         // Is it the first post?
         if ($thread['firstpost'] == $post['pid']) {
             echo json_encode(array("moderation_thread" => $lang->thread_moderation, 'url' => $mybb->settings['bburl'] . '/' . get_forum_link($thread['fid']), "message" => $post['message']));
             exit;
         } else {
             echo json_encode(array("moderation_post" => $lang->post_moderation, 'url' => $mybb->settings['bburl'] . '/' . get_thread_link($thread['tid']), "message" => $post['message']));
             exit;
         }
     }
 }
 require_once MYBB_ROOT . "inc/class_parser.php";
 $parser = new postParser();
 $parser_options = array("allow_html" => $forum['allowhtml'], "allow_mycode" => $forum['allowmycode'], "allow_smilies" => $forum['allowsmilies'], "allow_imgcode" => $forum['allowimgcode'], "allow_videocode" => $forum['allowvideocode'], "me_username" => $post['username'], "filter_badwords" => 1);
function save_raw_post_func($xmlrpc_params)
{
    global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups;
    $lang->load("editpost");
    $input = Tapatalk_Input::filterXmlInput(array('post_id' => Tapatalk_Input::INT, 'post_title' => Tapatalk_Input::STRING, 'post_content' => Tapatalk_Input::STRING, 'return_html' => Tapatalk_Input::INT, 'attachment_id_array' => Tapatalk_Input::RAW, 'group_id' => Tapatalk_Input::STRING, 'editreason' => Tapatalk_Input::STRING), $xmlrpc_params);
    $parser = new postParser();
    // No permission for guests
    if (!$mybb->user['uid']) {
        return tt_no_permission();
    }
    // Get post info
    $pid = $input['post_id'];
    $query = $db->simple_select("posts", "*", "pid='{$pid}'");
    $post = $db->fetch_array($query);
    if (empty($input['post_title'])) {
        $input['post_title'] = $post['subject'];
    }
    if (!$post['pid']) {
        return xmlrespfalse($lang->error_invalidpost);
    }
    // Get thread info
    $tid = $post['tid'];
    $thread = get_thread($tid);
    if (!$thread['tid']) {
        return xmlrespfalse($lang->error_invalidthread);
    }
    $thread['subject'] = htmlspecialchars_uni($thread['subject']);
    // Get forum info
    $fid = $post['fid'];
    $forum = get_forum($fid);
    if (!$forum || $forum['type'] != "f") {
        return xmlrespfalse($lang->error_closedinvalidforum);
    }
    if ($forum['open'] == 0 || $mybb->user['suspendposting'] == 1) {
        return tt_no_permission();
    }
    $forumpermissions = forum_permissions($fid);
    if (!is_moderator($fid, "caneditposts")) {
        if ($thread['closed'] == 1) {
            return xmlrespfalse($lang->redirect_threadclosed);
        }
        if ($forumpermissions['caneditposts'] == 0) {
            return tt_no_permission();
        }
        if ($mybb->user['uid'] != $post['uid']) {
            return tt_no_permission();
        }
        // Edit time limit
        $time = TIME_NOW;
        if ($mybb->settings['edittimelimit'] != 0 && $post['dateline'] < $time - $mybb->settings['edittimelimit'] * 60) {
            $lang->edit_time_limit = $lang->sprintf($lang->edit_time_limit, $mybb->settings['edittimelimit']);
            return xmlrespfalse($lang->edit_time_limit);
        }
    }
    // Check if this forum is password protected and we have a valid password
    tt_check_forum_password($forum['fid']);
    // Set up posthandler.
    require_once MYBB_ROOT . "inc/datahandlers/post.php";
    $posthandler = new PostDataHandler("update");
    $posthandler->action = "post";
    // Set the post data that came from the input to the $post array.
    $post = array("pid" => $pid, "subject" => $input['post_title'], "uid" => $mybb->user['uid'], "username" => $mybb->user['username'], "edit_uid" => $mybb->user['uid'], "message" => $input['post_content']);
    if (version_compare($mybb->version, '1.8.0', '>=') && !empty($input['editreason'])) {
        $post["editreason"] = $input['editreason'];
    }
    // get subscription status
    $query = $db->simple_select("threadsubscriptions", 'notification', "uid='" . intval($mybb->user['uid']) . "' AND tid='" . intval($tid) . "'");
    $substatus = $db->fetch_array($query);
    // Set up the post options from the input.
    $post['options'] = array("signature" => 1, "subscriptionmethod" => isset($substatus['notification']) ? $substatus['notification'] == 1 ? 'instant' : 'none' : '', "disablesmilies" => 0);
    $posthandler->set_data($post);
    // Now let the post handler do all the hard work.
    if (!$posthandler->validate_post()) {
        $post_errors = $posthandler->get_friendly_errors();
        return xmlrespfalse(implode(" :: ", $post_errors));
    } else {
        $postinfo = $posthandler->update_post();
        $visible = $postinfo['visible'];
        $first_post = $postinfo['first_post'];
        // Help keep our attachments table clean.
        $db->delete_query("attachments", "filename='' OR filesize<1");
        if ($visible == 0 && $first_post && !is_moderator($fid, "", $mybb->user['uid'])) {
            $state = 1;
        } else {
            if ($visible == 0 && !is_moderator($fid, "", $mybb->user['uid'])) {
                $state = 1;
            } else {
                $state = 0;
            }
        }
    }
    $pid = intval($pid);
    if (!empty($input['group_id_esc'])) {
        $db->update_query("attachments", array("pid" => $pid), "posthash='{$input['group_id_esc']}'");
    }
    // update thread attachment account
    if (count($input['attachment_id_array']) > 0) {
        update_thread_counters($tid, array("attachmentcount" => "+" . count($input['attachment_id_array'])));
    }
    $post = get_post($pid);
    $parser_options = array();
    $parser_options['allow_html'] = false;
    $parser_options['allow_mycode'] = true;
    $parser_options['allow_smilies'] = false;
    $parser_options['allow_imgcode'] = true;
    $parser_options['allow_videocode'] = true;
    $parser_options['nl2br'] = (bool) $input['return_html'];
    $parser_options['filter_badwords'] = 1;
    if (!$post['username']) {
        $post['username'] = $lang->guest;
    }
    if ($post['userusername']) {
        $parser_options['me_username'] = $post['userusername'];
    } else {
        $parser_options['me_username'] = $post['username'];
    }
    $post['message'] = $parser->parse_message($post['message'], $parser_options);
    $post['subject'] = $parser->parse_badwords($post['subject']);
    $result = new xmlrpcval(array('result' => new xmlrpcval(true, 'boolean'), 'result_text' => new xmlrpcval('', 'base64'), 'state' => new xmlrpcval($state, 'int'), 'post_title' => new xmlrpcval($post['subject'], 'base64'), 'post_content' => new xmlrpcval(process_post($post['message'], $input['return_html']), 'base64')), 'struct');
    return new xmlrpcresp($result);
}
Beispiel #3
0
 /**
  * Updates a thread in the database
  *
  * @param array $data Thread data
  * @param boolean $inline_errors Defines if we want a formatted error string or an array
  * @return array|string 
  * @return array|string When true it will return an array with threadID, postID and status of being visible - false = error array or inline string 
  */
 function updateThread($data, $inline_errors = true)
 {
     if (!isset($data['tid'])) {
         $this->_errorAndDie('Function <i>updateThread</i>: Must pass thread id in array parameter - Required array key is <i>tid</i>');
     }
     // Posthandler is used for a post, so let's fetch the thread-post
     $thread = $this->getThread($data['tid']);
     $data['pid'] = $thread['firstpost'];
     require_once MYBB_ROOT . 'inc/functions_post.php';
     require_once MYBB_ROOT . '/inc/datahandlers/post.php';
     $posthandler = new PostDataHandler('update');
     $posthandler->action = 'post';
     $posthandler->set_data($data);
     if (!$posthandler->validate_post()) {
         $errors = $posthandler->get_friendly_errors();
         return $inline_errors === true ? inline_error($errors) : $errors;
     }
     return $posthandler->update_post();
 }
Beispiel #4
0
function m_rename_topic_func($xmlrpc_params)
{
    global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups, $modlogdata;
    $lang->load("editpost");
    $input = Tapatalk_Input::filterXmlInput(array('topic_id' => Tapatalk_Input::INT, 'title' => Tapatalk_Input::STRING, 'prefix' => Tapatalk_Input::INT), $xmlrpc_params);
    $parser = new postParser();
    // Get post info
    $thread = get_thread($input['topic_id']);
    if (!$thread['tid']) {
        return xmlrespfalse($lang->error_invalidthread);
    }
    $forumpermissions = forum_permissions($thread['fid']);
    // No permission for guests
    if ($mybb->user['uid'] == 0) {
        return tt_no_permission();
    }
    // Get forum info
    $fid = $thread['fid'];
    $forum = get_forum($fid);
    if (!$forum || $forum['type'] != "f") {
        return xmlrespfalse($lang->error_closedinvalidforum);
    }
    if ($forum['open'] == 0 || $mybb->user['suspendposting'] == 1) {
        return tt_no_permission();
    }
    if (!is_moderator($fid, "caneditposts")) {
        if ($thread['closed'] == 1) {
            return xmlrespfalse($lang->redirect_threadclosed);
        }
        if ($forumpermissions['caneditposts'] == 0) {
            return tt_no_permission();
        }
        if ($mybb->user['uid'] != $thread['uid']) {
            return tt_no_permission();
        }
        // Edit time limit
        $time = TIME_NOW;
        if ($mybb->settings['edittimelimit'] != 0 && $thread['dateline'] < $time - $mybb->settings['edittimelimit'] * 60) {
            $lang->edit_time_limit = $lang->sprintf($lang->edit_time_limit, $mybb->settings['edittimelimit']);
            return xmlrespfalse($lang->edit_time_limit);
        }
    }
    // Check if this forum is password protected and we have a valid password
    tt_check_forum_password($forum['fid']);
    // Set up posthandler.
    require_once MYBB_ROOT . "inc/datahandlers/post.php";
    $posthandler = new PostDataHandler("update");
    $posthandler->action = "post";
    // Set the post data that came from the input to the $post array.
    $post = array("pid" => $thread['firstpost'], "subject" => $input['title'], "prefix" => $input['prefix']);
    $posthandler->set_data($post);
    // Now let the post handler do all the hard work.
    if (!$posthandler->validate_post()) {
        $post_errors = $posthandler->get_friendly_errors();
        return xmlrespfalse(implode(" :: ", $post_errors));
    } else {
        $postinfo = $posthandler->update_post();
        $response = new xmlrpcval(array('result' => new xmlrpcval(true, 'boolean'), 'is_login_mod' => new xmlrpcval(true, 'boolean'), 'result_text' => new xmlrpcval("", 'base64')), 'struct');
        return new xmlrpcresp($response);
    }
}
Beispiel #5
0
     $ip = $_POST['ip'];
     $user = $MyBBI->getUser($uid);
     $username = $user['username'];
     // get id of the first post in the thread
     $query = $MyBBI->db->simple_select("posts", "pid", "tid={$tid} AND replyto=0");
     $pid = $MyBBI->db->fetch_field($query, "pid");
     require_once MYBB_ROOT . "inc/datahandlers/post.php";
     $posthandler = new PostDataHandler("update");
     $posthandler->action = "post";
     $post = array("pid" => $pid, "subject" => $subject, "icon" => -1, "uid" => $uid, "username" => $username, "edit_uid" => '', "message" => $message);
     $post['options'] = array("signature" => $sig ? "yes" : "no", "emailnotify" => "no", "disablesmilies" => "no");
     $posthandler->set_data($post);
     if (!$posthandler->validate_post()) {
         exit(serialize($posthandler->get_friendly_errors()));
     }
     $posthandler->update_post();
     break;
 case 'delete_thread':
     $nonce = $_POST['_wordbbnonce'];
     if (!wordbb_verify_nonce($nonce, 'delete_thread')) {
         die;
     }
     $mybb_root = $_POST['wordbb_mybb_abs'];
     if (!isset($mybb_root)) {
         die;
     }
     require_once 'inc/include_mybb.php';
     $tid = $_POST['tid'];
     $deleted = $MyBBI->removeThread($tid);
     exit("{$deleted}");
     break;