From: Arun Persaud Date: Sat, 10 May 2008 19:15:35 +0000 (-0700) Subject: NEW FEATURE: new settings page, user can now change timezone X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=commitdiff_plain;h=880dfb2e715a3770de56fb525f5c90d28a6ccb4c NEW FEATURE: new settings page, user can now change timezone rewrote the settings page, timezone can now be changed, the user menu shows up on the left on the pref page. Added a link to the pref-page in the left menu. Signed-off-by: Arun Persaud --- diff --git a/include/db.php b/include/db.php index a9bdffd..208334f 100644 --- a/include/db.php +++ b/include/db.php @@ -95,6 +95,16 @@ function DB_get_passwd_by_name($name) return ""; } +function DB_get_passwd_by_userid($id) +{ + $r = DB_query_array("SELECT password FROM User WHERE id=".DB_quote_smart($id).""); + + if($r) + return $r[0]; + else + return ""; +} + function DB_check_recovery_passwords($password,$email) { $r = DB_query_array("SELECT User.id FROM User". @@ -673,7 +683,8 @@ function DB_get_PREF($myid) " WHERE user_id='$myid' AND pref_key='cardset'" ); if($r) { - if($r[0]=="germancards" && (time()-strtotime( "2009-12-31 23:59:59")<0) ) /* licence only valid until then */ + /* licence only valid until then */ + if($r[0]=="altenburg" && (time()-strtotime( "2009-12-31 23:59:59")<0) ) $PREF["cardset"]="altenburg"; else $PREF["cardset"]="english"; diff --git a/include/functions.php b/include/functions.php index e60f69f..382b148 100644 --- a/include/functions.php +++ b/include/functions.php @@ -828,6 +828,8 @@ function display_user_menu() echo "
Start a new game\n"; + echo "
Change settings\n"; + echo "
Statistics\n"; echo diff --git a/include/output.php b/include/output.php index 38356dd..397ed64 100644 --- a/include/output.php +++ b/include/output.php @@ -7,31 +7,6 @@ if(!isset($HOST)) /* functions which only ouput html */ -function output_user_settings() -{ - global $PREF; - - echo "
\n"; - echo "

Settings

\n"; - echo "Change password
"; - - echo "
Card set
\n"; - if( $PREF["cardset"] == "english" ) - echo "Change to German cards
"; - else - echo "Change to English cards
"; - - echo "
Email
\n"; - if( $PREF["email"] == "emailaddict" ) - echo "Change to non-addicted mode (emails for each move)
"; - else - echo "Change to addicted mode (minimal amount of emails)
"; - - echo "
\n"; - - return; -} - function output_ask_for_new_game($playerA,$playerB,$playerC,$playerD,$oldgameid) { global $RULES; @@ -342,6 +317,28 @@ function output_status() return; } +function output_select_timezone($name,$timezone="") +{ + $Tzone = array ( "Europe/London" => "London", + "Europe/Berlin" => "Berlin", + "America/Vancouver" => "Berkeley", + "Pacific/Auckland" => "Wellington" ); + + echo " \n"; + + return; +} + + function output_password_recovery($email,$password) { diff --git a/include/preferences.php b/include/preferences.php new file mode 100644 index 0000000..fdb6a19 --- /dev/null +++ b/include/preferences.php @@ -0,0 +1,177 @@ +\n"; +echo "
\n"; +echo "

Your settings are

\n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " ", + "\n"; +echo "
Email: $email
Timezone: "; +output_select_timezone("timezone",$timezone); +if($changed_timezone) echo "changed"; +echo "
Notification: "; + +echo " \n"; +if($changed_notify) echo "changed"; +echo "
Card set: "; + +echo " \n"; +if($changed_cards) echo "changed"; +echo "
Password(old): ", + ""; +switch($changed_password) + { + case '-2': + echo "The new passwords don't match."; + break; + case '-1': + echo "The old password is not correct."; + break; + case '1': + echo "changed"; + break; + } +echo "
Password(new): ", + "", + "
Password(new, retype): ", + "", + "
\n"; +echo "
\n"; +echo "\n"; + +output_footer(); +DB_close(); +exit(); + +?> \ No newline at end of file diff --git a/include/register.php b/include/register.php index 0dc204d..03be803 100644 --- a/include/register.php +++ b/include/register.php @@ -63,13 +63,9 @@ if(myisset("Rfullname","Remail","Rpassword","Rtimezone") ) - - (If your timezone is not listed, just select whatever you want and email the admin your correct time zone.) + diff --git a/include/user.php b/include/user.php index 00426aa..7e8ef9e 100644 --- a/include/user.php +++ b/include/user.php @@ -84,7 +84,6 @@ if(myisset("forgot")) else { /* normal user page */ - /* verify password and email */ if(strlen($password)!=32) $password = md5($password); @@ -103,162 +102,86 @@ if(myisset("forgot")) $PREF = DB_get_PREF($myid); - /* does the user want to change some preferences? */ - if(myisset("setpref")) + 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)) { - $setpref=$_REQUEST["setpref"]; - switch($setpref) + $game = DB_format_gameid($r[1]); + $gamenr = (int) $game; + if($gamenrold < $gamenr) { - case "germancards": - case "englishcards": - $result = DB_query("SELECT * from User_Prefs". - " WHERE user_id='$myid' AND pref_key='cardset'" ); - if( DB_fetch_array($result)) - $result = DB_query("UPDATE User_Prefs SET value=".DB_quote_smart($setpref). - " WHERE user_id='$myid' AND pref_key='cardset'" ); - else - $result = DB_query("INSERT INTO User_Prefs VALUES(NULL,'$myid','cardset',". - DB_quote_smart($setpref).")"); - echo "Ok, changed you preferences for the cards.\n"; - break; - case "emailaddict": - case "emailnonaddict": - $result = DB_query("SELECT * from User_Prefs". - " WHERE user_id='$myid' AND pref_key='email'" ); - if( DB_fetch_array($result)) - $result = DB_query("UPDATE User_Prefs SET value=".DB_quote_smart($setpref). - " WHERE user_id='$myid' AND pref_key='email'" ); + if($gamenrold!=-1) + echo "
$gamenr: "; else - $result = DB_query("INSERT INTO User_Prefs VALUES(NULL,'$myid','email',". - DB_quote_smart($setpref).")"); - echo "Ok, changed you preferences for sending out emails.\n"; - break; + echo "$gamenr: "; + $gamenrold = $gamenr; } - } - /* user wants to change his password or request a temporary one */ - else if(myisset("passwd")) - { - if( $_REQUEST["passwd"]=="ask" ) + if($r[4]=='pre') { - /* reset password form*/ - output_password_recovery($email,$password); + echo "\n p "; + } - else if($_REQUEST["passwd"]=="set") + else if ($r[4]=='gameover') + echo "\n F "; + else { - /* reset password */ - $ok = 1; - - /* check if old password matches */ - $oldpasswd = md5($_REQUEST["password0"]); - if(!( ($password == $oldpasswd) || DB_check_recovery_passwords($oldpasswd,$email) )) - $ok = -1; - /* check if new passwords are types the same twice */ - if($_REQUEST["password1"] != $_REQUEST["password2"] ) - $ok = -2; - - switch($ok) - { - case '-2': - echo "The new passwords don't match.
"; - break; - case '-1': - echo "The old password is not correct.
"; - break; - case '1': - echo "Changed the password.
"; - DB_query("UPDATE User SET password='".md5($_REQUEST["password1"]). - "' WHERE id=".DB_quote_smart($myid)); - break; - } - /* set password */ + echo "\n P "; } - } - else /* output default user page */ - { - /* display links to settings */ - output_user_settings(); - - 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)) + if($r[4] != 'gameover') { - $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 "; + echo "\n "; + if($r[3]==$myid || !$r[3]) + echo "(it's your turn)\n"; 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)"; - - } + $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"; } + 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 { diff --git a/index.php b/index.php index 77a2c5b..76bbc29 100644 --- a/index.php +++ b/index.php @@ -62,6 +62,9 @@ switch($action) case 'register': require './include/register.php'; break; + case 'prefs': + require './include/preferences.php'; + break; case 'game': require './include/game.php'; break;