Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > General > Member Archives
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Latest Threads in RSS Feed (need help) Details »»
Latest Threads in RSS Feed (need help)
Version: , by Marshalus Marshalus is offline
Developer Last Online: Jul 2020 Show Printable Version Email this Page

Version: Unknown Rating:
Released: 10-29-2002 Last Update: Never Installs: 0
 
No support by the author.

OK, I digging though the bowels of the site, and stumbled apon a RSS feed hack that will pull the most recent threads from a forum you specify, and deliver them up in RSS format.

What I want to do, instead of having to specify the forum, is just have it dish out the latest threads from all forums.

Here is what I have to work with:
Code:
<?php echo '<?xml version="1.0"?>'; ?>

<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN"
             "http://my.netscape.com/publish/formats/rss-0.91.dtd">

<rss version="0.91">

  <channel>

<?php

echo "<!--\n";
require("global.php");
echo "-->\n";

	echo "<title>$bbtitle</title>\n";
	echo "<link>$bburl</link>\n";

// set defaults
if (isset($perpage)==0 or $perpage==0) {
  $perpage=$maxthreads;
}

$forumid = verifyid("forum",$forumid);


$foruminfo=$DB_site->query_first("SELECT title,description,active FROM forum WHERE forumid=$forumid");
$forumtitle=htmlspecialchars($foruminfo[title]);
if ($foruminfo[active]==0) {
  echo "<item><title>Forum Not Active</title></item></channel></rss>";
  exit;
}

$description=htmlspecialchars($foruminfo[description]);
$forumtitle=htmlspecialchars($foruminfo[title]);

$threads=$DB_site->query("SELECT threadid,title,lastpost,replycount,postusername FROM thread WHERE forumid=$forumid ORDER BY lastpost DESC LIMIT 0,$perpage");
while ($thread=$DB_site->fetch_array($threads)) {

  $threadtitle=htmlspecialchars($thread[title]);
  $threadid=$thread[threadid];

  $notes=htmlspecialchars($thread[notes]);
  $replies=$thread[replycount];
  $firstposter=htmlspecialchars($thread[postusername]);
  $lastreplydate=date($dateformat,$thread[lastpost]+($timeoffset*3600));
  $lastreplytime=date($timeformat,$thread[lastpost]+($timeoffset*3600));

 echo "<item>\n";
 echo "<title>$threadtitle</title>\n";
 echo "<link>". $bburl ."/showthread.php?threadid=$threadid</link>\n";
 echo "<description> $firstposter - $replies - $lastreplytime </description>\n";
 echo "</item>\n";

}

?>

  </channel>

</rss>
This would be very useful for programs like Trillian that can pull RSS news feeds, or for syndicating your latest threads on other websites.

Any help would be appreciated.

Show Your Support

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

Comments
  #2  
Old 10-29-2002, 10:59 PM
N!ck N!ck is offline
 
Join Date: Mar 2002
Location: Lake Havasu City, AZ
Posts: 886
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

whoa, slow down...trillian reads rss? how?
Reply With Quote
  #3  
Old 11-02-2002, 04:58 PM
Marshalus's Avatar
Marshalus Marshalus is offline
 
Join Date: Nov 2001
Location: Lawrence, KS
Posts: 135
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Trillian Pro has a plug to read RSS feed and display them on your buddy list.

Buddy List
Attached Files
File Type: (21.4 KB, 191 views)
Reply With Quote
  #4  
Old 12-13-2002, 12:46 PM
pogo's Avatar
pogo pogo is offline
 
Join Date: Oct 2001
Posts: 74
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I worked a little with you code Marshalus.
What had to be changed was the query to grab the latest active threads. My query shows only threads from non-private forums.
Then I added a replacement for german umlauts because Trillian doesn't show them correct.
You can tweak a lot to customize it further and for example insert some text from the latest post. But then you have to change the query.

PHP Code:
<?php
require("global.php");

//##############################################
// Variables used:
$description "The latest active threads";
$replyword "Replies";
$showthreadnumber "15"// show this many threads in the newsfeed
//##############################################

$search = array ("?","?","?","?","?","?","?");
$replace = array ("ue","oe","ae","Ue","Oe","Ae","ss");

header("Content-Type: text/xml");
echo 
"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
echo 
"<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns=\"http://my.netscape.com/rdf/simple/0.9/\">";
echo 
"<channel>\n";
echo 
"<title>".$bbtitle."</title>\n";
echo 
"<link>".$bburl."</link>\n";
echo 
"<description>".$description."</description>";
echo 
"</channel>\n";

