diff --git a/php/about.php b/php/about.php
index 460e577..0bd0b52 100644
--- a/php/about.php
+++ b/php/about.php
@@ -3,4 +3,4 @@ require_once('includes/autoload.php');
$container->setTitle('About');
$container->setCurrentPage('about.php');
-$container->render('about.php');
+$container->render('about.html.php');
diff --git a/php/includes/autoload.php b/php/includes/autoload.php
index 010063c..8f9aefb 100644
--- a/php/includes/autoload.php
+++ b/php/includes/autoload.php
@@ -3,7 +3,6 @@ include 'config.php';
function autoloadIncludes($class) {
include 'config.php';
- $class = lcfirst($class);
$filename = $class . ".php";
if(file_exists($config['libLocation'] . $filename)) {
require_once($config['libLocation'] . $filename);
diff --git a/php/includes/bootstrap.php b/php/includes/bootstrap.php
deleted file mode 100644
index 4cd2a77..0000000
--- a/php/includes/bootstrap.php
+++ /dev/null
@@ -1,57 +0,0 @@
-config = $config;
- $this->storage = new Storage($this->config['dbLocation']);
- $this->login = new Login($this->storage);
- }
-
- public function render($page, $values=array()) {
- $viewVars = array();
- $viewVars['title'] = $this->title;
- if($this->title != '') {
- $viewVars['title'] .= ' · ';
- }
- $viewVars['currentPage'] = $this->currentPage;
- $container = $this;
- include($this->config['viewLocation'] . 'header.php');
- include($this->config['viewLocation'] . $page);
- include($this->config['viewLocation'] . 'footer.php');
- }
-
- public function setTitle($title) {
- $this->title = $title;
- }
-
- public function setCurrentPage($currentPage) {
- $this->currentPage = $currentPage;
- }
-
- public function getTitle() {
- return $this->title;
- }
-
- public function getCurrentPage() {
- return $this->currentPage;
- }
-
- public function getLogin() {
- return $this->login;
- }
-
- public function getStorage() {
- return $this->storage;
- }
-
- public function getConfig() {
- return $this->config;
- }
-}
diff --git a/php/includes/login.php b/php/includes/login.php
deleted file mode 100644
index d1099bd..0000000
--- a/php/includes/login.php
+++ /dev/null
@@ -1,107 +0,0 @@
-storage=$storage;
- $this->startSession();
- $this->checkLoggedIn();
- }
-
- protected function startSession() {
- session_start();
- }
-
- protected function endSession() {
- session_destroy();
- }
-
- protected function checkSessionLoggedIn() {
- if(!isset($_SESSION['username']) || !isset($_SESSION['loggedIn']) || !isset($_SESSION['capability'])) {
- return false;
- }
- if(!empty($_SESSION['username']) && $_SESSION['loggedIn']) {
- return true;
- }
- return false;
- }
-
- protected function checkLoggedIn() {
- $this->loggedIn = $this->checkSessionLoggedIn();
-
- if($this->isLoggedIn()) {
- $this->createUser($_SESSION['username'], $_SESSION['capability']);
- }
- }
-
- protected function hashPassword($salt, $password) {
- return sha1($salt . $password);
- }
-
- protected function createUser($username, $capabilities) {
- $this->user = new User($username, $capabilities);
- }
-
- protected function ircToLower($str) {
- $ircLowerSymbols = array("\\"=>"|", "["=>"{", "]"=>"}", "~"=>"^");
- $str = strtr($str, $ircLowerSymbols);
- $str = strtolower($str);
- return $str;
- }
-
- public function isLoggedIn() {
- return $this->loggedIn;
- }
-
- public function getUser() {
- return $this->user;
- }
-
- public function login($username, $password) {
- if($this->isLoggedIn()) {
- return true;
- }
-
- $usernameCanonical = $this->ircToLower($username);
-
- // Storage get salt, hashedPassword, capabilities for user
- $results = $this->storage->getLoginByUsernameCanonical($usernameCanonical);
-
- if(count($results) < 1) {
- return false;
- }
-
- $result = $results[0];
-
- $username = $result['username'];
- $salt = $result['salt'];
- $targetPassword = $result['password'];
- $capability = $result['capability'];
- $isHashed = $result['is_hashed'];
-
- $hashPassword = $password;
- if($isHashed) {
- $hashPassword = $this->hashPassword($salt, $password);
- }
-
- if($targetPassword == $hashPassword) {
- $_SESSION['username'] = $username;
- $_SESSION['loggedIn'] = true;
- $_SESSION['capability'] = $capability;
- $this->loggedIn = true;
- $this->createUser($username, $capability);
- return true;
- }
- return false;
- }
-
- public function logout() {
- $_SESSION = array();
- $this->endSession();
- $this->loggedIn = false;
- $this->user = null;
- }
-}
diff --git a/php/includes/paginator.php b/php/includes/paginator.php
deleted file mode 100644
index 2b55aea..0000000
--- a/php/includes/paginator.php
+++ /dev/null
@@ -1,156 +0,0 @@
-currentPage = $currentPage;
- $this->totalResults = $totalResults;
- if(!is_null($key)) {
- $this->key = $key;
- }
- if(!is_null($resultsPerPage)) {
- $this->resultsPerPage = $resultsPerPage;
- }
- if(!is_null($target)) {
- $this->target = $target;
- } else {
- $this->target = $this->getCurrentURI();
- }
- }
-
- protected function getCurrentURI() {
- return $_SERVER['REQUEST_URI'];
- }
-
- protected function replacePageVariable($uri, $pageNumber) {
- $pathInfo = parse_url($uri);
- if(array_key_exists('query', $pathInfo)) {
- $queryString = $pathInfo['query'];
- } else {
- $queryString = '';
- }
- parse_str($queryString, $queryArray);
- $queryArray[$this->key] = $pageNumber;
- if($pageNumber == 1) {
- unset($queryArray[$this->key]);
- }
- $queryString = http_build_query($queryArray);
- $new = $pathInfo['path'];
- if($queryString != ''){
- $new .= '?' . $queryString;
- }
- return $new;
- }
-
- protected function getMaxPages() {
- if($this->totalResults==0) {
- return 1;
- }
- $max = intval($this->totalResults / $this->resultsPerPage);
- if($this->totalResults % $this->resultsPerPage > 0) {
- $max++;
- }
- return intval($max);
- }
-
- public function paginate() {
- echo '
';
- }
-}
diff --git a/php/includes/storage.php b/php/includes/storage.php
deleted file mode 100644
index e004e22..0000000
--- a/php/includes/storage.php
+++ /dev/null
@@ -1,492 +0,0 @@
-dbLocation = $dbLocation;
- $this->dbType = $dbType;
- $this->connect();
- }
-
- public function connect() {
- if(is_null($this->db)) {
- try {
- $this->db = new PDO($this->dbType . $this->dbLocation);
- if(!$this->db) {
- $this->db = null;
- throw new StorageConnectionException();
- }
- } catch (Exception $e) {
- $this->db = null;
- }
- }
- }
-
- public function close() {
- $this->db = null;
- }
-
- protected function ircToLower($str) {
- $ircLowerSymbols = array("\\"=>"|", "["=>"{", "]"=>"}", "~"=>"^");
- $str = strtr($str, $ircLowerSymbols);
- $str = strtolower($str);
- return $str;
- }
-
- public function getLoginByUsernameCanonical($usernameCanonical) {
- if(!$this->isConnected()) {
- throw new StorageConnectionException();
- }
- $q = $this->db->prepare('SELECT *
- FROM trivialogin
- WHERE username_canonical=:username
- LIMIT 1');
- if ($q === false) {
- throw new StorageSchemaException();
- }
- $q->execute(array(':username'=>$usernameCanonical));
- $result = $q->fetchAll();
- return $result;
- }
-
- public function getTimeSinceLastPlayed($usernameCanonical) {
- if(!$this->isConnected()) {
- throw new StorageConnectionException();
- }
- $q = $this->db->prepare('SELECT last_updated
- FROM triviauserlog
- WHERE username_canonical=:username
- ORDER BY last_updated DESC
- LIMIT 1');
- if ($q === false) {
- throw new StorageSchemaException();
- }
- $q->execute(array(':username'=>$usernameCanonical));
- $result = $q->fetchAll();
- return $result;
- }
-
- public function getTopDeletions($page, $max) {
- if(!$this->isConnected()) {
- throw new StorageConnectionException();
- }
- if($page < 1) {
- $page = 1;
- }
- if($max < 1) {
- $max = 1;
- }
- $q = $this->db->prepare('SELECT td.*, tq.question as question
- FROM triviadelete td
- INNER JOIN triviaquestion tq
- ON tq.id=td.line_num
- ORDER BY id DESC LIMIT :offset, :maxResults');
- if ($q === false) {
- throw new StorageSchemaException();
- }
- $q->execute(array(':offset'=>($page-1) * $max, ':maxResults'=>$max));
- $result = $q->fetchAll();
- return $result;
- }
-
- public function getCountDeletions() {
- if(!$this->isConnected()) {
- throw new StorageConnectionException();
- }
- $q = $this->db->query('SELECT count(id) FROM triviadelete');
- if ($q === false) {
- throw new StorageSchemaException();
- }
- $result = $q->fetchColumn();
- return $result;
- }
-
- public function getTopReports($page, $max) {
- if(!$this->isConnected()) {
- throw new StorageConnectionException();
- }
- if($page < 1) {
- $page = 1;
- }
- if($max < 1) {
- $max = 1;
- }
- $q = $this->db->prepare('SELECT tr.*, tq.question as original
- FROM triviareport tr
- INNER JOIN triviaquestion tq
- ON tq.id=question_num
- ORDER BY id DESC LIMIT :offset, :maxResults');
- if ($q === false) {
- throw new StorageSchemaException();
- }
- $q->execute(array(':offset'=>($page-1) * $max, ':maxResults'=>$max));
- $result = $q->fetchAll();
- return $result;
- }
-
- public function getCountReports() {
- if(!$this->isConnected()) {
- throw new StorageConnectionException();
- }
- $q = $this->db->query('SELECT count(id) FROM triviareport');
- if ($q === false) {
- throw new StorageSchemaException();
- }
- $result = $q->fetchColumn();
- return $result;
- }
-
- public function getTopNewQuestions($page, $max) {
- if(!$this->isConnected()) {
- throw new StorageConnectionException();
- }
- if($page < 1) {
- $page = 1;
- }
- if($max < 1) {
- $max = 1;
- }
- $q = $this->db->prepare('SELECT tq.* FROM triviatemporaryquestion tq ORDER BY tq.id DESC LIMIT :offset, :maxResults');
- if ($q === false) {
- throw new StorageSchemaException();
- }
- $q->execute(array(':offset'=>($page-1) * $max, ':maxResults'=>$max));
- $result = $q->fetchAll();
- return $result;
- }
-
- public function getCountNewQuestions() {
- if(!$this->isConnected()) {
- throw new StorageConnectionException();
- }
- $q = $this->db->query('SELECT count(id) FROM triviatemporaryquestion');
- if ($q === false) {
- throw new StorageSchemaException();
- }
- $result = $q->fetchColumn();
- return $result;
- }
-
- public function getTopEdits($page, $max) {
- if(!$this->isConnected()) {
- throw new StorageConnectionException();
- }
- if($page < 1) {
- $page = 1;
- }
- if($max < 1) {
- $max = 1;
- }
- $q = $this->db->prepare('SELECT te.*, tq.question as original
- FROM triviaedit te
- INNER JOIN triviaquestion tq
- ON tq.id=question_id
- ORDER BY id DESC LIMIT :offset, :maxResults');
- if ($q === false) {
- throw new StorageSchemaException();
- }
- $q->execute(array(':offset'=>($page-1) * $max, ':maxResults'=>$max));
- $result = $q->fetchAll();
- return $result;
- }
-
- public function getCountEdits() {
- if(!$this->isConnected()) {
- throw new StorageConnectionException();
- }
- $q = $this->db->query('SELECT count(id) FROM triviaedit');
- if ($q === false) {
- throw new StorageSchemaException();
- }
- $result = $q->fetchColumn();
- return $result;
- }
-
- public function getDayTopScores($page=1, $max=10) {
- if(!$this->isConnected()) {
- throw new StorageConnectionException();
- }
- if($page < 1) {
- $page = 1;
- }
- if($max < 1) {
- $max = 1;
- }
- $day = date('j');
- $month = date('m');
- $year = date('Y');
- $q = $this->db->prepare("SELECT username,
- sum(points_made) as points
- FROM triviauserlog
- WHERE day=:day
- AND year=:year
- AND month=:month
- GROUP BY username_canonical
- ORDER BY points DESC
- LIMIT :offset, :maxResults");
- if ($q === false) {
- throw new StorageSchemaException();
- }
- $q->execute(array(':offset'=>($page-1) * $max, ':maxResults'=>$max, ':day'=>$day, ':year'=>$year, ':month'=>$month));
- $result = $q->fetchAll();
- return $result;
- }
-
- public function getCountDayTopScores() {
- if(!$this->isConnected()) {
- throw new StorageConnectionException();
- }
- $day = date('j');
- $month = date('m');
- $year = date('Y');
- $q = $this->db->prepare('SELECT count(distinct(username_canonical))
- FROM triviauserlog
- WHERE day=:day
- AND year=:year
- AND month=:month');
- if ($q === false) {
- throw new StorageSchemaException();
- }
- $q->execute(array(':day'=>$day, ':year'=>$year, ':month'=>$month));
- $result = $q->fetchColumn();
- return $result;
- }
-
- protected function generateWeekSqlClause() {
- $sqlClause = '';
- $day = date('N')-1;
- $week = new DateTime();
- $interval = new DateInterval('P'.$day.'D');
- $week->sub($interval);
- $interval = new DateInterval('P1D');
- for($i=0;$i<7;$i++) {
- if($i>0) {
- $sqlClause .= ' or ';
- }
- $sqlClause .= '(day=' . $week->format('j') .
- ' and month=' . $week->format('n') .
- ' and year=' . $week->format('Y') .
- ')';
- $week->add($interval);
- }
- return $sqlClause;
- }
-
- public function getWeekTopScores($page=1, $max=10) {
- if(!$this->isConnected()) {
- throw new StorageConnectionException();
- }
- if($page < 1) {
- $page = 1;
- }
- if($max < 1) {
- $max = 1;
- }
- $sqlClause = $this->generateWeekSqlClause();
- $q = $this->db->prepare("SELECT username, sum(points_made) as points FROM triviauserlog WHERE $sqlClause GROUP BY username_canonical ORDER BY points DESC LIMIT :offset, :maxResults");
- if ($q === false) {
- throw new StorageSchemaException();
- }
- $q->execute(array(':offset'=>($page-1) * $max, ':maxResults'=>$max));
- $result = $q->fetchAll();
- return $result;
- }
-
- public function getCountWeekTopScores() {
- if(!$this->isConnected()) {
- throw new StorageConnectionException();
- }
- $sqlClause = $this->generateWeekSqlClause();
- $q = $this->db->query('SELECT count(distinct(username_canonical))
- FROM triviauserlog
- WHERE $sqlClause');
- if ($q === false) {
- throw new StorageSchemaException();
- }
- $result = $q->fetchColumn();
- return $result;
- }
-
- public function getMonthTopScores($page=1, $max=10) {
- if(!$this->isConnected()) {
- throw new StorageConnectionException();
- }
- if($page < 1) {
- $page = 1;
- }
- if($max < 1) {
- $max = 1;
- }
- $month = date('m');
- $year = date('Y');
- $q = $this->db->prepare("SELECT username, sum(points_made) as points FROM triviauserlog WHERE year=:year AND month=:month GROUP BY username_canonical ORDER BY points DESC LIMIT :offset, :maxResults");
- if ($q === false) {
- throw new StorageSchemaException();
- }
- $q->execute(array(':offset'=>($page-1) * $max, ':maxResults'=>$max, ':year'=>$year, ':month'=>$month));
- $result = $q->fetchAll();
- return $result;
- }
-
- public function getCountMonthTopScores() {
- if(!$this->isConnected()) {
- throw new StorageConnectionException();
- }
- $month = date('m');
- $year = date('Y');
- $q = $this->db->prepare('SELECT count(distinct(username_canonical))
- FROM triviauserlog
- WHERE year=:year
- AND month=:month');
- if ($q === false) {
- throw new StorageSchemaException();
- }
- $q->execute(array(':year'=>$year, ':month'=>$month));
- $result = $q->fetchColumn();
- return $result;
- }
-
- public function getYearTopScores($page=1, $max=10) {
- if(!$this->isConnected()) {
- throw new StorageConnectionException();
- }
- if($page < 1) {
- $page = 1;
- }
- if($max < 1) {
- $max = 1;
- }
- $year = date('Y');
- $q = $this->db->prepare("SELECT username, sum(points_made) as points FROM triviauserlog WHERE year=:year GROUP BY username_canonical ORDER BY points DESC LIMIT :offset, :maxResults");
- if ($q === false) {
- throw new StorageSchemaException();
- }
- $q->execute(array(':offset'=>($page-1) * $max, ':maxResults'=>$max, ':year'=>$year));
- $result = $q->fetchAll();
- return $result;
- }
-
- public function getCountYearTopScores() {
- if(!$this->isConnected()) {
- throw new StorageConnectionException();
- }
- $year = date('Y');
- $q = $this->db->prepare('SELECT count(distinct(username_canonical))
- FROM triviauserlog
- WHERE year=:year');
- if ($q === false) {
- throw new StorageSchemaException();
- }
- $q->execute(array(':year'=>$year));
- $result = $q->fetchColumn();
- return $result;
- }
-
- public function getUserLikeUsernameCanonical($usernameCanonical, $page, $max) {
- if(!$this->isConnected()) {
- throw new StorageConnectionException();
- }
- if($page < 1) {
- $page = 1;
- }
- if($max < 1) {
- $max = 1;
- }
- $q = $this->db->prepare('select
- tl.username,
- sum(tl.points_made) as points,
- sum(tl.num_answered) as total
- from triviauserlog tl
- where tl.username_canonical like :username
- group by tl.username_canonical
- limit :offset, :maxResults
- ');
- if ($q === false) {
- throw new StorageSchemaException();
- }
- $likeString = '%'.$this->escapeLikeQuery($usernameCanonical).'%';
- $q->execute(array(':offset'=>($page-1) * $max, ':maxResults'=>$max, ':username'=>$likeString));
- $result = $q->fetchAll();
- return $result;
- }
-
- public function getCountUserLikeUsernameCanonical($usernameCanonical) {
- if(!$this->isConnected()) {
- throw new StorageConnectionException();
- }
- $q = $this->db->prepare('select
- count(distinct(tl.username_canonical))
- from triviauserlog tl
- where tl.username_canonical like :username
- ');
- if ($q === false) {
- throw new StorageSchemaException();
- }
- $likeString = '%'.$this->escapeLikeQuery($usernameCanonical).'%';
- $q->execute(array(':username'=>$likeString));
- $result = $q->fetchColumn();
- return $result;
- }
-
- public function getRecentAskedQuestions() {
- if(!$this->isConnected()) {
- throw new StorageConnectionException();
- }
- $q = $this->db->query('SELECT asked_at, channel, round_num, question, line_num FROM triviagameslog ORDER BY id DESC LIMIT 10');
- if ($q === false) {
- throw new StorageSchemaException();
- }
- $result = $q->fetchAll();
- return $result;
- }
-
- public function getUserProfileInformation($usernameCanonical) {
- if(!$this->isConnected()) {
- throw new StorageConnectionException();
- }
- $q = $this->db->prepare('select
- tl.username as usrname,
- sum(tl2.t * (tl2.n / (select sum(num_answered) from triviauserlog where username_canonical=:username))) as count,
- sum(tl2.p * (tl2.n / (select sum(num_answered) from triviauserlog where username_canonical=:username))) as score,
- (select sum(points_made) from triviauserlog t3 where username_canonical=:username) as points,
- (select sum(num_answered) from triviauserlog t4 where username_canonical=:username) as q_asked,
- (select num_editted from triviausers where username_canonical=:username) as num_e,
- (select num_editted_accepted from triviausers where username_canonical=:username) as num_e_accepted,
- (select num_questions_added from triviausers where username_canonical=:username) as num_q,
- (select num_questions_accepted from triviausers where username_canonical=:username) as num_q_accepted,
- (select num_reported from triviausers where username_canonical=:username) as num_r,
- (select highest_streak from triviausers where username_canonical=:username) as highest_streak
- from (select tl3.id as id2, tl3.average_time * 1.0 as t, tl3.average_score * 1.0 as p, tl3.num_answered * 1.0 as n from triviauserlog tl3) tl2
- inner join triviauserlog tl
- on tl.username_canonical=:username
- and tl.id=tl2.id2
- limit 1');
- if ($q === false) {
- throw new StorageSchemaException();
- }
- $q->execute(array(':username'=>$usernameCanonical));
- $result = $q->fetchAll();
- return $result;
- }
-
- public function isConnected() {
- if(is_null($this->db)) {
- return false;
- }
- return true;
- }
-
- protected function escapeLikeQuery($s) {
- $translations = array("%"=>"\\%", "_"=>"\\_");
- return strtr($s, $translations);
- }
-}
-
-class StorageException extends Exception { }
-
-class StorageSchemaException extends StorageException { }
-
-class StorageConnectionException extends StorageException { }
diff --git a/php/includes/user.php b/php/includes/user.php
deleted file mode 100644
index 1418615..0000000
--- a/php/includes/user.php
+++ /dev/null
@@ -1,19 +0,0 @@
-username = $username;
- $this->capabilty = $capabilty;
- }
-
- public function getUsername() {
- return $this->username;
- }
-
- public function getCapability() {
- return $this->capabilty;
- }
-}
diff --git a/php/index.php b/php/index.php
index 4db99de..4e0d991 100644
--- a/php/index.php
+++ b/php/index.php
@@ -21,4 +21,4 @@ $values['errors'] = $errors;
$container->setTitle('Home');
$container->setCurrentPage('index.php');
-$container->render('home.php', $values);
+$container->render('home.html.php', $values);
diff --git a/php/profile.php b/php/profile.php
index 639e420..39b65e9 100644
--- a/php/profile.php
+++ b/php/profile.php
@@ -120,4 +120,4 @@ $values['lastSeen'] = $lastSeen;
$container->setTitle($username);
$container->setCurrentPage('profile.php');
-$container->render('profile.php', $values);
+$container->render('profile.html.php', $values);
diff --git a/php/reports.php b/php/reports.php
index f4e92b3..8368af8 100644
--- a/php/reports.php
+++ b/php/reports.php
@@ -1,7 +1,100 @@
getStorage();
+
+function getPageVariable($name) {
+ if(array_key_exists($name, $_GET)) {
+ $page = $_GET[$name];
+ }
+ if(!isset($page)) {
+ $page = 1;
+ }
+ if($page < 1) {
+ $page = 1;
+ }
+ return $page;
+}
+
+$reportPage = getPageVariable('rp');
+$editPage = getPageVariable('ep');
+$newPage = getPageVariable('np');
+$deletePage = getPageVariable('dp');
+
+$maxResults = 5;
+
+$reportResultCount = 0;
+$reportResult = array();
+$reportErrors = array();
+try {
+ $reportResult = $storage->getTopReports($reportPage, $maxResults);
+ $reportResultCount = $storage->getCountReports();
+} catch(StorageSchemaException $e) {
+ $reportErrors[] = "Error: Database schema is not queryable";
+} catch(StorageConnectionException $e) {
+ $reportErrors[] = "Error: Database is not available";
+}
+
+$editResultCount = 0;
+$editResult = array();
+$editErrors = array();
+try {
+ $editResult = $storage->getTopEdits($editPage, $maxResults);
+ $editResultCount = $storage->getCountEdits();
+} catch(StorageSchemaException $e) {
+ $editErrors[] = "Error: Database schema is not queryable";
+} catch(StorageConnectionException $e) {
+ $editErrors[] = "Error: Database is not available";
+}
+
+$newResultCount = 0;
+$newResult = array();
+$newErrors = array();
+try {
+ $newResult = $storage->getTopNewQuestions($newPage, $maxResults);
+ $newResultCount = $storage->getCountNewQuestions();
+} catch(StorageSchemaException $e) {
+ $newErrors[] = "Error: Database schema is not queryable";
+} catch(StorageConnectionException $e) {
+ $newErrors[] = "Error: Database is not available";
+}
+
+$deleteResultCount = 0;
+$deleteResult = array();
+$deleteErrors = array();
+try {
+ $deleteResult = $storage->getTopDeletions($deletePage, $maxResults);
+ $deleteResultCount = $storage->getCountDeletions();
+} catch(StorageSchemaException $e) {
+ $deleteErrors[] = "Error: Database schema is not queryable";
+} catch(StorageConnectionException $e) {
+ $deleteErrors[] = "Error: Database is not available";
+}
+
+$values = array();
+$values['maxResults'] = $maxResults;
+
+$values['reportResultCount'] = $reportResultCount;
+$values['reportResult'] = $reportResult;
+$values['reportErrors'] = $reportErrors;
+$values['reportPage'] = $reportPage;
+
+$values['editResultCount'] = $editResultCount;
+$values['editResult'] = $editResult;
+$values['editErrors'] = $editErrors;
+$values['editPage'] = $editPage;
+
+$values['newResultCount'] = $newResultCount;
+$values['newResult'] = $newResult;
+$values['newErrors'] = $newErrors;
+$values['newPage'] = $newPage;
+
+$values['deleteResultCount'] = $deleteResultCount;
+$values['deleteResult'] = $deleteResult;
+$values['deleteErrors'] = $deleteErrors;
+$values['deletePage'] = $deletePage;
+
$container->setTitle('Reports');
$container->setCurrentPage('reports.php');
-$container->render('reports.php');
+$container->render('reports.html.php', $values);
diff --git a/php/stats.php b/php/stats.php
index 1d0ba09..e20f043 100644
--- a/php/stats.php
+++ b/php/stats.php
@@ -1,7 +1,59 @@
getStorage();
+
+$dayResult = array();
+$dayErrors = array();
+try {
+ $dayResult = $storage->getDayTopScores(1, 10);
+} catch(StorageSchemaException $e) {
+ $dayErrors[] = "Error: Database schema is not queryable";
+} catch(StorageConnectionException $e) {
+ $dayErrors[] = "Error: Database is not available";
+}
+
+$weekResult = array();
+$weekErrors = array();
+try {
+ $weekResult = $storage->getWeekTopScores(1, 10);
+} catch(StorageSchemaException $e) {
+ $weekErrors[] = "Error: Database schema is not queryable";
+} catch(StorageConnectionException $e) {
+ $weekErrors[] = "Error: Database is not available";
+}
+
+$monthResult = array();
+$monthErrors = array();
+try {
+ $monthResult = $storage->getMonthTopScores(1, 10);
+} catch(StorageSchemaException $e) {
+ $monthErrors[] = "Error: Database schema is not queryable";
+} catch(StorageConnectionException $e) {
+ $monthErrors[] = "Error: Database is not available";
+}
+
+$yearResult = array();
+$yearErrors = array();
+try {
+ $yearResult = $storage->getYearTopScores(1, 10);
+} catch(StorageSchemaException $e) {
+ $yearErrors[] = "Error: Database schema is not queryable";
+} catch(StorageConnectionException $e) {
+ $yearErrors[] = "Error: Database is not available";
+}
+
+$values = array();
+$values['dayResult'] = $dayResult;
+$values['dayErrors'] = $dayErrors;
+$values['weekResult'] = $weekResult;
+$values['weekErrors'] = $weekErrors;
+$values['monthResult'] = $monthResult;
+$values['monthErrors'] = $monthErrors;
+$values['yearResult'] = $yearResult;
+$values['yearErrors'] = $yearErrors;
+
$container->setTitle('Stats');
$container->setCurrentPage('stats.php');
-$container->render('stats.php');
+$container->render('stats.html.php', $values);
diff --git a/php/top.php b/php/top.php
index 4371d47..7af024b 100644
--- a/php/top.php
+++ b/php/top.php
@@ -60,4 +60,4 @@ $values['errors'] = $errors;
$container->setTitle('Top Scores for ' . $timeDesc);
$container->setCurrentPage('top.php');
-$container->render('top.php', $values);
+$container->render('top.html.php', $values);
diff --git a/php/user.php b/php/user.php
index a43f521..bf508a5 100644
--- a/php/user.php
+++ b/php/user.php
@@ -57,4 +57,4 @@ $values['errors'] = $errors;
$container->setTitle('Players');
$container->setCurrentPage('user.php');
-$container->render('user.php', $values);
+$container->render('user.html.php', $values);
diff --git a/php/views/about.php b/php/views/about.php
deleted file mode 100644
index fdec93b..0000000
--- a/php/views/about.php
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
About TriviaTime
-
We are #trivialand on Freenode. Come join us!
-
-
-
-
About
-
TriviaTime is a feature-packed trivia plugin developed by the Trivialand channel on Freenode, written in Python for Supybot with a built-in website generator. Be the first to answer the question to score points. On KAOS, it's a team effort to get all the answers before the time runs out. As you play you'll earn badges and level up.
-
-
-
-
-
Source
-
The source code is available on GitHub, be sure to check it out.
- Fork us and contribute!
-
-
diff --git a/php/views/footer.php b/php/views/footer.php
deleted file mode 100644
index 6846021..0000000
--- a/php/views/footer.php
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-