$username_new = !empty($_POST['ch_nik_name']) ? clean_username($_POST['ch_nik_name']) : '';
$return = '<br /><br /><a href="'. BONUS_URL .'">'. $lang['BONUS_RETURN'] .'</a>';
----------------
// Смена ника за сидбонус
if ($_POST['bonus_id'] == 'ch_nik')
{
require(INC_DIR .'functions_validate.php');
$points = $bb_cfg['seed_bonus_change_nik_price'];
if ($userdata['username_old'] != '' && $userdata['username_change_time'] != 0)
{
$time = bb_date($userdata['username_change_time'], $lang['DATE_FORMAT']);
message_die(GENERAL_ERROR, sprintf($lang['BONUS_CHANGED_NIK'], $userdata['username_old'], $userdata['username'], $time) . $return);
}
if ($user_points < $points)
{
message_die(GENERAL_ERROR, $lang['BONUS_NOT_SUCCES'] . $return);
}
if (IS_AM)
{
message_die(GENERAL_ERROR, $lang['BONUS_NOT_AM'] . $return);
}
if (empty($username_new))
{
message_die(GENERAL_ERROR, $lang['CHOOSE_A_NAME'] . $return);
}
if ($err = validate_username($username_new))
{
message_die(GENERAL_ERROR, $err . $return);
}
else
{
DB()->query("UPDATE ". BB_USERS ." u
SET
username_old = '". DB()->escape_string($username) ."',
username_change_time = ".time().",
u.username = '". DB()->escape_string($username_new) ."',
u.user_points = u.user_points - $points
WHERE
u.user_id = $user_id
");
cache_rm_user_sessions($user_id);
$log_action->admin('adm_user_ch_nik', array('log_msg' => "<b>$username</b> » <b>$username_new</b><br>id = $user_id"));
bb_die(sprintf($lang['CHANGE_NIK_GOOD'], $username_new) . $return);
}
}
--------------
if ($bb_cfg['seed_bonus_change_nik'])
{
$points = $bb_cfg['seed_bonus_change_nik_price'];
$class = ($user_points >= $points) ? 'seed' : 'leech';
$template->assign_block_vars('ch_nik', array(
'ROW_CLASS' => 'row1',
'ID' => 'ch_nik',
'DESC' => $lang['CHANGE_NIK'],
'PRICE' => sprintf($lang['BONUS_UPLOAD_PRICE'], $class, sprintf('%.2f', $points)),
));
}