89aedff9d802509517a1ba412e3a40b42716d779
[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_form_calls($me)
244 {
245   if( can_call(120,$me) )
246     echo " re/contra (120):".
247       " <input type=\"radio\" name=\"call120\" value=\"yes\" /> <br />";
248   if( can_call(90,$me) )
249     echo " 90:".
250       " <input type=\"radio\" name=\"call90\" value=\"yes\" /> <br />";
251   if( can_call(60,$me) )
252     echo " 60:".
253       " <input type=\"radio\" name=\"call60\" value=\"yes\" /> ";
254   if( can_call(30,$me) )
255     echo " 30:".
256       " <input type=\"radio\" name=\"call30\" value=\"yes\" /> ";
257   if( can_call(0,$me) )
258     echo " 0:".
259       " <input type=\"radio\" name=\"call0\" value=\"yes\" /> ".
260       " no call:".
261       " <input type=\"radio\" name=\"call0\" value=\"no\" /> ";
262 }
263
264
265 function output_check_want_to_play($me)
266 {
267    ?>
268  <form action="index.php" method="post">
269    Do you want to play a game of DoKo?
270    yes<input type="radio" name="in" value="yes" />
271    no<input type="radio" name="in" value="no" /> <br />
272 <?php   
273   echo "<input type=\"hidden\" name=\"me\" value=\"$me\" />\n";
274   echo "\n";
275   echo "<input type=\"submit\" value=\"count me in\" />\n";
276   echo " </form>\n";
277
278   return;
279 }
280
281 function output_home_page($pre,$game,$done,$avgtime)
282 {
283 ?>
284     <p> If you want to play a game of Doppelkopf, you found the right place ;) </p>
285 <?php
286     if($pre == 0)
287       echo "<p> At the moment there are no games that are being started ";
288     else if($pre==1)
289       echo "<p> At the moment there is one games that is being started ";
290     else
291       echo "<p> At the moment there are $pre games that are being started ";
292
293     echo "and ";
294
295     if($game==0)
296       echo "zero games that are ongoing. ";
297     else if($game==1)   
298       echo "one game that is ongoing. ";
299     else 
300       echo "$game games that are ongoing. ";
301
302     echo "<br />\n";
303
304     if($done==0)
305       echo "No game has been completed on this server. </p>";
306     else if($done==1)
307       echo "One game has been completed on this server. </p>";
308     else
309       echo "$done games have been completed on this server. Average time of a game: $avgtime days</p>";
310 ?>
311
312     <p> Please <a href="index.php?register">register</a>, in case you haven't done that yet  <br />
313         or login with you email-address or name and password here:
314     </p>
315         <form action="index.php" method="post">
316           <fieldset>
317             <legend>Login</legend>
318              <table>
319               <tr>
320                  <td><label for="email">Email:</label></td>
321                  <td><input type="text" id="email" name="email" size="20" maxlength="30" /> </td>
322               </tr><tr>
323                  <td><label for="password">Password:</label></td>
324                  <td><input type="password" id="password" name="password" size="20" maxlength="30" /></td>
325               </tr><tr>
326                 <td> <input type="submit" class="submitbutton" name="login" value="login" /></td>
327                 <td> <input type="submit" class="submitbutton" name="forgot" value="Forgot your password?" /></td>
328               </tr>
329              </table>
330           </fieldset>
331         </form>
332
333 <?php
334  return;
335 }
336
337 function output_header()
338 {
339    global $REV;
340 ?>
341 <!DOCTYPE html PUBLIC
342     "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"
343     "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">
344 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
345   <head>
346      <title>e-Doko</title>
347      <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" />
348      <link rel="stylesheet" type="text/css" href="css/standard.css" />  
349      <script type="text/javascript">
350        function hl(num) {
351          if(document.getElementById){
352            var i;
353            for(i=1;i<13;i++){
354              if(document.getElementById("trick"+i))
355                document.getElementById("trick"+i).style.display = 'none';
356            }
357            document.getElementById("trick"+num).style.display = 'block';
358          }
359        }
360        function high_last(){
361          if(document.getElementById){
362            var i;
363            for(i=12;i>0;i--) {
364              if(document.getElementById("trick"+i))
365                {
366                  hl(i);
367                  break;
368                }
369            }
370          }
371        }
372      </script>
373   </head>
374 <body onload="high_last();">
375 <div class="header">
376 <h1> Welcome to E-Doko <sup style="color:#888;">(beta)</sup> </h1>
377 </div>
378
379 <?php
380   return;
381 }
382
383 function output_footer()
384 {
385   global $REV,$PREF;
386
387   echo "<div class=\"footer\">\n";
388   echo "<p class=\"left\"> copyright 2006-2007 Arun Persaud <br />\n".
389     "Verwendung der [deutschen] Kartenbilder mit Genehmigung <br />der Spielkartenfabrik Altenburg GmbH,(c) ASS Altenburger <br />".
390     "- ASS Altenburger Spielkarten - Spielkartenfabrik Altenburg GmbH <br />".
391     "a Carta Mundi Company Email: info@spielkarten.com Internet: www.spielkarten.com</p>\n";
392   echo "<p class=\"right\"> Revision: $REV; <br /><a href=\"http://svn.nubati.net/emaildoko/trunk/\">".
393     "http://svn.nubati.net/emaildoko/trunk/</a> <br />".
394     "<a href=\"http://www.dreamhost.com/green.cgi\">".
395     "<img  border=\"0\" alt=\"Green Web Hosting! This site hosted by DreamHost.\"".
396     "src=\"https://secure.newdream.net/green1.gif\" height=\"32\" width=\"100\" /></a>".
397     "</p> \n";
398   echo "\n";
399   echo "</div>\n";
400
401   echo "</body>\n";
402   echo "</html>\n";
403
404   return;
405 }
406
407 function output_status($name)
408 {
409   echo "<div class=\"status\">\n";
410   echo $name;
411   echo " <a href=\"index.php?logout=1\">logout</a>\n";
412   echo "</div>";
413
414   return;
415 }
416
417
418 function output_password_recovery($email,$password)
419 {
420 ?>
421    <form action="index.php" method="post">
422 <?php
423   echo "  <input type=\"hidden\" name=\"email\" value=\"".$email."\" />\n";
424   echo "  <input type=\"hidden\" name=\"password\" value=\"".$password."\" />\n";
425   echo "  <input type=\"hidden\" name=\"passwd\"  value=\"set\" />\n";
426 ?>    
427      <fieldset>
428        <legend>Password recovery</legend>
429         <table>
430          <tr>
431             <td><label for="email">Old password:</label></td>
432             <td><input type="password" id="password0" name="password0" size="20" maxlength="30" /> </td>
433          </tr><tr>
434             <td><label for="password">New password:</label></td>
435             <td><input type="password" id="password1" name="password1" size="20" maxlength="30" /></td>
436          </tr><tr>
437             <td><label for="password">Retype:</label></td>
438             <td><input type="password" id="password2" name="password2" size="20" maxlength="30" /></td>
439          </tr><tr>
440            <td></td>
441            <td> <input type="submit" class="submitbutton" name="passwd" value="set" /></td>
442          </tr>
443         </table>
444      </fieldset>
445    </form>
446
447 <?php
448 }
449 ?>