edd23fb3db094e89b3f78a476ab82624394070c7
[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     <p> At the moment there are <?php echo "$pre";?> games that are being started and <?php echo"$game"; ?> games that are ongoing. 
271     <?php echo"$done";?> games have been completed on this server. </p>
272     <p> Please <a href="index.php?register">register</a>, in case you haven't done that yet  <br />
273         or login with you email-address or name and password here:
274     </p>
275         <form action="index.php" method="post">
276           <fieldset>
277             <legend>Login</legend>
278              <table>
279               <tr>
280                  <td><label for="email">Email:</label></td>
281                  <td><input type="text" id="email" name="email" size="20" maxlength="30" /> </td>
282               </tr><tr>
283                  <td><label for="password">Password:</label></td>
284                  <td><input type="password" id="password" name="password" size="20" maxlength="30" /></td>
285               </tr><tr>
286                 <td> <input type="submit" class="submitbutton" name="login" value="login" /></td>
287                 <td> <input type="submit" class="submitbutton" name="forgot" value="Forgot your password?" /></td>
288               </tr>
289              </table>
290           </fieldset>
291         </form>
292
293 <?php
294  return;
295 }
296
297 function output_header()
298 {
299    global $REV;
300 ?>
301 <!DOCTYPE html PUBLIC
302     "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"
303     "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">
304 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
305   <head>
306      <title>e-Doko</title>
307      <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" />
308      <link rel="stylesheet" type="text/css" href="css/standard.css" />  
309      <script type="text/javascript">
310        function hl(num) {
311          if(document.getElementById){
312            var i;
313            for(i=1;i<13;i++){
314              if(document.getElementById("trick"+i))
315                document.getElementById("trick"+i).style.display = 'none';
316            }
317            document.getElementById("trick"+num).style.display = 'block';
318          }
319        }
320        function high_last(){
321          if(document.getElementById){
322            var i;
323            for(i=12;i>0;i--) {
324              if(document.getElementById("trick"+i))
325                {
326                  hl(i);
327                  break;
328                }
329            }
330          }
331        }
332      </script>
333   </head>
334 <body onload="high_last();">
335 <div class="header">
336 <h1> Welcome to E-Doko <sup style="color:#888;">(beta)</sup> </h1>
337 </div>
338
339 <?php
340   return;
341 }
342
343
344
345 function output_footer()
346 {
347   global $REV,$PREF;
348
349   echo "<div class=\"footer\">\n";
350   echo "<p class=\"left\"> copyright 2006-2007 Arun Persaud <br />\n".
351     "Verwendung der [deutschen] Kartenbilder mit Genehmigung der Spielkartenfabrik Altenburg GmbH,(c) ASS Altenburger <br />".
352     "- ASS Altenburger Spielkarten - Spielkartenfabrik Altenburg GmbH <br />".
353     "a Carta Mundi Company Email: info@spielkarten.com Internet: www.spielkarten.com</p>\n";
354   echo "<p class=\"right\"> Revision: $REV; <a href=\"http://svn.nubati.net/emaildoko/trunk/\">".
355     "http://svn.nubati.net/emaildoko/trunk/</a></p> \n";
356   echo "\n";
357   echo "</div>\n";
358
359   echo "</body>\n";
360   echo "</html>\n";
361
362   return;
363 }
364 ?>