diff options
author | Patrick Davison <snapwilliam@gmail.com> | 2012-07-31 22:34:08 -0700 |
---|---|---|
committer | Patrick Davison <snapwilliam@gmail.com> | 2012-07-31 22:34:08 -0700 |
commit | 2d290b23c402561ef30c1de665895c120dd79483 (patch) | |
tree | 8bde5ebd953f3dd375abe88e61e40571df313b1f /includes/datas.php | |
parent | 628c2e712e39fe85762583fd1ddc12609746fc58 (diff) | |
download | pathery-2d290b23c402561ef30c1de665895c120dd79483.tar.xz |
Everything related to the scoreboard.
New feedback page.
Changed the speed of the pauses on checkpoints during a path animation.
Changed how notifications are recieved.
Diffstat (limited to 'includes/datas.php')
-rw-r--r-- | includes/datas.php | 136 |
1 files changed, 135 insertions, 1 deletions
diff --git a/includes/datas.php b/includes/datas.php index c445ca1..8c0309c 100644 --- a/includes/datas.php +++ b/includes/datas.php @@ -49,7 +49,8 @@ function topScores($mapid, $top = 5, $bottom = 0) { if ($wallEmblem == '') $wallEmblem = 'blank.png'; - $cdate = date("g:i A (T)", strtotime($cdate)); + //$cdate = date("g:i A (T)", strtotime($cdate)); + $cdate = relativeTime(strtotime($cdate)); $background = '#262631'; if ($i % 2 == 1) @@ -588,6 +589,139 @@ function trackMOTDstats($mapType) { +//Select Stats/Scores. +function getScores($mapid, $pageNumber = 1, $pageDivide = 10) { + $top = $pageNumber * $pageDivide; + $bottom = $top - $pageDivide; + + $pageRequest = 'all'; + + if ($pageRequest == 'all') { + $pageReqStart = 1; + $pageReqEnd = 1000; + } elseif (is_int($pageRequest)) { + $pageReqStart = $pageRequest; + $pageReqEnd = $pageRequest; + } else { + $tmp = explode($pageRequest, "-"); + $pageReqStart = $tmp[0]; + $pageReqEnd = $tmp[1]; + } + + $sql = " + SELECT + timediff(solutions.dateModified, TIMESTAMP(CURDATE())) as diff, + users.displayName as display, + solutions.moves as moves, + users.ID as ID, + IfNull(userData.displayColor, '#cccccc') as displayColor, + IfNull(userData.wallColor, '#666666') as wallColor, + IfNull(userData.wallEmblem, 'blank.png') as wallEmblem, + solutions.dateModified as cdate + FROM + `users` + JOIN `solutions` + ON users.ID = solutions.userID + LEFT JOIN `userData` + ON users.ID = userData.userID + WHERE solutions.mapID = '$mapid' + ORDER BY solutions.moves DESC, solutions.dateModified ASC + "; + $result = mysql_query($sql); + //$utime = date("g:i A (T)"); + + $output['updateTime'] = date("g:i A (T)"); + + $i = 0; + $foundUser = false; + while ($row = mysql_fetch_assoc($result)) { + $i++; + + $moves = $row['moves']; + $userID = $row['ID']; + if ($i == 1) { + $bestMoves = $moves; + $output['bestMoves'] = $bestMoves; + $output['bestBy'] = $row['display']; + } + + if ($_SESSION['userID'] == $userID) { + $userPosition = $i; + } else { + if ($i > $top) + continue; + if ($i <= $bottom) + continue; + } + + if ($wallEmblem == '') + $wallEmblem = 'blank.png'; + + $cdate = $row['cdate']; + $cdate = date("g:i A (T)", strtotime($cdate)); + + $scoredDate = strtotime($row['cdate']); + $secondsSinceScored = strtotime("now") - $scoredDate ; + + //Alternate background colors + $background = '#262631'; + if ($i % 2 == 1) + $background = '#20202a'; + + if ($userPosition == $i) { + $background = '#343c57'; + $foundUser = true; + } + + $medal = 'none'; + if ($moves == $bestMoves) + $medal = 'silver'; + if ($i == 1) + $medal = 'gold'; + + $output['users'][$i] = $row; + $output['users'][$i]['scoredDate'] = $cdate; + $output['users'][$i]['secondsSinceScored'] = $secondsSinceScored; + $output['users'][$i]['background'] = $background; + $output['users'][$i]['medal'] = $medal; + $output['users'][$i]['isUser'] = $userPosition == $i; + $output['users'][$i]['debug'] = "Bestmoves: $bestMoves moves: $moves"; + } // END WHILE + + if ($foundUser) { + $userPage = ceil(($userPosition / $pageDivide)); + $output['userPage'] = $userPage; + $output['userPosition'] = $userPosition; + } + + $output['pageCount'] = ceil(($i / $pageDivide)); + + if ($prevPage > 0) { + $navi .= " <a href='javascript:scoresShowPage($mapid, 1);'><<</a> "; + $navi .= " <a href='javascript:scoresShowPage($mapid, $prevPage);'><</a> "; + } else { + $navi .= " << "; + $navi .= " <"; + } + for ($x = 1; $x <= $pageCount; $x++) { + if ($x < $pageNumber - 3 OR $x > $pageNumber + 3) + continue; + if ($x == $pageNumber) + $navi .= "<strong> $x </strong>"; + elseif ($userPage == $x) + $navi .= " <a href='javascript:scoresShowPage($mapid, $x)'><i>$x</i></a> "; + else + $navi .= " <a href='javascript:scoresShowPage($mapid, $x)'>$x</a> "; + } + if ($nextPage <= $pageCount) { + $navi .= " <a href='javascript:scoresShowPage($mapid, $nextPage);'>></a> "; + $navi .= " <a href='javascript:scoresShowPage($mapid, $pageCount);'>>></a> "; + } + + return $output; +} + + |