1. ¡OFERTA! con cupón "DIRVPS": hosting por $0,01 y también VPS Linux y Windows por $0,01 el primer mes por Interserver ← publi
    Descartar aviso
Descartar aviso
Al usar este sitio web, aceptas que nosotros y nuestros socios podamos establecer cookies para fines tales como personalizar el contenido y la publicidad. Más información.

Problema en la columna "Ultimos Mensajes"

Tema en 'PunBB en español' iniciado por iRufus, 17 Oct 2006.

  1. iRufus

    iRufus Nuevo usuario

    El problema que tengo es que al hacer las modificaciones en el fichero (creo que viewforum.php) para añadir la columna de "Autor", como véis en la imagen he perdido la información de los últimos usuarios que respondieron en los temas.
    No me dí cuenta del error y añadí algunos cambios más, con lo cual, la última copia de seguridad no me sirve porque esos últimos cambios quiero conservarlos. He intentado ir vuelta atrás pero es un follón.

    Debajo de la imágen que incluyo, os dejo la pieza de código del archivo "viewforum.php" donde "creo" que está el error.

    A ver si alguien se atreve con esto?

    Salu2

    [​IMG]

    CODE, HTML o PHP Insertado:
    // Fetch list of topics to display on this page
    // 
    
    switch ($db_type)
    
    {
    
    	case 'mysql':
    	case 'mysqli':
    		$sql = 'SELECT p.poster_id AS has_posted, t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id WHERE t.forum_id='.$id.' GROUP BY t.id ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'];
    		break;
    
    	case 'sqlite':
    		$sql = 'SELECT p.poster_id AS has_posted, t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id WHERE t.id IN(SELECT id FROM '.$db->prefix.'topics WHERE forum_id='.$id.' ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'].') GROUP BY t.id ORDER BY t.sticky DESC, t.last_post DESC';
    		break;
    
    	default:
    		$sql = 'SELECT p.poster_id AS has_posted, t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id WHERE t.forum_id='.$id.' GROUP BY t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to, p.poster_id ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'];
    		break;
    
    }
    
    $result = $db->query($sql) or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error());
    
    // If there are topics in this forum.
    if ($db->num_rows($result))
    {
    	while ($cur_topic = $db->fetch_assoc($result))
    	{
    		$icon_text = $lang_common['Normal icon'];
    		$item_status = '';
    		$icon_type = 'icon';
    // MOD AUTHOR COLUMN 1 following line added
    		$author = '[url="profile.php?id='.$cur_topic['has_posted'].'"]'.pun_htmlspecialchars($cur_topic['poster']).'[/url]';		
    		if ($cur_topic['moved_to'] != 0)
    
    // 
    			$subject = $lang_forum['Moved'].': [url="viewtopic.php?id='.$cur_topic['moved_to'].'"]'.pun_htmlspecialchars($cur_topic['subject']).'[/url]';
    		else if ($cur_topic['closed'] == '0')
    
    // 
    			$subject = '[url="viewtopic.php?id='.$cur_topic['id'].'"]'.pun_htmlspecialchars($cur_topic['subject']).'[/url]';
    		else
    		{
    			$subject = '[url="viewtopic.php?id='.$cur_topic['id'].'"]'.pun_htmlspecialchars($cur_topic['subject']).'[/url] <span class="byuser">'.$lang_common['by'].''.pun_htmlspecialchars($cur_topic['poster']).'</span>';
    			$icon_text = $lang_common['Closed icon'];
    			$item_status = 'iclosed';
    		}
    
    		if (!$pun_user['is_guest'] && $cur_topic['last_post'] > $pun_user['last_visit'] && $cur_topic['moved_to'] == null)
    		{
    			$icon_text .= ' '.$lang_common['New icon'];
    			$item_status .= ' inew';
    			$icon_type = 'icon inew';
    			$subject = '[b]'.$subject.'[/b]';
    			$subject_new_posts = '<span class="newtext">[[url="viewtopic.php?id='.$cur_topic['id'].'&amp;action=new"]'.$lang_common['New posts'].'[/url]]</span>';
    		}
    		else
    			$subject_new_posts = null;
    
    // Should we display the dot or not? :)
    		if (!$pun_user['is_guest'] && $pun_config['o_show_dot'] == '1')
    		{
    			if ($cur_topic['has_posted'] == $pun_user['id'])
    				$subject = '[b]&middot;[/b]'.$subject;
    			else
    				$subject = ''.$subject;
    		}
    // MOD AUTHOR COLUMN 2 following lines added
    
    		else
    			$subject = ''.$subject;
    		
    		if ($cur_topic['sticky'] == '1')
    		{
    			$subject = '<span class="stickytext">'.$lang_forum['Sticky'].': </span>'.$subject;
    			$item_status .= ' isticky';
    			$icon_text .= ' '.$lang_forum['Sticky'];
    		}
    
    		$num_pages_topic = ceil(($cur_topic['num_replies'] + 1) / $pun_user['disp_posts']);
    
    		if ($num_pages_topic > 1)
    			$subject_multipage = '[ '.paginate($num_pages_topic, -1, 'viewtopic.php?id='.$cur_topic['id']).' ]';
    		else
    			$subject_multipage = null;
    
    		// Should we show the "New posts" and/or the multipage links?
    		if (!empty($subject_new_posts) || !empty($subject_multipage))
    		{
    			$subject .= ' '.(!empty($subject_new_posts) ? $subject_new_posts : '');
    			$subject .= !empty($subject_multipage) ? ' '.$subject_multipage : '';
    		}
    
    ?>
    				<tr<?php if ($item_status != '') echo ' class="'.trim($item_status).'"'; ?>>
    					<td class="tcl">
    						<div class="intd">
    							<div class="<?php echo $icon_type ?>"><div class="nosize"><?php echo trim($icon_text) ?></div></div>
    							<div class="tclcon">
    								<?php echo $subject."\n" ?>
    							</div>
    						</div>
    					</td>
    					
    
    					<td class="tc2"  style="WIDTH: 12%"><?php echo ($cur_topic['moved_to'] == null) ? $author : '' ?></td>					
    					<td class="tc2"><?php echo ($cur_topic['moved_to'] == null) ? $cur_topic['num_replies'] : '' ?></td>
    					<td class="tc3"><?php echo ($cur_topic['moved_to'] == null) ? $cur_topic['num_views'] : '' ?></td>
    					<td class="tcr"><?php echo $last_post ?></td>
    				</tr>
    <?php
    
    	}
    }
    else
    {
    
    ?>
    				<tr>
    					<td class="tcl" colspan="4"><?php echo $lang_forum['Empty forum'] ?></td>
    				</tr>
    <?php
    
    }
    
    ?>
    			</tbody>
    			</table>
    		</div>
    	</div>
    </div>
    
    <div class="linksb">
    	<div class="inbox">
    		<p class="pagelink conl"><?php echo $paging_links ?></p>
    <?php echo $post_link ?>
    		<ul>[*][url="index.php"]<?php echo $lang_common['Index'] ?>[/url][*]&raquo;<?php echo pun_htmlspecialchars($cur_forum['forum_name']) ?>[/list]
    		<div class="clearer"></div>
    	</div>
    </div>
    <?php
    
    $forum_id = $id;
    $footer_style = 'viewforum';
    require PUN_ROOT.'footer.php';
    Gracias por el esfuerzo
     
  2.  
  3. Apolo

    Apolo Administrador Miembro del Staff Administrador CH

    Hola,

    Fíjate en el trozo de código un poco más completo:

    CODE, HTML o PHP Insertado:
    <?php
    
    // Fetch list of topics to display on this page
    if ($pun_user['is_guest'] || $pun_config['o_show_dot'] == '0')
    {
    	// Without "the dot"
    	$sql = 'SELECT id, poster, subject, posted, last_post, last_post_id, last_poster, num_views, num_replies, closed, sticky, moved_to FROM '.$db->prefix.'topics WHERE forum_id='.$id.' ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'];
    }
    else
    {
    	// With "the dot"
    	switch ($db_type)
    	{
    		case 'mysql':
    		case 'mysqli':
    			$sql = 'SELECT p.poster_id AS has_posted, t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id AND p.poster_id='.$pun_user['id'].' WHERE t.forum_id='.$id.' GROUP BY t.id ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'];
    			break;
    
    		case 'sqlite':
    			$sql = 'SELECT p.poster_id AS has_posted, t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id AND p.poster_id='.$pun_user['id'].' WHERE t.id IN(SELECT id FROM '.$db->prefix.'topics WHERE forum_id='.$id.' ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'].') GROUP BY t.id ORDER BY t.sticky DESC, t.last_post DESC';
    			break;
    
    		default:
    			$sql = 'SELECT p.poster_id AS has_posted, t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id AND p.poster_id='.$pun_user['id'].' WHERE t.forum_id='.$id.' GROUP BY t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to, p.poster_id ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'];
    			break;
    
    	}
    }
    
    $result = $db->query($sql) or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error());
    Mira que antes de la última instrucción ($result=) a dos corchetes de cierre, y en el código que tú has pegado solamente hay uno. Compara muy bien el código tuyo con el que yo he puesto y encontrarás las diferencias.

    Saludos!

    Jaime
     
  4. iRufus

    iRufus Nuevo usuario

    Gracias por tu gran esfuerzo Apolo... Pero no está ahí el error.

    He desandado el camino de la modificación que hice y he logrado devolver el Autor a su sitio...
    Pero el Último Mensaje sigue sin salir. Despues de modificar lo que te digo me quedaron los dos corchetes igual que lo tienes tú.

    Seguiré buscando...

    Salu2
     
  5. iRufus

    iRufus Nuevo usuario

    Corregido por las bravas... Instalé la ultima versión de punbb...

    Gracias de todas formas...

    Salu2
     
  6. Apolo

    Apolo Administrador Miembro del Staff Administrador CH

    Que bueno que lo has solucionado. :)

    Saludos!
     


Alojamiento web, Hosting Reseller, Servidores Dedicados - All in Hosting


    
    
    
    
Blog · Sitios amigos: GuiaHosting · Unidominios · Interalta ·