$threads=$DB_site->query("SELECT threadid,title,lastpost,replycount,postusername,thread.forumid
                          FROM thread
                          LEFT JOIN forumpermission USING(forumid)
                          WHERE visible=1
                          AND forumpermission.forumid IS NULL
                          ORDER BY lastpost DESC LIMIT "
.$showthreadnumber);
while (
$thread=$DB_site->fetch_array($threads)) {
  
  
$title str_replace($search$replace$thread[title]);
  
$threadid=$thread[threadid];
  
$replies=$thread[replycount];
  
$firstposter=htmlspecialchars($thread[postusername]);
  
$lastreplydate=date($dateformat,$thread[lastpost]+($timeoffset*3600));
  
$lastreplytime=date($timeformat,$thread[lastpost]+($timeoffset*3600));

  echo 
"<item>\n";
  echo 
"<title>".htmlspecialchars($title)."</title>\n";
  echo 
"<link>$bburl/showthread.php?threadid=$threadid</link>\n";
  echo 
"<description> $firstposter - $replies $replyword - $lastreplydate $lastreplytime </description>\n";
  echo 
"</item>\n";
}

echo 
"</rdf:RDF>";

?>
Reply With Quote
  #5  
Old 02-03-2003, 08:52 PM
Highlander Highlander is offline
 
Join Date: Apr 2002
Posts: 188
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

WOW.. indeed..the best i ever saw.. .. is there any posobility .. to get read out on the same way another sql database?

what i have to to.. give me a starting point
Reply With Quote
  #6  
Old 02-23-2003, 04:59 PM
PeterNRG PeterNRG is offline
 
Join Date: Mar 2002
Location: Belgium
Posts: 22
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Any ideas how to add the first xxx characters of the first post as well, and put this as a description, based on pogo's exellent script?

I'm also looking for a way to not include the last reply features (last post name & date/time) if there is no reply yet.
Reply With Quote
  #7  
Old 02-24-2003, 08:32 AM
PeterNRG PeterNRG is offline
 
Join Date: Mar 2002
Location: Belgium
Posts: 22
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I found out that Pogo's code has a weird bug: as soon as someone starts a poll thread, the RSS script shows already the threadtitle and link, which results in a url which does not exist, as long as the creation of the poll isn't finished
Reply With Quote
  #8  
Old 02-24-2003, 09:23 AM
pogo's Avatar
pogo pogo is offline
 
Join Date: Oct 2001
Posts: 74
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally posted by PeterNRG
I found out that Pogo's code has a weird bug: as soon as someone starts a poll thread, the RSS script shows already the threadtitle and link, which results in a url which does not exist, as long as the creation of the poll isn't finished
It is not a weird bug it is just how vBulletin works. Just created threads with the option to add a poll are invisible as long as the poll is not set up.

Now I added visible=1 AND to the query and such threads are not shown anymore.


To not include the last reply line you can change the code like this:

replace:
echo "<description> $firstposter - $replies $replyword - $lastreplydate $lastreplytime </description>\n";

with:
if ($replies > 0) {
echo "<description> $firstposter - $replies $replyword - $lastreplydate $lastreplytime </description>\n";
}
Reply With Quote
  #9  
Old 02-26-2003, 12:46 PM
PeterNRG PeterNRG is offline
 
Join Date: Mar 2002
Location: Belgium
Posts: 22
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for all your help so far pogo. I have another issue which is giving me headaches: I have an announcement forum, where only admins can start new posts (being custom set with vB's forum permissions), members can reply though.

For some reason, with your code, the new announcement headlines do not show up in our RSS feed. I guess it has to do with the forumpermission in the query. Can someone help me out on that?
Reply With Quote
  #10  
Old 02-26-2003, 03:12 PM
pogo's Avatar
pogo pogo is offline
 
Join Date: Oct 2001
Posts: 74
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It's getting complicated.

Try this query instead of the above one

PHP Code:
SELECT threadid,title,lastpost,replycount,postusername,thread.forumid
                          FROM thread
                          LEFT JOIN forumpermission USING
(forumid)
                          
WHERE visible=1
                          
AND (forumpermission.forumid IS NULL OR forumpermission.canview=1)
                          
ORDER BY lastpost DESC LIMIT 
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 11:39 PM.


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.05158 seconds
  • Memory Usage 2,349KB
  • 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
  • (2)bbcode_php
  • (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
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (1)postbit_attachment
  • (10)postbit_onlinestatus
  • (10)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_postinfo_query
  • fetch_postinfo
  • 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
  • postbit_attachment
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete