[2.0.12] Freeze User Post Count

The cleanup is complete. This forum is now read only.

Rating:

Excellent!
7
78%
Very Good
1
11%
Good
1
11%
Fair
0
No votes
Poor
0
No votes
 
Total votes: 9

Extensions Robot
Extensions Robot
Extensions Robot
Posts: 28531
Joined: Sat Aug 16, 2003 7:36 am

[2.0.12] Freeze User Post Count

Post 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
Last edited by Extensions Robot on Mon Apr 30, 2007 12:27 am, edited 1 time in total.
(this is a non-active account manager for the phpBB Extension Customisations Team)
wGEric
Former Team Member
Posts: 8805
Joined: Sun Oct 13, 2002 3:01 am
Location: Friday
Name: Eric Faerber
Contact:

Post by wGEric »

MOD Validated/Released

Notes:
This MOD makes it so that certain users posts don't increase where ever they post.
ayusuf
I've Been Banned!
Posts: 917
Joined: Fri Feb 06, 2004 11:00 pm
Location: Orlando,Fl
Contact:

Post by ayusuf »

I might not use it but this is still a tight mod.
SessionCustom
Registered User
Posts: 4
Joined: Wed Aug 11, 2004 4:31 pm

Freeze User Too?

Post 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
Craven-
Registered User
Posts: 19
Joined: Fri Jun 06, 2003 10:51 am

Post 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:
pisqon
Registered User
Posts: 132
Joined: Mon Aug 09, 2004 5:12 am
Contact:

Post 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
Craven-
Registered User
Posts: 19
Joined: Fri Jun 06, 2003 10:51 am

Post 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.
N-Force
Registered User
Posts: 2
Joined: Fri Dec 17, 2004 7:00 pm

Post 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.
User avatar
angel of death
Registered User
Posts: 6
Joined: Mon Sep 06, 2004 2:00 pm

Post 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!
Craven-
Registered User
Posts: 19
Joined: Fri Jun 06, 2003 10:51 am

Post 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.
User avatar
obiku
Registered User
Posts: 73
Joined: Sun Oct 10, 2004 6:54 pm
Location: The Netherlands

Post 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.
User avatar
obiku
Registered User
Posts: 73
Joined: Sun Oct 10, 2004 6:54 pm
Location: The Netherlands

Post 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;
Craven-
Registered User
Posts: 19
Joined: Fri Jun 06, 2003 10:51 am

Post 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'];
	}
}
User avatar
obiku
Registered User
Posts: 73
Joined: Sun Oct 10, 2004 6:54 pm
Location: The Netherlands

Post by obiku »

Thnx, this works great :D :D
User avatar
obiku
Registered User
Posts: 73
Joined: Sun Oct 10, 2004 6:54 pm
Location: The Netherlands

Post 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
Post Reply

Return to “[2.0.x] MOD Database Cleanup”