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