diff --git a/php/profile.php b/php/profile.php
index bc8b8ed..3cbd1dc 100644
--- a/php/profile.php
+++ b/php/profile.php
@@ -1,9 +1,8 @@
-
"|", "["=>"{", "]"=>"}", "~"=>"^");
$usernameCanonical = strtr($username, $ircLowerSymbols);
@@ -12,7 +11,53 @@ if(array_key_exists('username', $_GET)) {
$username = '';
$usernameCanonical = '';
}
+
+if ($db && $username != '') {
+ $q = $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
+ 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');
+ $q->execute(array(':username'=>$usernameCanonical));
+ if ($q === false) {
+ die("Error: database error: table does not exist\n");
+ } else {
+ $result = $q->fetchAll();
+ if(sizeOf($result) > 0) {
+ $result = $result[0];
+ }
+
+ if(is_null($result['usrname'])) {
+ $result['usrname'] = "Not found";
+ $result['count'] = 0;
+ $result['score'] = 0;
+ $result['points'] = 0;
+ $result['q_asked'] = 0;
+ $result['num_e'] = 0;
+ $result['num_e_accepted'] = 0;
+ $result['num_q'] = 0;
+ $result['num_q_accepted'] = 0;
+ $result['num_r'] = 0;
+
+ }
+ }
+} else {
+ if(isset($err)) {
+ die($err);
+ }
+}
?>
+
Players · TriviaTime
@@ -48,168 +93,104 @@ if(array_key_exists('username', $_GET)) {
- 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
- 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
-');
-$q->execute(array(':username'=>$usernameCanonical));
-if ($q === false) {
- die("Error: database error: table does not exist\n");
-} else {
- $result = $q->fetchAll();
- if(sizeOf($result) > 0) {
- $result = $result[0];
- }
-
- if(is_null($result['usrname'])) {
- $result['usrname'] = "Not found";
- $result['count'] = 0;
- $result['score'] = 0;
- $result['points'] = 0;
- $result['q_asked'] = 0;
- $result['num_e'] = 0;
- $result['num_e_accepted'] = 0;
- $result['num_q'] = 0;
- $result['num_q_accepted'] = 0;
- $result['num_r'] = 0;
-
- }
-}
-} else {
- if(isset($err)) {
- die($err);
- }
-}
-?>
-
-
-
Profile and user summary.
-
-
-
+
+
+
Profile and user summary.
+
+
+
-
-
-
Averages
-
-
-
- | Average Time/Question* |
- Average Points/Question* |
-
-
-
-
+
+
Averages
+
+
+
+ | Average Time/Question* |
+ Average Points/Question* |
+
+
+
+ ';
+ echo '' . number_format($result['count'],2) . ' | ';
+ echo '' . number_format($result['score'],2) . ' | ';
+ echo '';
+ }
+ }
+ ?>
+
+
+
+
+
Totals
+
+
+
+ | Total Points |
+ Number Answered* |
+
+
+
+ ';
+ echo '' . number_format($result['points'],0) . ' | ';
+ echo '' . number_format($result['q_asked'],0) . ' | ';
+ echo '';
+ }
+ }
+ ?>
+
+
+
+
+
+
+
Contributions
+
+
+
+ | Number Edited |
+ Edits Accepted |
+ Questions Added |
+ Questions Accepted |
+ Reports Made |
+
+
+
+ ';
+ echo '' . number_format($result['num_e'],0) . ' | ';
+ echo '' . number_format($result['num_e_accepted'],0) . ' | ';
+ echo '' . number_format($result['num_q'],0) . ' | ';
+ echo '' . number_format($result['num_q_accepted'],0) . ' | ';
+ echo '' . number_format($result['num_r'],0) . ' | ';
+ echo '';
+ }
+ }
+ ?>
+
+
+
+
- if(isset($result)) {
- if(!is_null($result['usrname']) && $result['usrname'] != 'Not found') {
- echo '';
- echo '| ' . number_format($result['count'],2) . ' | ';
- echo '' . number_format($result['score'],2) . ' | ';
- echo '
';
- }
- }
- ?>
-
-
-
-
-
Totals
-
-
-
- | Total Points |
- Number Answered* |
-
-
-
-
+
+
* These stats do not include KAOS
+
+
+
- if(isset($result)) {
- if(!is_null($result['usrname']) && $result['usrname'] != 'Not found') {
- echo '';
- echo '| ' . number_format($result['points'],0) . ' | ';
- echo '' . number_format($result['q_asked'],0) . ' | ';
- echo '
';
- }
- }
- ?>
-
-
-
-
-
-
-
Contributions
-
-
-
- | Number Edited |
- Edits Accepted |
- Questions Added |
- Questions Accepted |
- Reports Made |
-
-
-
- ';
- echo '' . number_format($result['num_e'],0) . ' | ';
- echo '' . number_format($result['num_e_accepted'],0) . ' | ';
- echo '' . number_format($result['num_q'],0) . ' | ';
- echo '' . number_format($result['num_q_accepted'],0) . ' | ';
- echo '' . number_format($result['num_r'],0) . ' | ';
- echo '';
- }
- }
- ?>
-
-
-
-
-
-
-
-
* These stats do not include KAOS
-
-
-
-
-
+
diff --git a/php/stats.php b/php/stats.php
index cdf140a..bea8057 100644
--- a/php/stats.php
+++ b/php/stats.php
@@ -101,129 +101,129 @@ include('config.php');
' 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_canonical 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 '' . number_format($res['points'],0) . ' | ';
- echo '
';
- }
- }
- } else {
- die($err);
+ $week->add($interval);
}
?>
-
-
-
-
-
-
-
-
Month Top Scores
-
-
-
- | # |
- Username |
- Points |
-
-
-
- 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 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 '' . number_format($res['points'],0) . ' | ';
- echo '
';
+
+
Week Top Scores
+
+
+
+ | # |
+ Username |
+ Points |
+
+
+
+ query("SELECT username, sum(points_made) as points FROM triviauserlog WHERE $sqlClause GROUP BY username_canonical 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 '' . number_format($res['points'],0) . ' | ';
+ echo '
';
+ }
+ }
+ } else {
+ die($err);
}
- }
- } else {
- die($err);
- }
- ?>
-
-
-
-
-
Year Top Scores
-
-
-
- | # |
- Username |
- Points |
-
-
-
-
- if ($db) {
- $q = $db->prepare("SELECT username, sum(points_made) as points FROM triviauserlog WHERE year=:year GROUP BY username_canonical 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 '' . number_format($res['points'],0) . ' | ';
- echo '
';
+
+
+
+
+
+
+
Month Top Scores
+
+
+
+ | # |
+ Username |
+ Points |
+
+
+
+ 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 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 '' . number_format($res['points'],0) . ' | ';
+ echo '
';
+ }
+ }
+ } else {
+ die($err);
}
- }
- } else {
- die($err);
- }
- ?>
+ ?>
+
+
+
+
+
Year Top Scores
+
+
+
+ | # |
+ Username |
+ Points |
+
+
+
+
-
-
-
+ if ($db) {
+ $q = $db->prepare("SELECT username, sum(points_made) as points FROM triviauserlog WHERE year=:year GROUP BY username_canonical 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 '' . number_format($res['points'],0) . ' | ';
+ echo '
';
+ }
+ }
+ } else {
+ die($err);
+ }
+ ?>
-
+
+
+
+
-
+
+
+