[ABD] News Mod v1.2.1

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment! No new topics are allowed in this forum.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: MOD Development Forum rules

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.
leokor
Registered User
Posts: 94
Joined: Wed Sep 25, 2002 3:37 am
Contact:

Post by leokor »

dyingeyes wrote: Fatal error: Cannot redeclare news_auth() (previously declared in C:\Program Files\Apache Group\Apache2\htdocs\phpBB2\includes\news.php:36) in C:\Program Files\Apache Group\Apache2\htdocs\phpBB2\includes\news.php on line 36


Just rename the function.

Leo
dyingeyes
Registered User
Posts: 47
Joined: Fri Nov 01, 2002 1:14 am
Contact:

Post by dyingeyes »

nope

Fatal error: Call to undefined function: news_auth() in C:\Program Files\Apache Group\Apache2\htdocs\phpBB2\includes\news.php on line 121
Having potential means you havent done anything yet!
leokor
Registered User
Posts: 94
Joined: Wed Sep 25, 2002 3:37 am
Contact:

Post by leokor »

dyingeyes wrote: nope

Fatal error: Call to undefined function: news_auth() in C:\Program Files\Apache Group\Apache2\htdocs\phpBB2\includes\news.php on line 121


Well, it goes without saying that you need to replace news_auth with the new name everywhere it is used in the phpBB code.

Leo
leokor
Registered User
Posts: 94
Joined: Wed Sep 25, 2002 3:37 am
Contact:

Post by leokor »

Oh, wait. I didn't see... damn, I thought you had a naming conflict with some other software. It's something different.

I'm too tired...

Leo
dyingeyes
Registered User
Posts: 47
Joined: Fri Nov 01, 2002 1:14 am
Contact:

Post by dyingeyes »

nope, not a conflict. and the fuction news_auth() isnt defined in any other .php either. here is the entire source code:

Code: Select all

<?php
/***************************************************************************
 *                             includes/news.php
 *                            -------------------
 *   begin                : Monday, Jan 14, 2002
 *   copyright            : (C) 2002 Samuel Cochran
 *   email                : sam@wyvern.com.au
 *
 *   $Id: news.php,v 1.2.1 2002/05/30 20:41:00 sj26 Exp $
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

if ( !defined('IN_PHPBB') )
{
	die("Hacking attempt");
}


include_once($phpbb_root_path . 'includes/bbcode.'.$phpEx);

/** 
 * News auth
 * Authenticates a forum and checks if the user can view/read it. 
 * If not, pops the news item out of the array and checks the next 
 * news item.
 **/ 
function news_auth(&$news, $i)
{
	global $userdata, $is_auth;

	// Get all forum data (only once)
	if( empty($is_auth) )
	{
		$is_auth = auth(AUTH_ALL, AUTH_LIST_ALL, $userdata);
	}

	// Check permissions
	if( !$is_auth[$news[$i]['forum_id']]['auth_view'] || !$is_auth[$news[$i]['forum_id']]['auth_read'] )
	{
		// Pop off unauthorized entry
		array_splice($news, $i, 1);

		// If an entry still exists, check it
		if( isset($news[$i]) )
		{
			news_auth($news, $i);
		}
	}
}

$is_auth = array();

// 
// Assign some basic language variables
// 
$template->assign_vars(array(
	'NEWS_LINK' => append_sid("news.$phpEx"),

	'L_NEWS' => $lang['News'],
	'L_AUTHOR' => $lang['Author'],
	'L_READ_MORE' => $lang['Read_more'],
	'L_COMMENTS' => $lang['Comments'],
	'L_NEWS_ARCHIVE' => $lang['News_Archive'])
);

