[RC] Easy RSS Atom mod for phpBB3

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment!
Scam Warning
dicks
Registered User
Posts: 75
Joined: Wed Jun 01, 2005 8:01 am

Re: [BETA] Easy RSS Atom mod for phpBB3

Post by dicks » Mon May 05, 2008 9:17 am

Cool, can you please post some instructions what to replace with the above code?

Thx

DickS

sharathu7
Registered User
Posts: 173
Joined: Fri Jan 11, 2008 1:22 pm

Re: [BETA] Easy RSS Atom mod for phpBB3

Post by sharathu7 » Tue May 06, 2008 1:30 pm

thanks but how to make it work on IE... please help...

sharathu7
Registered User
Posts: 173
Joined: Fri Jan 11, 2008 1:22 pm

Re: [BETA] Easy RSS Atom mod for phpBB3

Post by sharathu7 » Thu May 08, 2008 12:25 pm

Please can anyone make this browser friendly.... to make it work on IE,etc

ReDaLeRt_PT
Registered User
Posts: 9
Joined: Mon Mar 24, 2008 3:05 am

Re: [BETA] Easy RSS Atom mod for phpBB3

Post by ReDaLeRt_PT » Thu May 08, 2008 11:34 pm

Hi,

I have a problem. This doesn't work with:

Code: Select all

$POSTS_LIMIT = 50; 
I have to setup to 15 posts to run without problems. I'm using phpBB 3.0.1 and Mozilla Firefox 2.0.0.14.


[[]]

Survival Bill
Registered User
Posts: 248
Joined: Tue Jun 12, 2007 3:03 am
Contact:

Re: [BETA] Easy RSS Atom mod for phpBB3

Post by Survival Bill » Sun May 11, 2008 11:45 pm

This does not work for me it will not show up any of the feeds to the rss only shows up the top and right side
no content what am I doing wrong or am I ?

http://www.survivalbill.ca/phpBB3/rss.php

in rss.php I have done this.

Code: Select all

//if not present, all forums are taking into account
$forums_list = request_var('forums','1,2,3,4,5');

ToonArmy
Former Team Member
Posts: 4608
Joined: Sat Mar 06, 2004 5:29 pm
Location: Worcestershire, UK
Name: Chris Smith
Contact:

Re: [BETA] Easy RSS Atom mod for phpBB3

Post by ToonArmy » Thu May 15, 2008 3:06 am

Just trawling through the forum looking for RSS mods for 3.0 and I must say, in no way offensively (more as advice) this code is scary. It does not properly sanitize input which will lead to nasty things. There is code lifted from 2.0 which is very outdated, the gzip stuff. The code does not follow the phpBB coding standards, which makes this very hard to read. There is an inordinate number of SQL queries for what its doing, why fetch the config data again when its already available in $config? The board url doesn't need to be hard coded in, you can use the generate_board_url() function to retrieve it.

One suggested code change:

Code: Select all

$forums_list = request_var('forums', '');
$forums_arr = explode(',',$forums_list);
$forums_condition = "";
for($i=0;$i<count($forums_arr);$i++) {
    if($i==0 && $forums_arr[$i]!='') $forums_condition = $forums_condition." WHERE forum_id=".$forums_arr[$i];
    else if($forums_arr[$i]!='') $forums_condition = $forums_condition." OR forum_id=".$forums_arr[$i];
}     
To:

Code: Select all

// Fetch the forums we should include in the feed, and them cast to integers, then build the SQL condition
$forums_condition = $db->sql_in_set('forum_id', array_map('intval', explode(',', request_var('forums', ''))), false, true);
     
Chris SmithBlogGitHub
Image
In a foreign field he lay. Lonely soldier unknown grave. On his dying words he prays. Tell the world of Paschendale.

stokerpiller
Registered User
Posts: 1934
Joined: Wed Feb 28, 2007 8:06 pm

Re: [BETA] Easy RSS Atom mod for phpBB3

Post by stokerpiller » Thu May 15, 2008 7:23 am

ToonArmy wrote:Just trawling through the forum looking for RSS mods for 3.0 and I must say, in no way offensively (more as advice) this code is scary. It does not properly sanitize input which will lead to nasty things. There is code lifted from 2.0 which is very outdated, the gzip stuff. The code does not follow the phpBB coding standards, which makes this very hard to read. There is an inordinate number of SQL queries for what its doing, why fetch the config data again when its already available in $config? The board url doesn't need to be hard coded in, you can use the generate_board_url() function to retrieve it.

One suggested code change:

Code: Select all

$forums_list = request_var('forums', '');
$forums_arr = explode(',',$forums_list);
$forums_condition = "";
for($i=0;$i<count($forums_arr);$i++) {
    if($i==0 && $forums_arr[$i]!='') $forums_condition = $forums_condition." WHERE forum_id=".$forums_arr[$i];
    else if($forums_arr[$i]!='') $forums_condition = $forums_condition." OR forum_id=".$forums_arr[$i];
}      
To:

