forked from pdinklag/MinecraftStats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathview-player.php
138 lines (131 loc) · 4.04 KB
/
view-player.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php
/**
* Viewing a specific player.
*
* Included by index.php when $_GET['player'] is set.
*/
$playerId = $_GET["player"];
if(isset($players[$playerId])) {
$player = $players[$playerId];
//Load player stats
$dataFile = "$playerDataDir/$playerId";
if(is_file($dataFile)) {
$pstats = unserialize(file_get_contents($dataFile));
} else {
$pstats = [];
}
$inactive = isPlayerInactive($playerId);
} else {
die("Unknown player.");
}
?>
<div id="header">
<?php echo(createPlayerWidget($playerId, 64)); ?>
<?php if(!isset($me)): ?>
<form action="index.php?player=<?php echo($playerId); ?>" method="post">
</form>
<?php endif; ?>
</div>
<div id="listing-wrapper">
<div class="listing">
<p class="date">Ultima vez online: <?php echo(formatDate(getPlayerLastOnline($playerId))); ?></p>
<?php if($inactive): ?>
<p class="inactive">Esse player esta inativo a mais de <?php echo((int)($inactiveTime / 86400)); ?> dias.</p>
<?php else: ?>
<p>Medalhas ganhas por <?php echo(getPlayerName($playerId)); ?>:</p>
<?php
//Count medals
$gold = 0;
$silver = 0;
$bronze = 0;
foreach($pstats as $id => $data) {
switch($data['rank']) {
case 0:
$gold++;
break;
case 1:
$silver++;
break;
case 2:
$bronze++;
break;
}
}
?>
<table class="medals">
<colgroup>
<col style="width:50%;"/>
<col style="width:50%;"/>
</colgroup>
<tbody>
<tr class="tablem">
<td class="medal"><img src="img/fatcow/medal_award_gold.png"/></td>
<td class="count"><?php echo($gold); ?></td>
</tr>
<tr class="tablem">
<td class="medal"><img src="img/fatcow/medal_award_silver.png"/></td>
<td class="count"><?php echo($silver); ?></td>
</tr>
<tr class="tablem">
<td class="medal"><img src="img/fatcow/medal_award_bronze.png"/></td>
<td class="count"><?php echo($bronze); ?></td>
</tr>
</tbody>
</table>
<?php endif; ?>
</div>
<hr/>
<div class="listing">
<p>Estatisticas por medalhas (<a href="?raw=<?php echo($playerId); ?>">veja dados brutos</a>):</p>
<table class="listing">
<colgroup>
<col style="width:40%;"/>
<col style="width:15%;"/>
<col style="width:35%;"/>
<col style="width:10%;"/>
</colgroup>
<tbody>
<tr>
<th>Estatistica</th>
<th>Pontos</th>
<th>Medalha</th>
<th>Rank</th>
</tr>
<?php sortStatsByAwardName(); ?>
<?php foreach($stats as $id => $stat): ?>
<?php
if(array_key_exists($id, $pstats)) {
$score = getStatDisplayValue($stat, $pstats[$id]['score']);
if(isset($pstats[$id]['rank'])) {
$rank = $pstats[$id]['rank'];
} else {
unset($rank);
}
} else {
unset($score);
unset($rank);
}
?>
<tr>
<td class="stat">
<?php echo($stat['desc']); ?>:
</td>
<td class="score">
<?php echo(isset($score) ? $score : '—'); ?>
</td>
<td class="award <?php if(isset($rank)) { echo("place$rank"); } ?>"><span class="icon">
<img src="<?php echo(getStatIcon($stat)); ?>"/></span> <a href="?stat=<?php echo($id); ?>"><?php echo($stat['award']); ?></a>
</td>
<td class="rank <?php if(isset($rank)) { echo("place$rank medal$rank"); } ?>">
<?php if(isset($rank)): ?>
<?php echo('#' . ($rank + 1)); ?>
<?php else: ?>
<?php echo('—'); ?>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>