Смена ника за очки сидирования
в usercp_bonus.php вставляем
PHP:case 'namechange': $sql = "SELECT username FROM ". BB_USERS ." WHERE user_id = $user_id LIMIT 1"; if ($row = DB()->fetch_row($sql)) { $curr_username = $row['username'].":".time(); } if (($cost = $bb_cfg['seed_points_ex']['namechange']["$bonus_count"]) && $seed_points >= $cost) { require_once(INC_DIR .'functions_validate.php'); $username = $_POST['username']; if ($username == '') { message_die(GENERAL_MESSAGE, $lang['FIELDS_EMPTY']); } $result = validate_username($username); if ($result['error']) { message_die(GENERAL_ERROR, $result['error_msg'] . $return); } else { DB()->query("UPDATE ". BB_BT_USERS ." SET seed_points = seed_points - $cost WHERE user_id = $user_id LIMIT 1"); $sql = "UPDATE ". BB_USERS ." SET username = '$username', username_old = '$curr_username' WHERE user_id = $user_id LIMIT 1"; if($result = DB()->sql_query($sql)) { delete_user_sessions($user_id); } $msg = sprintf($lang['SUCCESSFULLY_EXCHANGED_NEW_NAME'], $cost) . $return; } } else message_die(GENERAL_ERROR, $lang['POINTS_NOT_ENOUGH'] . $return); break;
в config_mods.php вставляемPHP:foreach ($bb_cfg['seed_points_ex']['namechange'] as $name => $cost) { $template->assign_block_vars('switch_namechange_allowed', array( 'BONUS_ID' => "namechange_$name", 'POINTS' => "$cost / <b class=\"$class\">$seed_points</b>", )); }
в шаблонPHP:'namechange' => array( '1' => 5000, ),
HTML:<!-- BEGIN switch_namechange_allowed --> <tr> <td class="row2 tLeft"> <b class="genmed">{L_USERNAME}:</b> <input type="text" name="username" size="35" maxlength="25" class="post" id="username" value="{USERNAME}" /> {L_NEW_NAME_TIP} </td> <td class="row1 tCenter"><span class="gen">{switch_namechange_allowed.POINTS}</span></td> <td class="row1 tCenter"><input type="radio" name="bonus_id" value="{switch_namechange_allowed.BONUS_ID}" /> </tr> <!-- END switch_namechange_allowed -->
break;
case 'namechange':
$sql = "SELECT username FROM ". BB_USERS ." WHERE user_id = $user_id LIMIT 1";
if ($row = DB()->fetch_row($sql))
{
$curr_username = $row['username'].":".time();
}
if (($cost = $bb_cfg['seed_points_ex']['namechange']["$bonus_count"]) && $seed_points >= $cost)
{
require_once(INC_DIR .'functions_validate.php');
$username = $_POST['username'];
if ($username == '')
{
message_die(GENERAL_MESSAGE, $lang['FIELDS_EMPTY']);
}
$result = validate_username($username);
if ($result['error'])
{
message_die(GENERAL_ERROR, $result['error_msg'] . $return);
}
else
{
DB()->query("UPDATE ". BB_BT_USERS ."
SET seed_points = seed_points - $cost
WHERE user_id = $user_id
LIMIT 1");
$sql = "UPDATE ". BB_USERS ."
SET username = '$username', username_old = '$curr_username'
WHERE user_id = $user_id
LIMIT 1";
if($result = DB()->sql_query($sql))
{
delete_user_sessions($user_id);
}
$msg = sprintf($lang['SUCCESSFULLY_EXCHANGED_NEW_NAME'], $cost) . $return;
}
}
else
message_die(GENERAL_ERROR, $lang['POINTS_NOT_ENOUGH'] . $return);
break;
foreach ($bb_cfg['seed_points_ex']['upload'] as $traffic => $cost)
{
$class = ($seed_points >= $cost) ? 'seed' : 'leech';
$template->assign_block_vars('bonusrow', array(
'BONUS_ID' => "upload_$traffic",
'BONUS_DESC' => humn_size($traffic*1024*1024*1024), // From bytes to GiB's
'POINTS' => "$cost / <b class=\"$class\">$seed_points</b>",
));
}
foreach ($bb_cfg['seed_points_ex']['namechange'] as $name => $cost)
{
$template->assign_block_vars('switch_namechange_allowed', array(
'BONUS_ID' => "namechange_$name",
'POINTS' => "$cost / <b class=\"$class\">$seed_points</b>",
));
}
ALTER TABLE `bb_users` ADD ` username_old ` text;