2 error_reporting(E_ALL);
4 include_once("config.php");
5 include_once("output.php"); /* html output only */
6 include_once("db.php"); /* database only */
7 include_once("functions.php"); /* the rest */
14 echo "Database error, can't connect... Please wait a while and try again. ".
15 "If the problem doesn't go away feel free to contact $ADMIN_NAME at $ADMIN_EMAIL.";
20 /* start a session, if it is not already running */
22 /* done major error checking, output header of HTML page */
25 /* check if we want to logout */
31 echo "<div class=\"message\"><span class=\"bigger\">You are now logged out!</span><br />\n".
32 "(<a href=\"$host\">This will take you back to the home-page</a>)</div>";
34 /* user status page */
35 else if( isset($_SESSION["name"]) )
37 $name = $_SESSION["name"];
38 $email = DB_get_email_by_name($name);
39 $password = DB_get_passwd_by_name($name);
42 /* verify password and email */
43 if(strlen($password)!=32)
44 $password = md5($password);
47 $myid = DB_get_userid_by_email_and_password($email,$password);
55 $time = DB_get_user_timestamp($myid);
56 $unixtime = strtotime($time);
58 $offset = DB_get_user_timezone($myid);
59 $zone = return_timezone($offset);
60 date_default_timezone_set($zone);
64 echo "<div class=\"lastlogin\">last login: ".date("r",$unixtime)."</div>";
66 DB_update_user_timestamp($myid);
71 echo "<div class=\"user\">\n";
73 /* always: if player logged in: add link to cards */
75 /* total number of games */
76 echo "<p>The number of finished games on this server is: ";
77 $result = mysql_query("SELECT COUNT(*) from Game".
78 " WHERE status='gameover'");
79 $r = mysql_fetch_array($result,MYSQL_NUM);
81 echo " $GameN </p>\n";
83 echo "<p>The contra party wins in ";
84 $result = mysql_query("SELECT COUNT(*) from Score".
85 " LEFT JOIN Game ON Game.id=game_id".
86 " WHERE score='againstqueens'".
87 " AND Game.status='gameover'");
88 while( $r = mysql_fetch_array($result,MYSQL_NUM))
94 echo "<p>These kind of games have been played this often: <br />";
95 $result = mysql_query("SELECT COUNT(*) as c,type from Game".
96 " WHERE status='gameover'".
99 while( $r = mysql_fetch_array($result,MYSQL_NUM))
100 echo "".$r[1]." (".$r[0].") <br />";
103 /* break up solos in types */
104 echo "<p>These kind of solos have been played this often: <br />";
105 $result = mysql_query("SELECT COUNT(*) as c,solo from Game".
106 " WHERE status='gameover'".
110 while( $r = mysql_fetch_array($result,MYSQL_NUM))
111 echo "".$r[1]." (".$r[0].")<br />";
115 2 top user mit maximaler quote an solo (min 10 games)
117 top scoring game: winning players
119 game with the same cards: show 3 at random:
120 player who won, points, what kind of game
121 select g1.id, g2.id from game g1 left join game g2 on g1.randomnumbers=g2.randomnumbers where g1.id<g2.id order by g1.id
122 select id from game where randomnumbers like "blablabl%"; the % is like .* in regexp
123 select id,type,solo,status from game where id in (select id from game where randomnumbers in (select randomnumbers from game where id=27));
126 echo "<p>Most extra points (doko, fox, karlchen) in a single game:<br />\n";
127 $result = mysql_query("SELECT COUNT(*) as c,fullname FROM Score".
128 " LEFT JOIN User ON User.id=winner_id" .
129 " WHERE score IN ('fox','doko','karlchen')".
130 " GROUP BY game_id,fullname".
131 " ORDER BY c DESC LIMIT 3" );
132 while( $r = mysql_fetch_array($result,MYSQL_NUM))
133 echo $r[1]." (".$r[0].") <br />\n";
136 /* longest and shortest game */
137 $r=mysql_query("SELECT MIN(timediff(mod_date,create_date)),session,id".
138 " FROM Game WHERE status='gameover' GROUP BY status");
141 $short= mysql_fetch_array($r,MYSQL_NUM);
142 $names = DB_get_all_names_by_gameid($short[2]);
143 echo "<p> The shortest game took only ".$short[0]." hours and was played by ".join(", ",$names).".<br />\n";
146 $r=mysql_query("SELECT MAX(datediff(mod_date,create_date)),session".
147 " FROM Game where status='gameover' GROUP BY status");
150 $long= mysql_fetch_array($r,MYSQL_NUM);
151 echo "The longest game took ".$long[0]." days.</p>\n";
154 $r=mysql_query("SELECT COUNT(*) as c, session, id FROM Game ".
155 " GROUP BY session ORDER BY c DESC LIMIT 1");
158 $long = mysql_fetch_array($r,MYSQL_NUM);
159 $names = DB_get_all_names_by_gameid($long[2]);
160 echo "The longest session is session ".$long[1]." with ".$long[0].
161 " games played by ".join(", ",$names).".</p>\n";
165 echo "<p>These players got the most reminders:<br />\n";
166 $result = mysql_query("SELECT COUNT(*) as c,fullname from Reminder".
167 " LEFT JOIN User ON User.id=user_id".
169 " ORDER BY c DESC LIMIT 3" );
170 while( $r = mysql_fetch_array($result,MYSQL_NUM))
171 echo $r[1]." (".$r[0].") <br />\n";
175 echo "<p>These players caught the most foxes:<br />\n";
176 $result = mysql_query("SELECT COUNT(*) as c,fullname from Score".
177 " LEFT JOIN User ON User.id=winner_id".
178 " WHERE score='fox'".
179 " GROUP BY winner_id".
180 " ORDER BY c DESC LIMIT 2" );
181 while( $r = mysql_fetch_array($result,MYSQL_NUM))
182 echo $r[1]." (".$r[0].") <br />\n";
185 echo "<p>These players lost their fox most often:<br />\n";
186 $result = mysql_query("SELECT COUNT(*) as c,fullname from Score".
187 " LEFT JOIN User ON User.id=looser_id".
188 " WHERE score='fox'".
189 " GROUP BY looser_id".
190 " ORDER BY c DESC LIMIT 2" );
191 while( $r = mysql_fetch_array($result,MYSQL_NUM))
192 echo $r[1]." (".$r[0].") <br />\n";
195 /* which position wins the most tricks */
196 echo "<p>Which positions at the table make the most tricks:<br />\n";
197 $result = mysql_query("SELECT COUNT(*) AS c,winner FROM Trick".
199 " ORDER BY winner ASC " );
200 $r = mysql_fetch_array($result,MYSQL_NUM);
201 if($r[1]==NULL) /* ongoing games, no winner yet */
202 $r = mysql_fetch_array($result,MYSQL_NUM);
203 echo " left ".$r[0]." <br />\n";
204 $r = mysql_fetch_array($result,MYSQL_NUM);
205 echo " top ".$r[0]." <br />\n";
206 $r = mysql_fetch_array($result,MYSQL_NUM);
207 echo " right ".$r[0]." <br />\n";
208 $r = mysql_fetch_array($result,MYSQL_NUM);
209 echo " bottom ".$r[0]." <br />\n";
213 does the party win more often if they start
215 echo "<p>The party playing first wins in";
216 $result = mysql_query("SELECT COUNT(*) from Score".
217 " LEFT JOIN Game ON Game.id=game_id".
218 " WHERE score='againstqueens'".
219 " AND Game.status='gameover'".
220 " AND Game.type<>'solo'");
221 while( $r = mysql_fetch_array($result,MYSQL_NUM))
222 echo $r[1]." (".$r[0].") <br />\n";
228 how often is the last trick a non-trump trick
231 echo "</div>\n"; /* end output */
236 /* send them back to the login page */
237 echo "<div class=\"message\"><span class=\"bigger\">You need to log in!</span><br />\n".
238 "(<a href=\"$host\">This will take you back to the login-page</a>)</div>";