Code: Select all

// Fetch the forums we should include in the feed, and them cast to integers, then build the SQL condition
$forums_condition = $db->sql_in_set('forum_id', array_map('intval', explode(',', request_var('forums', ''))), false, true);
      
Just testet that codechange.
Got this error:

Code: Select all

SQL ERROR [ mysqli ]

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= 0 ORDER BY post_time DESC LIMIT 50' at line 1 [1064]

SQL

SELECT * FROM phpbb_posts forum_id = 0 ORDER BY post_time DESC LIMIT 50

BACKTRACE

FILE: includes/db/mysqli.php
LINE: 143
CALL: dbal->sql_error()

FILE: includes/db/mysqli.php
LINE: 185
CALL: dbal_mysqli->sql_query()

FILE: includes/db/dbal.php
LINE: 159
CALL: dbal_mysqli->_sql_query_limit()

FILE: rss.php
LINE: 71
CALL: dbal->sql_query_limit()
I am done with phpBB

ToonArmy
Former Team Member
Posts: 4608
Joined: Sat Mar 06, 2004 5:29 pm
Location: Worcestershire, UK
Name: Chris Smith
Contact:

Re: [BETA] Easy RSS Atom mod for phpBB3

Post by ToonArmy » Thu May 15, 2008 1:08 pm

Fixed code change.

Code: Select all

$forums_list = request_var('forums', '');
$forums_arr = explode(',',$forums_list);
$forums_condition = "";
for($i=0;$i<count($forums_arr);$i++) {
    if($i==0 && $forums_arr[$i]!='') $forums_condition = $forums_condition." WHERE forum_id=".$forums_arr[$i];
    else if($forums_arr[$i]!='') $forums_condition = $forums_condition." OR forum_id=".$forums_arr[$i];
} 
To:

Code: Select all

// Fetch the forums we should include in the feed, and them cast to integers, then build the SQL condition
$forums_condition = ' WHERE ' . $db->sql_in_set('forum_id', array_map('intval', array_filter(explode(',', request_var('forums', '')))), false, true); 
Chris SmithBlogGitHub
Image
In a foreign field he lay. Lonely soldier unknown grave. On his dying words he prays. Tell the world of Paschendale.

XToF.be
Registered User
Posts: 61
Joined: Thu Jun 28, 2007 10:52 am
Contact:

Re: [BETA] Easy RSS Atom mod for phpBB3

Post by XToF.be » Thu May 15, 2008 6:11 pm

I have the following error:
Algemene fout
SQL ERROR [ mysqli ]

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'phpbb_topics t WHERE t.topic_id = p.topic_id AND t.topic_id = 1496' at line 3 [1064]

SQL

SELECT t.topic_title FROM phpbb_posts p phpbb_topics t WHERE t.topic_id = p.topic_id AND t.topic_id = 1496

BACKTRACE

FILE: includes/db/mysqli.php
LINE: 143
CALL: dbal->sql_error()

FILE: includes/functions_seo.php
LINE: 164
CALL: dbal_mysqli->sql_query()

FILE: viewtopic.php
LINE: 62
CALL: moved_topic()
I'm pretty sure it has something to do whit the SEO MOD on my board. What do I have to do to fix this and have this RSS MOD running on my board?

XToF.be
Registered User
Posts: 61
Joined: Thu Jun 28, 2007 10:52 am
Contact:

Re: [BETA] Easy RSS Atom mod for phpBB3

Post by XToF.be » Thu May 15, 2008 9:33 pm

These are the php code lines that are causing the error:

FILE: includes/db/mysqli.php

Code: Select all

function sql_query($query = '', $cache_ttl = 0)
125 	{
126 		if ($query != '')
127 		{
128 			global $cache;
129 
130 			// EXPLAIN only in extra debug mode
131 			if (defined('DEBUG_EXTRA'))
132 			{
133 				$this->sql_report('start', $query);
134 			}
135 
136 			$this->query_result = ($cache_ttl && method_exists($cache, 'sql_load')) ? $cache->sql_load($query) : false;
137 			$this->sql_add_num_queries($this->query_result);
138 
139 			if ($this->query_result === false)
140 			{
141 				if (($this->query_result = @mysqli_query($this->db_connect_id, $query)) === false)
142 				{
143 					$this->sql_error($query);
144 				}
145 
146 				if (defined('DEBUG_EXTRA'))
147 				{
148 					$this->sql_report('stop', $query);
149 				}
150 
151 				if ($cache_ttl && method_exists($cache, 'sql_save'))
152 				{
153 					$cache->sql_save($query, $this->query_result, $cache_ttl);
154 				}
155 			}
156 			else if (defined('DEBUG_EXTRA'))
157 			{
158 				$this->sql_report('fromcache', $query);
159 			}
160 		}
161 		else
162 		{
163 			return false;
164 		}
165 
166 		return ($this->query_result) ? $this->query_result : false;
167 	}

