diff --git a/asso_news.php b/asso_news.php index b427985..cb9c65c 100644 --- a/asso_news.php +++ b/asso_news.php @@ -3,76 +3,7 @@ $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), "News"); define('PUN_ALLOW_INDEX', 1); require PUN_ROOT.'header.php'; require PUN_ROOT.'include/parser.php'; - -function pun_news($fid='', $show=15, $truncate=1) -{ - global $lang_common, $db, $pun_config, $db_prefix; - $max_subject_length = 100; - $show_max_topics = 50; - $fid = intval($fid); - $order_by = 't.posted'; - $forum_sql = ''; - // Was a forum ID supplied? - if ( $fid ) $forum_sql = 'f.id='.$fid.' AND '; - $show = intval($show); - if ($show < 1 || $show > $show_max_topics) - $show = 15; - $saveddate=""; - // Fetch $show topics - $result = $db->query('SELECT t.id, t.poster, t.subject, t.posted, t.last_post, f.id AS fid, f.forum_name FROM '.$db_prefix.'topics AS t INNER JOIN '.$db_prefix.'forums AS f ON t.forum_id=f.id WHERE f.id='.$fid.' AND t.moved_to IS NULL ORDER BY '.$order_by.' DESC') 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 = ''; - 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']; - $newsheading = ''.pun_htmlspecialchars($subject_truncated).' - Posté par '.$cur_topic['poster'].' à '.date('H:i:s', $cur_topic['posted']).'
'; - // Group posts by - $thisdate = date('d n Y', $cur_topic['posted']); - if ($thisdate != $saveddate) - - { - if ($saveddate) - { - $temp .= ""; - } - $temp .= '

'.$thisdate.'

'; - $saveddate = $thisdate; - } - else { - $temp .= '

'; - } - $temp .= $newsheading.'

'; - $id = $cur_topic['id']; - $msg = $db->query('SELECT id, poster, poster_id, poster_ip, poster_email, message, posted, edited, edited_by FROM '.$db_prefix.'posts WHERE topic_id='.$id.' LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error()); - if ( !$db->num_rows($msg) ) continue; - $cur_post = $db->fetch_assoc($msg); - // Display first paragraph only (comment out next four lines to turn off) - if ($truncate == 1) - { - $paragraph = preg_split("/s*n+/", $cur_post['message']); - if (isset($paragraph[1])) { - $cur_post['message'] = $paragraph[0] . "..."; - } - } - $cur_post['message'] = parse_message($cur_post['message'], 0); - $temp .= $cur_post['message']; - $temp .= "

"; - if (isset($output)) { - $output .= $temp; - } - else { - $output = $temp; - } - ++$show_count; - } // end of while - $output .= "
"; - return $output; -} +require PUN_ROOT.'include/news/pun_news.php'; ?>
diff --git a/include/news/pun_news.php b/include/news/pun_news.php new file mode 100644 index 0000000..0d99231 --- /dev/null +++ b/include/news/pun_news.php @@ -0,0 +1,70 @@ + $show_max_topics) + $show = 15; + $saveddate=""; + // Fetch $show topics + $result = $db->query('SELECT t.id, t.poster, t.subject, t.posted, t.last_post, f.id AS fid, f.forum_name FROM '.$db_prefix.'topics AS t INNER JOIN '.$db_prefix.'forums AS f ON t.forum_id=f.id WHERE f.id='.$fid.' AND t.moved_to IS NULL ORDER BY '.$order_by.' DESC') 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 = ''; + 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']; + $newsheading = ''.pun_htmlspecialchars($subject_truncated).' - Posté par '.$cur_topic['poster'].' à '.date('H:i:s', $cur_topic['posted']).'
'; + // Group posts by + $thisdate = date('d n Y', $cur_topic['posted']); + if ($thisdate != $saveddate) + + { + if ($saveddate) + { + $temp .= "
"; + } + $temp .= '

'.$thisdate.'

'; + $saveddate = $thisdate; + } + else { + $temp .= '

'; + } + $temp .= $newsheading.'

