Code:<?php
/********************************************************/
/* */
/* News Display module for PHP-Nuke and the phpBB forum */
/* news port */
/* Written by ArtificialIntel & Mighty_Y */
/* Copyright (c) 2003 by ArtificialIntel */
/* All Rights Reserved */
/* */
/********************************************************/
if ( !defined('MODULE_FILE') )
{
die("You can't access this file directly...");
}
if(!isset($mainfile)){
include("mainfile.php");
}
define('INDEX_FILE', true);
$module_name = basename(dirname(__FILE__));
$module_dir = "modules/$module_name/";
get_lang($module_name);
include("header.php");
include($module_dir."bbstuff.php");
include_once($module_dir."fnafunctions.php");
global $db, $prefix, $storyhome, $board_config, $user, $home, $user_news, $cookie, $user_ip, $nukeuser, $user_prefix, $ThemeSel;
$news_id = isset($HTTP_GET_VARS['news_id']) ? intval($HTTP_GET_VARS['news_id']) : 0;
$id = isset($HTTP_GET_VARS['id']) ? intval($HTTP_GET_VARS['id']) : 0;
$page = isset($HTTP_GET_VARS['page']) ? intval($HTTP_GET_VARS['page']) : 0;
if ($page == "") { $page = 1 ; }
if (isset($cookie[3]) AND $user_news == 1) {
$num = $cookie[3];
} else {
$num = $storyhome;
}
$offset = ($page-1) * $num ;
$sql = $db->sql_query("SELECT news_id FROM ".$prefix."_bbtopics WHERE news_id > 0");
$numrows = $db->sql_fetchrow($sql);
if($numrows > 0){
$result = $db->sql_query("select post_id from ".$prefix."_bbapprove_posts");
$numrows2 = $db->sql_numrows($result);
if($numrows2 == "0"){
$topicpost = "";
}
elseif($numrows2 > "0"){
$topicpost = "";
while(list($post_id) = $db->sql_fetchrow($result)){
$topicpost .= " AND topic_first_post_id<>$post_id";
}
}
$forumaccesssql = $db->sql_query("select forum_id from ".$prefix."_bbforums");
$access = "";
while(list($forum_id) = $db->sql_fetchrow($forumaccesssql)){
$is_auth = array();
$is_auth = authcheck(0, $forum_id, $forum_row);
if ( !$is_auth['auth_read'] ){
$access .= " AND forum_id<>$forum_id";
}
}
if ($news_id != 0) {
$sql_count = "select * from ".$prefix."_bbtopics where news_id = $news_id $topicpost $access";
}else{
$sql_count = "select * from ".$prefix."_bbtopics where news_id > 0 $topicpost $access";
}
$result_count = $db->sql_query($sql_count);
$news_count = $db->sql_numrows($result_count);
$total_pages = ceil($news_count / $num);
$sql = "SELECT topic_id, forum_id, topic_poster, topic_replies, topic_title, topic_views, topic_time, topic_first_post_id, news_id FROM ".$prefix."_bbtopics WHERE ";
if($news_id == 0 & $id == 0 & $page == 1){
$sql .= "news_id > 0 $topicpost $access ORDER BY `topic_time` DESC LIMIT $num";
}elseif($news_id == 0 & $id == 0 & $page != 1){
$sql .= "news_id > 0 $topicpost $access ORDER BY `topic_time` DESC limit $offset, $num";
}elseif ($news_id == 0 & $id != 0){
$sql .= "topic_id = ".$id." and news_id > 0 $topicpost $access";
}elseif($news_id != 0 & $page != 1){
$sql .= "news_id = ".$news_id." $topicpost $access ORDER BY `topic_time` DESC limit $offset, $num";
}else{
$sql .= "news_id = ".$news_id." $topicpost $access ORDER BY `topic_time` DESC LIMIT $num";
}
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result)){
if($id != 0){
$sql = "UPDATE ".$prefix."_bbtopics SET topic_views = topic_views + 1 WHERE topic_id =" . $id;
$db->sql_query($sql);
}
$newssql = "SELECT u.username, n.*, p.*, pt.*, c.config_value, t.topic_views, an.user_dateformat, an.user_timezone
FROM ".$user_prefix."_users u, ".$prefix."_bbnews n, ".$prefix."_bbposts p, ".$prefix."_bbposts_text pt, ".$prefix."_bbconfig c, ".$prefix."_bbtopics t, ".$user_prefix."_users an
WHERE u.user_id=$row[topic_poster] AND n.news_id=$row[news_id] AND p.post_id=$row[topic_first_post_id] AND pt.post_id=$row[topic_first_post_id] AND c.config_name='news_item_trim' AND t.topic_id=$row[topic_id] AND an.user_id=1";
$newsresult = $db->sql_query($newssql);
$newsrow = $db->sql_fetchrow($newsresult);
$story_link = "<a href=\"modules.php?name=Forums&file=viewtopic&t=$row[topic_id]\">";
$numreplies = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_bbposts WHERE (topic_id=$row[topic_id] AND post_id <> $row[topic_first_post_id])"));
$aid = $newsrow[username];
$trim_append_body = "...";
$hometext = $newsrow['post_text'];
$bbcode_uid = $newsrow['bbcode_uid'];
$enable_smilies = $newsrow['enable_smilies'];
$title = '';
$pollsql = "select topic_id from ".$prefix."_bbvote_desc where topic_id = $row[topic_id]";
$poll = $db->sql_query($pollsql);
$pollrow = $db->sql_fetchrow($poll);
if ($pollrow!=''){
$title .= 'Poll: ';
}
$title .= stripslashes($row[topic_title]);
$notes = "";
//$time = gmdate($userinfo[user_dateformat], $row[topic_time] + (3600 * $userinfo[user_timezone]));
$time = gmdate('Y-m-d H:i:s', $row[topic_time] + (3600 * $tz));
$time = formatTimestampfna($time);
if($newsrow[config_value] > 0 AND strlen(preg_replace('#(<)([\/]?.*?)(>)#is', "", preg_replace('#(\[)([\/]?.*?)(\])#is', "",$hometext))) > $newsrow[config_value] & $id == 0){
$hometext = trimText($newsrow['post_text'], $newsrow[config_value], $trimmed);
$hometext = parseMessage( $hometext, $bbcode_uid );
//$hometext = acronym_pass( $hometext );
}elseif ( $id == 0 AND strpos( $hometext, htmlspecialchars( '<!--break-->' ) ) != false ){
$hometext = trimText2($newsrow['post_text']);
$hometext = parseMessage( $hometext, $bbcode_uid );
//$hometext = acronym_pass( $hometext );
}else{
$hometext = parseMessage( $newsrow['post_text'], $bbcode_uid );
//$hometext = acronym_pass( $hometext );
}
$readmore = "<a href=\"modules.php?name=".$module_name."&id=$row[topic_id]\">"._FN_READMORE."</a>";
$text2 = substr($hometext, -3);
if ( $is_auth['auth_reply'] ){
$reply = " | (<a href=\"ftopic-reply-.html$row[topic_id]\">Add Comment</a>)";
}
if($text2 == "..."){
$morelink = "( $story_link"._FN_VIEWCOMMENTS."</a> | $numreplies )$reply | ( $readmore )";
}
else
{
$morelink = "( $story_link"._FN_VIEWCOMMENTS."</a> | $numreplies )$reply";
}
$topiclink = "<a href=\"modules.php?name=".$module_name."&news_id=$row[news_id]\">";
themeindex($aid, $aid, $time, $title, $newsrow[topic_views], $title, $hometext, $notes, $morelink, $topic, $newsrow[news_image], $newsrow[news_category], $topiclink);
}
pagination($total_pages, $news_id, $id, $page);
include("footer.php");
}
?>
|