FILE: includes/functions_seo.php

Code: Select all

141 function moved_topic($id, $type, $start = 0)
142 {
143 	global $phpbb_root_path, $phpEx, $db;
144 
145 	$path = (!empty($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : getenv('REQUEST_URI');
146 	if (substr($path, 1, 10 + strlen($phpEx)) == 'viewtopic.' . $phpEx)
147 	{
148 		if ($type == 'topic')
149 		{
150 			$sql = 'SELECT topic_title
151 				FROM ' . TOPICS_TABLE . "
152 				WHERE topic_id = $id";
153 			$newid = "t$id";
154 		}
155 		else
156 		{
157 			$sql = 'SELECT t.topic_title
158 				FROM ' . POSTS_TABLE . ' p
159 					' . TOPICS_TABLE . " t
160 				WHERE t.topic_id = p.topic_id
161 					AND t.topic_id = $id";
162 			$newid = "p$id";
163 		}
164 		$result = $db->sql_query($sql);
165 		$topic_title = clean_url($db->sql_fetchfield('topic_title'));
166 		$db->sql_freeresult($result);
167 
168 		header('HTTP/1.1 301 Moved Permanently');
169 		header('Location: ' . format_url($topic_title, $newid, $start));
170 		exit();
171 	}
172 	return;
173 }

FILE: viewtopic.php

Code: Select all

  50 // Do we have a topic or post id?
  51 if (!$topic_id && !$post_id)
  52 {
  53 	trigger_error('NO_TOPIC');
  54 }
  55 $id = $topic_id;
  56 $type = 'topic';
  57 if (!$topic_id)
  58 {
  59 	$id = $post_id;
  60 	$type = 'post';
  61 }
  62 moved_topic($id, $type);

ToonArmy
Former Team Member
Posts: 4608
Joined: Sat Mar 06, 2004 5:29 pm
Location: Worcestershire, UK
Name: Chris Smith
Contact:

Re: [BETA] Easy RSS Atom mod for phpBB3

Post by ToonArmy » Fri May 16, 2008 12:36 am

XToF.be wrote:I'm pretty sure it has something to do whit the SEO MOD on my board. What do I have to do to fix this and have this RSS MOD running on my board?
This is a problem with the SEO mod you should seek support where you got it, there is a comma missing in the SQL statement.
Chris SmithBlogGitHub
Image
In a foreign field he lay. Lonely soldier unknown grave. On his dying words he prays. Tell the world of Paschendale.

XToF.be
Registered User
Posts: 61
Joined: Thu Jun 28, 2007 10:52 am
Contact:

Re: [BETA] Easy RSS Atom mod for phpBB3

Post by XToF.be » Fri May 16, 2008 12:57 pm

Thank you for the advice! I posted this error in this topic. I hope they can give me some support ;).

XToF.be
Registered User
Posts: 61
Joined: Thu Jun 28, 2007 10:52 am
Contact:

Re: [BETA] Easy RSS Atom mod for phpBB3

Post by XToF.be » Sun May 18, 2008 1:48 pm

Anyone who is facing the same problems with the RSS caused by the SEO MOD by Handyman, can find the solution for this issue in this topic (thanks to AllGo): http://www.phpbb.com/community/viewtopi ... 0#p5497265

rwap01
Registered User
Posts: 91
Joined: Wed Jun 04, 2008 11:09 am
Contact:

Re: [BETA] Easy RSS Atom mod for phpBB3

Post by rwap01 » Thu Jun 19, 2008 8:37 am

ToonArmy wrote:Fixed code change.

Code: Select all

$forums_list = request_var('forums', '');
$forums_arr = explode(',',$forums_list);
$forums_condition = "";
for($i=0;$i<count($forums_arr);$i++) {
    if($i==0 && $forums_arr[$i]!='') $forums_condition = $forums_condition." WHERE forum_id=".$forums_arr[$i];
    else if($forums_arr[$i]!='') $forums_condition = $forums_condition." OR forum_id=".$forums_arr[$i];
} 
To:

Code: Select all

// Fetch the forums we should include in the feed, and them cast to integers, then build the SQL condition
$forums_condition = ' WHERE ' . $db->sql_in_set('forum_id', array_map('intval', array_filter(explode(',', request_var('forums', '')))), false, true); 

Thanks - that needs to be updated in the download version.
Otherwise MOD installed and running nicely - great :-)

polov
Registered User
Posts: 27
Joined: Tue Feb 12, 2008 8:50 am

Re: [BETA] Easy RSS Atom mod for phpBB3

Post by polov » Thu Jun 19, 2008 11:22 am

I have put this fix into code already.

Locked

Return to “[3.0.x] MODs in Development”