2007-12-12 17:29:16 +01:00
|
|
|
<?php
|
2010-01-16 11:09:32 +01:00
|
|
|
/**
|
|
|
|
* RSS output of the latest posts.
|
|
|
|
*
|
2010-01-16 11:15:19 +01:00
|
|
|
* Parameter:
|
|
|
|
* - count=15
|
|
|
|
* Sets the number of RSS entries to export
|
|
|
|
*
|
2010-01-16 11:09:32 +01: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 17:29:16 +01:00
|
|
|
|
2010-03-17 21:11:21 +01:00
|
|
|
$httpContentType = 'application/rss+xml';
|
2010-02-08 08:32:34 +01:00
|
|
|
require_once 'www-header.php';
|
2008-11-25 16:57:29 +01:00
|
|
|
|
|
|
|
/* Service creation: only useful services are created */
|
2010-01-16 11:09:32 +01:00
|
|
|
$bookmarkservice = SemanticScuttle_Service_Factory::get('Bookmark');
|
|
|
|
$cacheservice = SemanticScuttle_Service_Factory::get('Cache');
|
2008-11-25 16:57:29 +01:00
|
|
|
|
2011-04-07 19:04:32 +02: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 16:57:29 +01:00
|
|
|
} else {
|
2010-01-16 11:09:32 +01:00
|
|
|
$url = '';
|
|
|
|
$user = '';
|
|
|
|
$cat = null;
|
2008-11-25 16:57:29 +01:00
|
|
|
}
|
2007-12-12 17:29:16 +01:00
|
|
|
|
|
|
|
if ($usecache) {
|
2010-01-16 11:09:32 +01: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 17:29:16 +01:00
|
|
|
}
|
|
|
|
|
2010-01-16 11:15:19 +01:00
|
|
|
if (isset($_GET['count'])) {
|
|
|
|
$rssEntries = (int)$_GET['count'];
|
|
|
|
}
|
2010-01-19 21:30:44 +01:00
|
|
|
if (!isset($rssEntries) || $rssEntries <= 0) {
|
2010-01-16 11:15:19 +01:00
|
|
|
$rssEntries = $defaultRssEntries;
|
|
|
|
} else if ($rssEntries > $maxRssEntries) {
|
|
|
|
$rssEntries = $maxRssEntries;
|
|
|
|
}
|
|
|
|
|
2011-06-27 22:31:24 +02:00
|
|
|
$privateKey = null;
|
|
|
|
if (isset($_GET['privateKey'])) {
|
|
|
|
$privateKey = $_GET['privateKey'];
|
2011-05-13 20:26:51 +02:00
|
|
|
}
|
2010-01-16 11:15:19 +01:00
|
|
|
|
2011-06-09 09:13:42 +02:00
|
|
|
$userid = null;
|
2007-12-12 17:29:16 +01:00
|
|
|
$watchlist = null;
|
2008-11-25 16:57:29 +01:00
|
|
|
$pagetitle = '';
|
2007-12-12 17:29:16 +01:00
|
|
|
if ($user && $user != 'all') {
|
2010-01-16 11:09:32 +01:00
|
|
|
if ($user == 'watchlist') {
|
|
|
|
$user = $cat;
|
|
|
|
$cat = null;
|
|
|
|
$watchlist = true;
|
|
|
|
}
|
|
|
|
if (is_int($user)) {
|
|
|
|
$userid = intval($user);
|
|
|
|
} else {
|
|
|
|
if ($userinfo = $userservice->getUserByUsername($user)) {
|
2013-03-20 20:00:25 +01:00
|
|
|
$userid = $userinfo[$userservice->getFieldName('primary')];
|
2011-06-27 22:31:24 +02:00
|
|
|
/* if user is not logged in and has valid privateKey */
|
2011-05-13 20:26:51 +02:00
|
|
|
if (!$userservice->isLoggedOn()) {
|
2011-06-27 22:31:24 +02:00
|
|
|
if ($privateKey != null) {
|
|
|
|
if (!$userservice->loginPrivateKey($privateKey)) {
|
2011-05-13 20:26:51 +02: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 11:09:32 +01:00
|
|
|
} else {
|
|
|
|
$tplVars['error'] = sprintf(T_('User with username %s was not found'), $user);
|
2011-05-13 20:26:51 +02:00
|
|
|
header('Content-type: text/html; charset=utf-8');
|
2010-01-16 11:09:32 +01:00
|
|
|
$templateservice->loadTemplate('error.404.tpl', $tplVars);
|
|
|
|
//throw a 404 error
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$pagetitle .= ": ". $user;
|
2007-12-12 17:29:16 +01:00
|
|
|
} else {
|
2011-06-27 22:31:24 +02:00
|
|
|
if ($privateKey != null) {
|
|
|
|
if (!$userservice->loginPrivateKey($privateKey)) {
|
2011-05-13 20:26:51 +02: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 17:29:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($cat) {
|
2010-01-16 11:09:32 +01:00
|
|
|
$pagetitle .= ": ". str_replace('+', ' + ', $cat);
|
2007-12-12 17:29:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$tplVars['feedtitle'] = filter($GLOBALS['sitename'] . (isset($pagetitle) ? $pagetitle : ''));
|
2012-01-20 15:03:29 +01:00
|
|
|
$tplVars['pagelink'] = addProtocolToUrl(ROOT);
|
|
|
|
$tplVars['feedlink'] = addProtocolToUrl(ROOT) . 'rss?sort=' . getSortOrder();
|
2007-12-12 17:29:16 +01:00
|
|
|
$tplVars['feeddescription'] = sprintf(T_('Recent bookmarks posted to %s'), $GLOBALS['sitename']);
|
|
|
|
|
2010-01-16 11:12:25 +01:00
|
|
|
$bookmarks = $bookmarkservice->getBookmarks(
|
2010-01-16 11:15:19 +01:00
|
|
|
0, $rssEntries, $userid, $cat,
|
2011-05-13 20:26:51 +02:00
|
|
|
null, getSortOrder(), $watchlist,
|
|
|
|
null, null, null
|
2010-01-16 11:12:25 +01:00
|
|
|
);
|
2008-11-25 16:57:29 +01:00
|
|
|
|
2010-01-16 11:12:25 +01:00
|
|
|
$bookmarks_tmp = filter($bookmarks['bookmarks']);
|
2007-12-12 17:29:16 +01:00
|
|
|
|
|
|
|
$bookmarks_tpl = array();
|
2010-01-16 11:12:25 +01:00
|
|
|
$latestdate = null;
|
2012-01-20 14:58:16 +01:00
|
|
|
$guidBaseUrl = addProtocolToUrl(ROOT) . '#';
|
2010-01-16 11:12:25 +01:00
|
|
|
foreach ($bookmarks_tmp as $key => $row) {
|
2010-01-16 11:09:32 +01:00
|
|
|
$_link = $row['bAddress'];
|
|
|
|
// Redirection option
|
|
|
|
if ($GLOBALS['useredir']) {
|
|
|
|
$_link = $GLOBALS['url_redir'] . $_link;
|
|
|
|
}
|
2010-01-16 11:12:25 +01:00
|
|
|
if ($row['bDatetime'] > $latestdate) {
|
|
|
|
$latestdate = $row['bDatetime'];
|
|
|
|
}
|
|
|
|
$_pubdate = gmdate('r', strtotime($row['bDatetime']));
|
2010-01-16 11:09:32 +01:00
|
|
|
|
|
|
|
$bookmarks_tpl[] = array(
|
2010-01-16 11:12:25 +01:00
|
|
|
'title' => $row['bTitle'],
|
|
|
|
'link' => $_link,
|
2007-12-12 17:29:16 +01:00
|
|
|
'description' => $row['bDescription'],
|
2011-03-15 19:13:14 +01:00
|
|
|
'creator' => SemanticScuttle_Model_UserArray::getName($row),
|
2010-01-16 11:12:25 +01:00
|
|
|
'pubdate' => $_pubdate,
|
2012-01-20 14:58:16 +01:00
|
|
|
'tags' => $row['tags'],
|
|
|
|
'guid' => $guidBaseUrl . $row['bId'],
|
2010-01-16 11:09:32 +01:00
|
|
|
);
|
2007-12-12 17:29:16 +01:00
|
|
|
}
|
|
|
|
unset($bookmarks_tmp);
|
|
|
|
unset($bookmarks);
|
2010-01-16 11:12:25 +01:00
|
|
|
$tplVars['bookmarks'] = $bookmarks_tpl;
|
|
|
|
$tplVars['feedlastupdate'] = date('r', strtotime($latestdate));
|
2007-12-12 17:29:16 +01:00
|
|
|
|
|
|
|
$templateservice->loadTemplate('rss.tpl', $tplVars);
|
|
|
|
|
|
|
|
if ($usecache) {
|
2010-01-16 11:09:32 +01:00
|
|
|
// Cache output if existing copy has expired
|
|
|
|
$cacheservice->End($hash);
|
2007-12-12 17:29:16 +01:00
|
|
|
}
|
|
|
|
?>
|