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 ''; - echo ''; - echo ''; - 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 ''; + echo ''; + echo ''; + echo ''; + } + } + } else { + die('Couldnt connect to db'); + } + ?>
' . $res['id'] . '' . $res['username'] . '' . $res['report_text'] . '
' . $res['id'] . '' . $res['username'] . '' . $res['report_text'] . '
- -
+
+
+

Edits

@@ -131,30 +132,32 @@ + -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 ''; - echo ''; - echo ''; - echo ''; - 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 ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + } + } else { + die($err); + } + ?>
Edit # Username New QuestionOld Question Question #
' . $res['id'] . '' . $res['username'] . '' . $res['question'] . '' . $res['question_id'] . '
' . $res['id'] . '' . $res['username'] . '' . $res['question'] . '' . $res['original'] . '' . $res['question_id'] . '
@@ -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 ''; - echo ''; - echo ''; - echo ''; - } - } - } else { - die($err); - } -?> + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + } + } else { + die($err); + } + ?>
' . ($key+1) . '' . $res['username'] . '' . $res['points'] . '
' . ($key+1) . '' . $res['username'] . '' . $res['points'] . '
-

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 ''; - echo ''; - echo ''; - 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 ''; + echo ''; + echo ''; + echo ''; + } + } + } else { + die($err); + } + ?>
' . ($key+1) . '' . $res['username'] . '' . $res['points'] . '
' . ($key+1) . '' . $res['username'] . '' . $res['points'] . '
+
+
+

Month Top Scores

+ + + + + + + + + + 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 ''; + echo ''; + echo ''; + echo ''; + } + } + } else { + die($err); + } + ?> + +
#UsernamePoints
' . ($key+1) . '' . $res['username'] . '' . $res['points'] . '
+
+
+

Year Top Scores

+ + + + + + + + + + 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 ''; + echo ''; + echo ''; + echo ''; + } + } + } else { + die($err); + } + ?> + + +
#UsernamePoints
' . ($key+1) . '' . $res['username'] . '' . $res['points'] . '
+
+ + 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

+ + + + + + + + + +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 ''; + echo ''; + echo ''; + echo ''; + } + } + } else { + die($err); + } +?> + + +
#UsernamePoints
' . ($key+1) . '' . $res['username'] . '' . $res['points'] . '
+
+
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