X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=stats.php;h=efd2c216fcb1fb54f2cd26bcd0c17c48d5758917;hp=83106cf48223f96f45073958f045e797d85a4f96;hb=2a95396715b96617efcc4f167352581b8ef0d688;hpb=a5684ef10fbd20dd335b99a0d53555498842268a diff --git a/stats.php b/stats.php index 83106cf..efd2c21 100644 --- a/stats.php +++ b/stats.php @@ -19,7 +19,6 @@ if(DB_open()<0) /* start a session, if it is not already running */ session_start(); - /* done major error checking, output header of HTML page */ output_header(); @@ -29,7 +28,8 @@ if(myisset("logout")) session_unset(); session_destroy(); $_SESSION = array(); - echo "you are now logged out!"; + echo "
You are now logged out!
\n". + "(This will take you back to the home-page)
"; } /* 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,18 +49,9 @@ else if( isset($_SESSION["name"]) ) if($ok) { - DB_get_PREF($myid); - - $time = DB_get_user_timestamp($myid); - $unixtime = strtotime($time); + output_status(); - $offset = DB_get_user_timezone($myid); - $zone = return_timezone($offset); - date_default_timezone_set($zone); - - output_status($name); - - echo "
last login: ".date("r",$unixtime)."
"; + DB_get_PREF($myid); DB_update_user_timestamp($myid); @@ -80,6 +70,16 @@ else if( isset($_SESSION["name"]) ) $GameN = $r[0]; echo " $GameN

\n"; + echo "

The contra party wins in "; + $result = mysql_query("SELECT COUNT(*) from Score". + " LEFT JOIN Game ON Game.id=game_id". + " WHERE score='againstqueens'". + " AND Game.status='gameover'"); + while( $r = mysql_fetch_array($result,MYSQL_NUM)) + echo $r[0]; + echo " games.

\n"; + + /* number of solos */ echo "

These kind of games have been played this often:
"; $result = mysql_query("SELECT COUNT(*) as c,type from Game". @@ -87,7 +87,7 @@ else if( isset($_SESSION["name"]) ) " GROUP BY type". " ORDER BY c DESC"); while( $r = mysql_fetch_array($result,MYSQL_NUM)) - echo "".$r[1]." (".$r[0].")
"; + echo "".$r[1]." (".$r[0].")
"; echo "

\n"; /* break up solos in types */ @@ -113,36 +113,53 @@ else if( isset($_SESSION["name"]) ) select id,type,solo,status from game where id in (select id from game where randomnumbers in (select randomnumbers from game where id=27)); */ - echo "

Most extra points in a game::
\n"; + echo "

Most extra points (doko, fox, karlchen) in a single game:
\n"; $result = mysql_query("SELECT COUNT(*) as c,fullname FROM Score". " LEFT JOIN User ON User.id=winner_id" . " WHERE score IN ('fox','doko','karlchen')". - " GROUP BY fullname". - " ORDER BY c DESC LIMIT 1" ); + " GROUP BY game_id,fullname". + " ORDER BY c DESC LIMIT 3" ); while( $r = mysql_fetch_array($result,MYSQL_NUM)) echo $r[1]." (".$r[0].")
\n"; echo "

\n"; /* longest and shortest game */ - $r=mysql_query("SELECT MIN(datediff(mod_date,create_date)),session". - " FROM Game WHERE status='gameover' GROUP BY status"); + $r=mysql_query("SELECT timediff(mod_date,create_date) ,session,id". + " FROM Game WHERE status='gameover'". + " ORDER BY time_to_sec(timediff(mod_date,create_date)) ASC LIMIT 1"); + if($r) { $short= mysql_fetch_array($r,MYSQL_NUM); - echo "

The shortest game took only ".$short[0]." days.
\n"; + $names = DB_get_all_names_by_gameid($short[2]); + echo "

The shortest game took only ".$short[0]." hours and was played by ".join(", ",$names).".
\n"; } - $r=mysql_query("SELECT MAX(datediff(mod_date,create_date)),session". - " FROM Game where status='gameover' GROUP BY status"); + $r=mysql_query("SELECT datediff(mod_date,create_date) ,session,id". + " FROM Game WHERE status='gameover'". + " ORDER BY time_to_sec(timediff(mod_date,create_date)) DESC LIMIT 1"); if($r) { $long= mysql_fetch_array($r,MYSQL_NUM); echo "The longest game took ".$long[0]." days.

\n"; } + $r=mysql_query("SELECT COUNT(*) as c, session, id FROM Game ". + " GROUP BY session ORDER BY c DESC LIMIT 1"); + if($r) + { + $long = mysql_fetch_array($r,MYSQL_NUM); + $names = DB_get_all_names_by_gameid($long[2]); + echo "The longest session is session ".$long[1]." with ".$long[0]. + " games played by ".join(", ",$names).".

\n"; + } + /* 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" ); @@ -151,22 +168,30 @@ else if( isset($_SESSION["name"]) ) 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:
\n"; - $result = mysql_query("SELECT COUNT(*) as c,fullname from Score". + 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 2" ); + " ORDER BY c DESC LIMIT 5" ); while( $r = mysql_fetch_array($result,MYSQL_NUM)) echo $r[1]." (".$r[0].")
\n"; echo "

\n"; @@ -202,15 +227,6 @@ else if( isset($_SESSION["name"]) ) echo " games

\n"; */ - echo "

The contra party wins in "; - $result = mysql_query("SELECT COUNT(*) from Score". - " LEFT JOIN Game ON Game.id=game_id". - " WHERE score='againstqueens'". - " AND Game.status='gameover'". - " AND Game.type<>'solo'"); - while( $r = mysql_fetch_array($result,MYSQL_NUM)) - echo $r[0]; - echo " games

\n"; /* how often is the last trick a non-trump trick @@ -222,7 +238,8 @@ else if( isset($_SESSION["name"]) ) else { /* send them back to the login page */ - echo "

Please log in

"; + echo "
You need to log in!
\n". + "(This will take you back to the login-page)
"; } output_footer();