From 3a58cb2802c8be14f78015105afe759b1c7ce692 Mon Sep 17 00:00:00 2001 From: Matthijs Kuiper Date: Tue, 9 Jan 2018 00:43:43 +0100 Subject: Implement design for pages and update includes --- html/pages/home.php | 266 +++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 202 insertions(+), 64 deletions(-) (limited to 'html/pages/home.php') diff --git a/html/pages/home.php b/html/pages/home.php index be75b66..535c15b 100755 --- a/html/pages/home.php +++ b/html/pages/home.php @@ -1,17 +1,154 @@ - - UTStats Summary + +include_once("analytics.php"); + +// Get last map, time, scores +$qlastMaps = small_query("SELECT id, mapfile, time, t0score, t1score, t2score, t3score FROM uts_match WHERE time = (SELECT MAX(time) FROM uts_match)"); +$lastMapId = $qlastMaps['id']; +$lastMapFile = $qlastMaps['mapfile']; +$lastMapFileName = rtrim($lastMapFile, ".unr"); + +$lastMapTime = $qlastMaps['time']; +$lastMapScore0 = $qlastMaps['t0score']; +$lastMapScore1 = $qlastMaps['t1score']; +$lastMapScore2 = $qlastMaps['t2score']; +$lastMapScore3 = $qlastMaps['t3score']; +$moreThan2Teams = ($lastMapScore2!=0); + +$mappic = getMapImageName($lastMapFileName); + +// quick hack to show empty one at front page if no map +if (!file_exists($mappic) || $mappic == "images/maps/blank_large.jpg") { + $mappic = "images/maps/emptyfront.jpg"; +} + +echo ' +
+
Last Map Updated
+ +
+ +
+
+ + + + + - - - - - + + + + + '; +$sql_recent = "SELECT m.id, m.time, g.name AS gamename, m.mapfile, m.gametime, t0score, t1score, t2score, t3score, (SELECT count(p.id) FROM uts_player AS p WHERE m.id = p.matchid) as players FROM uts_match AS m, uts_games AS g WHERE g.id = m.gid $where ORDER BY m.time DESC LIMIT 10"; +$q_recent = mysql_query($sql_recent) or die(mysql_error()); + +while ($r_recent = mysql_fetch_array($q_recent)) { + $r_time = mdate($r_recent[time]); + $r_mapfile = un_ut($r_recent[mapfile]); + $r_gametime = GetMinutes($r_recent[gametime]); + $winner = max($r_recent[t0score], $r_recent[t1score], $r_recent[t2score], $r_recent[t3score]); + + if ($winner == $r_recent[t0score]) { + $winnercolor = "red"; + $winmsg = "Red is the winner!"; + } + elseif ($winner == $r_recent[t1score]) { + $winnercolor = "blue"; + $winmsg = "Blue is the winner!"; + } + elseif ($winner == $r_recent[t2score]) { + $winnercolor = "green"; + $winmsg = "Green is the winner!"; + } + else { + $winnercolor = "gold"; + $winmsg = "Gold is the winner!"; + }; + + echo' + + + + + + + '; +} + +echo ' + + + + + +
Last 10 Matches
PlayersServersMapsMatches LoggedPlayer HoursIDDate/TimeMatch TypeMapScores
'.$r_recent[id].''.$r_time.''.$r_recent[gamename].''.$r_mapfile.' + '.$r_recent[t0score].''.$r_recent[t1score].''; + + if ($moreThan2Teams) { + echo ''.$r_recent[t2score].' '.$r_recent[t3score].''; + } + + echo '
+ Show all games +
+
'; + +echo' + + + + + + + + + + + + + '; + // Get Summary Info $r_playercount = small_query("SELECT COUNT(*) AS result FROM uts_pinfo"); $playercount = $r_playercount['result']; @@ -20,47 +157,42 @@ $mapcount = small_count("SELECT COUNT(mapfile) AS result FROM uts_match GROUP BY $r_matchcount = small_query("SELECT COUNT(*) AS result FROM uts_match"); $matchcount= $r_matchcount['result']; $hourscount = small_query("SELECT SUM(gametime) AS result FROM uts_player"); - $gametime = sec2hour($hourscount[result]); -echo' +echo ' - - - - - + + + + + -
UTStats Summary
PlayersServersMapsMatches LoggedPlayer Hours
'.$playercount.''.$servercount.''.$mapcount.''.$matchcount.''.$gametime.''.$playercount.''.$servercount.''.$mapcount.''.$matchcount.''.$gametime.'
- - - -
-
-

