Page 1 of 2

[2.0.12] Freeze User Post Count

Posted: Sun Aug 22, 2004 3:31 pm
by Extensions Robot
MOD Name: Freeze User Post Count
Author: Craven-
MOD Description: Allows the forum administrator to freeze a users postcount, stopping it from increasing/decreasing.


MOD Version: 1.0.3 (Updated 02/25/05)

Download File: freeze_postcount_1_0_3.zip
mods overview page: View
File Size: 4058 Bytes

Security Score: 0

Posted: Thu Aug 26, 2004 9:13 pm
by wGEric
MOD Validated/Released

Notes:
This MOD makes it so that certain users posts don't increase where ever they post.

Posted: Thu Aug 26, 2004 10:05 pm
by ayusuf
I might not use it but this is still a tight mod.

Freeze User Too?

Posted: Mon Aug 30, 2004 10:44 pm
by SessionCustom
Does this mod stop that specific user from posting anything, essentially freezing their account, or does it simply freeze the DISPLAY of the post count?

Thanks

SessionCustom

Posted: Fri Sep 03, 2004 3:12 pm
by Craven-
This MOD prevents phpBB from updating the database ('user_posts' in the users table) when a user makes a post/post is deleted etc.

Essentially this means the display of the users post count on the forum will remain "frozen", and stay the same until they are unfrozen again from the admin cp. It does not prevent them from actually posting.

Great for use on spammers whose only aim is to increase postcount/rank. :wink:

Posted: Sun Sep 05, 2004 12:46 am
by pisqon
This is the error I get:
Error in posting

DEBUG MODE

SQL Error : 1054 Unknown column 'user_posts_frozen' in 'field list'

SELECT user_posts_frozen FROM phpbb_users WHERE user_id = 3

Line : 477
File : /usr/home/matt/corbantis/forums/includes/functions_post.php

Posted: Thu Sep 09, 2004 5:54 pm
by Craven-
Apologies for the late reply.

Did you run the setup script first? You should have uploaded the included 'freeze_posts_update.php' file to your phpBB root directory and executed it.

Also, If anyone tried to e-mail me about the MOD lately, then re-send it because my mail server has been down.

Posted: Fri Dec 17, 2004 7:10 pm
by N-Force
Hmm I have a problem with this mod.

I editted every file I had to. I did a copple of tests, my post count did frozed. But i got a error every time I posted. I came to the conclusion that I forgot to execute the freeze_posts_updates.php. After I executed this file everything seems to be ok, cause the error was gone. So I went to the user panel again and said "yes" to "froze post count". Did some posts but this time it did increased but it had to froze. I came to a conclusion after some tests, that since I executed freeze_posts_updates.php that everything I change in a user won't be saved....so if I say yes to freeze post acount and click OK it is being switched back to no cause it wont save...so has anyone a idea how to fix this problem :?

NEVER MIND

I probarly forgot to change something in the admin_users.php cause when I did that file over and uploaded it, it suddenly did worked so nvm.

Posted: Mon Dec 27, 2004 4:18 pm
by angel of death
It's great!! ^_^

Question, though: when you de-freeze the user, the count starts again from where it's been frozen, or it automatically jumps up to the effective number of posts made by that user?

thank you!

Posted: Wed Jan 19, 2005 6:51 pm
by Craven-
Thanks!
My apologies for the (very) late reply! I had topic notification on, honest!

I guess you have figured out for yourself now, but for the benefit of others, when you unfreeze, the count starts from where it was frozen.

Posted: Sun Feb 20, 2005 9:46 am
by obiku
This freeze mod only works one way. If the users places a post the postcount isn't increased, but if you remove a post the postcount will well decrease. How can I stop this behavour.

Posted: Sun Feb 20, 2005 3:17 pm
by obiku
obiku wrote: This freeze mod only works one way. If the users places a post the postcount isn't increased, but if you remove a post the postcount will well decrease. How can I stop this behavour.

I have found my problem, now I only need a solution. I use the modcp_mod. If u remove a posting with the modcp_mod the users_post is decreased.
Here is a peace of code of the modcp mod