// 
// Here we have the (*very* simplified) sql statement ;)
// I knew there was an easy way :roll:
// 
$sql = "SELECT t.topic_id, t.forum_id, t.topic_title, t.topic_time, t.topic_replies, t.topic_last_post_id, t.topic_views, t.topic_vote, u.username, u.user_id, u.user_rank, u.user_sig, u.user_sig_bbcode_uid, u.user_allowsmile, p.*,  pt.post_text, pt.post_subject, pt.bbcode_uid
	FROM " . FORUMS_TABLE . " f, " . TOPICS_TABLE  . " t, " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt 
	WHERE f.forum_news = '" . TRUE . "' 
		AND t.forum_id = f.forum_id 
		AND p.topic_id = t.topic_id 
		AND p.post_id = t.topic_first_post_id 
		AND pt.post_id = p.post_id 
		AND u.user_id = p.poster_id 
		AND ((
				f.forum_news_post = '" . TRUE . "' 
				AND t.topic_type = '" . POST_NORMAL . "' 
			)
			OR (
				f.forum_news_sticky = '" . TRUE . "' 
				AND t.topic_type = '" . POST_STICKY . "' 
			)
			OR (
				f.forum_news_announce = '" . TRUE . "' 
				AND (
					t.topic_type = '" . POST_ANNOUNCE . "' 
					OR t.topic_type = '" . POST_GLOBAL_ANNOUNCE . "' 
				)
			)
		)
	ORDER BY topic_time DESC";

