function ff_FormatForPrint($str, $postmode = 'html', $status = 0) { global $_FF_CONF; $str = FF_formatTextBlock($str, $postmode, 'preview', $status); $str = str_replace('{', '{', $str); $str = str_replace('}', '}', $str); // we don't have a stylesheet for printing, so replace our div with the style... // $str = str_replace('<div class="quotemain">','<div style="border: 1px dotted #000;border-left: 4px solid #8394B2;color:#465584; padding: 4px; margin: 5px auto 8px auto;">',$str); return $str; }
/** * used for the list of users in admin/user.php * */ function ADMIN_getListField_ratings($fieldname, $fieldvalue, $A, $icon_arr) { global $_CONF, $_TABLES, $LANG_ADMIN, $LANG04, $LANG28, $LANG_GF98, $_FF_CONF; $retval = ''; switch ($fieldname) { case 'grade': $retval = intval($fieldvalue); break; case 'rating': $retval = '<input type="text" name="new_rating-' . $A['uid'] . '" value="' . intval($A['rating']) . '" size="5" />'; break; case 'voter_id': $uname = DB_getItem($_TABLES['users'], 'username', 'uid=' . $A['voter_id']); $retval = COM_createLink($uname, $_CONF['site_admin_url'] . '/plugins/forum/userrating_detail.php?vid=' . $A['voter_id']); break; case 'user_id': $uname = DB_getItem($_TABLES['users'], 'username', 'uid=' . $A['user_id']); if ($uname == '') { $retval = COM_createLink($A['user_id'], $_CONF['site_admin_url'] . '/plugins/forum/userrating_detail.php?uid=' . $A['user_id']); } else { $retval = COM_createLink($uname, $_CONF['site_admin_url'] . '/plugins/forum/userrating_detail.php?uid=' . $A['user_id']); } break; case 'topic_id': if (intval($A['topic_id']) > 0) { $res = DB_query("SELECT id,pid,forum,subject,comment,status FROM {$_TABLES['ff_topic']} WHERE id=" . $A['topic_id']); list($id, $pid, $forum, $subject, $comment, $status) = DB_fetchArray($res); $testText = FF_formatTextBlock($comment, 'text', 'text', $status); $testText = strip_tags($testText); $lastpostinfogll = htmlspecialchars(preg_replace('#\\r?\\n#', '<br>', strip_tags(substr($testText, 0, $_FF_CONF['contentinfo_numchars']) . '...')), ENT_QUOTES, COM_getEncodingt()); if ($subject == '') { $subject = '<em>' . $LANG_GF98['no_subject_defined'] . '</em>'; } $retval = '<a class="' . COM_getTooltipStyle() . '" style="text-decoration:none;" href="' . $_CONF['site_url'] . '/forum/viewtopic.php?showtopic=' . ($pid == 0 ? $id : $pid) . '&topic=' . $id . '#' . $id . '" title="' . $subject . '::' . $lastpostinfogll . '" rel="nofollow">' . $subject . '</a>'; } elseif ($A['topic_id'] == -1) { $retval = $LANG_GF98['admin_set_value']; } else { $retval = $LANG_GF98['no_topic_defined']; } break; case 'username': $retval = COM_createLink($fieldvalue, $_CONF['site_admin_url'] . '/plugins/forum/userrating_detail.php?uid=' . $A['uid']); break; case $_TABLES['users'] . '.uid': $retval = $A['uid']; break; default: $retval = $fieldvalue; break; } return $retval; }
function _ff_getListField_gettopic($fieldname, $fieldvalue, $A, $icon_arr) { global $_CONF, $_USER, $_TABLES, $LANG_ADMIN, $LANG04, $LANG28, $_IMAGE_TYPE; global $_FF_CONF, $_SYSTEM, $LANG_GF02, $LANG_GF03; USES_lib_html2text(); $dt = new Date('now', $_USER['tzid']); $retval = ''; switch ($fieldname) { case 'author': $retval = $A['name']; break; case 'date': $dt->setTimestamp($fieldvalue); $retval = $dt->format($_FF_CONF['default_Datetime_format'], true); break; case 'lastupdated': $dt->setTimestamp($fieldvalue); $retval = $dt->format($_FF_CONF['default_Datetime_format'], true); break; case 'subject': $testText = FF_formatTextBlock($A['comment'], 'text', 'text', $A['status']); $testText = strip_tags($testText); $html2txt = new html2text($testText, false); $testText = trim($html2txt->get_text()); $lastpostinfogll = htmlspecialchars(preg_replace('#\\r?\\n#', '<br>', strip_tags(substr($testText, 0, $_FF_CONF['contentinfo_numchars']) . '...')), ENT_QUOTES, COM_getEncodingt()); $retval = '<span class="' . COM_getTooltipStyle() . '" style="text-decoration:none;" title="' . $A['subject'] . '::' . $lastpostinfogll . '">' . $fieldvalue . '</span>'; break; case 'select': $retval = '[ <a href="#" onclick="insert_topic(\'' . $A['id'] . '\'); return false;">' . $LANG_GF03['select'] . '</a> ]'; break; default: $retval = $fieldvalue; break; } return $retval; }
function _ff_getListField_forum($fieldname, $fieldvalue, $A, $icon_arr) { global $_CONF, $_USER, $_TABLES, $LANG_ADMIN, $LANG04, $LANG28, $_IMAGE_TYPE; global $_FF_CONF, $_SYSTEM, $LANG_GF02; if (!isset($A['status'])) { $A['status'] = 0; } USES_lib_html2text(); $retval = ''; $dt = new Date('now', $_USER['tzid']); switch ($fieldname) { case 'date': case 'lastupdated': $dt->setTimestamp($fieldvalue); $retval = $dt->format($_FF_CONF['default_Datetime_format'], true); break; case 'subject': $testText = FF_formatTextBlock($A['comment'], 'text', 'text', $A['status']); $testText = strip_tags($testText); $html2txt = new html2text($testText, false); $testText = trim($html2txt->get_text()); $lastpostinfogll = @htmlspecialchars(preg_replace('#\\r?\\n#', '<br>', strip_tags(substr($testText, 0, $_FF_CONF['contentinfo_numchars']) . '...')), ENT_QUOTES, COM_getEncodingt()); $retval = '<a class="' . COM_getTooltipStyle() . '" style="text-decoration:none;" href="' . $_CONF['site_url'] . '/forum/viewtopic.php?showtopic=' . ($A['pid'] == 0 ? $A['id'] : $A['pid']) . '&topic=' . $A['id'] . '#' . $A['id'] . '" title="' . $A['subject'] . '::' . $lastpostinfogll . '" rel="nofollow">' . $fieldvalue . '</a>'; break; case 'bookmark': $bm_icon_on = '<img src="' . _ff_getImage('star_on_sm') . '" title="' . $LANG_GF02['msg204'] . '" alt=""/>'; $retval = '<span id="forumbookmark' . $A['topic_id'] . '"><a href="#" onclick="ajax_toggleForumBookmark(' . $A['topic_id'] . ');return false;">' . $bm_icon_on . '</a></span>'; break; case 'replies': case 'views': if ($fieldvalue != '') { $retval = $fieldvalue; } else { $retval = '0'; } break; default: $retval = $fieldvalue; break; } return $retval; }
function _ff_FormatForEmail($str, $postmode = 'html') { global $_CONF, $_FF_CONF; $_FF_CONF['use_geshi'] = true; $_FF_CONF['allow_smilies'] = false; $str = FF_formatTextBlock($str, $postmode, 'text'); $str = str_replace('<img src="' . $_CONF['site_url'] . '/forum/images/img_quote.gif" alt=""/>', '', $str); // we don't have a stylesheet for email, so replace our div with the style... $str = str_replace('<div class="quotemain">', '<div style="border: 1px dotted #000;border-left: 4px solid #8394B2;color:#465584; padding: 4px; margin: 5px auto 8px auto;">', $str); return $str; }
$testText = strip_tags($testText); $html2txt = new html2text($testText, false); $testText = trim($html2txt->get_text()); $lastpostinfogll = htmlspecialchars(preg_replace('#\\r?\\n#', '<br>', strip_tags(substr($testText, 0, $_FF_CONF['contentinfo_numchars']) . '...'))); } else { $qlreply = DB_query("SELECT id,uid,name,comment,date,status FROM {$_TABLES['ff_topic']} WHERE id=" . (int) $P['last_reply_rec']); $B = DB_fetchArray($qlreply); $lastid = $B['id']; $lastcomment = $B['comment']; $P['date'] = $B['date']; if ($B['uid'] > 1) { $topicinfo .= sprintf($LANG_GF01['LASTREPLYBY'], COM_getDisplayName($B['uid'])); } else { $topicinfo .= sprintf($LANG_GF01['LASTREPLYBY'], $B['name']); } $testText = FF_formatTextBlock($B['comment'], 'text', 'text', $B['status']); $testText = strip_tags($testText); $html2txt = new html2text($testText, false); $testText = trim($html2txt->get_text()); $lastpostinfogll = htmlspecialchars(preg_replace('#\\r?\\n#', '<br>', strip_tags(substr($testText, 0, $_FF_CONF['contentinfo_numchars']) . '...'))); } $link = '<a class="' . COM_getTooltipStyle() . '" style="text-decoration:none; white-space:nowrap;" href="' . $_CONF['site_url'] . '/forum/viewtopic.php?showtopic=' . $topic_id . '&lastpost=true#' . $lastid . '" title="' . htmlspecialchars($P['subject']) . '::' . $lastpostinfogll . '" rel="nofollow">'; $topiclink = '<a class="' . COM_getTooltipStyle() . '" style="text-decoration:none;" href="' . $_CONF['site_url'] . '/forum/viewtopic.php?showtopic=' . $topic_id . '" title="' . htmlspecialchars($P['subject']) . '::' . $topicinfo . '">' . $P['subject'] . '</a>'; $dt->setTimestamp($P['date']); $tdate = $dt->format($_FF_CONF['default_Datetime_format'], true); $data_arr[] = array('forum' => '<a href="' . $_CONF['site_url'] . '/forum/index.php?forum=' . $P['forum_id'] . '">' . $P['forum_name'] . '</a>', 'subject' => $topiclink, 'date' => $link . $tdate . '</a>'); if ($displayrecs >= 100) { break; } } }
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&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&forum=' . $showtopic['forum'] . '&id=' . $showtopic['id'] . '&editid=' . $showtopic['id'] . '&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&forum=' . $showtopic['forum'] . '&id=' . $replytopicid . '&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&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', ''); } }
function FF_saveTopic($forumData, $postData, $action) { global $_CONF, $_TABLES, $_FF_CONF, $_USER, $LANG03, $LANG_GF01, $LANG_GF02; $retval = ''; $uploadErrors = ''; $msg = ''; $errorMessages = ''; $email = ''; $forumfiles = array(); $okToSave = true; $dt = new Date('now', $_USER['tzid']); $date = $dt->toUnix(); $REMOTE_ADDR = $_SERVER['REMOTE_ADDR']; if (COM_isAnonUser()) { $uid = 1; } else { $uid = $_USER['uid']; } // verify postmode is allowed if (strtolower($postData['postmode']) == 'html') { if ($_FF_CONF['allow_html'] || SEC_inGroup('Root') || SEC_hasRights('forum.html')) { $postData['postmode'] = 'html'; } else { $postData['postmode'] = 'text'; } } // is forum readonly? if ($forumData['is_readonly'] == 1) { // Check if this user has moderation rights now to allow a post to a locked topic if (!forum_modPermission($forumData['forum'], $uid, 'mod_edit')) { _ff_accessError(); } } if ($action == 'saveedit') { // does the forum match the forum id of the posted data? if ($forumData['forum'] != 0 && $forumData['forum'] != $postData['forum']) { _ff_accessError(); } $editid = COM_applyFilter($postData['editid'], true); $forum = COM_applyFilter($postData['forum'], true); $editAllowed = false; if (forum_modPermission($forumData['forum'], $_USER['uid'], 'mod_edit')) { $editAllowed = true; } else { if ($_FF_CONF['allowed_editwindow'] > 0) { $t1 = DB_getItem($_TABLES['ff_topic'], 'date', "id=" . (int) $postData['id']); $t2 = $_FF_CONF['allowed_editwindow']; $time = time(); if (time() - $t2 < $t1) { $editAllowed = true; } } else { $editAllowed = true; } } if ($postData['editpid'] < 1 && trim($postData['subject']) == '') { $retval .= FF_BlockMessage('', $LANG_GF02['msg18'], false); $okToSave = false; } elseif (!$editAllowed) { $link = $_CONF['site_url'] . '/forum/viewtopic.php?showtopic=' . (int) $postData['$id']; $retval .= _ff_alertMessage('', $LANG_GF02['msg189'], sprintf($LANG_GF02['msg187'], $link)); $okToSave = false; } } else { if (!COM_isAnonUser() && $_FF_CONF['use_sfs']) { $email = isset($_USER['email']) ? $_USER['email'] : ''; } } if (isset($postData['name']) && $postData['name'] != '') { $name = _ff_preparefordb(@htmlspecialchars(strip_tags(trim(COM_checkWords(USER_sanitizeName($postData['name'])))), ENT_QUOTES, COM_getEncodingt()), 'text'); $name = urldecode($name); } else { $okToSave = false; $errorMessages .= $LANG_GF02['invalid_name'] . '<br />'; } // speed limit check if (!SEC_hasRights('forum.edit')) { COM_clearSpeedlimit($_FF_CONF['post_speedlimit'], 'forum'); $last = COM_checkSpeedlimit('forum'); if ($last > 0) { $errorMessages .= sprintf($LANG_GF01['SPEEDLIMIT'], $last, $_FF_CONF['post_speedlimit']) . '<br/>'; $okToSave = false; } } // standard edit checks if (strlen(trim($postData['name'])) < $_FF_CONF['min_username_length'] || strlen(trim($postData['subject'])) < $_FF_CONF['min_subject_length'] || strlen(trim($postData['comment'])) < $_FF_CONF['min_comment_length']) { $errorMessages .= $LANG_GF02['msg18'] . '<br/>'; $okToSave = false; } // CAPTCHA check if (function_exists('plugin_itemPreSave_captcha') && $okToSave == true) { if (!isset($postData['captcha'])) { $postData['captcha'] = ''; } $msg = plugin_itemPreSave_captcha('forum', $postData['captcha']); if ($msg != '') { $errorMessages .= $msg . '<br/>'; $okToSave = false; } } $status = 0; if (isset($postData['disable_bbcode']) && $postData['disable_bbcode'] == 1) { $status += DISABLE_BBCODE; } if (isset($postData['disable_smilies']) && $postData['disable_smilies'] == 1) { $status += DISABLE_SMILIES; } if (isset($postData['disable_urlparse']) && $postData['disable_urlparse'] == 1) { $status += DISABLE_URLPARSE; } // spamx check if ($_FF_CONF['use_spamx_filter'] == 1 && $okToSave == true) { SESS_unSet('spamx_msg'); // clear out the message. // Check for SPAM $spamcheck = '<h1>' . $postData['subject'] . '</h1><p>' . FF_formatTextBlock($postData['comment'], $postData['postmode'], 'preview', $status) . '</p>'; $result = PLG_checkforSpam($spamcheck, $_CONF['spamx']); // Now check the result and redirect to index.php if spam action was taken if ($result > 0) { // then tell them to get lost ... $errorMessages .= $LANG_GF02['spam_detected']; if (SESS_isSet('spamx_msg')) { $errorMessages .= '<br>' . SESS_getVar('spamx_msg') . '<br>'; SESS_unSet('spamx_msg'); } $okToSave = false; } } if ($_FF_CONF['use_sfs'] == 1 && COM_isAnonUser() && function_exists('plugin_itemPreSave_spamx')) { $spamCheckData = array('username' => $postData['name'], 'email' => $email, 'ip' => $REMOTE_ADDR); $msg = plugin_itemPreSave_spamx('forum', $spamCheckData); if ($msg) { $errorMessages .= $msg; $okToSave = false; } } if ($okToSave == false) { $retval .= _ff_alertMessage($errorMessages, $LANG_GF01['ERROR'], ' '); return array(false, $retval); } if ($okToSave == true) { if (!isset($postData['postmode_switch'])) { $postData['postmode_switch'] = 0; } $postmode = _ff_chkpostmode($postData['postmode'], $postData['postmode_switch']); // validate postmode if ($postmode == 'html' || $postmode == 'HTML') { if ($_FF_CONF['allow_html'] || SEC_inGroup('Root') || SEC_hasRights('forum.html')) { $postmode = 'html'; } else { $postmode = 'text'; } } $subject = _ff_preparefordb(strip_tags($postData['subject']), 'text'); $comment = _ff_preparefordb($postData['comment'], $postmode); $mood = isset($postData['mood']) ? COM_applyFilter($postData['mood']) : ''; $id = COM_applyFilter($postData['id'], true); $forum = COM_applyFilter($postData['forum'], true); $notify = isset($postData['notify']) ? COM_applyFilter($postData['notify']) : ''; // If user has moderator edit rights only $locked = 0; $sticky = 0; if (isset($postData['modedit']) && $postData['modedit'] == 1) { if (isset($postData['locked_switch']) && $postData['locked_switch'] == 1) { $locked = 1; } if (isset($postData['sticky_switch']) && $postData['sticky_switch'] == 1) { $sticky = 1; } } if ($action == 'savetopic') { $fields = "forum,name,email,date,lastupdated,subject,comment,postmode,ip,mood,uid,pid,sticky,locked,status"; $sql = "INSERT INTO {$_TABLES['ff_topic']} ({$fields}) "; $sql .= "VALUES (" . (int) $forum . "," . "'" . DB_escapeString($name) . "'," . "'" . DB_escapeString($email) . "'," . "'" . DB_escapeString($date) . "'," . "'" . DB_escapeString($date) . "'," . "'" . $subject . "'," . "'" . $comment . "'," . "'" . DB_escapeString($postmode) . "'," . "'" . DB_escapeString($REMOTE_ADDR) . "'," . "'" . DB_escapeString($mood) . "'," . (int) $uid . "," . "0," . (int) $sticky . "," . (int) $locked . "," . (int) $status . ")"; DB_query($sql); // Find the id of the last inserted topic list($lastid) = DB_fetchArray(DB_query("SELECT max(id) FROM {$_TABLES['ff_topic']} ")); $savedPostID = $lastid; $topicPID = $lastid; /* Check for any uploaded files - during add of new topic */ $uploadErrors = _ff_check4files($lastid); // 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 = ''; $imagerecs = implode(',', $forumfiles); $sql = "UPDATE {$_TABLES['ff_attachments']} SET show_inline = 0 WHERE topic_id=" . (int) $lastid . " "; if ($imagerecs != '') { $sql .= "AND id NOT IN ({$imagerecs})"; } DB_query($sql); // Update forums record DB_query("UPDATE {$_TABLES['ff_forums']} SET post_count=post_count+1, topic_count=topic_count+1, last_post_rec=" . (int) $lastid . " WHERE forum_id=" . (int) $forum); if (DB_Count($_TABLES['ff_attachments'], 'topic_id', (int) $lastid)) { DB_query("UPDATE {$_TABLES['ff_topic']} SET attachments=1 WHERE id=" . (int) $lastid); } DB_query("DELETE FROM {$_TABLES['ff_log']} WHERE topic=" . (int) $topicPID . " and time > 0"); } else { if ($action == 'savereply') { $fields = "name,email,date,subject,comment,postmode,ip,mood,uid,pid,forum,status"; $sql = "INSERT INTO {$_TABLES['ff_topic']} ({$fields}) "; $sql .= "VALUES (" . "'" . DB_escapeString($name) . "'," . "'" . DB_escapeString($email) . "'," . "'" . DB_escapeString($date) . "'," . "'{$subject}'," . "'{$comment}'," . "'" . DB_escapeString($postmode) . "'," . "'" . DB_escapeString($REMOTE_ADDR) . "'," . "'" . DB_escapeString($mood) . "'," . (int) $uid . "," . (int) $id . "," . (int) $forum . "," . (int) $status . ")"; DB_query($sql); // Find the id of the last inserted topic list($lastid) = DB_fetchArray(DB_query("SELECT max(id) FROM {$_TABLES['ff_topic']} ")); $savedPostID = $lastid; $topicPID = $id; /* Check for any uploaded files - during adding reply post */ $uploadErrors = _ff_check4files($lastid); // 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 = ''; $imagerecs = implode(',', $forumfiles); $sql = "UPDATE {$_TABLES['ff_attachments']} SET show_inline = 0 WHERE topic_id=" . (int) $lastid; if ($imagerecs != '') { $sql .= " AND id NOT IN ({$imagerecs})"; } DB_query($sql); DB_query("UPDATE {$_TABLES['ff_topic']} SET replies=replies+1, lastupdated='" . DB_escapeString($date) . "',last_reply_rec=" . (int) $lastid . " WHERE id=" . (int) $id); DB_query("UPDATE {$_TABLES['ff_forums']} SET post_count=post_count+1, last_post_rec=" . (int) $lastid . " WHERE forum_id=" . (int) $forum); if (DB_Count($_TABLES['ff_attachments'], 'topic_id', (int) $lastid)) { DB_query("UPDATE {$_TABLES['ff_topic']} SET attachments=1 WHERE id=" . (int) $id); } DB_query("DELETE FROM {$_TABLES['ff_log']} WHERE topic=" . (int) $topicPID . " and time > 0"); } elseif ($action == 'saveedit') { $sql = "UPDATE {$_TABLES['ff_topic']} SET " . "subject='{$subject}'," . "comment='{$comment}'," . "postmode='" . DB_escapeString($postmode) . "'," . "mood='" . DB_escapeString($mood) . "'," . "sticky=" . (int) $sticky . "," . "locked=" . (int) $locked . "," . "status=" . (int) $status . " " . "WHERE (id=" . (int) $editid . ")"; DB_query($sql); /* Check for any uploaded files - during save of edit */ $uploadErrors = _ff_check4files($editid); // 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 = ''; $imagerecs = implode(',', $forumfiles); $sql = "UPDATE {$_TABLES['ff_attachments']} SET show_inline = 0 WHERE topic_id=" . (int) $editid . " "; if ($imagerecs != '') { $sql .= "AND id NOT IN ({$imagerecs})"; } DB_query($sql); $topicPID = DB_getITEM($_TABLES['ff_topic'], "pid", "id=" . (int) $editid); if ($topicPID == 0) { $topicPID = $editid; } $savedPostID = $editid; if ($postData['silentedit'] != 1) { DB_query("UPDATE {$_TABLES['ff_topic']} SET lastupdated='" . DB_escapeString($date) . "' WHERE id=" . (int) $topicPID); //Remove any lastviewed records in the log so that the new updated topic indicator will appear DB_query("DELETE FROM {$_TABLES['ff_log']} WHERE topic=" . (int) $topicPID . " and time > 0"); } if (DB_Count($_TABLES['ff_attachments'], 'topic_id', (int) $editid)) { DB_query("UPDATE {$_TABLES['ff_topic']} SET attachments=1 WHERE id=" . (int) $topicPID); } $topicparent = $topicPID; } } COM_updateSpeedLimit('forum'); PLG_itemSaved($savedPostID, 'forum'); CACHE_remove_instance('forumcb'); if (!COM_isAnonUser()) { //NOTIFY - Checkbox variable in form set to "on" when checked and they don't already have subscribed to forum or topic $nid = -$topicPID; $currentForumNotifyRecID = (int) DB_getItem($_TABLES['subscriptions'], 'sub_id', "type='forum' AND category='" . DB_escapeString($forum) . "' AND id=0 AND uid=" . (int) $uid); $currentTopicNotifyRecID = (int) DB_getItem($_TABLES['subscriptions'], 'sub_id', "type='forum' AND category='" . DB_escapeString($forum) . "' AND id='" . DB_escapeString($topicPID) . "' AND uid=" . (int) $uid); $currentTopicUnNotifyRecID = (int) DB_getItem($_TABLES['subscriptions'], 'sub_id', "type='forum' AND category='" . DB_escapeString($forum) . "' AND id='" . DB_escapeString($nid) . "' AND uid=" . (int) $uid); $forum_name = DB_getItem($_TABLES['ff_forums'], 'forum_name', 'forum_id=' . (int) $forum); $topic_name = $subject; if ($notify == 'on' and ($currentForumNotifyRecID < 1 and $currentTopicNotifyRecID < 1)) { $sql = "INSERT INTO {$_TABLES['subscriptions']} (type,category,category_desc,id,id_desc,uid,date_added) "; $sql .= "VALUES ('forum','" . DB_escapeString($forum) . "','" . DB_escapeString($forum_name) . "','" . DB_escapeString($topicPID) . "','" . $subject . "'," . (int) $uid . ",now() )"; DB_query($sql); } elseif ($notify == 'on' and $currentTopicUnNotifyRecID > 1) { // Had un-subcribed to topic and now wants to subscribe DB_query("DELETE FROM {$_TABLES['subscriptions']} WHERE sub_id=" . (int) $currentTopicUnNotifyRecID); } elseif ($notify == '' and $currentTopicNotifyRecID > 1) { // Subscribed to topic - but does not want to be notified anymore DB_query("DELETE FROM {$_TABLES['subscriptions']} WHERE type='forum' AND uid=" . (int) $uid . " AND category='" . DB_escapeString($forum) . "' and id = '" . DB_escapeString($topicPID) . "'"); } elseif ($notify == '' and $currentForumNotifyRecID > 1) { // Subscribed to forum - but does not want to be notified about this topic DB_query("DELETE FROM {$_TABLES['subscriptions']} WHERE type='forum' AND uid=" . (int) $uid . " AND category='" . DB_escapeString($forum) . "' and id = '" . DB_escapeString($topicPID) . "'"); DB_query("DELETE FROM {$_TABLES['subscriptions']} WHERE type='forum' AND uid=" . (int) $uid . " AND category='" . DB_escapeString($forum) . "' and id = '" . DB_escapeString($nid) . "'"); DB_query("INSERT INTO {$_TABLES['subscriptions']} (type,category,category_desc,id,id_desc,uid,date_added) VALUES ('forum','" . DB_escapeString($forum) . "','" . DB_escapeString($forum_name) . "','" . DB_escapeString($nid) . "','" . $subject . "'," . (int) $uid . ",now() )"); } } if ($action != 'saveedit') { _ff_chknotifications($forum, $savedPostID, $uid); } $link = $_CONF['site_url'] . '/forum/viewtopic.php?showtopic=' . $topicPID . '&topic=' . $savedPostID . '#' . $savedPostID; if ($uploadErrors != '') { $autorefresh = false; } else { $autorefresh = true; } $retval .= FF_statusMessage($uploadErrors . $LANG_GF02['msg19'], $link, $LANG_GF02['msg19'], false, '', $autorefresh); } else { $retval .= _ff_alertMessage($LANG_GF02['msg18']); } return array(true, $retval); }