BUGFIX: a comment for schweinchen was issued even in solo games without schweinchen
[e-DoKo.git] / stats.php
index 68a09afbb6953156f4b23cb9a68015e217d67b93..efd2c216fcb1fb54f2cd26bcd0c17c48d5758917 100644 (file)
--- a/stats.php
+++ b/stats.php
@@ -29,7 +29,7 @@ if(myisset("logout"))
     session_destroy();
     $_SESSION = array();
     echo "<div class=\"message\"><span class=\"bigger\">You are now logged out!</span><br />\n".
-      "(<a href=\"$host\">This will take you back to the home-page</a>)</div>";
+      "(<a href=\"$INDEX\">This will take you back to the home-page</a>)</div>";
   }
 /* user status page */
 else if( isset($_SESSION["name"]) )
@@ -38,7 +38,6 @@ else if( isset($_SESSION["name"]) )
      $email     = DB_get_email_by_name($name);
      $password  = DB_get_passwd_by_name($name);
 
-
      /* verify password and email */
      if(strlen($password)!=32)
        $password = md5($password);
@@ -50,6 +49,8 @@ else if( isset($_SESSION["name"]) )
 
      if($ok)
        {
+        output_status();
+
         DB_get_PREF($myid);
 
         DB_update_user_timestamp($myid);
@@ -154,8 +155,11 @@ else if( isset($_SESSION["name"]) )
           }
 
         /* most reminders */
-        echo "<p>These players got the most reminders:<br />\n";
-        $result = mysql_query("SELECT COUNT(*) as c,fullname from Reminder".
+        echo "<p>These players got the most reminders per game:<br />\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" );
@@ -164,22 +168,30 @@ else if( isset($_SESSION["name"]) )
         echo "</p>\n";
 
         /* fox */
-        echo "<p>These players caught the most foxes:<br />\n";
-        $result = mysql_query("SELECT COUNT(*) as c,fullname from Score".
+        echo "<p>These players caught the most foxes per game:<br />\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].") <br />\n";
         echo "</p>\n";
 
-        echo "<p>These players lost their fox most often:<br />\n";
-        $result = mysql_query("SELECT COUNT(*) as c,fullname from Score".
+        echo "<p>These players lost their fox most often per game:<br />\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 DESC LIMIT 5" );
         while( $r = mysql_fetch_array($result,MYSQL_NUM))
           echo $r[1]." (".$r[0].") <br />\n";
         echo "</p>\n";
@@ -227,7 +239,7 @@ else if( isset($_SESSION["name"]) )
    {
      /* send them back to the login page */
     echo "<div class=\"message\"><span class=\"bigger\">You need to log in!</span><br />\n".
-      "(<a href=\"$host\">This will take you back to the login-page</a>)</div>";
+      "(<a href=\"$INDEX\">This will take you back to the login-page</a>)</div>";
    }
 
 output_footer();