players should get emails again, if it is there turn
[e-DoKo.git] / index.php
1 <!DOCTYPE html PUBLIC
2     "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"
3     "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
5   <head>
6      <title>e-Doko</title>
7      <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" />
8      <link rel="stylesheet" type="text/css" href="standard.css" />      
9      <script type="text/javascript">
10        function hl(num) {
11          if(document.getElementById){
12            var i;
13            for(i=1;i<13;i++){
14              if(document.getElementById("trick"+i))
15                document.getElementById("trick"+i).style.display = 'none';
16            }
17            document.getElementById("trick"+num).style.display = 'block';
18          }
19        }
20        function high_last(){
21          if(document.getElementById){
22            var i;
23            for(i=12;i>0;i--) {
24              if(document.getElementById("trick"+i))
25                {
26                  hl(i);
27                  break;
28                }
29            }
30          }
31        }
32      </script>
33   </head>
34 <body onload="high_last();">
35 <div class="header">
36 <h1> Welcome to E-Doko </h1>
37 </div>
38
39 <?php
40 error_reporting(E_ALL);
41
42 include_once("config.php");     
43 include_once("functions.php");
44 include_once("db.php");
45
46 DB_open();
47
48 /* end header */
49
50 /*****************  M A I N **************************/
51
52 /* check if we want to start a new game */
53 if(isset($_REQUEST["new"]))
54   {
55     output_form_for_new_game();
56   } 
57 /* end start a new game */
58
59 /*check if everything is ready to set up a new game */
60 else if( isset($_REQUEST["PlayerA"]) && 
61     isset($_REQUEST["PlayerB"]) && 
62     isset($_REQUEST["PlayerC"]) && 
63     isset($_REQUEST["PlayerD"]) )
64   {
65     $PlayerA = $_REQUEST["PlayerA"];
66     $PlayerB = $_REQUEST["PlayerB"];
67     $PlayerC = $_REQUEST["PlayerC"];
68     $PlayerD = $_REQUEST["PlayerD"];
69     
70     $EmailA  = DB_get_email_by_name($PlayerA);
71     $EmailB  = DB_get_email_by_name($PlayerB);
72     $EmailC  = DB_get_email_by_name($PlayerC);
73     $EmailD  = DB_get_email_by_name($PlayerD);
74     
75     if($EmailA=="" || $EmailB=="" || $EmailC=="" || $EmailD=="")
76       {
77         echo "couldn't find one of the names, please start a new game";
78         exit();
79       }
80     
81     $useridA  = DB_get_userid_by_name($PlayerA);
82     $useridB  = DB_get_userid_by_name($PlayerB);
83     $useridC  = DB_get_userid_by_name($PlayerC);
84     $useridD  = DB_get_userid_by_name($PlayerD);
85     
86     /* create random numbers */
87     $randomNR       = create_array_of_random_numbers();
88     $randomNRstring = join(":",$randomNR);
89     
90     /* create game */
91     $followup = NULL;
92     if(isset($_REQUEST["followup"])) 
93       {
94         $followup= $_REQUEST["followup"];
95         mysql_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', NULL, NULL,'pre','$followup' ,NULL)");
96       }
97     else
98       mysql_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', NULL, NULL,'pre', NULL ,NULL)");
99     $game_id = mysql_insert_id();
100     
101     /* create hash */
102     $hashA = md5("AGameOfDoko".$game_id.$PlayerA.$EmailA);
103     $hashB = md5("AGameOfDoko".$game_id.$PlayerB.$EmailB);
104     $hashC = md5("AGameOfDoko".$game_id.$PlayerC.$EmailC);
105     $hashD = md5("AGameOfDoko".$game_id.$PlayerD.$EmailD);
106     
107     /* create hands */
108     mysql_query("INSERT INTO Hand VALUES (NULL,".DB_quote_smart($game_id).",".DB_quote_smart($useridA).
109                 ", ".DB_quote_smart($hashA).", 'start','1',NULL,NULL,NULL,'false','false',NULL)");
110     $hand_idA = mysql_insert_id();                                                             
111     mysql_query("INSERT INTO Hand VALUES (NULL,".DB_quote_smart($game_id).",".DB_quote_smart($useridB).
112                 ", ".DB_quote_smart($hashB).", 'start','2',NULL,NULL,NULL,'false','false',NULL)");
113     $hand_idB = mysql_insert_id();                                                             
114     mysql_query("INSERT INTO Hand VALUES (NULL,".DB_quote_smart($game_id).",".DB_quote_smart($useridC).
115                 ", ".DB_quote_smart($hashC).", 'start','3',NULL,NULL,NULL,'false','false',NULL)");
116     $hand_idC = mysql_insert_id();                                                             
117     mysql_query("INSERT INTO Hand VALUES (NULL,".DB_quote_smart($game_id).",".DB_quote_smart($useridD).
118                 ", ".DB_quote_smart($hashD).", 'start','4',NULL,NULL,NULL,'false','false',NULL)");
119     $hand_idD = mysql_insert_id();
120     
121     /* save cards */
122     for($i=0;$i<12;$i++)
123       mysql_query("INSERT INTO Hand_Card VALUES (NULL, '$hand_idA', '".$randomNR[$i]."', 'false')");
124     for($i=12;$i<24;$i++)
125       mysql_query("INSERT INTO Hand_Card VALUES (NULL, '$hand_idB', '".$randomNR[$i]."', 'false')");
126     for($i=24;$i<36;$i++)
127       mysql_query("INSERT INTO Hand_Card VALUES (NULL, '$hand_idC', '".$randomNR[$i]."', 'false')");
128     for($i=36;$i<48;$i++)
129       mysql_query("INSERT INTO Hand_Card VALUES (NULL, '$hand_idD', '".$randomNR[$i]."', 'false')");
130
131     /* send out email, TODO: check for error with email */
132     $message = "\n".
133       "you are invited to play a game of DoKo (that is to debug the program ;).\n".
134       "Place comments and bug reports here:\n".
135       "http://wiki.nubati.net/index.php?title=EmailDoko\n\n".
136       "The whole round would consist of the following players:\n".
137       "$PlayerA\n".
138       "$PlayerB\n".
139       "$PlayerC\n".
140       "$PlayerD\n\n".
141       "If you want to join this game, please follow this link:\n\n".
142       " ".$host."?me=";
143     
144     mymail($EmailA,"You are invited to a game of DoKo","Hello $PlayerA,\n".$message.$hashA);
145     mymail($EmailB,"You are invited to a game of DoKo","Hello $PlayerB,\n".$message.$hashB);
146     mymail($EmailC,"You are invited to a game of DoKo","Hello $PlayerC,\n".$message.$hashC);
147     mymail($EmailD,"You are invited to a game of DoKo","Hello $PlayerD,\n".$message.$hashD);
148         
149   }    
150 /* end set up a new game */
151
152 else if(isset($_REQUEST["me"]))
153   {
154      /* handle request from one specifig player,
155       * the hash is set on a per game base, so first just handle this game
156       * perhaps also show links to other games in a sidebar
157       */
158     
159     $me = $_REQUEST["me"];
160     
161     $myid = DB_get_userid_by_hash($me);
162     if(!$myid)
163       {
164         echo "Can't find you in the database, please check the url.<br />\n";
165         echo "perhaps the game has been cancled.";
166         exit();
167       }
168     
169     DB_update_user_timestamp($myid);
170
171     /* get some information from the DB */
172     $gameid   = DB_get_gameid_by_hash($me);
173     $myname   = DB_get_name_by_hash($me);
174     $mystatus = DB_get_status_by_hash($me);
175     
176     switch($mystatus)
177       {
178       case 'start':
179         check_want_to_play($me);
180         DB_set_hand_status_by_hash($me,'init');
181         break;
182       case 'init':
183         if( !isset($_REQUEST["in"]) || !isset($_REQUEST["update"]))
184           {
185             DB_set_hand_status_by_hash($me,'start');
186             echo "you need to answer both question";
187           }
188         else
189           {
190             if($_REQUEST["in"] == "no")
191               {
192                 echo "TODO: email everyone that the game has been canceled.<br />";
193                  /*something like
194                  for($i=0;$i<4;$i++)
195                    {
196                      $message = "Hello ".$player[$hash[$i]]["name"].",\n\n".
197                        "the game has been canceled due to the request of one of the players.\n";
198                      mymail($player[$hash[$i]]["email"],"[DoKo-Debug] the game has been canceled",$message); 
199                    }
200                  */
201                 DB_cancel_game($me);
202               }
203             else
204               {
205                 echo "thanks for joining the game... please scroll down";
206                 echo "TODO: make this page nicer<br />";
207                 echo "TODO: set card pref<br />";
208                 
209                 $mycards = DB_get_hand($me);
210                 sort($mycards);
211                 echo "<p class=\"mycards\">your cards are: <br />\n";
212                 foreach($mycards as $card) 
213                   display_card($card);
214                 echo "</p>\n";   
215                 
216                 check_for_sickness($me,$mycards);
217                 
218                 DB_set_hand_status_by_hash($me,'check');
219               }
220            }
221         break;
222         
223       case 'check':
224         echo "no checking at the moment... you need to play a normal game. At the moment you need to reload this page to finish the setup.";
225         if(!isset($_REQUEST["solo"])    || 
226            !isset($_REQUEST["wedding"]) ||
227            !isset($_REQUEST["poverty"]) ||
228            !isset($_REQUEST["nines"]) )
229           {
230             DB_set_hand_status_by_hash($me,'init');
231             /* problem: by setting it back to init, variables "in" and "update" are 
232              * not set, so the player will be send back to the start, after seeing his hand
233              */
234             echo "you need to fill out the form";
235           }
236         else
237           {
238             if( $_REQUEST["solo"]!="No")
239               {
240                 DB_set_solo_by_hash($me,$_REQUEST["solo"]);
241                 DB_set_sickness_by_hash($me,"solo");
242               }
243             else if($_REQUEST["wedding"] == "yes")
244               {
245                 echo "wedding was chosen<br />\n";
246                 DB_set_sickness_by_hash($me,"wedding");
247               }
248             else if($_REQUEST["poverty"] == "yes")
249               {
250                 echo "poverty was chosen<br />\n";
251                 DB_set_sickness_by_hash($me,"poverty");
252               }
253             else if($_REQUEST["nines"] == "yes")
254               {
255                 echo "nines was chosen<br />\n";
256                  DB_set_sickness_by_hash($me,"nines");
257               }
258           }
259         DB_set_hand_status_by_hash($me,'poverty');
260         
261         /* check all players and set game to final result, e.g. solo, wedding, povert, redeal */
262         
263         /* reset solo, etc from players who did say something, but it didn't matter? */
264         break;
265       case 'poverty':
266         echo "<br />poverty not handeled at the moment... you need to play a normal game<br />";
267         
268         /* only set this after all poverty, etc. are handeled*/
269         DB_set_hand_status_by_hash($me,'play');
270
271         /* check if the game can start  */
272         $userids = DB_get_all_userid_by_gameid($gameid);
273         $done=1;
274         foreach($userids as $user)
275           if(DB_get_hand_status_by_userid($user)!='play')
276             $done=0;
277
278         if($done)
279           DB_set_game_status_by_gameid($gameid,'play');
280
281         break;
282       case 'play':
283       case 'gameover': /* gameover and play, so that the tricks are visible for both */
284         display_news();
285         display_status();
286
287         $gamestatus = DB_get_game_status_by_gameid($gameid);
288         if($gamestatus == 'pre')
289           {
290             echo "you need to wait for the others... <br />";
291             break;
292           }
293         /* get trick ids */
294         $result = mysql_query("SELECT Hand_Card.card_id as card,".
295                               "       User.fullname as name,".
296                               "       Hand.position as position,".
297                               "       Play.sequence as sequence, ".
298                               "       Hand.hash     as hash,     ".
299                               "       Trick.id, ".
300                               "       Comment.comment ".
301                               "FROM Trick ".
302                               "LEFT JOIN Play ON Trick.id=Play.trick_id ".
303                               "LEFT JOIN Hand_Card ON Play.hand_card_id=Hand_Card.id ".
304                               "LEFT JOIN Hand ON Hand_Card.hand_id=Hand.id ".
305                               "LEFT JOIN User ON User.id=Hand.user_id ".
306                               "LEFT JOIN Comment ON Play.id=Comment.play_id ".
307                               "WHERE Trick.game_id='".$gameid."' ".
308                               "ORDER BY Trick.id,sequence ASC");
309         
310         
311         $trickNR = 1;
312         
313         $lasttrick = DB_get_max_trickid($gameid);
314         
315         $play = array(); /* needed to calculate winner later  */
316         $seq  = 1;          
317         $pos  = 0;
318         
319         echo "\n<ul class=\"oldtrick\">\n";
320         echo "  <li> Hello $myname!   History: </li>\n";
321         
322         while($r = mysql_fetch_array($result,MYSQL_NUM))
323           {
324             $seq     = $r[3];
325             $pos     = $r[2];
326             $trick   = $r[5];
327             $comment = $r[6];
328             
329             if($trick!=$lasttrick && $seq==1)
330               {
331                 /* start of an old trick? */
332                 echo "  <li onclick=\"hl('$trickNR');\"><a href=\"#\">Trick $trickNR</a>\n".
333                   "    <div class=\"table\" id=\"trick".$trickNR."\">\n".
334                   "      <img class=\"table\" src=\"pics/table".($pos-1).".png\" alt=\"table\" />\n";
335               }
336             else if($trick==$lasttrick && $seq==1)
337               {
338                 /* start of a last trick? */
339                 echo "  <li onclick=\"hl('$trickNR');\"><a href=\"#\">Current Trick</a>\n".
340                   "    <div class=\"table\" id=\"trick".$trickNR."\">\n".
341                   "      <img class=\"table\" src=\"pics/table".($pos-1).".png\" alt=\"table\" />";
342               }
343             
344             /* display card */
345             echo "      <div class=\"card".($pos-1)."\">\n";
346             
347             $play[$pos]=$r[0];
348             
349             if($comment!="")
350               echo "        <span class=\"comment\">";
351             else
352               echo "        <span>";
353             
354             /* print name */
355             echo $r[1];
356             
357             /* check for comment */
358             if($comment!="")
359               echo "<span>".$comment."</span>";
360             echo "</span>\n        ";
361             
362             display_card($r[0]);
363             
364             echo "      </div>\n"; /* end div card */
365             
366             /* end of trick? */
367             if($seq==4)
368               {
369                 $trickNR++;
370                 echo "    </div>\n  </li>\n";  /* end div table, end li table */
371               }
372           }
373         if($seq!=4) 
374           echo "    </div>\n  </li>\n";  /* end div table, end li table */
375         
376         echo "</ul>\n";
377         
378         /* whos turn is it? */
379         if($seq==4)
380           {
381              $winner = get_winner($play); /* returns the position */
382              $next = $winner;
383           }
384         else
385           {
386             $next = $pos+1;
387           }
388         if($next==5) $next=1;
389         
390         /* my turn?, display cards as links, ask for comments*/
391         if(DB_get_pos_by_hash($me) == $next)
392           $myturn = 1;
393         else
394           $myturn = 0;
395
396         /* do we want to play a card? */
397         if(isset($_REQUEST["card"]) && $myturn)
398           {
399             $card   = $_REQUEST["card"];
400             $handid = DB_get_handid_by_hash($me); 
401             
402             /* check if we have card and that we haven't played it yet*/
403             /* set played in hand_card to true where hand_id and card_id*/
404             $result = mysql_query("SELECT id FROM Hand_Card WHERE played='false' and ".
405                                   "hand_id='$handid' AND card_id=".DB_quote_smart($card));
406             $r = mysql_fetch_array($result,MYSQL_NUM);
407             $handcardid = $r[0];
408             
409             if($handcardid)
410               {
411                 mysql_query("UPDATE Hand_Card SET played='true' WHERE hand_id='$handid' AND card_id=".DB_quote_smart($card));
412                 
413                 /* get trick id or start new trick */
414                 $a = DB_get_current_trickid($gameid);
415                 $trickid  = $a[0];
416                 $sequence = $a[1];
417                 
418                 $playid = DB_play_card($trickid,$handcardid,$sequence);
419
420                 /*check for coment */
421                 if(isset($_REQUEST["comment"]))
422                   {
423                     DB_insert_comment($_REQUEST["comment"],$playid,$myid);
424                   };  
425
426                 echo "<div class=\"card\">";
427                 echo " you played  <br />";
428                 display_card($card);
429                 echo "</div>\n";
430                 
431
432                 /*check if we still have cards left, else set status to gameover */
433                 if(sizeof(DB_get_hand($me))==0)
434                   {
435                     DB_set_hand_status_by_hash($me,'gameover');
436                     $mystatus='gameover';
437                   }
438                 
439                 /* if all players are done, set game status also to game over */
440                 $userids = DB_get_all_userid_by_gameid($gameid);
441                 $done=1;
442                 foreach($userids as $user)
443                   if(DB_get_hand_status_by_userid($user)!='gameover')
444                     $done=0;
445
446                 if($done)
447                   DB_set_game_status_by_gameid($gameid,"gameover");
448                 
449                 /* email next player */
450                 if(DB_get_game_status_by_gameid($gameid)=='play')
451                   {
452                     if($sequence==4)
453                       {
454                         $play   = DB_get_cards_by_trick($trickid);
455                         $winner = get_winner($play); /* returns the position */
456                         $next = $winner;
457                       }
458                     else
459                       {
460                         $next = DB_get_pos_by_hash($me)+1;
461                       }
462                     if($next==5) $next=1;
463
464                     /* email next player */
465                     $next_hash = DB_get_hash_from_game_and_pos($gameid,$next);
466                     $email     = DB_get_email_by_hash($next_hash);
467
468                     $message .= "It's your turn  now.\n".
469                       "Use this link to play a card: ".$host."?me=".$next_hash."\n\n" ;
470                     mymail($email,"[DoKo-debug] a card has been played",$message);
471
472                     if($debug)
473                       echo "DEBUG:<a href=\"index.php?me=".DB_get_hash_from_game_and_pos($gameid,$next).
474                         "\"> next player </a> <br />\n";
475
476                   }
477               }
478             else
479               {
480                 echo "couldn't find card <br />\n";
481               }
482           }
483         else if(isset($_REQUEST["card"]) && !$myturn )
484           {
485             echo "please wait until it is your turn! <br />\n";
486           }
487         
488         $mycards = DB_get_hand($me);
489         sort($mycards);
490         echo "<div class=\"mycards\">\n";
491         
492         if($myturn && !isset($_REQUEST["card"]))
493           {
494             echo "Hello ".$myname.", it's your turn!  <br />\n";
495             echo "Your cards are: <br />\n";
496             echo "<form action=\"index.php?me=$me\" method=\"post\">\n";
497             foreach($mycards as $card) 
498               display_link_card($card);
499 ?>
500     <br />A short comments:<input name="comment" type="text" size="30" maxlength="50" /> 
501     <input type="hidden" name="me" value="<?php echo $me; ?>" />
502     <input type="submit" value="move" />
503  </form>
504  <?php
505          }
506         else if($mystatus=='play')
507           {
508             echo "Your cards are: <br />\n";
509             foreach($mycards as $card) 
510               display_card($card);
511           }
512         echo "</div>\n";
513
514         /* check if we need to set status to 'gameover' is done during playing of the card */
515         if($mystatus=='play')
516           break;
517    /* the following happens only when the gamestatus is 'gameover' */
518         /* check if game is over, display results */
519         if(DB_get_game_status_by_gameid($gameid)=='play')
520           {
521             echo "the game is over for you.. other people still need to play though";
522           }
523         else
524           {
525             echo "the game is over now... guess the final score should be displayed here...<br />\n";
526             
527             /* suggest a new game with the same people in it, just rotated once */
528             $names = DB_get_all_names_by_gameid($gameid);
529             
530             echo "Do you want to continue playing?(This will start a new game, with the next person as dealer.)\n";
531             echo "<form action=\"index.php\" methog=\"post\">\n";
532             echo "  <input type=\"hidden\" name=\"PlayerA\" value=\"".($names[1])."\" />\n";
533             echo "  <input type=\"hidden\" name=\"PlayerB\" value=\"".($names[2])."\" />\n";
534             echo "  <input type=\"hidden\" name=\"PlayerC\" value=\"".($names[3])."\" />\n";
535             echo "  <input type=\"hidden\" name=\"PlayerD\" value=\"".($names[0])."\" />\n";
536             echo "  <input type=\"hidden\" name=\"followup\" value=\"".($gameid)."\" />\n";
537             echo "  <input type=\"submit\" value=\"keep playing\" />\n";
538             echo "</form>\n";
539           }
540         break;
541       default:
542         echo "error in testing the status";
543       }
544     exit();
545   } 
546  else if(isset($_REQUEST["email"]) && isset($_REQUEST["password"]))
547   {
548     $ok=1;
549     $uid = DB_get_userid_by_email($_REQUEST["email"]);
550     if(!$uid)
551       $ok=0;
552     if(!DB_get_userid_by_passwd(md5($_REQUEST["password"])))
553       $ok=0;
554
555     if($ok)
556       {
557         $time = DB_get_user_timestamp($uid);
558         $unixtime =strtotime($time);
559         
560         $offset = DB_get_user_timezone($uid);
561         $zone = return_timezone($offset);
562         date_default_timezone_set($zone);
563
564         echo "ok. your logged in, now what? :) <br />last login: ";
565         echo date("r",$unixtime)."<br />";
566
567         DB_update_user_timestamp($uid);
568
569         echo "<p>these are the games you are playing in:<br />\n";
570         $result = mysql_query("SELECT hash,game_id from Hand WHERE user_id='$uid' AND status<>'gameover'" );
571         while( $r = mysql_fetch_array($result,MYSQL_NUM))
572           echo "<a href=\"http://doko.nubati.net/database/index.php?me=".$r[0]."\">game #".$r[1]." </a><br />";
573         echo "</p>\n";
574
575         $names = DB_get_all_names();
576         echo "<p>registered players:<br />\n";
577         foreach ($names as $name)
578           echo "$name <br />\n";
579         echo "</p>\n";
580         echo "<p>Want to start a new game? remember 4 names from the list above and visit ".
581           "<a href=\"http://doko.nubati.net/database/index.php?new\">this page.</a></p>";
582       }
583     else
584       {
585         echo "sorry email and password don't match <br />";
586       }
587     exit();
588   }
589 else if(isset($_REQUEST["register"]) )
590   {
591     echo "TODO: convert timezone into a menu<br />\n";
592     echo "TODO: figure out a way to handle passwrods <br />\n";
593 ?>
594         <form action="index.php" method="post">
595           <fieldset>
596             <legend>Register</legend>
597              <table>
598               <tr>
599                <td><label for="Rfullname">Full name:</label></td>
600                <td><input type="text" id="Rfullname" name="Rfullname" size="20" maxsize="30" /> </td>
601               </tr><tr>
602                <td><label for="Remail">Email:</label></td>
603                <td><input type="text" id="Remail" name="Remail" size="20" maxsize="30" /></td>
604               </tr><tr>
605                <td><label for="Rpassword">Password(will be displayed in cleartext on the next page):</label></td>
606                <td><input type="password" id="Rpassword" name="Rpassword" size="20" maxsize="30" /></td>
607               </tr><tr>
608                <td><label for="Rtimezone">Timezone:</label></td>
609                <td>
610                   <input type="text" id="Rtimezone" name="Rtimezone" size="4" maxsize="4" value="+1" />
611                </td>
612               </tr><tr>
613                <td colspan="2"> <input type="submit" value="register" /></td>
614              </table>
615           </fieldset>
616         </form>
617 <?php
618   }
619 else if(isset($_REQUEST["Rfullname"]) && 
620         isset($_REQUEST["Remail"]   ) && 
621         isset($_REQUEST["Rpassword"]) && 
622         isset($_REQUEST["Rtimezone"]) )
623   {
624         $ok=1;
625         if(DB_get_userid_by_name($_REQUEST["Rfullname"]))
626           {
627             echo "please chose another name<br />";
628             $ok=0;
629           }
630         if(DB_get_userid_by_email($_REQUEST["Remail"]))
631           {
632             echo "this email address is already used ?!<br />";
633             $ok=0;
634           }
635         if($ok)
636           {
637             $r=mysql_query("INSERT INTO User VALUES(NULL,".DB_quote_smart($_REQUEST["Rfullname"]).
638                       ",".DB_quote_smart($_REQUEST["Remail"]).
639                       ",".DB_quote_smart(md5($_REQUEST["Rpassword"])).
640                       ",".DB_quote_smart($_REQUEST["Rtimezone"]).",NULL)"); 
641             
642             if($r)
643               echo "  added you to the database";
644             else
645               echo " something went wrong";
646           }
647   }
648 else
649   { /* no new game, not in a game */
650 ?>
651     <p> If you want to play a game of Doppelkopf, you found the right place ;) </p>
652     <p> Please <a href="index.php?register">register</a>, in case you haven't done yet  <br />
653         or login with you email-address or name and password here:
654         <form action="index.php" method="post">
655           <fieldset>
656             <legend>Login</legend>
657              <table>
658               <tr>
659                <td><label for="email">Email:</label></td><td><input type="text" id="email" name="email" size="20" maxsize="30" /> </td>
660               </tr><tr>
661                <td><label for="password">Password:</label></td><td><input type="password" id="password" name="password" size="20" maxsize="30" /></td>
662               </tr><tr>
663                <td> <input type="submit" value="login" /></td>
664              </table>
665           </fieldset>
666         </form>
667  
668     </p>
669
670
671 <?php
672   }
673 ?>
674 </body>
675 </html>
676
677 <?php
678
679 DB_close();
680
681 /*
682  *Local Variables: 
683  *mode: php
684  *mode: hs-minor
685  *End:
686  */
687 ?>
688
689