function outputRPCPosts()
{
    global $context;
    $response = '
<params>
<param>
<value>
<struct>
<member>
<name>total_post_num</name>
<value><int>' . intval($context['numReplies'] + 1) . '</int></value>
</member>
<member>
<name>forum_id</name>
<value><string>' . $context['board_id'] . '</string></value>
</member>
<member>
<name>forum_name</name>
<value><base64>' . base64_encode(mobi_unescape_html($context['board_name'])) . '</base64></value>
</member>
<member>
<name>topic_id</name>
<value><string>' . $context['topic_id'] . '</string></value>
</member>
<member>
<name>topic_title</name>
<value><base64>' . base64_encode(mobi_unescape_html($context['subject'])) . '</base64></value>
</member>
<member>
<name>is_subscribed</name>
<value><boolean>' . (empty($context['is_marked_notify']) ? 0 : 1) . '</boolean></value>
</member>
<member>
<name>can_subscribe</name>
<value><boolean>' . (empty($context['can_mark_notify']) ? 0 : 1) . '</boolean></value>
</member>
<member>
<name>is_closed</name>
<value><boolean>' . (empty($context['locked']) ? 0 : 1) . '</boolean></value>
</member>
<member>
<name>can_reply</name>
<value><boolean>' . (empty($context['can_reply']) ? 0 : 1) . '</boolean></value>
</member>
<member>
<name>position</name>
<value><int>' . intval($context['new_position']) . '</int></value>
</member>
<member>
<name>posts</name>
<value>
<array><data>';
    // Get the posts
    foreach ($context['posts'] as $post) {
        $response .= '
<value><struct>
<member>
<name>topic_id</name>
<value><string>' . $post['topic'] . '</string></value>
</member>
<member>
<name>post_id</name>
<value><string>' . $post['id'] . '</string></value>
</member>
<member>
<name>post_title</name>
<value><base64>' . base64_encode(mobi_unescape_html($post['subject'])) . '</base64></value>
</member>
<member>
<name>post_content</name>
<value><base64>' . base64_encode(mobi_unescape_body_html($post['body'])) . '</base64></value>
</member>
<member>
<name>post_author_name</name>
<value><base64>' . base64_encode(processUsername($post['poster']['username'])) . '</base64></value>
</member>
<member>
<name>post_author_display_name</name>
<value><base64>' . base64_encode(processUsername($post['poster']['name'])) . '</base64></value>
</member>
<member>
<name>can_edit</name>
<value><boolean>' . (!empty($post['can_edit']) ? 1 : 0) . '</boolean></value>
</member>
<member>
<name>allow_smilies</name>
<value><boolean>' . ($post['allow_smilies'] ? 1 : 0) . '</boolean></value>
</member>
<member>
<name>is_online</name>
<value><boolean>' . (!empty($post['poster']['is_online']) ? 1 : 0) . '</boolean></value>
</member>
<member>
<name>icon_url</name>
<value><string>' . process_url($post['poster']['avatar']) . '</string></value>
</member>
<member>
<name>post_time</name>
<value><dateTime.iso8601>' . $post['time'] . '</dateTime.iso8601></value>
</member>
<member>
<name>attachments</name>
<value>
<array><data>';
        foreach ($post['attachments'] as $attachment) {
            $response .= '
<value><struct>
<member>
<name>content_type</name>
<value><string>' . ($attachment['is_image'] ? 'image' : 'others') . '</string></value>
</member>
<member>
<name>url</name>
<value><string>' . process_url($attachment['href']) . '</string></value>
</member>
<member>
<name>thumbnail_url</name>
<value><string>' . process_url($attachment['thumbnail']) . '</string></value>
</member>
</struct></value>';
        }
        $response .= '
</data></array>
</value>
</member>
</struct></value>';
    }
    $response .= '
</data></array>
</value>
</member>
</struct>
</value>
</param>
</params>';
    outputRPCResponse($response);
}
Exemple #2
0
function processBody($body)
{
    global $modSettings, $mobsettings;
    $body = str_replace(array('[IMG', '[/IMG]', '[URL', '[/URL]', '[IURL', '[/IURL]', '[iurl', '[/iurl]'), array('[img', '[/img]', '[url', '[/url]', '[url', '[/url]', '[url', '[/url]'), $body);
    $body = preg_replace('/\\[img.*?\\]/', '[tpt-img]', $body);
    $body = str_replace('[url', '[tpt-url', $body);
    // convert youtube bbcode
    $body = preg_replace('/\\[(youtube|yt)\\](.*?)\\[\\/\\1\\]/ie', "'[url]'.youtube_url_check('\$2').'[/url]'", $body);
    $body = preg_replace('/\\[b\\](.*?)\\[\\/b\\]/', '[tpt-b]$1[/tpt-b]', $body);
    $body = preg_replace('/\\[u\\](.*?)\\[\\/u\\]/', '[tpt-u]$1[/tpt-u]', $body);
    $body = preg_replace('/\\[i\\](.*?)\\[\\/i\\]/', '[tpt-i]$1[/tpt-i]', $body);
    $body = preg_replace('#\\[color=(\\#[\\da-fA-F]{3}|\\#[\\da-fA-F]{6}|[A-Za-z]{1,20}|rgb\\(\\d{1,3}, ?\\d{1,3}, ?\\d{1,3}\\))\\](.*?)\\[/color\\]#si', '[tpt-color=$1]$2[/tpt-color]', $body);
    $body = strip_tags(parse_bbc($body, false, '', getUnsafeTags()), '<br><br />');
    $body = strip_tags($body, '<br><br />');
    $body = str_replace('<br />', "\n", $body);
    $body = str_replace('[tpt-img]', '[img]', $body);
    $body = str_replace('[tpt-url', '[url', $body);
    $body = preg_replace('/\\[quote.*?\\]/is', '[quote]', $body);
    $blocks = preg_split('/(\\[\\/?quote\\])/i', $body, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
    $quote_level = 0;
    $body = '';
    foreach ($blocks as $block) {
        if ($block == '[quote]') {
            if ($quote_level == 0) {
                $body .= $block;
            }
            $quote_level++;
        } else {
            if ($block == '[/quote]') {
                if ($quote_level <= 1) {
                    $body .= $block;
                }
                if ($quote_level >= 1) {
                    $quote_level--;
                }
            } else {
                if ($quote_level <= 1) {
                    $body .= ltrim($block);
                }
            }
        }
    }
    return mobi_unescape_body_html($body);
}