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