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