예제 #1
0
$cantView = 0;
$topicTemplate->set_block('topictemplate', 'topicrow', 'trow');
while ($topicRec = DB_fetchArray($result)) {
    if ($FF_userprefs['viewanonposts'] == 0 and $topicRec['uid'] == 1) {
        $display .= '<div class="pluginAlert" style="padding:10px;margin:10px;">Your preferences have block anonymous posts enabled</div>';
        break;
    } else {
        if (!_ff_canUserViewRating($forum)) {
            if ($cantView == 0) {
                $display .= '<div class="pluginAlert" style="padding:10px;margin:10px;">' . $LANG_GF02['rate_too_low_thread'] . '</div>';
            }
            $cantView++;
        } else {
            $topicRec['is_readonly'] = $viewtopic['is_readonly'];
            $topicRec['locked'] = $viewtopic['locked'];
            FF_showtopic($topicRec, $mode, $onetwo, $page, $topicTemplate);
            $topicTemplate->parse('trow', 'topicrow', true);
            $onetwo = $onetwo == 1 ? 2 : 1;
        }
    }
}
if (!$iframe) {
    DB_query("UPDATE {$_TABLES['ff_topic']} SET views=views+1 WHERE id=" . (int) $showtopic);
    //@TODO look at optimizing this better
    if (!COM_isAnonUser()) {
        $showtopicpid = $showtopic;
        $forumid = $viewtopic['forum'];
        $lrows = DB_count($_TABLES['ff_log'], array('uid', 'topic'), array((int) $_USER['uid'], (int) $showtopic));
        $logtime = time();
        if ($lrows < 1) {
            DB_query("INSERT INTO {$_TABLES['ff_log']} (uid,forum,topic,time) VALUES (" . (int) $_USER['uid'] . "," . (int) $forumid . "," . (int) $showtopicpid . "," . $logtime . ")");
예제 #2
0
function FF_previewPost($postData, $mode)
{
    global $_CONF, $_TABLES, $_FF_CONF, $_USER;
    $retval = '';
    $postData['name'] = @htmlspecialchars(strip_tags(COM_checkWords(trim(USER_sanitizeName(urldecode($_POST['name']))))), ENT_QUOTES, COM_getEncodingt());
    if (!isset($postData['uid'])) {
        if (COM_isAnonUser()) {
            $postData['uid'] = 1;
        } else {
            $postData['uid'] = $_USER['uid'];
        }
    }
    $status = 0;
    if (isset($postData['disable_bbcode']) && $postData['disable_bbcode'] == 1) {
        $disable_bbcode_val = ' checked="checked"';
        $status += DISABLE_BBCODE;
    } else {
        $disable_bbcode_val = '';
    }
    if (isset($postData['disable_smilies']) && $postData['disable_smilies'] == 1) {
        $disable_smilies_val = ' checked="checked"';
        $status += DISABLE_SMILIES;
    } else {
        $disable_smilies_val = '';
    }
    if (isset($postData['disable_urlparse']) && $postData['disable_urlparse'] == 1) {
        $disable_urlparse_val = ' checked="checked"';
        $status += DISABLE_URLPARSE;
    } else {
        $disable_urlparse_val = '';
    }
    $postData['status'] = $status;
    $postData['date'] = time();
    if (isset($postData['modedit']) && $postData['modedit'] == 1) {
        if (isset($postData['locked_switch']) && $postData['locked_switch'] == 1) {
            $postData['locked'] = 1;
        }
        if (isset($postData['sticky_switch']) && $postData['sticky_switch'] == 1) {
            $postData['sticky'] = 1;
        }
    } else {
        $postData['locked'] = 0;
        $postData['sticky'] = 0;
    }
    if (!isset($postData['pid'])) {
        $postData['pid'] = 0;
    }
    if (!isset($postData['views'])) {
        $postData['views'] = 0;
    }
    /* Check for any uploaded files */
    $UploadErrors = '';
    if ($mode == 'edittopic') {
        /* Check for any uploaded files */
        if (isset($postData['id']) && $postData['id'] > 0) {
            $UploadErrors = _ff_check4files($postData['id']);
            $postData['numAttachments'] = DB_count($_TABLES['ff_attachments'], 'topic_id', (int) $postData['id']);
        }
    } else {
        /* Check for any uploaded files */
        if (isset($postData['uniqueid']) && $postData['uniqueid'] > 0) {
            $UploadErrors = _ff_check4files($postData['uniqueid'], true);
            $postData['numAttachments'] = DB_count($_TABLES['ff_attachments'], array('topic_id', 'tempfile'), array((int) $postData['uniqueid'], 1));
        }
    }
    $previewTemplate = new Template($_CONF['path'] . 'plugins/forum/templates/');
    $previewTemplate->set_file('preview', 'topic_preview.thtml');
    if ($UploadErrors) {
        $previewTemplate->set_var('error_msg', $UploadErrors);
    }
    if (!isset($postData['date'])) {
        $postData['date'] = time();
    }
    $filter = sanitizer::getInstance();
    $AllowedElements = $filter->makeAllowedElements($_FF_CONF['allowed_html']);
    $filter->setAllowedelements($AllowedElements);
    $filter->setNamespace('forum', 'post');
    $filter->setPostmode($postData['postmode']);
    $postData['comment'] = $filter->filterHTML($postData['comment']);
    FF_showtopic($postData, 'preview', 1, 0, $previewTemplate);
    $previewTemplate->parse('output', 'preview');
    $retval .= $previewTemplate->finish($previewTemplate->get_var('output'));
    return $retval;
}