if( !$result = $db->sql_query($sql) )
{
	message_die(GENERAL_ERROR, "Couldn't obtain news data", "", __LINE__, __FILE__, $sql);
}
else
{
	$news = $db->sql_fetchrowset($result);

	for( $i = 0; $i < ( !defined('NEWS_ARCHIVE') ? $board_config['news_items'] : @count($news) ); $i++ )
	{
		// Stop from trying to display a non-existant topic
		if( !isset($news[$i]) || empty($news[$i]) )
		{
			break;
		}

		news_auth($news, $i);

		//
		// Main part where bbcode is parsed and stuff like that regarding the post text
		//
		$message = $news[$i]['post_text'];
		$bbcode_uid = $news[$i]['bbcode_uid'];
		$poll = '';

		$user_sig = ( $news[$i]['enable_sig'] && $news[$i]['user_sig'] != '' && $board_config['news_display_signature'] ) ? $news[$i]['user_sig'] : "";
		$user_sig_bbcode_uid = $news[$i]['user_sig_bbcode_uid'];

		//
		// Define censored word matches
		//
		$orig_word = array();
		$replacement_word = array();
		obtain_word_list($orig_word, $replacement_word);

		$poster_id = $news[$i]['user_id'];
		$poster = $news[$i]['username'];

		//
		// If the board has HTML off but the post has HTML
		// on then we process it, else leave it alone
		//
		if( !$board_config['allow_html'] )
		{
			if( $user_sig != "" && $userdata['user_allowhtml'] )
			{
				$user_sig = preg_replace("#(<)([\/]?.*?)(>)#is", "<\\2>", $user_sig);
			}
			if( $news[0]['enable_html'] )
			{
				$message = preg_replace("#(<)([\/]?.*?)(>)#is", "<\\2>", $message);
			}
		}

		//
		// Parse message and/or sig for BBCode if reqd
		//
		if( $board_config['allow_bbcode'] )
		{
			if( $user_sig != '' && $user_sig_bbcode_uid != '' )
			{
				$user_sig = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($user_sig, $user_sig_bbcode_uid) : preg_replace("/\:[0-9a-z\:]+\]/si", "]", $user_sig);
			}
			if( $bbcode_uid != '' )
			{
				$message = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace("/\:[0-9a-z\:]+\]/si", "]", $message);
			}
		}
		if( $user_sig != '' )
		{
			$user_sig = make_clickable($user_sig);
		}
		$message = make_clickable($message);

		//
		// Replace naughty words
		//
		if( count($orig_word) )
		{
			if( $user_sig != '' )
			{
				$user_sig = preg_replace($orig_word, $replacement_word, $user_sig);
			}
			$post_subject = preg_replace($orig_word, $replacement_word, $post_subject);
			$message = preg_replace($orig_word, $replacement_word, $message);
		}

		//
		// Parse smilies
		//
		if( $board_config['allow_smilies'] )
		{
			if( $news[$i]['user_allowsmile'] && $user_sig != "" )
			{
				$user_sig = smilies_pass($user_sig);
			}
			if( $news[$i]['enable_smilies'] )
			{
				$message = smilies_pass($message);
			}
		}

		//
		// Replace newlines (we use this rather than nl2br because
		// till recently it wasn't XHTML compliant)
		//
		if( $user_sig != '' )
		{
			$user_sig = '<br /><hr />' . str_replace("\n", "\n<br />", $user_sig);
		}

		if( $board_config['news_display_edit_info'] )
		{
			//
			// Editing information
			//
			if( $news[$i]['post_edit_count'] )
			{
				$l_edit_time_total = ( $news[$i]['post_edit_count'] == 1 ) ? $lang['Edited_time_total'] : $lang['Edited_times_total'];

				$l_edited_by = '<br />' . sprintf($l_edit_time_total, $poster, create_date($board_config['default_dateformat'], $news[$i]['post_edit_time'], $board_config['board_timezone']), $news[$i]['post_edit_count']);
			}
			else
			{
				$l_edited_by = '';
			}
		}

		$message = str_replace("\n", "\n<br />\n", $message);

		if( $board_config['news_trim_char'] != "" )
		{
			$message = explode($board_config['news_trim_char'], $message);
			$message = $message[0];
			$message .= ' ...<br /><p align="right"><a href="' . append_sid("viewtopic.$phpEx?t=" . $news[$i]['topic_id']) . '">Read more</a>&nbsp;</p>';
		}

		$l_comment = ($news[$i]['topic_replies'] == "1") ? strtolower($lang['Comment']) : strtolower($lang['Comments']);
		$poster_name = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&id=" . $news[$i]['user_id']) . "\">$poster</a>";
		$topic_time = create_date($board_config['news_time_format'], $news[$i]['topic_time'], $board_config['board_timezone']);

		//
		// Assign replacement variables to template
		//
		$template->assign_block_vars('newsrow',	array(
			'TOPIC_ID' => $news[$i]['topic_id'],
			'TOPIC_TITLE' => $news[$i]['topic_title'],
			'TOPIC_TIME' => $topic_time,
			'TOPIC_REPLIES' => $news[$i]['topic_replies'],
			'TOPIC_VIEWS' => $news[$i]['topic_views'],

			'TOPIC_LINK' => append_sid("viewtopic.$phpEx?t=" . $news[$i]['topic_id']),
			'TOPIC_LAST_POST_LINK' => append_sid("viewtopic.$phpEx?p=" . $news[$i]['topic_last_post_id'] . "#" . $news[$i]['topic_last_post_id']),

			'POSTER_NAME' => $poster_name,

			'POST_SUBJECT' => $post_subject,
			'MESSAGE' => $message,
			'SIGNATURE' => $user_sig,
			'EDITED_MESSAGE' => $l_edited_by,
			'READS' => sprintf($lang['Reads'], $news[$i]['topic_title']),
			'POSTED_BY_ON' => sprintf('Posted by %s on %s', $poster_name, $topic_time),

			'NEWS_POLL_DISPLAY' => $poll,

			'L_COMMENT' => $l_comment)
		);

		//
		// Does this topic contain a poll? 
		//
		if ( !empty($news[$i]['topic_vote']) && $board_config['news_display_polls'] )
		{
			$sql = "SELECT vd.vote_id, vd.vote_text, vd.vote_start, vd.vote_length, vr.vote_option_id, vr.vote_option_text, vr.vote_result
				FROM " . VOTE_DESC_TABLE . " vd, " . VOTE_RESULTS_TABLE . " vr
				WHERE vd.topic_id = " . $news[$i]['topic_id'] . "
					AND vr.vote_id = vd.vote_id
				ORDER BY vr.vote_option_id ASC";
			if ( !($result = $db->sql_query($sql)) )
			{
				message_die(GENERAL_ERROR, "Could not obtain vote data for this topic", '', __LINE__, __FILE__, $sql);
			}

			if ( $vote_info = $db->sql_fetchrowset($result) )
			{
				$template->assign_block_vars('newsrow.switch_poll', array());
				
				$db->sql_freeresult($result);
				$vote_options = count($vote_info);

				$vote_id = $vote_info[0]['vote_id'];
				$vote_title = $vote_info[0]['vote_text'];

				$sql = "SELECT vote_id
					FROM " . VOTE_USERS_TABLE . "
					WHERE vote_id = $vote_id
						AND vote_user_id = " . $userdata['user_id'];
				if ( !($result = $db->sql_query($sql)) )
				{
					message_die(GENERAL_ERROR, "Could not obtain user vote data for this topic", '', __LINE__, __FILE__, $sql);
				}

				$user_voted = ( $row = $db->sql_fetchrow($result) ) ? TRUE : 0;
				$db->sql_freeresult($result);

				if ( isset($HTTP_GET_VARS['vote']) || isset($HTTP_POST_VARS['vote']) )
				{
					$view_result = ( ( ( isset($HTTP_GET_VARS['vote']) ) ? $HTTP_GET_VARS['vote'] : $HTTP_POST_VARS['vote'] ) == 'viewresult' ) ? TRUE : 0;
				}
				else
				{
					$view_result = 0;
				}

				$poll_expired = ( $vote_info[0]['vote_length'] ) ? ( ( $vote_info[0]['vote_start'] + $vote_info[0]['vote_length'] < time() ) ? TRUE : 0 ) : 0;

				if ( count($orig_word) )
				{
					$vote_title = preg_replace($orig_word, $replacement_word, $vote_title);
				}

				if ( $user_voted || $view_result || $poll_expired || !$is_auth[$news[$i]['forum_id']]['auth_vote'] || $news[$i]['topic_status'] == TOPIC_LOCKED )
				{
					$template->assign_vars(array(
						'L_TOTAL_VOTES' => $lang['Total_votes'])
					);

					$vote_results_sum = 0;

					for($j = 0; $j < $vote_options; $j++)
					{
						$vote_results_sum += $vote_info[$j]['vote_result'];
					}

					$template->assign_block_vars('newsrow.switch_poll_view', array(
						'POLL_QUESTION' => $vote_title,
						'TOTAL_VOTES' => $vote_results_sum,
	
						'S_POLL_ACTION' => append_sid("posting.$phpEx?" . POST_TOPIC_URL . "=$topic_id"))
					);

					$vote_graphic = 0;
					$vote_graphic_max = count($images['voting_graphic']);

					for($j = 0; $j < $vote_options; $j++)
					{
						$vote_percent = ( $vote_results_sum > 0 ) ? $vote_info[$j]['vote_result'] / $vote_results_sum : 0;
						$vote_graphic_length = round($vote_percent * $board_config['vote_graphic_length']);

						$vote_graphic_img = $images['voting_graphic'][$vote_graphic];
						$vote_graphic = ($vote_graphic < $vote_graphic_max - 1) ? $vote_graphic + 1 : 0;

						if ( count($orig_word) )
						{
							$vote_info[$j]['vote_option_text'] = preg_replace($orig_word, $replacement_word, $vote_info[$j]['vote_option_text']);
						}

						$template->assign_block_vars('newsrow.switch_poll_view.poll_option', array(
							'POLL_OPTION_CAPTION' => $vote_info[$j]['vote_option_text'],
							'POLL_OPTION_RESULT' => $vote_info[$j]['vote_result'],
							'POLL_OPTION_PERCENT' => sprintf("%.1d%%", ($vote_percent * 100)),

							'POLL_OPTION_IMG' => $vote_graphic_img,
							'POLL_OPTION_IMG_WIDTH' => $vote_graphic_length)
						);
					}
				}
				else
				{
					$template->assign_vars(array(
						'L_SUBMIT_VOTE' => $lang['Submit_vote'],
						'L_VIEW_RESULTS' => $lang['View_results'])
					);

					$template->assign_block_vars('newsrow.switch_poll_vote', array(
						'POLL_QUESTION' => $vote_title,
	
						'S_HIDDEN_FIELDS' => '<input type="hidden" name="topic_id" value="' . $news[$i]['topic_id'] . '"><input type="hidden" name="mode" value="vote">',
						'S_POLL_ACTION' => append_sid("posting.$phpEx?" . POST_TOPIC_URL . '=' . $news[$i]['topic_id']),
	
						'U_VIEW_RESULTS' => append_sid(basename(__FILE__) . '?' . ( $cat_id ? POST_CAT_URL . '=' . $cat_id . '&' : '' ) . "vote=viewresult"))
					);

					for($j = 0; $j < $vote_options; $j++)
					{
						if ( count($orig_word) )
						{
							$vote_info[$j]['vote_option_text'] = preg_replace($orig_word, $replacement_word, $vote_info[$j]['vote_option_text']);
						}

						$template->assign_block_vars('newsrow.switch_poll_vote.poll_option', array(
							'POLL_OPTION_ID' => $vote_info[$j]['vote_option_id'],
							'POLL_OPTION_CAPTION' => $vote_info[$j]['vote_option_text'])
						);
					}
				}
			}
		}
		else
		{
			$template->assign_block_vars('newsrow.switch_no_poll', array());
		}
	}
}

