####################################################################################################
## 
## MOD Title: Democracy MOD - Update from 0.1.0 to 0.1.1
## MOD Author: Carbofos < carbofos@mail.ru > (N/A) N/A
## MOD Description: Adds some social mechanisms to the phpBB
## MOD Version: 0.1.1
## 
## Installation Level: Easy
## Installation Time: <5 Minutes 
## Files To Edit: 8:
##	viewtopic.php
##	admin/admin_democracy.php
##	includes/page_header.php
##	includes/usercp_reputation.php
##	language/lang_english/lang_admin.php
##	language/lang_english/lang_main.php
##	templates/subSilver/profile_view_reputation.tpl
##	templates/subSilver/admin/reputation_body.tpl
## Included Files: 1:
##	templates/subSilver/images/icon_ban.gif
##
####################################################################################################
## 
## For Security Purposes, Please Check: http://www.phpbb.com/mods/ for the 
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code 
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered 
## in our MOD-Database, located at: http://www.phpbb.com/mods/ 
## 
####################################################################################################
## 
## Few minor bugs fixed, added one file (icon_ban.gif) that was missing in the previous version.
## Added new feature: now users can be banned for some time instead of forever (off by default,
## check the ACP to setup)
##  
####################################################################################################
## 
## IMPORTANT:
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
## 
####################################################################################################
#
#-----------------------[ COPY ]-------------------------
#
copy icon_ban.gif to templates/subSilver/images/icon_ban.gif
#
#------------------------[ SQL ]-------------------------
#
INSERT INTO `phpbb_config` VALUES ('reputation_ban_expire', '0');
INSERT INTO `phpbb_config` VALUES ('reputation_ban_expire_lower', '0');
INSERT INTO `phpbb_config` VALUES ('reputation_ban_expire_upper', '-1');
INSERT INTO `phpbb_config` VALUES ('reputation_autoban_exipre', '-1');

