/**
 This is where you perform the action when the API is called, the parameter given is an instance of stdClass, this method should return an instance of stdClass.
 */
 public function action()
 {
     global $mybb;
     require_once MYBB_ROOT . 'inc/functions_post.php';
     require_once MYBB_ROOT . '/inc/datahandlers/post.php';
     if (isset($mybb->input["subject"]) && is_string($mybb->input["subject"]) && isset($mybb->input["forumid"]) && is_numeric($mybb->input["forumid"]) && isset($mybb->input["message"]) && is_string($mybb->input["message"]) && isset($mybb->input["ipaddress"]) && is_string($mybb->input["ipaddress"])) {
         $subject = $mybb->input["subject"];
         $forumid = (int) $mybb->input["forumid"];
         $message = $mybb->input["message"];
         $ipaddress = $mybb->input["ipaddress"];
         $prefix = isset($mybb->input["prefix"]) && is_string($mybb->input["prefix"]) ? $mybb->input["prefix"] : null;
         $icon = isset($mybb->input["icon"]) && is_string($mybb->input["icon"]) ? $mybb->input["icon"] : null;
         $savedraft = isset($mybb->input["savedraft"]) && in_array($mybb->input["savedraft"], array("1", "0")) ? (int) $mybb->input["savedraft"] : 0;
         $subscriptionmethod = isset($mybb->input["subscriptionmethod"]) && in_array($mybb->input["subscriptionmethod"], array("", "none", "instant")) ? $mybb->input["subscriptionmethod"] : "";
         $signature = isset($mybb->input["signature"]) && in_array($mybb->input["signature"], array("1", "0")) ? (int) $mybb->input["signature"] : 0;
         $disablesmilies = isset($mybb->input["disablesmilies"]) && in_array($mybb->input["disablesmilies"], array("1", "0")) ? (int) $mybb->input["disablesmilies"] : 0;
         $modclosethread = isset($mybb->input["modclosethread"]) && in_array($mybb->input["modclosethread"], array("1", "0")) ? (int) $mybb->input["modclosethread"] : 0;
         $modstickthread = isset($mybb->input["modstickthread"]) && in_array($mybb->input["modstickthread"], array("1", "0")) ? (int) $mybb->input["modstickthread"] : 0;
         // let's start
         $posthandler = new PostDataHandler('insert');
         $posthandler->action = 'thread';
         $data = array("uid" => $this->get_user()->uid, "username" => $this->get_user()->username, "subject" => $subject, "fid" => $forumid, "prefix" => $prefix, "message" => $message, "ipaddress" => $ipaddress, "icon" => $icon, "savedraft" => $savedraft, "options" => array("subscriptionmethod" => $subscriptionmethod, "signature" => $signature, "disablesmilies" => $disablesmilies));
         if (isset($this->get_user()->is_moderator) && $this->get_user()->is_moderator) {
             $data[] = array("closethread" => $modclosethread, "stickthread" => $modstickthread);
         }
         $posthandler->set_data($data);
         if (!$posthandler->validate_thread()) {
             throw new BadRequestException((object) $posthandler->get_friendly_errors());
         }
         return (object) $posthandler->insert_thread();
     }
 }
/**
 * Create the thread
 *
 */