'; + $id = $cur_topic['id']; + $msg = $db->query('SELECT id, poster, poster_id, poster_ip, poster_email, message, posted, edited, edited_by FROM '.$db_prefix.'posts WHERE topic_id='.$id.' LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error()); + if ( !$db->num_rows($msg) ) continue; + $cur_post = $db->fetch_assoc($msg); + // Display first paragraph only (comment out next four lines to turn off) + if ($truncate == 1) + { + $paragraph = preg_split("/s*n+/", $cur_post['message']); + if (isset($paragraph[1])) { + $cur_post['message'] = $paragraph[0] . "..."; + } + } + $cur_post['message'] = parse_message($cur_post['message'], 0); + $temp .= $cur_post['message']; + $temp .= "

"; + if (isset($output)) { + $output .= $temp; + } + else { + $output = $temp; + } + ++$show_count; + } // end of while + $output .= "
"; + return $output; +} diff --git a/index-df.php b/index-df.php index 0bb6226..cfb1414 100644 --- a/index-df.php +++ b/index-df.php @@ -11,83 +11,7 @@ $page_title = pun_htmlspecialchars($pun_config['o_board_title']); define('PUN_ALLOW_INDEX', 1); require PUN_ROOT.'header.php'; require PUN_ROOT.'include/parser.php'; - -function pun_news($fid='', $show=15, $truncate=1) -{ - global $lang_common, $db, $pun_config, $db_prefix; - $max_subject_length = 100; - $show_max_topics = 50; - $fid = intval($fid); - $order_by = 't.posted'; - $forum_sql = ''; - // Was a forum ID supplied? - if ( $fid ) $forum_sql = 'f.id='.$fid.' AND '; - $show = intval($show); - if ($show < 1 || $show > $show_max_topics) - $show = 15; - $saveddate=""; - // Fetch $show topics - $result = $db->query('SELECT t.id, t.poster, t.subject, t.posted, t.last_post, f.id AS fid, f.forum_name FROM '.$db_prefix.'topics AS t INNER JOIN '.$db_prefix.'forums AS f ON t.forum_id=f.id WHERE f.id='.$fid.' AND t.moved_to IS NULL ORDER BY '.$order_by.' DESC') 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 = ''; - 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']; - $newsheading = ''.pun_htmlspecialchars($subject_truncated).' - Posté par '.$cur_topic['poster'].' à '.date('H:i:s', $cur_topic['posted']).'
'; - // Group posts by - $thisdate = date('d n Y', $cur_topic['posted']); - if ($thisdate != $saveddate) - - { - if ($saveddate) - { - $temp .= "
"; - } - $temp .= '

'.$thisdate.'

'; - $saveddate = $thisdate; - } - else { - $temp .= '

'; - } - $temp .= $newsheading.'

'; - $id = $cur_topic['id']; - $msg = $db->query('SELECT id, poster, poster_id, poster_ip, poster_email, message, posted, edited, edited_by FROM '.$db_prefix.'posts WHERE topic_id='.$id.' ORDER BY posted ASC LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error()); - if ( !$db->num_rows($msg) ) continue; - $cur_post = $db->fetch_assoc($msg); - // Display first paragraph only. If first paragraph is a blockquote, it will be considered as a single paragraph, even if it's not. - // Nested quote are not supported - //To enable this option, pass 1 to pun_news as 3rd parameters -if ($truncate == 1) - { - $paragraph = preg_split("#\s*\n+#", $cur_post['message']); - if (isset($paragraph[1])) { - if (preg_match("#^\[(quote|i|b|url|img|u|code)(=.*)?\](.*?)\[/\\1\]#s", $phrase, $out)) { - $paragraph[0]=$out[0]; - } - $cur_post['message'] = $paragraph[0] . "..." ; - } - } - - $cur_post['message'] = parse_message($cur_post['message'], 0); - $temp .= $cur_post['message']; - $temp .= "

"; - if (isset($output)) { - $output .= $temp; - } - else { - $output = $temp; - } - ++$show_count; - } // end of while - $output .= "
"; - return $output; -} - +require PUN_ROOT.'include/news/pun_news.php'; ?>

Wiki