X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=include%2Fuser.php;h=be0d68a5b08740252cbe3f7af9fa13f236b3b5db;hp=54ce3026ce83e12e1883827b347693ea370a72f3;hb=ed0ffd0d14904b661622a29e95661fc03728c2c4;hpb=448ca16b770c8cfe055f4ffb41cd5c189da3cde0 diff --git a/include/user.php b/include/user.php index 54ce302..be0d68a 100644 --- a/include/user.php +++ b/include/user.php @@ -1,5 +1,5 @@ ". @@ -81,115 +81,115 @@ if(myisset("forgot")) "or else try again."; } } - else - { /* normal user page */ - - /* verify password and email */ - if(strlen($password)!=32) - $password = md5($password); - - $ok = 1; - $myid = DB_get_userid('email-password',$email,$password); - if(!$myid) - $ok = 0; - - if($ok) - { - /* user information is ok */ - $myname = DB_get_name('email',$email); - $_SESSION["name"] = $myname; - output_status(); - - $PREF = DB_get_PREF($myid); - - DB_update_user_timestamp($myid); - - display_user_menu(); - - /* display all games the user has played */ - echo "
"; - echo "

These are all your games:

\n"; - echo "

Session:
\n"; - echo " p = pre-game phase "; - echo "P = game in progess "; - echo "F = game finished
"; - echo "

\n"; - - $output = array(); - $result = DB_query("SELECT Hand.hash,Hand.game_id,Game.mod_date,Game.player,Game.status from Hand". - " LEFT JOIN Game ON Game.id=Hand.game_id". - " WHERE user_id='$myid'". - " ORDER BY Game.session,Game.create_date" ); - $gamenrold = -1; - echo "\n \n \n
\n"; - while( $r = DB_fetch_array($result)) - { - $game = DB_format_gameid($r[1]); - $gamenr = (int) $game; - if($gamenrold < $gamenr) - { - if($gamenrold!=-1) - echo "
$gamenr: "; - else - echo "$gamenr: "; - $gamenrold = $gamenr; - } - if($r[4]=='pre') - { - echo "\n p "; - - } - else if ($r[4]=='gameover') - echo "\n F "; - else - { - echo "\n P "; - } - if($r[4] != 'gameover') - { - echo "\n "; - if($r[3]==$myid || !$r[3]) - echo "(it's your turn)\n"; - else - { - $name = DB_get_name('userid',$r[3]); - $gameid = $r[1]; - if(DB_get_reminder($r[3],$gameid)==0) - if(time()-strtotime($r[2]) > 60*60*24*7) - echo "". - "Send a reminder."; - echo "(it's $name's turn)\n"; - }; - if(time()-strtotime($r[2]) > 60*60*24*30) - echo "". - "Cancel?". - " (clicking here is final and can't be restored)"; - - } - } - echo "
\n"; - - /* display last 5 users that have signed up to e-DoKo */ - $names = DB_get_names_of_new_logins(5); - echo "

New Players:

\n

\n"; - echo implode(", ",$names).",...\n"; - echo "

\n"; - - /* display last 5 users that logged on */ - $names = DB_get_names_of_last_logins(5); - echo "

Players last logged in:

\n

\n"; - echo implode(", ",$names).",...\n"; - echo "

\n"; - - echo "
\n"; - } - else - { - echo "
Sorry email and password don't match. Please try again.
"; - } - }; -output_footer(); -DB_close(); -exit(); +else + { /* normal user page */ + + /* verify password and email */ + if(strlen($password)!=32) + $password = md5($password); + + $ok = 1; + $myid = DB_get_userid('email-password',$email,$password); + if(!$myid) + $ok = 0; + + if($ok) + { + /* user information is ok */ + $myname = DB_get_name('email',$email); + $_SESSION["name"] = $myname; + + $PREF = DB_get_PREF($myid); + + DB_update_user_timestamp($myid); + + display_user_menu($myid); + /* display all games the user has played */ + echo "
"; + echo "

These are all your games:

\n"; + echo "

Session:
\n"; + echo " p = pre-game phase "; + echo "P = game in progess "; + echo "F = game finished "; + echo " N = game finished, hand played by others too
"; + echo "

\n"; + + $output = array(); + $result = DB_query("SELECT Hand.hash,Hand.game_id,G.mod_date,G.player,G.status, ". + " (SELECT count(H.randomnumbers) FROM Game H WHERE H.randomnumbers=G.randomnumbers) AS count ". + " FROM Hand". + " LEFT JOIN Game G ON G.id=Hand.game_id". + " WHERE user_id='$myid'". + " ORDER BY G.session,G.create_date" ); + + $gamenrold = -1; + echo "\n \n \n"; + else + echo "$gamenr:\n"; + $gamenrold = $gamenr; + echo "\n\n
\n"; + while( $r = DB_fetch_array($result)) + { + $game = DB_format_gameid($r[1]); + $gamenr = (int) $game; + if($gamenrold < $gamenr) + { + if($gamenrold!=-1) + echo "
$gamenr:\n"; + } + $Multi = ($r[5]>1) ? "multi" : ""; + if($r[4]=='pre') + echo " p \n"; + else if ($r[4]=='gameover') + { + echo " "; + if($r[5]<2) + echo "F "; + else + echo $r[5]; + echo "\n"; + } + else + echo " P \n"; + if($r[4] != 'gameover') + { + echo "\n "; + if($r[3]==$myid || !$r[3]) + echo "(it's your turn)\n"; + else + { + $name = DB_get_name('userid',$r[3]); + $gameid = $r[1]; + if(DB_get_reminder($r[3],$gameid)==0) + if(time()-strtotime($r[2]) > 60*60*24*7) + echo "Send a reminder."; + echo "(it's $name's turn)\n"; + }; + if(time()-strtotime($r[2]) > 60*60*24*30) + echo "Cancel?". + " (clicking here is final and can't be restored)"; + } + } + echo "
\n"; + + /* display last 5 users that have signed up to e-DoKo */ + $names = DB_get_names_of_new_logins(5); + echo "

New Players:

\n

\n"; + echo implode(", ",$names).",...\n"; + echo "

\n"; + + /* display last 5 users that logged on */ + $names = DB_get_names_of_last_logins(5); + echo "

Players last logged in:

\n

\n"; + echo implode(", ",$names).",...\n"; + echo "

\n"; + + echo "
\n"; + } + else + { + echo "
Sorry email and password don't match. Please try again.
"; + } + }; ?> \ No newline at end of file