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