############################################################## 
## MOD Title: Temp Ban
## MOD Author: szquirrel < squirrel@digitalsquirrel.com > (Andy McConnell) http://www.digitalsquirrel.com/ 
## MOD Author: eviL3 < evil@phpbbmodders.com > (Igor Wiedler) http://phpbbmodders.com/
## MOD Description: Este MOD aade la opcion de banear temporariamente (segundos, minutos, horasy semanas) a usuarios, 
##                  direccion ip y por email.
## MOD Version: 1.1.1
## Translation: Spanish (Espaol)  
## Rev date:    14/11/2006
##  
## Translator:  Zuker < webmaster@eddb.com.ar > Matias http://www.eddb.com.ar
## 
## Installation Level: Intermediate
## Installation Time: 20 Minutes
##
## Files To Edit: 8
##		language/lang_spanish/lang_main.php
##		language/lang_spanish/lang_admin.php
##		includes/functions.php
##		includes/functions_post.php
##		includes/functions_validate.php
##		includes/sessions.php
##		admin/admin_user_ban.php
##		templates/subSilver/admin/user_ban_body.tpl
##
## Included Files: N/A
## License: http://opensource.org/licenses/gpl-license.php GNU General Public License v2
##############################################################
## Author Notes: 
##
##	When banning a user, ip, or email from the admin pages, you should
##	see an extra field for automatically removing the ban after a
##	number of minutes, hours, days or weeks. Bans that have expired
##	will be automatically removed from the ban table with no further
##	admin action required.
##
##	Setting the ban-remove field to zero results in a permanent ban.
##	The default database value for this field is zero. Therefore other
##	mods that touch the ban table but don't know about this mod will
##	still cause permanent bans as expected. Also all pre-existing bans
##	will still be permanent after this mod is installed.
##
##	You are free to borrow some or all of the code found in this
##	package as long as your product includes an attribution to me,
##	squirrel (Andy McConnell).
##
##
##  ---------- { eviL3 } ----------
##
## Credit for this MOD goes to szquirrel. He made it. I will continue
## development and provide support for this MOD. And i will update it as well.
##
############################################################## 
## MOD History: 
##
##	2006-08-17 - Version 1.1.1
##		- Fixed a little EasyMod problem
##
##	2006-08-17 - Version 1.1.0
##		- MOD overtaken by eviL3
##    - Changed the format a little
##
##	2006-03-16 - Version 1.0.1
##		- fixed a bug that prevented EasyMod installation
##		- This is expected to be the last version of TempBan
##
##	2006-03-09 - Version 1.0.0
##		- fixed bugs in the MOD template (doh!)
##		- submitted to the MOD database
##
##	2006-03-08 - Version 0.9.1
##		- fixed bugs that broke IP and email bans
##		- added ban expiration dates to the unban list
##		- changed ban expiration wording to make it clearer
##		- various tweaks to PHP and MOD syntax
## 
##	2006-03-07 - Version 0.9.0
##		- initial version, w00t!
## 
############################################################## 
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
############################################################## 
#
#-----[ SQL ]------------------------------------------ 
#
ALTER TABLE `phpbb_banlist` ADD ban_until INT(11) DEFAULT '0' NOT NULL;

#
#-----[ OPEN ]------------------------------------------ 
#
language/lang_spanish/lang_main.php

#
#-----[ FIND ]------------------------------------------ 
#
$lang['Message'] = 'Mensaje';

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

// 'Horas' y 'Dias' se definen aparte
$lang['Seconds'] = 'Segundos';
$lang['Minutes'] = 'Minutos';
$lang['Weeks'] = 'Semanas';

#
#-----[ OPEN ]------------------------------------------ 
#
language/lang_spanish/lang_admin.php

#
#-----[ FIND ]------------------------------------------ 
#
$lang['Ban_explain_warn'] = 'Tenga en cuenta que colocando un RANGO de direcciones IP usted excluye de acceso al foro a todas las direcciones que se encuentran dentro del Rango de la lista de excludos.  Si realmente debe utilizar un rango intente utilizar uno pequeo para as no excluir a otros usuarios.';

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

$lang['Expires_after'] = 'Banear usuario por';
$lang['Expires_explain'] = '0 significa baneo permanente';
$lang['Expires'] = 'Expira el';
$lang['Expires_format'] = 'd M Y g:i a';

#
#-----[ OPEN ]------------------------------------------ 
#
includes/functions.php

#
#-----[ FIND ]------------------------------------------ 
#
?>

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

function prune_banlist()
{
	global $db;

	$sql = "DELETE FROM " . BANLIST_TABLE .
		" WHERE ban_until <> 0 AND ban_until < " . time();
	if (!($result = $db->sql_query($sql)))
	{
		message_die(GENERAL_ERROR, 'Could not access banlist', '', __LINE__, __FILE__, $sql);
	}
}

#
#-----[ OPEN ]------------------------------------------ 
#
includes/functions_post.php

#
#-----[ FIND ]------------------------------------------ 
#
			$sql = "SELECT ban_userid 

#
#-----[ BEFORE, ADD ]------------------------------------------ 
#
			prune_banlist();

#
#-----[ OPEN ]------------------------------------------ 
#
includes/functions_validate.php

#
#-----[ FIND ]------------------------------------------ 
#
			$sql = "SELECT ban_email

#
#-----[ BEFORE, ADD ]------------------------------------------ 
#
			prune_banlist();

#
#-----[ OPEN ]------------------------------------------ 
#
includes/sessions.php

#
#-----[ FIND ]------------------------------------------ 
#
	$sql = "SELECT ban_ip, ban_userid, ban_email 

#
#-----[ BEFORE, ADD ]------------------------------------------ 
#
	prune_banlist();

#
#-----[ OPEN ]------------------------------------------ 
#
admin/admin_user_ban.php

#
#-----[ FIND ]------------------------------------------ 
#
		$user_list[] = $this_userdata['user_id'];

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

		$user_ban_until = 0;
		if ( isset($HTTP_POST_VARS['user_ban_length']) && isset($HTTP_POST_VARS['user_ban_unit']) )
		{
			$user_ban_until = (int) $HTTP_POST_VARS['user_ban_length'] * $HTTP_POST_VARS['user_ban_unit'];
			$user_ban_until = ($user_ban_until > 0) ? (time() + $user_ban_until) : 0;
		}

#
#-----[ FIND ]------------------------------------------ 
#
				$ip_list[] = encode_ip(str_replace('*', '255', trim($ip_list_temp[$i])));
			}
		}

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

		$ip_ban_until = 0;
		if ( isset($HTTP_POST_VARS['ip_ban_length']) && isset($HTTP_POST_VARS['ip_ban_unit']) )
		{
			$ip_ban_until = (int) $HTTP_POST_VARS['ip_ban_length'] * $HTTP_POST_VARS['ip_ban_unit'];
			$ip_ban_until = ($ip_ban_until > 0) ? (time() + $ip_ban_until) : 0;
		}

#
#-----[ FIND ]------------------------------------------ 
#
				$email_list[] = trim($email_list_temp[$i]);
			}
		}

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

		$email_ban_until = 0;
		if ( isset($HTTP_POST_VARS['email_ban_length']) && isset($HTTP_POST_VARS['email_ban_unit']) )
		{
			$email_ban_until = (int) $HTTP_POST_VARS['email_ban_length'] * $HTTP_POST_VARS['email_ban_unit'];
			$email_ban_until = ($email_ban_until > 0) ? (time() + $email_ban_until) : 0;
		}

#
#-----[ FIND ]------------------------------------------ 
#
			$sql = "INSERT INTO " . BANLIST_TABLE . " (ban_userid

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

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

#
#-----[ FIND ]------------------------------------------ 
#
				VALUES (" . $user_list[$i]

#
#-----[ IN-LINE FIND ]------------------------------------------
#
$user_list[$i]

#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#
 . ", " . $user_ban_until

#
#-----[ FIND ]------------------------------------------ 
#
			$sql = "INSERT INTO " . BANLIST_TABLE . " (ban_ip

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

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

#
#-----[ FIND ]------------------------------------------ 
#
				VALUES ('" . $ip_list[$i]

#
#-----[ IN-LINE FIND ]------------------------------------------
#
$ip_list[$i] . "'

#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#
, " . $ip_ban_until . "

#
#-----[ FIND ]------------------------------------------ 
#
			$sql = "INSERT INTO " . BANLIST_TABLE . " (ban_email

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

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

#
#-----[ FIND ]------------------------------------------ 
#
				VALUES ('" . str_replace("\'", "''", $email_list[$i]

#
#-----[ IN-LINE FIND ]------------------------------------------
#
$email_list[$i]) . "'

#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#
, " . $email_ban_until . "

#
#-----[ FIND ]------------------------------------------ 
#
	$sql = "SELECT b.ban_id, u.user_id, u.username

#
#-----[ BEFORE, ADD ]------------------------------------------
#
	prune_banlist();

#
#-----[ IN-LINE FIND ]------------------------------------------
#
b.ban_id

#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#
, b.ban_until

#
#-----[ FIND ]------------------------------------------ 
#
		$select_userlist .= '<option value="' . $user_list[$i]['ban_id'] . '">' . $user_list[$i]['username'] . '</option>';

#
#-----[ BEFORE, ADD ]------------------------------------------
#
		$ban_until = ( $user_list[$i]['ban_until'] > 0 ) ? ' [' . $lang['Expires'] . ' ' . create_date($lang['Expires_format'], $user_list[$i]['ban_until'], $board_config['board_timezone']) . ']' : '';

#
#-----[ IN-LINE FIND ]------------------------------------------
#
['username']

#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#
 . $ban_until

#
#-----[ FIND ]------------------------------------------ 
#
	$sql = "SELECT ban_id, ban_ip, ban_email

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

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

#
#-----[ FIND ]------------------------------------------ 
#
	for($i = 0; $i < count($banlist); $i++)
	{
		$ban_id = $banlist[$i]['ban_id'];

#
#-----[ AFTER, ADD ]------------------------------------------
#
		$ban_until = ( $banlist[$i]['ban_until'] > 0 ) ? ' [' . $lang['Expires'] . ' ' . create_date($lang['Expires_format'], $banlist[$i]['ban_until'], $board_config['board_timezone']) . ']' : '';

#
#-----[ FIND ]------------------------------------------ 
#
			$select_iplist .= '<option value="' . $ban_id . '">' . $ban_ip . '</option>';

#
#-----[ IN-LINE FIND ]------------------------------------------
#
$ban_ip

#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#
 . $ban_until

#
#-----[ FIND ]------------------------------------------ 
#
			$select_emaillist .= '<option value="' . $ban_id . '">' . $ban_email . '</option>';

#
#-----[ IN-LINE FIND ]------------------------------------------
#
$ban_email

#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#
 . $ban_until

#
#-----[ FIND ]------------------------------------------ 
#
		'L_FIND_USERNAME' => $lang['Find_username'],

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

		'L_MINUTES' => $lang['Minutes'],
		'L_HOURS' => $lang['Hours'],
		'L_DAYS' => $lang['Days'],
		'L_WEEKS' => $lang['Weeks'],
		'L_EXPIRES_AFTER' => $lang['Expires_after'],
		'L_EXPIRES_EXPLAIN' => $lang['Expires_explain'],

#
#-----[ OPEN ]------------------------------------------ 
#
templates/subSilver/admin/user_ban_body.tpl

#
#-----[ FIND ]------------------------------------------ 
#
<p>{L_BAN_EXPLAIN}</p>

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

<p><b>{S_CURRENT_TIME}</b></p>

#
#-----[ FIND ]------------------------------------------ 
#
	  <td class="row2"><input class="post" type="text" class="post" name="username" maxlength="50" size="20" />

#
#-----[ IN-LINE FIND ]------------------------------------------
#
</td>

#
#-----[ IN-LINE BEFORE, ADD ]------------------------------------------
#
 <br />{L_EXPIRES_AFTER} <input class="post" type="text" name="user_ban_length" value="0" size="4" /> <select name="user_ban_unit"><option selected="selected" value="60">{L_MINUTES}</option><option value="3600">{L_HOURS}</option><option value="86400">{L_DAYS}</option><option value="604800">{L_WEEKS}</option></select> <br /><span class="gensmall">{L_EXPIRES_EXPLAIN}</span>

#
#-----[ FIND ]------------------------------------------ 
#
	  <td class="row2"><input class="post" type="text" name="ban_ip" size="35" /></td>

#
#-----[ IN-LINE FIND ]------------------------------------------
#
</td>

#
#-----[ IN-LINE BEFORE, ADD ]------------------------------------------
#
 <br />{L_EXPIRES_AFTER} <input class="post" type="text" name="ip_ban_length" value="0" size="4" /> <select name="ip_ban_unit"><option selected="selected" value="60">{L_MINUTES}</option><option value="3600">{L_HOURS}</option><option value="86400">{L_DAYS}</option><option value="604800">{L_WEEKS}</option></select> <br /><span class="gensmall">{L_EXPIRES_EXPLAIN}</span>

#
#-----[ FIND ]------------------------------------------ 
#
	  <td class="row2"><input class="post" type="text" name="ban_email" size="35" /></td>

#
#-----[ IN-LINE FIND ]------------------------------------------
#
</td>

#
#-----[ IN-LINE BEFORE, ADD ]------------------------------------------
#
 <br />{L_EXPIRES_AFTER} <input class="post" type="text" name="email_ban_length" value="0" size="4" /> <select name="email_ban_unit"><option selected="selected" value="60">{L_MINUTES}</option><option value="3600">{L_HOURS}</option><option value="86400">{L_DAYS}</option><option value="604800">{L_WEEKS}</option></select> <br /><span class="gensmall">{L_EXPIRES_EXPLAIN}</span>

#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ 
#
# EoM
