Cod: Selectaţi tot
<php>= MAGIC_BAN_NUMBER)
{
$mode = 'ban';
}
else
{
$mode = 'warn';
}
}
elseif($HTTP_GET_VARS['mode'] == 'unwarn')
{
$profiledata = get_userdata(intval($HTTP_GET_VARS[POST_USERS_URL]));
if (!$profiledata)
{
message_die(GENERAL_MESSAGE, $lang['No_user_id_specified']);
}
if(!$profiledata['user_warnings'])
{
message_die(GENERAL_MESSAGE, $lang['User_has_no_warnings'] . '<br><br>' . sprintf($lang['Click_return_index'], '<a href="' . append_sid(">', '</a>'));
}
$mode = 'unwarn';
}
elseif($HTTP_GET_VARS['mode'] == 'unban')
{
$profiledata = get_userdata(intval($HTTP_GET_VARS[POST_USERS_URL]));
if (!$profiledata)
{
message_die(GENERAL_MESSAGE, $lang['No_user_id_specified']);
}
$mode = 'unban';
}
else
{
// Go away, your not doing anything anyway.
redirect(append_sid("index.$phpEx"));
}
//
// Ok, Modes are set now - Lets play with them.
//
if($mode == 'ban')
{
$ban_config_rank = intval($board_config['warnmod_banrank']);
// Ok, Lets make them happy and change the rank... Lazy admins!
$sql = "UPDATE ". USERS_TABLE ." SET user_rank = '" . $ban_config_rank . "' WHERE user_id = '" . $profiledata['user_id'] . "'";
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't update user rank", "Database Error", __LINE__, __FILE__, $sql);
}
// Change the warnings counter to show they are banned.
$sql = "UPDATE " . USERS_TABLE . " SET user_warnings = 4 WHERE user_id = " . $profiledata['user_id'];
if (!$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't update warning count", "", __LINE__, __FILE__, $sql);
}
// Lets check the banlist...
$sql = "SELECT ban_userid FROM " . BANLIST_TABLE . " WHERE ban_userid = " . $profiledata['user_id'];
if(! $result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't obtain banlist information", "", __LINE__, __FILE__, $sql);
}
if ($db->sql_fetchrowset($result))
{
message_die(GENERAL_MESSAGE, $lang['User_already_banned_warnmod'] . '<br><br>' . sprintf($lang['Click_return_index'], '<a href="' . append_sid(">', '</a>'));
}
// Lets ban this little bastard.
$sql = "INSERT INTO " . BANLIST_TABLE . " (ban_userid) VALUES (" . $profiledata['user_id'] . ")";
if (!$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't insert ban_userid info into database", "", __LINE__, __FILE__, $sql);
}
// Tell them the good news!
$message = $lang['User_successfully_banned_warnmod'] . '<br><br>' . sprintf($lang['Click_return_index'], '<a href="' . append_sid(">', '</a>');
message_die(GENERAL_MESSAGE, $message, $lang['warnmod_title']);
}
elseif($mode == 'unban')
{
// This has to be a rare thing...
$unban_config_rank = intval($board_config['warnmod_unbanrank']);
// Ok, Lets make them happy and change the rank... Lazy admins!
$sql = "UPDATE ". USERS_TABLE ." SET user_rank = '" . $unban_config_rank . "' WHERE user_id = '" . $profiledata['user_id'] . "'";
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't update user rank", "Database Error", __LINE__, __FILE__, $sql);
}
// Change the warnings counter to show they are unbanned.
$sql = "UPDATE " . USERS_TABLE . " SET user_warnings = 0 WHERE user_id = " . $profiledata['user_id'];
if (!$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't update warning count", "", __LINE__, __FILE__, $sql);
}
// Lets check the banlist...
$sql = "SELECT ban_userid FROM " . BANLIST_TABLE . " WHERE ban_userid = " . $profiledata['user_id'];
if(! $result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't obtain banlist information", "", __LINE__, __FILE__, $sql);
}
if (!$db->sql_fetchrowset($result))
{
message_die(GENERAL_MESSAGE, $lang['User_not_banned_warnmod'] . '<br><br>' . sprintf($lang['Click_return_index'], '<a href="' . append_sid(">', '</a>'));
}
// Lets unban this little bundle of joy.
$sql = "DELETE FROM " . BANLIST_TABLE . " WHERE ban_userid = " . $profiledata['user_id'] . " LIMIT 1";
if (!$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't insert ban_userid info into database", "", __LINE__, __FILE__, $sql);
}
// Tell them the good news!
$message = $lang['User_successfully_unbanned_warnmod'] . '<br><br>' . sprintf($lang['Click_return_index'], '<a href="' . append_sid(">', '</a>');
message_die(GENERAL_MESSAGE, $message, $lang['warnmod_title']);
}
elseif($mode == 'unwarn')
{
// Hmm, Looks like somebody has been good today
$newWarnlevel = intval($profiledata['user_warnings']);
$newWarnlevel--;
$sql = "UPDATE " . USERS_TABLE . " SET user_warnings = $newWarnlevel WHERE user_id = " . $profiledata['user_id'];
if (!$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't update warning count", "", __LINE__, __FILE__, $sql);
}
$message = $lang['User_successfully_unwarned_warnmod'] . '<br><br>' . sprintf($lang['Click_return_index'], '<a href="' . append_sid(">', '</a>');
message_die(GENERAL_MESSAGE, $message, $lang['warnmod_title']);
}
elseif($mode == 'warn')
{
// Whats the point of warning a banned user...
$sql = "SELECT ban_userid FROM " . BANLIST_TABLE . " WHERE ban_userid = " . $profiledata['user_id'];
if(! $result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't obtain banlist information", "", __LINE__, __FILE__, $sql);
}
if ($db->sql_fetchrowset($result))
{
message_die(GENERAL_MESSAGE, $lang['User_already_banned_warnmod'] . '<br><br>' . sprintf($lang['Click_return_index'], '<a href="' . append_sid(">', '</a>'));
}
// Oh noes! Somebody did something wrong!
$newWarnlevel = intval($profiledata['user_warnings']);
$newWarnlevel++;
$sql = "UPDATE " . USERS_TABLE . " SET user_warnings = $newWarnlevel WHERE user_id = " . $profiledata['user_id'];
if (!$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't update warning count", "", __LINE__, __FILE__, $sql);
}
$message = $lang['User_successfully_warned_warnmod'] . '<br><br>' . sprintf($lang['Click_return_index'], '<a href="' . append_sid(">', '</a>');
message_die(GENERAL_MESSAGE, $message, $lang['warnmod_title']);
}
else
{
// Hmm, Wtf did i do wrong to make it do this?
redirect(append_sid("index.$phpEx"));
}
//
// Output page and footer
//
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
?>