rss

Installatie lukt niet? Plotseling een foutmelding. Of weet je niet hoe iets werkt. Problemen met phpBB2 kun je in dit archief opzoeken.
Forumregels

Sinds 1 januari 2009 wordt phpBB2 niet meer ondersteund.
Onderstaande informatie is verouderd en dient uitsluitend als archief.
phpBB2.0.x
Gesloten
debrouwer
Berichten: 20
Lid geworden op: 29 sep 2006, 22:23
Locatie: Amsterdam
Contacteer:

rss

Bericht door debrouwer » 17 feb 2008, 02:49

hallo,
ik heb hieronder een rss feed code staan, en opzich werkt hij, alleen nu is de vraag !!!
weet iemand hoe je het voor elkaar krijgt om alle topics te tonen ook namelijk de topics waarvoor je moet zijn ingelogt? het gaat mij hier om ik heb een rss reader op mijn website staan en daarin wil ik de laatste 5 topics laten vertonen dus als ware alleen de titels van de topics en zodra je erop klikt dat je dan pas moet inloggen op het forum voor de gehele topic te kunnen lezen.
kan iemand mij hierbij helpen?

Code: Selecteer alles

<?php
/***************************************************************************
 *                                rss.php
 *                            -------------------
 *   begin                : Saturday, Feb 13, 2001
 *   copyright            : (C) 2005 by Lucas van Dijk
 *   email                : lucas@aoe3capitol.nl
 *
 *   $Id: rss.php,v 1.0.3 2004/07/11 16:46:15 mrlucky Exp $
 *
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

define('IN_PHPBB', 1);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
include($phpbb_root_path.'includes/functions_post.'.$phpEx);
include($phpbb_root_path.'includes/bbcode.'.$phpEx);

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//

// -------
// Begin Page specific functions
//
function make_xml_compatible($text, $bbcode_uid = '', $use_bbcode = 0)
{
        global $board_config, $base_url;

        if($use_bbcode)
        {
                if($bbcode_uid != '')
                {
                        $text = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($text, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $text);
                }
                else
                {
                        $text = preg_replace('/\:[0-9a-z\:]+\]/si', ']', $text);
                }
                $text = make_clickable($text);
                if($board_config['allow_smilies'])
                {
                        $text = smilies_pass($text);
                        $text = str_replace("./".$board_config['smilies_path'], $base_url.$board_config['smilies_path'], $text);
                }
        }
        $text = nl2br($text);

        $text = str_replace('&pound', '&#163;', $text);
        $text = str_replace('&copy;', '(c)', $text);

        $text = htmlspecialchars($text);

        return $text;
}
//
// End page specific functions
// ------

//
// Get Various vars
//
$forum = isset($HTTP_GET_VARS[POST_FORUM_URL]) && ctype_digit($HTTP_GET_VARS[POST_FORUM_URL]) ? $HTTP_GET_VARS[POST_FORUM_URL] : false;
$topic = isset($HTTP_GET_VARS[POST_TOPIC_URL]) && ctype_digit($HTTP_GET_VARS[POST_TOPIC_URL]) ? $HTTP_GET_VARS[POST_TOPIC_URL] : false;
$post = isset($HTTP_GET_VARS[POST_POST_URL]) && ctype_digit($HTTP_GET_VARS[POST_POST_URL]) ? $HTTP_GET_VARS[POST_POST_URL] : false;

$base_url = ($board_config['cookie_secure'] ? "https://" : "http://").$HTTP_SERVER_VARS['HTTP_HOST'].dirname($HTTP_SERVER_VARS['PHP_SELF']);

if(substr($base_url, -1) != "/")
{
        $base_url .= "/";
}

//
// Get topic ID by post id
//
if($post)
{
        $sql = "SELECT topic_id
                FROM ".POSTS_TABLE."
                WHERE post_id = ".intval($post);
        if(!$result = $db->sql_query($sql))
        {
                message_die(GENERAL_ERROR, "Could not get topic id by post id", '', __LINE__, __FILE__, $sql);
        }

        $row = $db->sql_fetchrow($result);

        $topic = $row['topic_id'];
}

//
// Start RSS output
//
$rss_result = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>
<rss version=\"2.0\">
<channel>
  <title>".make_xml_compatible($board_config['sitename'])."</title>
  <link>".$base_url."index.".$phpEx."</link>
  <description>".make_xml_compatible($board_config['site_desc'])."</description>
  <language>".$board_config['default_lang']."</language>
  <copyright>(c) Copyright ".create_date("Y", time(), $board_config['board_timezone'])." by ".make_xml_compatible($board_config['sitename'])."</copyright>
  <managingEditor>".$board_config['board_email']."</managingEditor>
  <webMaster>".$board_config['board_email']."</webMaster>
  <pubDate>".create_date($board_config['default_dateformat'], time(), $board_config['board_timezone'])."</pubDate>
  <lastBuildDate>".create_date($board_config['default_dateformat'], time(), $board_config['board_timezone'])."</lastBuildDate>
  <docs>http://backend.userland.com/rss</docs>
  <generator>phpBB2 RSS Syndication Mod by Lucas</generator>
  <ttl>1</ttl>

  <image>
    <title>".make_xml_compatible($board_config['sitename'])."</title>
    <url>".$board_config['rss_image']."</url>
    <link>".$base_url."</link>
    <description>".make_xml_compatible($board_config['site_desc'])."</description>
  </image>
";

//
// Get latest topics
//
if(!$topic && !$forum)
{
        //
        // This SQL Code selects the latest topics on he forum
        //
        $sql = "SELECT t.topic_title, t.topic_last_post_id, t.forum_id, p.post_time, pt.post_text, pt.bbcode_uid, u.username, u.user_id
                FROM ".TOPICS_TABLE." t, ".POSTS_TABLE." p, ".POSTS_TEXT_TABLE." pt, ".USERS_TABLE." u
                WHERE t.topic_status != 1
                AND p.post_id = t.topic_last_post_id
                AND pt.post_id = p.post_id
                AND u.user_id = p.poster_id
                ORDER BY t.topic_last_post_id DESC
                LIMIT 0, ".intval($board_config['max_rss_topics']);
        if(!$result = $db->sql_query($sql))
        {
                message_die(GENERAL_ERROR, "Could not get Latest topics", '', __LINE__, __FILE__, $sql);
        }

        while($row = $db->sql_fetchrow($result))
        {
                $is_auth = array();
                $is_auth = auth(AUTH_ALL, $row['forum_id'], $userdata);
                if($is_auth['auth_view'] && $is_auth['auth_read'])
                {
                        $description = "
                                      <b>".$lang['Author'].":</b> <a href='".$base_url."profile.".$phpEx."?mode=viewprofile&".POST_USERS_URL."=".$row['user_id']."'>".$row['username']."</a><br />
                                      <b>".$lang['Posted'].":</b> ".create_date($board_config['default_dateformat'], $row['post_time'], $board_config['board_timezone'])."<br />
                                      <br />
                                      ".$row['post_text'];

                        $rss_result .= "
                                      <item>
                                        <title>".make_xml_compatible(strip_tags($row['topic_title']))."</title>
                                        <link>".$base_url."viewtopic.".$phpEx."?".POST_POST_URL."=".$row['topic_last_post_id']."#".$row['topic_last_post_id']."</link>
                                        <description>".make_xml_compatible($description, $row['bbcode_uid'], true)."</description>
                                        <comments>".$base_url."viewtopic.".$phpEx."?".POST_POST_URL."=".$row['topic_last_post_id']."#".$row['topic_last_post_id']."</comments>
                                        <author>".make_xml_compatible($row['username'])."</author>
                                        <pubDate>".create_date($board_config['default_dateformat'], $row['post_time'], $board_config['board_timezone'])."</pubDate>
                                        <guid isPermaLink=\"true\">".$base_url."viewtopic.".$phpEx."?".POST_POST_URL."=".$row['topic_last_post_id']."#".$row['topic_last_post_id']."</guid>
                                      </item>";
                }
        }
}

if($topic && !$forum)
{
        //
        // This SQL query selects the latest posts of a topic
        //
        $sql = "SELECT p.post_id, p.post_time, pt.post_text, pt.bbcode_uid, pt.post_subject, t.topic_title, t.forum_id, u.username, u.user_id
                FROM ".POSTS_TABLE." p, ".POSTS_TEXT_TABLE." pt, ".TOPICS_TABLE." t, ".USERS_TABLE." u
                WHERE p.topic_id = ".intval($topic)."
                AND pt.post_id = p.post_id
                AND t.topic_id = p.topic_id
                AND u.user_id = p.poster_id
                ORDER BY p.post_time DESC
                LIMIT 0, ".intval($board_config['max_rss_topics']);
        if(!$result = $db->sql_query($sql))
        {
                message_die(GENERAL_ERROR, "Could not get Latest posts", '', __LINE__, __FILE__, $sql);
        }

        $auth_loaded = false;

        while($row = $db->sql_fetchrow($result))
        {
                if(!$auth_loaded)
                {
                        $is_auth = array();
                        $is_auth = auth(AUTH_ALL, $row['forum_id'], $userdata);
                        $auth_loaded = true;
                }
                if($is_auth['auth_view'] && $is_auth['auth_read'])
                {
                        $description = "
                                      ".$lang['Author'].": <a href='".$base_url."profile.".$phpEx."?mode=viewprofile&".POST_USERS_URL."=".$row['user_id']."'>".$row['username']."</a><br />
                                      ".$lang['Posted'].": ".create_date($board_config['default_dateformat'], $row['post_time'], $board_config['board_timezone'])."<br />
                                      <br />
                                      ".$row['post_text'];

                        $rss_result .= "
                                      <item>
                                        <title>".make_xml_compatible(strip_tags(($row['post_subject'] != '' ? $row['post_subject'] : "Re: ".$row['topic_title'])))."</title>
                                        <link>".$base_url."viewtopic.".$phpEx."?".POST_POST_URL."=".$row['post_id']."#".$row['post_id']."</link>
                                        <description>".make_xml_compatible($description, $row['bbcode_uid'], true)."</description>
                                        <comments>".$base_url."viewtopic.".$phpEx."?".POST_POST_URL."=".$row['post_id']."#".$row['post_id']."</comments>
                                        <author>".make_xml_compatible($row['username'])."</author>
                                        <pubDate>".create_date($board_config['default_dateformat'], $row['post_time'], $board_config['board_timezone'])."</pubDate>
                                        <guid isPermaLink=\"true\">".$base_url."viewtopic.".$phpEx."?".POST_POST_URL."=".$row['post_id']."#".$row['post_id']."</guid>
                                      </item>";
                }
        }
}

if($forum && !$topic)
{
        //
        // This SQL query selects the latest topics of a specific forum
        //
        $sql = "SELECT t.topic_title, t.topic_last_post_id, p.post_time, pt.post_text, pt.bbcode_uid, u.username, u.user_id
                FROM ".TOPICS_TABLE." t, ".POSTS_TABLE." p, ".POSTS_TEXT_TABLE." pt, ".USERS_TABLE." u
                WHERE t.forum_id = ".intval($forum)."
                AND t.topic_status != 1
                AND p.post_id = t.topic_last_post_id
                AND pt.post_id = p.post_id
                AND u.user_id = p.poster_id
                ORDER BY t.topic_last_post_id DESC
                LIMIT 0, ".intval($board_config['max_rss_topics']);
        if(!$result = $db->sql_query($sql))
        {
                message_die(GENERAL_ERROR, "Could not get Latest topics", '', __LINE__, __FILE__, $sql);
        }

        $is_auth = array();
        $is_auth = auth(AUTH_ALL, $forum, $userdata);

        while($row = $db->sql_fetchrow($result))
        {
                if($is_auth['auth_view'] && $is_auth['auth_read'])
                {
                        $description = "
                                      ".$lang['Author'].": <a href='".$base_url."profile.".$phpEx."?mode=viewprofile&".POST_USERS_URL."=".$row['user_id']."'>".$row['username']."</a><br />
                                      ".$lang['Posted'].": ".create_date($board_config['default_dateformat'], $row['post_time'], $board_config['board_timezone'])."<br />
                                      <br />
                                      ".$row['post_text'];

                        $rss_result .= "
                                      <item>
                                        <title>".make_xml_compatible(strip_tags($row['topic_title']))."</title>
                                        <link>".$base_url."viewtopic.".$phpEx."?".POST_POST_URL."=".$row['topic_last_post_id']."#".$row['topic_last_post_id']."</link>
                                        <description>".make_xml_compatible($description, $row['bbcode_uid'], true)."</description>
                                        <comments>".$base_url."viewtopic.".$phpEx."?".POST_POST_URL."=".$row['topic_last_post_id']."#".$row['topic_last_post_id']."</comments>
                                        <author>".make_xml_compatible($row['username'])."</author>
                                        <pubDate>".create_date($board_config['default_dateformat'], $row['post_time'], $board_config['board_timezone'])."</pubDate>
                                        <guid isPermaLink=\"true\">".$base_url."viewtopic.".$phpEx."?".POST_POST_URL."=".$row['topic_last_post_id']."#".$row['topic_last_post_id']."</guid>
                                      </item>";
                }
        }
}

$rss_result .= "</channel></rss>";

header("Content-type: text/xml", true);
echo $rss_result;

?>

Gebruikersavatar
Ramon Fincken
Berichten: 2552
Lid geworden op: 27 nov 2005, 23:15
Locatie: Diemen
Contacteer:

Re: rss

Bericht door Ramon Fincken » 19 feb 2008, 19:27

de grap zit hem hierin:

Code: Selecteer alles

if($is_auth['auth_view'] && $is_auth['auth_read'])
je _kunt_ hiervan maken :

Code: Selecteer alles

if(true)
maar dan laat hij dus ALLES altijd zien !
Freelance webdevelopment, including phpbb2 scripting!

Website founder van: phpBBinstallers.net phpBBantispam.com
Mods: zie op http://www.phpbb.com Blog in wording: RamonFincken.com

debrouwer
Berichten: 20
Lid geworden op: 29 sep 2006, 22:23
Locatie: Amsterdam
Contacteer:

Re: rss

Bericht door debrouwer » 20 feb 2008, 22:41

ik heb het geprobeerd, ik heb gewoon de hele regel weg gehaald en if(true) er voor in de plaats gezet, maar ik zie geen verandering?

Gebruikersavatar
Ramon Fincken
Berichten: 2552
Lid geworden op: 27 nov 2005, 23:15
Locatie: Diemen
Contacteer:

Re: rss

Bericht door Ramon Fincken » 20 feb 2008, 22:54

debrouwer schreef:ik heb het geprobeerd, ik heb gewoon de hele regel weg gehaald en if(true) er voor in de plaats gezet, maar ik zie geen verandering?
overal of 1x veranderd ?
Freelance webdevelopment, including phpbb2 scripting!

Website founder van: phpBBinstallers.net phpBBantispam.com
Mods: zie op http://www.phpbb.com Blog in wording: RamonFincken.com

debrouwer
Berichten: 20
Lid geworden op: 29 sep 2006, 22:23
Locatie: Amsterdam
Contacteer:

Re: rss

Bericht door debrouwer » 20 feb 2008, 23:00

haha uuuuh 1x ik zal wel ff kijken of er meer in staat dacht eigenlijk dat het maar 1 regel was. :D

debrouwer
Berichten: 20
Lid geworden op: 29 sep 2006, 22:23
Locatie: Amsterdam
Contacteer:

Re: rss

Bericht door debrouwer » 20 feb 2008, 23:23

je heb gelijk, het werkt alleen als ik de rss opvraag via een directe link vertoond hij dus alle topics, maar zodra ik de rssreader op mijn website bekijk vertoond hij helaas niks anders dan geen geldige feed, en eerst wel.
Maar je bent wel de enige die wist hoe je alles moest laten vertonen. maar hellaas werkt het tegoed wat je al zij. hij vertoond nu ook mijn underground forum. daar kunnen admin's en modderators topics plaatsen die leden niet zien.
pfff nou dit probleem weer.

hieronder heb ik een werkende phpschript die mijn laatste topics vertoond op mijn website. deze deed precies wat ik wilde, je kan daarmee ook bepaalde groepen afschermen. alleen helaas is het geen rssfeed.
misschien kan ik hier wat uit plukken en gebruiken? of een gehele rssfeed van maken?
ik weet dat ik veel van je vraag, maar tot nu toe ben jij de enige op diverse forums die mij een stap dichter bij heb geholpen.

Code: Selecteer alles

<?php  
// QuickDesigns NL phpBB Topics 
// By QuickDesigns NL  =PaS= 
// 
// http://www.quickdesigns.nl 




// Hier het pad naar je phpBB folder 
$phpbb_root_path = './';  


define('IN_PHPBB', true);  
include($phpbb_root_path . 'extension.inc');  
include($phpbb_root_path . 'common.'.$phpEx);  





Function replacebbcode($text){  

$text = eregi_replace("\[b:.{0,10}\]", "<b>", $text);  
$text = eregi_replace("\[\/b:.{0,10}\]", "</b>", $text);  
$text = eregi_replace("\[u:.{0,10}\]", "<u>", $text);  
$text = eregi_replace("\[\/u:.{0,10}\]", "</u>", $text);  
$text = eregi_replace("\[i:.{0,10}\]", "<i>", $text);  
$text = eregi_replace("\[\/i:.{0,10}\]", "</i>", $text);  
$text = eregi_replace("\[url=http:.{1,80}\]"," ",$text);  
$text = eregi_replace("\[\/url\]"," ",$text);  
$text = eregi_replace("\[url\]"," ",$text);  
$text = eregi_replace("\[.{1,10}:.{1,10}\]"," ",$text);  
$text = eregi_replace("\[\/.{1,10}:.{1,10}\]"," ",$text);  
$text = eregi_replace("\[\/.{1,20}\]"," ",$text);  
$text = eregi_replace("\[.{1,20}\]"," ",$text);  
Return $text;  
}  





// Diverse settings 


$NUM_POSTS = 3; // Aantal laatste topics 
$POST_IMAGE ="mini-category.gif"; // Het plaatje naast het bericht 
$TEXT_ON = false; //Laat een gedeelte tekst zien uit de topic 
$TEXT_LEN = 100; //maximum aantal letters als je hierboven "true" hebt gekozen 
$HIDE = true;//true of false - als je kiest voor true, worden berichten uit bepaalde forums niet weergegeven - (optie hieronder) 
$hide_level = 1;// display threshold 0=laat alleen berichten zien uit forums open voor gasten, 1= ook uit geregistreerd, 2=ook uit Moderators, 3=Laat alle posts zien, ook die uit forums voor admins only 
$fontheadercolor="#808080";  
$fontsize=2;  
$fontcolor="#c0c0c0";  
$fontsizetext=2;  
$fontcolortext="#5695BA";  
$fontheaderface="veranda";  
$box_title = "<font size=\"$fontheadersize\" color=\"$fontheadercolor\" face=\"$fontheaderface\"><b>Topics Forumzuid.</b></font>";  
$box_content = "";  

$time=time();  
$time=date("d M Y h:i a",$time);  

$sqlxx="SELECT a1.post_id AS postid, a1.poster_id AS poster, a1.forum_id, a1.topic_id AS topic, a1.post_time AS time, a2.post_subject AS subject, a2.post_text AS text FROM phpbb_posts a1, phpbb_posts_text a2, phpbb_forums a3 WHERE a1.post_id = a2.post_id AND a1.forum_id = a3.forum_id";  


if($HIDE) $sqlxx .= " AND a3.auth_view <= \"" . $hide_level . "\"";  

$sqlxx .= " ORDER BY a1.post_time DESC";  

$resultxx = mysql_query($sqlxx) or die("Cannot query database");  

if($resultxx){  

$box_content .="<table cellpadding=\"0\" cellspacing = \"0\" width= \"80%\" border=\"0\">";  
for($i=0;$i<$NUM_POSTS;$i++){  
if($post = mysql_fetch_array($resultxx)){  
$result3=mysql_query("SELECT username FROM phpbb_users WHERE user_id =" . $post["poster"]);  
$author=mysql_fetch_array($result3);  
$result4 = mysql_query("SELECT forum_name FROM phpbb_forums WHERE forum_id =" . $post["forum_id"]);  
$forum=mysql_fetch_array($result4);  
if(!$post["subject"]){  
$result2=mysql_query("SELECT topic_title FROM phpbb_topics WHERE topic_id =" . $post["topic"]);  
$replyto = mysql_fetch_array($result2);  
$post["subject"]="RE: " . $replyto["topic_title"];  
mysql_free_result($result2);  
}  
$box_content .="<tr><td ><font size=\"$fontsize\" color=\"$fontcolor\" face=\"$fontheaderface\"><img src=\"$POST_IMAGE \" width=\"13\" height=\"13\" ><a href=\"" . $phpbb_root_path . "viewtopic.php?t=" .$post["topic"] . "\" title=\"Geplaatst door:" . $author["username"]. " && In:" . $forum["forum_name"] . "\" target=\"_blank\"> " . $post["subject"] . "</a><br> geplaatst op " . date("d-m-y ", $post["time"]) . " - " . date("H:i", $post["time"]) . "</font></td></tr>";  
if($TEXT_ON){  
$post["text"] = replacebbcode($post["text"]);  
$post["text"] = substr($post["text"],0,$TEXT_LEN);  
$box_content .= "<tr><td cellpadding=\"0\">&&&&&&<font color=\"$fontcolortext\" size=\"$fontsizetext\" face=\"$fontheaderface\"-" . $post["text"] . "...</font></td></tr>";  
}  

}  


}  
$box_content .="</table>";   
}  

print("<table width=\"340\"><tr><td>" . $box_title . "</td></tr><tr><td><font size=\"$fontsize\" color=\"$fontcolor\" face=\"$fontheaderface\">Updated $time</font></td></tr><tr><td>" . $box_content . "</td></tr></table>");// grote van tabel 



?>


Gebruikersavatar
Ramon Fincken
Berichten: 2552
Lid geworden op: 27 nov 2005, 23:15
Locatie: Diemen
Contacteer:

Re: rss

Bericht door Ramon Fincken » 20 feb 2008, 23:33

als deze code al werkt raad ik je aan toch op de rss door te werken, deze code is niet echt PHPBB compatible gescheven.

tip : tja .. je wilde alles laten zien he :)
maar kijk eens in de sql daar kun je bv neerzetten
( uit mijn hoofd )

AND t.forum_id != 15
AND t.forum_id != 16

zo zou ( niet getest dus ) je alles behalve forum 15 en 16 kunnen verbergen.
Freelance webdevelopment, including phpbb2 scripting!

Website founder van: phpBBinstallers.net phpBBantispam.com
Mods: zie op http://www.phpbb.com Blog in wording: RamonFincken.com

debrouwer
Berichten: 20
Lid geworden op: 29 sep 2006, 22:23
Locatie: Amsterdam
Contacteer:

Re: rss

Bericht door debrouwer » 23 feb 2008, 20:28

Toppie.
ik heb de nummers van de items veranderd in de nummers van de beschermde topics, en alles werkt zoals het moet zijn.
nu kan ik eindelijk weer een stap verder, met mijn website te vernieuwen.
ik zal straks wel weer wat vragen tegen komen, maar het belangrijkste is in iedergeval gelukt.
thanx voor je hulp. :lol:

Gesloten