Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.6 > vBulletin 3.6 Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
vBISpy - AJAX real-time feed of new posts/threads Details »»
vBISpy - AJAX real-time feed of new posts/threads
Version: 1.12, by MPDev MPDev is offline
Developer Last Online: Dec 2016 Show Printable Version Email this Page

Category: Add-On Releases - Version: 3.6.x Rating:
Released: 09-05-2006 Last Update: 09-27-2006 Installs: 947
Additional Files  
No support by the author.

After seeing the http://www.digg.com/spy application; I wondered if this could be done for vBulletin as well. I came across this webpage which had a "how to" on how they built a similiar application to do the same thing. Taking a page from their book (i.e. the code), I modified it for use with vBulletin.

During development, I also came across this post here on vBulletin.Org where the very subject had already been discussed.

So I put this together; a simple ZIP file with a single PHP script, three javascript files and 4 images.

Installation

. UNZIP the file into your forums directory
. That's it!

Virtually all the code to customize the page is in the vaispy.php script; there are no plugins, no templates and no phrases. You do not need to do anything further; this should work right out of the box.

In your browser, open the URL:

http://www.yourforum.com/forum/vaispy.php

You can see examples of this at:

http://www.viperalley.com/forum/vaispy.php
http://www.extremefitness.com/forum/vaispy.php

Note: I claim no ownership of this code except for the file vaispy.php - the rest of the files were using 'freely distributable' sources. As such, you may use these files as you wish, but please do not remove the copyrights.

This modification is for vBulletin 3.6 only, if you are running vBulletin 3.5 you will need to see this thread.

JOIN THE vBIspy Network!
Once you have this mod installed, you can join the vBIspy network to have your threads appear on this site; the vBIspy Network is a great way for people to see what's going on in various vBulletin communities and for forum owners to promote their sites and generate new traffic.

Optional add-ons

Who's Online mod for this: https://vborg.vbsupport.ru/showthread.php?t=126209

vBAdvanced Module: https://vborg.vbsupport.ru/showthread.php?t=126421

UPDATES
1.0.4
Added buro9's code from here

1.0.5 - 9.9.06
Modified some JavaScript in va_spy.js to remove split strings

1.0.6 - 9.10.06
Added date cuffoff code from here and changed init() to spyinit() - changed vaispy.php and va_spy.js files.

1.0.7 - 9.12.06
va_spy.js: Added a forum url variable to allow for integration with portals or other products outside the forum directory
va_spy.js: Added xmldelay variable at top of script for easier configuration or repolling
Updated files: vaispy.php, vb_spy.js

1.0.8 - 9.13.06
vaispy.php - changed code for checking for forum permissions to include password protected forums, added javascript tag for script code

