Licensed under the GNU GPL v3 license. See file COPYRIGHT for details.
*/
$dontStartSession = 1;
require_once('./init.php');
require_once('./lang/class.default.php');
require_once('./lang/'.$config['lang'].'.php');
$lang = new Lang();
if(!canAllRead()) {
die("Access denied!
Disable password protection or Grant read access");
}
$listId = (int)_get('list');
$listData = $db->sqa("SELECT * FROM lists WHERE id=$listId");
if(!$listData) {
die("No such list");
}
$listData['_feed_title'] = sprintf($lang->get('feed_title'), $listData['name']);
$listData['_feed_descr'] = sprintf($lang->get('feed_description'), $listData['name']);
htmlarray_ref($listData);
$data = array();
$q = $db->dq("SELECT * FROM todolist WHERE list_id=$listId ORDER BY d DESC LIMIT 100");
while($r = $q->fetch_assoc($q))
{
if($r['prio'] > 0) $r['prio'] = '+'.$r['prio'];
$a = array();
if($r['prio']) $a[] = $lang->get('priority'). ": $r[prio]";
if($r['duedate'] != '') {
$ad = explode('-', $r['duedate']);
$a[] = $lang->get('due'). ": ".formatDate3($config['dateformat'], (int)$ad[0], (int)$ad[1], (int)$ad[2], $lang);
}
if($r['tags'] != '') $a[] = $lang->get('tags'). ": ". str_replace(',', ', ', $r['tags']);
$r['_descr'] = nl2br($r['note']). ($a && $r['note']!='' ? "
" : ""). implode("
", $a);
$data[] = htmlarray($r);
}
printRss($listData, $data);
function printRss($listData, $data)
{
$link = htmlarray('http://'. $_SERVER['HTTP_HOST']. substr($_SERVER['REQUEST_URI'], 0, strrpos($_SERVER['REQUEST_URI'], '/') + 1));
$buildDate = gmdate('r');
$s = "\n\n\n".
"$listData[_feed_title]\n$link\n$listData[_feed_descr]\n".
"$buildDate\n\n";
foreach($data as $v)
{
$da = explode(' ', $v['d']);
$dDate = explode('-', $da[0]);
$dTime = explode(':', $da[1]);
$d_ts = mktime((int)$dTime[0],(int)$dTime[1],(int)$dTime[2], (int)$dDate[1],(int)$dDate[2],(int)$dDate[0]);
$d = gmdate('r', $d_ts);
$guid = $listData['id'].'-'.$v['id'].'-'.$d_ts;
$s .= "- \n$v[title]\n".
"$link\n".
"$d\n".
"$v[_descr]\n".
"$guid\n".
"
\n";
}
$s .= "\n";
header("Content-type: text/xml");
print $s;
}
?>