845281563615800795606c6e54cbd79de07c735b
[e-DoKo.git] / output.php
1 <?php
2
3 /* functions which only ouput html  */
4
5 function display_links($email,$password)
6 {
7   global $wiki;
8   echo "<div class=\"bug\">\n".
9     "Report bugs in the <a href=\"". $wiki."\">wiki</a>.<hr />\n";
10   output_link_to_user_page($email,$password);
11   echo  "</div>\n";
12   return;
13 }
14
15 function output_link_to_user_page($email,$password)
16 {
17   echo "<a href=\"index.php\"> go to my user page </a>";
18
19   return;
20 }
21
22 function output_user_settings($email,$password)
23 {
24   global $PREF;
25
26   echo "<div class=\"useroptions\">\n";
27   echo "<h4> Settings </h4>\n";
28   echo "<a href=\"index.php?passwd=ask\">change password</a><br /";
29
30   if( $PREF["cardset"] == "english" )
31     echo "<a href=\"index.php?setpref=germancards\">use german cards</a><br />";
32   else
33     echo "<a href=\"index.php?setpref=englishcards\">use english cards</a> <br />";
34
35   echo "</div>\n";
36
37   return;
38 }
39
40 function output_ask_for_new_game($playerA,$playerB,$playerC,$playerD,$oldgameid)
41 {
42   global $RULES;
43
44   echo "Do you want to continue playing?(This will start a new game, with the next person as dealer.)\n";
45   echo "<form action=\"index.php\" method=\"post\">\n";
46   echo "  <input type=\"hidden\" name=\"PlayerA\" value=\"$playerA\" />\n";
47   echo "  <input type=\"hidden\" name=\"PlayerB\" value=\"$playerB\" />\n";
48   echo "  <input type=\"hidden\" name=\"PlayerC\" value=\"$playerC\" />\n";
49   echo "  <input type=\"hidden\" name=\"PlayerD\" value=\"$playerD\" />\n";
50   echo "  <input type=\"hidden\" name=\"dullen\"  value=\"".$RULES["dullen"]."\" />\n";
51   echo "  <input type=\"hidden\" name=\"schweinchen\" value=\"".$RULES["schweinchen"]."\" />\n";
52   echo "  <input type=\"hidden\" name=\"call\" value=\"".$RULES["call"]."\" />\n";
53   echo "  <input type=\"hidden\" name=\"followup\" value=\"$oldgameid\" />\n";
54   echo "  <input type=\"submit\" value=\"keep playing\" />\n";
55   echo "</form>\n";
56
57   return;
58 }
59
60 function output_form_for_new_game($names)
61 {
62 ?>
63     <h2> Players </h2>
64     <p>Please select four players (or use the randomly pre-selected names)</p>
65        <form action="index.php" method="post">
66 <?php
67     /* ask for player names */
68   foreach( array("PlayerA","PlayerB","PlayerC","PlayerD") as $player)
69   {
70     srand((float) microtime() * 10000000);
71     $randkey = array_rand($names);
72     $rand = $names[$randkey];
73     echo "    Name:  <select name=\"$player\" size=\"1\" />  \n";
74     foreach($names as $name)
75     {
76       if($name==$rand)
77         {
78           echo "     <option selected=\"selected\">$name</option>\n";
79         }
80       else
81         echo "     <option>$name</option>\n";
82     }
83     echo "  </select>\n";
84    }
85 ?>   
86    <h2> Rules </h2> 
87       <p> Some areas are grayed out which means that the rule is not implemented yet and therefore cannot be selected </p>
88       <p> ten of hearts: 
89          <ul>
90          <li> <input type="radio" name="dullen" value="none" /> just normal non-trump  </li>
91          <li> <input type="radio" name="dullen" value="firstwins" /> first ten of hearts wins the trick </li>
92          <li> <input type="radio" name="dullen" value="secondwins" checked="checked" /> second ten of hearts wins the trick </li>
93          </ul>
94       </p>
95       <p> schweinchen (both foxes), only in normal games or silent solos: 
96         <ul>
97         <li> <input type="radio" name="schweinchen" value="none" checked="checked" /> none </li>
98         <li> <input type="radio" name="schweinchen" value="both" /> 
99               both become highest trump (automatic call at beginning of the game)
100         </li>
101         <li> <input type="radio" name="schweinchen" value="second" /> 
102               first one normal, second one becomes highest (call during the game) </li>
103         <li> <input type="radio" name="schweinchen" value="secondaftercall"  disabled="disabled" /> 
104       second one become highest only in case re/contra was announced (not working yet)
105         </li>
106         </ul>
107       </p>
108       <p> Call Re/Contra, etc.: 
109         <ul>
110            <li><input type="radio" name="call" value="1st-own-card" checked="checked" />
111                 Can call re/contra on the first <strong>own</strong> card played, 90 on the second, etc.</li>
112            <li><input type="radio" name="call" value="5th-card" /> 
113                 Can call re/contra until 5th card is played, 90 until 9th card is played, etc.</li>
114            <li><input type="radio" name="call" value="9-cards"  /> 
115                 Can call re/contra until 5th card is played, 90 if player still has 9 cards, etc.</li>
116         </ul>
117       </p>      
118    <input type="submit" value="start game" />
119  </form>
120 <?php
121 }
122
123 function display_card($card,$dir="english")
124 {
125   /* cards are only availabl for the odd values, e.g. 1.png, 3.png, ... 
126    * convert even cards to the matching odd value */
127
128   if( $card/2 - (int)($card/2) == 0.5)
129     echo "<img src=\"cards/".$dir."/".$card.".png\"  alt=\"".DB_get_card_name($card)."\" />\n";
130   else
131     echo "<img src=\"cards/".$dir."/".($card-1).".png\"  alt=\"".DB_get_card_name($card-1)."\" />\n";
132
133   return;
134 }
135
136 function display_link_card($card,$dir="english",$type="card")
137 {
138   if( $card/2 - (int)($card/2) == 0.5)
139     echo "<div class=\"cardinput\"><input type=\"radio\" name=\"".$type."\" value=\"".$card."\" /><img src=\"cards/".$dir."/".$card.".png\" alt=\"".DB_get_card_name($card)."\" /></div>\n";
140   else
141     echo "<div class=\"cardinput\" ><input type=\"radio\" name=\"".$type."\" value=\"".$card."\" /><img src=\"cards/".$dir."/".($card-1).".png\" alt=\"".DB_get_card_name($card-1)."\" /></div>\n";
142   return;
143 }
144
145 function output_check_for_sickness($me,$mycards)
146 {
147  ?>
148   <form action="index.php" method="post">
149
150     do you want to play solo? 
151     <select name="solo" size="1">
152       <option selected="selected">No</option>
153       <option>trumpless</option>
154       <option>trump</option>
155       <option>queen</option>
156       <option>jack</option>
157       <option>club</option>
158       <option>spade</option>
159       <option>heart</option>
160     </select>     
161     <br />
162
163  <?php   
164       
165   echo "Wedding?";
166   if(check_wedding($mycards))
167      {
168        echo " yes<input type=\"radio\" name=\"wedding\" value=\"yes\" checked=\"checked\" />";
169        echo " no <input type=\"radio\" name=\"wedding\" value=\"no\" /> <br />\n";
170      }
171    else
172      {
173        echo " no <input type=\"hidden\" name=\"wedding\" value=\"no\" /> <br />\n";
174      };
175
176   echo "Do you have poverty?";
177   if(count_trump($mycards)<4)
178     {
179       echo " yes<input type=\"radio\" name=\"poverty\" value=\"yes\" checked=\"checked\" />";
180       echo " no <input type=\"radio\" name=\"poverty\" value=\"no\" /> <br />\n";
181     }
182   else
183     {
184       echo " no <input type=\"hidden\" name=\"poverty\" value=\"no\" /> <br />\n";
185     };
186
187    echo "Do you have too many nines?";
188   if(count_nines($mycards)>4)
189      {
190        echo " yes<input type=\"radio\" name=\"nines\" value=\"yes\" checked=\"checked\" />";
191        echo " no <input type=\"radio\" name=\"nines\" value=\"no\" /> <br />\n";
192      }
193    else
194      {
195        echo " no <input type=\"hidden\" name=\"nines\" value=\"no\" /> <br />\n";
196      };
197
198    echo "<input type=\"hidden\" name=\"me\" value=\"$me\" />\n";
199    echo "<input type=\"submit\" value=\"count me in\" />\n";
200
201    echo "</form>\n";
202
203   return;
204 }
205
206 function output_form_calls($me)
207 {
208   if( can_call(120,$me) )
209     echo " re/contra (120):".
210       " <input type=\"radio\" name=\"call120\" value=\"yes\" /> <br />";
211   if( can_call(90,$me) )
212     echo " 90:".
213       " <input type=\"radio\" name=\"call90\" value=\"yes\" /> <br />";
214   if( can_call(60,$me) )
215     echo " 60:".
216       " <input type=\"radio\" name=\"call60\" value=\"yes\" /> ";
217   if( can_call(30,$me) )
218     echo " 30:".
219       " <input type=\"radio\" name=\"call30\" value=\"yes\" /> ";
220   if( can_call(0,$me) )
221     echo " 0:".
222       " <input type=\"radio\" name=\"call0\" value=\"yes\" /> ".
223       " no call:".
224       " <input type=\"radio\" name=\"call0\" value=\"no\" /> ";
225 }
226
227
228 function output_check_want_to_play($me)
229 {
230    ?>
231  <form action="index.php" method="post">
232    Do you want to play a game of DoKo?
233    yes<input type="radio" name="in" value="yes" />
234    no<input type="radio" name="in" value="no" /> <br />
235 <?php   
236   echo "<input type=\"hidden\" name=\"me\" value=\"$me\" />\n";
237   echo "\n";
238   echo "<input type=\"submit\" value=\"count me in\" />\n";
239   echo " </form>\n";
240
241   return;
242 }
243
244 function output_home_page($pre,$game,$done,$avgtime)
245 {
246 ?>
247     <p> If you want to play a game of Doppelkopf, you found the right place ;) </p>
248 <?php
249     if($pre == 0)
250       echo "<p> At the moment there are no games that are being started ";
251     else if($pre==1)
252       echo "<p> At the moment there is one games that is being started ";
253     else
254       echo "<p> At the moment there are $pre games that are being started ";
255
256     echo "and ";
257
258     if($game==0)
259       echo "zero games that are ongoing. ";
260     else if($game==1)   
261       echo "one game that is ongoing. ";
262     else 
263       echo "$game games that are ongoing. ";
264
265     echo "<br />\n";
266
267     if($done==0)
268       echo "No game has been completed on this server. </p>";
269     else if($done==1)
270       echo "One game has been completed on this server. </p>";
271     else
272       echo "$done games have been completed on this server. Average time of a game: $avgtime days</p>";
273 ?>
274
275     <p> Please <a href="register.php">register</a>, in case you haven't done that yet  <br />
276         or login with you email-address or name and password here:
277     </p>
278         <form action="index.php" method="post">
279           <fieldset>
280             <legend>Login</legend>
281              <table>
282               <tr>
283                  <td><label for="email">Email:</label></td>
284                  <td><input type="text" id="email" name="email" size="20" maxlength="30" /> </td>
285               </tr><tr>
286                  <td><label for="password">Password:</label></td>
287                  <td><input type="password" id="password" name="password" size="20" maxlength="30" /></td>
288               </tr><tr>
289                 <td> <input type="submit" class="submitbutton" name="login" value="login" /></td>
290                 <td> <input type="submit" class="submitbutton" name="forgot" value="Forgot your password?" /></td>
291               </tr>
292              </table>
293           </fieldset>
294         </form>
295
296 <?php
297  return;
298 }
299
300 function output_header()
301 {
302    global $REV;
303 ?>
304 <!DOCTYPE html PUBLIC
305     "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"
306     "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">
307 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
308   <head>
309      <title>e-Doko</title>
310      <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" />
311      <link rel="stylesheet" type="text/css" href="css/standard.css" />  
312      <script type="text/javascript">
313        function hl(num) {
314          if(document.getElementById){
315            var i;
316            for(i=1;i<13;i++){
317              if(document.getElementById("trick"+i))
318                document.getElementById("trick"+i).style.display = 'none';
319            }
320            document.getElementById("trick"+num).style.display = 'block';
321          }
322        }
323        function high_last(){
324          if(document.getElementById){
325            var i;
326            for(i=12;i>0;i--) {
327              if(document.getElementById("trick"+i))
328                {
329                  hl(i);
330                  break;
331                }
332            }
333          }
334        }
335      </script>
336   </head>
337 <body onload="high_last();">
338 <div class="header">
339 <h1> Welcome to E-Doko <sup style="color:#888;">(beta)</sup> </h1>
340 </div>
341
342 <?php
343   return;
344 }
345
346 function output_footer()
347 {
348   global $REV,$PREF;
349
350   echo "<div class=\"footer\">\n";
351   echo "<p class=\"left\"> copyright 2006-2007 Arun Persaud <br />\n".
352     "Verwendung der [deutschen] Kartenbilder mit Genehmigung <br />der Spielkartenfabrik Altenburg GmbH,(c) ASS Altenburger <br />".
353     "- ASS Altenburger Spielkarten - Spielkartenfabrik Altenburg GmbH <br />".
354     "a Carta Mundi Company Email: info@spielkarten.com Internet: www.spielkarten.com</p>\n";
355  echo "<p class=\"right\"> See the latest changes <a href=\"http://nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=summary\">".
356     "via git </a> <br />or download the source via <br />'git clone http://nubati.net/git/e-DoKo.git' <br />".
357     "<a href=\"http://www.dreamhost.com/green.cgi\">".
358     "<img  border=\"0\" alt=\"Green Web Hosting! This site hosted by DreamHost.\"".
359     "src=\"https://secure.newdream.net/green1.gif\" height=\"32\" width=\"100\" /></a>".
360     "</p> \n";
361   echo "\n";
362   echo "</div>\n";
363
364   echo "</body>\n";
365   echo "</html>\n";
366
367   return;
368 }
369
370 function output_status($name)
371 {
372   echo "<div class=\"status\">\n";
373   echo $name;
374   echo " <a href=\"index.php?logout=1\">logout</a>\n";
375   echo "</div>";
376
377   return;
378 }
379
380
381 function output_password_recovery($email,$password)
382 {
383 ?>
384    <form action="index.php" method="post">
385 <?php
386   echo "  <input type=\"hidden\" name=\"email\" value=\"".$email."\" />\n";
387   echo "  <input type=\"hidden\" name=\"password\" value=\"".$password."\" />\n";
388   echo "  <input type=\"hidden\" name=\"passwd\"  value=\"set\" />\n";
389 ?>    
390      <fieldset>
391        <legend>Password recovery</legend>
392         <table>
393          <tr>
394             <td><label for="email">Old password:</label></td>
395             <td><input type="password" id="password0" name="password0" size="20" maxlength="30" /> </td>
396          </tr><tr>
397             <td><label for="password">New password:</label></td>
398             <td><input type="password" id="password1" name="password1" size="20" maxlength="30" /></td>
399          </tr><tr>
400             <td><label for="password">Retype:</label></td>
401             <td><input type="password" id="password2" name="password2" size="20" maxlength="30" /></td>
402          </tr><tr>
403            <td></td>
404            <td> <input type="submit" class="submitbutton" name="passwd" value="set" /></td>
405          </tr>
406         </table>
407      </fieldset>
408    </form>
409
410 <?php
411 }
412 ?>