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 "you are now logged out!";
33 /* user status page */
34 else if( isset($_SESSION["name"]) )
36 $name = $_SESSION["name"];
37 $email = DB_get_email_by_name($name);
38 $password = DB_get_passwd_by_name($name);
41 /* verify password and email */
42 if(strlen($password)!=32)
43 $password = md5($password);
46 $myid = DB_get_userid_by_email_and_password($email,$password);
54 $time = DB_get_user_timestamp($myid);
55 $unixtime = strtotime($time);
57 $offset = DB_get_user_timezone($myid);
58 $zone = return_timezone($offset);
59 date_default_timezone_set($zone);
63 echo "<div class=\"lastlogin\">last login: ".date("r",$unixtime)."</div>";
65 DB_update_user_timestamp($myid);
70 echo "<div class=\"user\">\n";
72 /* always: if player logged in: add link to cards */
74 /* total number of games */
75 echo "<p>The number of finished games on this server is: ";
76 $result = mysql_query("SELECT COUNT(*) from Game".
77 " WHERE status='gameover'");
78 $r = mysql_fetch_array($result,MYSQL_NUM);
80 echo " $GameN </p>\n";
82 echo "<p>The contra party wins in ";
83 $result = mysql_query("SELECT COUNT(*) from Score".
84 " LEFT JOIN Game ON Game.id=game_id".
85 " WHERE score='againstqueens'".
86 " AND Game.status='gameover'");
87 while( $r = mysql_fetch_array($result,MYSQL_NUM))
93 echo "<p>These kind of games have been played this often: <br />";
94 $result = mysql_query("SELECT COUNT(*) as c,type from Game".
95 " WHERE status='gameover'".
98 while( $r = mysql_fetch_array($result,MYSQL_NUM))
99 echo "".$r[1]." (".$r[0].") <br />";
102 /* break up solos in types */
103 echo "<p>These kind of solos have been played this often: <br />";
104 $result = mysql_query("SELECT COUNT(*) as c,solo from Game".
105 " WHERE status='gameover'".
109 while( $r = mysql_fetch_array($result,MYSQL_NUM))
110 echo "".$r[1]." (".$r[0].")<br />";
114 2 top user mit maximaler quote an solo (min 10 games)
116 top scoring game: winning players
118 game with the same cards: show 3 at random:
119 player who won, points, what kind of game
120 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
121 select id from game where randomnumbers like "blablabl%"; the % is like .* in regexp
122 select id,type,solo,status from game where id in (select id from game where randomnumbers in (select randomnumbers from game where id=27));
125 echo "<p>Most extra points (doko, fox, karlchen) in a game::<br />\n";
126 $result = mysql_query("SELECT COUNT(*) as c,fullname FROM Score".
127 " LEFT JOIN User ON User.id=winner_id" .
128 " WHERE score IN ('fox','doko','karlchen')".
129 " GROUP BY game_id,fullname".
130 " ORDER BY c DESC LIMIT 3" );
131 while( $r = mysql_fetch_array($result,MYSQL_NUM))
132 echo $r[1]." (".$r[0].") <br />\n";
135 /* longest and shortest game */
136 $r=mysql_query("SELECT MIN(datediff(mod_date,create_date)),session".
137 " FROM Game WHERE status='gameover' GROUP BY status");
140 $short= mysql_fetch_array($r,MYSQL_NUM);
141 echo "<p> The shortest game took only ".$short[0]." days.<br />\n";
144 $r=mysql_query("SELECT MAX(datediff(mod_date,create_date)),session".
145 " FROM Game where status='gameover' GROUP BY status");
148 $long= mysql_fetch_array($r,MYSQL_NUM);
149 echo "The longest game took ".$long[0]." days.</p>\n";
153 echo "<p>These players got the most reminders:<br />\n";
154 $result = mysql_query("SELECT COUNT(*) as c,fullname from Reminder".
155 " LEFT JOIN User ON User.id=user_id".
157 " ORDER BY c DESC LIMIT 3" );
158 while( $r = mysql_fetch_array($result,MYSQL_NUM))
159 echo $r[1]." (".$r[0].") <br />\n";
163 echo "<p>These players caught the most foxes:<br />\n";
164 $result = mysql_query("SELECT COUNT(*) as c,fullname from Score".
165 " LEFT JOIN User ON User.id=winner_id".
166 " WHERE score='fox'".
167 " GROUP BY winner_id".
168 " ORDER BY c DESC LIMIT 2" );
169 while( $r = mysql_fetch_array($result,MYSQL_NUM))
170 echo $r[1]." (".$r[0].") <br />\n";
173 echo "<p>These players lost their fox most often:<br />\n";
174 $result = mysql_query("SELECT COUNT(*) as c,fullname from Score".
175 " LEFT JOIN User ON User.id=looser_id".
176 " WHERE score='fox'".
177 " GROUP BY looser_id".
178 " ORDER BY c DESC LIMIT 2" );
179 while( $r = mysql_fetch_array($result,MYSQL_NUM))
180 echo $r[1]." (".$r[0].") <br />\n";
183 /* which position wins the most tricks */
184 echo "<p>Which positions at the table make the most tricks:<br />\n";
185 $result = mysql_query("SELECT COUNT(*) AS c,winner FROM Trick".
187 " ORDER BY winner ASC " );
188 $r = mysql_fetch_array($result,MYSQL_NUM);
189 if($r[1]==NULL) /* ongoing games, no winner yet */
190 $r = mysql_fetch_array($result,MYSQL_NUM);
191 echo " left ".$r[0]." <br />\n";
192 $r = mysql_fetch_array($result,MYSQL_NUM);
193 echo " top ".$r[0]." <br />\n";
194 $r = mysql_fetch_array($result,MYSQL_NUM);
195 echo " right ".$r[0]." <br />\n";
196 $r = mysql_fetch_array($result,MYSQL_NUM);
197 echo " bottom ".$r[0]." <br />\n";
201 does the party win more often if they start
203 echo "<p>The party playing first wins in";
204 $result = mysql_query("SELECT COUNT(*) from Score".
205 " LEFT JOIN Game ON Game.id=game_id".
206 " WHERE score='againstqueens'".
207 " AND Game.status='gameover'".
208 " AND Game.type<>'solo'");
209 while( $r = mysql_fetch_array($result,MYSQL_NUM))
210 echo $r[1]." (".$r[0].") <br />\n";
216 how often is the last trick a non-trump trick
219 echo "</div>\n"; /* end output */
224 /* send them back to the login page */
225 echo "<p>Please log in</p>";