diff options
author | Arun Persaud <arun@nubati.net> | 2010-02-02 22:37:27 -0800 |
---|---|---|
committer | Arun Persaud <arun@nubati.net> | 2010-02-04 22:17:09 -0800 |
commit | b76cddb9313d8a67e5d7e1830503b5775666238f (patch) | |
tree | 29a1b79a6f0578c804318a9cf741ab51538940a6 /include | |
parent | 3b407a98fe0243cef87fdd64aeb4f567cca41f40 (diff) | |
download | e-DoKo-b76cddb9313d8a67e5d7e1830503b5775666238f.tar.gz e-DoKo-b76cddb9313d8a67e5d7e1830503b5775666238f.tar.bz2 e-DoKo-b76cddb9313d8a67e5d7e1830503b5775666238f.zip |
NEW FEATURE: provide an RSS feed for each user showing in which games it's his turn
the feed shows the same as the "It's your turn in these games" box.
Diffstat (limited to 'include')
-rw-r--r-- | include/db.php | 20 | ||||
-rw-r--r-- | include/functions.php | 14 | ||||
-rw-r--r-- | include/output.php | 71 |
3 files changed, 72 insertions, 33 deletions
diff --git a/include/db.php b/include/db.php index 882a1ad..55d97c9 100644 --- a/include/db.php +++ b/include/db.php @@ -498,6 +498,15 @@ function DB_update_game_timestamp($gameid) return; } +function DB_get_game_timestamp($gameid) +{ + $r = DB_query_array("SELECT mod_date FROM Game WHERE id=".DB_quote_smart($gameid)); + + if($r) + return $r[0]; + else + return NULL; +} function DB_update_user_timestamp($userid) { @@ -514,6 +523,17 @@ function DB_get_user_timestamp($userid) else return NULL; } + +function DB_get_user_creation_date($userid) +{ + $r = DB_query_array("SELECT create_date FROM User WHERE id=".DB_quote_smart($userid)); + + if($r) + return $r[0]; + else + return NULL; +} + function DB_get_user_timezone($userid) { $r = DB_query_array("SELECT timezone FROM User WHERE id=".DB_quote_smart($userid)); diff --git a/include/functions.php b/include/functions.php index eca0155..33da9ef 100644 --- a/include/functions.php +++ b/include/functions.php @@ -1384,4 +1384,18 @@ function cancel_game($why,$gameid) return; } +function get_user_token($userid) +{ + + $token = NULL; + + $date = DB_get_user_creation_date($userid); + $name = DB_get_name('userid',$userid); + + if($date && $name) + $token = md5("token".$name.$date); + + return $token; +} + ?> diff --git a/include/output.php b/include/output.php index 57b3152..61fef60 100644 --- a/include/output.php +++ b/include/output.php @@ -380,39 +380,44 @@ function output_footer() function output_status() { - global $defaulttimezone,$INDEX,$WIKI; - if(isset($_SESSION["name"])) - { - $name = $_SESSION["name"]; - - /* logout info */ - echo "\n<div class=\"status\">\n"; - echo $name,"\n"; - echo " | <a href=\"".$INDEX."\"> mypage </a>\n"; - echo " | <a href=\"".$INDEX."?action=prefs\">settings</a>\n"; - echo " | <a href=\"".$INDEX."?action=new\">new game</a>\n"; - echo " | <a href=\"".$INDEX."?action=stats\">statistics</a>\n"; - echo " | <a href=\"".$WIKI."\">wiki</a>\n"; - echo " | <a href=\"".$INDEX."?action=logout\">logout</a>\n"; - echo "</div>\n"; - - /* last logon time */ - $myid = DB_get_userid("name",$name); - $zone = DB_get_user_timezone($myid); - - $time = DB_get_user_timestamp($myid); - date_default_timezone_set($defaulttimezone); - $unixtime = strtotime($time); - date_default_timezone_set($zone); - - echo "<div class=\"lastlogin\"><span>last login: ".date("r",$unixtime)."</span></div>\n"; - } - else - { - echo "\n<div class=\"status\">\n"; - echo "<a href=\"".$INDEX."\">login</a>\n"; - echo "</div>\n"; - } + global $defaulttimezone, $INDEX, $WIKI, $RSS; + + if(isset($_SESSION["name"])) + { + $name = $_SESSION["name"]; + + /* last logon time */ + $myid = DB_get_userid("name",$name); + $zone = DB_get_user_timezone($myid); + + $time = DB_get_user_timestamp($myid); + date_default_timezone_set($defaulttimezone); + $unixtime = strtotime($time); + date_default_timezone_set($zone); + + /* rss token */ + $token = get_user_token($myid); + + /* logout info */ + echo "\n<div class=\"status\">\n"; + echo $name,"\n"; + echo " | <a href=\"".$INDEX."\"> mypage </a>\n"; + echo " | <a href=\"".$INDEX."?action=prefs\">settings</a>\n"; + echo " | <a href=\"".$INDEX."?action=new\">new game</a>\n"; + echo " | <a href=\"".$INDEX."?action=stats\">statistics</a>\n"; + echo " | <a href=\"".$WIKI."\">wiki</a>\n"; + echo " | <a href=\"".$RSS."?uid=".$myid."&token=".$token."\">rss</a>\n"; + echo " | <a href=\"".$INDEX."?action=logout\">logout</a>\n"; + echo "</div>\n"; + + echo "<div class=\"lastlogin\"><span>last login: ".date("r",$unixtime)."</span></div>\n"; + } + else + { + echo "\n<div class=\"status\">\n"; + echo "<a href=\"".$INDEX."\">login</a>\n"; + echo "</div>\n"; + } return; } |