Code: Select all

	case 'delete':
		if( !$is_auth['auth_delete'] )
		{
			message_die(MESSAGE, sprintf($lang['Sorry_auth_delete'], $is_auth['auth_delete_type']));
		}

		$page_title = $lang['Mod_CP'] .' ('. $lang['Delete'] .')';
		include($phpbb_root_path .'includes/page_header.'.$phpEx);

		if( $confirm )
		{
			include($phpbb_root_path .'includes/functions_search.'.$phpEx);

			$topics = ( isset($HTTP_POST_VARS['topic_id_list']) ) ? $HTTP_POST_VARS['topic_id_list'] : array($topic_id);
			$topic_id_sql = '';
			for( $i = 0; $i < count($topics); $i++ )
			{
				$topic_id_sql .= ( ( $topic_id_sql != '' ) ? ', ' : '' ) . intval($topics[$i]);
			}

			$sql = "SELECT topic_id FROM ". TOPICS_TABLE ." WHERE topic_id IN ($topic_id_sql) AND forum_id = $forum_id";
			if( !($result = $db->sql_query($sql)) )
			{
				message_die(GENERAL_ERROR, 'could not get topic id information.', '', __LINE__, __FILE__, $sql);
			}
			$topic_id_sql = '';
			while( $row = $db->sql_fetchrow($result) )
			{
				$topic_id_sql .= (($topic_id_sql != '') ? ', ' : '') . intval($row['topic_id']);
			}
			$db->sql_freeresult($result);

			$sql = "SELECT poster_id, COUNT(post_id) AS posts FROM ". POSTS_TABLE ."
				WHERE topic_id IN ($topic_id_sql) GROUP BY poster_id";
			if( !($result = $db->sql_query($sql)) )
			{
				message_die(GENERAL_ERROR, 'could not get poster id information.', '', __LINE__, __FILE__, $sql);
			}
			$count_sql = array();
			while( $row = $db->sql_fetchrow($result) )
			{
				$count_sql[] = "UPDATE ". USERS_TABLE ." SET user_posts = user_posts - ". $row['posts'] ."
						WHERE user_id = ". $row['poster_id'];
			}
			$db->sql_freeresult($result);

			if( sizeof($count_sql) )
			{
				for($i = 0; $i < sizeof($count_sql); $i++)
				{
					if( !$db->sql_query($count_sql[$i]) )
					{
						message_die(GENERAL_ERROR, 'could not update user post count information.', '', __LINE__, __FILE__, $sql);
					}
				}
			}
			
			$sql = "SELECT post_id FROM ". POSTS_TABLE ." WHERE topic_id IN ($topic_id_sql)";
			if( !($result = $db->sql_query($sql)) )
			{
				message_die(GENERAL_ERROR, 'could not get post id information.', '', __LINE__, __FILE__, $sql);
			}
			$post_id_sql = '';
			while( $row = $db->sql_fetchrow($result) )
			{
				$post_id_sql .= ( ( $post_id_sql != '' ) ? ', ' : '' ) . intval($row['post_id']);
			}
			$db->sql_freeresult($result);

			$sql = "SELECT vote_id FROM ". VOTE_DESC_TABLE ." WHERE topic_id IN ($topic_id_sql)";
			if( !($result = $db->sql_query($sql)) )
			{
				message_die(GENERAL_ERROR, 'could not get vote id information.', '', __LINE__, __FILE__, $sql);
			}
			$vote_id_sql = '';
			while( $row = $db->sql_fetchrow($result) )
			{
				$vote_id_sql .= ( ( $vote_id_sql != '' ) ? ', ' : '' ) . $row['vote_id'];
			}
			$db->sql_freeresult($result);

			$sql = "DELETE FROM ". TOPICS_TABLE ." WHERE topic_id IN ($topic_id_sql) OR topic_moved_id IN ($topic_id_sql)";
			if( !$db->sql_query($sql, BEGIN_TRANSACTION) )
			{
				message_die(GENERAL_ERROR, 'could not delete topics.', '', __LINE__, __FILE__, $sql);
			}

			if( $post_id_sql != '' )
			{
				$sql = "DELETE FROM ". POSTS_TABLE ." WHERE post_id IN ($post_id_sql)";
				if( !$db->sql_query($sql) )
				{
					message_die(GENERAL_ERROR, 'could not delete posts.', '', __LINE__, __FILE__, $sql);
				}
				// Log actions MOD Start
				log_action('verwijder', $topic_id_sql, $userdata['user_id'], $userdata['username']);
				// Log actions MOD End

				$sql = "DELETE FROM ". POSTS_TEXT_TABLE ." WHERE post_id IN ($post_id_sql)";
				if( !$db->sql_query($sql) )
				{
					message_die(GENERAL_ERROR, 'could not delete posts text.', '', __LINE__, __FILE__, $sql);
				}
				remove_search_post($post_id_sql);
			}

			if( $vote_id_sql != '' )
			{
				$sql = "DELETE FROM ". VOTE_DESC_TABLE ." WHERE vote_id IN ($vote_id_sql)";
				if( !$db->sql_query($sql) )
				{
					message_die(GENERAL_ERROR, 'could not delete vote descriptions.', '', __LINE__, __FILE__, $sql);
				}

				$sql = "DELETE FROM ". VOTE_RESULTS_TABLE ." WHERE vote_id IN ($vote_id_sql)";
				if( !$db->sql_query($sql) )
				{
					message_die(GENERAL_ERROR, 'could not delete vote results.', '', __LINE__, __FILE__, $sql);
				}

				$sql = "DELETE FROM ". VOTE_USERS_TABLE ." WHERE vote_id IN ($vote_id_sql)";
				if( !$db->sql_query($sql) )
				{
					message_die(GENERAL_ERROR, 'could not delete vote users.', '', __LINE__, __FILE__, $sql);
				}
			}

			$sql = "DELETE FROM ". TOPICS_WATCH_TABLE ." WHERE topic_id IN ($topic_id_sql)";
			if( !$db->sql_query($sql, END_TRANSACTION) )
			{
				message_die(GENERAL_ERROR, 'could not delete watched post list.', '', __LINE__, __FILE__, $sql);
			}
			sync('forum', $forum_id);

			if( !empty($topic_id) )
			{
				$redirect_page = "viewforum.$phpEx?". POST_FORUM_URL ."=$forum_id&sid=". $userdata['session_id'];
				$l_redirect = sprintf($lang['Click_return_forum'], '<a href="'. $redirect_page .'">', '</a>');
			}
			else
			{
				$redirect_page = "modcp.$phpEx?". POST_FORUM_URL ."=$forum_id&sid=". $userdata['session_id'];
				$l_redirect = sprintf($lang['Click_return_modcp'], '<a href="'. $redirect_page .'">', '</a>') .'<br \><br \>'. sprintf($lang['Click_return_forum'], '<a href="'. "viewforum.$phpEx?". POST_FORUM_URL ."=$forum_id&sid=". $userdata['session_id'] .'">', '</a>');
			}
			$template->assign_vars(array('META' => '<meta http-equiv="refresh" content="3;url='. $redirect_page .'">'));
			message_die(GENERAL_MESSAGE, (( count($topics) == '1' ) ? $lang['Mod_CP_topic_removed'] : $lang['Topics_Removed']) .'<br /><br />'. $l_redirect);
		}
		else
		{
			if( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) )
			{
				message_die(GENERAL_MESSAGE, $lang['None_selected']);
			}

			$hidden_fields = '<input type="hidden" name="sid" value="'. $userdata['session_id'] .'" /><input type="hidden" name="mode" value="'. $mode .'" /><input type="hidden" name="type" value="'. $type .'" /><input type="hidden" name="'. POST_FORUM_URL .'" value="'. $forum_id .'" />';
			if( isset($HTTP_POST_VARS['topic_id_list']) )
			{
				$topics = $HTTP_POST_VARS['topic_id_list'];
				for( $i = 0; $i < count($topics); $i++ )
				{
					$hidden_fields .= '<input type="hidden" name="topic_id_list[]" value="'. intval($topics[$i]) .'" />';
				}
			}
			else
			{
				$hidden_fields .= '<input type="hidden" name="'. POST_TOPIC_URL .'" value="'. $topic_id .'" />';
			}

			$template->set_filenames(array('confirm' => 'confirm_body.tpl'));
			$template->assign_vars(array(
				'MESSAGE_TITLE' => $lang['Confirm'],
				'MESSAGE_TEXT' => $lang['Confirm_delete_topic'],
				'L_YES' => $lang['Yes'],
				'L_NO' => $lang['No'],
				'S_CONFIRM_ACTION' => append_sid("modcp.$phpEx"),
				'S_HIDDEN_FIELDS' => $hidden_fields,
			));
			$template->pparse('confirm');
			include($phpbb_root_path .'includes/page_tail.'.$phpEx);
		}
		break;