1.0.9 - 9.16.06
vaispy.php
va_spy.js
va_effects.js
- modified to allow for proper display in Opera browsers and moved more html into vaispy.php to allow for stylevars, trimmed va_effects.js to remove unused code (ForumDog's suggestions, except not using templates yet), changed way threads are parsed (removes html as well)

1.0.10 - 9.17.06
va_prototype.js - removed 20kb of unused code

1.1.11 - 9.25.2006
vaispy.php
va_spy.js
- added SirAdrian's mods for thread status icons and alternating row colors
- added code to prepopulate the first 10 rows with existing threads allowing for 5 new ones to be added in scrolling mode (versus scrolling starting from the first thread).
- added option to display subscribed threads only

1.1.12 - 9.26.2006
vaispy.php
- added code to add empty rows if initial pull has less than 20 rows.

Supporters / CoAuthors

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #852  
Old 05-24-2010, 05:53 PM
nerbert nerbert is offline
 
Join Date: May 2008
Posts: 784
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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 vaispy!
Reply With Quote
  #853  
Old 05-24-2010, 09:02 PM
grey_goose grey_goose is offline
 
Join Date: Jun 2009
Posts: 284
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I get an error on line 254
Reply With Quote
  #854  
Old 05-24-2010, 09:22 PM
nerbert nerbert is offline
 
Join Date: May 2008
Posts: 784
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That's exactly as I have it on my forum and it works. What does the error text say and do you know which is line 254?

EDIT: Is the error in vaispy or showthread? If in showthread do you already have the original version of vaispy working? If so rename the original one "vaispy_original.php"

EDIT 2: I put this in notepad and found line 254:


header( 'Content-Type: text/xml' . ($stylevar['charset'] != '' ? '; charset=' . $stylevar['charset'] : '') );

Maybe a real coder can help.
Reply With Quote
  #855  
Old 05-25-2010, 03:50 AM
Eric's Avatar
Eric Eric is offline
 
Join Date: May 2006
Location: Kentucky
Posts: 792
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by nerbert View Post
That's exactly as I have it on my forum and it works. What does the error text say and do you know which is line 254?

EDIT: Is the error in vaispy or showthread? If in showthread do you already have the original version of vaispy working? If so rename the original one "vaispy_original.php"

EDIT 2: I put this in notepad and found line 254:


header( 'Content-Type: text/xml' . ($stylevar['charset'] != '' ? '; charset=' . $stylevar['charset'] : '') );

Maybe a real coder can help.
There are no errors in the file.
Reply With Quote
  #856  
Old 05-27-2010, 02:36 AM
nerbert nerbert is offline
 
Join Date: May 2008
Posts: 784
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I edited my version of vaispy to fix some things that one of my forum members pointed out. If you have already copied the file make the following edits:

find:
<div class = "tborder" style="overflow:auto; border-top-width:0px;" width="100%;">
and remove the ";"

find:
<body style="margin:0px;" onload="spyinit();">
and remove "onload="spyinit();""

The latter may cause problems in older versions of IE
Reply With Quote
  #857  
Old 06-06-2010, 02:10 AM
mavherzog's Avatar
mavherzog mavherzog is offline
 
Join Date: Dec 2004
Location: Columbus, WI
Posts: 42
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I use this with 3.8.5 and it works great. However, I have an issue with a wiki mod I have in place.

In a nutshell, I need to add "&do=comments" to the showthread link that is generated. I edited the script, changing the $post_url definition appropriately. This works for the initial "static" entries that show up when the script is first loaded, but the subsequent entries that load from the top don't seem to be generated from the $post_url variable.

I'm at a loss as to where to fix this.

EDIT: Just found where to edit it in va_spy.js
Reply With Quote
  #858  
Old 06-06-2010, 08:59 PM
Floris Floris is offline
 
Join Date: Jan 2002
Posts: 1,898
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

<div class = "tborder" style="overflow:auto; border-top-width:0px;" width="100%;">
and remove the ";"

The ; is optional, and doens't fix an issue, it's non exist.

It works with and without the last ;

style="this:that"
or
style="this:that;"

the ; is there by default, and without it, is just more short hand.

the ; must actually be there, if you add more ..

style="this:that; anotherne;"
is the same as
style="this:that; anotherne"

Just saying

It doesn't cause bugs, nor fix them.
Reply With Quote
  #859  
Old 06-14-2010, 04:32 AM
Zylantex Zylantex is offline
 
Join Date: Sep 2009
Location: France
Posts: 170
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Just installed this mod in 3.8.4 and it worked first time. Simplest install ever. Thanks OP very nice mod.
Reply With Quote
  #860  
Old 07-15-2010, 11:17 PM
DieselMinded's Avatar
DieselMinded DieselMinded is offline
 
Join Date: Mar 2007
Posts: 1,655
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Working on 3.8.6

http://www.dieselbombers.com/vaispy.php

I added my chatroom and some google ads

Anyone know how to make it parse smilies and show avatars?
Reply With Quote
  #861  
Old 07-16-2010, 12:14 AM
Taurus1's Avatar
Taurus1 Taurus1 is offline
 
Join Date: Dec 2009
Posts: 648
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Same here, works great on 3.8.6
Have been using it for a very long time. Can't go without it....lol

I have one question though, it does not seem to work with LiteSpeed. Does anyone have a fix for that. Thanks!
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:29 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05257 seconds
  • Memory Usage 2,347KB
  • Queries Executed 26 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)bbcode_code
  • (1)bbcode_html
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (2)pagenav_pagelinkrel
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete