2 /***************************************************************************
3 Copyright (C) 2004 - 2010 Marcus Campbell
6 This program 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 2 of the License, or
9 (at your option) any later version.
11 This program 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.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 ***************************************************************************/
21 require_once 'header.inc.php';
23 $bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
24 $cacheservice =& ServiceFactory::getServiceInstance('CacheService');
25 $templateservice =& ServiceFactory::getServiceInstance('TemplateService');
26 $userservice =& ServiceFactory::getServiceInstance('UserService');
29 header('Content-Type: application/xml');
30 list($url, $user, $cat) = explode('/', $_SERVER['PATH_INFO']);
33 // Generate hash for caching on
34 $hashtext = $_SERVER['REQUEST_URI'];
35 if ($userservice->isLoggedOn()) {
36 $hashtext .= $userservice->getCurrentUserID();
37 $currentUser = $userservice->getCurrentUser();
38 $currentUsername = $currentUser[$userservice->getFieldName('username')];
39 if ($currentUsername == $user) {
43 $hash = md5($hashtext);
46 $cacheservice->Start($hash, 3600);
50 if ($user && $user != 'all') {
51 if ($user == 'watchlist') {
57 $userid = intval($user);
59 if ($userinfo = $userservice->getUserByUsername($user)) {
60 $userid =& $userinfo[$userservice->getFieldName('primary')];
62 $tplVars['error'] = sprintf(T_('User with username %s was not found'), $user);
63 $templateservice->loadTemplate('error.404.tpl', $tplVars);
68 $pagetitle .= ": ". $user;
74 $pagetitle .= ": ". str_replace('+', ' + ', $cat);
77 $tplVars['feedtitle'] = filter($GLOBALS['sitename'] . (isset($pagetitle) ? $pagetitle : ''));
78 $tplVars['feedlink'] = $GLOBALS['root'];
79 $tplVars['feeddescription'] = sprintf(T_('Recent bookmarks posted to %s'), $GLOBALS['sitename']);
81 $bookmarks =& $bookmarkservice->getBookmarks(0, 15, $userid, $cat, NULL, getSortOrder(), $watchlist);
82 $bookmarks_tmp =& filter($bookmarks['bookmarks']);
84 $bookmarks_tpl = array();
85 foreach(array_keys($bookmarks_tmp) as $key) {
86 $row =& $bookmarks_tmp[$key];
88 $_link = $row['bAddress'];
90 if ($GLOBALS['useredir']) {
91 $_link = $GLOBALS['url_redir'] . $_link;
93 $_pubdate = date("r", strtotime($row['bDatetime']));
95 $uriparts = explode('.', $_link);
96 $extension = end($uriparts);
100 if ($keys = multi_array_search($extension, $GLOBALS['filetypes'])) {
101 $enclosure['mime'] = file_get_mimetype($_link);
102 $enclosure['length'] = file_get_filesize($_link);
105 $bookmarks_tpl[] = array(
106 'title' => $row['bTitle'],
108 'description' => $row['bDescription'],
109 'creator' => $row['username'],
110 'pubdate' => $_pubdate,
111 'tags' => $row['tags'],
112 'enclosure_mime' => $enclosure['mime'],
113 'enclosure_length' => $enclosure['length']
116 unset($bookmarks_tmp);
118 $tplVars['bookmarks'] =& $bookmarks_tpl;
120 $templateservice->loadTemplate('rss.tpl', $tplVars);
123 // Cache output if existing copy has expired
124 $cacheservice->End($hash);