summaryrefslogtreecommitdiffstats
path: root/includes
diff options
context:
space:
mode:
Diffstat (limited to 'includes')
-rw-r--r--includes/datas.php136
-rw-r--r--includes/header.php9
2 files changed, 141 insertions, 4 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);'>&lt;&lt;</a> ";
+ $navi .= " <a href='javascript:scoresShowPage($mapid, $prevPage);'>&lt;</a> ";
+ } else {
+ $navi .= " &lt;&lt; ";
+ $navi .= " &lt;";
+ }
+ 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);'>&gt;</a> ";
+ $navi .= " <a href='javascript:scoresShowPage($mapid, $pageCount);'>&gt;&gt;</a> ";
+ }
+
+ return $output;
+}
+
+
diff --git a/includes/header.php b/includes/header.php
index 887aa41..4e19fad 100644
--- a/includes/header.php
+++ b/includes/header.php
@@ -1,6 +1,6 @@
<?php
$accepted = isset($_SESSION['accepted']) && $_SESSION['accepted'] == 1;
-function htmlHeader($css = array(), $title = 'Pathery', $desc = '') {
+function htmlHeader($css = array(), $title = 'Pathery', $desc = '', $scripts = array()) {
global $accepted;
?>
<!DOCTYPE html>
@@ -17,9 +17,12 @@ function htmlHeader($css = array(), $title = 'Pathery', $desc = '') {
}
if ($desc !== '')
echo " <meta name='Description' content='$desc'>";
+
+ foreach ($scripts as $s)
+ echo "<script src='js/$s.js?v=1'></script>";
?>
- <script src="js/ajax.js" async="async"></script>
- <script src="js/mapspecs.js"></script>
+ <script src="js/ajax.js?v=1" async="async"></script>
+ <script src="js/mapspecs.js?v=1"></script>
<script>
(function(d,c){var a,b,g,e;a=d.createElement("script");a.type="text/javascript";a.async=!0;a.src=("https:"===d.location.protocol?"https:":"http:")+'//api.mixpanel.com/site_media/js/api/mixpanel.2.js';b=d.getElementsByTagName("script")[0];b.parentNode.insertBefore(a,b);c._i=[];c.init=function(a,d,f){var b=c;"undefined"!==typeof f?b=c[f]=[]:f="mixpanel";g="disable track track_pageview track_links track_forms register register_once unregister identify name_tag set_config".split(" ");