Kod php:
<?php
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'tabsample1'); // change this to the filename
// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();
// get special data templates from the datastore
$specialtemplates = array('iconcache');
// pre-cache templates used by all actions
$globaltemplates = array();
// pre-cache templates used by specific actions
$actiontemplates = array();
// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
require_once('./includes/vba_cmps_global.php');
require_once('./includes/functions_forumdisplay.php');
// ############# MODIFICATION CONTROL OPTIONS ############################
$mod_options['portal_threads_forumid'] = '21,43,44'; // Add the forumid(s) you would like to display threads from in your news module. Seperate each with a comma.
$mod_options['portal_threads_maxthreads'] = '10'; // Set this for the Max Number of Threads to Display.
$mod_options['portal_threads_maxchars'] = '30'; // Set This for the Max Number of Characters you want to Display for the Thread Title.
$mod_options['portal_threads_cutoffdate'] = '360'; // Enter a number of days that represents a threshold for recent threads.
$mod_options['portal_threads_orderby'] = ''; // thread.dateline
$mod_options['portal_threads_orderby'] = 'lastpost'; // if you want Ramdom replace with: RAND()
$mod_options['portal_threads_direction'] = 'DESC'; //
$mod_options['portal_threads_showicon'] = '0'; // 1=ON 0=OFF
// ## DO NOT EDIT BELOW THIS POINT UNLESS YOU KNOW EXACTLY WHAT YOU ARE DOING ##
// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################
$show['lastpost'] = $mod_options['portal_threads_lastpost'];
$markinglimit = (TIMENOW - ($vbulletin->options['markinglimit'] * 86400));
$forumids = array($mod_options['portal_threads_forumid']);
// Set the last visit date to the marking limit so new threads will not be based on individual cookie
if ($pages['name'] == 'home' AND !$vbulletin->userinfo['userid'] AND $vba_options['portal_guestcache'])
{
$vbulletin->userinfo['lastvisit'] = $markinglimit;
}
// Database read marking
if ($vbulletin->options['threadmarking'] AND $vbulletin->userinfo['userid'])
{
$rthread_fields .= ', threadread.readtime AS threadread, forumread.readtime AS forumread';
$rthread_join .= ' LEFT JOIN ' . TABLE_PREFIX . 'threadread AS threadread ON (threadread.threadid = thread.threadid AND threadread.userid = ' . $vbulletin->userinfo['userid'] . ') LEFT JOIN ' . TABLE_PREFIX . 'forumread AS forumread ON (thread.forumid = forumread.forumid AND forumread.userid = ' . $vbulletin->userinfo['userid'] . ')';
}
// MAIN SQL
$threads = $db->query_read("
SELECT $rtrating_fields thread.threadid, thread.title, thread.replycount, postusername, postuserid, thread.dateline AS postdateline, IF(views <= thread.replycount, thread.replycount+1, views) AS views, thread.lastposter, thread.lastpost, thread.lastpostid, pollid, thread.forumid, thread.open, sticky, post.pagetext AS preview, thread.iconid AS threadiconid, iconpath AS threadiconpath $rthread_fields
FROM " . TABLE_PREFIX . "thread as thread
LEFT JOIN " . TABLE_PREFIX . "post AS post ON (post.postid = thread.firstpostid)
LEFT JOIN " . TABLE_PREFIX . "icon AS icon ON (icon.iconid = thread.iconid)
$rthread_join
WHERE open != 10
AND thread.visible = 1 " .
iif($mod_options['portal_threads_cutoffdate'], 'AND thread.lastpost > ' . (TIMENOW - $mod_options['portal_threads_cutoffdate'] * 86400)) .
iif($ignusers, ' AND thread.postuserid NOT IN(' . $ignusers . ')') . "
AND thread.forumid IN(" . implode(',', $forumids) . ")
ORDER BY $mod_options[portal_threads_orderby] $mod_options[portal_threads_direction]
LIMIT $mod_options[portal_threads_maxthreads]
");
$mods['threadcount'] = $db->num_rows($threads);
// CONTENT HEADER OUTPUT (echos out Table Header into Tab Div Container)
echo '<table border="0" cellpadding="6" cellspacing="1" class="tborder" width=100%>
<tr>
<td class="thead" width="2%"> </td>
<td class="thead" width="50%">Title, Username, Date</td>
<td class="thead" width="25%" align="center" style="white-space: nowrap" >Last Post</td>
<td class="thead" width="2%">Replies</td>
<td class="thead" width="2%" align="center">Views</td>
</tr>';
// CONTENT LOOP (Loops through each result set created by the MAIN SQL)
while ($thread = $db->fetch_array($threads))
{
$bgclass = exec_switch_bg();
// The vB preview function can be intensive w/ long strings, so let's try to save some overhead
$thread['preview'] = substr($thread['preview'], 0, ($vbulletin->options['threadpreview'] * 10));
// Trim title
if (strlen($thread['title']) > $mod_options['portal_threads_maxchars'] AND $mod_options['portal_threads_maxchars'])
{
$thread['title'] = fetch_trimmed_title($thread['title'], $mod_options['portal_threads_maxchars']);
}
// Check for long words that may stretch the page
if ($mod_options['portal_threads_maxwordchars'])
{
$thread['titlecheck'] = explode(' ', $thread['title']);
if (!empty($thread['titlecheck']))
{
$thread['title'] = '';
foreach ($thread['titlecheck'] AS $key => $word)
{
if (!$thread['titletrimmed'])
{
if (strlen($word) > $mod_options['portal_threads_maxwordchars'])
{
$word = fetch_trimmed_title($word, $mod_options['portal_threads_maxwordchars']);
$thread['titletrimmed'] = true;
}
if ($thread['title'])
{
$thread['title'] .= ' ';
}
$thread['title'] .= $word;
}
}
}
}
// Thread read marking
if ($vbulletin->options['threadmarking'] AND $vbulletin->userinfo['userid'])
{
if ($thread['threadread'] < $thread['forumread'])
{
$thread['threadread'] = $thread['forumread'];
}
}
// Check the cookie, but only if guest caching is not enabled
else if (!$vb_read_cookies[$thread['forumid']])
{
if ($vbulletin->userinfo['userid'] OR !$vba_options['portal_guestcache'] OR $pages['name'] != 'home')
{
$vb_read_cookies[$thread['forumid']] = max(fetch_bbarray_cookie('forum_view', $thread['forumid']), $markinglimit);
}
else
{
$vb_read_cookies[$thread['forumid']] = $markinglimit;
}
}
if (!$thread['threadread'] AND ($vb_read_cookies[$thread['forumid']] >= $thread['lastpost'] OR $markinglimit > $thread['lastpost']))
{
$thread['threadread'] = TIMENOW;
}
else if (!$vbulletin->options['threadmarking'])
{
$thread['threadread'] = '-1';
}
$thread = process_thread_array(
$thread,
$thread['threadread'],
$mod_options['portal_threads_showicon']
);
// CONTENT OUTPUT (echos out each individual recent thread result into Tab Div Container)
echo '<tr>';
if (!$thread[threadiconpath])
{
echo '<td class="alt2"> </td>';
}
else
{
echo '<td class="alt2"><img alt="" border="0" src="' . $thread[threadiconpath] . '" title="' . $thread[threadicontitle] . '" /></td>';
}
echo '<td class="alt1" class="smallfont" width="50%">';
if ($show[gotonewpost])
{
echo '<a href="showthread.php?t=' . $thread[threadid] . '"title="' . $thread[preview] . '"><strong>' . $thread[title] . '</strong></a>';
}
else
{
echo '<a href="showthread.php?t=' . $thread[threadid] . '"title="' . $thread[preview] . '"><i>' . $thread[title] . '</i></a>';
}
echo '<br />' . $thread['postusername'] . '<br /><div class="smallfont">' . $thread[postdate] . ' <span class="time">' . $thread[posttime] . '</span></div></td>';
echo '<td class="alt2" width="20%"><div class="smallfont" style="text-align:right; white-space:nowrap">' . $thread[lastpostdate] . ' <span class="time">' . $thread[lastposttime] . ' </span> <br />by <a href="member.php?find=lastposter&t=' . $thread[threadid] . '">' . $thread[lastposter] . '</a> <a href="showthread.php?p=' . $thread[lastpostid] . '#post' . $thread[lastpostid] . '"><img border="0" src="images/buttons/lastpost.gif" title="Go To Last Post" /></a></div></td>';
echo '<td align="center" class="alt1" width="2%"> <span class="smallfont">' . $thread[replycount] . ' </span></td>';
echo '<td align="center" class="alt2" width="2%"> <span class="smallfont">' . $thread[views] . '</span></td>';
echo '</tr>';
}
$db->free_result($threads);
unset($thread);
echo '</table>';
?>