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