?>
Having potential means you havent done anything yet!
dyingeyes
Registered User
Posts: 47
Joined: Fri Nov 01, 2002 1:14 am
Contact:

Post by dyingeyes »

ok i fixed that problem, but now whenever i click on the + sign next to a topic, it gives me an error about "object expected" and it tells me it origionated in index.php
Having potential means you havent done anything yet!
jovenile
Registered User
Posts: 4
Joined: Sun Sep 15, 2002 2:08 am

Post by jovenile »

don't forget to copy everything included in the mod file..

such as the "rollout.js" file.. that's what i forgot..
elipse..
ub3x
Registered User
Posts: 14
Joined: Sun Nov 24, 2002 9:13 am
Location: michigan
Contact:

Post by ub3x »

undergoing maintenance :(
ub3r.net - ask me anything
aforum.us - a forum for artists and art appreciators
MattousHardyous
Registered User
Posts: 15
Joined: Thu Nov 28, 2002 10:17 pm
Location: Kent, England
Contact:

Post by MattousHardyous »

Hey all, I think this mod may of cause a problem with my admin index.php file.

Take a look here http://www.phpbb.com/phpBB/viewtopic.php?t=58342 and you can see for yourself.

I was just wondering if anyone else has had this problem? and if anyone knows how I can fix this?
User avatar
thewizard
Registered User
Posts: 356
Joined: Sun Sep 29, 2002 7:46 am

Re: [Dev] News Mod v1.1.3

Post by thewizard »

sj26 wrote: News Mod

» Downloads

That's right! remember that news mod everyone loves ;)
Here's a shot to refresh:
Image

It's finally been released, under new ownership, new and improved!

New features:
  • Multiple Forums
  • Auth checking (only once per forum, quicker)
  • Specification of Announcements, Stickies and Normal Posts ofr each forum (mix and match)
  • Supports polls
  • Better javascript code
  • Easy-to-use configuration panel - no more configuration file editing!
  • EasyModv0.4alpha compatible
  • Attachment mod support soming soon!
Click Here for more details...


why is it that everytime this forum is posted its not a real forum? it always seems to be undercontruction.
Stijntje
Registered User
Posts: 45
Joined: Sun Jun 16, 2002 4:21 pm

Post by Stijntje »

please give me a new link to download, this site is gone!
veni, vidi, vici
Conoscenza
Registered User
Posts: 2
Joined: Thu Dec 19, 2002 6:50 pm
Location: Canada
Contact:

Post by Conoscenza »

any updates??
dyingeyes
Registered User
Posts: 47
Joined: Fri Nov 01, 2002 1:14 am
Contact:

Post by dyingeyes »

is there any way of having this news mod able to select certain individual posts only?
Having potential means you havent done anything yet!
miguetoo
Registered User
Posts: 1
Joined: Fri Nov 01, 2002 3:15 am

Post by miguetoo »

could someone post a link to their site the mod..? it's been awhile since sj26 had his board down.

please.. anyone upload the mod on their site for the public to download..

or email me an attachment to mmj@junglemate.com the mod for me to upload on my site..

thanks in advance..
elipse..
sj26
Registered User
Posts: 447
Joined: Fri Dec 14, 2001 4:06 pm
Location: /dev/cpu/[0-9]+ :D
Contact:

Post by sj26 »

OK, I'm back.

This weekend my server will be finally up again... and it's NOT WYVERN.

http://mods.sj26.bur.st/ should work soon. It was working before, but I had to do some updates on the server, then decided to switch to Debian, so I'm trying to update apache, etc...

Once it works I'll post again. I also want to incorporate RSS/RDF news pulling so that news appears automatically.

Well, I'll post again soon.
[ Working on: It's a secret! ]
[ Links: My Mods | My Site | PALGN ]
Locked

Return to “[2.0.x] MODs in Development”