mirror of
https://github.com/Znote/ZnoteAAC.git
synced 2025-04-30 11:19:22 +02:00
myaccount - cleanup, optimize and fixes
This commit is contained in:
parent
ae07a0f421
commit
f7445bb89a
@ -143,7 +143,18 @@ function support_list03() {
|
|||||||
|
|
||||||
// NEWS
|
// NEWS
|
||||||
function fetchAllNews() {
|
function fetchAllNews() {
|
||||||
return mysql_select_multi("SELECT `n`.`id`, `n`.`title`, `n`.`text`, `n`.`date`, `p`.`name` FROM `znote_news` AS `n` INNER JOIN `players` AS `p` ON `n`.`pid` = `p`.`id` ORDER BY `n`.`id` DESC;");
|
return mysql_select_multi("
|
||||||
|
SELECT
|
||||||
|
`n`.`id`,
|
||||||
|
`n`.`title`,
|
||||||
|
`n`.`text`,
|
||||||
|
`n`.`date`,
|
||||||
|
`p`.`name`
|
||||||
|
FROM `znote_news` AS `n`
|
||||||
|
INNER JOIN `players` AS `p`
|
||||||
|
ON `n`.`pid` = `p`.`id`
|
||||||
|
ORDER BY `n`.`id` DESC;
|
||||||
|
");
|
||||||
}
|
}
|
||||||
|
|
||||||
// HOUSES
|
// HOUSES
|
||||||
@ -640,16 +651,30 @@ function user_character_list($account_id) {
|
|||||||
//$count = user_character_list_count($account_id);
|
//$count = user_character_list_count($account_id);
|
||||||
$account_id = (int)$account_id;
|
$account_id = (int)$account_id;
|
||||||
|
|
||||||
if (config('ServerEngine') == 'TFS_10') {
|
$characters = mysql_select_multi("
|
||||||
$characters = mysql_select_multi("SELECT `p`.`id`, `p`.`name`, `p`.`level`, `p`.`vocation`, `p`.`town_id`, `p`.`lastlogin`, `gm`.`rank_id`, `po`.`player_id` AS `online` FROM `players` AS `p` LEFT JOIN `guild_membership` AS `gm` ON `p`.`id`=`gm`.`player_id` LEFT JOIN `players_online` AS `po` ON `p`.`id`=`po`.`player_id` WHERE `p`.`account_id`='$account_id' ORDER BY `p`.`level` DESC");
|
SELECT
|
||||||
if ($characters !== false) {
|
`p`.`id`,
|
||||||
for ($i = 0; $i < count($characters); $i++) {
|
`p`.`name`,
|
||||||
$characters[$i]['online'] = ($characters[$i]['online'] > 0) ? 1 : 0;
|
`p`.`level`,
|
||||||
//unset($characters[$i]['id']);
|
`p`.`vocation`,
|
||||||
}
|
`p`.`town_id`,
|
||||||
}
|
`p`.`lastlogin`,
|
||||||
|
`gm`.`rank_id`,
|
||||||
} else $characters = mysql_select_multi("SELECT `id`, `name`, `level`, `vocation`, `town_id`, `lastlogin`, `online`, `rank_id` FROM `players` WHERE `account_id`='$account_id' ORDER BY `level` DESC");
|
`zp`.`hide_char`,
|
||||||
|
CASE WHEN `po`.`player_id` IS NULL
|
||||||
|
THEN 0
|
||||||
|
ELSE 1
|
||||||
|
END AS `online`
|
||||||
|
FROM `players` AS `p`
|
||||||
|
LEFT JOIN `guild_membership` AS `gm`
|
||||||
|
ON `p`.`id`=`gm`.`player_id`
|
||||||
|
LEFT JOIN `players_online` AS `po`
|
||||||
|
ON `p`.`id`=`po`.`player_id`
|
||||||
|
LEFT JOIN `znote_players` AS `zp`
|
||||||
|
ON `p`.`id`=`zp`.`player_id`
|
||||||
|
WHERE `p`.`account_id`='{$account_id}'
|
||||||
|
ORDER BY `p`.`level` DESC
|
||||||
|
");
|
||||||
|
|
||||||
if ($characters !== false) {
|
if ($characters !== false) {
|
||||||
$count = count($characters);
|
$count = count($characters);
|
||||||
|
@ -5,7 +5,15 @@ include 'layout/overall/header.php';
|
|||||||
$undelete_id = @$_GET['cancel_delete_id'];
|
$undelete_id = @$_GET['cancel_delete_id'];
|
||||||
if($undelete_id) {
|
if($undelete_id) {
|
||||||
$undelete_id = (int)$undelete_id;
|
$undelete_id = (int)$undelete_id;
|
||||||
$undelete_q1 = mysql_select_single('SELECT `character_name` FROM `znote_deleted_characters` WHERE `done` = 0 AND `id` = ' . $undelete_id . ' AND `original_account_id` = ' . $session_user_id . ' AND NOW() < `time`');
|
$undelete_q1 = mysql_select_single("
|
||||||
|
SELECT
|
||||||
|
`character_name`
|
||||||
|
FROM `znote_deleted_characters`
|
||||||
|
WHERE `done` = 0
|
||||||
|
AND `id` = {$undelete_id}
|
||||||
|
AND `original_account_id` = {$session_user_id}
|
||||||
|
AND NOW() < `time`
|
||||||
|
");
|
||||||
if($undelete_q1) {
|
if($undelete_q1) {
|
||||||
mysql_delete('DELETE FROM `znote_deleted_characters` WHERE `id` = ' . $undelete_id);
|
mysql_delete('DELETE FROM `znote_deleted_characters` WHERE `id` = ' . $undelete_id);
|
||||||
echo 'Pending delete of ' . $undelete_q1['character_name'] . ' has been successfully canceled.<br/>';
|
echo 'Pending delete of ' . $undelete_q1['character_name'] . ' has been successfully canceled.<br/>';
|
||||||
@ -93,7 +101,7 @@ if (!empty($_POST['selected_character'])) {
|
|||||||
switch($action) {
|
switch($action) {
|
||||||
// Change character comment PAGE2 (Success).
|
// Change character comment PAGE2 (Success).
|
||||||
case 'update_comment':
|
case 'update_comment':
|
||||||
if (user_character_account_id($char_name) === $session_user_id) {
|
if ((int)user_character_account_id($char_name) === $session_user_id) {
|
||||||
user_update_comment(user_character_id($char_name), getValue($_POST['comment']));
|
user_update_comment(user_character_id($char_name), getValue($_POST['comment']));
|
||||||
echo 'Successfully updated comment.';
|
echo 'Successfully updated comment.';
|
||||||
}
|
}
|
||||||
@ -103,7 +111,7 @@ if (!empty($_POST['selected_character'])) {
|
|||||||
// Hide character
|
// Hide character
|
||||||
case 'toggle_hide':
|
case 'toggle_hide':
|
||||||
$hide = (user_character_hide($char_name) == 1 ? 0 : 1);
|
$hide = (user_character_hide($char_name) == 1 ? 0 : 1);
|
||||||
if (user_character_account_id($char_name) === $session_user_id) {
|
if ((int)user_character_account_id($char_name) === $session_user_id) {
|
||||||
user_character_set_hide(user_character_id($char_name), $hide);
|
user_character_set_hide(user_character_id($char_name), $hide);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -111,21 +119,13 @@ if (!empty($_POST['selected_character'])) {
|
|||||||
|
|
||||||
// DELETE character
|
// DELETE character
|
||||||
case 'delete_character':
|
case 'delete_character':
|
||||||
if (user_character_account_id($char_name) === $session_user_id) {
|
if ((int)user_character_account_id($char_name) === $session_user_id) {
|
||||||
$charid = user_character_id($char_name);
|
$charid = user_character_id($char_name);
|
||||||
if ($charid !== false) {
|
if ($charid !== false) {
|
||||||
if ($config['ServerEngine'] === 'TFS_10') {
|
|
||||||
if (!user_is_online_10($charid)) {
|
if (!user_is_online_10($charid)) {
|
||||||
if (guild_leader_gid($charid) === false) user_delete_character_soft($charid);
|
if (guild_leader_gid($charid) === false) user_delete_character_soft($charid);
|
||||||
else echo 'Character is leader of a guild, you must disband the guild or change leadership before deleting character.';
|
else echo 'Character is leader of a guild, you must disband the guild or change leadership before deleting character.';
|
||||||
} else echo 'Character must be offline first.';
|
} else echo 'Character must be offline first.';
|
||||||
} else {
|
|
||||||
$chr_data = user_character_data($charid, 'online');
|
|
||||||
if ($chr_data['online'] != 1) {
|
|
||||||
if (guild_leader_gid($charid) === false) user_delete_character_soft($charid);
|
|
||||||
else echo 'Character is leader of a guild, you must disband the guild or change leadership before deleting character.';
|
|
||||||
} else echo 'Character must be offline first.';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -137,10 +137,8 @@ if (!empty($_POST['selected_character'])) {
|
|||||||
$newname = isset($_POST['newName']) ? getValue($_POST['newName']) : '';
|
$newname = isset($_POST['newName']) ? getValue($_POST['newName']) : '';
|
||||||
|
|
||||||
$player = false;
|
$player = false;
|
||||||
if ($config['ServerEngine'] === 'TFS_10') {
|
|
||||||
$player = mysql_select_single("SELECT `id`, `account_id` FROM `players` WHERE `name` = '$oldname'");
|
$player = mysql_select_single("SELECT `id`, `account_id` FROM `players` WHERE `name` = '$oldname'");
|
||||||
$player['online'] = (user_is_online_10($player['id'])) ? 1 : 0;
|
$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 user is online
|
// Check if user is online
|
||||||
if ($player['online'] == 1) {
|
if ($player['online'] == 1) {
|
||||||
@ -204,13 +202,11 @@ if (!empty($_POST['selected_character'])) {
|
|||||||
|
|
||||||
// Change character sex
|
// Change character sex
|
||||||
case 'change_gender':
|
case 'change_gender':
|
||||||
if (user_character_account_id($char_name) === $session_user_id) {
|
if ((int)user_character_account_id($char_name) === $session_user_id) {
|
||||||
$char_id = (int)user_character_id($char_name);
|
$char_id = (int)user_character_id($char_name);
|
||||||
$account_id = user_character_account_id($char_name);
|
$account_id = user_character_account_id($char_name);
|
||||||
|
|
||||||
if ($config['ServerEngine'] == 'TFS_10') {
|
|
||||||
$chr_data['online'] = user_is_online_10($char_id) ? 1 : 0;
|
$chr_data['online'] = user_is_online_10($char_id) ? 1 : 0;
|
||||||
} else $chr_data = user_character_data($char_id, 'online');
|
|
||||||
if ($chr_data['online'] != 1) {
|
if ($chr_data['online'] != 1) {
|
||||||
// Verify that we are not messing around with data
|
// Verify that we are not messing around with data
|
||||||
if ($account_id != $user_data['id']) die("wtf? Something went wrong, try relogging.");
|
if ($account_id != $user_data['id']) die("wtf? Something went wrong, try relogging.");
|
||||||
@ -254,7 +250,7 @@ if (!empty($_POST['selected_character'])) {
|
|||||||
// Change character comment PAGE1:
|
// Change character comment PAGE1:
|
||||||
case 'change_comment':
|
case 'change_comment':
|
||||||
$render_page = false; // Regular "myaccount" page should not render
|
$render_page = false; // Regular "myaccount" page should not render
|
||||||
if (user_character_account_id($char_name) === $session_user_id) {
|
if ((int)user_character_account_id($char_name) === $session_user_id) {
|
||||||
$comment_data = user_znote_character_data(user_character_id($char_name), 'comment');
|
$comment_data = user_znote_character_data(user_character_id($char_name), 'comment');
|
||||||
?>
|
?>
|
||||||
<!-- Changing comment MARKUP -->
|
<!-- Changing comment MARKUP -->
|
||||||
@ -303,21 +299,12 @@ if ($render_page) {
|
|||||||
?>
|
?>
|
||||||
<div id="myaccount">
|
<div id="myaccount">
|
||||||
<h1>My account</h1>
|
<h1>My account</h1>
|
||||||
<p>Welcome to your account page, <?php if ($config['ServerEngine'] !== 'OTHIRE') echo $user_data['name']; else echo $user_data['id']; ?><br>
|
<p>Welcome to your account page, <?php echo $user_data['name']; ?><br>
|
||||||
<?php if ($config['ServerEngine'] !== 'OTHIRE') {
|
<?php
|
||||||
if ($user_data['premdays'] != 0) {
|
// Todo: If premdays is less than 2, inform how many hours are left.
|
||||||
echo 'You have ' .$user_data['premdays']. ' remaining premium account days.';
|
if ($user_data['premdays'] != 0) echo "You have {$user_data['premdays']} remaining premium account days.";
|
||||||
} else {
|
else echo 'You are free account.';
|
||||||
echo 'You are free account.';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ($user_data['premend'] != 0) {
|
|
||||||
echo 'Your premium account will last till ';
|
|
||||||
echo date("d/m/Y", $user_data['premend']);
|
|
||||||
} else {
|
|
||||||
echo 'You do not have premium account days.';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($config['mailserver']['myaccount_verify_email']):
|
if ($config['mailserver']['myaccount_verify_email']):
|
||||||
?><br>Email: <?php echo $user_data['email'];
|
?><br>Email: <?php echo $user_data['email'];
|
||||||
if ($user_znote_data['active_email'] == 1) {
|
if ($user_znote_data['active_email'] == 1) {
|
||||||
@ -328,7 +315,7 @@ if ($render_page) {
|
|||||||
endif; ?>
|
endif; ?>
|
||||||
</p>
|
</p>
|
||||||
<?php
|
<?php
|
||||||
if ($config['ServerEngine'] === 'TFS_10' && $config['twoFactorAuthenticator']) {
|
if ($config['twoFactorAuthenticator']) {
|
||||||
$query = mysql_select_single("SELECT `secret` FROM `accounts` WHERE `id`='".(int)$session_user_id."' LIMIT 1;");
|
$query = mysql_select_single("SELECT `secret` FROM `accounts` WHERE `id`='".(int)$session_user_id."' LIMIT 1;");
|
||||||
$status = ($query['secret'] === NULL) ? false : true;
|
$status = ($query['secret'] === NULL) ? false : true;
|
||||||
?><p>Account security with Two-factor Authentication: <a href="twofa.php"><?php echo ($status) ? 'Enabled' : 'Disabled'; ?></a></p><?php
|
?><p>Account security with Two-factor Authentication: <a href="twofa.php"><?php echo ($status) ? 'Enabled' : 'Disabled'; ?></a></p><?php
|
||||||
@ -343,17 +330,27 @@ if ($render_page) {
|
|||||||
?>
|
?>
|
||||||
<table id="myaccountTable" class="table table-striped table-hover">
|
<table id="myaccountTable" class="table table-striped table-hover">
|
||||||
<tr class="yellow">
|
<tr class="yellow">
|
||||||
<th>NAME</th><th>LEVEL</th><th>VOCATION</th><th>TOWN</th><th>LAST LOGIN</th><th>STATUS</th><th>HIDE</th>
|
<th>NAME</th>
|
||||||
|
<th>LEVEL</th>
|
||||||
|
<th>VOCATION</th>
|
||||||
|
<th>TOWN</th>
|
||||||
|
<th>LAST LOGIN</th>
|
||||||
|
<th>STATUS</th>
|
||||||
|
<th>HIDE</th>
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
$characters = array();
|
foreach ($char_array as $value): ?>
|
||||||
foreach ($char_array as $value) {
|
<tr>
|
||||||
// characters: [0] = name, [1] = level, [2] = vocation, [3] = town_id, [4] = lastlogin, [5] = online
|
<td><a href="characterprofile.php?name=<?php echo $value['name']; ?>"><?php echo $value['name']; ?></a></td>
|
||||||
echo '<tr>';
|
<td><?php echo $value['level']; ?></td>
|
||||||
echo '<td><a href="characterprofile.php?name='. $value['name'] .'">'. $value['name'] .'</a></td><td>'. $value['level'] .'</td><td>'. $value['vocation'] .'</td><td>'. $value['town_id'] .'</td><td>'. $value['lastlogin'] .'</td><td>'. $value['online'] .'</td><td>'. hide_char_to_name(user_character_hide($value['name'])) .'</td>';
|
<td><?php echo $value['vocation']; ?></td>
|
||||||
echo '</tr>';
|
<td><?php echo $value['town_id']; ?></td>
|
||||||
$characters[] = $value['name'];
|
<td><?php echo $value['lastlogin']; ?></td>
|
||||||
}
|
<td><?php echo $value['online']; ?></td>
|
||||||
|
<td><?php echo hide_char_to_name($value['hide_char']); ?></td>
|
||||||
|
</tr>
|
||||||
|
<?php
|
||||||
|
endforeach;
|
||||||
?>
|
?>
|
||||||
</table>
|
</table>
|
||||||
<!-- FORMS TO EDIT CHARACTER-->
|
<!-- FORMS TO EDIT CHARACTER-->
|
||||||
@ -362,15 +359,9 @@ if ($render_page) {
|
|||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<select id="selected_character" name="selected_character" class="form-control">
|
<select id="selected_character" name="selected_character" class="form-control">
|
||||||
<?php
|
<?php foreach ($char_array as $character): ?>
|
||||||
for ($i = 0; $i < $char_count; $i++) {
|
<option value="<?php echo $character['name']; ?>"><?php echo $character['name']; ?></option>
|
||||||
if (user_character_hide($characters[$i]) == 1) {
|
<?php endforeach; ?>
|
||||||
echo '<option value="'. $characters[$i] . '">'. $characters[$i] .'</option>';
|
|
||||||
} else {
|
|
||||||
echo '<option value="'. $characters[$i] . '">'. $characters[$i] .'</option>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@ -395,7 +386,7 @@ if ($render_page) {
|
|||||||
</form>
|
</form>
|
||||||
<?php
|
<?php
|
||||||
} else {
|
} else {
|
||||||
echo 'You don\'t have any characters. Why don\'t you <a href="createcharacter.php">create one</a>?';
|
echo "You don't have any characters. Why don't you <a href='createcharacter.php'>create one</a>?";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user