The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
vBISpy - AJAX real-time feed of new posts/threads Details »» | |||||||||||||||||||||||||||
vBISpy - AJAX real-time feed of new posts/threads
Developer Last Online: Dec 2016
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
|
Comments |
#852
|
|||
|
|||
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:
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; ?> 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">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 /> /*$navbits =.....*/One last thing: One of our members was very suspicious when his browser was loading a file called vaispy! |
#853
|
|||
|
|||
I get an error on line 254
|
#854
|
|||
|
|||
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. |
#855
|
||||
|
||||
Quote:
|
#856
|
|||
|
|||
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 |
#857
|
||||
|
||||
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 |
#858
|
|||
|
|||
<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. |
#859
|
|||
|
|||
Just installed this mod in 3.8.4 and it worked first time. Simplest install ever. Thanks OP very nice mod.
|
#860
|
||||
|
||||
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? |
#861
|
||||
|
||||
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! |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|