diff options
-rw-r--r-- | create_database.sql | 2 | ||||
-rw-r--r-- | functions.php | 33 | ||||
-rw-r--r-- | index.php | 17 | ||||
-rw-r--r-- | output.php | 29 | ||||
-rw-r--r-- | register.php | 7 | ||||
-rw-r--r-- | stats.php | 11 |
6 files changed, 35 insertions, 64 deletions
diff --git a/create_database.sql b/create_database.sql index d7b7e20..ed6d3f6 100644 --- a/create_database.sql +++ b/create_database.sql @@ -260,7 +260,7 @@ CREATE TABLE `User` ( `fullname` varchar(64) default NULL, `email` varchar(64) default NULL, `password` varchar(32) default NULL, - `timezone` tinyint(2) default NULL, + `timezone` varchar(64) default 'Europe/London', `last_login` timestamp NOT NULL default '0000-00-00 00:00:00', UNIQUE KEY `id` (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; diff --git a/functions.php b/functions.php index 16ca508..c835f89 100644 --- a/functions.php +++ b/functions.php @@ -390,26 +390,6 @@ function display_cards($me,$myturn) return; } -function return_timezone($offset) -{ - switch($offset) - { - case '1': - $zone = "Europe/Berlin"; - break; - case '-8': - $zone = "America/Vancouver"; - break; - case '13': - $zone = "Pacific/Auckland"; - break; - default: - $zone = "Europe/London"; - } - - return $zone; -} - function have_suit($cards,$c) { global $CARDS; @@ -669,7 +649,8 @@ function display_table () " Hand.sickness as sickness, ". " Hand.point_call, ". " User.last_login, ". - " Hand.hash ". + " Hand.hash, ". + " User.timezone ". "FROM Hand ". "LEFT JOIN User ON User.id=Hand.user_id ". "WHERE Hand.game_id='".$gameid."' ". @@ -685,12 +666,12 @@ function display_table () $party = $r[3]; $sickness = $r[4]; $call = $r[5]; - $lastlogin = strtotime($r[6]); $hash = $r[7]; + $timezone = $r[8]; + date_default_timezone_set($timezone); + $timenow = strtotime(date("Y-m-d H:i:s")); + $lastlogin = strtotime($r[6]); - $offset = DB_get_user_timezone($user); - $zone = return_timezone($offset); - date_default_timezone_set($zone); echo " <div class=\"table".($pos-1)."\">\n"; if(!$debug) @@ -790,7 +771,7 @@ function display_table () } echo " <br />\n"; - echo " <span title=\"".date("Y-m-d H:i:s")."\">local time</span>\n"; + echo " <span title=\"".date("Y-m-d H:i:s",$timenow). "\">local time</span>\n"; echo " <span title=\"".date("Y-m-d H:i:s",$lastlogin)."\">last login</span>\n"; echo " </div>\n"; @@ -1153,13 +1153,8 @@ else if(myisset("me")) $seq = $r[2]; $trick = $r[3]; $comment = $r[4]; - $timeplayed = strtotime($r[5]); $user = $r[6]; - $offset = DB_get_user_timezone($user); - $zone = return_timezone($offset); - date_default_timezone_set($zone); - /* check if first schweinchen has been played */ if( $GAME["schweinchen"] && ($r[0] == 19 || $r[0] == 20) ) $GAME["schweinchen"]++; @@ -2057,24 +2052,12 @@ else if( myisset("email","password") || isset($_SESSION["name"]) ) } else /* output default user page */ { - $time = DB_get_user_timestamp($myid); - $unixtime = strtotime($time); - - $offset = DB_get_user_timezone($myid); - $zone = return_timezone($offset); - date_default_timezone_set($zone); - $myname = DB_get_name_by_email($email); $_SESSION["name"] = $myname; - if(isset($_SESSION["name"])) - output_status($_SESSION["name"]); - /* display links to settings */ output_user_settings(); - echo "<div class=\"lastlogin\">last login: ".date("r",$unixtime)."</div>"; - DB_update_user_timestamp($myid); display_user_menu(); @@ -267,7 +267,7 @@ function output_home_page($pre,$game,$done,$avgtime) echo "$done games have been completed on this server. Average time of a game: $avgtime days</p>"; ?> - <p> Please <a href="register.php">register</a>, in case you haven't done that yet <br /> + <p> Please <a href="register.php">register</a>, in case you have not done that yet <br /> or login with you email-address or name and password here: </p> <form action="index.php" method="post"> @@ -333,8 +333,29 @@ function output_header() <div class="header"> <h1> Welcome to E-Doko <sup style="color:#888;">(beta)</sup> </h1> </div> -<div class="main"> <?php + if(isset($_SESSION["name"])) + { + $name = $_SESSION["name"]; + + /* logout info */ + echo "<div class=\"status\">\n"; + echo $name; + echo " <a href=\"index.php?logout=1\">logout</a>\n"; + echo "</div>"; + + /* last logon time */ + $myid = DB_get_userid_by_name($name); + $zone = DB_get_user_timezone($myid); + date_default_timezone_set($zone); + + $time = DB_get_user_timestamp($myid); + $unixtime = strtotime($time); + + echo "<div class=\"lastlogin\">last login: ".date("r",$unixtime)."</div>"; + }; + + echo "<div class=\"main\">"; return; } @@ -365,10 +386,6 @@ function output_footer() function output_status($name) { - echo "<div class=\"status\">\n"; - echo $name; - echo " <a href=\"index.php?logout=1\">logout</a>\n"; - echo "</div>"; return; } diff --git a/register.php b/register.php index 827e77e..7c3a373 100644 --- a/register.php +++ b/register.php @@ -71,9 +71,10 @@ if(myisset("Rfullname","Remail","Rpassword","Rtimezone") ) <td><label for="Rtimezone">Timezone:</label></td> <td> <select id="Rtimezone" name="Rtimezone" size="1"> - <option value="1">Berlin</option> - <option value="-8">Berkeley</option> - <option value="13">Wellington</option> + <option value="Europe/London">Berlin</option> + <option value="Europe/Berlin">Berlin</option> + <option value="America/Vancouver">Berkeley</option> + <option value="Pacific/Auckland">Wellington</option> </select> (If your timezone is not listed, just select whatever you want and email the admin your correct time zone.) </td> @@ -52,17 +52,6 @@ else if( isset($_SESSION["name"]) ) { DB_get_PREF($myid); - $time = DB_get_user_timestamp($myid); - $unixtime = strtotime($time); - - $offset = DB_get_user_timezone($myid); - $zone = return_timezone($offset); - date_default_timezone_set($zone); - - output_status($name); - - echo "<div class=\"lastlogin\">last login: ".date("r",$unixtime)."</div>"; - DB_update_user_timestamp($myid); display_user_menu(); |