-
Notifications
You must be signed in to change notification settings - Fork 11
/
showPlayers.php
120 lines (104 loc) · 4.24 KB
/
showPlayers.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
<?php
// Copyright (C) 2012 Mark Vejvoda, Titus Tscharntke and Tom Reynolds
// The MegaGlest Team, under GNU GPL v3.0
// ==============================================================
define( 'INCLUSION_PERMITTED', true );
require_once( 'registry.php' );
require_once( 'config.php' );
require_once( 'functions.php' );
define( 'DB_LINK', db_connect() );
// $period = $_GET["period"];
if (isset($_GET["period"])) {
$period = $_GET["period"];
} else {
$period = "";
}
$timelimit=" ";
if( $period == "day") {
$timelimit = " and s.lasttime >= DATE_SUB(NOW(), INTERVAL 1 DAY) ";
}
else if( $period == "week") {
$timelimit = " and s.lasttime >= DATE_SUB(NOW(), INTERVAL 1 WEEK) ";
}
else if( $period == "month") {
$timelimit = " and s.lasttime >= DATE_SUB(NOW(), INTERVAL 1 MONTH) ";
}
$players_in_db = mysqli_query( Registry::$mysqliLink, 'select playername, count(*) as c, concat( floor(sum(ggs.framesToCalculatePlaytime)/30/(60*60*24)), \' days \' , sec_to_time(mod(sum(ggs.framesToCalculatePlaytime)/30,60*60*24))) as playtime from glestgameplayerstats s , glestgamestats ggs where s.gameUUID=ggs.gameUUID and controltype>4 '.$timelimit.' group by playername having c >1 order by c desc,playername LIMIT 100' );
$all_players = array();
while ( $players = mysqli_fetch_array( $players_in_db ) )
{
array_push( $all_players, $players );
}
unset( $players_in_db );
unset( $players );
db_disconnect( Registry::$mysqliLink );
unset( $linkid );
// Representation starts here
header( 'Content-Type: text/html; charset=utf-8' );
echo '<!DOCTYPE HTML>' . PHP_EOL;
echo '<html>' . PHP_EOL;
echo ' <head>' . PHP_EOL;
echo ' <meta charset="UTF-8" />' . PHP_EOL;
echo ' <title>' . htmlspecialchars( PRODUCT_NAME ) . ' top 100 players</title>' . PHP_EOL;
echo ' <link rel="stylesheet" type="text/css" href="style/screen.css" />' . PHP_EOL;
echo ' <link rel="shortcut icon" type="image/x-icon" href="images/' . htmlspecialchars( strtolower( PRODUCT_NAME ) ) . '.ico" />' . PHP_EOL;
echo ' </head>' . PHP_EOL;
echo ' <body>' . PHP_EOL;
echo ' <h1><a href="' . htmlspecialchars( PRODUCT_URL ) . '">' . htmlspecialchars( PRODUCT_NAME ) . '</a> Top 100 Players</h1>' . PHP_EOL;
if( $period == "day") {
echo ' <b>' . PHP_EOL;
}
echo ' <a href="' . $_SERVER['PHP_SELF'].'?period=day ">' . htmlspecialchars( 'day' ) . '</a> ' . PHP_EOL;
if( $period == "day") {
echo '</b>' . PHP_EOL;
}
if( $period == "week") {
echo ' <b>' . PHP_EOL;
}
echo ' <a href="' . $_SERVER['PHP_SELF'].'?period=week ">' . htmlspecialchars( 'week' ) . '</a> ' . PHP_EOL;
if( $period == "week") {
echo '</b>' . PHP_EOL;
}
if( $period == "month") {
echo ' <b>' . PHP_EOL;
}
echo ' <a href="' . $_SERVER['PHP_SELF'].'?period=month ">' . htmlspecialchars( 'month' ) . '</a> ' . PHP_EOL;
if( $period == "month") {
echo '</b>' . PHP_EOL;
}
if( $period == "") {
echo ' <b>' . PHP_EOL;
}
echo ' <a href="' . $_SERVER['PHP_SELF'].'">' . htmlspecialchars( 'all time' ) . '</a> ' . PHP_EOL;
if( $period == "") {
echo '</b>' . PHP_EOL;
}
echo ' <table>' . PHP_EOL;
echo ' <tr>' . PHP_EOL;
echo ' <th title="position">'.htmlspecialchars('#').'</th>' . PHP_EOL;
echo ' <th title="playerName">Player Name</th>' . PHP_EOL;
echo ' <th title="gamesPlayed">Games Played</th>' . PHP_EOL;
echo ' <th title="gamesPlayed">Total Time Played</th>' . PHP_EOL;
echo ' </tr>' . PHP_EOL;
$position = 0;
foreach( $all_players as $player )
{
$position +=1;
echo "\t\t\t" . '<tr>' . PHP_EOL;
// #
printf( "\t\t\t\t<td>%s</td>%s", htmlspecialchars( $position, ENT_QUOTES ), PHP_EOL );
// playername
printf( "\t\t\t\t<td>%s</td>%s", htmlspecialchars( $player['playername'], ENT_QUOTES ), PHP_EOL );
// # of games games
printf( "\t\t\t\t<td>%s</td>%s", htmlspecialchars( $player['c'], ENT_QUOTES ), PHP_EOL );
// # of games games
printf( "\t\t\t\t<td>%s</td>%s", htmlspecialchars( $player['playtime'], ENT_QUOTES ), PHP_EOL );
echo "\t\t\t" . '</tr>' . PHP_EOL;
}
echo ' </table>' . PHP_EOL;
//echo ' <script language="javascript" type="text/javascript" src="scripts/utils.js"></script>' . PHP_EOL;
echo ' </body>' . PHP_EOL;
echo '</html>' . PHP_EOL;
unset( $all_players );
unset( $player );
?>