I used this on vB 3.7.3 but decided to simplify it and embed it as an iframe on SHOWTHREAD. I used a meta refresh in the head instead of ajax so all you need is one php file.
Features:
- Lists 20 latest posts. Scrolls side to side.
- 112 pixels tall.
- Visited titles turn purple.
- Hover for forum name, views and replies.
Code:
<?php
//################################################################################//
// MOD NAME: VBISpy #//
//################################################################################//
// DESCRIPTION: This modification for vBulletin adds a "live" scrolling #//
// update of new posts to the forum #//
//################################################################################//
// BY: MPDev #//
// DATE: 9.26.06 #//
// VERSION: 1.0.12 #//
//################################################################################//
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// #################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT', 'vaispy');
// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();
// get special data templates from the datastore
$specialtemplates = array();
// 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');
// ######################### CONFIG VARS ############################
// The number of days to scan the table for .. (86400 represents the number of seconds in 24 hours)
$daysprune = 1;
// Do not list these forums even if they have permissions (test categories, etc)
$blockforums = "";
// ######################### CONFIG VARS ############################
$forumperms = array();
$lastpostid = (int)$_REQUEST['last'];
$subscribe = (int)$_REQUEST['subscribe'];
foreach($vbulletin->forumcache AS $forum) {
$forumid = $forum['forumid'];
$forumperms =& $vbulletin->userinfo['forumpermissions']["$forumid"];
if (!isset($vbulletin->forumcache["$forumid"]) OR !($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) OR !($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewothers']) OR !verify_forum_password($forumid, $vbulletin->forumcache["$forumid"]['password'], false))
{
$blockforums .= ','.$forum['forumid'];
}
}
unset($forum);
$datecut = "AND thread.lastpost >= " . (TIMENOW - ($daysprune * 86400));
$prefetched = null;
############################################################################
// Get Threads I've Posted In
require_once(DIR . '/includes/functions_forumdisplay.php');
$result = $db->query_read("
SELECT threadid
FROM " . TABLE_PREFIX . "thread as thread
WHERE thread.forumid NOT IN (0$blockforums) and
thread.visible = 1 and
thread.open <> 10 and
thread.lastpostid > $lastpostid
$datecut
");
$idsArray = array();
while ($id = $db->fetch_array($result))
{
$idsArray[] = $id['threadid'];
}
$dotthreads = fetch_dot_threads_array(implode(',', $idsArray));
############################################################################
// Get Threads
// Do not set to more than 20 unless you know how to modify the html at the bottom of the page (and at line 291)
$limitq = ( isset($_REQUEST['do']) ? "20" : "0,20" );
$getthreads = $db->query_read("
SELECT thread.forumid,
thread.firstpostid,
thread.lastpost,
thread.lastposter,
thread.lastpostid,
thread.replycount,
thread.threadid,
thread.title,
thread.open,
thread.views,
post.pagetext AS preview,
post.userid AS lastpuserid
FROM " . TABLE_PREFIX . "thread AS thread
LEFT JOIN " . TABLE_PREFIX . "deletionlog AS deletionlog ON (thread.threadid = deletionlog.primaryid AND type = 'thread')
LEFT JOIN " . TABLE_PREFIX . "post AS post ON (post.postid = thread.lastpostid)
WHERE open <> 10
$datecut
AND thread.forumid NOT IN (0$blockforums)
AND thread.visible = '1'
AND thread.lastpostid > $lastpostid
AND post.visible = 1
AND deletionlog.primaryid IS NULL
ORDER BY thread.lastpost DESC LIMIT $limitq
");
$row = $highestid = 1;
$rowcolor = "alt2";
while($thread = $db->fetch_array($getthreads)) {
$thread['title'] = htmlspecialchars_uni(fetch_censored_text(fetch_trimmed_title(unhtmlspecialchars($thread['title']), 85)));
$thread['date'] = vbdate($vbulletin->options['dateformat'], $thread['lastpost'], 1);
$thread['time'] = vbdate($vbulletin->options['timeformat'], $thread['lastpost']);
/* Get rid of html and bbcode first
$thread['preview'] = strip_tags(strip_bbcode($thread['preview'], true, true));
$thread['preview'] = htmlspecialchars_uni(fetch_trimmed_title($thread['preview'], 200));
$thread['preview'] = fetch_censored_text(fetch_word_wrapped_string($thread['preview'], 20));*/
$thread['replycount'] = vb_number_format($thread['replycount']);
$thread['views'] = vb_number_format($thread['views']);
$tforumid = $thread['forumid'];
$thread['forum'] = htmlspecialchars_uni($vbulletin->forumcache["$tforumid"]['title']);
// Statusicon
// show dot folder?
if ($vbulletin->userinfo['userid'] AND $vbulletin->options['showdots'] AND $dotthreads["$thread[threadid]"])
{
$thread['statusicon'] .= '_dot';
$thread['dot_count'] = $dotthreads["$thread[threadid]"]['count'];
$thread['dot_lastpost'] = $dotthreads["$thread[threadid]"]['lastpost'];
}
// show hot folder?
if ($vbulletin->options['usehotthreads'] AND (($thread['replycount'] >= $vbulletin->options['hotnumberposts'] AND $vbulletin->options['hotnumberposts'] > 0) OR ($thread['views'] >= $vbulletin->options['hotnumberviews'] AND $vbulletin->options['hotnumberviews'] > 0)))
{
$thread['statusicon'] .= '_hot';
}
// show locked folder?
if (!$thread['open'])
{
$thread['statusicon'] .= '_lock';
}
$thread['statusicon'] = $stylevar['imgdir_statusicon'] . '/thread' . $thread['statusicon'] . '.gif';
if ( $_REQUEST['do'] == "xml" )
{
$output .= <<<VAPRINT
<event>
<id>{$thread['lastpostid']}</id>
<what>$etype</what>
<when>{$thread['date']} {$thread['time']}</when>
<title>{$thread['title']}</title>
<preview>{$thread['preview']}</preview>
<poster>{$thread['lastposter']}</poster>
<threadid>{$thread['threadid']}</threadid>
<postid>{$thread['lastpostid']}</postid>
<lastpost>{$thread['lastpost']}</lastpost>
<userid>{$thread['lastpuserid']}</userid>
<forumid>{$thread['forumid']}</forumid>
<forumname>{$thread['forum']}</forumname>
<views>{$thread['views']}</views>
<replies>{$thread['replycount']}</replies>
<statusicon>{$thread['statusicon']}</statusicon>
</event>
VAPRINT;
}
else
{
/*$rowcolor = ( $rowcolor == "alt1" ? "alt2" : "alt1" );*/
$where = $clip = $poster_clip = $poster = null;
if ( stristr($etype, "thread") )
{
$post_url = "showthread.php?t={$thread['threadid']}";
}
else
{
$post_url = "showthread.php?p={$thread['lastpostid']}#post{$thread['lastpostid']}";
}
if( !$thread['title'] )
{
$clip = "<strong>Unknown</strong>";
}
else
{
$clip = "<strong><img src=\"{$thread['statusicon']}\" alt=\"\" /><a target=\"_parent\" href=\"{$post_url}\" >{$thread['title']}</a></strong>";
}
//$clip .= " ({$thread['views']} views, {$thread['replycount']} replies)";
if ( $thread['lastpuserid'] )
{
$poster_clip = "By <strong>{$thread['lastposter']}</strong>";
}
$poster_clip .= " {$thread['date']} {$thread['time']}";
if ( $thread['forum'] )
{
$where .= "In {$thread['forum']}";
$where .= " ({$thread['views']} views, {$thread['replycount']} replies)";
}
else
{
$where = "";
}
$prefetched .= <<<VAPRINT
<td><div class = "alt1" style="vertical-align:top;"> <div class="smallfont" style="padding: 3px 6px;
vertical-align:top;height:35px;" title = "$where">$clip</div></div><div class= "alt2" style="width:298px;vertical-align:bottom;"><div class ="smallfont" style="padding: 3px 6px;vertical-align:bottom;height:100%;">$poster_clip</div></div></td>\n
VAPRINT;
$row++;
if ( $thread['lastpostid'] > $highestid )
{
$highestid = $thread['lastpostid'];
}
}
}
// memory saving
unset($thread);
$db->free_result($getthreads);
if ( $_REQUEST['do'] == "xml" )
{
header( 'Content-Type: text/xml' . ($stylevar['charset'] != '' ? '; charset=' . $stylevar['charset'] : '') );
echo '<?xml version="1.0" encoding="' . $stylevar['charset'] . '"?>' . "\r\n";
if ( $output )
{
echo "<events>$output</events>";
}
else
{
echo "<events />";
}
exit;
}
/*$navbits = array();
$navbits[$parent] = 'iSpy';
$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
$navbar = process_replacement_vars($navbar);*/
eval('$headinclude = "' . fetch_template('headinclude') . '";');
$headinclude = process_replacement_vars($headinclude);
/*eval('$footer = "' . fetch_template('footer') . '";');
$footer = process_replacement_vars($footer);*/
echo<<<VAPRINT
$stylevar[htmldoctype]
<html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
<META HTTP-EQUIV="refresh" CONTENT="120;url=/forum/vaispy.php"></META>
$headinclude
<style type="text/css">
a:link {color:#22229C;} /* unvisited link */
a:visited {color:#8B008B;} /* visited link */
</style>
<title>iSpy</title>
</head>
<body style="margin:0px;" >
$output
<table class = "tborder" cellpadding="6" cellspacing="1" style="border-bottom-width:0px;" width="100%" align="center">
<thead>
<tr>
<td class="tcat">
Latest Twenty Posts
</td>
</tr>
</thead>
</table>
<div class = "tborder" style="overflow:auto; border-top-width:0px;" width="100%">
<table class = "tborder" style="border-top-width:0px; border-left-width:0px; border-right-width:0px; border-bottom-width:1px;" cellspacing="1" cellpadding ="0" align="left" >
<tr>
$prefetched
</tr>
</table>
</div>
VAPRINT;
echo $output;
?>
Just paste it in as vaispy.php under forum.
To change refresh rate change this to the number of seconds you want:
<META HTTP-EQUIV="refresh" CONTENT="120;url=/forum/vaispy.php"></META>
To change the number of posts shown change these lines:
$limitq = ( isset($_REQUEST['do']) ? "20" : "0,20" );
and
<td class="tcat">
Latest Twenty Posts
</td>
To embed it as an iframe, paste this under $navbar in SHOWTHREAD template:
HTML Code:
<if condition="$show['member']">
<iframe src ="/forum/vaispy.php" width="100%" height ="112px" frameborder="0" >
<p>Your browser does not support iframes.</p>
</iframe>
</if><br /><br />
I've left in some odds and ends that could probably be left out, specifically
/*$navbits =.....*/
/*eval('$footer =......*/
One last thing: One of our members was very suspicious when his browser was loading a file called va
ispy!