function createthread()
{
    global $mybb, $event, $db;
    if ($event['private'] != 1) {
        require_once MYBB_ROOT . "inc/datahandlers/post.php";
        $posthandler = new PostDataHandler("insert");
        $posthandler->action = "thread";
        $posthandler->admin_override = true;
        $uid = $mybb->user['uid'];
        $username = $mybb->user['username'];
        $message = $mybb->input['description'];
        $subject = "[" . $event['start_date']['day'] . '.' . $event['start_date']['month'] . '.' . $event['start_date']['year'] . '] - ' . $db->escape_string($event['name']);
        $new_thread = array("fid" => $mybb->settings['eventcal_id'], "subject" => $subject, "uid" => $uid, "username" => $username, "message" => $message, "ipaddress" => get_ip());
        $posthandler->set_data($new_thread);
        $validate = $posthandler->validate_thread();
        if ($validate) {
            $tinfo = $posthandler->insert_thread();
        }
        header("Location: showthread.php?tid=" . $tinfo['tid']);
    }
}
Beispiel #3
0
 if ($mybb->input['savedraft'] && $mybb->user['uid']) {
     $new_thread['savedraft'] = 1;
 } else {
     $new_thread['savedraft'] = 0;
 }
 // Is this thread already a draft and we're updating it?
 if (isset($thread['tid']) && $thread['visible'] == -2) {
     $new_thread['tid'] = $thread['tid'];
 }
 // Set up the thread options from the input.
 $new_thread['options'] = array("signature" => $mybb->input['postoptions']['signature'], "subscriptionmethod" => $mybb->input['postoptions']['subscriptionmethod'], "disablesmilies" => $mybb->input['postoptions']['disablesmilies']);
 // Apply moderation options if we have them
 $new_thread['modoptions'] = $mybb->input['modoptions'];
 $posthandler->set_data($new_thread);
 // Now let the post handler do all the hard work.
 $valid_thread = $posthandler->validate_thread();
 $post_errors = array();
 // Fetch friendly error messages if this is an invalid thread
 if (!$valid_thread) {
     $post_errors = $posthandler->get_friendly_errors();
 }
 // Check captcha image
 if ($mybb->settings['captchaimage'] && !$mybb->user['uid']) {
     require_once MYBB_ROOT . 'inc/class_captcha.php';
     $post_captcha = new captcha();
     if ($post_captcha->validate_captcha() == false) {
         // CAPTCHA validation failed
         foreach ($post_captcha->get_errors() as $error) {
             $post_errors[] = $error;
         }
     } else {
Beispiel #4
0
 /**
  * Inserts a thread into 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 createThread($data, $inline_errors = true)
 {
     require_once MYBB_ROOT . 'inc/functions_post.php';
     require_once MYBB_ROOT . '/inc/datahandlers/post.php';
     $posthandler = new PostDataHandler('insert');
     $posthandler->action = 'thread';
     $posthandler->set_data($data);
     if (!$posthandler->validate_thread()) {
         $errors = $posthandler->get_friendly_errors();
         return $inline_errors === true ? inline_error($errors) : $errors;
     }
     return $posthandler->insert_thread();
 }
Beispiel #5
0
function new_topic_func($xmlrpc_params)
{
    global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups, $thread_info, $pid, $tid, $visible, $fid, $new_thread;
    $lang->load("newthread");
    $input = Tapatalk_Input::filterXmlInput(array('forum_id' => Tapatalk_Input::INT, 'subject' => Tapatalk_Input::STRING, 'message' => Tapatalk_Input::STRING, 'prefix_id' => Tapatalk_Input::STRING, 'attachment_id_array' => Tapatalk_Input::RAW, 'group_id' => Tapatalk_Input::STRING), $xmlrpc_params);
    $fid = $input['forum_id'];
    // Fetch forum information.
    $forum = get_forum($fid);
    if (!$forum) {
        return xmlrespfalse($lang->error_invalidforum);
    }
    $forumpermissions = forum_permissions($fid);
    if ($forum['open'] == 0 || $forum['type'] != "f") {
        return xmlrespfalse($lang->error_closedinvalidforum);
    }
    if ($mybb->user['uid'] < 1 || $forumpermissions['canview'] == 0 || $forumpermissions['canpostthreads'] == 0 || $mybb->user['suspendposting'] == 1) {
        return tt_no_permission();
    }
    // Check if this forum is password protected and we have a valid password
    tt_check_forum_password($forum['fid']);
    // Check the maximum posts per day for this user
    if ($mybb->settings['maxposts'] > 0 && $mybb->usergroup['cancp'] != 1) {
        $daycut = TIME_NOW - 60 * 60 * 24;
        $query = $db->simple_select("posts", "COUNT(*) AS posts_today", "uid='{$mybb->user['uid']}' AND visible='1' AND dateline>{$daycut}");
        $post_count = $db->fetch_field($query, "posts_today");
        if ($post_count >= $mybb->settings['maxposts']) {
            $lang->error_maxposts = $lang->sprintf($lang->error_maxposts, $mybb->settings['maxposts']);
            return xmlrespfalse($lang->error_maxposts);
        }
    }
    $username = $mybb->user['username'];
    $uid = $mybb->user['uid'];
    // Attempt to see if this post is a duplicate or not
    if ($uid > 0) {
        $user_check = "p.uid='{$uid}'";
    } else {
        $user_check = "p.ipaddress='" . $db->escape_string($session->ipaddress) . "'";
    }
    if (!$mybb->input['savedraft'] && !$pid) {
        $query = $db->simple_select("posts p", "p.pid", "{$user_check} AND p.fid='{$forum['fid']}' AND p.subject='{$input['subject_esc']}' AND p.message='{$input['message_esc']}'");
        $duplicate_check = $db->fetch_field($query, "pid");
        if ($duplicate_check) {
            return xmlrespfalse($lang->error_post_already_submitted);
        }
    }
    // Set up posthandler.
    require_once MYBB_ROOT . "inc/datahandlers/post.php";
    $posthandler = new PostDataHandler("insert");
    $posthandler->action = "thread";
    // Set the thread data that came from the input to the $thread array.
    $new_thread = array("fid" => $forum['fid'], "subject" => $input['subject'], "prefix" => $input['prefix_id'], "icon" => 0, "uid" => $uid, "username" => $username, "message" => $input['message'], "ipaddress" => get_ip(), "posthash" => $input['group_id_esc']);
    $new_thread['savedraft'] = 0;
    // Set up the thread options from the input.
    $new_thread['options'] = array("signature" => 1, "subscriptionmethod" => $mybb->user['subscriptionmethod'] == 0 ? '' : $mybb->user['subscriptionmethod'], "disablesmilies" => 0);
    $posthandler->set_data($new_thread);
    // Now let the post handler do all the hard work.
    $valid_thread = $posthandler->validate_thread();
    $post_errors = array();
    // Fetch friendly error messages if this is an invalid thread
    if (!$valid_thread) {
        $post_errors = $posthandler->get_friendly_errors();
        return xmlrespfalse(implode(" :: ", $post_errors));
    }
    $thread_info = $posthandler->insert_thread();
    $tid = $thread_info['tid'];
    $pid = $thread_info['pid'];
    $visible = $thread_info['visible'];
    if ($pid != '') {
        if (!empty($input['group_id_esc'])) {
            $db->update_query("attachments", array("pid" => intval($pid)), "posthash='{$input['group_id_esc']}'");
        }
    }
    tapatalk_push_newtopic();
    tapatalk_push_quote();
    tapatalk_push_tag();
    // Mark thread as read
    require_once MYBB_ROOT . "inc/functions_indicators.php";
    mark_thread_read($tid, $fid);
    $result = new xmlrpcval(array('result' => new xmlrpcval(true, 'boolean'), 'result_text' => new xmlrpcval('', 'base64'), 'topic_id' => new xmlrpcval($tid, 'string'), 'state' => new xmlrpcval($visible ? 0 : 1, 'int')), 'struct');
    return new xmlrpcresp($result);
}
Beispiel #6
0
function reportthread_dopost()
{
    require_once MYBB_ROOT . "inc/datahandlers/post.php";
    global $db, $mybb;
    if (intval($mybb->settings['rtt_enabled']) == 1 || preg_replace("/[^a-z]/i", "", $mybb->settings['rtt_enabled']) == "yes") {
        if ($mybb->input['type'] == 'post') {
            $title = "Reported Post By ";
            $post = get_post($mybb->input['pid']);
            $thread = get_thread($post['tid']);
            $forum = get_forum($thread['fid']);
            $tlink = get_thread_link($thread['tid']);
            $flink = get_forum_link($thread['fid']);
            $reason = $mybb->input['reason'];
            if ($reason === 'other') {
                $reason = $mybb->input['comment'];
            }
            $post_data = $mybb->user['username'] . " has reported a post.\r\n\r\nOriginal Thread: [url=" . $mybb->settings['bburl'] . "/{$tlink}]" . $thread['subject'] . "[/url]\r\nForum: [url=" . $mybb->settings['bburl'] . "/{$flink}]" . $forum['name'] . "[/url]\r\n\r\nReason Given:\r\n[quote=\"" . $mybb->user['username'] . "\" dateline=\"" . time() . "\"]" . $reason . "[/quote]\r\n\r\nPost Content:\r\n[quote=\"" . $post['username'] . "\" pid=\"" . $post['pid'] . "\" dateline=\"" . $post['dateline'] . "\"]" . $post['message'] . "[/quote]";
        } else {
            if ($mybb->input['type'] == 'reputation') {
                $title = "Reported Reputation By ";
                $rep = get_reputation_point($mybb->input['pid']);
                $giver = get_user($rep['adduid']);
                $reason = $mybb->input['reason'];
                if ($reason === 'other') {
                    $reason = $mybb->input['comment'];
                }
                $post_data = $mybb->user['username'] . " has reported a reputation point.\r\n\r\nReason Given:\r\n[quote=\"" . $mybb->user['username'] . "\" dateline=\"" . time() . "\"]" . $reason . "[/quote]\r\n\r\nReputation comment:\r\n[quote=\"" . $giver['username'] . "\" dateline=\"" . $rep['dateline'] . "\"]" . $rep['comments'] . "[/quote]";
            }
        }
        $new_thread = array("fid" => $mybb->settings['rtt_fid'], "prefix" => 0, "subject" => $title . $mybb->user['username'], "icon" => 0, "uid" => $mybb->user['uid'], "username" => $mybb->user['username'], "message" => $post_data, "ipaddress" => get_ip(), "posthash" => md5($mybb->user['uid'] . random_str()));
        $posthandler = new PostDataHandler("insert");
        $posthandler->action = "thread";
        $posthandler->set_data($new_thread);
        if ($posthandler->validate_thread()) {
            $thread_info = $posthandler->insert_thread();
        }
    }
}