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