fixed labels for password recovery form
[e-DoKo.git] / include / output.php
1 <?php
2 /* Copyright 2006, 2007, 2008, 2009, 2010 Arun Persaud <arun@nubati.net>
3  *
4  *   This file is part of e-DoKo.
5  *
6  *   e-DoKo is free software: you can redistribute it and/or modify
7  *   it under the terms of the GNU General Public License as published by
8  *   the Free Software Foundation, either version 3 of the License, or
9  *   (at your option) any later version.
10  *
11  *   e-DoKo is distributed in the hope that it will be useful,
12  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *   GNU General Public License for more details.
15  *
16  *   You should have received a copy of the GNU General Public License
17  *   along with e-DoKo.  If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20
21 /* make sure that we are not called from outside the scripts,
22  * use a variable defined in config.php to check this
23  */
24 if(!isset($HOST))
25   exit;
26
27 /* functions which only ouput html  */
28
29 function output_ask_for_new_game($playerA,$playerB,$playerC,$playerD,$oldgameid)
30 {
31   global $RULES;
32
33   echo "<div class=\"message\">\n<form action=\"index.php?action=new\" method=\"post\">\n";
34   $output = sprintf(_('Do you want to continue playing? (This will start a new game, with %s starting the game.)'),$playerA);
35   echo $output."\n";
36   echo "  <input type=\"hidden\" name=\"PlayerA\" value=\"$playerA\" />\n";
37   echo "  <input type=\"hidden\" name=\"PlayerB\" value=\"$playerB\" />\n";
38   echo "  <input type=\"hidden\" name=\"PlayerC\" value=\"$playerC\" />\n";
39   echo "  <input type=\"hidden\" name=\"PlayerD\" value=\"$playerD\" />\n";
40   echo "  <input type=\"hidden\" name=\"dullen\"  value=\"".$RULES['dullen']."\" />\n";
41   echo "  <input type=\"hidden\" name=\"schweinchen\" value=\"".$RULES['schweinchen']."\" />\n";
42   echo "  <input type=\"hidden\" name=\"callrule\" value=\"".$RULES['call']."\" />\n";
43   echo "  <input type=\"hidden\" name=\"lowtrump\" value=\"".$RULES['lowtrump']."\" />\n";
44   echo "  <input type=\"hidden\" name=\"followup\" value=\"$oldgameid\" />\n";
45   echo "  <input type=\"submit\" value=\""._('keep playing')."\" />\n";
46   echo "</form>\n</div>";
47   return;
48 }
49
50 function output_form_for_new_game($names)
51 {
52   $copy_names = $names; /* local copy, so that we can delete names from it
53                          * after we selected them to make sure that each name
54                          * only shows up once
55                          */
56   echo '  <form action="index.php?action=new" method="post">';
57   echo '    <h2> '._('Select players (Remember: you need to be one of the players)').' </h2>';
58   echo '   <div class="table">';
59   echo '     <img class="table" src="pics/table.png" alt="table" />';
60
61   /* ask player for names */
62
63   $i=0;
64
65   /* delete players name, since he will be on position D anyway */
66   unset($copy_names[array_search($_SESSION["name"],$copy_names)]);
67
68   srand((float) microtime() * 10000000);
69   foreach( array("PlayerA","PlayerB","PlayerC","PlayerD") as $player)
70     {
71       /* pick 3 names at random and put the players name on position D*/
72       if($i<3)
73         {
74           $randkey = array_rand($copy_names);
75           $rand = $copy_names[$randkey];
76           /* delete this name from the list of possible names */
77           unset($copy_names[$randkey]);
78         }
79       else
80         {
81           $rand = $_SESSION["name"];
82         }
83
84       echo  "     <div class=\"table".$i."\">\n";
85       $i++;
86       echo "       <select name=\"$player\" size=\"1\">  \n";
87       foreach($names as $name)
88         {
89           if($name==$rand)
90             {
91               echo "         <option selected=\"selected\">$name</option>\n";
92             }
93           else
94             echo "         <option>$name</option>\n";
95         }
96       echo "       </select>\n     </div>\n";
97     }
98
99     echo '    </div>';
100     echo '';
101     echo '     <h2 class="rules">'._('Rules').'</h2>';
102     echo '     <h3>'._('Gameplay-related').'</h3>';
103     echo '     <h4>'._('Ten of hearts').':</h4>';
104     echo '     <p>';
105     echo '       <select name="dullen">';
106     echo '         <option value="none"> '._('just normal non-trump').'  </option>';
107     echo '         <option value="firstwins"> '._('first ten of hearts wins the trick').' </option>';
108     echo '         <option value="secondwins" selected="selected"> '.('second ten of hearts wins the trick').' </option>';
109     echo '       </select>';
110     echo '     </p>';
111     echo '     <h4>'._('Schweinchen (both foxes), only in normal games or silent solos').':</h4>';
112     echo '     <p>';
113     echo '       <select name="schweinchen">';
114     echo '         <option value="none" selected="selected"> '._('none').' </option>';
115     echo '       <option value="both"> '._('both become highest trump (automatic call at beginning of the game)').'   </option>';
116     echo '       <option value="second"> '._('first one normal, second one becomes highest (call during the game)').' </option>';
117     echo '       <option value="secondaftercall">  ',_('second one become highest only in case re/contra was announced');
118     echo '       </option>';
119     echo '       </select>';
120     echo '     </p>';
121     echo '     <h4>'._('Call Re/Contra, etc.').':</h4>';
122     echo '     <p>';
123     echo '       <select name="callrule">';
124     echo '       <option value="1st-own-card" selected="selected">  '._('Can call re/contra on the first <strong>own</strong> card played, 90 on the second, etc.').'</option>';
125     echo '       <option value="5th-card"> '._('Can call re/contra until 5th card is played, 90 until 9th card is played, etc.').'</option>';
126     echo '       <option value="9-cards" > '._('Can call re/contra until 5th card is played, 90 if player still has 9 cards, etc.').'</option>';
127     echo '       </select>';
128     echo '     </p>';
129     echo '     <h4>'._('Low trump').'</h4>';
130     echo '     <p>';
131     echo '       '._('Player can\'t trump a fox, that is none of his trump is higher than a fox.');
132     echo '       <select name="lowtrump">';
133     echo '       <option value="poverty">'._('The trump will be treated as poverty and offered to another player.').'</option>';
134     echo '       <option value="cancel"> '._('The game will be canceled unless there is a solo.').'</option>';
135     echo '       <option value="none">   '._('Bad luck, the player needs to play a normal game.').'</option>';
136     echo '       </select>';
137     echo '     </p>';
138     echo '     <h3>'._('Scoring-related').'</h3>';
139     echo '     <h4>'._('(not yet implemented)').'</h4>';
140     echo '     <p><input type="submit" value="'._('start game').'"></p>';
141     echo '     </form>';
142
143 }
144
145 function output_table($data,$caption="",$class="",$id="")
146 {
147
148   $HTML  = "\n<table";
149
150   if($class!="")
151     $HTML.= " class=\"$class\"";
152   if($id!="")
153     $HTML.= " id=\"$id\"";
154
155   $HTML.=">\n";
156
157   $i=0;
158
159   if($caption!="")
160     $HTML .= "  <caption> $caption </caption>\n";
161
162   foreach($data as $record)
163     {
164       if(!$i)
165         $HTML .= "  <thead>\n  <tr>\n";
166       else
167         {
168           if($i==1) $HTML .= "  <tbody>\n";
169           $HTML .= "  <tr>  ";
170         }
171       foreach($record as $point)
172         {
173           if($i)
174             $HTML .= "    <td>$point</td> ";
175           else
176             $HTML .= "    <th>$point</th> ";
177         }
178
179       if(!$i)
180         $HTML .= "  </tr>\n  </thead>\n";
181       else
182         {
183           $HTML .= "  </tr>\n";
184         }
185       $i++;
186     }
187   $HTML .= "  </tbody>\n</table>\n";
188
189   return $HTML;
190 }
191
192 function display_card($card,$dir="english")
193 {
194   /* cards are only availabl for the odd values, e.g. 1.png, 3.png, ...
195    * convert even cards to the matching odd value */
196
197   if( $card/2 - (int)($card/2) == 0.5 || $card == 0)
198     echo "<img src=\"cards/".$dir."/".$card.".png\"  alt=\"".DB_get_card_name($card)."\" />\n";
199   else
200     echo "<img src=\"cards/".$dir."/".($card-1).".png\"  alt=\"".DB_get_card_name($card-1)."\" />\n";
201
202   return;
203 }
204
205 function display_link_card($card,$dir="english",$type="card", $selected=0)
206 {
207   if($selected)
208     $selected = 'checked="checked"';
209
210   if( $card/2 - (int)($card/2) == 0.5)
211     echo "<div class=\"cardinput\"><input type=\"radio\" name=\"".$type."\" value=\"".$card."\" $selected /><img src=\"cards/".$dir."/".$card.".png\" alt=\"".DB_get_card_name($card)."\" /></div>\n";
212   else
213     echo "<div class=\"cardinput\" ><input type=\"radio\" name=\"".$type."\" value=\"".$card."\" $selected /><img src=\"cards/".$dir."/".($card-1).".png\" alt=\"".DB_get_card_name($card-1)."\" /></div>\n";
214   return;
215 }
216
217 function output_check_for_sickness($me,$mycards)
218 {
219   global $RULES;
220
221   echo '  <div class="sickness"> '._('Thanks for joining the game').'...<br />';
222   echo '';
223   echo '    '._('Do you want to play solo?').'';
224   echo '    <select name="solo" size="1">';
225   echo '      <option value="No" selected="selected">'.'No'.'</option>';
226   echo '      <option value="trumpless">'._('trumpless').'</option>';
227   echo '      <option value="trump">'._('trump').'</option>';
228   echo '      <option value="queen">'._('queen').'</option>';
229   echo '      <option value="jack">'._('jack').'</option>';
230   echo '      <option value="club">'._('club').'</option>';
231   echo '      <option valvue="spade">'._('spade').'</option>';
232   echo '      <option value="hear">'._('heart').'</option>';
233   echo '    </select>';
234   echo '    <br />';
235
236   echo _('Wedding?');
237   if(check_wedding($mycards))
238      {
239        echo ' '._('yes')."<input type=\"radio\" name=\"wedding\" value=\"yes\" checked=\"checked\" />";
240        echo ' '._('no')." <input type=\"radio\" name=\"wedding\" value=\"no\" /> <br />\n";
241      }
242    else
243      {
244        echo ' '._('no')." <input type=\"hidden\" name=\"wedding\" value=\"no\" /> <br />\n";
245      };
246
247   echo _('Do you have poverty?');
248   if(count_trump($mycards)<4)
249     {
250       echo ' '._('yes')."<input type=\"radio\" name=\"poverty\" value=\"yes\" checked=\"checked\" />";
251       echo ' '._('no')." <input type=\"radio\" name=\"poverty\" value=\"no\" /> <br />\n";
252     }
253   else
254     {
255       echo ' '._('no')." <input type=\"hidden\" name=\"poverty\" value=\"no\" /> <br />\n";
256     };
257
258   echo _('Do you have too many nines?');
259   if(count_nines($mycards)>4)
260      {
261        echo ' '._('yes')."<input type=\"radio\" name=\"nines\" value=\"yes\" checked=\"checked\" />";
262        echo ' '._('no')." <input type=\"radio\" name=\"nines\" value=\"no\" /> <br />\n";
263      }
264    else
265      {
266        echo ' '._('no')." <input type=\"hidden\" name=\"nines\" value=\"no\" /> <br />\n";
267      };
268
269   if($RULES['lowtrump']=='cancel' || $RULES['lowtrump']=='poverty')
270     {
271       if($RULES['lowtrump']=='cancel')
272         echo _('Do you have low trump (cancel game)?');
273       else
274         echo _('Do you have low trump (poverty)?');
275
276       if(check_low_trump($mycards))
277         {
278           echo ' '._('yes')."<input type=\"radio\" name=\"lowtrump\" value=\"yes\" checked=\"checked\" />";
279           echo ' '._('no')." <input type=\"radio\" name=\"lowtrump\" value=\"no\" /> <br />\n";
280         }
281       else
282         {
283           echo ' '._('no')." <input type=\"hidden\" name=\"lowtrump\" value=\"no\" /> <br />\n";
284         };
285     }
286   else
287     echo "<input type=\"hidden\" name=\"lowtrump\" value=\"no\" />";
288
289    echo "<input type=\"hidden\" name=\"me\" value=\"$me\" />\n";
290    echo "<input type=\"submit\" value=\""._('count me in')."\" />\n";
291
292    echo "</div>\n";
293
294   return;
295 }
296
297 function output_form_calls($me,$myparty)
298 {
299   $highstart = '  <span class="highcall">';
300   $highend   = '</span>';
301
302   $tmp = can_call(120,$me);
303   if( $tmp )
304     {
305       if($tmp==2) echo $highstart;
306       if($myparty=='re')
307         echo '  re (120):';
308       else if ($myparty=='contra')
309         echo '  contra (120):';
310       else
311         echo '  re/contra (120):';
312       echo ' <input type="radio" name="call" value="120" />';
313       if($tmp==2) echo $highend;
314       echo "\n";
315     }
316   $tmp = can_call(90,$me);
317   if( $tmp )
318     {
319       if($tmp==2) echo $highstart;
320       echo '  90:'.
321         ' <input type="radio" name="call" value="90" />';
322       if($tmp==2) echo $highend;
323       echo "\n";
324     }
325   $tmp = can_call(60,$me);
326   if( $tmp )
327     {
328       if($tmp==2) echo $highstart;
329       echo '  60:'.
330         ' <input type="radio" name="call" value="60" />';
331       if($tmp==2) echo $highend;
332       echo "\n";
333     }
334   $tmp = can_call(30,$me);
335   if( $tmp )
336     {
337       if($tmp==2) echo $highstart;
338       echo '  30:'.
339         ' <input type="radio" name="call" value="30" />';
340       if($tmp==2) echo $highend;
341       echo "\n";
342     }
343   $tmp = can_call(0,$me);
344   if( $tmp )
345     {
346       if($tmp==2) echo $highstart;
347       echo '  0:'.
348         ' <input type="radio" name="call" value="0" />';
349       if($tmp==2) echo $highend;
350       echo "\n".
351         '  no call:'.
352         ' <input type="radio" name="call" value="no" />'."\n";
353     }
354 }
355
356 function output_check_want_to_play($me)
357 {
358   echo ' <div class="joingame">';
359   echo '   '._('Do you want to play a game of DoKo?').' <br />';
360   echo '   '._('yes').'<input type="radio" name="in" value="yes" />';
361   echo '   '._('no').'<input type="radio" name="in" value="no" /> <br />';
362   echo "<input type=\"hidden\" name=\"me\" value=\"$me\" />\n";
363   echo "\n";
364   echo "<input type=\"submit\" value=\""._('submit')."\" />\n";
365   echo " </div>\n";
366
367   return;
368 }
369
370 function output_header()
371 {
372    global $REV;
373 ?>
374 <!DOCTYPE html>
375 <html lang="en">
376   <head>
377      <title>e-Doko</title>
378      <meta charset="utf-8" />
379      <link rel="shortcut icon" href="pics/edoko-favicon.png" />
380      <link rel="stylesheet" href="css/standard.css?v=30" />
381      <link rel="stylesheet" href="css/dateinput.css?v=1"/>
382      <script type="text/javascript" src="include/jquery.js"> </script>
383      <script type="text/javascript" src="include/jquery.tablesorter.js"></script>
384      <script type="text/javascript" src="include/jquery.tools.min.js"></script>
385      <script type="text/javascript" src="include/game.js"> </script>
386      <script type="text/javascript">
387         $(document).ready(function()
388            {
389               $("#ScoreTable").tablesorter({ widgets: ['zebra']});
390
391               $(".gameshidesession").click( function () {
392                   $(this).parent().children(".gamessession").hide(300);
393                   $(this).parent().children(".gamesshowsession").show();
394                   $(this).hide();
395                 });
396
397               $(".gamesshowsession").click( function () {
398                   $(this).parent().children(".gamessession").show(300);
399                   $(this).parent().children(".gameshidesession").show();
400                   $(this).hide();
401                 });
402
403               $(".gameshowall").click( function () {
404                   $(".gamessession").show(300);
405                   $(".gamesshowsession").hide();
406                   $(".gameshidesession").show();
407                 });
408               $(".gamehideall").click( function () {
409                   $(".gamessession").hide(300);
410                   $(".gamesshowsession").show();
411                   $(".gameshidesession").hide();
412                 });
413
414               $("ul.loginregister").click(function () {
415                   $(".dologin").slideToggle();
416                   $(".doregister").slideToggle();
417                 });
418
419            });
420      </script>
421   </head>
422 <body onload="high_last();">
423 <header>
424 <?php
425   echo '<h1> '._('Welcome to E-Doko').' </h1>';
426 ?>
427 </header>
428 <?php
429
430   echo "<div class=\"main\">";
431   return;
432 }
433
434 function output_footer()
435 {
436   global $REV, $PREF, $INDEX;
437
438   echo "</div>\n\n";
439   echo "<footer>\n";
440   echo "  <p class=\"left\"> copyright 2006,2007,2008,2009,2010 <a href=\"$INDEX?action=about\">Arun Persaud, et al.</a> <br />\n".
441     "  Verwendung der [deutschen] Kartenbilder mit Genehmigung <br />der Spielkartenfabrik Altenburg GmbH,(c) ASS Altenburger <br />\n".
442     "  - ASS Altenburger Spielkarten - Spielkartenfabrik Altenburg GmbH <br />\n".
443     "  a Carta Mundi Company Email: info@spielkarten.com Internet: www.spielkarten.com</p>\n";
444  echo " <p class=\"right\"> See the latest changes <a href=\"http://nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=summary\">\n".
445     "  via git </a> <br />or download the source via <br />\n'git clone http://nubati.net/git/e-DoKo.git' <br />\n".
446     "  <a href=\"http://www.dreamhost.com/green.cgi\">\n".
447     "  <img alt=\"Green Web Hosting! This site hosted by DreamHost.\"".
448     " src=\"pics/green1.gif\" height=\"32\" width=\"100\" /></a>\n".
449     "  </p> \n";
450   echo "\n";
451   echo "</footer>\n";
452
453   echo "</body>\n";
454   echo "</html>\n";
455
456   return;
457 }
458
459 function output_status()
460 {
461   global $defaulttimezone, $INDEX, $WIKI, $RSS;
462
463   if(isset($_SESSION['name']))
464     {
465       $name = $_SESSION['name'];
466
467       /* last logon time */
468       $myid  = DB_get_userid('name',$name);
469       $zone  = DB_get_user_timezone($myid);
470
471       $time     = DB_get_user_timestamp($myid);
472       date_default_timezone_set($defaulttimezone);
473       $unixtime = strtotime($time);
474       date_default_timezone_set($zone);
475
476       /* rss token */
477       $token = get_user_token($myid);
478
479       /* logout info */
480       echo "\n<div class=\"status\">\n";
481       echo $name,"\n";
482       echo " | <a href=\"".$INDEX."\">"._('mypage')."</a>\n";
483       echo " | <a href=\"".$INDEX."?action=prefs\">"._('settings')."</a>\n";
484       echo " | <a href=\"".$INDEX."?action=new\">"._('new game')."</a>\n";
485       echo " | <a href=\"".$INDEX."?action=stats\">"._('statistics')."</a>\n";
486       echo " | <a href=\"".$WIKI."\">"._('wiki/bugs')."</a>\n";
487       echo " | <a href=\"".$RSS."?uid=".$myid."&amp;token=".$token."\">"._('atom')."</a>\n";
488       echo " |&nbsp;&nbsp;&nbsp; <a href=\"".$INDEX."?action=logout\">"._('logout')."</a>\n";
489       echo "</div>\n";
490
491       echo "<div class=\"lastlogin\"><span>"._('last login').": ".date("r",$unixtime)."</span></div>\n";
492     }
493   return;
494 }
495
496 function output_select_timezone($name,$timezone="")
497 {
498   $Tzone = array ("Pacific/Apia"         => "Apia",                /*UTC-11*/
499                   "Pacific/Honolulu"     => "Honolulu",            /*UTC-10*/
500                   "America/Anchorage"    => "Anchorage",           /*UTC-9*/
501                   "America/Vancouver"    => "Berkeley",            /*UTC-8*/
502                   "America/Phoenix"      => "Phoenix",             /*UTC-7*/
503                   "America/Chicago"      => "Chicago",             /*UTC-6*/
504                   "America/New_York"     => "New York",            /*UTC-5*/
505                   "America/Santiago"     => "Santiago",            /*UTC-4*/
506                   "America/Buenos_Aires" => "Buenos Aires",        /*UTC-3*/
507                   "Atlantic/South_Georgia" => "Fernando de Noronha", /*UTC-2*/
508                   "Atlantic/Azores"       => "Azores",             /*UTC-1"*/
509                   "Europe/London"         => "London",             /*UTC*/
510                   "Europe/Berlin"         => "Berlin",             /*UTC+1*/
511                   "Africa/Cairo"          => "Cairo",              /*UTC+2*/
512                   "Europe/Moscow"         => "Moscow",             /*UTC+3*/
513                   "Asia/Tehran"           => "Tehran",             /*UTC+3:30*/
514                   "Asia/Dubai"            => "Dubai",              /*UTC+4*/
515                   "Asia/Karachi"          => "Karachi",            /*UTC+5*/
516                   "Asia/Calcutta"         => "Delhi",              /*UTC+5:30*/
517                   "Asia/Kathmandu"        => "Kathmandu",          /*UTC+5:45*/
518                   "Asia/Dhaka"            => "Dhaka",              /*UTC+6*/
519                   "Asia/Rangoon"          => "Yangon",             /*UTC+6:30*/
520                   "Asia/Bangkok"          => "Bangkok",            /*UTC+7*/
521                   "Asia/Hong_Kong"        => "Beijing",            /*UTC+8*/
522                   "Asia/Tokyo"            => "Tokyo",              /*UTC+9*/
523                   "Australia/Darwin"      => "Darwin",             /*UTC+9:30*/
524                   "Australia/Sydney"      => "Sydney",             /*UTC+10*/
525                   "Asia/Magadan"          => "Magadan",            /*UTC+11*/
526                   "Pacific/Auckland"      => "Wellington" );       /*UTC+12*/
527
528   echo "  <select id=\"$name\" name=\"$name\" size=\"1\">\n";
529
530   foreach($Tzone as $zone=>$city)
531     {
532       if($timezone==$zone)
533         echo "   <option value=\"$zone\" selected=\"selected\">$city</option>\n";
534       else
535         echo "   <option value=\"$zone\">$city</option>\n";
536     }
537   echo "  </select>\n";
538
539   return;
540 }
541
542 function output_select_language($name,$language="")
543 {
544   $LOCALE = array ("English"     => "en",
545                    "Deutsch"     => "de" );
546
547   echo "  <select id=\"$name\" name=\"$name\" size=\"1\">\n";
548
549   foreach($LOCALE as $place=>$locale)
550     {
551       if($language==$locale)
552         echo "   <option value=\"$locale\" selected=\"selected\">$place</option>\n";
553       else
554         echo "   <option value=\"$locale\">$place</option>\n";
555     }
556   echo "  </select>\n";
557
558   return;
559 }
560
561
562 function output_password_recovery($email,$password)
563 {
564 ?>
565    <form action="index.php" method="post">
566 <?php
567   echo "  <input type=\"hidden\" name=\"email\" value=\"".$email."\" />\n";
568   echo "  <input type=\"hidden\" name=\"password\" value=\"".$password."\" />\n";
569   echo "  <input type=\"hidden\" name=\"passwd\"  value=\"set\" />\n";
570 ?>
571      <fieldset>
572        <legend>Password recovery</legend>
573         <table>
574          <tr>
575             <td><label for="password0">Old password:</label></td>
576             <td><input type="password" id="password0" name="password0" size="20" maxlength="30" /> </td>
577          </tr><tr>
578             <td><label for="password1">New password:</label></td>
579             <td><input type="password" id="password1" name="password1" size="20" maxlength="30" /></td>
580          </tr><tr>
581             <td><label for="password2">Retype:</label></td>
582             <td><input type="password" id="password2" name="password2" size="20" maxlength="30" /></td>
583          </tr><tr>
584            <td></td>
585            <td> <input type="submit" class="submitbutton" name="passwd" value="set" /></td>
586          </tr>
587         </table>
588      </fieldset>
589    </form>
590
591 <?php
592 }
593
594 function output_user_notes($userid,$gameid,$userstatus)
595 {
596   echo "<div class=\"notes\"> "._('Personal notes').": <br />\n";
597   $notes = DB_get_notes_by_userid_and_gameid($userid,$gameid);
598   foreach($notes as $note)
599     echo "$note <hr />\n";
600   if($userstatus!='gameover')
601     echo "<input name=\"note\" type=\"text\" size=\"15\" maxlength=\"100\" />\n";
602   echo "</div> \n";
603
604   return;
605 }
606
607 function output_robotproof($i)
608 {
609   switch($i)
610     {
611     case 0:
612       return "6*7=";
613     case 1:
614       return "5*7=";
615     case 2:
616       return "4*7=";
617     case 3:
618       return "3*7=";
619     case 4:
620       return "2*7=";
621     }
622 }
623
624 function output_exchanged_cards()
625 {
626   /* in a poverty game this function will output the exchanged cards
627    * players in the team will see the cards, the other team will see
628    * the backside of cards
629    */
630
631   /* need some information about the game */
632   global $gameid,$mygametype, $PREF,$me,$mystatus, $RULES;
633
634   /* some variables to track where the people with poverty are sitting */
635   $partnerpos1 = 0;
636   $povertypos1 = 0;
637   $partnerpos2 = 0;
638   $povertypos2 = 0;
639
640   /* only need to do it in a poverty game, this might not be needed, but
641    * just to make sure everything is ok
642    */
643   if($mygametype == 'poverty' || $mygametype=='dpoverty')
644     {
645       /* find out who has poverty */
646       for($mypos=1;$mypos<5;$mypos++)
647         {
648           $usersick = DB_get_sickness_by_pos_and_gameid($mypos,$gameid);
649           if($usersick == 'poverty' || ($RULES['lowtrump']=='poverty' && $usersick=='lowtrump'))
650             if($povertypos1)
651               $povertypos2 = $mypos;
652             else
653               $povertypos1 = $mypos;
654         }
655       /* get hash and exchanged cards for all involved */
656       $povertyhash1 = DB_get_hash_from_game_and_pos($gameid,$povertypos1);
657       $partnerhash1 = DB_get_partner_hash_by_hash($povertyhash1);
658
659       $povertycards1 = DB_get_exchanged_cards($povertyhash1);
660       $partnercards1 = DB_get_exchanged_cards($partnerhash1);
661
662       $partnerpos1 = DB_get_pos_by_hash($partnerhash1);
663       if($povertypos2)
664         {
665           $povertyhash2 = DB_get_hash_from_game_and_pos($gameid,$povertypos2);
666           $partnerhash2 = DB_get_partner_hash_by_hash($povertyhash2);
667
668           $povertycards2 = DB_get_exchanged_cards($povertyhash2);
669           $partnercards2 = DB_get_exchanged_cards($partnerhash2);
670
671           $partnerpos2 = DB_get_pos_by_hash($partnerhash2);
672         }
673     }
674
675   /* output the cards
676    * go through all positions, check that position has cards that need to be shown and
677    * show those cards
678    */
679   $show=1;
680   for($mypos=1;$mypos<5;$mypos++)
681     {
682       $usersick = DB_get_sickness_by_pos_and_gameid($mypos,$gameid);
683       if($usersick!=NULL ||
684          $mypos==$povertypos1 || $mypos==$partnerpos1 ||
685          $mypos==$povertypos2 || $mypos==$partnerpos2 )
686         {
687           /* figure out if we gave trump back */
688           $trump_back1=0;
689           if($povertypos2)
690             foreach($povertycards1 as $card)
691               {
692                 if(is_trump($card))
693                   {
694                     $trump_back1=1;
695                     break;
696                   }
697               }
698           $trump_back2=0;
699           if($povertypos2)
700             foreach($povertycards2 as $card)
701               {
702                 if(is_trump($card))
703                   {
704                     $trump_back2=1;
705                     break;
706                   }
707               }
708
709           /* output vorbehalt  */
710           echo "      <div class=\"vorbehalt".($mypos-1)."\"> Vorbehalt <br />\n";
711           if($show)
712             echo "       $usersick <br />\n";
713
714           /* output cards */
715           if($mypos==$partnerpos1)
716             {
717               foreach($partnercards1 as $card)
718                 {
719                   echo '        ';
720                   if($povertyhash1 == $me || $partnerhash1 == $me || $mystatus=='gameover')
721                     display_card($card,$PREF['cardset']);
722                   else
723                     display_card(0,$PREF['cardset']);
724                 }
725               if($trump_back1) echo '        '._('Trump back');
726             }
727           else if($mypos==$povertypos1)
728             {
729               foreach($povertycards1 as $card)
730                 {
731                   echo '        ';
732                   if($povertyhash1 == $me || $partnerhash1 == $me || $mystatus=='gameover')
733                     display_card($card,$PREF['cardset']);
734                   else
735                     display_card(0,$PREF['cardset']);
736               }
737               if($trump_back1) echo '        '._('Trump back');
738             }
739           else if($mypos==$povertypos2)
740             {
741               foreach($povertycards2 as $card)
742                 {
743                   echo '        ';
744                   if($povertyhash2 == $me || $partnerhash2 == $me || $mystatus=='gameover')
745                     display_card($card,$PREF['cardset']);
746                   else
747                     display_card(0,$PREF['cardset']);
748                 }
749               if($trump_back2) echo '        '._('Trump back');
750             }
751           else if($mypos==$partnerpos2)
752             {
753               foreach($partnercards2 as $card)
754                 {
755                   if(is_trump($card)) $trump_back=1;
756                   echo '        ';
757                   if($povertyhash2 == $me || $partnerhash2 == $me || $mystatus=='gameover')
758                     display_card($card,$PREF['cardset']);
759                   else
760                     display_card(0,$PREF['cardset']);
761                 }
762               if($trump_back2) echo '        '._('Trump back');
763             }
764           echo  "      </div>\n";
765         }
766       if($mygametype == $usersick)
767         $show = 0;
768     }
769 }
770
771
772 ?>