$totalpages) { $startpage = ($totalpages-$maxpages) < 1 ? 1 : $totalpages-$maxpages; $endpage = $totalpages; } $output = ''._PAGE; if ($startpage > 1) { if ($endpage < $totalpages) $endpage--; $output .= CKunenaLink::GetThreadPageLink($fbConfig, 'view', $catid, $threadid, 1, $fbConfig->messages_per_page, 1, '', $rel='follow'); if ($startpage > 2) { $output .= "..."; } } for ($i = $startpage; $i <= $endpage && $i <= $totalpages; $i++) { if ($page == $i) { $output .= "$i"; } else { $output .= CKunenaLink::GetThreadPageLink($fbConfig, 'view', $catid, $threadid, $i, $fbConfig->messages_per_page, $i, '', $rel='follow'); } } if ($endpage < $totalpages) { if ($endpage < $totalpages-1) { $output .= "..."; } $output .= CKunenaLink::GetThreadPageLink($fbConfig, 'view', $catid, $threadid, $totalpages, $fbConfig->messages_per_page, $totalpages, '', $rel='follow'); } $output .= ''; return $output; } global $is_Moderator; $kunena_acl = &JFactory::getACL(); //securing form elements $catid = (int)$catid; $id = (int)$id; $smileyList = smile::getEmoticons(0); //ob_start(); $showedEdit = 0; require_once (KUNENA_PATH_LIB .DS. 'kunena.authentication.php'); require_once (KUNENA_PATH_LIB .DS. 'kunena.statsbar.php'); //get the allowed forums and turn it into an array $allow_forum = ($fbSession->allowed <> '')?explode(',', $fbSession->allowed):array(); $forumLocked = 0; $topicLocked = 0; $kunena_db->setQuery("SELECT a.*, b.* FROM #__fb_messages AS a LEFT JOIN #__fb_messages_text AS b ON a.id=b.mesid WHERE a.id='{$id}' AND a.hold='0'"); $this_message = $kunena_db->loadObject(); check_dberror('Unable to load current message.'); if ((in_array($catid, $allow_forum)) || (isset($this_message->catid) && in_array($this_message->catid, $allow_forum))) { $view = $view == "" ? $settings[current_view] : $view; setcookie("fboard_settings[current_view]", $view, time() + 31536000, '/'); $topicLocked = $this_message->locked; $topicSticky = $this_message->ordering; if (count($this_message) < 1) { echo '
' . _MODERATION_INVALID_ID . '
'; } else { $thread = $this_message->parent == 0 ? $this_message->id : $this_message->thread; // Test if this is a valid SEO URL if not we should redirect using a 301 - permanent redirect if ($thread != $this_message->id || $catid != $this_message->catid) { // Invalid SEO URL detected! // Create permanent re-direct and quit // This query to calculate the page this reply is sitting on within this thread $query = "SELECT COUNT(*) FROM #__fb_messages AS a WHERE a.thread='{$thread}' AND hold='0' AND a.id<='{$id}'"; $kunena_db->setQuery($query); $replyCount = $kunena_db->loadResult(); check_dberror('Unable to calculate location of current message.'); $replyPage = $replyCount > $fbConfig->messages_per_page ? ceil($replyCount / $fbConfig->messages_per_page) : 1; header("HTTP/1.1 301 Moved Permanently"); header("Location: " . htmlspecialchars_decode(CKunenaLink::GetThreadPageURL($fbConfig, 'view', $this_message->catid, $thread, $replyPage, $fbConfig->messages_per_page, $this_message->id))); $app->close(); } if ($kunena_my->id) { //mark this topic as read $kunena_db->setQuery("SELECT readtopics FROM #__fb_sessions WHERE userid='{$kunena_my->id}'"); $readTopics = $kunena_db->loadResult(); if ($readTopics == "") { $readTopics = $thread; } else { //get all readTopics in an array $_read_topics = @explode(',', $readTopics); if (!@in_array($thread, $_read_topics)) { $readTopics .= "," . $thread; } } $kunena_db->setQuery("UPDATE #__fb_sessions SET readtopics='{$readTopics}' WHERE userid='{$kunena_my->id}'"); $kunena_db->query(); } //update the hits counter for this topic & exclude the owner if ($kunena_my->id == 0 || $this_message->userid != $kunena_my->id) { $kunena_db->setQuery("UPDATE #__fb_messages SET hits=hits+1 WHERE id='{$thread}' AND parent='0'"); $kunena_db->query(); } $query = "SELECT COUNT(*) FROM #__fb_messages AS a WHERE a.thread='{$thread}' AND hold='0'"; $kunena_db->setQuery($query); $total = $kunena_db->loadResult(); check_dberror('Unable to calculate message count.'); //prepare paging $limit = JRequest::getInt('limit', 0); if ($limit < 1) $limit = $fbConfig->messages_per_page; $limitstart = JRequest::getInt('limitstart', 0); if ($limitstart < 0) $limitstart = 0; if ($limitstart > $total) $limitstart = intval($total/$limit)*$limit; $ordering = ($fbConfig->default_sort == 'desc' ? 'desc' : 'asc'); // Just to make sure only valid options make it $maxpages = 9 - 2; // odd number here (show - 2) $totalpages = ceil($total / $limit); $page = floor($limitstart / $limit)+1; $firstpage = 1; if ($ordering == 'desc') $firstpage = $totalpages; $replylimit = $page == $firstpage ? $limit-1 : $limit; // If page contains first message, load $limit-1 messages $replystart = $limitstart && $ordering == 'asc' ? $limitstart-1 : $limitstart; // If not first page and order=asc, start on $limitstart-1 // Get replies of current thread $query = "SELECT a.*, b.* FROM #__fb_messages AS a LEFT JOIN #__fb_messages_text AS b ON a.id=b.mesid " ."WHERE a.thread='{$thread}' AND a.id!='{$id}' AND a.hold='0' AND a.catid='{$catid}' ORDER BY id {$ordering}"; $kunena_db->setQuery($query, $replystart, $replylimit); $replies = $kunena_db->loadObjectList(); check_dberror('Unable to load replies'); $flat_messages = array(); if ($page == 1 && $ordering == 'asc') $flat_messages[] = $this_message; // ASC: first message is the first one foreach ($replies as $message) $flat_messages[] = $message; if ($page == $totalpages && $ordering == 'desc') $flat_messages[] = $this_message; // DESC: first message is the last one unset($replies); $pagination = KunenaViewPagination($catid, $thread, $page, $totalpages, $maxpages); //Get the category name for breadcrumb $kunena_db->setQuery("SELECT * FROM #__fb_categories WHERE id='{$catid}'"); $objCatInfo = $kunena_db->loadObject(); //Get Parent's cat.name for breadcrumb $kunena_db->setQuery("SELECT id, name FROM #__fb_categories WHERE id='{$objCatInfo->parent}'"); $objCatParentInfo = $kunena_db->loadObject(); $forumLocked = $objCatInfo->locked; //meta description and keywords $metaKeys=kunena_htmlspecialchars(stripslashes("{$this_message->subject}, {$objCatParentInfo->name}, {$fbConfig->board_title}, " ._GEN_FORUM. ', ' .$app->getCfg('sitename'))); $metaDesc=kunena_htmlspecialchars(stripslashes("{$this_message->subject} ({$page}/{$totalpages}) - {$objCatParentInfo->name} - {$objCatInfo->name} - {$fbConfig->board_title} " ._GEN_FORUM)); $document =& JFactory::getDocument(); $cur = $document->get( 'description' ); $metaDesc = $cur .'. ' . $metaDesc; $document->setMetadata( 'keywords', $metaKeys ); $document->setDescription($metaDesc); //Perform subscriptions check only once $fb_cansubscribe = 0; if ($fbConfig->allowsubscriptions && ("" != $kunena_my->id || 0 != $kunena_my->id)) { $kunena_db->setQuery("SELECT thread FROM #__fb_subscriptions WHERE userid='{$kunena_my->id}' AND thread='{$thread}'"); $fb_subscribed = $kunena_db->loadResult(); if ($fb_subscribed == "") { $fb_cansubscribe = 1; } } //Perform favorites check only once $fb_canfavorite = 0; if ($fbConfig->allowfavorites && ("" != $kunena_my->id || 0 != $kunena_my->id)) { $kunena_db->setQuery("SELECT thread FROM #__fb_favorites WHERE userid='{$kunena_my->id}' AND thread='{$thread}'"); $fb_favorited = $kunena_db->loadResult(); if ($fb_favorited == "") { $fb_canfavorite = 1; } } //data ready display now if ($is_Moderator || (($forumLocked == 0 && $topicLocked == 0) && ($kunena_my->id > 0 || $fbConfig->pubwrite))) { //this user is allowed to reply to this topic $thread_reply = CKunenaLink::GetTopicPostReplyLink('reply', $catid, $thread, isset($fbIcons['topicreply']) ? '| headerdesc, 0, $fbConfig->disemoticons, $smileyList)); $headerdesc = nl2br($headerdesc); //wordwrap: $headerdesc = smile::htmlwrap($headerdesc, $fbConfig->wrap); echo $headerdesc; ?> |
|
';
echo CKunenaLink::GetSamePageAnkerLink('forumbottom', isset($fbIcons['bottomarrow']) ? ' | ';
if ($is_Moderator || isset($thread_reply) || isset($thread_subscribe) || isset($thread_favorite))
{
echo ''; echo ''; if ($is_Moderator) { echo ''; } echo ' | '; } echo ''; if (isset($thread_new)) { echo ''; } if (isset($thread_merge)) { echo ''; } echo ' | '; //pagination 1 echo ''; echo $pagination; echo ' | '; ?>
|
';
if ($fbIcons['favoritestar']) {
if ($fb_totalfavorited>=1) echo ' ';
?>
|
||
|---|---|---|
|
setQuery("SELECT a.userid FROM #__fb_users AS a LEFT JOIN #__fb_moderation AS b ON b.userid=a.userid WHERE b.catid='{$catid}'");
$catModerators = $kunena_db->loadResultArray();
/**
* note: please check if this routine is fine. there is no need to see for all messages if they are locked or not, either the thread or cat can be locked anyway
*/
//check if topic is locked
$_lockTopicID = $this_message->thread;
$topicLocked = $this_message->locked;
if ($_lockTopicID) // prev UNDEFINED $topicID!!
{
$lockedWhat = _TOPIC_NOT_ALLOWED; // UNUSED
}
else
{ //topic not locked; check if forum is locked
$kunena_db->setQuery("SELECT locked FROM #__fb_categories WHERE id='{$this_message->catid}'");
$topicLocked = $kunena_db->loadResult();
$lockedWhat = _FORUM_NOT_ALLOWED; // UNUSED
}
// END TOPIC LOCK
if (count($flat_messages) > 0)
{
foreach ($flat_messages as $fmessage)
{
$k = 1 - $k;
$mmm++;
if ($fmessage->parent == 0) {
$fb_thread = $fmessage->id;
}
else {
$fb_thread = $fmessage->thread;
}
//filter out clear html
$fmessage->name = kunena_htmlspecialchars($fmessage->name);
$fmessage->email = kunena_htmlspecialchars($fmessage->email);
$fmessage->subject = kunena_htmlspecialchars($fmessage->subject);
//Get userinfo needed later on, this limits the amount of queries
static $uinfocache = array();
if (!isset($uinfocache[$fmessage->userid]))
{
$kunena_db->setQuery("SELECT a.*, b.id, b.name, b.username, b.gid FROM #__fb_users AS a INNER JOIN #__users AS b ON b.id=a.userid WHERE a.userid='{$fmessage->userid}'");
$userinfo = $kunena_db->loadObject();
if ($userinfo == NULL) {
$userinfo = new stdClass();
$userinfo->userid = 0;
$userinfo->name = '';
$userinfo->username = '';
$userinfo->avatar = '';
$userinfo->gid = 0;
$userinfo->rank = 0;
$userinfo->posts = 0;
$userinfo->karma = 0;
$userinfo->gender = _KUNENA_NOGENDER;
$userinfo->personalText = '';
$userinfo->ICQ = '';
$userinfo->location = '';
$userinfo->birthdate = '';
$userinfo->AIM = '';
$userinfo->MSN = '';
$userinfo->YIM = '';
$userinfo->SKYPE = '';
$userinfo->GTALK = '';
$userinfo->websiteurl = '';
$userinfo->signature = '';
}
$uinfocache[$fmessage->userid] = $userinfo;
} else $userinfo = $uinfocache[$fmessage->userid];
if ($fbConfig->fb_profile == 'cb')
{
$triggerParams = array( 'userid'=> $fmessage->userid,
'userinfo'=> &$userinfo );
$kunenaProfile->trigger( 'profileIntegration', $triggerParams );
}
//get the username:
if ($fbConfig->username) {
$fb_queryName = "username";
}
else {
$fb_queryName = "name";
}
$fb_username = $userinfo->$fb_queryName;
if ($fb_username == "" || $fbConfig->changename) {
$fb_username = stripslashes($fmessage->name);
}
$fb_username = kunena_htmlspecialchars($fb_username);
$msg_id = $fmessage->id;
$lists["userid"] = $userinfo->userid;
$msg_username = $fmessage->email != "" && $my_id > 0 && $fbConfig->showemail ? CKunenaLink::GetEmailLink(kunena_htmlspecialchars(stripslashes($fmessage->email)), $fb_username) : $fb_username;
if ($fbConfig->allowavatar)
{
$Avatarname = $userinfo->username;
if ($fbConfig->avatar_src == "jomsocial")
{
// Get CUser object
$jsuser =& CFactory::getUser($userinfo->userid);
$msg_avatar = ' ' .
"" . _POSTS . " $numPosts" . "" .
" ";
}
else
{
$myGraph = new phpGraph;
//$myGraph->SetGraphTitle(_POSTS);
$myGraph->AddValue(_POSTS, $numPosts);
$myGraph->SetRowSortMode(0);
$myGraph->SetBarImg(KUNENA_URLGRAPHPATH . "col" . $fbConfig->statscolor . "m.png");
$myGraph->SetBarImg2(KUNENA_URLEMOTIONSPATH . "graph.gif");
$myGraph->SetMaxVal($maxPosts);
$myGraph->SetShowCountsMode(2);
$myGraph->SetBarWidth(4); //height of the bar
$myGraph->SetBorderColor("#333333");
$myGraph->SetBarBorderWidth(0);
$myGraph->SetGraphWidth(64); //should match column width in the | above -5 pixels //$myGraph->BarGraphHoriz(); $useGraph = 1; } } } // Start Integration AlphaUserPoints // **************************** $api_AUP = JPATH_SITE.DS.'components'.DS.'com_alphauserpoints'.DS.'helper.php'; if ( $fbConfig->alphauserpoints && file_exists($api_AUP)) { static $maxPoints = false; if ($maxPoints == false) { //Get the max# of points for any one user $kunena_db->setQuery("SELECT MAX(points) FROM #__alpha_userpoints"); $maxPoints = $kunena_db->loadResult(); check_dberror("Unable to load AUP max points."); } $kunena_db->setQuery("SELECT points FROM #__alpha_userpoints WHERE `userid`='".(int)$fmessage->userid."'"); $numPoints = $kunena_db->loadResult(); check_dberror("Unable to load AUP points."); $myGraphAUP = new phpGraph; $myGraphAUP->AddValue(_KUNENA_AUP_POINTS, $numPoints); $myGraphAUP->SetRowSortMode(0); $myGraphAUP->SetBarImg(KUNENA_URLGRAPHPATH . "col" . $fbConfig->statscolor . "m.png"); $myGraphAUP->SetBarImg2(KUNENA_URLEMOTIONSPATH . "graph.gif"); $myGraphAUP->SetMaxVal($maxPoints); $myGraphAUP->SetShowCountsMode(2); $myGraphAUP->SetBarWidth(4); //height of the bar $myGraphAUP->SetBorderColor("#333333"); $myGraphAUP->SetBarBorderWidth(0); $myGraphAUP->SetGraphWidth(64); //should match column width in the | above -5 pixels
$useGraph = 1;
}
// End Integration AlphaUserPoints
//karma points and buttons
if ($fbConfig->showkarma && $userinfo->userid != '0')
{
$karmaPoints = $userinfo->karma;
$karmaPoints = (int)$karmaPoints;
$msg_karma = "" . _KARMA . ": $karmaPoints";
if ($kunena_my->id != '0' && $kunena_my->id != $userinfo->userid)
{
$msg_karmaminus = CKunenaLink::GetKarmaLink('decrease', $catid, $fmessage->id, $userinfo->userid, ' ';
}
if ($userinfo->location != '') {
$msg_location = isset($fbIcons['msglocation']) ? '
","",$fb_message_txt); //$fb_message_txt = str_replace(" ","",$fb_message_txt); //$fb_message_txt = str_replace("
",$fb_message_txt);
// Code tag: restore TABS as we had to 'hide' them from the rest of the logic
$fb_message_txt = str_replace("__FBTAB__", " ", $fb_message_txt);
$fb_message_txt = smile::htmlwrap($fb_message_txt, $fbConfig->wrap);
$msg_text = CKunenaTools::prepareContent($fb_message_txt);
$signature = $userinfo->signature;
if ($signature)
{
$signature = stripslashes(smile::smileReplace($signature, 0, $fbConfig->disemoticons, $smileyList));
$signature = nl2br($signature);
//wordwrap:
$signature = smile::htmlwrap($signature, $fbConfig->wrap);
//restore the \n (were replaced with _CTRL_) occurences inside code tags, but only after we have striplslashes; otherwise they will be stripped again
//$signature = str_replace("_CRLF_", "\\n", stripslashes($signature));
$msg_signature = $signature;
}
if ($is_Moderator || (($forumLocked == 0 && $topicLocked == 0) && ($kunena_my->id > 0 || $fbConfig->pubwrite)))
{
//user is allowed to reply/quote
$msg_reply = CKunenaLink::GetTopicPostReplyLink('reply', $catid, $fmessage->id , isset($fbIcons['reply']) ? ' |
|
';
echo CKunenaLink::GetSamePageAnkerLink('forumtop', isset($fbIcons['toparrow']) ? ' | ';
if ($is_Moderator || isset($thread_reply) || isset($thread_subscribe) || isset($thread_favorite))
{
echo ''; echo ''; if ($is_Moderator) { echo ''; } echo ' | '; } echo ''; if (isset($thread_new)) { echo ''; } if (isset($thread_merge)) { echo ''; } echo ' | '; echo ''; echo $pagination; echo ' | '; echo '
|
setQuery("SELECT m.*, u.* FROM #__fb_moderation AS m LEFT JOIN #__users AS u ON u.id=m.userid WHERE m.catid={$catid}");
$modslist = $kunena_db->loadObjectList();
check_dberror("Unable to load moderators.");
?>
0)
{ ?>
userid, ($fbConfig->username ? $mod->username : $mod->name));
} ?>
|
enableforumjump) require (KUNENA_PATH_LIB .DS. 'kunena.forumjump.php'); ?> |