Ver Mensaje Individual
  #89 (permalink)  
Antiguo 08/08/2005, 13:32
Avatar de yoseman
yoseman
 
Fecha de Ingreso: diciembre-2003
Ubicación: Alicante (Spain)
Mensajes: 471
Antigüedad: 21 años, 2 meses
Puntos: 5
Yo tengo un script que hace más o menos lo que tu quieres, lo que pasa es que se le puede llamar de tal forma que inicialmente muestre los X nuevos mensajes en el foro
Código PHP:
<? 
// ################################################################################## 
// ULTIMOS MENSAJES ENVIADOS A UN FORO 
// ################################################################################## 
define('IN_PHPBB'true); 
$phpbb_root_path ''//PATH DEL FORO RESPECTO DEL SCRIPT
include($phpbb_root_path 'extension.inc'); 
include(
$phpbb_root_path 'common.'.$phpEx); 
$userdata session_pagestart($user_ipPAGE_INDEX); 
init_userprefs($userdata); 
$p $table_prefix
$auth_ary auth(AUTH_READAUTH_LIST_ALL$userdata); 
while ( list(
$auth_forum_id$auth_level) = each($auth_ary) ) 
{
    if (!
$auth_level['auth_read'] ) 
    { 
        
$auth_view_forums = ($auth_view_forums " p.forum_id<>" $auth_forum_id " and "); 
        
$auth_view_forums1 = ($auth_view_forums1 " forum_id<>" $auth_forum_id " and "); 
    }

$auth_view_forums="WHERE " $auth_view_forums
$auth_view_forums1="WHERE " $auth_view_forums1
$busqueda= @mysql_query("SELECT c.cat_id,c.cat_title,c.cat_order,p.forum_id,p.forum_name from " $p "forums p,"$p "categories c "$auth_view_forums1 "p.cat_id=c.cat_id order by c.cat_order,p.forum_order asc"); 
if (!
$busqueda

    echo (
"Error al seleccionar los elementos de la base de datos. Por favor Inténtelo de nuevo más tarde."); 
    exit();

$k=0
while (
$row mysql_fetch_array($busqueda)) 

    
$k=$k+1
    
$foro_id[$k]=$row['forum_id']; 
    
$foro_name[$k]=$row['forum_name']; 
    
$cat[$k]=$row['cat_title']; 

if (!isset(
$_GET['id']) || $_GET['id']==-1
{
    
$_GET['id']=$foro_id[1];

if (!isset(
$_GET['num'])) 
{
    
$_GET['num']=10;

$id=$_GET['id']; 
$mensajes=$_GET['num']; 
$reducido=0// ACTIVA A 1 SI DESEAS QUE SE MUESTRE LA VERSIÓN REDUCIDA 
$id=($id!="todos") ? (" p.forum_id=".$id." and ") : (""); 
$busqueda= @mysql_query("SELECT p.post_id,p.topic_id,p.forum_id,p.poster_id,p.post_time,po.post_id,po.post_subject,t.topic_id,t.topic_title,t.topic_views,t.topic_replies,u.user_id,u.username,f.forum_name FROM " $p "posts_text po," $p "posts p," $p "topics t," $p "users u," $p "forums f " $auth_view_forums $id ." p.forum_id=f.forum_id and p.post_id=po.post_id and p.poster_id=u.user_id and p.topic_id=t.topic_id ORDER BY p.post_time desc limit " $mensajes);
if (!
$busqueda)

    echo (
"Error al seleccionar los elementos de la base de datos. Por favor Inténtelo de nuevo más tarde."); 
    exit(); 

$i=0
while (
$row mysql_fetch_array($busqueda)) 

    
$i=$i+1
    
$u_username[$i]=$row['username']; 
    
$u_id[$i]=$row['user_id']; 
    
$t_title[$i]=$row['topic_title']; 
    
$t_id[$i]=$row['topic_id']; 
    
$t_views[$i]=$row['topic_views']; 
    
$t_replies[$i]=$row['topic_replies']; 
    
$p_time[$i]=$row['post_time']; 
    
$p_subject[$i]=$row['post_subject']; 
    
$f_title[$i]=$row['forum_name']; 
    
$p_id[$i]=$row['post_id']; 
    
$f_id[$i]=$row['forum_id']; 

$col = ($reducido) ? 6

$id=$_GET['id']; 
$titu=($id!="todos") ? ($f_title[$i]) : ("TODOS LOS FOROS"); 
?> 
<link rel="stylesheet" href="<?=$phpbb_root_path?>templates/subSilver/subSilver.css" type="text/css" >
<style>
* {font-size:10px}
</style>
<span class="nav"><a href="./index.php" class="gen"><?=$lang['Forum_index']?></a></span> 
<table class="forumline" width="100%" cellspacing="1" cellpadding="3" border="0"> 
    <tr align="center"> 
        <td class="catHead" colspan="<?=$col?>" height="28" > 
        <span class="nav"> ÚLTIMAS RESPUESTAS EN EL FORO :: <?=$titu?> </span> 
    </td>
    </tr> 
    <tr> 
        <th> Tópico: </th> 
<? if ($id!="todos") {?> 
        <th> Título post: </th> 
<?} else {?> 
        <th> Foro: </th> 
<?}?> 
        <th> Autor: </th> 
<? if (!$reducido) {?> 
        <th> Fecha: </th> 
        <th> Respuestas: </th> 
        <th> Lecturas: </th> 
<? ?> 
    </tr> 
<? 
$row
=0
for(
$j=1$j<$i+1$j=$j+1

    
$row++; 
    if (
$row==3
    { 
        
$row=1;
    } 
    if (
$p_subject[$j]==''
    { 
        
$p_subject[$j]="Re:" $t_title[$j]; 
    } 
    
$dat=getdate($p_time[$j]); 
    
?> 
    <tr> 
        <td class="row<?=$row?>"> 
        <span class="gensmall"> <a href="<?=$phpbb_root_path?>viewtopic.php?p=<?=$p_id[$j]?>&highlight=#<?=$p_id[$j]?>"> <?=$t_title[$j]?> </a> </span> 
        </td> 
<? if ($id!="todos") {?> 
        <td class="row<?=$row?>"> <span class="gensmall"> <?=$p_subject[$j]?> </span> 
        </td>
<?} else {?> 
        <td class="row<?=$row?>"> <a href="http://elotrositio.tuarrobanet.com/foro/viewforum.php?f=<?=$f_id[$j]?>"> <span class="gensmall"><?=$f_title[$j]?></span> </a> 
        </td> 
<?}?> 
        <td align="center" class="row<?=$row?>"> <span class="gensmall"> <a href="<?=$phpbb_root_path?>profile.php?mode=viewprofile&u=<?=$u_id[$j]?>"> <?=$u_username[$j]?> </a> </span> 
        </td> 
<? if (!$reducido) {?> 
        <td align="center" class="row<?=$row?>"> <span class="gensmall"> <?=$dat["mday"]?>/<?=$dat["mon"]?>/<?=$dat["year"]?> </span> 
        </td> 
        <td align="center" class="row<?=$row?>"> <span class="gensmall"> <?=$t_replies[$j]?> </span> 
        </td> 
        <td align="center" class="row<?=$row?>"> <span class="gensmall"> <?=$t_views[$j]?> </span> 
        </td> 
<? ?> 
    </tr> 
<? ?> 
</table> 
<form action="ultimos.php" method="get"> 
    <table width="100%" cellspacing="0" cellpadding="0" border="0"> 
        <tr> 
            <td rowspan="2" align="center"><span class="gensmall">Seleccione el foro y el número de mensajes:</span>
            </td> 
            <td rowspan="2" class="gensmall"> 
            <select name="id" value="1" onchange="if(this.options[this.selectedIndex].value != -1) {this.form.submit();}"> 
            <option value="-1">Seleccione el foro</option> 
            <option value="-1"></option> 
            <option value="-1">[+] TODOS LOS FOROS</option> 
            <option value="-1">-------------</option> 
<? $sel = ($_GET['id']=="todos") ? " selected=\"selected\"" ""?> 
            <option value="todos" <?=$sel?>>| TODOS</option>
            <option value="-1"></option>
<? 
$newcat 
$cat[1];
for(
$j=1$j<$k+1$j=$j+1)

    if ((
$cat[$j]!=$cat[$j-1])||$j==1
        {
?>
            <option value="-1"></option> 
            <option value="-1"><?=$cat[$j]?></option> 
            <option value="-1">-------------</option> 
<? 

$sel = ($foro_id[$j]==$_GET['id']) ? " selected=\"selected\"" ""?> 
            <option value="<?=$foro_id[$j]?>"<?=$sel?>><?=$foro_name[$j]?></option> 
<?}?> 
            </select> 
            <select name="num" value="1" onchange="this.form.submit();"> 
<? for($j=1$j<100$j=$j+1) { $sel = ($j == $_GET['num']) ? " selected=\"selected\"" ""?> 
            <option value="<?=$j?><?=$sel?>><?=$j?></option>
<?}?>
            </td>
        </tr> 
    </table>
</form> 
<? include($phpbb_root_path 'includes/page_tail.'.$phpEx); ?>
En la línea dónde está la variable $phpbb_root_path, debes de poner la ruta dónde está el foro respecto de la ruta dónde estará este codigo.

Inicialmente si quieres que muestre todos los mensajes puedes llamarlo así:
ultimos.php?id=todos&num=15. Luego ya te muestra según la categoría que elijas y el numero de mensajes.

Si quieres que quite cosas ya me vas diciendo
Ejemplo : http://usuarios.lycos.es/canalfrance...d=todos&num=15
Salu2 ;)
__________________
[+]
[+]

Última edición por yoseman; 08/08/2005 a las 13:53