';
}
}
#endregion
// CHANGE character name
if (!empty($_POST['change_name'])) {
if (!Token::isValid($_POST['token'])) {
exit();
}
$oldname = getValue($_POST['change_name']);
$newname = getValue($_POST['newName']);
// Check if user is online
$player = false;
if ($config['TFSVersion'] === 'TFS_10') {
$player = mysql_select_single("SELECT `id`, `account_id` FROM `players` WHERE `name` = '$oldname'");
$player['online'] = (user_is_online_10($player['id'])) ? 1 : 0;
} else $player = mysql_select_single("SELECT `id`, `account_id`, `online` FROM `players` WHERE `name` = '$oldname'");
// Check if player has bough ticket
$order = mysql_select_single("SELECT `id`, `account_id` FROM `znote_shop_orders` WHERE `type`='4' AND `account_id`='".$player['account_id']."' LIMIT 1;");
if ($order !== false) {
//data_dump($order, array($player['account_id'], $session_user_id), "data");
// Check if player and account matches
if ($session_user_id == $player['account_id'] && $session_user_id == $order['account_id']) {
// Check if new name is not occupied
$exist = mysql_select_single("SELECT `id` FROM `players` WHERE `name`='$newname';");
if (!$exist) {
// Check if new name follow rules
$newname = validate_name($newname);
if ($newname !== false) {
$error = false;
// name restriction
$resname = explode(" ", $newname);
foreach($resname as $res) {
if(in_array(strtolower($res), $config['invalidNameTags'])) {
$error = true;
}
else if(strlen($res) == 1) {
$error = true;
}
}
// Check name for illegal characters.
function checkNewNameForIllegal($name) {
if (preg_match('#^[\0-9åäö&()+%/*$€é,.\'"-]*$#i', $name)) {
return true;
}
return false;
}
if (checkNewNameForIllegal($newname)) {
$error = true;
echo 'This name contains illegal characters.';
}
if ($error === false) {
// Change the name!
mysql_update("UPDATE `players` SET `name`='$newname' WHERE `id`='".$player['id']."' LIMIT 1;");
mysql_delete("DELETE FROM `znote_shop_orders` WHERE `id`='".$order['id']."' LIMIT 1;");
}
} else echo "Name validation failed, use another name.";
} else echo "The character name you wish to change to already exist.";
} else echo "Failed to sync your account. :|";
} else echo "Did not find any name change tickets, but them in our shop!";
}
// end
// Change character sex
if (!empty($_POST['change_gender'])) {
if (!Token::isValid($_POST['token'])) {
exit();
}
if (user_character_account_id($_POST['change_gender']) === $session_user_id) {
$char_name = sanitize($_POST['change_gender']);
$char_id = (int)user_character_id($char_name);
$account_id = user_character_account_id($char_name);
if ($config['TFSVersion'] == 'TFS_10') {
$chr_data = user_is_online_10($char_id);
} else $chr_data = user_character_data($char_id, 'online');
if ($chr_data['online'] != 1) {
// Verify that we are not messing around with data
if ($account_id != $user_data['id']) die("wtf? Something went wrong, try relogging.");
// Fetch character tickets
$tickets = shop_account_gender_tickets($account_id);
if ($tickets !== false || $config['free_sex_change'] == true) {
// They are allowed to change gender
$last = false;
$infinite = false;
$tks = 0;
// Do we have any infinite tickets?
foreach ($tickets as $ticket) {
if ($ticket['count'] == 0) $infinite = true;
else if ($ticket > 0 && $infinite === false) $tks += (int)$ticket['count'];
}
if ($infinite === true) $tks = 0;
$dbid = (int)$tickets[0]['id'];
// If they dont have unlimited tickets, remove a count from their ticket.
if ($tickets[0]['count'] > 1) { // Decrease count
$tks--;
$tkr = ((int)$tickets[0]['count'] - 1);
shop_update_row_count($dbid, $tkr);
} else if ($tickets[0]['count'] == 1) { // Delete record
shop_delete_row_order($dbid);
$tks--;
}
// Change character gender:
//
user_character_change_gender($char_name);
echo 'You have successfully changed gender on character '. $char_name .'.';
if ($tks > 0) echo '
You have '. $tks .' gender change tickets left.';
else if ($infinite !== true) echo '
You are out of tickets.';
} else echo 'You don\'t have any character gender tickets, buy them in the SHOP!';
} else echo 'Your character must be offline.';
}
}
// end
// Change character comment PAGE1:
if (!empty($_POST['selected_comment'])) {
if (!Token::isValid($_POST['token'])) {
exit();
}
if (user_character_account_id($_POST['selected_comment']) === $session_user_id) {
$comment_data = user_znote_character_data(user_character_id($_POST['selected_comment']), 'comment');
?>
Welcome to your account page,
You have days remaining premium account.
NAME | LEVEL | VOCATION | TOWN | LAST LOGIN | STATUS | HIDE | '. $value['name'] .' | '. $value['level'] .' | '. $value['vocation'] .' | '. $value['town_id'] .' | '. $value['lastlogin'] .' | '. $value['online'] .' | '. hide_char_to_name(user_character_hide($value['name'])) .' | '; echo ''; $characters[] = $value['name']; } ?>
---|