mirror of
https://github.com/Znote/ZnoteAAC.git
synced 2025-04-29 18:59:21 +02:00
Fix #429 Various warnings
Rewrote other characters on this account list in characterprofile Added hash_equal() backport for low PHP versions Fixed some warnings
This commit is contained in:
parent
5d9b0f3d00
commit
4b0db861d5
@ -840,11 +840,13 @@ if (isset($_GET['name']) === true && empty($_GET['name']) === false) {
|
||||
if (isset($config['quests']) && !empty($config['quests'])) {
|
||||
foreach ($config['quests'] as $cquest) {
|
||||
$totalquests = $totalquests + 1;
|
||||
foreach ($sqlquests as $dbquest) {
|
||||
if ($cquest[0] == $dbquest['key'] && $cquest[1] == $dbquest['value']) {
|
||||
$completedquests = $completedquests + 1;
|
||||
}
|
||||
}
|
||||
if ($sqlquests !== false) {
|
||||
foreach ($sqlquests as $dbquest) {
|
||||
if ($cquest[0] == $dbquest['key'] && $cquest[1] == $dbquest['value']) {
|
||||
$completedquests = $completedquests + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($cquest[3] == 1) {
|
||||
if ($completedquests != 0) {
|
||||
if ($firstrun == 1): ?>
|
||||
@ -885,49 +887,65 @@ if (isset($_GET['name']) === true && empty($_GET['name']) === false) {
|
||||
|
||||
<!-- CHARACTER LIST -->
|
||||
<?php
|
||||
if (user_character_hide($profile_data['name']) != 1 && user_character_list_count(user_character_account_id($name)) > 1)
|
||||
{
|
||||
?>
|
||||
// Backward compatibility
|
||||
$select_online = "CASE WHEN `l`.`player_id` IS NULL THEN 0 else 1 END as `online`";
|
||||
$join_online = "LEFT JOIN `players_online` as `l` ON `p`.`id` = `l`.`player_id`";
|
||||
if ($config['ServerEngine'] != 'TFS_10') {
|
||||
$select_online = "`p`.`online`";
|
||||
$join_online = "";
|
||||
}
|
||||
|
||||
// Load other visible characters
|
||||
$otherChars = mysql_select_multi("
|
||||
SELECT
|
||||
`p`.`id`,
|
||||
`p`.`name`,
|
||||
`p`.`level`,
|
||||
`p`.`vocation`,
|
||||
`p`.`lastlogin`,
|
||||
{$select_online}
|
||||
FROM `players` as `o`
|
||||
JOIN `players` as `p`
|
||||
ON `o`.`account_id` = `p`.`account_id`
|
||||
LEFT JOIN `znote_players` as `z`
|
||||
ON `p`.`id` = `z`.`player_id`
|
||||
{$join_online}
|
||||
WHERE `o`.`id` = {$user_id}
|
||||
AND `p`.`id` != `o`.`id`
|
||||
AND `z`.`hide_char` = 0
|
||||
ORDER BY `p`.`experience` DESC;
|
||||
");
|
||||
|
||||
// Render table if there are any characters to show
|
||||
if ($otherChars !== false) {
|
||||
?>
|
||||
<li>
|
||||
<b>Other visible characters on this account:</b><br>
|
||||
<?php
|
||||
$characters = user_character_list(user_character_account_id($profile_data['name']));
|
||||
// characters: [0] = name, [1] = level, [2] = vocation, [3] = town_id, [4] = lastlogin, [5] = online
|
||||
if ($characters && count($characters) > 0) {
|
||||
?>
|
||||
<table id="characterprofileTable" class="table table-striped table-hover">
|
||||
<tr class="yellow">
|
||||
<th>Name:</th>
|
||||
<th>Level:</th>
|
||||
<th>Vocation:</th>
|
||||
<th>Last login:</th>
|
||||
<th>Status:</th>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
// Design and present the list
|
||||
foreach ($characters as $char) {
|
||||
if ($char['name'] != $profile_data['name']) {
|
||||
if (hide_char_to_name(user_character_hide($char['name'])) != 'hidden'): ?>
|
||||
<tr>
|
||||
<td><a href="characterprofile.php?name=<?php echo $char['name']; ?>"><?php echo $char['name']; ?></a></td>
|
||||
<td><?php echo (int)$char['level']; ?></td>
|
||||
<td><?php echo $char['vocation']; ?></td>
|
||||
<td><?php echo $char['lastlogin']; ?></td>
|
||||
<td><?php echo $char['online']; ?></td>
|
||||
</tr>
|
||||
<?php endif;
|
||||
}
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<table id="characterprofileTable" class="table table-striped table-hover">
|
||||
<tr class="yellow">
|
||||
<th>Name:</th>
|
||||
<th>Level:</th>
|
||||
<th>Vocation:</th>
|
||||
<th>Last login:</th>
|
||||
<th>Status:</th>
|
||||
</tr>
|
||||
<?php
|
||||
}/* else {
|
||||
echo '<b><font color="green">This player has never died.</font></b>';
|
||||
}*/
|
||||
?>
|
||||
// Add character rows
|
||||
foreach ($otherChars as $char):
|
||||
?>
|
||||
<tr>
|
||||
<td><a href="characterprofile.php?name=<?php echo $char['name']; ?>"><?php echo $char['name']; ?></a></td>
|
||||
<td><?php echo (int)$char['level']; ?></td>
|
||||
<td><?php echo vocation_id_to_name($char['vocation']); ?></td>
|
||||
<td><?php echo ($char['lastlogin'] != 0) ? getClock($char['lastlogin'], true, true) : 'Never.'; ?></td>
|
||||
<td><?php echo ($char['online']) ? 'online' : 'offline'; ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
endforeach;
|
||||
?>
|
||||
</table>
|
||||
</li>
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<!-- END CHARACTER LIST -->
|
||||
|
@ -595,4 +595,19 @@ function random_bytes_compat($length, &$crypto_strong = null) {
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
// hash_equals legacy support < 5.6
|
||||
if(!function_exists('hash_equals')) {
|
||||
function hash_equals($str1, $str2) {
|
||||
if(strlen($str1) != strlen($str2)) {
|
||||
return false;
|
||||
}
|
||||
$res = $str1 ^ $str2;
|
||||
$ret = 0;
|
||||
for($i = strlen($res) - 1; $i >= 0; $i--) {
|
||||
$ret |= ord($res[$i]);
|
||||
}
|
||||
return !$ret;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -105,28 +105,27 @@ function fetchLatestDeaths_03($rowz = 30, $killers = false) {
|
||||
|
||||
// Support list
|
||||
function support_list() {
|
||||
$TFS = Config('ServerEngine');
|
||||
|
||||
if ($TFS == 'TFS_10') $staffs = mysql_select_multi("SELECT `p`.`id`, `a`.`type` as `group_id`, `p`.`name`, `p`.`account_id` FROM `players` AS `p` INNER JOIN `accounts` AS `a` ON `p`.`account_id` = `a`.`id` WHERE `a`.`type` > 1 ORDER BY `p`.`account_id` DESC, `p`.`group_id` ASC, `p`.`level` ASC;");
|
||||
else $staffs = mysql_select_multi("SELECT `a`.`type` as `group_id`, `p`.`name`, `p`.`online`, `p`.`account_id` FROM `players` AS `p` INNER JOIN `accounts` AS `a` ON `a`.`id` = `p`.`account_id` WHERE `a`.`type` > 1 ORDER BY `p`.`account_id` DESC, `p`.`group_id` ASC, `p`.`level` ASC;");
|
||||
|
||||
foreach($staffs as $k => $v) {
|
||||
foreach($staffs as $key => $value) {
|
||||
if($k != $key && $v['account_id'] == $value['account_id']) {
|
||||
unset($staffs[$k]);
|
||||
}
|
||||
}
|
||||
$TFS = Config('ServerEngine');
|
||||
if ($TFS == 'TFS_10') $staffs = mysql_select_multi("SELECT `p`.`id`, `a`.`type` as `group_id`, `p`.`name`, `p`.`account_id` FROM `players` AS `p` INNER JOIN `accounts` AS `a` ON `p`.`account_id` = `a`.`id` WHERE `a`.`type` > 1 ORDER BY `p`.`account_id` DESC, `p`.`group_id` ASC, `p`.`level` ASC;");
|
||||
else $staffs = mysql_select_multi("SELECT `a`.`type` as `group_id`, `p`.`name`, `p`.`online`, `p`.`account_id` FROM `players` AS `p` INNER JOIN `accounts` AS `a` ON `a`.`id` = `p`.`account_id` WHERE `a`.`type` > 1 ORDER BY `p`.`account_id` DESC, `p`.`group_id` ASC, `p`.`level` ASC;");
|
||||
if ($staffs !== false) {
|
||||
foreach($staffs as $k => $v) {
|
||||
foreach($staffs as $key => $value) {
|
||||
if($k != $key && $v['account_id'] == $value['account_id']) {
|
||||
unset($staffs[$k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
$staffs = array_values($staffs);
|
||||
if ($TFS == 'TFS_10') {
|
||||
for ($i = 0; $i < count($staffs); $i++) {
|
||||
// Fix online status on TFS 1.0
|
||||
$staffs[$i]['online'] = (isset($staffs[$i]['id']) && user_is_online_10($staffs[$i]['id'])) ? 1 : 0;
|
||||
unset($staffs[$i]['id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
$staffs = array_values($staffs);
|
||||
|
||||
if ($staffs !== false && $TFS == 'TFS_10') {
|
||||
for ($i = 0; $i < count($staffs); $i++) {
|
||||
// Fix online status on TFS 1.0
|
||||
$staffs[$i]['online'] = (isset($staffs[$i]['id']) && user_is_online_10($staffs[$i]['id'])) ? 1 : 0;
|
||||
unset($staffs[$i]['id']);
|
||||
}
|
||||
}
|
||||
return $staffs;
|
||||
return $staffs;
|
||||
}
|
||||
|
||||
function support_list03() {
|
||||
|
@ -124,28 +124,32 @@
|
||||
return $string;
|
||||
}
|
||||
|
||||
if (!empty($guilds) || $guilds !== false) {
|
||||
?>
|
||||
|
||||
<table id="onlinelistTable" class="table table-striped table-hover">
|
||||
<tr class="yellow">
|
||||
<b><tr><h3><center>Top 10 guilds with most frags</center></h3></tr></b>
|
||||
<th>#</th>
|
||||
<th>Name:</th>
|
||||
<th>Frags:</th>
|
||||
</tr>
|
||||
<?php foreach ($guilds as $guild) {
|
||||
|
||||
$url = url("guilds.php?name=". $guild['name']);
|
||||
echo '<tr class="special" onclick="javascript:window.location.href=\'' . $url . '\'">'; ?>
|
||||
<td><?php echo convert_number_to_words($count);
|
||||
$count++; ?></td>
|
||||
<td><a href="" onclick="return false"><?php echo $guild['name']; ?></a></td>
|
||||
<td><?php echo $guild['frags']; ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
|
||||
<?php
|
||||
} else echo '<h1>No frags yet.</h1>';
|
||||
if (!empty($guilds) && $guilds !== false) {
|
||||
?>
|
||||
<h3><center>Top 10 guilds with most frags</center></h3>
|
||||
<table id="onlinelistTable" class="table table-striped table-hover">
|
||||
<tr class="yellow">
|
||||
<th>#</th>
|
||||
<th>Name:</th>
|
||||
<th>Frags:</th>
|
||||
</tr>
|
||||
<?php
|
||||
foreach ($guilds as $guild):
|
||||
$url = url("guilds.php?name=". $guild['name']);
|
||||
?>
|
||||
<tr class="special" onclick="javascript:window.location.href='<?php echo $url; ?>'">
|
||||
<td><?php
|
||||
echo convert_number_to_words($count);
|
||||
$count++;
|
||||
?></td>
|
||||
<td><a href="" onclick="return false"><?php echo $guild['name']; ?></a></td>
|
||||
<td><?php echo $guild['frags']; ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
endforeach; ?>
|
||||
</table>
|
||||
<?php
|
||||
} else {
|
||||
echo '<h1>No frags yet.</h1>';
|
||||
}
|
||||
include 'layout/overall/footer.php'; ?>
|
||||
|
Loading…
x
Reference in New Issue
Block a user