Topic: Some advice on my modded Latest Topics
I am no coder but I managed to whip this Latest Topics up using various code. I am not sure if it is correct but it does work. I would just like someone to tell me if everything in here is required or not. I have no clue what the censoring area of the code does. I am assuming that if censoring is turned on in the admin panel the results are shown here. One thing I do not understand is why I need to set the make topics displayed to (6) in order to show (5). However, if I remove the censoring code then a setting of (5) is (5). Anyway, just need someone to pick out the code that I need in here:
<?php
showRecent(); // Set amount of posts to be displayed here
function showRecent($show=10) {
global $lang_common, $db, $pun_config, $pun_user, $db_prefix;
$max_subject_length = 20;
$order_by = 't.last_post';
$forum_sql = '';
$show = intval($show);
if ($show < 1 || $show > $show_max_topics)
$show = 6;
// Fetch $show topics
$result = $db->query('SELECT t.id, t.poster, t.subject, t.posted, t.last_post FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id=3) WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.moved_to IS NULL'.$forum_sql.' ORDER BY '.$order_by.' DESC LIMIT '.$show) or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error());
$show_count = 0;
if ( !$db->num_rows($result) ) return $output;
while ( ($show_count < $show) && ($cur_topic = $db->fetch_assoc($result)) ) {
$temp = '';
while ($cur_topic = $db->fetch_assoc($result)) {
if ($pun_config['o_censoring'] == '1')
$cur_topic['subject'] = censor_words($cur_topic['subject']);
$subject_truncated = pun_htmlspecialchars($cur_topic['subject']);
if ($pun_config['o_censoring'] == '1')
$cur_topic['subject'] = censor_words($cur_topic['subject']);
if (pun_strlen($cur_topic['subject']) > $max_subject_length)
$subject_truncated = trim(substr($cur_topic['subject'], 0, ($max_subject_length-5))).' ...';
else
$subject_truncated = $cur_topic['subject'];
echo '<div class="l_icon"><strong><a class="l_icon_padding" href="'.$pun_config['o_base_url'].'/viewtopic.php?id='.$cur_topic['id'].'&action=new" title="'.pun_htmlspecialchars($cur_topic['subject']).'">'.pun_htmlspecialchars($subject_truncated).'</a></strong></div><br /><div style="padding-left: 12px; font-size: 9px; font-family: Tahoma, Arial, Verdana; text-align: left;">by: '.pun_htmlspecialchars($cur_topic['poster']).'<br />'.format_time($cur_topic['last_post']).'</div><br />'."\n";
}
return;
}
}
Thanks
Bingiman.