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