コード例 #1
0
ファイル: topic.inc.php プロジェクト: spacequad/glfusion
function FF_showtopic($showtopic, $mode = '', $onetwo = 1, $page = 1, $topictemplate)
{
    global $_FF_CONF, $_CONF, $_TABLES, $_USER, $LANG_GF01, $LANG_GF02, $_SYSTEM;
    global $highlight;
    global $forumfiles;
    global $canPost;
    $retval = '';
    if (isset($showtopic['date'])) {
        $dt = new Date($showtopic['date'], $_USER['tzid']);
    } else {
        $dt = new Date('now', $_USER['tzid']);
    }
    static $cacheUserArray = array();
    static $_user_already_voted = array();
    $oldPost = 0;
    if (!class_exists('StringParser')) {
        require_once $_CONF['path'] . 'lib/bbcode/stringparser_bbcode.class.php';
    }
    if ($mode == 'preview') {
        $topictemplate->set_var(array('lang_postpreview' => $LANG_GF01['PREVIEW_HEADER'], 'preview' => true));
    }
    $min_height = 50;
    // Base minimum  height of topic - will increase if avatar or sig is used
    $foundUser = 0;
    if ($showtopic['uid'] > 1) {
        if (isset($cacheUserArray[$showtopic['uid']])) {
            $userarray = $cacheUserArray[$showtopic['uid']];
            $username = $userarray['display_name'];
            $location = $userarray['location'];
            $posts = $userarray['posts'];
            $user_level = $userarray['user_level'];
            $user_levelname = $userarray['user_levelname'];
            $avatar = $userarray['avatar'];
            $onlinestatus = $userarray['onlinestatus'];
            $min_height = $userarray['min_height'];
            $regdate = $userarray['regdate'];
            $numposts = $userarray['numposts'];
            $foundUser = 1;
        } else {
            $sql = "SELECT users.*,userprefs.*,userinfo.*,gf_userinfo.rating,gf_userinfo.signature FROM {$_TABLES['users']} users LEFT JOIN {$_TABLES['userprefs']} userprefs ON users.uid=userprefs.uid LEFT JOIN {$_TABLES['userinfo']} userinfo ON users.uid=userinfo.uid LEFT JOIN {$_TABLES['ff_userinfo']} gf_userinfo ON users.uid=gf_userinfo.uid WHERE users.uid=" . (int) $showtopic['uid'];
            $userQuery = DB_query($sql);
            if (DB_numRows($userQuery) == 1) {
                $userarray = DB_fetchArray($userQuery);
                $username = COM_getDisplayName($showtopic['uid']);
                $userarray['display_name'] = $username;
                $postcount = DB_query("SELECT * FROM {$_TABLES['ff_topic']} WHERE uid='" . (int) $showtopic['uid'] . "'");
                $posts = DB_numRows($postcount);
                $userarray['posts'] = $posts;
                $starimage = '<img src="%s" alt="' . $LANG_GF01['FORUM'] . ' %s" title="' . $LANG_GF01['FORUM'] . ' %s"/>';
                if ($posts < $_FF_CONF['level2']) {
                    $user_level = sprintf($starimage, _ff_getImage('rank1', 'ranks'), $_FF_CONF['level1name'], $_FF_CONF['level1name']);
                    $user_levelname = $_FF_CONF['level1name'];
                } elseif ($posts >= $_FF_CONF['level2'] && $posts < $_FF_CONF['level3']) {
                    $user_level = sprintf($starimage, _ff_getImage('rank2', 'ranks'), $_FF_CONF['level2name'], $_FF_CONF['level2name']);
                    $user_levelname = $_FF_CONF['level2name'];
                } elseif ($posts >= $_FF_CONF['level3'] && $posts < $_FF_CONF['level4']) {
                    $user_level = sprintf($starimage, _ff_getImage('rank3', 'ranks'), $_FF_CONF['level3name'], $_FF_CONF['level3name']);
                    $user_levelname = $_FF_CONF['level3name'];
                } elseif ($posts >= $_FF_CONF['level4'] && $posts < $_FF_CONF['level5']) {
                    $user_level = sprintf($starimage, _ff_getImage('rank4', 'ranks'), $_FF_CONF['level4name'], $_FF_CONF['level4name']);
                    $user_levelname = $_FF_CONF['level4name'];
                } elseif ($posts > $_FF_CONF['level5']) {
                    $user_level = sprintf($starimage, _ff_getImage('rank5', 'ranks'), $_FF_CONF['level5name'], $_FF_CONF['level5name']);
                    $user_levelname = $_FF_CONF['level5name'];
                }
                if (forum_modPermission($showtopic['forum'], $showtopic['uid'])) {
                    $user_level = sprintf($starimage, _ff_getImage('rank_mod', 'ranks'), $LANG_GF01['moderator'], $LANG_GF01['moderator']);
                    $user_levelname = $LANG_GF01['moderator'];
                }
                if (SEC_inGroup(1, $showtopic['uid'])) {
                    $user_level = sprintf($starimage, _ff_getImage('rank_admin', 'ranks'), $LANG_GF01['admin'], $LANG_GF01['admin']);
                    $user_levelname = $LANG_GF01['admin'];
                }
                $userarray['user_level'] = $user_level;
                $userarray['user_levelname'] = $user_levelname;
                if ($userarray['photo'] != "") {
                    $avatar = '<img src="' . USER_getPhoto($showtopic['uid'], '', '', '', '0') . '" alt="" title="" class="forum-userphoto" style="width:' . $_FF_CONF['avatar_width'] . 'px;"/>';
                    $min_height = $min_height + 150;
                } else {
                    if (!isset($_CONF['default_photo']) || $_CONF['default_photo'] == '') {
                        $img = $_CONF['site_url'] . '/images/userphotos/default.jpg';
                    } else {
                        $img = $_CONF['default_photo'];
                    }
                    $avatar = '<img src="' . $img . '" alt="" title="" class="forum-userphoto" style="width:' . $_FF_CONF['avatar_width'] . 'px;"/>';
                    $min_height = $min_height + 150;
                }
                if ($_FF_CONF['enable_user_rating_system']) {
                    if ($showtopic['uid'] > 1) {
                        $min_height = $min_height + 10;
                    }
                }
                if (SEC_inGroup('Root') && function_exists('plugin_cclabel_nettools') && isset($showtopic['ip'])) {
                    $min_height = $min_height + 5;
                }
                $udt = new Date(strtotime($userarray['regdate']), $_USER['tzid']);
                $regdate = $udt->format($_CONF['shortdate'], true) . '<br/>';
                $numposts = $posts;
                if (DB_count($_TABLES['sessions'], 'uid', (int) $showtopic['uid']) > 0 and DB_getItem($_TABLES['userprefs'], 'showonline', "uid=" . (int) $showtopic['uid'] . "") == 1) {
                    $onlinestatus = $LANG_GF01['ONLINE'];
                } else {
                    $onlinestatus = $LANG_GF01['OFFLINE'];
                }
                $userarray['avatar'] = $avatar;
                $userarray['onlinestatus'] = $onlinestatus;
                $userarray['min_height'] = $min_height;
                $userarray['regdate'] = $regdate;
                $userarray['numposts'] = $numposts;
                $location = $userarray['location'];
                $cacheUserArray[$showtopic['uid']] = $userarray;
                $foundUser = 1;
            }
        }
    } else {
        if (!isset($_CONF['default_photo']) || $_CONF['default_photo'] == '') {
            $img = $_CONF['site_url'] . '/images/userphotos/default.jpg';
        } else {
            $img = $_CONF['default_photo'];
        }
        $avatar = '<img src="' . $img . '" alt="" title="" class="forum-userphoto" style="width:' . $_FF_CONF['avatar_width'] . 'px;"/>';
        $min_height = $min_height + 150;
    }
    if ($foundUser) {
        $userlink = '<a href="' . $_CONF['site_url'] . '/users.php?mode=profile&amp;uid=' . $showtopic['uid'] . '" ';
        $userlink .= 'class="authorname ' . $onetwo . '" rel="nofollow"><strong>' . $username . '</strong></a>';
        $uservalid = true;
        if ($userarray['sig'] != '' || $userarray['signature'] != '') {
            $sig = '';
            $sig .= FF_getSignature($userarray['sig'], $userarray['signature'], 'html');
            $min_height = $min_height + 30;
        }
    } else {
        $uservalid = false;
        $userlink = $LANG_GF01['ANON'] . $showtopic['name'];
    }
    if ($_FF_CONF['show_moods'] && $showtopic['mood'] != "") {
        $moodimage = '<img style="vertical-align:middle;" src="' . _ff_getImage($showtopic['mood'], 'moods') . '" title="' . $showtopic['mood'] . '" alt=""/><br/>';
        $min_height = $min_height + 30;
    }
    $showtopic['comment'] = FF_formatTextBlock($showtopic['comment'], $showtopic['postmode'], $mode, $showtopic['status']);
    $showtopic['subject'] = @htmlspecialchars(strip_tags($showtopic['subject']), ENT_QUOTES, COM_getEncodingt());
    $showtopic['subject'] = COM_truncate($showtopic['subject'], $_FF_CONF['show_subject_length'], '...');
    if ($mode != 'preview' && $uservalid && !COM_isAnonUser() && (isset($_USER['uid']) && $_USER['uid'] == $showtopic['uid'])) {
        /* Check if user can still edit this post - within allowed edit timeframe */
        $editAllowed = false;
        if ($_FF_CONF['allowed_editwindow'] > 0) {
            $t1 = $showtopic['date'];
            $t2 = $_FF_CONF['allowed_editwindow'];
            if (time() - $t2 < $t1) {
                $editAllowed = true;
            }
        } else {
            $editAllowed = true;
        }
        if ($editAllowed) {
            $editlink = $_CONF['site_url'] . '/forum/createtopic.php?mode=edittopic&amp;forum=' . $showtopic['forum'] . '&amp;id=' . $showtopic['id'] . '&amp;editid=' . $showtopic['id'] . '&amp;page=' . $page;
            $editlinkimg = '<img src="' . _ff_getImage('edit_button') . '" style="vertical-align:middle;" alt="' . $LANG_GF01['EDITICON'] . '" title="' . $LANG_GF01['EDITICON'] . '"/>';
            $topictemplate->set_var(array('editlink' => $editlink, 'editlinkimg' => $editlinkimg, 'LANG_edit' => $LANG_GF01['EDITICON']));
        }
    } else {
        $topictemplate->set_var(array('editlink' => '', 'editlinkimg' => '', 'LANG_edit' => ''));
    }
    if ($highlight != '') {
        $showtopic['subject'] = str_replace("{$highlight}", "<span class=\"b\">{$highlight}</span>", $showtopic['subject']);
        $showtopic['comment'] = str_replace("{$highlight}", "<span class=\"b\">{$highlight}</span>", $showtopic['comment']);
    }
    if ($showtopic['pid'] == 0) {
        $replytopicid = $showtopic['id'];
        $is_lockedtopic = $showtopic['locked'];
        $views = $showtopic['views'];
        $topictemplate->set_var('read_msg', sprintf($LANG_GF02['msg49'], $views));
        if ($is_lockedtopic) {
            $topictemplate->set_var('locked_icon', '<img src="' . _ff_getImage('padlock') . '" title="' . $LANG_GF02['msg114'] . '" alt=""/>');
        }
    } else {
        $is_lockedtopic = $showtopic['locked'];
        $replytopicid = $showtopic['pid'];
        $topictemplate->set_var('read_msg', '');
    }
    if ($_FF_CONF['allow_user_dateformat']) {
        $date = $dt->format($dt->getUserFormat(), true);
    } else {
        $date = $dt->format($_FF_CONF['default_Topic_Datetime_format'], true);
    }
    $topictemplate->set_var('posted_date', $date);
    if ($mode != 'preview') {
        if (!COM_isAnonUser()) {
            $bmArray = _ff_cacheBookMarks($_USER['uid']);
            if (isset($bmArray[$showtopic['id']])) {
                $topictemplate->set_var('bookmark_icon', '<img src="' . _ff_getImage('star_on_sm') . '" title="' . $LANG_GF02['msg204'] . '" alt=""/>');
                $topictemplate->set_var('bookmarked', true);
            } else {
                $topictemplate->set_var('bookmark_icon', '<img src="' . _ff_getImage('star_off_sm') . '" title="' . $LANG_GF02['msg203'] . '" alt=""/>');
                $topictemplate->unset_var('bookmarked');
            }
        }
        $topictemplate->clear_var(array('quotelink', 'quotelinkimg', 'LANG_quote'));
        if ($is_lockedtopic == 0) {
            $is_readonly = $showtopic['is_readonly'];
            if ($is_readonly == 0 || forum_modPermission($showtopic['forum'], COM_isAnonUser() ? 1 : $_USER['uid'], 'mod_edit')) {
                if ($canPost != 0) {
                    $quotelink = $_CONF['site_url'] . '/forum/createtopic.php?mode=newreply&amp;forum=' . $showtopic['forum'] . '&amp;id=' . $replytopicid . '&amp;quoteid=' . $showtopic['id'];
                    $quotelinkimg = '<img src="' . _ff_getImage('quote_button') . '" style="vertical-align:middle;" alt="' . $LANG_GF01['QUOTEICON'] . '" title="' . $LANG_GF01['QUOTEICON'] . '"/>';
                    $topictemplate->set_var(array('quotelink' => $quotelink, 'quotelinkimg' => $quotelinkimg, 'LANG_quote' => $LANG_GF01['QUOTEICON']));
                }
            }
        }
        $topictemplate->set_var(array('topic_post_link_begin' => '<a name="' . $showtopic['id'] . '">', 'topic_post_link_end' => '</a>'));
        $mod_functions = _ff_getmodFunctions($showtopic);
        $topictemplate->clear_var(array('profilelink', 'profilelinkimg', 'LANG_profile'));
        $topictemplate->clear_var(array('pmlink', 'pmlinkimg', 'LANG_pm'));
        if ($showtopic['uid'] > 1 && $uservalid) {
            $profile_link = $_CONF['site_url'] . '/users.php?mode=profile&amp;uid=' . $showtopic['uid'];
            $profile_linkimg = '<img src="' . _ff_getImage('profile_button') . '" style="border:none;vertical-align:middle;" alt="' . $LANG_GF01['ProfileLink'] . '" title="' . $LANG_GF01['ProfileLink'] . '"/>';
            $topictemplate->set_var(array('profilelink' => $profile_link, 'profilelinkimg' => $profile_linkimg, 'LANG_profile' => $LANG_GF01['ProfileLink']));
            if ($_FF_CONF['use_pm_plugin'] && (!COM_isAnonUser() && $_USER['uid'] != $showtopic['uid'])) {
                $pmplugin_link = forumPLG_getPMlink($showtopic['uid']);
                if ($pmplugin_link != '') {
                    $pm_link = $pmplugin_link;
                    $pm_linkimg = '<img src="' . _ff_getImage('pm_button') . '" style="vertical-align:middle;" alt="' . $LANG_GF01['PMLink'] . '" title="' . $LANG_GF01['PMLink'] . '"/>';
                    $topictemplate->set_var(array('pmlink' => $pm_link, 'pmlinkimg' => $pm_linkimg, 'LANG_pm' => $LANG_GF01['PMLink']));
                }
            }
        }
        $topictemplate->clear_var(array('emaillink', 'emaillinkimg', 'LANG_email'));
        if (isset($userarray['email']) && $userarray['email'] != '' && $showtopic["uid"] > 1 && $userarray['emailfromuser'] == 1) {
            $email_link = $_CONF['site_url'] . '/profiles.php?uid=' . $showtopic['uid'];
            $email_linkimg = '<img src="' . _ff_getImage('email_button') . '" style="vertical-align:middle;" alt="' . $LANG_GF01['EmailLink'] . '" title="' . $LANG_GF01['EmailLink'] . '"/>';
            $topictemplate->set_var(array('emaillink' => $email_link, 'emaillinkimg' => $email_linkimg, 'LANG_email' => $LANG_GF01['EmailLink']));
        }
        $topictemplate->clear_var(array('websitelink', 'websitelinkimg', 'LANG_website'));
        if (isset($userarray['homepage']) && $userarray['homepage'] != '') {
            $homepage = trim($userarray['homepage']);
            if (!preg_match("/http/i", $homepage)) {
                $homepage = 'http://' . $homepage;
            }
            $homepageimg = '<img src="' . _ff_getImage('website_button') . '" style="vertical-align:middle;" alt="' . $LANG_GF01['WebsiteLink'] . '" title="' . $LANG_GF01['WebsiteLink'] . '"/>';
            $topictemplate->set_var(array('websitelink' => $homepage, 'websitelinkimg' => $homepageimg, 'LANG_website' => $LANG_GF01['WebsiteLink']));
        }
        $back2 = $LANG_GF01['back2top'];
        $backlink = '<center><a href="' . $_CONF['site_url'] . '/forum/viewtopic.php?showtopic=' . $replytopicid . '">' . $back2 . '</a></center>';
    } else {
        if (!isset($_GET['onlytopic']) || $_GET['onlytopic'] != 1) {
            $topictemplate->set_var('preview_topic_subject', $showtopic['subject']);
        } else {
            $topictemplate->set_var('preview_topic_subject', '');
        }
        $topictemplate->set_var('read_msg', '');
        $topictemplate->set_var('locked_icon', '');
        // Check and see if there are no [file] bbcode tags in content and reset the show_inline value
        // This is needed in case user had used the file bbcode tag and then removed it
        $imagerecs = '';
        if (is_array($forumfiles)) {
            $imagerecs = implode(',', $forumfiles);
        }
        if (!empty($_POST['uniqueid'])) {
            $uniqueid = COM_applyFilter($_POST['uniqueid'], true);
            $sql = "UPDATE {$_TABLES['ff_attachments']} SET show_inline = 0 WHERE topic_id=" . (int) $uniqueid . " ";
            if ($imagerecs != '') {
                $sql .= "AND id NOT IN ({$imagerecs})";
            }
            DB_query($sql);
        } else {
            if (isset($_POST['id'])) {
                $tid = COM_applyFilter($_POST['id'], true);
                $sql = "UPDATE {$_TABLES['ff_attachments']} SET show_inline = 0 WHERE topic_id=" . (int) $tid . " ";
                if ($imagerecs != '') {
                    $sql .= "AND id NOT IN ({$imagerecs})";
                }
                DB_query($sql);
            }
        }
    }
    $uniqueid = isset($_POST['uniqueid']) ? COM_applyFilter($_POST['uniqueid'], true) : 0;
    if ($showtopic['id'] > 0 && (!isset($_POST['action']) || $_POST['action'] != 'newreply')) {
        $topictemplate->set_var('attachments', _ff_showattachments((int) $showtopic['id']));
    } elseif ($uniqueid > 0) {
        $topictemplate->set_var('attachments', _ff_showattachments((int) $uniqueid));
    }
    if (SEC_inGroup('Root') && function_exists('plugin_cclabel_nettools') && isset($showtopic['ip'])) {
        $iplink = '<a href="' . $_CONF['site_admin_url'] . '/plugins/nettools/whois.php?domain=' . $showtopic['ip'] . '" target="_new">' . $showtopic['ip'] . '</a>';
        $topictemplate->set_var('ipaddress', $iplink);
    } else {
        $topictemplate->set_var('ipaddress', '');
    }
    $voteHTML = '';
    if ($_FF_CONF['enable_user_rating_system']) {
        if ($showtopic['uid'] > 1) {
            //not an anonymous poster
            // grab the poster's current rating...
            $rating = _ff_getUserRating($showtopic['uid']);
            if ($rating > 0) {
                $grade = '+' . $rating;
            } else {
                $grade = $rating;
            }
            //Find out if user has rights to increase / decrease score
            if (!COM_isAnonUser() && $_USER['uid'] != $showtopic['uid']) {
                //Can't vote for yourself & must be logged in
                if (!isset($_user_already_voted[$showtopic['uid']])) {
                    $_user_already_voted[$showtopic['uid']] = DB_getItem($_TABLES['ff_rating_assoc'], 'grade', "user_id = " . (int) $showtopic['uid'] . ' AND voter_id = ' . (int) $_USER['uid']);
                }
                if ($_user_already_voted[$showtopic['uid']] == '') {
                    // user has never voted for this poster
                    $vote_language = $LANG_GF01['grade_user'];
                    $plus_vote = '<a href="#" onclick="ajax_voteuser(' . $_USER['uid'] . ',' . $showtopic['uid'] . ',' . $showtopic['id'] . ',1,1);return false;"><img src="' . $_CONF['site_url'] . '/forum/images/plus.png" alt="plus" /></a>';
                    $minus_vote = '<a href="#" onclick="ajax_voteuser(' . $_USER['uid'] . ',' . $showtopic['uid'] . ',' . $showtopic['id'] . ',-1,1);return false;"><img src="' . $_CONF['site_url'] . '/forum/images/minus.png" alt="minus" /></a>';
                    $min_height = $min_height + 10;
                } else {
                    // user has already voted for this poster
                    $vote_language = $LANG_GF01['retract_grade'];
                    if ($_user_already_voted[$showtopic['uid']] > 0) {
                        // gave a +1 show the minus to retract
                        $plus_vote = '';
                        $minus_vote = '<a href="#" onclick="ajax_voteuser(' . $_USER['uid'] . ',' . $showtopic['uid'] . ',' . $showtopic['id'] . ',-1,0);return false;"><img src="' . $_CONF['site_url'] . '/forum/images/minus.png" alt="minus" /></a>';
                        $min_height = $min_height + 10;
                    } else {
                        // gave a -1 show the plus to retract
                        $minus_vote = '';
                        $plus_vote = '<a href="#" onclick="ajax_voteuser(' . $_USER['uid'] . ',' . $showtopic['uid'] . ',' . $showtopic['id'] . ',1,0);return false;"><img src="' . $_CONF['site_url'] . '/forum/images/plus.png" alt="plus" /></a>';
                        $min_height = $min_height + 10;
                    }
                }
                $voteHTML = '<div class="c' . $showtopic['uid'] . '"><span id="vote' . $showtopic['id'] . '">' . $vote_language . '<br />' . $minus_vote . $plus_vote . '<br />' . $LANG_GF01['grade'] . ': ' . $grade . '</span></div>';
            } else {
                // display 'rating'
                $voteHTML = $LANG_GF01['grade'] . ': ' . $grade;
            }
        }
    }
    $topictemplate->set_var(array('user_name' => isset($username) ? $username : '******', 'vote_html' => $voteHTML, 'csscode' => $onetwo, 'postmode' => $showtopic['postmode'], 'userlink' => $userlink, 'lang_forum' => $LANG_GF01['FORUM'], 'user_levelname' => isset($user_levelname) ? $user_levelname : '', 'user_level' => isset($user_level) ? $user_level : '', 'magical_image' => isset($moodimage) ? $moodimage : '', 'avatar' => isset($avatar) ? $avatar : '', 'onlinestatus' => isset($onlinestatus) ? $onlinestatus : '', 'regdate' => isset($regdate) ? $regdate : '', 'numposts' => isset($numposts) ? $numposts : '', 'location' => isset($location) ? wordwrap(COM_truncate($location, 100), 20, '<br />') : '', 'topic_subject' => $showtopic['subject'], 'LANG_ON2' => $LANG_GF01['ON2'], 'mod_functions' => isset($mod_functions) ? $mod_functions : '', 'topic_comment' => $showtopic['comment'], 'subject' => $showtopic['subject'], 'comment_minheight' => "min-height:{$min_height}px", 'forumid' => $showtopic['forum'], 'topic_id' => $showtopic['id'], 'parent_id' => $replytopicid, 'back_link' => isset($backlink) ? $backlink : '', 'member_badge' => forumPLG_getMemberBadge($showtopic['uid'])));
    if ($replytopicid != 0) {
        $topictemplate->set_var('prefix', $LANG_GF01['RE']);
    } else {
        $topictemplate->set_var('prefix', '');
    }
    if (isset($sig) && trim($sig) != '') {
        $topictemplate->set_var('sig', PLG_replaceTags($sig, 'forum', 'signature'));
    } else {
        $topictemplate->set_var('sig', '');
    }
}
コード例 #2
0
ファイル: createtopic.php プロジェクト: NewRoute/glfusion
function FF_postEditor($postData, $forumData, $action, $viewMode)
{
    global $_CONF, $_TABLES, $_FF_CONF, $FF_userprefs, $_USER, $LANG_GF01, $LANG_GF02, $LANG_GF10, $REMOTE_ADDR;
    $retval = '';
    $editmoderator = false;
    $numAttachments = 0;
    $edit_val = '';
    $sticky_val = '';
    $locked_val = '';
    if (COM_isAnonUser()) {
        $uid = 1;
    } else {
        $uid = $_USER['uid'];
    }
    // initialize defaults
    if ($_FF_CONF['bbcode_disabled']) {
        $disable_bbcode_val = ' checked="checked"';
    } else {
        $disable_bbcode_val = '';
    }
    if ($_FF_CONF['smilies_disabled']) {
        $disable_smilies_val = ' checked="checked"';
    } else {
        $disable_smilies_val = '';
    }
    if ($_FF_CONF['urlparse_disabled']) {
        $disable_urlparse_val = ' checked="checked"';
    } else {
        $disable_urlparse_val = '';
    }
    // check postmode
    if (isset($postData['postmode'])) {
        // this means we are editing or previewing (or both)
        if (isset($postData['postmode_switch'])) {
            // means they selected a switch
            $chkpostmode = _ff_chkpostmode($postData['postmode'], $postData['postmode_switch']);
            if ($chkpostmode != $postData['postmode']) {
                $postData['postmode'] = $chkpostmode;
                $postData['postmode_switch'] = 0;
            }
        }
    } else {
        if ($_FF_CONF['post_htmlmode'] && $_FF_CONF['allow_html']) {
            $postData['postmode'] = 'html';
        } else {
            $postData['postmode'] = 'text';
        }
    }
    // verify postmode is allowed
    if ($postData['postmode'] == 'html' || $postData['postmode'] == 'HTML') {
        if ($_FF_CONF['allow_html'] || SEC_inGroup('Root') || SEC_hasRights('forum.html')) {
            $postData['postmode'] = 'html';
        } else {
            $postData['postmode'] = 'text';
        }
    }
    $postData['postmode_switch'] = 0;
    // action specific setup
    if ($action == 'edittopic' || $viewMode) {
        // need to see what options were checked...
        $status = 0;
        // get our options...
        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 = '';
        }
    }
    // create our template
    $peTemplate = new Template($_CONF['path'] . 'plugins/forum/templates/');
    $peTemplate->set_file('posteditor', 'posteditor.thtml');
    if ($postData['postmode'] == 'html') {
        $peTemplate->set_var('html_mode', true);
    } else {
        $peTemplate->unset_var('html_mode');
    }
    if ($viewMode == PREVIEW_VIEW) {
        $peTemplate->set_var('preview_post', FF_previewPost($postData, $action));
    }
    $uniqueid = isset($postData['uniqueid']) ? COM_applyFilter($postData['uniqueid'], true) : mt_rand();
    $peTemplate->set_var('uniqueid', $uniqueid);
    if (SEC_inGroup($postData['use_attachment_grpid']) && $_FF_CONF['maxattachments'] > 0) {
        $peTemplate->set_var('use_attachments', true);
    }
    if ($action == 'newtopic') {
        $peTemplate->set_var('save_button', 'savetopic');
        $postmessage = $LANG_GF02['PostTopic'];
        $peTemplate->set_var('hidden_action', 'newtopic');
    }
    if ($action == 'edittopic') {
        $peTemplate->set_var('save_button', 'saveedit');
        if (isset($postData['forum']) && forum_modPermission($postData['forum'], $_USER['uid'], 'mod_edit')) {
            $editmoderator = true;
            $peTemplate->set_var('hidden_modedit', '1');
        } else {
            $peTemplate->set_var('hidden_modedit', '0');
            $editmoderator = false;
        }
        $postmessage = $LANG_GF02['EditTopic'];
        $peTemplate->set_var('hidden_action', 'edittopic');
        $peTemplate->set_var('hidden_editpost', 'yes');
        if ($editmoderator) {
            $username = $postData['name'];
        } elseif ($postData['uid'] > 1) {
            $username = COM_getDisplayName($postData['uid']);
        }
        $postData['comment'] = str_ireplace('</textarea>', '&lt;/textarea&gt;', $postData['comment']);
        if (isset($postData['pid'])) {
            $peTemplate->set_var('hidden_editpid', $postData['pid']);
        }
        $peTemplate->set_var('hidden_editid', $postData['id']);
        $edit_prompt = $LANG_GF02['msg190'] . '<br/><input type="checkbox" name="silentedit" ';
        if (isset($postData['silentedit']) && $postData['silentedit'] == 1 or !isset($postData['modedit']) and $_FF_CONF['silent_edit_default']) {
            $edit_prompt .= 'checked="checked" ';
            $edit_val = ' checked="checked" ';
        } else {
            $edit_val = '';
        }
        $edit_prompt .= 'value="1"/>';
        $peTemplate->set_var('attachments', '<div id="fileattachlist">' . _ff_showattachments($postData['id'], 'edit') . '</div>');
        $numAttachments = DB_Count($_TABLES['ff_attachments'], 'topic_id', $postData['id']);
        $allowedAttachments = $_FF_CONF['maxattachments'] - $numAttachments;
        $peTemplate->set_var('fcounter', $allowedAttachments);
    } else {
        $numAttachments = (int) DB_Count($_TABLES['ff_attachments'], 'topic_id', $uniqueid);
        $allowedAttachments = $_FF_CONF['maxattachments'] - $numAttachments;
        $peTemplate->set_var('fcounter', $allowedAttachments);
        $peTemplate->set_var('attachments', '');
        if ($uniqueid > 0) {
            $peTemplate->set_var('attachments', '<div id="fileattachlist">' . _ff_showattachments($uniqueid, 'edit') . '</div>');
        }
        $edit_prompt = '&nbsp;';
    }
    if ($action == 'newreply') {
        $peTemplate->set_var('save_button', 'savereply');
        $postmessage = $LANG_GF02['PostReply'];
        $peTemplate->set_var('hidden_action', 'newreply');
        if (!$viewMode) {
            $postData['subject'] = $LANG_GF01['RE'] . $postData['subject'];
        }
        $quoteid = isset($_GET['quoteid']) ? COM_applyFilter($_GET['quoteid'], true) : 0;
        $postData['mood'] = '';
        if ($quoteid > 0 && !$viewMode) {
            $quotesql = DB_query("SELECT * FROM {$_TABLES['ff_topic']} WHERE id=" . (int) $quoteid);
            $quotearray = DB_fetchArray($quotesql);
            $quotearray['name'] = urldecode($quotearray['name']);
            $quotearray['comment'] = $quotearray['comment'];
            $postData['comment'] = sprintf($_FF_CONF['quoteformat'], $quotearray['name'], $quotearray['comment']);
        }
        $postData['editpid'] = $postData['id'];
    }
    if ($_FF_CONF['use_sfs']) {
        $peTemplate->set_var('usesfs', 1);
    }
    if (COM_isAnonUser()) {
        if (!$_FF_CONF['use_sfs']) {
            $postData['email'] = '';
        }
        $peTemplate->set_var('anonymous_user', true);
        $peTemplate->set_var('post_message', $postmessage);
        $peTemplate->set_var('LANG_NAME', $LANG_GF02['msg33']);
        $peTemplate->set_var('name', htmlentities(strip_tags(COM_checkWords(trim(USER_sanitizeName(isset($postData['name']) ? $postData['name'] : ''))))), ENT_COMPAT, COM_getEncodingt());
        if (isset($postData['email'])) {
            $peTemplate->set_var('email', strip_tags($postData['email']));
        }
    } else {
        $peTemplate->set_var('member_user', true);
        $peTemplate->set_var('post_message', $postmessage);
        $peTemplate->set_var('LANG_NAME', $LANG_GF02['msg33']);
        if (!isset($username) or $username == '') {
            if ($action == 'edittopic') {
                if ($editmoderator) {
                    $username = $postData['name'];
                } else {
                    $username = COM_getDisplayName($_USER['uid']);
                }
            } else {
                $username = COM_getDisplayName($_USER['uid']);
            }
        }
        $peTemplate->set_var('username', $username);
        $peTemplate->set_var('xusername', urlencode($username));
    }
    $moodoptions = '';
    if ($_FF_CONF['show_moods']) {
        if (isset($postData['mood']) && $postData['mood'] != '') {
            $postData['mood'] = COM_applyFilter($postData['mood']);
        }
        if (!isset($postData['mood']) || $postData['mood'] == '') {
            $moodoptions = '<option value="" selected="selected">' . $LANG_GF01['NOMOOD'] . '</option>';
        }
        if ($dir = @opendir($_CONF['path_html'] . '/forum/images/moods')) {
            while (($file = readdir($dir)) !== false) {
                if (strlen($file) > 3 && substr(strtolower(trim($file)), -4, 4) == '.gif') {
                    $file = str_replace(array('.gif', '.jpg'), array('', ''), $file);
                    if (isset($postData['mood']) && $file == $postData['mood']) {
                        $moodoptions .= "<option selected=\"selected\">" . $file . "</option>";
                    } else {
                        $moodoptions .= "<option>" . $file . "</option>";
                    }
                } else {
                    $moodoptions .= '';
                }
            }
            closedir($dir);
        }
        $peTemplate->set_var('LANG_MOOD', $LANG_GF02['msg36']);
        $peTemplate->set_var('moodoptions', $moodoptions);
    }
    $sub_dot = '...';
    $sub_none = '';
    $postData['subject'] = str_replace($sub_dot, $sub_none, $postData['subject']);
    if ($_FF_CONF['allow_smilies']) {
        $peTemplate->set_var('smiley_enabled', true);
    }
    if ($_FF_CONF['allow_img_bbcode']) {
        $peTemplate->set_var('allow_img_bbcode', true);
    }
    // if this is the first time showing the new submission form - then check if notify option should be on
    if (!$viewMode) {
        if (isset($postData['editpid']) && $postData['editpid'] > 0) {
            $notifyTopicid = $postData['editpid'];
        } else {
            $notifyTopicid = $postData['id'];
        }
        if (!isset($postData['forum'])) {
            $postData['forum'] = '';
        }
        if (DB_getItem($_TABLES['ff_userprefs'], 'alwaysnotify', "uid=" . (int) $uid) == 1 or FF_isSubscribed($postData['forum'], $notifyTopicid, $uid)) {
            $postData['notify'] = 'on';
            // check and see if user has un-subscribed to this topic
            $nid = -$notifyTopicid;
            if ($notifyTopicid > 0 and DB_getItem($_TABLES['subscriptions'], 'id', "type='forum' AND category=" . (int) $postData['forum'] . " AND id={$nid} AND uid={$uid}") > 1) {
                $postData['notify'] = '';
            }
        } else {
            $postData['notify'] = '';
        }
    }
    if ($editmoderator) {
        if (isset($postData['notify']) && $postData['notify'] == 'on' or isset($postData['notify']) && $postData['notify'] == 'on') {
            $notify_val = 'checked="checked"';
        } else {
            $notify_val = '';
        }
        $notify_prompt = $LANG_GF02['msg38'] . '<br/><input type="checkbox" name="notify" value="on" ' . $notify_val . '/>';
        // check that this is the parent topic - only able to make it skicky or locked
        if (!isset($postData['pid']) || $postData['pid'] == 0) {
            if (!isset($locked_val) and !isset($sticky_val) and $action == 'edittopic') {
                if (!isset($postData['locked_switch']) and isset($postData['locked']) && $postData['locked'] == 1 or isset($postData['locked_switch']) && $postData['locked_switch'] == 1) {
                    $locked_val = 'checked="checked"';
                } else {
                    $locked_val = '';
                }
                if (!isset($postData['sticky_switch']) and isset($postData['sticky']) && $postData['sticky'] == 1 or isset($postData['sticky_switch']) && $postData['sticky_switch'] == 1) {
                    $sticky_val = 'checked="checked"';
                } else {
                    $sticky_val = '';
                }
            }
            $locked_prompt = $LANG_GF02['msg109'] . '<br/><input type="checkbox" name="locked_switch" ' . $locked_val . ' value="1"/>';
            $sticky_prompt = $LANG_GF02['msg61'] . '<br/><input type="checkbox" name="sticky_switch" ' . $sticky_val . ' value="1"/>';
        } else {
            $locked_prompt = '';
            $sticky_prompt = '';
        }
    } else {
        if ($uid > 1) {
            if (isset($postData['notify']) && $postData['notify'] == 'on') {
                $notify_val = 'checked="checked"';
            } else {
                $notify_val = '';
            }
            $notify_prompt = $LANG_GF02['msg38'] . '<br/><input type="checkbox" name="notify" ' . $notify_val . '/>';
            $locked_prompt = '';
        } else {
            $notify_prompt = '';
            $locked_prompt = '';
        }
    }
    if ($postData['postmode'] == 'html' || $postData['postmode'] == 'HTML') {
        $postmode_msg = $LANG_GF01['TEXTMODE'];
        $postData['postmode'] = 'html';
    } else {
        $peTemplate->unset_var('show_htmleditor');
        $postmode_msg = $LANG_GF01['HTMLMODE'];
    }
    if ($_FF_CONF['allow_html'] || SEC_inGroup('Root') || SEC_hasRights('forum.html')) {
        if ($action == 'edittopic') {
            $mode_prompt = $postmode_msg . '<br/><input type="checkbox" name="postmode_switch" value="1"/><input type="hidden" name="postmode" value="' . $postData['postmode'] . '"/>';
        }
    }
    if ($action == 'edittopic') {
        $peTemplate->set_var('bbcodeeditor', true);
    }
    $postData['subject'] = str_replace('"', '&quot;', $postData['subject']);
    if (!$_FF_CONF['allow_smilies']) {
        $smilies = '';
    } else {
        $smilies = forumPLG_showsmilies(0);
    }
    $disable_bbcode_prompt = $LANG_GF01['disable_bbcode'] . '&nbsp;<input type="checkbox" name="disable_bbcode" value="1" ' . $disable_bbcode_val . '/>';
    if ($_FF_CONF['allow_smilies']) {
        $disable_smilies_prompt = $LANG_GF01['disable_smilies'] . '&nbsp;<input type="checkbox" name="disable_smilies" value="1"' . $disable_smilies_val . ' />';
    } else {
        $disable_smilies_prompt = '';
    }
    $disable_urlparse_prompt = $LANG_GF01['disable_urlparse'] . '&nbsp;<input type="checkbox" name="disable_urlparse" value="1"' . $disable_urlparse_val . ' />';
    $peTemplate->set_var('comment', @htmlspecialchars($postData['comment'], ENT_QUOTES, COM_getEncodingt()));
    $peTemplate->set_var(array('edit_val' => $edit_val, 'sticky_val' => $sticky_val, 'postmode_msg' => $postmode_msg, 'notify_val' => $notify_val, 'disable_bbcode_val' => $disable_bbcode_val, 'disable_smilies_val' => $disable_smilies_val, 'disable_urlparse_val' => $disable_urlparse_val, 'bbcode_prompt' => $disable_bbcode_prompt, 'smilies_prompt' => $disable_smilies_prompt, 'urlparse_prompt' => $disable_urlparse_prompt, 'LANG_SUBJECT' => $LANG_GF01['SUBJECT'], 'LANG_OPTIONS' => $LANG_GF01['OPTIONS'], 'mode_prompt' => isset($mode_prompt) ? $mode_prompt : '', 'notify_prompt' => $notify_prompt, 'locked_prompt' => $locked_prompt, 'sticky_prompt' => isset($sticky_prompt) ? $sticky_prompt : '', 'edit_prompt' => $edit_prompt, 'LANG_SUBMIT' => $LANG_GF01['SUBMIT'], 'LANG_PREVIEW' => $LANG_GF01['PREVIEW'], 'subject' => $postData['subject'], 'smilies' => $smilies, 'LANG_attachments' => $LANG_GF10['attachments'], 'LANG_maxattachments' => sprintf($LANG_GF10['maxattachments'], $_FF_CONF['maxattachments']), 'postmode' => $postData['postmode']));
    // Check and see if the filemgmt plugin is installed and enabled
    if (function_exists('filemgmt_buildAccessSql') && $_FF_CONF['enable_fm_integration'] == 1) {
        $peTemplate->set_var('filemgmt_category_options', gf_makeFilemgmtCatSelect($uid));
        $peTemplate->set_var('LANG_usefilemgmt', $LANG_GF10['usefilemgmt']);
        $peTemplate->set_var('LANG_description', $LANG_GF10['description']);
        $peTemplate->set_var('LANG_category', $LANG_GF10['category']);
    } else {
        $peTemplate->set_var('show_filemgmt_option', 'none');
    }
    if (COM_isAnonUser()) {
        $peTemplate->set_var('hide_notify', 'none');
    }
    if (function_exists('plugin_templatesetvars_captcha')) {
        plugin_templatesetvars_captcha('forum', $peTemplate);
    } else {
        $peTemplate->set_var('captcha', '');
    }
    if ($postData['id'] > 0) {
        $peTemplate->set_var('topic_id', $postData['id']);
    }
    $peTemplate->set_var(array('navbreadcrumbsimg' => _ff_getImage('nav_breadcrumbs'), 'navtopicimg' => _ff_getImage('nav_topic'), 'form_action' => $_CONF['site_url'] . '/forum/createtopic.php', 'referer' => $forumData['referer'], 'forum_id' => $forumData['forum'], 'cat_name' => $postData['cat_name'], 'cat_id' => $forumData['forum_cat'], 'forum_name' => $postData['forum_name'], 'subject' => @htmlspecialchars($postData['subject'], ENT_QUOTES, COM_getEncodingt()), 'LANG_HOME' => $LANG_GF01['HOMEPAGE'], 'forum_home' => $LANG_GF01['INDEXPAGE'], 'hidden_id' => $postData['id'], 'page' => $forumData['page'], 'LANG_bhelp' => $LANG_GF01['b_help'], 'LANG_ihelp' => $LANG_GF01['i_help'], 'LANG_uhelp' => $LANG_GF01['u_help'], 'LANG_qhelp' => $LANG_GF01['q_help'], 'LANG_chelp' => $LANG_GF01['c_help'], 'LANG_lhelp' => $LANG_GF01['l_help'], 'LANG_ohelp' => $LANG_GF01['o_help'], 'LANG_phelp' => $LANG_GF01['p_help'], 'LANG_whelp' => $LANG_GF01['w_help'], 'LANG_ahelp' => $LANG_GF01['a_help'], 'LANG_shelp' => $LANG_GF01['s_help'], 'LANG_fhelp' => $LANG_GF01['f_help'], 'LANG_hhelp' => $LANG_GF01['h_help'], 'LANG_thelp' => $LANG_GF01['t_help'], 'LANG_ehelp' => $LANG_GF01['e_help'], 'LANG_code' => $LANG_GF01['CODE'], 'LANG_fontcolor' => $LANG_GF01['FONTCOLOR'], 'LANG_fontsize' => $LANG_GF01['FONTSIZE'], 'LANG_closetags' => $LANG_GF01['CLOSETAGS'], 'LANG_codetip' => $LANG_GF01['CODETIP'], 'LANG_tiny' => $LANG_GF01['TINY'], 'LANG_small' => $LANG_GF01['SMALL'], 'LANG_normal' => $LANG_GF01['NORMAL'], 'LANG_large' => $LANG_GF01['LARGE'], 'LANG_huge' => $LANG_GF01['HUGE'], 'LANG_default' => $LANG_GF01['DEFAULT'], 'LANG_dkred' => $LANG_GF01['DKRED'], 'LANG_red' => $LANG_GF01['RED'], 'LANG_orange' => $LANG_GF01['ORANGE'], 'LANG_brown' => $LANG_GF01['BROWN'], 'LANG_yellow' => $LANG_GF01['YELLOW'], 'LANG_green' => $LANG_GF01['GREEN'], 'LANG_olive' => $LANG_GF01['OLIVE'], 'LANG_cyan' => $LANG_GF01['CYAN'], 'LANG_blue' => $LANG_GF01['BLUE'], 'LANG_dkblue' => $LANG_GF01['DKBLUE'], 'LANG_indigo' => $LANG_GF01['INDIGO'], 'LANG_violet' => $LANG_GF01['VIOLET'], 'LANG_white' => $LANG_GF01['WHITE'], 'LANG_black' => $LANG_GF01['BLACK']));
    $peTemplate->set_var('token_name', CSRF_TOKEN);
    $peTemplate->set_var('token', SEC_createToken());
    $peTemplate->set_var('postmode', $postData['postmode']);
    $peTemplate->unset_var('show_htmleditor');
    if ($_FF_CONF['use_wysiwyg_editor'] && $postData['postmode'] == 'html') {
        // hook into wysiwyg here
        switch (PLG_getEditorType()) {
            case 'ckeditor':
                $peTemplate->set_var('show_htmleditor', true);
                PLG_requestEditor('forum', 'forum_entry', 'ckeditor_forum.thtml');
                PLG_templateSetVars('forum_entry', $peTemplate);
                break;
            case 'tinymce':
                $peTemplate->set_var('show_htmleditor', true);
                PLG_requestEditor('forum', 'forum_entry', 'tinymce_forum.thtml');
                PLG_templateSetVars('forum_entry', $peTemplate);
                break;
            default:
                // don't support others right now
                break;
        }
    }
    $peTemplate->parse('output', 'posteditor');
    $retval .= $peTemplate->finish($peTemplate->get_var('output'));
    $urlfor = 'advancededitor';
    if ($uid == 1) {
        $urlfor = 'advancededitor' . md5($REMOTE_ADDR);
    }
    SEC_setCookie($_CONF['cookie_name'] . 'adveditor', SEC_createTokenGeneral($urlfor), time() + 1200, $_CONF['cookie_path'], $_CONF['cookiedomain'], $_CONF['cookiesecure'], false);
    if (!isset($_POST['editpost'])) {
        $_POST['editpost'] = '';
    }
    if ($action != 'newtopic' && $_POST['editpost'] != 'yes' && ($action == 'newreply' || $viewMode)) {
        if ($FF_userprefs['showiframe']) {
            $retval .= "<iframe src=\"{$_CONF['site_url']}/forum/viewtopic.php?mode=preview&amp;showtopic=" . $postData['id'] . "&amp;onlytopic=1&amp;lastpost=true\" height=\"300\" width=\"100%\"></iframe>";
        }
    }
    return $retval;
}
コード例 #3
0
ファイル: ajaxdelfile.php プロジェクト: spacequad/glfusion
} else {
    $uid = $_USER['uid'];
}
if (forum_modPermission($edittopic['forum'], $uid, 'mod_edit')) {
    $editAllowed = true;
} elseif ($edittopic['uid'] > 1 and $edittopic['uid'] == $uid) {
    // User is trying to edit their topic post - this is allowed
    if ($edittopic['date'] > 0) {
        if ($_FF_CONF['allowed_editwindow'] > 0) {
            // Check if edit timeframe is still valid
            $t2 = $_FF_CONF['allowed_editwindow'];
            $time = time();
            if (time() - $t2 < $edittopic['date']) {
                $editAllowed = true;
            }
        } else {
            $editAllowed = true;
        }
    }
} elseif (DB_getItem($_TABLES['ff_attachments'], 'tempfile', "id=" . (int) $deleteid) == 1) {
    $editAllowed = true;
}
// Moderator or logged-in User is editing their topic post
if ($editAllowed) {
    forum_delAttachment($deleteid);
} else {
    COM_errorLog("Forum warning, invalid attempt to delete an attachment - topic:{$topic}, user:{$_USER['uid']}");
}
$retval = _ff_showattachments($topic, 'edit');
print $retval;
exit;