#
#------------------------[ OPEN ]------------------------
#
viewtopic.php
#
#------------------------[ FIND ]------------------------
# Remove the statement $db->sql_freeresult. I have really no idea how did it get there :)
#
			$db->sql_freeresult($result);			
			if ( $postrow[$i]['warnings'] > 0 )
			{
#
#-------------------[ REPLACE WITH ]---------------------
#
			if ( $postrow[$i]['warnings'] > 0 )
			{
#
#------------------------[ OPEN ]------------------------
#
admin/admin_democracy.php
#
#------------------------[ FIND ]------------------------
#
		'L_EXPIRE_MAX' => $lang['reputation_expire_max'],
#
#---------------------[ AFTER, ADD ]---------------------
#
		'L_BAN_EXPIRE_ENABLED' => $lang['reputation_ban_expire_enabled'],
		'L_BAN_EXPIRE_DEFAULT' => $lang['reputation_ban_expire_default'],
		'L_BAN_EXPIRE_MIN' => $lang['reputation_ban_expire_min'],
		'L_BAN_EXPIRE_MAX' => $lang['reputation_ban_expire_max'],
#
#------------------------[ FIND ]------------------------
#
		'S_EXPIRE_ENABLED_' . $board_config['reputation_expire_mod_defined'] . '_CHECKED' => 'checked="checked" ',
#
#---------------------[ AFTER, ADD ]---------------------
#
		'S_BAN_EXPIRE_ENABLED_' . $board_config['reputation_ban_expire'] . '_CHECKED' => 'checked="checked" ',
#
#------------------------[ FIND ]------------------------
#
		'S_EXPIRE_MAX' => $board_config['reputation_expire_upper'],
#
#---------------------[ AFTER, ADD ]---------------------
#
		'S_BAN_EXPIRE_DEFAULT' => $board_config['reputation_autoban_exipre'],
		'S_BAN_EXPIRE_MIN' => $board_config['reputation_ban_expire_lower'],
		'S_BAN_EXPIRE_MAX' => $board_config['reputation_ban_expire_upper'],
#
#------------------------[ FIND ]------------------------
#

	if ( isset($HTTP_POST_VARS['delete_expired']) && ( $HTTP_POST_VARS['delete_expired'] == 0 || $HTTP_POST_VARS['delete_expired'] == 1 ) )
#
#--------------------[ BEFORE, ADD ]---------------------
#
	if ( isset($HTTP_POST_VARS['ban_expire_enable']) && ( $HTTP_POST_VARS['ban_expire_enable'] == 0 || $HTTP_POST_VARS['ban_expire_enable'] == 1 ) )
	{
		$new_name[] = 'reputation_ban_expire';
		$new_value[] = intval($HTTP_POST_VARS['ban_expire_enable']);
	}
	if ( isset($HTTP_POST_VARS['ban_expire_default']) && $HTTP_POST_VARS['ban_expire_default'] >= -1 )
	{
		$new_name[] = 'reputation_autoban_exipre';
		$new_value[] = intval($HTTP_POST_VARS['ban_expire_default']);
	}
	if ( isset($HTTP_POST_VARS['ban_expire_min']) && $HTTP_POST_VARS['ban_expire_min'] >= 0 )
	{
		$new_name[] = 'reputation_ban_expire_lower';
		$new_value[] = intval($HTTP_POST_VARS['ban_expire_min']);
	}
	if ( isset($HTTP_POST_VARS['ban_expire_max']) && $HTTP_POST_VARS['ban_expire_max'] >= -1 )
	{
		$new_name[] = 'reputation_ban_expire_upper';
		$new_value[] = intval($HTTP_POST_VARS['ban_expire_max']);
	}
#
#------------------------[ OPEN ]------------------------
#
includes/page_header.php
#
#------------------------[ FIND ]------------------------
#
// Check for expired warnings
#
#-------------------[ REPLACE WITH ]---------------------
#
// Check for expired warnings and bans
#
#------------------------[ FIND ]------------------------
#
	$sql = 'SELECT id, user_id FROM ' . REPUTATION_TABLE . '
	        WHERE modification = ' . REPUTATION_WARNING . "
#
#-------------------[ REPLACE WITH ]---------------------
#
	$sql = 'SELECT id, user_id, modification FROM ' . REPUTATION_TABLE . '
	        WHERE modification = ' . REPUTATION_WARNING . ' OR modification = ' . REPUTATION_BAN . "
#
#------------------------[ FIND ]------------------------
#
		}
		else
		{
#
#--------------------[ BEFORE, ADD ]---------------------
#
			if ( $row['modification'] == REPUTATION_BAN )
			{
				$sql = 'DELETE FROM ' . BANLIST_TABLE . "
					WHERE ban_userid = '" . $row['user_id'] . "'";
				if ( !($result = $db->sql_query($sql)) )
				{
					message_die(GENERAL_ERROR, "Couldn't obtain banlist information", "", __LINE__, __FILE__, $sql);
				}
			}
#
#--------------------[ AFTER, ADD ]----------------------
#
			if ( $row['modification'] == REPUTATION_WARNING )
			{
				$set = REPUTATION_WARNING_EXPIRED;
			}
			else
			{
				$set = REPUTATION_BAN_EXPIRED;
			}
#
#------------------------[ FIND ]------------------------
#
			$sql = 'UPDATE ' . REPUTATION_TABLE . '
				SET modification = ' . REPUTATION_WARNING_EXPIRED . '
#
#-------------------[ REPLACE WITH ]---------------------
#
			$sql = 'UPDATE ' . REPUTATION_TABLE . '
				SET modification = ' . $set . '
#
#------------------------[ OPEN ]------------------------
#
includes/usercp_reputation.php
#
#------------------------[ FIND ]------------------------
#
				case REPUTATION_WARNING:
					$review = '<img src="' . $images['user_warning'] . '" alt="" border="0" />';
#
#-------------------[ REPLACE WITH ]---------------------
#
				case REPUTATION_WARNING:
					$review = '<img src="' . $images['user_warning'] . '" alt="' . $lang['Warning'] . '" border="0" />';
#
#------------------------[ FIND ]------------------------
#
				case REPUTATION_BAN:
					$review = '<img src="' . $images['user_ban'] . '" alt="" border="0" />';
					$expire = $lang['reputation_never'];
#
#-------------------[ REPLACE WITH ]---------------------
#
				case REPUTATION_BAN:
					$review = '<img src="' . $images['user_ban'] . '" alt="' . $lang['reputation_ban'] . '" border="0" />';
					$expire = ( $warning[$i]['expire'] == -1 ) ? $lang['reputation_never'] : create_date('d.m.Y', $info[$i]['expire'], $board_config['board_timezone']);
#
#------------------------[ FIND ]------------------------
#
		$current_time = time();
		if ( $rep_mode == REPUTATION_WARNING )
#
#-------------------[ REPLACE WITH ]---------------------
#
		$current_time = time();
		if ( $rep_mode == REPUTATION_WARNING || ( $rep_mode == REPUTATION_BAN && $board_config['reputation_ban_expire'] == 1 ) )
#
#------------------------[ FIND ]------------------------
#
			'REASON' => $user_comments,
			'EMAIL_SIG' => (!empty($board_config['board_email_sig'])) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '',
#
#--------------------[ BEFORE, ADD ]---------------------
#
			'TIME' => $expire > 0 ? $lang['reputation_for'] . ' ' . ( ($expire - $current_time) / 86400 ) . ' ' . $lang['reputation_days'] : '',
#
#------------------------[ FIND ]------------------------
#
			$template->assign_block_vars('switch_ban', array(
				'L_NEVER_EXPIRE' => $lang['reputation_expire_never'] . $expire_explain )
			);
		}
#
#-------------------[ REPLACE WITH ]---------------------
#
			// Compile expire date hint
			if ( $board_config['reputation_ban_expire'] )
			{
				$expire_hint = $lang['reputation_expire_hint'];
				if ( $board_config['reputation_ban_expire_lower'] >= 0 )
				{
					$expire_hint .= ' ' . $lang['reputation_from'] . ' ' . $board_config['reputation_ban_expire_lower'];
				}
				if ( $board_config['reputation_ban_expire_upper'] > $board_config['reputation_ban_expire_lower'] )
				{
					$expire_hint .= ' ' . $lang['reputation_to'] . ' ' . $board_config['reputation_ban_expire_upper'];
				}
				$expire_hint .= ' (' . $lang['reputation_days'] . ')';
		
				if ( $board_config['reputation_ban_expire_upper'] == -1 )
				{
					$expire_hint .= '<br />' . $lang['reputation_expire_hint_inf'];
				}
				$template->assign_block_vars('switch_warning', array(
					'L_EXPIRE_HINT' => $expire_hint,
					'L_DAYS' => $lang['reputation_days'],
					'L_EXPIRE' => $lang['reputation_expire_after'],
					'S_EXPIRE_VALUE' => $board_config['reputation_autoban_exipre'],
					'S_EXPIRE_DISABLED' => $board_config['reputation_ban_expire'] == 0 ? 'disabled="disabled" ' : '')
				);
			}
			else
			{
				$template->assign_block_vars('switch_ban', array(
					'L_NEVER_EXPIRE' => $lang['reputation_expire_never'] . $expire_explain )
				);
			}
		}
