vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Member Archives (https://vborg.vbsupport.ru/forumdisplay.php?f=202)
-   -   Latest Threads in RSS Feed (need help) (https://vborg.vbsupport.ru/showthread.php?t=45147)

Marshalus 10-29-2002 06:57 AM

Latest Threads in RSS Feed (need help)
 
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.

N!ck 10-29-2002 10:59 PM

whoa, slow down...trillian reads rss? how?

Marshalus 11-02-2002 04:58 PM

1 Attachment(s)
Trillian Pro has a plug to read RSS feed and display them on your buddy list.

Buddy List

pogo 12-13-2002 12:46 PM

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>";

?>


Highlander 02-03-2003 08:52 PM

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 :)

PeterNRG 02-23-2003 04:59 PM

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.

PeterNRG 02-24-2003 08:32 AM

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 :)

pogo 02-24-2003 09:23 AM

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";
}

PeterNRG 02-26-2003 12:46 PM

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?

pogo 02-26-2003 03:12 PM

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 


PeterNRG 02-27-2003 09:05 AM

It's indeed getting complicated. I can see the announement forum now, but your last query didn't work out the way I was expecting it. Instead of showing a clean list of latest threads, it shows thread titles multiple times when there have been multiple recent replies into one thread.

It looks like your last query gives a list of thread titles based on the post dates, instead of based on the last post date of a thread. So if there are 10 new posts in only 1 thread, the thread title will show up 10 times :)

We're getting close, but still no cigar :cheeky:

AlexanderT 04-15-2003 06:47 AM

1 Attachment(s)
I've taken Pogo's script and added the actual post content to it.

feed.php?mode=xxx&limit=yyy&offset=zzz

xxx can be
  • lite (default) - no post content displayed
  • full - post content displayed with html tags
  • notags - post content displayed without html tags (e.g. trillian pro requires that)
yyy can be
  • any number from 1 to 20 - shows the last 1 to 20 postings (default is 15)
zzz can be
  • your timezone offset, e.g. +2 (default is GMT)

blackice912 04-17-2003 11:09 PM

Sweet, I'm going to check this out...

UPDATE: This. Is. So. Cool.

I can read my forums in Trillian PRO! :D

AlexanderT 04-18-2003 01:37 AM

Glad you like it. Thanks to pogo for providing the whole thing :)

Gutspiller 07-03-2003 05:16 AM

Do I need a cronjob to keep this updated?

How do I get the rss file to be displayed on a website?

Is it possible only show certain forums? I have a few news forums that would be cool to have a seperate rss file. One for my forums and one for my news. Could you guys create something like that for me? Please. :)

Gutspiller 07-03-2003 05:18 AM

Do I need a cronjob to keep this updated?

How do I get the rss file to be displayed on a website?

Is it possible only show certain forums? I have a few news forums that would be cool to have a seperate rss file. One for my forums and one for my news. Could you guys create something like that for me? Please. :)

iJason 07-31-2003 06:28 AM

How exactly do I install the hack.. I installed the plugin for trillian pro, and had it point to feed.php? But nothing happens. I have feed.php in my forums dir.

iJason 07-31-2003 06:46 AM

okay well now it shows the threads.. But when I click them.. It goes here.. http:///showthread.php?threadid=1792&goto=newpost how do I fix that?

iJason 07-31-2003 07:24 AM

Okay well I got everything working.. Had to change some stuff for vb3.. Is there a way to make the threads update faster?

AlexanderT 07-31-2003 09:08 AM

This is limited to Trillian which does not allow to change the time interval for updating the feed. Maybe the soon-to-come-out-2.0 does that.

iJason 07-31-2003 09:48 AM

I found that I have to change my computers time to an hour later each time I wanted to update.. That's so lame :(

mashby 12-18-2003 02:12 PM

Has this become an official hack? I'm very interested in installing this on my board, but it's a little unclear how to install this puppy.

Any feedback would be appreciated.


All times are GMT. The time now is 04:46 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01344 seconds
  • Memory Usage 1,809KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (2)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (22)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete