Code: Alles auswählen
##############################################################
## MOD Title: mod_new_topic_limit
## MOD Author: Barbarella < babs@slebog.net > (N/A) N/A
## MOD Description: Allows administrators to limit the number of new topics that users can start in a defined period
## MOD Version: 1.0.0
##
## Installation Level: Intermediate
## Installation Time: 5 Minutes
## Files To Edit: includes/functions_post.php, includes/functions_select.php, admin/admin_board.php,
## templates/subSilver/admin/board_config_body.tpl, language/lang_english/lang_main.php, language/lang_english/lang_admin.php
## Included Files: n/a
##############################################################
## 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/
##############################################################
## Author Notes:
##
##############################################################
## MOD History:
##
##Ê ÊYYYY-MM-DD - Version x.x.x
##Ê ÊÊ Ê- version notes go here
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################
#
#-----[ SQL ]------------------------------------------
#
INSERT INTO `phpbb_config` VALUES('topic_limit_default','0');
INSERT INTO `phpbb_config` VALUES('topic_limit_period','0');
ALTER TABLE `phpbb_users`
ADD `user_topic_count` SMALLINT UNSIGNED DEFAULT '0' NOT NULL,
ADD `user_topic_period` INT UNSIGNED DEFAULT '0' NOT NULL;
#
#-----[ OPEN ]------------------------------------------
#
includes/functions_post.php
#
#-----[ FIND ]------------------------------------------
#
// Check username
if (!empty($username))
{
$username = trim(strip_tags($username));
if (!$userdata['session_logged_in'] || ($userdata['session_logged_in'] && $username != $userdata['username']))
{
include($phpbb_root_path . 'includes/functions_validate.'.$phpEx);
$result = validate_username($username);
if ($result['error'])
{
$error_msg .= (!empty($error_msg)) ? '<br />' . $result['error_msg'] : $result['error_msg'];
}
}
else
{
$username = '';
}
}
#
#-----[ AFTER, ADD ]------------------------------------------
#
// Check topic limit
if ($mode == 'newtopic' && $board_config['topic_limit_default']
&& $board_config['topic_limit_period'] && !$userdata['user_level'])
{
$timenow = time();
if (($timenow - $userdata['user_topic_period']) < $board_config['topic_limit_period'])
{
// in same posting period
if ($userdata['user_topic_count'] >= $board_config['topic_limit_default'])
{
// over limit
$msg = sprintf($lang['Newtopic_limit_reached'],
$board_config['topic_limit_default'],
$lang['Newtopic_limit'][$board_config['topic_limit_period']],
create_date($board_config['default_dateformat'],
$userdata['user_topic_period']+$board_config['topic_limit_period'], $board_config['board_timezone']));
message_die(GENERAL_MESSAGE, $msg);
} else {
// increment topic count
$userdata['new_user_topic_count'] = $userdata['user_topic_count']+1;
}
}
else
{
// start new posting period
$userdata['new_user_topic_period'] = $timenow;
$userdata['new_user_topic_count'] = 1;
}
}
#
#-----[ FIND ]------------------------------------------
#
//
// Update post stats and details
//
function update_post_stats(&$mode, &$post_data, &$forum_id, &$topic_id, &$post_id, &$user_id)
{
global $db;
#
#-----[ REPLACE WITH ]------------------------------------------
#
//
// Update post stats and details
//
function update_post_stats(&$mode, &$post_data, &$forum_id, &$topic_id, &$post_id, &$user_id)
{
global $db,$userdata;
#
#-----[ FIND ]------------------------------------------
#
if ($mode != 'poll_delete')
{
$sql = "UPDATE " . USERS_TABLE . "
SET user_posts = user_posts $sign
WHERE user_id = $user_id";
if (!$db->sql_query($sql, END_TRANSACTION))
{
message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
}
}
#
#-----[ REPLACE WITH ]------------------------------------------
#
if ($mode != 'poll_delete')
{
$sql = "UPDATE " . USERS_TABLE . " SET user_posts = user_posts $sign";
if ($userdata['new_user_topic_count'] || $userdata['new_user_topic_period'])
{
$sql .= ', user_topic_count = '.$userdata['new_user_topic_count'];
}
if ($userdata['new_user_topic_period'])
{
$sql .= ', user_topic_period = '.$userdata['new_user_topic_period'];
}
$sql .= " WHERE user_id = $user_id";
if (!$db->sql_query($sql, END_TRANSACTION))
{
message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
}
}
#
#-----[ OPEN ]------------------------------------------
#
includes/functions_select.php
#
#-----[ FIND ]------------------------------------------
#
return $tz_select;
}
#
#-----[ AFTER, ADD ]------------------------------------------
#
//
// Pick a period to limit new topics in
//
function newtopic_select($default, $select_name = 'topic_limit_period')
{
global $lang;
$nt_select = '<select name="' . $select_name . '">';
if ( !isset($default) )
{
$default == 0;
}
while( list($offset, $zone) = @each($lang['Newtopic_limit']) )
{
$selected = ( $offset == $default ) ? ' selected="selected"' : '';
$nt_select .= '<option value="' . $offset . '"' . $selected . '>' . $zone . '</option>';
}
$nt_select .= '</select>';
return $nt_select;
}
#
#-----[ OPEN ]------------------------------------------
#
admin/admin_board.php
#
#-----[ FIND ]------------------------------------------
#
$timezone_select = tz_select($new['board_timezone'], 'board_timezone');
#
#-----[ AFTER, ADD ]------------------------------------------
#
$newtopic_select = newtopic_select($new['topic_limit_period'], 'topic_limit_period');
#
#-----[ FIND ]------------------------------------------
#
"L_RESET" => $lang['Reset'],
#
#-----[ AFTER, ADD ]------------------------------------------
#
"L_NEWTOPIC_LIMIT" => $lang['Newtopic_limit_label'],
"L_NEWTOPIC_IN" => $lang['Newtopic_in'],
#
#-----[ FIND ]------------------------------------------
#
"COPPA_FAX" => $new['coppa_fax'])
#
#-----[ REPLACE WITH ]------------------------------------------
#
"COPPA_FAX" => $new['coppa_fax'],
"NEWTOPIC_LIMIT_DEFAULT" => $new['topic_limit_default'],
"NEWTOPIC_SELECT" => $newtopic_select)
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/admin/board_config_body.tpl
#
#-----[ FIND ]------------------------------------------
#
<tr>
<td class="row1">{L_ALLOW_NAME_CHANGE}</td>
<td class="row2"><input type="radio" name="allow_namechange" value="1" {NAMECHANGE_YES} /> {L_YES} <input type="radio" name="allow_namechange" value="0" {NAMECHANGE_NO} /> {L_NO}</td>
</tr>
#
#-----[ AFTER, ADD ]------------------------------------------
#
<tr>
<td class="row1">{L_NEWTOPIC_LIMIT}</td>
<td class="row2"><input class="post" type="text" size="5" maxlength="4" name="topic_limit_default" value="{NEWTOPIC_LIMIT_DEFAULT}" /> {L_NEWTOPIC_IN} {NEWTOPIC_SELECT}</td>
</tr>
#
#-----[ OPEN ]------------------------------------------
#
language/lang_english/lang_main.php
#
#-----[ FIND ]------------------------------------------
#
$lang['A_critical_error'] = 'A Critical Error Occurred';
#
#-----[ AFTER, ADD ]------------------------------------------
#
//
// New topic limiting
//
$lang['Newtopic_limit_reached'] = 'You can\'t start more than %d new topics in any %s. You can\'t start a new topic until %s';
$lang['Newtopic_limit']['0'] = 'No limit';
$lang['Newtopic_limit']['300'] = '5 minutes';
$lang['Newtopic_limit']['900'] = '15 minutes';
$lang['Newtopic_limit']['1800'] = '30 minutes';
$lang['Newtopic_limit']['3600'] = '1 hour';
$lang['Newtopic_limit']['10800'] = '3 hours';
$lang['Newtopic_limit']['21600'] = '6 hours';
$lang['Newtopic_limit']['43200'] = '12 hours';
$lang['Newtopic_limit']['86400'] = '24 hours';
$lang['Newtopic_limit']['172800'] = '48 hours';
$lang['Newtopic_limit']['604800'] = '1 week';
$lang['Newtopic_limit']['1209600'] = '2 weeks';
$lang['Newtopic_limit']['2419200'] = '4 weeks';
#
#-----[ OPEN ]------------------------------------------
#
language/lang_english/lang_admin.php
#
#-----[ FIND ]------------------------------------------
#
$lang['Install_No_PCRE'] = 'phpBB2 Requires the Perl-Compatible Regular Expressions Module for PHP which your PHP configuration doesn\'t appear to support!';
#
#-----[ AFTER, ADD ]------------------------------------------
#
//
// New topic limiting
//
$lang['Newtopic_limit_label'] = 'Limit the number of new topics a user can start';
$lang['Newtopic_in'] = 'in any';
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM