X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=index.php;h=6daea5e20ae67dc82332270b7daa195005812b22;hp=90b91cead33914e4accd08b868de26dd3fc64a8d;hb=11bc256437ae08976ca1b65fcab39f9e326c760f;hpb=75ad669f06207b8e2813c7ae4f238d46dab25160
diff --git a/index.php b/index.php
index 90b91ce..6daea5e 100644
--- a/index.php
+++ b/index.php
@@ -3,208 +3,690 @@
"http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">
- Doko via email
-
+ e-Doko
+
+
+
-
+
+
";
- echo " player 1 ";
- echo " player 2 ";
- echo " player 3 ";
- echo " player 4 ";
- /* read in random.txt */
- if(file_exists("random.txt"))
- $random = file("random.txt");
- else
- die("no random file");
-
- $randomNR = explode( ":", $random[1] );
-
- /* write status into file */
- $output = fopen("status.txt","w");
- if ($output)
- {
- fwrite($output, "0\n");
-
- fwrite($output, "hash1:".$PlayerA.":".$EmailA."::" );
- for($i=0;$i<12;$i++)
- fwrite($output,";$randomNR[$i]" );
- fwrite($output,"\n");
-
- fwrite($output, "hash2:$PlayerB:$EmailB::" );
- for(;$i<24;$i++)
- fwrite($output,";$randomNR[$i]" );
- fwrite($output,"\n");
-
- fwrite($output, "hash3:$PlayerC:$EmailC::" );
- for(;$i<36;$i++)
- fwrite($output,";$randomNR[$i]" );
- fwrite($output,"\n");
-
- fwrite($output, "hash4:$PlayerD:$EmailD::");
- for(;$i<48;$i++)
- fwrite($output,";$randomNR[$i]" );
- fwrite($output,"\n");
-
- fclose($output);
- }
- else
- echo "can't open file for writing";
-};
-
-/* test if a game is running, else output everything for a new game */
-if(sizeof($lines)<2)
-{
+if(isset($_REQUEST["new"]))
+ {
?>
- no game in progress, please input 4 names and email addresses
-
- \n";
-}
- /* yes? email him his hand, ask for solo, poverty, email every move or every card? */
-if(isset($_REQUEST["b"]))
-{
- $b=$_REQUEST["b"];
- echo "hash is $b ";
- if(!isset($_REQUEST["in"])|| !isset($_REQUEST["update"]) )
- {
- echo "go back to ";
- echo " here and fill out the form ";
- }
- else
- { /* show the hand */
- echo $player[$b]["cards"];
- $tmp = $player[$b]["cards"];
- $cards = explode( ":",$tmp);
- echo "your cards are";
- foreach($cards as $card) echo " $card ";
- echo " \n";
- ?>
- \n";
+ echo " \n";
+ echo " \n";
+ echo " \n";
+ echo " \n";
+ echo " \n";
+ echo " \n";
+ echo " \n";
+ }
+ break;
+ default:
+ echo "error in testing the status";
+ }
+ exit();
+ }
+ else if(isset($_REQUEST["email"]) && isset($_REQUEST["password"]))
+ {
+ $ok=1;
+ $uid = DB_get_userid_by_email($_REQUEST["email"]);
+ if(!$uid)
+ $ok=0;
+ if(!DB_get_userid_by_passwd(md5($_REQUEST["password"])))
+ $ok=0;
+
+ if($ok)
+ {
+ $time = DB_get_user_timestamp($uid);
+ $unixtime =strtotime($time);
+
+ $offset = DB_get_user_timezone($uid);
+ $zone = return_timezone($offset);
+ date_default_timezone_set($zone);
+
+ echo "ok. your logged in, now what? :) last login: ";
+ echo date("r",$unixtime)." ";
+
+ DB_update_user_timestamp($uid);
+
+ echo "these are the games you are playing in: \n";
+ $result = mysql_query("SELECT hash,game_id from Hand WHERE user_id='$uid' AND status<>'gameover'" );
+ while( $r = mysql_fetch_array($result,MYSQL_NUM))
+ echo "game #".$r[1]." ";
+ echo "
\n";
+
+ $names = DB_get_all_names();
+ echo "registered players: \n";
+ foreach ($names as $name)
+ echo "$name \n";
+ echo "
\n";
+ echo "Want to start a new game? remember 4 names from the list above and visit ".
+ "this page.
";
+ }
+ else
+ {
+ echo "sorry email and password don't match ";
+ }
+ exit();
+ }
+else if(isset($_REQUEST["register"]) )
+ {
+ echo "TODO: convert timezone into a menu \n";
+ echo "TODO: figure out a way to handle passwrods \n";
+?>
+
+
+ Register
+
+
+
";
+ $ok=0;
+ }
+ if(DB_get_userid_by_email($_REQUEST["Remail"]))
+ {
+ echo "this email address is already used ?! ";
+ $ok=0;
+ }
+ if($ok)
+ {
+ $r=mysql_query("INSERT INTO User VALUES(NULL,".DB_quote_smart($_REQUEST["Rfullname"]).
+ ",".DB_quote_smart($_REQUEST["Remail"]).
+ ",".DB_quote_smart(md5($_REQUEST["Rpassword"])).
+ ",".DB_quote_smart($_REQUEST["Rtimezone"]).",NULL)");
+
+ if($r)
+ echo " added you to the database";
+ else
+ echo " something went wrong";
+ }
+ }
+else
+ { /* no new game, not in a game */
?>
+ If you want to play a game of Doppelkopf, you found the right place ;)
+ Please register , in case you haven't done yet
+ or login with you email-address or name and password here:
+
+
+ Login
+
+
+
+
+
+
+
+
+
+
+