[討論]關於Points system2.1.1的修正

phpBB 2 MOD Support
無論是官方或非官方認證之外掛,安裝與使用問題討論。
(發表文章請按照公告格式發表,違者砍文)

版主: 版主管理群

主題已鎖定
蕭遙
星球公民
星球公民
文章: 120
註冊時間: 2004-09-29 05:21

[討論]關於Points system2.1.1的修正

文章 蕭遙 »

日前在安裝points system2.1.1的時候,有發現一個問題,即是管理員使用帖子右上角的叉來刪除帖子的時候,是扣做刪除操作的管理員的點數,而不是扣發帖人的點數……這樣的話版主的點數沒多久就要被扣沒了。經檢查,在下以爲是這段安裝代碼的錯誤:

代碼: 選擇全部

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

includes/functions_post.php

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

	global $userdata, $user_ip;

#
#-----[ IN-LINE FIND ]------------------------------------------ 
#

$user_ip

#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------ 
#

, $post_info

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

	$meta = '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=" . $post_id) . '#' . $post_id . '">';
	$message = $lang['Stored'] . '<br /><br />' . sprintf($lang['Click_view_message'], '<a href="' . append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=" . $post_id) . '#' . $post_id . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_forum'], '<a href="' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id") . '">', '</a>');

#
#-----[ BEFORE, ADD ]------------------------------------------
#

	if ($board_config['points_post'] && !$post_info['points_disabled'] && (($mode == 'newtopic') || ($mode == 'reply')) )
	{
		$points = abs(($mode == 'newtopic') ? $board_config['points_topic'] : $board_config['points_reply']);

		if (($userdata['user_id'] != ANONYMOUS) && ($userdata['admin_allow_points']))
		{
			add_points($userdata['user_id'], $points);
		}
	}

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

	if ($mode == 'delete' && $post_data['first_post'] && $post_data['last_post'])
	{
		$meta = '<meta http-equiv="refresh" content="3;url=' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . '=' . $forum_id) . '">';
		$message = $lang['Deleted'];
	}
	else
	{
		$meta = '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . '=' . $topic_id) . '">';
		$message = (($mode == 'poll_delete') ? $lang['Poll_delete'] : $lang['Deleted']) . '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id") . '">', '</a>');
	}

#
#-----[ AFTER, ADD ]------------------------------------------
#

	if ($board_config['points_post'] && !$post_info['points_disabled'] && ($mode == 'delete' || $mode == 'poll_delete') )
	{
		if (($userdata['user_id'] == $post_data['first_post']) && (($userdata['user_id'] != ANONYMOUS) && ($userdata['admin_allow_points'])))
		{
					}
		else if (($userdata['user_id'] != ANONYMOUS) && ($userdata['admin_allow_points']))
		{
			subtract_points($userdata['user_id'], $board_config['points_reply']);
		}
	}

可以看到裏面的判別句
if (($userdata['user_id'] == $post_data
和執行句\r
subtract_points($userdata['user_id'], $board_config['points_topic']);
都是以 $userdata 作爲對象的,但是如果是版主做刪除操作的話,這裡的$userdata代表的是版主id而非發帖人本人的id。因此造成上述的問題出現。於是在下對其稍微做了修正:

代碼: 選擇全部


打開 functions_post.php

找到\r

if ($board_config['points_post'] && !$post_info['points_disabled'] && ($mode == 'delete' || $mode == 'poll_delete') )
	{
		if (($userdata['user_id'] == $post_data['first_post']) && (($userdata['user_id'] != ANONYMOUS) && ($userdata['admin_allow_points'])))
		{
					}
		else if (($userdata['user_id'] != ANONYMOUS) && ($userdata['admin_allow_points']))
		{
			subtract_points($userdata['user_id'], $board_config['points_reply']);
		}
	}

替換為\r

if ($mode == 'delete' && $board_config['points_post'] && !$post_info['points_disabled'])
	{
		$posterid = $post_data['poster_id'];
		
		if (($posterid == $post_data['first_post']))
		{
			subtract_points($posterid, $board_config['points_topic']);
		}
		else
		{
			subtract_points($posterid, $board_config['points_reply']);
		}
	}
這樣扣除的就是發帖人的積分,而非管理人員的積分了~目前使用未發現問題,請指教~
主題已鎖定

回到「外掛問題討論」