Posted: Sun Feb 20, 2005 3:27 pm
by Craven-
obiku wrote: This freeze mod only works one way. If the users places a post the postcount isn't increased, but if you remove a post the postcount will well decrease. How can I stop this behavour.


Indeed you are correct. If an entire topic is removed and a user who has posted in that topic has had their postcount frozen, their postcount will still decrease. Removing single posts by a frozen user however, does not affect the post count.

Thanks for pointing out this bug!
I have fixed this and submitted an updated MOD to be validated.

In the mean while, you can use this fix:

Code: Select all

# 
#-----[ OPEN ]------------------------------------------ 
#

modcp.php

# 
#-----[ FIND ]------------------------------------------ 
# 

while ( $row = $db->sql_fetchrow($result) )
{
	$count_sql[] = "UPDATE " . USERS_TABLE . " 
		SET user_posts = user_posts - " . $row['posts'] . " 
		WHERE user_id = " . $row['poster_id'];
}

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 

while ( $row = $db->sql_fetchrow($result) )
{
	//
	// Determine whether the users
	// post count is frozen
	// or not.
	//
	$sql = "SELECT user_posts_frozen
		FROM " . USERS_TABLE . "
		WHERE user_id = " . $row['poster_id'];


	if( !($fresult = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Error in deleting', '', __LINE__, __FILE__, $sql);
	}

	$frow = $db->sql_fetchrow($fresult);
	$posts_frozen = $frow['user_posts_frozen'];


	// 
	// Only update the users post 
	// count if they aren't frozen!
	//
	if ( !$posts_frozen )
	{
		$count_sql[] = "UPDATE " . USERS_TABLE . " 
			SET user_posts = user_posts - " . $row['posts'] . " 
			WHERE user_id = " . $row['poster_id'];
	}
}

Posted: Sun Feb 20, 2005 4:01 pm
by obiku
Thnx, this works great :D :D

Posted: Sun Feb 20, 2005 4:08 pm
by obiku
If you use the Find_input_1_0_3_mod from Adrian Cockburn (http://www.netclectic.com) you have to add some lines in the functions_insert_posts.php

Code: Select all

#
#--------FIND----------------------------
#
    // update the first / last post ids for the topic
    $first_post_sql = ( $mode == 'newtopic' ) ? ", topic_first_post_id = $post_id  " : ' , topic_replies=topic_replies+1'; 
    $sql = "UPDATE " . TOPICS_TABLE . " SET 
                topic_last_post_id = $post_id 
                $first_post_sql
            WHERE topic_id = $topic_id";
    if ( !$db->sql_query($sql, BEGIN_TRANSACTION) )
    {
        $error_die_function(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
    }
#
#----- ADD AFTER-----------------------------
#
    
		//
		// Determine whether a user's
		// post count is frozen
		// or not.
		//
		
		$sql = "SELECT user_posts_frozen
			FROM " . USERS_TABLE . "
			WHERE user_id = $user_id";

if( !($result = $db->sql_query($sql)) )
		{
			message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
		}
		
		$row = $db->sql_fetchrow($result);
					
		$posts_frozen = $row['user_posts_frozen'];

// 
		// Only update the user's post 
		// count if they aren't frozen!
		//
		
#
#-----FIND--------------------------
#
    // update the user's post count and commit the transaction
    $sql = "UPDATE " . USERS_TABLE . " SET 
                user_posts = user_posts + 1
            WHERE user_id = $user_id";
    if ( !$db->sql_query($sql, END_TRANSACTION) )
    {
        $error_die_function(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
    }
#
#-----REPLACE WITH ------------------
#
		if ($posts_frozen != 1) 
		{
	    // update the user's post count and commit the transaction
	    $sql = "UPDATE " . USERS_TABLE . " SET 
	                user_posts = user_posts + 1
	            WHERE user_id = $user_id";
	    if ( !$db->sql_query($sql, END_TRANSACTION) )
	    {
	        $error_die_function(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
	    }
    }
Now the user_post count isn't increasing anymore