i really do like this code. I want to thank everyone for helping out. i have added some info about the user to this script...
Q
demo link follows: http://nalan.org/8.php can we say final release?
<?php
define('PUN_ROOT', './');
require_once PUN_ROOT.'include/common.php';
//Set the page title here
$page_title = pun_htmlspecialchars($pun_config['o_board_title']);
define('PUN_ALLOW_INDEX', 1);
require_once PUN_ROOT.'header.php';
require_once PUN_ROOT.'include/parser.php';
require_once PUN_ROOT.'lang/'.$pun_user['language'].'/index.php';
require_once PUN_ROOT.'lang/'.$pun_user['language'].'/common.php';
require_once PUN_ROOT.'lang/'.$pun_user['language'].'/topic.php';
require_once PUN_ROOT.'lang/'.$pun_user['language'].'/login.php';
require_once PUN_ROOT.'lang/'.$pun_user['language'].'/forum.php';
//----------------------------------------------------------------------//
//These are the forums from which the news is retrieved
$forumids = array(1,2);
//This is the overall limit for how many news items will be displayed
$master_limit = '10';
//This is the amount of characters above which truncation will occur
$trunc_chars = '100';
//----------------------------------------------------------------------//
if ($pun_config['o_index_message_show'] == 1)
{
?>
<div class="block">
<h2><span><?php echo pun_htmlspecialchars($pun_config['o_index_message_head']) ?></span></h2>
<div class="box">
<div class="inbox">
<?php echo $pun_config['o_index_message'] ?>
</div>
</div>
</div>
<?php
}
//----------------------------------------------------------------------//
function close_tags($string)
{
if (preg_match_all ('/<([a-z]+)[ >]/', $string, $start_tags))
{
$start_tags = $start_tags[1];
if (preg_match_all ('/<\/([a-z]+)>/', $string, $end_tags))
{
$complete_tags = array();
$end_tags = $end_tags[1];
foreach ($start_tags as $key => $val)
{
$posb = array_search ($val, $end_tags);
if (is_integer ($posb))
{
unset ($end_tags[$posb]);
}
else
{
$complete_tags[] = $val;
}
}
}
else
{
$complete_tags = $start_tags;
}
$complete_tags = array_reverse ($complete_tags);
for ($i = 0; $i < count ($complete_tags); $i++)
{
$string .= '</' . $complete_tags[$i] . '>';
}
}
// Removes irrelevant tags
$xhtml_tags = array ('</img>', '</hr>', '</br>');
$string = str_replace ($xhtml_tags, '', $string);
return $string;
}
//----------------------------------------------------------------------//
function truncate($string)
{
global $pun_config;
$trunc_chars = '100';
$length = $trunc_chars;
$append = ' ..... ';
if (strlen ($string) <= $length)
{
return $string;
}
else if ($length > 0)
{
preg_match ('#^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){'.$length.',}\b#U', $string, $matches);
$string = $matches[0];
$string = close_tags (preg_replace ('#\s*<[^>]+>?\s*$#', '', $string).$append);
return $string;
}
}
//----------------------------------------------------------------------//
$result = $db->query('SELECT t.id, t.subject, t.num_replies, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.forum_id, u.use_avatar, u.num_posts, u.registered, u.title, p.poster, p.poster_id, p.message, p.hide_smilies, p.posted, g.g_title, f.forum_name FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'posts AS p ON p.topic_id=t.id AND p.posted=t.posted INNER JOIN '.$db->prefix.'users AS u ON u.id=p.poster_id LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id WHERE t.forum_id IN ('.implode(',', $forumids).') AND t.moved_to IS NULL AND f.redirect_url IS NULL ORDER BY t.posted DESC LIMIT '.$master_limit) or error('Unable to fetch announcements', __FILE__, __LINE__, $db->error());
if ($db->num_rows($result))
{
while($cur_post = $db->fetch_assoc($result))
{
echo '<div class="block">';
if ($pun_config['o_avatars'] == '1' && $cur_post['use_avatar'] == '1' && $pun_user['show_avatars'] != '0')
{
if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.gif'))
{
$user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.gif" '.$img_size[3].' title="'.$cur_post['poster'].'\'s Avatar" alt="'.$cur_post['poster'].'\'s Avatar" /></a>';
}
else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.jpg'))
{
$user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.jpg" '.$img_size[3].' title="'.$cur_post['poster'].'\'s Avatar" alt="'.$cur_post['poster'].'\'s Avatar" /></a>';
}
else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.png'))
{
$user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.png" '.$img_size[3].' title="'.$cur_post['poster'].'\'s Avatar" alt="'.$cur_post['poster'].'\'s Avatar" /></a>';
}
}
else
{
$user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img src="img/noimage.gif" alt=""/></a>';
}
$news_message = parse_message($cur_post['message'], $cur_post['hide_smilies']);
if (pun_strlen($news_message) > $trunc_chars)
{
$news_message = truncate($news_message);
$read_more = ' | <a href="'.$pun_config['o_base_url'].'/viewtopic.php?id='.$cur_post['id'].'">Read More</a> | ';
}
else
{
$read_more = ' | ';
}
if ($cur_post['num_replies'] != '0')
{
$replies = ' <a href="'.$pun_config['o_base_url'].'/viewtopic.php?id='.$cur_post['id'].'#p'.$cur_post['last_post_id'].'">Replies</a>: '.$cur_post['num_replies'].' ';
}
else
{
$replies = ' Replies: '.$cur_post['num_replies'].' ';
}
echo "\t\t\t\t\t\t\t".'<h2><strong><a href="forum.php">Forum</a> » <a href="viewforum.php?id='.$cur_post['forum_id'].'">'.pun_htmlspecialchars($cur_post['forum_name']).'</a>'.'</strong></h2>'."\n";
?>
<div class="box">
<div class="inbox">
<ul><li>
<table cellSpacing="0" cellPadding="0" width="100%" border="0">
<tr>
<td style="border: 0px; padding: 0px 10px 7px 7px;"><a class="news_subject" href="viewtopic.php?id=<?php echo $cur_post['id']; ?>"><strong><?php echo $cur_post['subject']; ?></strong></a></td>
</tr>
</table>
<table cellSpacing="0" cellPadding="0" width="100%" border="0">
<tr>
<td align="left" style="white-space: nowrap; width: 8em; padding-left: 7px; padding-top: 6px; padding-bottom: 30px; border: 0px;" valign="top"><?php echo $user_avatar ?><p></p><strong><?php echo pun_htmlspecialchars($cur_post['poster']) ?></strong><p></p><?php echo 'Title: '.$cur_post['g_title'] ?><p></p><?php echo 'Total Post: '.$cur_post['num_posts'] ?><p></p><?php echo 'Registered Date: '. format_time($cur_post['registered'], true) ?></td>
<td style="text-align: left; border: 0px; padding-top: 0px;" valign="top"><?php echo $news_message."\n" ?></td>
</tr>
</table>
<table class="news_footer" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="100%">
<?php
echo "\t\t\t\t\t\t\t".'<span class="user" style="float:left">Posted: '.format_time($cur_post['posted']).' by:<span class="user'.(isset($cur_post['g_title']) ? ' '.strtolower(str_replace(' ', '', $cur_post['g_title'])) : '').'"> <a class="poster" href="profile.php?id='.$cur_post['poster_id'].'">'.pun_htmlspecialchars($cur_post['poster']).'</a>'.$read_more.'Views: '.$cur_post['num_views'].' |'.$replies.'</span></span>'."\n";
if ($cur_post['poster_id'] == $pun_user['id'] || $pun_user['g_id'] < PUN_GUEST)
{
echo "\t\t\t\t\t\t\t".'<a href="viewtopic.php?id='.$cur_post['id'].'">'.pun_htmlspecialchars($lang_portal['Visit_Topic']).'</a>'.'<span style="float:right">'.'<a href="misc.php?report='.$cur_post['id'].'">'.$lang_topic['Report'].'</a>'.' | <a href="delete.php?id='.$cur_post['id'].'">'.$lang_topic['Delete'].'</a> | <a href="edit.php?id='.$cur_post['id'].'">'.$lang_topic['Edit'].'</a>'.' | <a href="post.php?tid='.$cur_post['id'].'">'.'Reply'.'</a>'.' | <a href="post.php?tid='.$cur_post['id'].'&qid='.$cur_post['id'].'">'.$lang_topic['Quote'].'</a>'.' | <a href="'.$pun_config['o_base_url'].'/viewtopic.php?id='.$cur_post['id'].'">'.'Read More'.'</a>'.'</span>'."\n\n\n\n";
}
?>
</td>
</tr>
</table>
</li></ul>
</div>
</div>
</div>
<?php
}
}
?>
<div align="center">Theme Designed by: Shedrock - <a onclick="window.open(this.href); return false;" href="http://shednotes.com">shednotes.com</a></div>
<br/>
<?php
require PUN_ROOT.'footer.php';
?>
My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!