forked from RetroAchievements/RAWeb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhistoryexamine.php
205 lines (155 loc) · 5.39 KB
/
historyexamine.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
<?php
require_once('db.inc.php');
RA_ReadCookieCredentials( $user, $points, $truePoints, $unreadMessageCount, $permissions );
$userPage = seekGET( 'u', $user );
if( !isset( $userPage ) )
{
header( "Location: http://" . AT_HOST . "?e=notloggedin" );
exit;
}
$dateInput = seekGET( 'd', 0 );
$userPagePoints = getScore( $userPage );
$achEarnedOnDay = getAchievementsEarnedOnDay( $dateInput, $userPage );
$dateStr = strftime( "%d %b %Y", $dateInput );
$errorCode = seekGET( 'e' );
$pageTitle = "$userPage's Legacy - $dateStr";
RenderDocType( TRUE );
//error_reporting(E_ALL);
?>
<head>
<?php RenderSharedHeader( $user ); ?>
<?php RenderTitleTag( $pageTitle, $user ); ?>
<?php RenderGoogleTracking(); ?>
</head>
<body>
<?php RenderTitleBar( $user, $points, $truePoints, $unreadMessageCount, $errorCode ); ?>
<?php RenderToolbar( $user, $permissions ); ?>
<div id="mainpage">
<div id='leftcontainer'>
<?php
echo "<div class='left'>";
echo "<div class='navpath'>";
echo "<a href='/userList.php'>All Users</a>";
echo " » <a href='/User/$userPage'>$userPage</a>";
echo " » <a href='history.php?u=$userPage'>History</a>";
echo " » <b>$dateStr</b>";
echo "</div>";
echo "<h3 class='longheader'>$userPage's legacy - $dateStr</h3>";
echo "<div class='userlegacy'>";
echo "<img src='/UserPic/$userPage.png' alt='$userPage' align='right' width='64' height='64'>";
echo "<b><a href='/User/$userPage'><strong>$userPage</strong></a> ($userPagePoints points)</b><br/><br/>";
//echo "<a href='history.php?u=$userPage'>Back to $userPage's Legacy</a>";
echo "<br/>";
echo "</div>";
echo "<table class='smalltable xsmall'><tbody>";
//$sort1 = ($sortBy==1) ? 11 : 1;
//$sort2 = ($sortBy==2) ? 12 : 2;
//$sort3 = ($sortBy==3) ? 13 : 3;
echo "<tr>";
echo "<th>At</th>";
echo "<th>Title</th>";
echo "<th>Description</th>";
echo "<th>Points</th>";
echo "<th>Author</th>";
echo "<th>Game Title</th>";
echo "</tr>";
//var_dump( $achEarnedOnDay );
// Merge if poss and count
$achCount = count($achEarnedOnDay);
$pointsCount = 0;
//foreach( $achEarnedOnDay as $achEarned )
// Tally all
for( $i = 0; $i < $achCount; $i++ )
{
$achID = $achEarnedOnDay[$i]['AchievementID'];
$achPoints = $achEarnedOnDay[$i]['Points'];
$pointsCount += $achPoints;
}
$achEarnedLib = Array();
// Store all NORMAL into $achEarnedLib
for( $i = 0; $i < $achCount; $i++ )
{
$achID = $achEarnedOnDay[$i]['AchievementID'];
//var_dump( $achEarnedOnDay[$i] );
if( $achEarnedOnDay[$i]['HardcoreMode'] == 0 )
$achEarnedLib[$achID] = $achEarnedOnDay[$i];
}
// Potentially overwrite HARDCORE into $achEarnedLib
for( $i = 0; $i < $achCount; $i++ )
{
$achID = $achEarnedOnDay[$i]['AchievementID'];
if( $achEarnedOnDay[$i]['HardcoreMode'] == 1 )
{
//if( isset( $achEarnedLib[$achID] ) && $achEarnedLib[$achID]['HardcoreMode'] == 1 )
// Ordinary ach also exists: notify in points col
$achEarnedLib[$achID] = $achEarnedOnDay[$i];
$achPoints = $achEarnedLib[$achID]['Points'];
$achEarnedLib[$achID]['PointsNote'] = "<span class='hardcore'>(+$achPoints)</span>";
}
}
//
function dateCompare($a, $b)
{
return $a['Date'] > $b['Date'];
}
usort( $achEarnedLib, "dateCompare" );
foreach( $achEarnedLib as $achEarned )
{
$achAwardedAt = $achEarned['Date'];
$achID = $achEarned['AchievementID'];
$achTitle = $achEarned['Title'];
$achDesc = $achEarned['Description'];
$achPoints = $achEarned['Points'];
$achPointsNote = isset( $achEarned['PointsNote'] ) ? $achEarned['PointsNote'] : '';
$achAuthor = $achEarned['Author'];
$achGameID = $achEarned['GameID'];
$achGameTitle = $achEarned['GameTitle'];
$achGameIcon = $achEarned['GameIcon'];
$achConsoleName = $achEarned['ConsoleName'];
$achBadgeName = $achEarned['BadgeName'];
$hardcoreMode = $achEarned['HardcoreMode'];
//$pointsCount += $achPoints;
//$dateUnix = strtotime( "$nextDay-$nextMonth-$nextYear" );
//$dateStr = getNiceDate( $dateUnix, TRUE );
echo "<tr>";
echo "<td>";
echo getNiceTime( strtotime( $achAwardedAt ) );
echo "</td>";
echo "<td style='min-width:25%'>";
echo GetAchievementAndTooltipDiv( $achID, $achTitle, $achDesc, $achPoints, $achGameTitle, $achBadgeName, TRUE );
echo "</td>";
echo "<td style='min-width:25%'>";
echo "$achDesc";
if( $hardcoreMode )
echo " <span class='hardcore'>(Hardcore!)</span>";
echo "</td>";
echo "<td>";
echo "$achPoints $achPointsNote";
echo "</td>";
echo "<td>";
echo GetUserAndTooltipDiv( $achAuthor, NULL, NULL, NULL, NULL, TRUE );
echo "</td>";
echo "<td>";
echo GetGameAndTooltipDiv( $achGameID, $achGameTitle, $achGameIcon, $achConsoleName, TRUE, 32 );
echo "</td>";
echo "</tr>";
}
echo "</tbody></table>";
echo "<h3>Summary</h3>";
echo "<div class='historyexaminesummary'>";
echo "Total earned on $dateStr: <strong>$pointsCount</strong> points, <strong>$achCount</strong> achievements.<br/><br/>";
echo "<a href='/history.php?u=$userPage'>« Back to $userPage's Legacy</a><br/><br/>";
echo "</div>";
echo "</div>";
?>
</div>
<div id='rightcontainer'>
<?php
if( $user !== NULL )
RenderScoreLeaderboardComponent( $user, $points, $yOffset, TRUE );
?>
</div>
</div>
<?php RenderFooter(); ?>
</body>
</html>