コード例 #1
0
function remove_attachment_func($xmlrpc_params)
{
    global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups;
    chdir("../");
    $lang->load("member");
    $parser = new postParser();
    $input = Tapatalk_Input::filterXmlInput(array('attachment_id' => Tapatalk_Input::INT, 'forum_id' => Tapatalk_Input::INT, 'group_id' => Tapatalk_Input::STRING, 'post_id' => Tapatalk_Input::INT), $xmlrpc_params);
    $fid = $input['forum_id'];
    $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();
    }
    tt_check_forum_password($forum['fid']);
    $posthash = $input['group_id'];
    $mybb->input['posthash'] = $posthash;
    // If we're removing an attachment that belongs to an existing post, some security checks...
    $query = $db->simple_select("attachments", "pid", "aid='{$input['attachment_id']}'");
    $attachment = $db->fetch_array($query);
    $pid = $attachment['pid'];
    if ($pid > 0) {
        if ($pid != $input['post_id']) {
            return xmlrespfalse("The attachment you are trying to remove does not belong to this post");
        }
        $query = $db->simple_select("posts", "*", "pid='{$pid}'");
        $post = $db->fetch_array($query);
        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);
        }
        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();
            }
        }
    } else {
        $pid = 0;
    }
    require_once MYBB_ROOT . "inc/functions_upload.php";
    remove_attachment($pid, $mybb->input['posthash'], $input['attachment_id']);
    return xmlresptrue();
}
コード例 #2
0
function upload_attach_func($xmlrpc_params)
{
    global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups;
    $lang->load("member");
    $parser = new postParser();
    $input = Tapatalk_Input::filterXmlInput(array('forum_id' => Tapatalk_Input::INT, 'group_id' => Tapatalk_Input::STRING, 'content' => Tapatalk_Input::STRING), $xmlrpc_params);
    $fid = $input['forum_id'];
    //return xmlrespfalse(print_r($_FILES, true));
    // 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']);
    $posthash = $input['group_id'];
    if (empty($posthash)) {
        $posthash = md5($mybb->user['uid'] . random_str());
    }
    $mybb->input['posthash'] = $posthash;
    if (!empty($mybb->input['pid'])) {
        $attachwhere = "pid='{$mybb->input['pid']}'";
    } else {
        $attachwhere = "posthash='{$posthash}'";
    }
    $query = $db->simple_select("attachments", "COUNT(aid) as numattachs", $attachwhere);
    $attachcount = $db->fetch_field($query, "numattachs");
    //if(is_array($_FILES['attachment']['name'])){
    foreach ($_FILES['attachment'] as $k => $v) {
        if (is_array($_FILES['attachment'][$k])) {
            $_FILES['attachment'][$k] = $_FILES['attachment'][$k][0];
        }
    }
    //}
    if ($_FILES['attachment']['type'] == 'image/jpg') {
        $_FILES['attachment']['type'] = 'image/jpeg';
    }
    // If there's an attachment, check it and upload it
    if ($_FILES['attachment']['size'] > 0 && $forumpermissions['canpostattachments'] != 0 && ($mybb->settings['maxattachments'] == 0 || $attachcount < $mybb->settings['maxattachments'])) {
        require_once MYBB_ROOT . "inc/functions_upload.php";
        $attachedfile = upload_attachment($_FILES['attachment'], false);
    }
    if (empty($attachedfile)) {
        return xmlrespfalse("No file uploaded");
    }
    //return xmlrespfalse(print_r($attachedfile, true));
    if ($attachedfile['error']) {
        return xmlrespfalse(implode(" :: ", $attachedfile['error']));
    }
    $result = new xmlrpcval(array('attachment_id' => new xmlrpcval($attachedfile['aid'], 'string'), 'group_id' => new xmlrpcval($posthash, 'string'), 'result' => new xmlrpcval(true, 'boolean'), 'result_text' => new xmlrpcval('', 'base64'), 'file_size' => new xmlrpcval($attachedfile['filesize'], 'int')), 'struct');
    return new xmlrpcresp($result);
}
コード例 #3
0
ファイル: login_forum.php プロジェクト: dthiago/tapatalk-mybb
function login_forum_func($xmlrpc_params)
{
    global $lang;
    $lang->load("forumdisplay");
    $input = Tapatalk_Input::filterXmlInput(array('forum_id' => Tapatalk_Input::INT, 'password' => Tapatalk_Input::STRING), $xmlrpc_params);
    tt_check_forum_password($input['forum_id'], 0, $input['password']);
    return xmlresptrue();
}
コード例 #4
0
function tt_check_forum_password($fid, $pid = 0, $pass = '')
{
    global $mybb, $header, $footer, $headerinclude, $theme, $templates, $lang, $forum_cache;
    $mybb->input['pwverify'] = $pass;
    $showform = true;
    if (!is_array($forum_cache)) {
        $forum_cache = cache_forums();
        if (!$forum_cache) {
            return false;
        }
    }
    // Loop through each of parent forums to ensure we have a password for them too
    $parents = explode(',', $forum_cache[$fid]['parentlist']);
    rsort($parents);
    if (!empty($parents)) {
        foreach ($parents as $parent_id) {
            if ($parent_id == $fid || $parent_id == $pid) {
                continue;
            }
            if ($forum_cache[$parent_id]['password'] != "") {
                tt_check_forum_password($parent_id, $fid);
            }
        }
    }
    $password = $forum_cache[$fid]['password'];
    if ($password) {
        if ($mybb->input['pwverify'] && $pid == 0) {
            if ($password == $mybb->input['pwverify']) {
                my_setcookie("forumpass[{$fid}]", md5($mybb->user['uid'] . $mybb->input['pwverify']), null, true);
                $showform = false;
            } else {
                eval("\$pwnote = \"" . $templates->get("forumdisplay_password_wrongpass") . "\";");
                $showform = true;
            }
        } else {
            if (!$mybb->cookies['forumpass'][$fid] || $mybb->cookies['forumpass'][$fid] && md5($mybb->user['uid'] . $password) != $mybb->cookies['forumpass'][$fid]) {
                $showform = true;
            } else {
                $showform = false;
            }
        }
    } else {
        $showform = false;
    }
    if ($showform) {
        if (empty($pwnote)) {
            global $lang;
            $pwnote = $lang->forum_password_note;
        }
        error($pwnote);
    }
}
コード例 #5
0
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);
}
コード例 #6
0
ファイル: get_thread.php プロジェクト: dthiago/tapatalk-mybb
function get_thread_func($xmlrpc_params)
{
    global $db, $lang, $mybb, $position, $plugins, $pids;
    global $pforumcache, $currentitem, $forum_cache, $navbits, $base_url, $archiveurl;
    $input = Tapatalk_Input::filterXmlInput(array('topic_id' => Tapatalk_Input::STRING, 'start_num' => Tapatalk_Input::INT, 'last_num' => Tapatalk_Input::INT, 'return_html' => Tapatalk_Input::INT), $xmlrpc_params);
    if (preg_match('/^ann_/', $input['topic_id'])) {
        $_GET["aid"] = intval(str_replace('ann_', '', $input['topic_id']));
        return get_announcement_func($xmlrpc_params);
    }
    $lang->load("showthread");
    global $parser;
    $parser = new Tapatalk_Parser();
    // Get the thread details from the database.
    $thread = get_thread($input['topic_id']);
    if (!empty($thread['closed'])) {
        $moved = explode("|", $thread['closed']);
        if ($moved[0] == "moved") {
            $thread = get_thread($moved[1]);
        }
    }
    // Get thread prefix if there is one.
    $thread['threadprefix'] = '';
    $thread['displayprefix'] = '';
    if ($thread['prefix'] != 0) {
        $threadprefix = build_prefixes($thread['prefix']);
        if ($threadprefix['prefix']) {
            $thread['threadprefix'] = $threadprefix['prefix'] . '&nbsp;';
            $thread['displayprefix'] = $threadprefix['displaystyle'] . '&nbsp;';
        }
    }
    $thread['subject'] = $parser->parse_badwords($thread['subject']);
    $tid = $thread['tid'];
    $fid = $thread['fid'];
    if (!$thread['username']) {
        $thread['username'] = $lang->guest;
    }
    $visibleonly = "AND visible='1'";
    // Is the currently logged in user a moderator of this forum?
    if (is_moderator($fid)) {
        $visibleonly = " AND (visible='1' OR visible='0')";
        $ismod = true;
    } else {
        $ismod = false;
    }
    $forumpermissions = forum_permissions($thread['fid']);
    // Does the user have permission to view this thread?
    if ($forumpermissions['canview'] != 1 || $forumpermissions['canviewthreads'] != 1) {
        error_no_permission();
    }
    if ($forumpermissions['canonlyviewownthreads'] == 1 && $thread['uid'] != $mybb->user['uid']) {
        error_no_permission();
    }
    // Make sure we are looking at a real thread here.
    if (!$thread['tid'] || $thread['visible'] == 0 && $ismod == false || $thread['visible'] > 1 && $ismod == true) {
        return xmlrespfalse($lang->error_invalidthread);
    }
    // Does the thread belong to a valid forum?
    $forum = get_forum($fid);
    if (!$forum || $forum['type'] != "f") {
        return xmlrespfalse($lang->error_invalidforum);
    }
    tt_check_forum_password($forum['fid']);
    if ($thread['firstpost'] == 0) {
        update_first_post($tid);
    }
    // Mark this thread as read
    mark_thread_read($tid, $fid);
    // Increment the thread view.
    if ($mybb->settings['delayedthreadviews'] == 1) {
        $db->shutdown_query("INSERT INTO " . TABLE_PREFIX . "threadviews (tid) VALUES('{$tid}')");
    } else {
        $db->shutdown_query("UPDATE " . TABLE_PREFIX . "threads SET views=views+1 WHERE tid='{$tid}'");
    }
    ++$thread['views'];
    // Work out if we are showing unapproved posts as well (if the user is a moderator etc.)
    if ($ismod) {
        $visible = "AND (p.visible='0' OR p.visible='1')";
    } else {
        $visible = "AND p.visible='1'";
    }
    // Fetch the ignore list for the current user if they have one
    $ignored_users = array();
    if ($mybb->user['uid'] > 0 && $mybb->user['ignorelist'] != "") {
        $ignore_list = explode(',', $mybb->user['ignorelist']);
        foreach ($ignore_list as $uid) {
            $ignored_users[$uid] = 1;
        }
    }
    list($start, $limit) = process_page($input['start_num'], $input['last_num']);
    // Recount replies if user is a moderator to take into account unapproved posts.
    if ($ismod) {
        $query = $db->simple_select("posts p", "COUNT(*) AS replies", "p.tid='{$tid}' {$visible}");
        $thread['replies'] = $db->fetch_field($query, 'replies') - 1;
    }
    $postcount = intval($thread['replies']) + 1;
    $pids = "";
    $comma = '';
    $query = $db->simple_select("posts p", "p.pid", "p.tid='{$tid}' {$visible}", array('order_by' => 'p.dateline', 'limit_start' => $start, 'limit' => $limit));
    while ($getid = $db->fetch_array($query)) {
        // Set the ID of the first post on page to $pid if it doesn't hold any value
        // to allow this value to be used for Thread Mode/Linear Mode links
        // and ensure the user lands on the correct page after changing view mode
        if (!$pid) {
            $pid = $getid['pid'];
        }
        // Gather a comma separated list of post IDs
        $pids .= "{$comma}'{$getid['pid']}'";
        $comma = ",";
    }
    if ($pids) {
        $pids = "pid IN({$pids})";
        global $attachcache;
        $attachcache = array();
        if ($thread['attachmentcount'] > 0) {
            // Now lets fetch all of the attachments for these posts.
            $query = $db->simple_select("attachments", "*", $pids);
            while ($attachment = $db->fetch_array($query)) {
                $attachcache[$attachment['pid']][$attachment['aid']] = $attachment;
            }
        }
    } else {
        // If there are no pid's the thread is probably awaiting approval.
        return xmlrespfalse($lang->error_invalidthread);
    }
    $post_list = array();
    // Get the actual posts from the database here.
    $posts = '';
    $query = $db->query("\n        SELECT u.*, u.username AS userusername, p.*, f.*, eu.username AS editusername, IF(b.lifted > UNIX_TIMESTAMP() OR b.lifted = 0, 1, 0) as isbanned\n        FROM " . TABLE_PREFIX . "posts p\n        LEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid=p.uid)\n        LEFT JOIN " . TABLE_PREFIX . "userfields f ON (f.ufid=u.uid)\n        LEFT JOIN " . TABLE_PREFIX . "users eu ON (eu.uid=p.edituid)\n        LEFT JOIN " . TABLE_PREFIX . "banned b ON (b.uid = p.uid)\n        WHERE {$pids}\n        ORDER BY p.dateline\n    ");
    //can_rename topic
    $can_rename = (is_moderator($fid, "caneditposts") || $forumpermissions['caneditposts'] == 1 && $mybb->user['uid'] == $thread['uid']) && $mybb->user['uid'] != 0;
    while ($post = $db->fetch_array($query)) {
        if ($thread['firstpost'] == $post['pid'] && $thread['visible'] == 0) {
            $post['visible'] = 0;
        }
        //$posts .= build_postbit($post);
        $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['subject'] = $parser->parse_badwords($post['subject']);
        $post['author'] = $post['uid'];
        if ($post['userusername']) {
            // This post was made by a registered user
            $post['username'] = $post['userusername'];
        }
        // Eidt Option
        $can_edit = (is_moderator($fid, "caneditposts") || $forumpermissions['caneditposts'] == 1 && $mybb->user['uid'] == $post['uid']) && $mybb->user['uid'] != 0;
        // Quick Delete Option
        $can_delete = 0;
        if ($mybb->user['uid'] == $post['uid']) {
            if ($forumpermissions['candeletethreads'] == 1 && $postcounter == 1) {
                $can_delete = 1;
            } else {
                if ($forumpermissions['candeleteposts'] == 1 && $postcounter != 1) {
                    $can_delete = 1;
                }
            }
        }
        $can_delete = (is_moderator($fid, "candeleteposts") || $can_delete == 1) && $mybb->user['uid'] != 0;
        // User Online status
        $is_online = false;
        $timecut = TIME_NOW - $mybb->settings['wolcutoff'];
        if ($post['lastactive'] > $timecut && ($post['invisible'] != 1 || $mybb->usergroup['canviewwolinvis'] == 1) && $post['lastvisit'] != $post['lastactive']) {
            $is_online = true;
        }
        $post['message'] = post_bbcode_clean($post['message']);
        $plugins->remove_hook('parse_message', 'mybbirckeditor_parser');
        // Post content and attachments
        $post['message'] = $parser->parse_message($post['message'], $parser_options);
        $attachment_list = process_post_attachments($post['pid'], $post);
        // add for thank/like support
        $post = $plugins->run_hooks("postbit", $post);
        if (is_array($ignored_users) && $post['uid'] != 0 && $ignored_users[$post['uid']] == 1) {
            $show_spoiler = "[spoiler]" . $post['message'] . "[/spoiler]";
            $post['message'] = $lang->sprintf($lang->postbit_currently_ignoring_user, $post['username']) . $show_spoiler;
        }
        $post_xmlrpc = array('post_id' => new xmlrpcval($post['pid'], 'string'), 'post_title' => new xmlrpcval(basic_clean($post['subject']), 'base64'), 'post_content' => new xmlrpcval(process_post($post['message'], $input['return_html']), 'base64'), 'post_author_id' => new xmlrpcval($post['uid'], 'string'), 'post_author_name' => new xmlrpcval(basic_clean($post['username']), 'base64'), 'icon_url' => new xmlrpcval(absolute_url($post['avatar']), 'string'), 'post_time' => new xmlrpcval(mobiquo_iso8601_encode($post['dateline']), 'dateTime.iso8601'), 'timestamp' => new xmlrpcval($post['dateline'], 'string'), 'attachments' => new xmlrpcval($attachment_list, 'array'));
        if (!$post['visible']) {
            $post_xmlrpc['is_approved'] = new xmlrpcval(false, 'boolean');
        }
        // default as true
        if ($post['smilieoff']) {
            $post_xmlrpc['allow_smilies'] = new xmlrpcval(false, 'boolean');
        }
        // default as true
        if ($post['isbanned']) {
            $post_xmlrpc['is_ban'] = new xmlrpcval(true, 'boolean');
        }
        if ($is_online) {
            $post_xmlrpc['is_online'] = new xmlrpcval(true, 'boolean');
        }
        if ($can_edit) {
            $post_xmlrpc['can_edit'] = new xmlrpcval(true, 'boolean');
        }
        if ($can_delete) {
            $post_xmlrpc['can_delete'] = new xmlrpcval(true, 'boolean');
        }
        if (is_moderator($fid, 'canmanagethreads')) {
            $post_xmlrpc['can_approve'] = new xmlrpcval(true, 'boolean');
        }
        if (is_moderator($fid, 'canmanagethreads')) {
            $post_xmlrpc['can_move'] = new xmlrpcval(true, 'boolean');
        }
        if ($mybb->usergroup['canmodcp'] == 1) {
            $post_xmlrpc['can_ban'] = new xmlrpcval(true, 'boolean');
        }
        if ($post['edituid']) {
            //add edit info
            $edit_info = array('editor_id' => new xmlrpcval($post['edituid'], 'string'), 'editor_name' => new xmlrpcval($post['editusername'], 'base64'), 'edit_time' => new xmlrpcval($post['edittime'], 'string'));
            if (!empty($post['editreason'])) {
                $edit_info['edit_reason'] = new xmlrpcval($post['editreason'], 'base64');
            }
            $post_xmlrpc = array_merge($post_xmlrpc, $edit_info);
        }
        // add for thank/like support
        if (isset($post['button_tyl']) && $mybb->user['uid']) {
            global $mobiquo_config, $g33k_pcache;
            $thlprefix = $mobiquo_config['thlprefix'];
            $tyled = false;
            $tyl_list = array();
            if ($mybb->settings[$thlprefix . 'enabled'] == "1") {
                if ($post['thankyoulike'] && isset($g33k_pcache[$post['pid']])) {
                    foreach ($g33k_pcache[$post['pid']] as $tyl) {
                        if ($tyl['uid'] == $mybb->user['uid']) {
                            $tyled = true;
                        }
                        $tyl_list[] = new xmlrpcval(array('userid' => new xmlrpcval($tyl['uid'], 'string'), 'username' => new xmlrpcval(basic_clean($tyl['username']), 'base64')), 'struct');
                    }
                }
                if ($mybb->settings[$thlprefix . 'thankslike'] == "like") {
                    if ($post['button_tyl']) {
                        $post_xmlrpc['can_like'] = new xmlrpcval(true, 'boolean');
                    }
                    if ($tyled) {
                        $post_xmlrpc['is_liked'] = new xmlrpcval(true, 'boolean');
                    }
                    if ($tyl_list) {
                        $post_xmlrpc['likes_info'] = new xmlrpcval($tyl_list, 'array');
                    }
                } else {
                    if ($mybb->settings[$thlprefix . 'thankslike'] == "thanks") {
                        if ($post['button_tyl']) {
                            $post_xmlrpc['can_thank'] = new xmlrpcval(true, 'boolean');
                        }
                        if ($mybb->settings[$thlprefix . 'removing'] == 1) {
                            $post_xmlrpc['can_remove_thank'] = new xmlrpcval(true, 'boolean');
                        }
                        if ($tyled) {
                            $post_xmlrpc['is_thanked'] = new xmlrpcval(true, 'boolean');
                        }
                        if ($tyl_list) {
                            $post_xmlrpc['thanks_info'] = new xmlrpcval($tyl_list, 'array');
                        }
                    }
                }
            }
        }
        $post_list[] = new xmlrpcval($post_xmlrpc, 'struct');
    }
    $query = $db->simple_select("threadsubscriptions", "tid", "tid='" . intval($tid) . "' AND uid='" . intval($mybb->user['uid']) . "'", array('limit' => 1));
    $subscribed = (bool) $db->fetch_field($query, 'tid');
    $query = $db->simple_select("banned", "uid", "uid='{$thread['uid']}'");
    $isbanned = !!$db->fetch_field($query, "uid");
    $can_reply = $forumpermissions['canpostreplys'] != 0 && $mybb->user['suspendposting'] != 1 && ($thread['closed'] != 1 || is_moderator($fid)) && $forum['open'] != 0;
    build_tt_breadcrumb($fid);
    $navgation_arr = $navbits;
    if (is_array($navgation_arr) && count($navgation_arr) > 1) {
        unset($navgation_arr[0]);
        foreach ($navgation_arr as $navigation) {
            $forum_id = $navigation['fid'];
            $sub_only = false;
            if ($navigation['type'] != 'f') {
                $sub_only = true;
            }
            $breadcrumb[] = new xmlrpcval(array('forum_id' => new xmlrpcval($forum_id, 'string'), 'forum_name' => new xmlrpcval($navigation['name'], 'base64'), 'sub_only' => new xmlrpcval($sub_only, 'boolean')), 'struct');
        }
    }
    $is_poll = !empty($thread['poll']) ? true : false;
    $result = array('total_post_num' => new xmlrpcval($postcount, 'int'), 'forum_id' => new xmlrpcval($thread['fid'], 'string'), 'forum_name' => new xmlrpcval(basic_clean($forum['name']), 'base64'), 'topic_id' => new xmlrpcval($thread['tid'], 'string'), 'topic_title' => new xmlrpcval(basic_clean($thread['subject']), 'base64'), 'can_upload' => new xmlrpcval($forumpermissions['canpostattachments'] != 0, 'boolean'), 'can_report' => new xmlrpcval(true, 'boolean'), 'can_reply' => new xmlrpcval($can_reply, 'boolean'), 'is_poll' => new xmlrpcval($is_poll, 'boolean'), 'view_number' => new xmlrpcval(intval($thread['views']), 'int'));
    if ($forumpermissions['canview'] == 0 || $forumpermissions['canviewthreads'] == 0) {
        $new_topic['can_subscribe'] = new xmlrpcval(false, 'boolean');
    } else {
        $new_topic['can_subscribe'] = new xmlrpcval(true, 'boolean');
    }
    if ($thread['prefix']) {
        $result['prefix'] = new xmlrpcval(basic_clean($thread['displayprefix']), 'base64');
    }
    if (!$thread['visible']) {
        $result['is_approved'] = new xmlrpcval(false, 'boolean');
    }
    // default as true
    if ($thread['closed']) {
        $result['is_closed'] = new xmlrpcval(true, 'boolean');
    }
    if ($thread['sticky']) {
        $result['is_sticky'] = new xmlrpcval(true, 'boolean');
    }
    if ($subscribed) {
        $result['is_subscribed'] = new xmlrpcval(true, 'boolean');
    } else {
        $result['is_subscribed'] = new xmlrpcval(false, 'boolean');
    }
    if ($isbanned) {
        $result['is_ban'] = new xmlrpcval(true, 'boolean');
    }
    if ($position) {
        $result['position'] = new xmlrpcval(intval($position), 'int');
    }
    if (is_moderator($fid, "canopenclosethreads")) {
        $result['can_close'] = new xmlrpcval(true, 'boolean');
    }
    if (is_moderator($fid, "candeleteposts")) {
        $result['can_delete'] = new xmlrpcval(true, 'boolean');
    }
    if (is_moderator($fid, "canmanagethreads")) {
        $result['can_stick'] = new xmlrpcval(true, 'boolean');
    }
    if (is_moderator($fid, "canmanagethreads")) {
        $result['can_move'] = new xmlrpcval(true, 'boolean');
        $result['can_merge'] = new xmlrpcval(true, 'boolean');
        $result['can_merge_post'] = new xmlrpcval(true, 'boolean');
    }
    if (is_moderator($fid, "canopenclosethreads")) {
        $result['can_approve'] = new xmlrpcval(true, 'boolean');
    }
    if ($can_rename) {
        $result['can_rename'] = new xmlrpcval(true, 'boolean');
    }
    if ($mybb->usergroup['canmodcp'] == 1) {
        $result['can_ban'] = new xmlrpcval(true, 'boolean');
    }
    if (!empty($breadcrumb)) {
        $result['breadcrumb'] = new xmlrpcval($breadcrumb, 'array');
    }
    $result['posts'] = new xmlrpcval($post_list, 'array');
    return new xmlrpcresp(new xmlrpcval($result, 'struct'));
}
コード例 #7
0
ファイル: moderation.php プロジェクト: dthiago/tapatalk-mybb
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);
    }
}
コード例 #8
0
ファイル: get_topic.php プロジェクト: dthiago/tapatalk-mybb
function get_topic_func($xmlrpc_params)
{
    global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $time, $mybbgroups;
    $lang->load("member");
    $parser = new postParser();
    $input = Tapatalk_Input::filterXmlInput(array('forum_id' => Tapatalk_Input::INT, 'start_num' => Tapatalk_Input::INT, 'last_num' => Tapatalk_Input::INT, 'mode' => Tapatalk_Input::STRING), $xmlrpc_params);
    $lang->load("forumdisplay");
    $fid = $input['forum_id'];
    $foruminfo = get_forum($fid);
    if (!$foruminfo) {
        return xmlrespfalse($lang->error_invalidforum);
    }
    list($start, $limit) = process_page($input['start_num'], $input['last_num']);
    $forumpermissions = forum_permissions();
    $fpermissions = $forumpermissions[$fid];
    if ($fpermissions['canview'] != 1) {
        return tt_no_permission();
    }
    switch ($input['mode']) {
        case 'TOP':
            $stickyonly = " AND sticky=1 ";
            $tstickyonly = " AND t.sticky=1 ";
            break;
        case 'ANN':
            return get_announcement_list($foruminfo, $fid);
            break;
        default:
            $stickyonly = " AND sticky=0 ";
            $tstickyonly = " AND t.sticky=0 ";
            break;
    }
    if ($mybb->user['uid'] == 0) {
        // Build a forum cache.
        $query = $db->query("\n            SELECT *\n            FROM " . TABLE_PREFIX . "forums\n            WHERE active != 0\n            ORDER BY pid, disporder\n        ");
        $forumsread = unserialize($mybb->cookies['mybb']['forumread']);
        if (!is_array($forumsread)) {
            $forumsread = array();
        }
    } else {
        // Build a forum cache.
        $query = $db->query("\n            SELECT f.*, fr.dateline AS lastread\n            FROM " . TABLE_PREFIX . "forums f\n            LEFT JOIN " . TABLE_PREFIX . "forumsread fr ON (fr.fid=f.fid AND fr.uid='{$mybb->user['uid']}')\n            WHERE f.active != 0\n            ORDER BY pid, disporder\n        ");
    }
    while ($forum = $db->fetch_array($query)) {
        if ($mybb->user['uid'] == 0) {
            if ($forumsread[$forum['fid']]) {
                $forum['lastread'] = $forumsread[$forum['fid']];
            }
        }
        $fcache[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum;
    }
    tt_check_forum_password($foruminfo['fid']);
    if ($foruminfo['linkto']) {
        return xmlrespfalse('This forum is a link');
    }
    $visibleonly = "AND visible='1'";
    $tvisibleonly = "AND t.visible='1'";
    // Check if the active user is a moderator and get the inline moderation tools.
    if (is_moderator($fid)) {
        $ismod = true;
        $inlinecount = "0";
        $inlinecookie = "inlinemod_forum" . $fid;
        $visibleonly = " AND (visible='1' OR visible='0')";
        $tvisibleonly = " AND (t.visible='1' OR t.visible='0')";
    } else {
        $inlinemod = '';
        $ismod = false;
    }
    if (is_moderator($fid, "caneditposts") || $fpermissions['caneditposts'] == 1) {
        $can_edit_titles = 1;
    } else {
        $can_edit_titles = 0;
    }
    $t = "t.";
    $sortby = "lastpost";
    $sortfield = "lastpost";
    $sortordernow = "desc";
    $threadcount = 0;
    $useronly = $tuseronly = "";
    if ($fpermissions['canonlyviewownthreads'] == 1) {
        $useronly = "AND uid={$mybb->user['uid']}";
        $tuseronly = "AND t.uid={$mybb->user['uid']}";
    }
    if ($fpermissions['canviewthreads'] != 0) {
        // How many posts are there?
        if ($datecut > 0 || $fpermissions['canonlyviewownthreads'] == 1) {
            $query = $db->simple_select("threads", "COUNT(tid) AS threads", "fid = '{$fid}' {$useronly} {$visibleonly} {$stickyonly}");
            $threadcount = $db->fetch_field($query, "threads");
        } else {
            $query = $db->simple_select("threads", "COUNT(tid) AS threads", "fid = '{$fid}' {$useronly} {$visibleonly} {$stickyonly}", array('limit' => 1));
            $threadcount = $db->fetch_field($query, "threads");
        }
    }
    // count unread stickies
    $query = $db->query("\n        select COUNT(t.tid) AS threads\n        from " . TABLE_PREFIX . "threads t\n        left join " . TABLE_PREFIX . "threadsread tr on t.tid = tr.tid and tr.uid = '{$mybb->user['uid']}'\n        where t.fid = '{$fid}' {$tuseronly} {$tvisibleonly} and t.sticky=1 and (tr.dateline < t.lastpost or tr.dateline is null)\n    ");
    $unreadStickyCount = $db->fetch_field($query, "threads");
    if ($fpermissions['canviewthreads'] != 0) {
        // Start Getting Threads
        $query = $db->query("\n            SELECT t.*, {$ratingadd}{$select_rating_user}t.username AS threadusername, u.username, u.avatar, s.sid as subscribed, po.message, IF(b.lifted > UNIX_TIMESTAMP() OR b.lifted = 0, 1, 0) as isbanned\n            FROM " . TABLE_PREFIX . "threads t\n            LEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid = t.uid){$select_voting}\n            LEFT JOIN " . TABLE_PREFIX . "banned b ON (b.uid = t.uid) \n            LEFT JOIN " . TABLE_PREFIX . "threadsubscriptions s ON (s.tid = t.tid) AND (s.uid = '{$mybb->user['uid']}')\n            LEFT JOIN " . TABLE_PREFIX . "posts po ON (po.pid = t.firstpost)\n            WHERE t.fid='{$fid}' {$tuseronly} {$tvisibleonly} {$tstickyonly}\n            GROUP BY t.tid\n            ORDER BY t.sticky DESC, {$t}{$sortfield} {$sortordernow} {$sortfield2}\n            LIMIT {$start}, {$limit}\n        ");
        while ($thread = $db->fetch_array($query)) {
            $threadcache[$thread['tid']] = $thread;
            // If this is a moved thread - set the tid for participation marking and thread read marking to that of the moved thread
            if (substr($thread['closed'], 0, 5) == "moved") {
                $tid = substr($thread['closed'], 6);
                if (!$tids[$tid]) {
                    $moved_threads[$tid] = $thread['tid'];
                    $tids[$thread['tid']] = $tid;
                }
            } else {
                $tids[$thread['tid']] = $thread['tid'];
                if ($moved_threads[$tid]) {
                    unset($moved_threads[$tid]);
                }
            }
        }
    } else {
        $threadcache = $tids = null;
    }
    if ($tids) {
        $tids = implode(",", $tids);
    }
    if ($mybb->settings['dotfolders'] != 0 && $mybb->user['uid'] && $threadcache) {
        $query = $db->simple_select("posts", "tid,uid", "uid='{$mybb->user['uid']}' AND tid IN ({$tids})");
        while ($post = $db->fetch_array($query)) {
            if ($moved_threads[$post['tid']]) {
                $post['tid'] = $moved_threads[$post['tid']];
            }
            if ($threadcache[$post['tid']]) {
                $threadcache[$post['tid']]['doticon'] = 1;
            }
        }
    }
    if ($mybb->user['uid'] && $mybb->settings['threadreadcut'] > 0 && $threadcache) {
        $query = $db->simple_select("threadsread", "*", "uid='{$mybb->user['uid']}' AND tid IN ({$tids})");
        while ($readthread = $db->fetch_array($query)) {
            if ($moved_threads[$readthread['tid']]) {
                $readthread['tid'] = $moved_threads[$readthread['tid']];
            }
            if ($threadcache[$readthread['tid']]) {
                $threadcache[$readthread['tid']]['lastread'] = $readthread['dateline'];
            }
        }
    }
    if ($mybb->settings['threadreadcut'] > 0 && $mybb->user['uid']) {
        $query = $db->simple_select("forumsread", "dateline", "fid='{$fid}' AND uid='{$mybb->user['uid']}'");
        $forum_read = $db->fetch_field($query, "dateline");
        $read_cutoff = TIME_NOW - $mybb->settings['threadreadcut'] * 60 * 60 * 24;
        if ($forum_read == 0 || $forum_read < $read_cutoff) {
            $forum_read = $read_cutoff;
        }
    } else {
        $forum_read = my_get_array_cookie("forumread", $fid);
    }
    $threads = '';
    $load_inline_edit_js = 0;
    $topic_list = array();
    if (is_array($threadcache)) {
        reset($threadcache);
        foreach ($threadcache as $thread) {
            $unreadpost = false;
            $moved = explode("|", $thread['closed']);
            $thread['author'] = $thread['uid'];
            if (!$thread['username']) {
                $thread['username'] = $thread['threadusername'];
                $thread['profilelink'] = $thread['threadusername'];
            } else {
                $thread['profilelink'] = build_profile_link($thread['username'], $thread['uid']);
            }
            // If this thread has a prefix, insert a space between prefix and subject
            if ($thread['prefix'] != 0) {
                $threadprefix = build_prefixes($thread['prefix']);
                $thread['displayprefix'] = $threadprefix['displaystyle'];
            }
            $thread['subject'] = $parser->parse_badwords($thread['subject']);
            $prefix = '';
            if ($thread['poll']) {
                $prefix = $lang->poll_prefix;
            }
            $thread['posts'] = $thread['replies'] + 1;
            if ($moved[0] == "moved") {
                $prefix = $lang->moved_prefix;
                $thread['replies'] = "-";
                $thread['views'] = "-";
            }
            $gotounread = '';
            $isnew = 0;
            $donenew = 0;
            if ($mybb->settings['threadreadcut'] > 0 && $mybb->user['uid'] && $thread['lastpost'] > $forum_read) {
                if ($thread['lastread']) {
                    $last_read = $thread['lastread'];
                } else {
                    $last_read = $read_cutoff;
                }
            } else {
                $last_read = my_get_array_cookie("threadread", $thread['tid']);
            }
            if ($forum_read > $last_read) {
                $last_read = $forum_read;
            }
            if ($thread['lastpost'] > $last_read && $moved[0] != "moved") {
                $folder .= "new";
                $folder_label .= $lang->icon_new;
                $new_class = "subject_new";
                $unreadpost = true;
            } else {
                $folder_label .= $lang->icon_no_new;
                $new_class = "subject_old";
            }
            if (!empty($thread['closed'])) {
                $moved = explode("|", $thread['closed']);
                if ($moved[0] == "moved") {
                    $thread['subject'] = $lang->moved_prefix . ' ' . $thread['subject'];
                }
            }
            $new_topic = array('forum_id' => new xmlrpcval($thread['fid'], 'string'), 'topic_id' => new xmlrpcval($thread['tid'], 'string'), 'topic_title' => new xmlrpcval(basic_clean($thread['subject']), 'base64'), 'prefix' => new xmlrpcval(basic_clean($thread['displayprefix']), 'base64'), 'topic_author_id' => new xmlrpcval($thread['uid'], 'string'), 'topic_author_name' => new xmlrpcval(basic_clean($thread['username']), 'base64'), 'icon_url' => new xmlrpcval(absolute_url($thread['avatar']), 'string'), 'last_reply_time' => new xmlrpcval(mobiquo_iso8601_encode($thread['lastpost']), 'dateTime.iso8601'), 'timestamp' => new xmlrpcval($thread['lastpost'], 'string'), 'short_content' => new xmlrpcval(process_short_content($thread['message'], $parser), 'base64'), 'reply_number' => new xmlrpcval(intval($thread['replies']), 'int'), 'view_number' => new xmlrpcval(intval($thread['views']), 'int'), 'is_approved' => new xmlrpcval($thread['visible'], 'boolean'), 'is_moved' => new xmlrpcval(isset($moved[0]) && $moved[0] == "moved" ? true : false, 'boolean'), 'real_topic_id' => new xmlrpcval(isset($moved[1]) ? $moved[1] : $thread['tid']));
            $forumpermissions = forum_permissions($thread['fid']);
            if ($forumpermissions['canview'] == 0 || $forumpermissions['canviewthreads'] == 0) {
                $new_topic['can_subscribe'] = new xmlrpcval(false, 'boolean');
            } else {
                $new_topic['can_subscribe'] = new xmlrpcval(true, 'boolean');
            }
            //can_rename topic
            $can_rename = (is_moderator($fid, "caneditposts") || $forumpermissions['caneditposts'] == 1 && $mybb->user['uid'] == $thread['uid']) && $mybb->user['uid'] != 0;
            if ($unreadpost) {
                $new_topic['new_post'] = new xmlrpcval(true, 'boolean');
            }
            if ($thread['sticky']) {
                $new_topic['is_sticky'] = new xmlrpcval(true, 'boolean');
            }
            if (!empty($thread['subscribed'])) {
                $new_topic['is_subscribed'] = new xmlrpcval(true, 'boolean');
            } else {
                $new_topic['is_subscribed'] = new xmlrpcval(false, 'boolean');
            }
            if ($thread['closed']) {
                $new_topic['is_closed'] = new xmlrpcval(true, 'boolean');
            }
            if ($thread['isbanned']) {
                $new_topic['is_ban'] = new xmlrpcval(true, 'boolean');
            }
            if ($mybb->usergroup['canmodcp'] == 1) {
                $new_topic['can_ban'] = new xmlrpcval(true, 'boolean');
            }
            if (is_moderator($fid, "canmanagethreads")) {
                $new_topic['can_move'] = new xmlrpcval(true, 'boolean');
                $new_topic['can_merge'] = new xmlrpcval(true, 'boolean');
                $new_topic['can_merge_post'] = new xmlrpcval(true, 'boolean');
            }
            if (is_moderator($fid, "canopenclosethreads")) {
                $new_topic['can_close'] = new xmlrpcval(true, 'boolean');
            }
            if (is_moderator($fid, "candeleteposts")) {
                $new_topic['can_delete'] = new xmlrpcval(true, 'boolean');
            }
            if (is_moderator($fid, "canmanagethreads")) {
                $new_topic['can_stick'] = new xmlrpcval(true, 'boolean');
            }
            if (is_moderator($fid, "canopenclosethreads")) {
                $new_topic['can_approve'] = new xmlrpcval(true, 'boolean');
            }
            if ($can_rename) {
                $new_topic['can_rename'] = new xmlrpcval(true, 'boolean');
            }
            $topic_list[] = new xmlrpcval($new_topic, 'struct');
        }
        $customthreadtools = '';
    }
    // If there are no unread threads in this forum and no unread child forums - mark it as read
    require_once MYBB_ROOT . "inc/functions_indicators.php";
    if (fetch_unread_count($fid) == 0 && $unread_forums == 0) {
        mark_forum_read($fid);
    }
    $prefix_list = array();
    // Does this user have additional groups?
    if ($mybb->user['additionalgroups']) {
        $exp = explode(",", $mybb->user['additionalgroups']);
        // Because we like apostrophes...
        $imps = array();
        foreach ($exp as $group) {
            $imps[] = "'{$group}'";
        }
        $additional_groups = implode(",", $imps);
        $extra_sql = "groups IN ({$additional_groups}) OR ";
    } else {
        $extra_sql = '';
    }
    if ($mybb->version_code >= 1600 && $mybb->user['uid']) {
        $prefixes = get_prefix_list($fid);
        foreach ($prefixes as $prefix) {
            $prefix_list[] = new xmlrpcval(array('prefix_id' => new xmlrpcval($prefix['pid'], "string"), 'prefix_display_name' => new xmlrpcval(basic_clean($prefix['prefix']), "base64")), "struct");
        }
    }
    $read_only_forums = explode(",", $settings['tapatalk_forum_read_only']);
    $can_post = true;
    if (empty($read_only_forums) || !is_array($read_only_forums)) {
        $read_only_forums = array();
    }
    if (!($foruminfo['type'] == "f" && $foruminfo['open'] != 0 && $mybb->user['uid'] > 0 && $mybb->usergroup['canpostthreads']) || in_array($fid, $read_only_forums)) {
        $can_post = false;
    }
    $result = array('total_topic_num' => new xmlrpcval($threadcount, 'int'), 'forum_id' => new xmlrpcval($fid, 'string'), 'forum_name' => new xmlrpcval(basic_clean($foruminfo['name']), 'base64'), 'can_post' => new xmlrpcval($can_post, 'boolean'), 'prefixes' => new xmlrpcval($prefix_list, 'array'), 'can_upload' => new xmlrpcval($fpermissions['canpostattachments'], 'boolean'));
    if ($unreadStickyCount) {
        $result['unread_sticky_count'] = new xmlrpcval($unreadStickyCount, 'int');
    }
    if ($mybb->user['uid']) {
        $query = $db->simple_select("forumsubscriptions", "fid", "fid='" . $fid . "' AND uid='{$mybb->user['uid']}'", array('limit' => 1));
        if ($db->fetch_field($query, 'fid')) {
            $result['is_subscribed'] = new xmlrpcval(true, 'boolean');
        }
    }
    $result['topics'] = new xmlrpcval($topic_list, 'array');
    return new xmlrpcresp(new xmlrpcval($result, 'struct'));
}
コード例 #9
0
function get_raw_post_func($xmlrpc_params)
{
    global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups;
    require_once MYBB_ROOT . $mybb->settings['tapatalk_directory'] . '/emoji/emoji.class.php';
    $lang->load("editpost");
    $input = Tapatalk_Input::filterXmlInput(array('post_id' => Tapatalk_Input::INT), $xmlrpc_params);
    // 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 (!$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']);
    if ($forumpermissions['canpostattachments'] != 0) {
        // Get a listing of the current attachments, if there are any
        $attachcount = 0;
        global $attachcache;
        $query = $db->simple_select("attachments", "*", "pid='{$pid}'");
        $attachments = '';
        while ($attachment = $db->fetch_array($query)) {
            $attachcache[$attachment['pid']][$attachment['aid']] = $attachment;
            $attachcount++;
        }
    }
    $attachment_list = array();
    if ($attachcount) {
        $attachment_list = process_post_attachments($post['pid'], $post, true);
    }
    $result = new xmlrpcval(array('post_id' => new xmlrpcval($post['pid'], 'string'), 'post_title' => new xmlrpcval($post['subject'], 'base64'), 'post_content' => new xmlrpcval(tapatalkEmoji::covertNameToEmoji($post['message']), 'base64'), 'attachments' => new xmlrpcval($attachment_list, 'array'), 'group_id' => new xmlrpcval($post['posthash']), 'show_reason' => new xmlrpcval($mybb->settings['alloweditreason'] && version_compare($mybb->version, '1.8.0', '>='), 'boolean'), 'edit_reason' => new xmlrpcval($post['editreason'], 'base64')), 'struct');
    return new xmlrpcresp($result);
}
コード例 #10
0
ファイル: new_topic.php プロジェクト: dthiago/tapatalk-mybb
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);
}
コード例 #11
0
ファイル: report_post.php プロジェクト: dthiago/tapatalk-mybb
function report_post_func($xmlrpc_params)
{
    global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups;
    $input = Tapatalk_Input::filterXmlInput(array('post_id' => Tapatalk_Input::INT, 'reason' => Tapatalk_Input::STRING), $xmlrpc_params);
    $lang->load("report");
    if ($mybb->usergroup['canview'] == 0 || !$mybb->user['uid']) {
        return tt_no_permission();
    }
    $post = get_post($input['post_id']);
    if (!$post['pid']) {
        return xmlrespfalse($lang->error_invalidpost);
    }
    $forum = get_forum($post['fid']);
    if (!$forum) {
        $error = $lang->error_invalidforum;
        eval("\$report_error = \"" . $templates->get("report_error") . "\";");
        output_page($report_error);
        exit;
    }
    tt_check_forum_password($forum['parentlist']);
    $thread = get_thread($post['tid']);
    if (version_compare($mybb->version, '1.8.0', '<')) {
        if ($mybb->settings['reportmethod'] == "email" || $mybb->settings['reportmethod'] == "pms") {
            $query = $db->query("\n\t\t\t\tSELECT DISTINCT u.username, u.email, u.receivepms, u.uid\n\t\t\t\tFROM " . TABLE_PREFIX . "moderators m\n\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid=m.id)\n\t\t\t\tWHERE m.fid IN (" . $forum['parentlist'] . ") AND m.isgroup = '0'\n\t\t\t");
            $nummods = $db->num_rows($query);
            if (!$nummods) {
                unset($query);
                switch ($db->type) {
                    case "pgsql":
                    case "sqlite":
                        $query = $db->query("\n\t\t\t\t\t\t\tSELECT u.username, u.email, u.receivepms, u.uid\n\t\t\t\t\t\t\tFROM " . TABLE_PREFIX . "users u\n\t\t\t\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "usergroups g ON (((','|| u.additionalgroups|| ',' LIKE '%,'|| g.gid|| ',%') OR u.usergroup = g.gid))\n\t\t\t\t\t\t\tWHERE (g.cancp=1 OR g.issupermod=1)\n\t\t\t\t\t\t");
                        break;
                    default:
                        $query = $db->query("\n\t\t\t\t\t\t\tSELECT u.username, u.email, u.receivepms, u.uid\n\t\t\t\t\t\t\tFROM " . TABLE_PREFIX . "users u\n\t\t\t\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "usergroups g ON (((CONCAT(',', u.additionalgroups, ',') LIKE CONCAT('%,', g.gid, ',%')) OR u.usergroup = g.gid))\n\t\t\t\t\t\t\tWHERE (g.cancp=1 OR g.issupermod=1)\n\t\t\t\t\t\t");
                }
            }
            while ($mod = $db->fetch_array($query)) {
                $emailsubject = $lang->sprintf($lang->emailsubject_reportpost, $mybb->settings['bbname']);
                $emailmessage = $lang->sprintf($lang->email_reportpost, $mybb->user['username'], $mybb->settings['bbname'], $post['subject'], $mybb->settings['bburl'], str_replace('&amp;', '&', get_post_link($post['pid'], $thread['tid']) . "#pid" . $post['pid']), $thread['subject'], $input['reason']);
                if ($mybb->settings['reportmethod'] == "pms" && $mod['receivepms'] != 0 && $mybb->settings['enablepms'] != 0) {
                    $pm_recipients[] = $mod['uid'];
                } else {
                    my_mail($mod['email'], $emailsubject, $emailmessage);
                }
            }
            if (count($pm_recipients) > 0) {
                $emailsubject = $lang->sprintf($lang->emailsubject_reportpost, $mybb->settings['bbname']);
                $emailmessage = $lang->sprintf($lang->email_reportpost, $mybb->user['username'], $mybb->settings['bbname'], $post['subject'], $mybb->settings['bburl'], str_replace('&amp;', '&', get_post_link($post['pid'], $thread['tid']) . "#pid" . $post['pid']), $thread['subject'], $input['reason']);
                require_once MYBB_ROOT . "inc/datahandlers/pm.php";
                $pmhandler = new PMDataHandler();
                $pm = array("subject" => $emailsubject, "message" => $emailmessage, "icon" => 0, "fromid" => $mybb->user['uid'], "toid" => $pm_recipients);
                $pmhandler->admin_override = true;
                $pmhandler->set_data($pm);
                // Now let the pm handler do all the hard work.
                if (!$pmhandler->validate_pm()) {
                    // Force it to valid to just get it out of here
                    $pmhandler->is_validated = true;
                    $pmhandler->errors = array();
                }
                $pminfo = $pmhandler->insert_pm();
            }
        } else {
            $reportedpost = array("pid" => $input['post_id'], "tid" => $thread['tid'], "fid" => $thread['fid'], "uid" => $mybb->user['uid'], "dateline" => TIME_NOW, "reportstatus" => 0, "reason" => $db->escape_string(htmlspecialchars_uni($input['reason'])));
            $db->insert_query("reportedposts", $reportedpost);
            $cache->update_reportedposts();
        }
    } else {
        require_once MYBB_ROOT . 'inc/functions_modcp.php';
        $plugins->run_hooks("report_do_report_start");
        $id = $post['pid'];
        $id2 = $post['tid'];
        $id3 = $forum['fid'];
        $report_type = 'post';
        $report_type_db = "(type = 'post' OR type = '')";
        if (!empty($report_type_db)) {
            $query = $db->simple_select("reportedcontent", "*", "reportstatus != '1' AND id = '{$id}' AND {$report_type_db}");
            if ($db->num_rows($query)) {
                // Existing report
                $report = $db->fetch_array($query);
                $report['reporters'] = my_unserialize($report['reporters']);
                if ($mybb->user['uid'] == $report['uid'] || is_array($report['reporters']) && in_array($mybb->user['uid'], $report['reporters'])) {
                    $error = $lang->success_report_voted;
                }
            }
        }
        // Is this an existing report or a new offender?
        if (!empty($report)) {
            // Existing report, add vote
            $report['reporters'][] = $mybb->user['uid'];
            update_report($report);
            //$plugins->run_hooks("report_do_report_end");
        } else {
            // Bad user!
            $new_report = array('id' => $id, 'id2' => $id2, 'id3' => $id3, 'uid' => $mybb->user['uid']);
            // Figure out the reason
            $reason = trim($input['reason']);
            if ($reason == 'other') {
                // Replace the reason with the user comment
                $reason = trim($mybb->get_input('comment'));
            } else {
                $report_reason_string = "report_reason_{$reason}";
                //$reason = "\n".$lang->$report_reason_string;
            }
            if (my_strlen($reason) < 3) {
                $error = $lang->error_report_length;
            }
            if (empty($error)) {
                $new_report['reason'] = $reason;
                add_report($new_report, $report_type);
            } else {
                error($error);
            }
        }
    }
    return xmlresptrue();
}
コード例 #12
0
ファイル: reply_post.php プロジェクト: dthiago/tapatalk-mybb
function reply_post_func($xmlrpc_params)
{
    global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups, $tid, $pid, $visible, $thread, $post;
    $input = Tapatalk_Input::filterXmlInput(array('forum_id' => Tapatalk_Input::INT, 'topic_id' => Tapatalk_Input::INT, 'subject' => Tapatalk_Input::STRING, 'text_body' => Tapatalk_Input::STRING, 'attachment_id_array' => Tapatalk_Input::RAW, 'group_id' => Tapatalk_Input::STRING, 'return_html' => Tapatalk_Input::INT), $xmlrpc_params);
    $lang->load("newreply");
    $parser = new Tapatalk_Parser();
    $tid = $input['topic_id'];
    $options = array("limit" => 1);
    $query = $db->simple_select("threads", "*", "tid='" . $tid . "'");
    if ($db->num_rows($query) == 0) {
        return xmlrespfalse($lang->error_invalidthread);
    }
    $thread = $db->fetch_array($query);
    $fid = $thread['fid'];
    // Get forum info
    $forum = get_forum($fid);
    if (!$forum) {
        return xmlrespfalse($lang->error_invalidforum);
    }
    $forumpermissions = forum_permissions($fid);
    if ($thread['visible'] == 0 && !is_moderator($fid) || $thread['visible'] < 0) {
        return xmlrespfalse($lang->error_invalidthread);
    }
    if ($forum['open'] == 0 || $forum['type'] != "f") {
        return xmlrespfalse($lang->error_closedinvalidforum);
    }
    if ($mybb->user['uid'] < 1 || $forumpermissions['canview'] == 0 || $forumpermissions['canpostreplys'] == 0 || $mybb->user['suspendposting'] == 1) {
        return tt_no_permission();
    }
    if ($forumpermissions['canonlyviewthreads'] == 1 && $thread['uid'] != $mybb->user['uid']) {
        return tt_no_permission();
    }
    tt_check_forum_password($forum['fid']);
    // Check to see if the thread is closed, and if the user is a mod.
    if (!is_moderator($fid, "caneditposts")) {
        if ($thread['closed'] == 1) {
            return xmlrespfalse($lang->redirect_threadclosed);
        }
    }
    // Is the currently logged in user a moderator of this forum?
    if (is_moderator($fid)) {
        $ismod = true;
    } else {
        $ismod = false;
    }
    if (!empty($input['group_id'])) {
        $posthash = $input['group_id'];
    } else {
        $posthash = md5($thread['tid'] . $mybb->user['uid'] . random_str());
    }
    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'];
    $user_check = "p.uid='{$uid}'";
    if (version_compare($mybb->version, '1.8.0', '<')) {
        $query = $db->simple_select("posts p", "p.pid, p.visible", "{$user_check} AND p.tid='{$thread['tid']}' AND p.subject='" . $db->escape_string($mybb->input['subject']) . "' AND p.message='" . $db->escape_string($mybb->input['message']) . "' AND p.posthash='" . $db->escape_string($mybb->input['posthash']) . "' AND p.visible != '-2'");
    } else {
        $query = $db->simple_select("posts p", "p.pid, p.visible", "{$user_check} AND p.tid='{$thread['tid']}' AND p.subject='" . $db->escape_string($mybb->get_input('subject')) . "' AND p.message='" . $db->escape_string($mybb->get_input('message')) . "' AND p.visible != '-2' AND p.dateline>" . (TIME_NOW - 600));
    }
    $duplicate_check = $db->fetch_field($query, "pid");
    if ($duplicate_check) {
        return xmlrespfalse($lang->error_post_already_submitted);
    }
    require_once MYBB_ROOT . "inc/datahandlers/post.php";
    $posthandler = new PostDataHandler("insert");
    $post = array("tid" => $input['topic_id'], "replyto" => 0, "fid" => $thread['fid'], "subject" => $input['subject'], "icon" => 0, "uid" => $uid, "username" => $username, "message" => $input['text_body'], "ipaddress" => get_ip(), "posthash" => $posthash);
    if ($mybb->input['pid']) {
        $post['pid'] = $mybb->input['pid'];
    }
    $post['savedraft'] = 0;
    // Set up the post options from the input.
    $post['options'] = array("signature" => 1, "subscriptionmethod" => $mybb->user['subscriptionmethod'] == 0 ? '' : $mybb->user['subscriptionmethod'], "disablesmilies" => 0);
    $post['modoptions']['stickthread'] = $thread['sticky'];
    $post['modoptions']['closethread'] = $thread['closed'];
    $posthandler->set_data($post);
    // Now let the post handler do all the hard work.
    $valid_post = $posthandler->validate_post();
    $post_errors = array();
    // Fetch friendly error messages if this is an invalid post
    if (!$valid_post) {
        $post_errors = $posthandler->get_friendly_errors();
    }
    // Mark thread as read
    require_once MYBB_ROOT . "inc/functions_indicators.php";
    mark_thread_read($tid, $fid);
    // One or more errors returned, fetch error list and throw to newreply page
    if (count($post_errors) > 0) {
        return xmlrespfalse(implode(" :: ", $post_errors));
    } else {
        $postinfo = $posthandler->insert_post();
        $pid = $postinfo['pid'];
        $visible = $postinfo['visible'];
        tapatalk_push_reply();
        tapatalk_push_quote();
        tapatalk_push_tag();
        // Deciding the fate
        if ($visible == -2) {
            $state = 1;
        } elseif ($visible == 1) {
            $state = 0;
        } else {
            $state = 1;
        }
    }
    $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'] = post_bbcode_clean($post['message']);
    $post['message'] = $parser->parse_message($post['message'], $parser_options);
    global $attachcache;
    $attachcache = array();
    if ($thread['attachmentcount'] > 0) {
        // Now lets fetch all of the attachments for these posts.
        $query = $db->simple_select("attachments", "*", "pid='{$pid}'");
        while ($attachment = $db->fetch_array($query)) {
            $attachcache[$attachment['pid']][$attachment['aid']] = $attachment;
        }
    }
    $attachment_list = process_post_attachments($post['pid'], $post);
    $can_delete = 0;
    if ($mybb->user['uid'] == $post['uid']) {
        if ($forumpermissions['candeletethreads'] == 1 && $postcounter == 1) {
            $can_delete = 1;
        } else {
            if ($forumpermissions['candeleteposts'] == 1 && $postcounter != 1) {
                $can_delete = 1;
            }
        }
    }
    $can_delete = (is_moderator($fid, "candeleteposts") || $can_delete == 1) && $mybb->user['uid'] != 0;
    $result = new xmlrpcval(array('result' => new xmlrpcval(true, 'boolean'), 'result_text' => new xmlrpcval('', 'base64'), 'post_id' => new xmlrpcval($postinfo['pid'], 'string'), 'state' => new xmlrpcval($state, 'int'), 'post_author_id' => new xmlrpcval($mybb->user['uid'], 'string'), 'post_author_name' => new xmlrpcval(basic_clean($mybb->user['username']), 'base64'), 'icon_url' => new xmlrpcval(absolute_url($mybb->user['avatar']), 'string'), 'post_content' => new xmlrpcval(process_post($post['message'], $input['return_html']), 'base64'), 'can_edit' => new xmlrpcval(is_moderator($fid, "caneditposts") || $thread['closed'] == 0 && $forumpermissions['caneditposts'] == 1, 'boolean'), 'can_delete' => new xmlrpcval($can_delete, 'boolean'), 'post_time' => new xmlrpcval(mobiquo_iso8601_encode(TIME_NOW), 'dateTime.iso8601'), 'timestamp' => new xmlrpcval(TIME_NOW, 'string'), 'attachments' => new xmlrpcval($attachment_list, 'array')), 'struct');
    return new xmlrpcresp($result);
}
コード例 #13
0
function get_quote_post_func($xmlrpc_params)
{
    global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups;
    require_once MYBB_ROOT . $mybb->settings['tapatalk_directory'] . '/emoji/emoji.class.php';
    $input = Tapatalk_Input::filterXmlInput(array('post_id' => Tapatalk_Input::STRING), $xmlrpc_params);
    $lang->load("newreply");
    $parser = new postParser();
    $pids = explode('-', $input['post_id']);
    $message = '';
    foreach ($pids as $pid) {
        $query = $db->simple_select("posts", "tid", "pid = '{$pid}'");
        if ($db->num_rows($query) == 0) {
            return xmlrespfalse("Invalid post");
        }
        $post = $db->fetch_array($query);
        $tid = $post['tid'];
        $options = array("limit" => 1);
        $query = $db->simple_select("threads", "*", "tid='" . $tid . "'");
        if ($db->num_rows($query) == 0) {
            return xmlrespfalse($lang->error_invalidthread);
        }
        $thread = $db->fetch_array($query);
        $fid = $thread['fid'];
        // Get forum info
        $forum = get_forum($fid);
        if (!$forum) {
            return xmlrespfalse($lang->error_invalidforum);
        }
        $forumpermissions = forum_permissions($fid);
        if ($thread['visible'] == 0 && !is_moderator($fid) || $thread['visible'] < 0) {
            return xmlrespfalse($lang->error_invalidthread);
        }
        if ($forum['open'] == 0 || $forum['type'] != "f") {
            return xmlrespfalse($lang->error_closedinvalidforum);
        }
        if ($mybb->user['uid'] < 1 || $forumpermissions['canview'] == 0 || $forumpermissions['canpostreplys'] == 0 || $mybb->user['suspendposting'] == 1) {
            return tt_no_permission();
        }
        if ($forumpermissions['canonlyviewthreads'] == 1 && $thread['uid'] != $mybb->user['uid']) {
            return tt_no_permission();
        }
        tt_check_forum_password($forum['fid']);
        // Check to see if the thread is closed, and if the user is a mod.
        if (!is_moderator($fid, "caneditposts")) {
            if ($thread['closed'] == 1) {
                return xmlrespfalse($lang->redirect_threadclosed);
            }
        }
        // Is the currently logged in user a moderator of this forum?
        if (is_moderator($fid)) {
            $ismod = true;
        } else {
            $ismod = false;
        }
        $unviewable_forums = get_unviewable_forums();
        if ($unviewable_forums) {
            $unviewable_forums = "AND t.fid NOT IN ({$unviewable_forums})";
        }
        if (is_moderator($fid)) {
            $visible_where = "AND p.visible != 2";
        } else {
            $visible_where = "AND p.visible > 0";
        }
        require_once MYBB_ROOT . "inc/functions_posting.php";
        $query = $db->query("\n\t\t\tSELECT p.subject, p.message, p.pid, p.tid, p.username, p.dateline, u.username AS userusername\n\t\t\tFROM " . TABLE_PREFIX . "posts p\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "threads t ON (t.tid=p.tid)\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid=p.uid)\n\t\t\tWHERE p.pid = {$pid} {$unviewable_forums} {$visible_where}\n\t\t");
        $load_all = intval($mybb->input['load_all_quotes']);
        if ($db->num_rows($query) == 0) {
            return xmlrespfalse("Invalid post");
        }
        $quoted_post = $db->fetch_array($query);
        // Only show messages for the current thread
        if ($quoted_post['tid'] == $tid || $load_all == 1) {
            // If this post was the post for which a quote button was clicked, set the subject
            if ($pid == $quoted_post['pid']) {
                $subject = preg_replace('#RE:\\s?#i', '', $quoted_post['subject']);
                $subject = "RE: " . $subject;
            }
            $message .= parse_quoted_message($quoted_post);
            $quoted_ids[] = $quoted_post['pid'];
        } else {
            ++$external_quotes;
        }
        if ($mybb->settings['maxquotedepth'] != '0') {
            $message = remove_message_quotes($message);
        }
    }
    $result = new xmlrpcval(array('post_id' => new xmlrpcval($pid), 'post_title' => new xmlrpcval($subject, 'base64'), 'post_content' => new xmlrpcval(tapatalkEmoji::covertNameToEmoji($message), 'base64')), 'struct');
    return new xmlrpcresp($result);
}