X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=stats.php;h=9ecbd94904c80011195850591eedfeb7c4d4ec79;hp=68a09afbb6953156f4b23cb9a68015e217d67b93;hb=9f3cec73181b5ac35486fea031828b11468bceb9;hpb=a28cbfa660f2ff982f1cdcee41c09cec772d84af;ds=sidebyside diff --git a/stats.php b/stats.php index 68a09af..9ecbd94 100644 --- a/stats.php +++ b/stats.php @@ -29,27 +29,28 @@ if(myisset("logout")) session_destroy(); $_SESSION = array(); echo "
You are now logged out!
\n". - "(This will take you back to the home-page)
"; + "(This will take you back to the home-page)"; } /* user status page */ else if( isset($_SESSION["name"]) ) { $name = $_SESSION["name"]; - $email = DB_get_email_by_name($name); + $email = DB_get_email('name',$name); $password = DB_get_passwd_by_name($name); - /* verify password and email */ if(strlen($password)!=32) $password = md5($password); $ok = 1; - $myid = DB_get_userid_by_email_and_password($email,$password); + $myid = DB_get_userid('email-password',$email,$password); if(!$myid) $ok = 0; if($ok) { + output_status(); + DB_get_PREF($myid); DB_update_user_timestamp($myid); @@ -154,32 +155,57 @@ else if( isset($_SESSION["name"]) ) } /* most reminders */ - echo "

These players got the most reminders:
\n"; - $result = mysql_query("SELECT COUNT(*) as c,fullname from Reminder". + echo "

These players got the most reminders per game:
\n"; + $result = mysql_query("SELECT COUNT(*) /" . + " (SELECT COUNT(*) FROM Hand". + " WHERE user_id=User.id) as c,". + " fullname FROM Reminder". " LEFT JOIN User ON User.id=user_id". " GROUP BY user_id". - " ORDER BY c DESC LIMIT 3" ); + " ORDER BY c DESC LIMIT 5" ); while( $r = mysql_fetch_array($result,MYSQL_NUM)) echo $r[1]." (".$r[0].")
\n"; echo "

\n"; /* fox */ - echo "

These players caught the most foxes:
\n"; - $result = mysql_query("SELECT COUNT(*) as c,fullname from Score". + echo "

These players caught the most foxes per game:
\n"; + $result = mysql_query("SELECT COUNT(*) /" . + " (SELECT COUNT(*) FROM Hand". + " WHERE user_id=User.id) as c,". + " fullname". + " FROM Score". " LEFT JOIN User ON User.id=winner_id". " WHERE score='fox'". " GROUP BY winner_id". - " ORDER BY c DESC LIMIT 2" ); + " ORDER BY c DESC LIMIT 5" ); + while( $r = mysql_fetch_array($result,MYSQL_NUM)) + echo $r[1]." (".$r[0].")
\n"; + echo "

\n"; + + echo "

These players lost their fox most often per game:
\n"; + $result = mysql_query("SELECT COUNT(*) /" . + " (SELECT COUNT(*) FROM Hand". + " WHERE user_id=User.id) as c,". + " fullname". + " FROM Score". + " LEFT JOIN User ON User.id=looser_id". + " WHERE score='fox'". + " GROUP BY looser_id". + " ORDER BY c DESC LIMIT 5" ); while( $r = mysql_fetch_array($result,MYSQL_NUM)) echo $r[1]." (".$r[0].")
\n"; echo "

\n"; - echo "

These players lost their fox most often:
\n"; - $result = mysql_query("SELECT COUNT(*) as c,fullname from Score". + echo "

These players lost their fox least often per game:
\n"; + $result = mysql_query("SELECT COUNT(*) /" . + " (SELECT COUNT(*) FROM Hand". + " WHERE user_id=User.id) as c,". + " fullname". + " FROM Score". " LEFT JOIN User ON User.id=looser_id". " WHERE score='fox'". " GROUP BY looser_id". - " ORDER BY c DESC LIMIT 2" ); + " ORDER BY c ASC LIMIT 5" ); while( $r = mysql_fetch_array($result,MYSQL_NUM)) echo $r[1]." (".$r[0].")
\n"; echo "

\n"; @@ -201,6 +227,31 @@ else if( isset($_SESSION["name"]) ) echo " bottom ".$r[0]."
\n"; echo "

\n"; + /* most games */ + echo "

Most games played on the server:
\n"; + $result = mysql_query("SELECT COUNT(*) as c, " . + " fullname FROM Hand". + " LEFT JOIN User ON User.id=user_id". + " GROUP BY user_id". + " ORDER BY c DESC LIMIT 7" ); + while( $r = mysql_fetch_array($result,MYSQL_NUM)) + echo $r[1]." (".$r[0].")
\n"; + echo "

\n"; + + /* most active games */ + echo "

These players are involved in this many active games:
\n"; + $result = mysql_query("SELECT COUNT(*) as c, " . + " fullname FROM Hand". + " LEFT JOIN User ON User.id=user_id". + " LEFT JOIN Game ON Game.id=game_id". + " WHERE Game.status<>'gameover'". + " GROUP BY user_id". + " ORDER BY c DESC LIMIT 7" ); + while( $r = mysql_fetch_array($result,MYSQL_NUM)) + echo $r[1]." (".$r[0].")
\n"; + echo "

\n"; + + /* does the party win more often if they start @@ -227,7 +278,7 @@ else if( isset($_SESSION["name"]) ) { /* send them back to the login page */ echo "
You need to log in!
\n". - "(This will take you back to the login-page)
"; + "(This will take you back to the login-page)"; } output_footer();