#
#------------------------[ OPEN ]------------------------
#
language/lang_english/lang_admin.php
#
#------------------------[ FIND ]------------------------
#
$lang['reputation_expire_max']
#
#---------------------[ AFTER, ADD ]---------------------
#
$lang['reputation_ban_expire_enabled'] = 'Ban can expire over time (only when banned using warnings system)';
$lang['reputation_ban_expire_default'] = 'Default expire time for bans';
$lang['reputation_ban_expire_min'] = 'Minimal expire time for bans';
$lang['reputation_ban_expire_max'] = 'Maximal expire time for bans';
#
#------------------------[ FIND ]------------------------
#
$lang['reputation_expired_warnings']
#
#-------------------[ REPLACE WITH ]---------------------
#
$lang['reputation_expired_warnings'] = 'Expired warnings and bans';
#
#------------------------[ OPEN ]------------------------
#
language/lang_english/lang_main.php
#
#------------------------[ FIND ]------------------------
#
$lang['reputation_from']
#
#--------------------[ BEFORE, ADD ]---------------------
#
$lang['reputation_for'] = 'for';
#
#------------------------[ OPEN ]------------------------
#
language/lang_english/email/reputation_ban.tpl
#
#------------------------[ FIND ]------------------------
#
"{SITENAME}"
#
#-------------------[ IN-LINE FIND ]---------------------
#
"{SITENAME}"
#
#----------------[ IN-LINE AFTER, ADD ]------------------
#
{TIME}
#
#------------------------[ OPEN ]------------------------
#
templates/subSilver/profile_view_reputation.tpl
#
#------------------------[ FIND ]------------------------
# The attribute width="100%" was in the wrong place, that could cause some problems
#
		<td class="{postrow.ROW_CLASS}" height="28" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
#
#-------------------[ REPLACE WITH ]---------------------
#
		<td class="{postrow.ROW_CLASS}" width="100%" height="28" valign="top"><table border="0" cellspacing="0" cellpadding="0">
#
#------------------------[ OPEN ]------------------------
#
templates/subSilver/admin/reputation_body.tpl
#
#------------------------[ FIND ]------------------------
#
	<tr> 
	  <td class="row1"><span class="gen">{L_EXPIRE_MAX}</span></td>
	  <td class="row2"><input type="text" name="expire_max" value="{S_EXPIRE_MAX}" maxlength="3" size="3" /> {L_DAYS} ({L_INF_HINT})</td>
	</tr>
#
#---------------------[ AFTER, ADD ]---------------------
#
	<tr> 
	  <td class="row1"><span class="gen">{L_BAN_EXPIRE_ENABLED}</span></td>
	  <td class="row2"><input type="radio" name="ban_expire_enable" value="1" {S_BAN_EXPIRE_ENABLED_1_CHECKED}/>{L_YES} <input type="radio" name="ban_expire_enable" value="0" {S_BAN_EXPIRE_ENABLED_0_CHECKED}/><u>{L_NO}</u></td>
	</tr>
	<tr>
	  <td class="row1"><span class="gen">{L_BAN_EXPIRE_DEFAULT}</span></td>
	  <td class="row2"><input type="text" name="ban_expire_default" value="{S_BAN_EXPIRE_DEFAULT}" maxlength="3" size="3" /> {L_DAYS} ({L_INF_HINT})</td>
	</tr>
	<tr> 
	  <td class="row1"><span class="gen">{L_BAN_EXPIRE_MIN}</span></td>
	  <td class="row2"><input type="text" name="ban_expire_min" value="{S_BAN_EXPIRE_MIN}" maxlength="3" size="3" /> {L_DAYS}</td>
	</tr>
	<tr> 
	  <td class="row1"><span class="gen">{L_BAN_EXPIRE_MAX}</span></td>
	  <td class="row2"><input type="text" name="ban_expire_max" value="{S_BAN_EXPIRE_MAX}" maxlength="3" size="3" /> {L_DAYS} ({L_INF_HINT})</td>
	</tr>
#
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ 
#
# EoM 