resulta que he usado uno de estos codigos https://blog.phpbb.com/2009/11/09/how-t ... nal-pages/
especificamente el tercero: EXAMPLE 3: Display posts from specified topics
esto lo he usado para obtener el texto del contenido de 5 temas de un foro especifico, para mostrarlo en una pagina externa..
El codigo es el siguiente:
Código: Seleccionar todo
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
function create_where_clauses($gen_id, $type)
{
global $db, $auth;
$size_gen_id = sizeof($gen_id);
switch($type)
{
case 'forum':
$type = 'forum_id';
break;
case 'topic':
$type = 'topic_id';
break;
default:
trigger_error('No type defined');
}
// Set $out_where to nothing, this will be used of the gen_id
// size is empty, in other words "grab from anywhere" with
// no restrictions
$out_where = '';
if ($size_gen_id > 0)
{
// Get a list of all forums the user has permissions to read
$auth_f_read = array_keys($auth->acl_getf('f_read', true));
if ($type == 'topic_id')
{
$sql = 'SELECT topic_id FROM ' . TOPICS_TABLE . '
WHERE ' . $db->sql_in_set('topic_id', $gen_id) . '
AND ' . $db->sql_in_set('forum_id', $auth_f_read);
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
// Create an array with all acceptable topic ids
$topic_id_list[] = $row['topic_id'];
}
unset($gen_id);
$gen_id = $topic_id_list;
$size_gen_id = sizeof($gen_id);
}
$j = 0;
for ($i = 0; $i < $size_gen_id; $i++)
{
$id_check = (int) $gen_id[$i]; // If the type is topic, all checks have been made and the query can start to be built if( $type == 'topic_id' ) { $out_where .= ($j == 0) ? 'WHERE ' . $type . ' = ' . $id_check . ' ' : 'OR ' . $type . ' = ' . $id_check . ' '; } // If the type is forum, do the check to make sure the user has read permissions else if( $type == 'forum_id' && $auth->acl_get('f_read', $id_check) )
{
$out_where .= ($j == 0) ? 'WHERE ' . $type . ' = ' . $id_check . ' ' : 'OR ' . $type . ' = ' . $id_check . ' ';
}
$j++;
}
}
if ($out_where == '' && $size_gen_id > 0)
{
trigger_error('A list of topics/forums has not been created');
}
return $out_where;
}
$search_limit = 5;
$forum_id = array(31);
$forum_id_where = create_where_clauses($forum_id, 'forum');
$topic_id = array(5099,5093,5096,5097,5098);
$topic_id_where = create_where_clauses($topic_id, 'topic');
$posts_ary = array(
'SELECT' => 'p.*, t.*, u.username, u.user_colour',
'FROM' => array(
POSTS_TABLE => 'p',
),
'LEFT_JOIN' => array(
array(
'FROM' => array(USERS_TABLE => 'u'),
'ON' => 'u.user_id = p.poster_id'
),
array(
'FROM' => array(TOPICS_TABLE => 't'),
'ON' => 'p.topic_id = t.topic_id'
),
),
'WHERE' => str_replace( array('WHERE ', 'topic_id'), array('', 't.topic_id'), $topic_id_where) . '
AND t.topic_status <> ' . ITEM_MOVED . '
AND t.topic_approved = 1',
'ORDER_BY' => 'p.post_id DESC',
);
$posts = $db->sql_build_query('SELECT', $posts_ary);
$posts_result = $db->sql_query_limit($posts, $search_limit);
while ($posts_row = $db->sql_fetchrow($posts_result))
{
$post_text = nl2br($posts_row['post_text']);
$bbcode = new bbcode(base64_encode($bbcode_bitfield));
$bbcode->bbcode_second_pass($post_text, $posts_row['bbcode_uid'], $posts_row['bbcode_bitfield']);
$post_text = smiley_text($post_text);
$template->assign_block_vars('animelista', array(
'POST_TEXT' => censor_text($post_text),
));
}
Esto me funciona perfecto en Google Chrome, pero en los demas navegadores como Firefox, Opera e IE me tira el siguiente error:
creo que hace referencia a esta linea que se encuentra dentro del codigo anteriorError General
SQL ERROR [ mysql4 ]
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 'AND t.topic_status <> 2 AND t.topic_approved = 1 ORDER BY p.post_id DESC LIMIT ' at line 2 [1064]
Ocurrió un error SQL mientras recuperaba esta página. Por favor contacta con La Administración del Sitio si el problema persiste.
Código: Seleccionar todo
'WHERE' => str_replace( array('WHERE ', 'topic_id'), array('', 't.topic_id'), $topic_id_where) . '
AND t.topic_status <> ' . ITEM_MOVED . '
AND t.topic_approved = 1',
'ORDER_BY' => 'p.post_id DESC',
en mi portal tambien he puesto el mismo codigo pero apuntando a un foro diferente y tampoco me funciona, asi que lo he quitado. Estoy casi seguro que el problema es ese estracto de codigo anterior, porque he usado otros codigos para mostrar los ultimos temas, pero ninguno posee ese estracto en su interior y me funcionan bien en todos los navegadores.. pueden verlos al final de mi portal..
Espero alguien tenga alguna idea de como solucionarlo, desde ya gracias por leer