diff --git a/php/top.php b/php/top.php new file mode 100644 index 0000000..1ee463d --- /dev/null +++ b/php/top.php @@ -0,0 +1,175 @@ + + +'Day', 'w'=>'Week', 'm'=>'Month', 'y'=>'Year'); +$timespan = 'd'; +$timeDesc = 'Day'; +if(array_key_exists('t', $_GET)) { + if(array_key_exists(strtolower($_GET['t']), $timespans)) { + $timespan = strtolower($_GET['t']); + $timeDesc = $timespans[$timespan]; + } +} + +if(array_key_exists('page', $_GET)) { + $page = $_GET['page']; +} +if(!isset($page)) { + $page = 1; +} +if($page < 1) { + $page = 1; +} + +$maxResults = 20; + +function replaceTimespanVariable($t) { + $pathInfo = parse_url($_SERVER['REQUEST_URI']); + if(array_key_exists('query', $pathInfo)) { + $queryString = $pathInfo['query']; + } else { + $queryString = ''; + } + parse_str($queryString, $queryArray); + $queryArray['t'] = $t; + if($t == 'd') { + unset($queryArray['t']); + } + $queryArray['page'] = 1; + unset($queryArray['page']); + $queryString = http_build_query($queryArray); + $new = $pathInfo['path']; + if($queryString != ''){ + $new .= '?' . $queryString; + } + return $new; +} + +?> + + + Top Scores for <?php echo $timeDesc; ?> · TriviaTime + + + + + + + + + + + + +
+
+

Top Scores

+

Player rankings.

+
+
+
+ +
+
+
+
+

Top Scores for

+ getWeekTopScores($page, $maxResults); + $resultCount = $storage->getCountWeekTopScores(); + } else if ($timespan == 'm') { + $result = $storage->getMonthTopScores($page, $maxResults); + $resultCount = $storage->getCountMonthTopScores(); + } else if ($timespan == 'y') { + $result = $storage->getYearTopScores($page, $maxResults); + $resultCount = $storage->getCountYearTopScores(); + } else { + $result = $storage->getDayTopScores($page, $maxResults); + $resultCount = $storage->getCountDayTopScores(); + } + } catch(StorageSchemaException $e) { + echo "
Error: Database schema is not queryable
"; + $result = array(); + $result[0] = array('round_num'=>'', 'channel'=>'', 'question'=>'', 'line_num'=>''); + } catch(StorageConnectionException $e) { + echo "
Error: Database is not available
"; + $result = array(); + $result[0] = array('round_num'=>'', 'channel'=>'', 'question'=>'', 'line_num'=>''); + } + $storage->close(); + ?> + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + $currentRank++; + } + ?> + +
#UsernameScore
' . $currentRank . '' . $res['username'] . '' . $res['points'] . '
+ paginate(); + ?> +
+
+ + +
+ + + + + +