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