TRANSLATION: some more strings and updated po.de
[e-DoKo.git] / rss.php
1 <?php
2 /* Copyright 2006, 2007, 2008, 2009, 2010 Arun Persaud <arun@nubati.net>
3  *
4  *   This file is part of e-DoKo.
5  *
6  *   e-DoKo is free software: you can redistribute it and/or modify
7  *   it under the terms of the GNU General Public License as published by
8  *   the Free Software Foundation, either version 3 of the License, or
9  *   (at your option) any later version.
10  *
11  *   e-DoKo is distributed in the hope that it will be useful,
12  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *   GNU General Public License for more details.
15  *
16  *   You should have received a copy of the GNU General Public License
17  *   along with e-DoKo.  If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20
21   /* get some information from the database */
22 error_reporting(E_ALL);
23
24 /* start a session, if it is not already running.
25  * This way people don't have to log in all the times.
26  * The session variables can also be read out from different
27  * php scripts, so that the code can be easily split up across several files
28  */
29
30 include_once("config.php");                /* needs to be first in list, since other includes use this */
31 include_once("./include/output.php");      /* html output only */
32 include_once("./include/db.php");          /* database only */
33 include_once("./include/functions.php");   /* the rest */
34
35 /* make sure that user has set all variables in config.php */
36 config_check();
37
38 /* open the database */
39 if(DB_open()<0)
40   {
41     output_header();
42     echo "Database error, can't connect... Please wait a while and try again. ".
43       "If the problem doesn't go away feel free to contact $ADMIN_NAME at $ADMIN_EMAIL.";
44     output_footer();
45     exit();
46   }
47
48 $ok = 0;
49 $id = 0;
50
51 if(!myisset("uid","token"))
52   {
53     echo "error";
54   }
55 else
56   {
57     $id = $_REQUEST['uid'];
58     $token = get_user_token($id);
59
60     if($token == $_REQUEST['token'])
61       $ok = 1;
62   }
63
64 if(! $ok)
65   {
66     echo "No valid userid";
67     exit();
68   }
69
70 header("Content-Type: text/xml");
71 /* start the feed */
72 ?>
73 <feed xmlns="http://www.w3.org/2005/Atom">
74 <title>E-DoKo Feed</title>
75 <subtitle>Know when it is your turn</subtitle>
76 <?php
77
78   global $WIKI,$INDEX, $HOST;
79
80   /* output last creation date */
81 echo "<link href=\"$HOST/$INDEX\" />\n";
82 echo "<link rel=\"self\" href=\"".$HOST.htmlentities($_SERVER['REQUEST_URI'])."\" />\n";
83 $date = DB_query_array("Select create_date from User order by create_date ASC limit 1");
84 $date = $date[0];
85 $timestamp = strtotime($date);
86 echo "<id>tag:".$_SERVER['SERVER_NAME'].",".date("Y-m-d",$timestamp).":$INDEX</id>\n";
87 echo "<updated>".date(DATE_ATOM)."</updated>\n";
88 echo "<author>\n";
89 echo "<name>$ADMIN_NAME  $date $timestamp</name>\n";
90 echo "<email>$ADMIN_EMAIL</email>\n";
91 echo "</author>\n\n";
92
93
94  /* output the entries */
95
96
97   $result = DB_query("SELECT Hand.hash,Hand.game_id,Game.player from Hand".
98                      " LEFT JOIN Game On Hand.game_id=Game.id".
99                      " WHERE Hand.user_id='$id'".
100                      " AND ( Game.player='$id' OR ISNULL(Game.player) )".
101                      " AND ( Game.status='pre' OR Game.status='play' )".
102                      " ORDER BY Game.session" );
103
104   while( $r = DB_fetch_array($result))
105     {
106       echo "<entry>\n";
107       echo "<title>game ".DB_format_gameid($r[1])."</title>\n";
108       $url=$INDEX."?action=game&amp;me=".$r[0];
109       echo "<link href=\"".$HOST.$url."\" />\n";
110       $date = DB_get_game_timestamp($r[1]);
111       $timestamp = strtotime($date);
112       $date = date("Y-m-d",$timestamp);
113       echo "<id>tag:doko.nubati.net,$date:$url</id>\n";
114       echo "<updated>".date(DATE_ATOM,$timestamp)."</updated>\n";
115       echo "<summary>Please use the link to access the game.</summary>\n";
116       echo "</entry>\n\n";
117     }
118
119 ?>
120 </feed>