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