Welcome to UTStats.
- Here you can look up information on UT matches and players.
- Select a category from the column on the left.

-
- - - - - - - - - - - - - - '; + +
Game Summary
Match TypeFragsKillsSuicidesTeam KillsMatchesGame Hours
+
+ + + + + + + + + + + + + + + + +'; $sql_gamesummary = "SELECT g.id AS gid, g.name AS gamename, SUM(p.frags) AS frags, SUM(p.kills) AS kills, SUM(p.suicides) AS suicides, SUM(p.teamkills) AS teamkills, COUNT(DISTINCT p.matchid) AS matchcount -FROM uts_player AS p, uts_games AS g -WHERE p.gid = g.id -GROUP BY gamename, gid -ORDER BY gamename ASC"; + FROM uts_player AS p, uts_games AS g + WHERE p.gid = g.id + GROUP BY gamename, gid + ORDER BY gamename ASC"; $q_gamesummary = mysql_query($sql_gamesummary) or die(mysql_error()); @@ -70,36 +202,42 @@ while ($r_gamesummary = mysql_fetch_array($q_gamesummary)) { $q_gametime = small_query("SELECT SUM(gametime) AS gametime FROM uts_match WHERE gid = '$gid'"); $gametime = sec2hour($q_gametime[gametime]); - echo' - - - - - - '; + echo ' + + + + + + + + + '; } $totalsummary = small_query("SELECT SUM(p.frags) AS frags, SUM(p.kills) AS kills, SUM(p.suicides) AS suicides, SUM(p.teamkills) AS teamkills, COUNT(DISTINCT p.matchid) AS matchcount, SUM(p.gametime) AS gametime -FROM uts_player AS p, uts_games AS g -WHERE p.gid = g.id"); + FROM uts_player AS p, uts_games AS g + WHERE p.gid = g.id"); $q_gametime = small_query("SELECT SUM(gametime) AS gametime FROM uts_match"); $gametime = sec2hour($q_gametime[gametime]); -echo' - - - - - - - - -
Game Summary
Match TypeFragsKillsSuicidesTeam KillsMatchesGame Hours
'.$r_gamesummary[gamename].''.$r_gamesummary[frags].''.$r_gamesummary[kills].''.$r_gamesummary[suicides].''.$r_gamesummary[teamkills].''.$r_gamesummary[matchcount].''.$gametime.'
'.$r_gamesummary[gamename].''.$r_gamesummary[frags].''.$r_gamesummary[kills].''.$r_gamesummary[suicides].''.$r_gamesummary[teamkills].''.$r_gamesummary[matchcount].''.$gametime.'
Totals for All Players'.$totalsummary[frags].''.$totalsummary[kills].''.$totalsummary[suicides].''.$totalsummary[teamkills].''.$totalsummary[matchcount].''.$gametime.'
-

'; +echo ' + + Totals for All Players + '.$totalsummary[frags].' + '.$totalsummary[kills].' + '.$totalsummary[suicides].' + '.$totalsummary[teamkills].' + '.$totalsummary[matchcount].' + '.$gametime.' + + + +
'; // Do graph stuff $gtitle = "Across All Servers"; $bgwhere = "id >= 0"; include("pages/graph_mbreakdown.php"); + ?> -- cgit