2007-12-12 16:29:16 +00:00
|
|
|
<?php
|
2010-01-16 10:09:32 +00:00
|
|
|
/**
|
|
|
|
* RSS output of the latest posts.
|
|
|
|
*
|
2010-01-16 10:15:19 +00:00
|
|
|
* Parameter:
|
|
|
|
* - count=15
|
|
|
|
* Sets the number of RSS entries to export
|
|
|
|
*
|
2010-01-16 10:09:32 +00:00
|
|
|
* SemanticScuttle - your social bookmark manager.
|
|
|
|
*
|
|
|
|
* PHP version 5.
|
|
|
|
*
|
|
|
|
* @category Bookmarking
|
|
|
|
* @package SemanticScuttle
|
|
|
|
* @author Benjamin Huynh-Kim-Bang <mensonge@users.sourceforge.net>
|
|
|
|
* @author Christian Weiske <cweiske@cweiske.de>
|
|
|
|
* @author Eric Dane <ericdane@users.sourceforge.net>
|
|
|
|
* @license GPL http://www.gnu.org/licenses/gpl.html
|
|
|
|
* @link http://sourceforge.net/projects/semanticscuttle
|
|
|
|
*/
|
2007-12-12 16:29:16 +00:00
|
|
|
|
2010-03-17 20:11:21 +00:00
|
|
|
$httpContentType = 'application/rss+xml';
|
2010-02-08 07:32:34 +00:00
|
|
|
require_once 'www-header.php';
|
2008-11-25 15:57:29 +00:00
|
|
|
|
|
|
|
/* Service creation: only useful services are created */
|
2010-01-16 10:09:32 +00:00
|
|
|
$bookmarkservice = SemanticScuttle_Service_Factory::get('Bookmark');
|
|
|
|
$cacheservice = SemanticScuttle_Service_Factory::get('Cache');
|
2008-11-25 15:57:29 +00:00
|
|
|
|
2011-04-07 17:04:32 +00:00
|
|
|
if (isset($_SERVER['PATH_INFO']) && strlen($_SERVER['PATH_INFO']) > 1) {
|
|
|
|
$parts = explode('/', $_SERVER['PATH_INFO']);
|
|
|
|
if (count($parts) == 3) {
|
|
|
|
list($url, $user, $cat) = $parts;
|
|
|
|
} else {
|
|
|
|
list($url, $user) = $parts;
|
|
|
|
$cat = null;
|
|
|
|
}
|
2008-11-25 15:57:29 +00:00
|
|
|
} else {
|
2010-01-16 10:09:32 +00:00
|
|
|
$url = '';
|
|
|
|
$user = '';
|
|
|
|
$cat = null;
|
2008-11-25 15:57:29 +00:00
|
|
|
}
|
2007-12-12 16:29:16 +00:00
|
|
|
|
|
|
|
if ($usecache) {
|
2010-01-16 10:09:32 +00:00
|
|
|
// Generate hash for caching on
|
|
|
|
$hashtext = $_SERVER['REQUEST_URI'];
|
|
|
|
if ($userservice->isLoggedOn()) {
|
|
|
|
$hashtext .= $userservice->getCurrentUserID();
|
|
|
|
if ($currentUser->getUsername() == $user) {
|
|
|
|
$hashtext .= $user;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$hash = md5($hashtext);
|
|
|
|
|
|
|
|
// Cache for an hour
|
|
|
|
$cacheservice->Start($hash, 3600);
|
2007-12-12 16:29:16 +00:00
|
|
|
}
|
|
|
|
|
2010-01-16 10:15:19 +00:00
|
|
|
if (isset($_GET['count'])) {
|
|
|
|
$rssEntries = (int)$_GET['count'];
|
|
|
|
}
|
2010-01-19 20:30:44 +00:00
|
|
|
if (!isset($rssEntries) || $rssEntries <= 0) {
|
2010-01-16 10:15:19 +00:00
|
|
|
$rssEntries = $defaultRssEntries;
|
|
|
|
} else if ($rssEntries > $maxRssEntries) {
|
|
|
|
$rssEntries = $maxRssEntries;
|
|
|
|
}
|
|
|
|
|
2011-06-27 20:31:24 +00:00
|
|
|
$privateKey = null;
|
|
|
|
if (isset($_GET['privateKey'])) {
|
|
|
|
$privateKey = $_GET['privateKey'];
|
2011-05-13 18:26:51 +00:00
|
|
|
}
|
2010-01-16 10:15:19 +00:00
|
|
|
|
2011-06-09 07:13:42 +00:00
|
|
|
$userid = null;
|
2007-12-12 16:29:16 +00:00
|
|
|
$watchlist = null;
|
2008-11-25 15:57:29 +00:00
|
|
|
$pagetitle = '';
|
2007-12-12 16:29:16 +00:00
|
|
|
if ($user && $user != 'all') {
|
2010-01-16 10:09:32 +00:00
|
|
|
if ($user == 'watchlist') {
|
|
|
|
$user = $cat;
|
|
|
|
$cat = null;
|
|
|
|
$watchlist = true;
|
|
|
|
}
|
|
|
|
if (is_int($user)) {
|
|
|
|
$userid = intval($user);
|
|
|
|
} else {
|
|
|
|
if ($userinfo = $userservice->getUserByUsername($user)) {
|
|
|
|
$userid =& $userinfo[$userservice->getFieldName('primary')];
|
2011-06-27 20:31:24 +00:00
|
|
|
/* if user is not logged in and has valid privateKey */
|
2011-05-13 18:26:51 +00:00
|
|
|
if (!$userservice->isLoggedOn()) {
|
2011-06-27 20:31:24 +00:00
|
|
|
if ($privateKey != null) {
|
|
|
|
if (!$userservice->loginPrivateKey($privateKey)) {
|
2011-05-13 18:26:51 +00:00
|
|
|
$tplVars['error'] = sprintf(T_('Failed to Autenticate User with username %s using private key'), $user);
|
|
|
|
header('Content-type: text/html; charset=utf-8');
|
|
|
|
$templateservice->loadTemplate('error.404.tpl', $tplVars);
|
|
|
|
//throw a 404 error
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-16 10:09:32 +00:00
|
|
|
} else {
|
|
|
|
$tplVars['error'] = sprintf(T_('User with username %s was not found'), $user);
|
2011-05-13 18:26:51 +00:00
|
|
|
header('Content-type: text/html; charset=utf-8');
|
2010-01-16 10:09:32 +00:00
|
|
|
$templateservice->loadTemplate('error.404.tpl', $tplVars);
|
|
|
|
//throw a 404 error
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$pagetitle .= ": ". $user;
|
2007-12-12 16:29:16 +00:00
|
|
|
} else {
|
2011-06-27 20:31:24 +00:00
|
|
|
if ($privateKey != null) {
|
|
|
|
if (!$userservice->loginPrivateKey($privateKey)) {
|
2011-05-13 18:26:51 +00:00
|
|
|
$tplVars['error'] = sprintf(T_('Failed to Autenticate User with username %s using private key'), $user);
|
|
|
|
header('Content-type: text/html; charset=utf-8');
|
|
|
|
$templateservice->loadTemplate('error.404.tpl', $tplVars);
|
|
|
|
//throw a 404 error
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$userid = null;
|
|
|
|
}
|
2007-12-12 16:29:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($cat) {
|
2010-01-16 10:09:32 +00:00
|
|
|
$pagetitle .= ": ". str_replace('+', ' + ', $cat);
|
2007-12-12 16:29:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$tplVars['feedtitle'] = filter($GLOBALS['sitename'] . (isset($pagetitle) ? $pagetitle : ''));
|
2012-01-20 14:03:29 +00:00
|
|
|
$tplVars['pagelink'] = addProtocolToUrl(ROOT);
|
|
|
|
$tplVars['feedlink'] = addProtocolToUrl(ROOT) . 'rss?sort=' . getSortOrder();
|
2007-12-12 16:29:16 +00:00
|
|
|
$tplVars['feeddescription'] = sprintf(T_('Recent bookmarks posted to %s'), $GLOBALS['sitename']);
|
|
|
|
|
2010-01-16 10:12:25 +00:00
|
|
|
$bookmarks = $bookmarkservice->getBookmarks(
|
2010-01-16 10:15:19 +00:00
|
|
|
0, $rssEntries, $userid, $cat,
|
2011-05-13 18:26:51 +00:00
|
|
|
null, getSortOrder(), $watchlist,
|
|
|
|
null, null, null
|
2010-01-16 10:12:25 +00:00
|
|
|
);
|
2008-11-25 15:57:29 +00:00
|
|
|
|
2010-01-16 10:12:25 +00:00
|
|
|
$bookmarks_tmp = filter($bookmarks['bookmarks']);
|
2007-12-12 16:29:16 +00:00
|
|
|
|
|
|
|
$bookmarks_tpl = array();
|
2010-01-16 10:12:25 +00:00
|
|
|
$latestdate = null;
|
2012-01-20 13:58:16 +00:00
|
|
|
$guidBaseUrl = addProtocolToUrl(ROOT) . '#';
|
2010-01-16 10:12:25 +00:00
|
|
|
foreach ($bookmarks_tmp as $key => $row) {
|
2010-01-16 10:09:32 +00:00
|
|
|
$_link = $row['bAddress'];
|
|
|
|
// Redirection option
|
|
|
|
if ($GLOBALS['useredir']) {
|
|
|
|
$_link = $GLOBALS['url_redir'] . $_link;
|
|
|
|
}
|
2010-01-16 10:12:25 +00:00
|
|
|
if ($row['bDatetime'] > $latestdate) {
|
|
|
|
$latestdate = $row['bDatetime'];
|
|
|
|
}
|
|
|
|
$_pubdate = gmdate('r', strtotime($row['bDatetime']));
|
2010-01-16 10:09:32 +00:00
|
|
|
|
|
|
|
$bookmarks_tpl[] = array(
|
2010-01-16 10:12:25 +00:00
|
|
|
'title' => $row['bTitle'],
|
|
|
|
'link' => $_link,
|
2007-12-12 16:29:16 +00:00
|
|
|
'description' => $row['bDescription'],
|
2011-03-15 18:13:14 +00:00
|
|
|
'creator' => SemanticScuttle_Model_UserArray::getName($row),
|
2010-01-16 10:12:25 +00:00
|
|
|
'pubdate' => $_pubdate,
|
2012-01-20 13:58:16 +00:00
|
|
|
'tags' => $row['tags'],
|
|
|
|
'guid' => $guidBaseUrl . $row['bId'],
|
2010-01-16 10:09:32 +00:00
|
|
|
);
|
2007-12-12 16:29:16 +00:00
|
|
|
}
|
|
|
|
unset($bookmarks_tmp);
|
|
|
|
unset($bookmarks);
|
2010-01-16 10:12:25 +00:00
|
|
|
$tplVars['bookmarks'] = $bookmarks_tpl;
|
|
|
|
$tplVars['feedlastupdate'] = date('r', strtotime($latestdate));
|
2007-12-12 16:29:16 +00:00
|
|
|
|
|
|
|
$templateservice->loadTemplate('rss.tpl', $tplVars);
|
|
|
|
|
|
|
|
if ($usecache) {
|
2010-01-16 10:09:32 +00:00
|
|
|
// Cache output if existing copy has expired
|
|
|
|
$cacheservice->End($hash);
|
2007-12-12 16:29:16 +00:00
|
|
|
}
|
|
|
|
?>
|