Código PHP:
if ($mod_options['portal_news_bbcode_attach'])
{
$bbcode_parser->attachments =& $nattachcache[$news['postid']];
}
$bbcode_parser->cached = array();
// Use the post cache
if ($mod_options['portal_news_postcache'])
{
$news['pagetext_html'] = $bbcode_parser->parse(
$news['pagetext'],
$news['forumid'],
$news['allowsmilie'],
true,
$news['pagetext_html'],
$news['hasimages'],
true
);
// Insert the parsed BB code
if ($bbcode_parser->cached['text'] AND $vbulletin->options['cachemaxage'])
{
$parsedposts .= '(
' . $news['postid'] . ',
' . TIMENOW . ',
' . intval(STYLEID) . ',
' . intval(LANGUAGEID) . ',
' . $bbcode_parser->cached['has_images'] . ',
\'' . $db->escape_string($bbcode_parser->cached['text']) . '\'
), ';
}
$news['message'] = $news['pagetext_html'];
}
else
{
$news['message'] = $bbcode_parser->do_parse(
$news['pagetext'],
$mod_options['portal_news_enablehtml'],
$news['allowsmilie'],
$mod_options['portal_news_enablevbcode'],
$mod_options['portal_news_enablevbimage']
);
$news['pagetext_html'] = $news['message'];
}
// #### Strip characters and add "read more"
if ($mod_options['portal_news_maxchars'] AND strlen($news['message']) > $mod_options['portal_news_maxchars'])
{
$trimmedlength = strrpos(substr($news['message'], 0, $mod_options['portal_news_maxchars']), ' ');
$news['message'] = substr($news['message'], 0, $trimmedlength);
// Make sure we're not cutting off in the middle of tags
// ##### <img>
$news['message'] = str_replace("<img", "<img style='border: 0;padding:5px;float:left;' width=50% height=50% " , $news['message']);
$news['message'] = str_replace("<img", "<img style='border: 0;padding:5px;float:left;' width=50% height=50% " , $news['message']);
$lastimage = strripos($news['message'], '<img');
if ($lastimage !== false)
{
$imagecheck = substr($news['message'], $lastimage);
// Don't have the end, so find it
if (strpos($imagecheck, ' />') === false)
{
$remainstring = substr($news['pagetext_html'], $trimmedlength);
$endimgpos = strpos($remainstring, ' />') + 3;
if ($endimgpos != false)
{
$news['message'] .= substr($remainstring, 0, $endimgpos);
$trimmedlength += $endimgpos;
}
}
}
// ##### <a>
$lasthref = strripos($news['message'], '<a');
if ($lasthref !== false)
{
$hrefcheck = substr($news['message'], $lasthref);
// Don't have the end, so just strip the tag
if (strpos($hrefcheck, '>') === false)
{
$news['message'] = substr($news['message'], 0, $lasthref);
$trimmedlength -= $lasthref;
}
}
// ##### <br />
$lastbr = strripos($news['message'], '<br');
if ($lastbr !== false)
{
$brcheck = substr($news['message'], $lastbr);
// Don't have the end, so add it
if (strpos($brcheck, ' />') === false)
{
$news['message'] .= ' />';
$trimmedlength += 3;
}
}
// ##### <table>
$lasttable = strripos($news['message'], '<table');
if ($lasttable !== false)
{
$tablecheck = substr($news['message'], $lasttable);
// Don't have the end, so strip the tag
if (strpos($tablecheck, '>') === false)
{
$news['message'] = substr($news['message'], 0, $lasttable);
$trimmedlength -= $lasttable;
}
}
// ##### <td>
$lasttd = strripos($news['message'], '<td');
if ($lasttd !== false)
{
$tdcheck = substr($news['message'], $lasttd);
// Don't have the end, so find it
if (strpos($tdcheck, '>') === false)
{
$remainstring = substr($news['pagetext_html'], $trimmedlength);
$endtdpos = strpos($remainstring, '>') + 1;
if ($endtdpos != false)
{
$news['message'] .= substr($remainstring, 0, $endtdpos);
$trimmedlength += $endtdpos;
}
}
}
// ##### <object>
$lastobject = strripos($news['message'], '<object');
if ($lastobject !== false)
{
$objectcheck = substr($news['message'], $lastobject);
// Don't have the end, so find it
if (strpos($objectcheck, '</object>') === false)
{
$remainstring = substr($news['pagetext_html'], $trimmedlength);
$endobjectpos = strpos($remainstring, '</object>') + 9;
if ($endobjectpos != false)
{
$news['message'] .= substr($remainstring, 0, $endobjectpos);
$trimmedlength += $endobjectpos;
}
}
}
// ##### Comment tags
$lastcom = strripos($news['message'], '<!');
if ($lastcom)
{
$comcheck = substr($news['message'], $lastcom);
// Don't have the end, so add it
if (strpos($comcheck, '-->') === false)
{
$news['message'] .= '-->';
$trimmedlength += 3;
}
}
// ##### <font>
$lastfont = strripos($news['message'], '<font');
if ($lastfont !== false)
{
$fontcheck = substr($news['message'], $lastfont);
if (strpos($fontcheck, '>') === false)
{
$news['message'] = substr($news['message'], 0, $lastfont);
$trimmedlength -= $lastfont;
}
}
// ##### Now check normal HTML tags
preg_match_all("/(<([\w]+)[^>]*>)/", $news['message'], $opentags);
preg_match_all("/(<\/([\w]+)[^>]*>)/", $news['message'], $closetags);
$opentags = array_count_values(array_reverse($opentags[2]));
$closetags = array_count_values(array_reverse($closetags[2]));
foreach ($opentags AS $otag => $value)
{
$otag = trim($otag);
switch ($otag)
{
case 'br':
case 'hr':
case 'img':
case 'param':
continue;
default:
if ($closetags[$otag] != $value)
{
for ($i = $closetags[$otag]; $i < $value; $i++)
{
$news['message'] .= '</' . $otag . '>';
}
}
}
}
$news['message'] .= '...' . construct_phrase($vbphrase['read_more'], $vbulletin->options['bburl'], $news['threadid'], $vbulletin->session->vars['sessionurl']);
}
// Edit Button
$show['editbutton'] = ((($newsforumperms[$news['forumid']] & $vbulletin->bf_ugp_forumpermissions['caneditpost']) AND $vbulletin->userinfo['userid'] == $news['userid']) OR can_moderate($news['forumid'], 'caneditposts')) ? true : false;
$show['replybutton'] = (($newsforumperms[$news['forumid']] & $vbulletin->bf_ugp_forumpermissions['canreplyothers']) AND $mod_options['portal_news_allowreplies']) ? true : false;
// ##### Attachments
if ($nattachcache[$news['postid']] AND $mod_options['portal_news_showattachments'])
{
foreach ($nattachcache[$news['postid']] AS $attachid => $attachment)
{
$attachment['filesize'] = vb_number_format($attachment['filesize'], 1, true);
($hook = vBulletinHook::fetch_hook('vba_cmps_module_newsbits_attachmentbits')) ? eval($hook) : false;
if ($attachment['hasthumbnail'] AND $vbulletin->options['attachthumbs'] AND ($newsforumperms[$news['forumid']] & $vbulletin->bf_ugp_forumpermissions['cangetattachment']) AND ($newsforumperms[$news['forumid']] & $vbulletin->bf_ugp_forumpermissions['canviewthreads']) AND $vbulletin->userinfo['showimages'])
{
$show['newwindow'] = $attachment['newwindow'];
$templater = vB_Template::create('adv_portal_newsbits_attach_thumb');
$templater->register('attachment', $attachment);
$templater->register('lightboxid', $lightboxid);
$news['attachment'] .= $templater->render();
}
else
{
$attachment['attachmentextension'] = file_extension($attachment['filename']);
$templater = vB_Template::create('adv_portal_newsbits_attach_inline');
$templater->register('attachment', $attachment);
$news['attachment'] .= $templater->render();
}
}
}
// Thread prefix
if ($news['prefixid'])
{
$news['prefix'] = $vbphrase['prefix_' . $news['prefixid'] . '_title_rich'];
}
// Icon
$blockbullet = $vba_style['portal_blockbullet'];
if ($mod_options['portal_news_showicon'])
{
$vba_style['portal_blockbullet'] = '';
if ($news['threadiconpath'])
{
$vba_style['portal_blockbullet'] = '<img alt="" border="0" src="' . $news['threadiconpath'] . '" title="' . $news['threadicontitle'] . '" class="inlineimg" />';
}
}
($hook = vBulletinHook::fetch_hook('vba_cmps_module_newsbits')) ? eval($hook) : false;
// Separate the posts
if ($mod_options['portal_news_legacy'])
{
$mods['title'] = ($news['prefix'] ? $news['prefix'] : '') . ' <a href="' . $vbulletin->options['bburl'] . '/' . fetch_seo_url('thread', $news) . '">' . $news['title'] . '</a>';
$mods['collapse'] = $newsmod['modid'] . '_' . $news['threadid'];
$show['table'] = false;
$templater = vB_Template::create('adv_portal_newsbits');
$templater->register('mod_options', $mod_options);
$templater->register('news', $news);
$templater->register('newscount', $newscount);
$templater->register('vba_style', $vba_style);
$modulehtml = $templater->render();
if ($newsmod['useshell'] & $vba_shellint['enable'])
{
if ($newsmod['useshell'] & $vba_shellint['collapse'])
{
$modcollapse = 'display: none';
$modimgcollapse = '_collapsed';
}
else
{
$modcollapse = $vbcollapse['collapseobj_module_' . $mods['collapse']];
$modimgcollapse = $vbcollapse['collapseimg_module_' . $mods['collapse']];
}
$show['divrow'] = false;
$templater = vB_Template::create($news_wrappername);
$templater->register('mods', $mods);
$templater->register('vba_style', $vba_style);
$templater->register('modulehtml', $modulehtml);
$home[$newsmod['modid']]['content'] .= $templater->render();
}
else
{
$home[$newsmod['modid']]['content'] .= $modulehtml;
}
}
// No separation
else
{
$templater = vB_Template::create('adv_portal_newsbits');
$templater->register('mod_options', $mod_options);
$templater->register('news', $news);
$templater->register('newscount', $newscount);
$templater->register('vba_style', $vba_style);
$newsbits .= $templater->render();
}
$vba_style['portal_blockbullet'] = $blockbullet;
}
// ##### News Archive
else if ($archivemod['modid'])
{
$mods['modcol'] = $archivemod['modcol'];
if ($mods['modcol'] != 1)
{
$bgclass = exec_switch_bg();
}
if (strlen($news['title']) > $mod_options['portal_archive_maxchars'] AND $mod_options['portal_archive_maxchars'])
{
$news['title'] = fetch_trimmed_title($news['title'], $mod_options['portal_archive_maxchars']);
}
// Attach paperclip
if (!$mod_options['portal_archive_attachpaperclip'])
{
$news['attach'] = 0;
$show['paperclip'] = 0;
}
($hook = vBulletinHook::fetch_hook('vba_cmps_module_news_archivebits')) ? eval($hook) : false;
$templater = vB_Template::create('adv_portal_archivebits_' . $archive_tempname);
$show['table'] = ($archive_tempname == 'exp');
$templater->register('mod_options', $mod_options);
$templater->register('news', $news);
$templater->register('vba_style', $vba_style);
$newsarchivebits .= $templater->render();
}
}
$vbulletin->options['viewattachedimages'] = $origsettings_viewattachedimages;
$vbulletin->options['attachthumbs'] = $origsettings_attachthumbs;
$db->free_result($getnews);
// ##### Archive (module shell)
if ($archivemod['modid'] AND ($archivemod['useshell'] & $vba_shellint['enable']) AND $newsarchivebits)
{
$mods['link'] = '';
if ($archivemod['link'])
{
eval('$mods[\'link\'] = "' . addslashes($archivemod['link']) . '";');
}
$mods['colspan'] = $archivemod['colspan'];
$mods['title'] = $archivemod['title'];
$mods['collapse'] = $archivemod['modid'];
if ($archivemod['useshell'] & $vba_shellint['collapse'])
{
$modcollapse = 'display: none';
$modimgcollapse = '_collapsed';
}
else
{
$modcollapse = $vbcollapse['collapseobj_module_' . $archivemod['modid']];
$modimgcollapse = $vbcollapse['collapseimg_module_' . $archivemod['collapse']];
}
$modulehtml =& $newsarchivebits;
$templater = vB_Template::create($archive_wrappername);
$templater->register('mods', $mods);
$templater->register('modulehtml', $modulehtml);
$templater->register('vba_style', $vba_style);
$home[$archivemod['modid']]['content'] = $templater->render();
}
else if ($archivemod['modid'])
{
$home[$archivemod['modid']]['content'] =& $newsarchivebits;
}
// ##### Process news module if not splitting posts and we have no module shell
if ($newsbits AND !$mod_options['portal_news_legacy'])
{
$mods['modcol'] = $newsmod['modcol'];
$mods['colspan'] = $newsmod['colspan'];
$mods['title'] = $newsmod['title'];
$mods['collapse'] = $newsmod['modid'];
$modcollapse = $vbcollapse['collapseobj_module_' . $newsmod['modid']];
$modimgcollapse = $vbcollapse['collapseimg_module_' . $newsmod['modid']];
$show['divrow'] = false;
$show['table'] = false;
$modulehtml = $newsbits;
if ($newsmod['useshell'])
{
$templater = vB_Template::create($news_wrappername);
$templater->register('mods', $mods);
$templater->register('vba_style', $vba_style);
$templater->register('modulehtml', $modulehtml);
$home[$newsmod['modid']]['content'] = $templater->render();
}
else
{
$home[$newsmod['modid']]['content'] = $modulehtml;
}
}
// ##### Lightbox stuff
if ($vbulletin->options['lightboxenabled'])
{
if (!defined('lightbox_js'))
{
$headinclude .= "\r\n<script type=\"text/javascript\" src=\"" . $vbulletin->options['bburl'] . '/clientscript/vbulletin_lightbox.js?v=' . $vbulletin->options['simpleversion'] . '"></script>';
define('lightbox_js', true);
}
$home[$newsmod['modid']]['content'] = '<div id="vba_news' . $newsmod['modid'] . '">' . $home[$newsmod['modid']]['content'] . '</div>
<script type="text/javascript">
<!--
vBulletin.register_control("vB_Lightbox_Container", "vba_news' . $newsmod['modid'] . '", ' . $vbulletin->options['lightboxenabled'] . ');
//-->
</script>';
}
// ##### Pagination
if ($mod_options['portal_news_threadsperpage'] AND (($newsrows >= ($mod_options['portal_news_maxposts'] + $mod_options['portal_news_enablearchive'])) OR $vbulletin->GPC[$newspagevar]))
{
$vba_news_where = 'visible = 1 AND open != 10';
if (!empty($mod_options['portal_threadids']))
{
$vba_news_where .= ' AND (threadid IN(' . implode(',', $newstids) . ')';
}
if (!empty($mods['inforums']))
{
$vba_news_where .= iif(!empty($mod_options['portal_threadids']), ' OR', ' AND') . ' forumid IN(' . implode(', ', $mods['inforums']) . ')';
}
if (!empty($mod_options['portal_threadids']))
{
$vba_news_where .= ')';
}
if ($mod_options['portal_news_cutoffdate'])
{
$vba_news_where .= ' AND dateline > ' . (TIMENOW - ($mod_options['portal_news_cutoffdate'] * 86400));
}
if ($ignusers)
{
$vba_news_where .= ' AND postuserid NOT IN(' . $ignusers . ')';
}
if ($mod_options['portal_applypermissions'])
{
$vba_news_where .= $forumperms_query;
}
$newscount = $db->query_first("
SELECT COUNT(*) AS count
FROM " . TABLE_PREFIX . "thread
WHERE $vba_news_where
");
$oldshowpopups = $show['popups'];
$show['popups'] = false;
$newspagenav = construct_page_nav(
max($vbulletin->GPC[$newspagevar], 1),
$mod_options['portal_news_maxposts'],
min($newscount['count'], ($mod_options['portal_news_maxposts'] * $mod_options['portal_news_threadsperpage'])),
$vba_options['portal_homeurl'] . '?' . $vba_options['portal_pagevar'] . '=' . $pages['name']
);
$show['popups'] = $oldshowpopups;
$home[$newsmod['modid']]['content'] .= '<div style="padding-bottom: ' . $vba_style['portal_vspace'] . 'px" class="floatcontainer">' . str_replace(
'&page=',
'&' . $newspagevar . '=',
$newspagenav
) . '</div>';
}
// Post cache
if ($parsedposts)
{
$db->query_write("
REPLACE INTO " . TABLE_PREFIX . "postparsed
(postid, dateline, styleid, languageid, hasimages, pagetext_html)
VALUES
" . substr($parsedposts, 0, (strlen($parsedposts) - 2))
);
}
}
$foruminfo['allowratings'] = $oldforumratings;
unset($newsbits, $newsarchivebits, $news);
// reset the $mods variable
if ($currentmodule == 'archive' AND !empty($archivemod))
{
$mods = $archivemod;
}
else if ($currentmodule == 'archive' AND !empty($newsmod))
{
$mods = $newsmod;
}
if ($mod_options['portal_news_showavatar'] AND $vbulletin->templatecache['bbcode_quote_printable'])
{
$vbulletin->templatecache['bbcode_quote'] = $default_quote_template;
}
}
$mods['noshell'] = true;
?>