Code: Select all
$POSTS_LIMIT = 50;
Code: Select all
//if not present, all forums are taking into account
$forums_list = request_var('forums','1,2,3,4,5');
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];
}
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.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:
To: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]; }
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);
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()
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];
}
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);
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?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()
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 }
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 }
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);
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.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?
ToonArmy wrote:Fixed code change.
To: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]; }
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);