diff --git a/php/about.php b/php/about.php
index 21d192c..c27ad21 100644
--- a/php/about.php
+++ b/php/about.php
@@ -90,7 +90,7 @@
diff --git a/php/contact.php b/php/contact.php
index 0a5dc26..052bab5 100644
--- a/php/contact.php
+++ b/php/contact.php
@@ -89,7 +89,7 @@
diff --git a/php/index.php b/php/index.php
index b6d7f8c..85ba02c 100644
--- a/php/index.php
+++ b/php/index.php
@@ -126,7 +126,7 @@
diff --git a/php/reports.php b/php/reports.php
index 30866e8..5d2c1cc 100644
--- a/php/reports.php
+++ b/php/reports.php
@@ -89,7 +89,7 @@
-
+
Reports
@@ -100,30 +100,31 @@
-query('SELECT * FROM triviareport LIMIT 10');
- if ($q === false) {
- die("Error: database error: table does not exist\n");
- } else {
- $result = $q->fetchAll();
- foreach($result as $res) {
- echo '';
- echo '| ' . $res['id'] . ' | ';
- echo '' . $res['username'] . ' | ';
- echo '' . $res['report_text'] . ' | ';
- echo '
';
- }
- }
- } else {
- die('Couldnt connect to db');
- }
-?>
+ query('SELECT * FROM triviareport LIMIT 10');
+ if ($q === false) {
+ die("Error: database error: table does not exist\n");
+ } else {
+ $result = $q->fetchAll();
+ foreach($result as $res) {
+ echo '';
+ echo '| ' . $res['id'] . ' | ';
+ echo '' . $res['username'] . ' | ';
+ echo '' . $res['report_text'] . ' | ';
+ echo '
';
+ }
+ }
+ } else {
+ die('Couldnt connect to db');
+ }
+ ?>
-
-
+
+
+
Edits
@@ -131,30 +132,32 @@
| Edit # |
Username |
New Question |
+ Old Question |
Question # |
-query('SELECT * FROM triviaedit ORDER BY id DESC LIMIT 10');
- if ($q === false) {
- die("Error: database error: table does not exist\n");
- } else {
- $result = $q->fetchAll();
- foreach($result as $res) {
- echo '';
- echo '| ' . $res['id'] . ' | ';
- echo '' . $res['username'] . ' | ';
- echo '' . $res['question'] . ' | ';
- echo '' . $res['question_id'] . ' | ';
- echo '
';
- }
- }
- } else {
- die($err);
- }
-?>
+ query('SELECT *, tq.question as original FROM triviaedit INNER JOIN triviaquestion tq on tq.id=question_id ORDER BY id DESC LIMIT 10');
+ if ($q === false) {
+ die("Error: database error: table does not exist\n");
+ } else {
+ $result = $q->fetchAll();
+ foreach($result as $res) {
+ echo '';
+ echo '| ' . $res['id'] . ' | ';
+ echo '' . $res['username'] . ' | ';
+ echo '' . $res['question'] . ' | ';
+ echo '' . $res['original'] . ' | ';
+ echo '' . $res['question_id'] . ' | ';
+ echo '
';
+ }
+ }
+ } else {
+ die($err);
+ }
+ ?>
@@ -162,7 +165,7 @@
diff --git a/php/stats.php b/php/stats.php
index 6dec59b..cc92342 100644
--- a/php/stats.php
+++ b/php/stats.php
@@ -91,7 +91,7 @@
-
Top10 of ALL TIME
+
All Time Top Scores
@@ -101,32 +101,32 @@
-query('SELECT username, sum(points_made) as points FROM triviauserlog GROUP BY username ORDER BY points DESC LIMIT 10');
- if ($q === false) {
- die("Error: database error: table does not exist\n");
- } else {
- $result = $q->fetchAll();
+ query('SELECT username, sum(points_made) as points FROM triviauserlog GROUP BY username ORDER BY points DESC LIMIT 10');
+ if ($q === false) {
+ die("Error: database error: table does not exist\n");
+ } else {
+ $result = $q->fetchAll();
- foreach($result as $key=>$res) {
+ foreach($result as $key=>$res) {
- echo '';
- echo '| ' . ($key+1) . ' | ';
- echo '' . $res['username'] . ' | ';
- echo '' . $res['points'] . ' | ';
- echo '
';
- }
- }
- } else {
- die($err);
- }
-?>
+ echo '';
+ echo '| ' . ($key+1) . ' | ';
+ echo '' . $res['username'] . ' | ';
+ echo '' . $res['points'] . ' | ';
+ echo '
';
+ }
+ }
+ } else {
+ die($err);
+ }
+ ?>
-
Todays TOP10
+
Todays Top Scores
@@ -136,37 +136,168 @@
-prepare("SELECT username, sum(points_made) as points FROM triviauserlog WHERE day=:day AND year=:year AND month=:month GROUP BY username ORDER BY points DESC LIMIT 10");
- $q->execute(array(':day'=>$day, 'year'=>$year, 'month'=>$month));
- if ($q === false) {
- die("Error: database error: table does not exist\n");
- } else {
- $result = $q->fetchAll();
- foreach($result as $key=>$res) {
- echo '';
- echo '| ' . ($key+1) . ' | ';
- echo '' . $res['username'] . ' | ';
- echo '' . $res['points'] . ' | ';
- echo '
';
- }
- }
- } else {
- die($err);
- }
-?>
+ if ($db) {
+ $q = $db->prepare("SELECT username, sum(points_made) as points FROM triviauserlog WHERE day=:day AND year=:year AND month=:month GROUP BY username ORDER BY points DESC LIMIT 10");
+ $q->execute(array(':day'=>$day, 'year'=>$year, 'month'=>$month));
+ if ($q === false) {
+ die("Error: database error: table does not exist\n");
+ } else {
+ $result = $q->fetchAll();
+ foreach($result as $key=>$res) {
+ echo '';
+ echo '| ' . ($key+1) . ' | ';
+ echo '' . $res['username'] . ' | ';
+ echo '' . $res['points'] . ' | ';
+ echo '
';
+ }
+ }
+ } else {
+ die($err);
+ }
+ ?>
+
+
+
Month Top Scores
+
+
+
+ | # |
+ Username |
+ Points |
+
+
+
+ prepare("SELECT username, sum(points_made) as points FROM triviauserlog WHERE year=:year AND month=:month GROUP BY username ORDER BY points DESC LIMIT 10");
+ $q->execute(array('year'=>$year, 'month'=>$month));
+ if ($q === false) {
+ die("Error: database error: table does not exist\n");
+ } else {
+ $result = $q->fetchAll();
+ foreach($result as $key=>$res) {
+ echo '';
+ echo '| ' . ($key+1) . ' | ';
+ echo '' . $res['username'] . ' | ';
+ echo '' . $res['points'] . ' | ';
+ echo '
';
+ }
+ }
+ } else {
+ die($err);
+ }
+ ?>
+
+
+
+
+
Year Top Scores
+
+
+
+ | # |
+ Username |
+ Points |
+
+
+
+ prepare("SELECT username, sum(points_made) as points FROM triviauserlog WHERE year=:year GROUP BY username ORDER BY points DESC LIMIT 10");
+ $q->execute(array('year'=>$year));
+ if ($q === false) {
+ die("Error: database error: table does not exist\n");
+ } else {
+ $result = $q->fetchAll();
+ foreach($result as $key=>$res) {
+ echo '';
+ echo '| ' . ($key+1) . ' | ';
+ echo '' . $res['username'] . ' | ';
+ echo '' . $res['points'] . ' | ';
+ echo '
';
+ }
+ }
+ } else {
+ die($err);
+ }
+ ?>
+
+
+
+
+
+ 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);
+ }
+ ?>
+
+
Week Top Scores
+
+
+
+ | # |
+ Username |
+ Points |
+
+
+
+query("SELECT username, sum(points_made) as points FROM triviauserlog WHERE $sqlClause GROUP BY username ORDER BY points DESC LIMIT 10");
+ if ($q === false) {
+ die("Error: database error: table does not exist\n");
+ } else {
+ $result = $q->fetchAll();
+ foreach($result as $key=>$res) {
+ echo '';
+ echo '| ' . ($key+1) . ' | ';
+ echo '' . $res['username'] . ' | ';
+ echo '' . $res['points'] . ' | ';
+ echo '
';
+ }
+ }
+ } else {
+ die($err);
+ }
+?>
+
+
+
+
+
diff --git a/storage/samplequestions b/storage/samplequestions
new file mode 100644
index 0000000..9add35a
--- /dev/null
+++ b/storage/samplequestions
@@ -0,0 +1,4 @@
+foo*bar
+Hello*world
+Answer to everything*42
+Lorem*Ipsum
diff --git a/storage/samplequestions~ b/storage/samplequestions~
new file mode 100644
index 0000000..e69de29