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