Cleaning up some code in www folder

This commit is contained in:
Mark Pemberton 2011-01-24 02:04:08 -05:00
parent 8d91bf83bc
commit 456af09a04
49 changed files with 1260 additions and 1100 deletions

View File

@ -35,57 +35,56 @@ $tplVars['sidebar_blocks'] = array('users' );
$tplVars['error'] = '';
$tplVars['msg'] = '';
if ( !$userservice->isLoggedOn() ) {
header('Location: '. createURL('login', ''));
exit();
if (!$userservice->isLoggedOn()) {
header('Location: '. createURL('login', ''));
exit();
}
if ( !$currentUser->isAdmin() ) {
header('Location: '. createURL('bookmarks', $currentUser->getUsername()));
exit();
if (!$currentUser->isAdmin()) {
header('Location: '. createURL('bookmarks', $currentUser->getUsername()));
exit();
}
@list($url, $action, $user) = isset($_SERVER['PATH_INFO']) ? explode('/', $_SERVER['PATH_INFO']) : NULL;
@list($url, $action, $user) = isset($_SERVER['PATH_INFO']) ? explode('/', $_SERVER['PATH_INFO']) : null;
if ( $action
&& (strpos($_SERVER['HTTP_REFERER'], ROOT.'admin') === 0) // Prevent CSRF attacks
) {
switch ( $action ) {
case 'delete':
if ( $user && ($userinfo = $userservice->getUserByUsername($user)) ) {
$uId = $userinfo['uId'];
// Prevent CSRF attacks
if ($action && (strpos($_SERVER['HTTP_REFERER'], ROOT.'admin') === 0)) {
switch ($action) {
case 'delete':
if ($user && ($userinfo = $userservice->getUserByUsername($user))) {
$uId = $userinfo['uId'];
$tagcacheservice->deleteByUser($uId);
$tag2tagservice->removeLinkedTagsForUser($uId);
$userservice->deleteUser($uId);
$bookmark2tagservice->deleteTagsForUser($uId);
$commondescriptionservice->deleteDescriptionsForUser($uId);
$searchhistoryservice->deleteSearchHistoryForUser($uId);
$tagstatservice->deleteTagStatForUser($uId);
// XXX: don't delete bookmarks before tags, else tags can't be deleted !!!
$bookmarkservice->deleteBookmarksForUser($uId);
$tagcacheservice->deleteByUser($uId);
$tag2tagservice->removeLinkedTagsForUser($uId);
$userservice->deleteUser($uId);
$bookmark2tagservice->deleteTagsForUser($uId);
$commondescriptionservice->deleteDescriptionsForUser($uId);
$searchhistoryservice->deleteSearchHistoryForUser($uId);
$tagstatservice->deleteTagStatForUser($uId);
// XXX: don't delete bookmarks before tags, else tags can't be deleted !!!
$bookmarkservice->deleteBookmarksForUser($uId);
$tplVars['msg'] = sprintf(T_('%s and all his bookmarks and tags were deleted.'), $user);
}
break;
case 'checkUrl' :
$bookmarks =& $bookmarkservice->getBookmarks(0, NULL, NULL, NULL, NULL, getSortOrder());
foreach($bookmarks['bookmarks'] as $bookmark) {
if(!checkUrl($bookmark['bAddress'])) {
$tplVars['error'].= T_('Problem with ').$bookmark['bAddress'].' ('. $bookmark['username'] .')<br/>';
}
}
break;
default:
// DO NOTHING
}
$tplVars['msg'] = sprintf(T_('%s and all his bookmarks and tags were deleted.'), $user);
}
break;
case 'checkUrl' :
$bookmarks =& $bookmarkservice->getBookmarks(0, null, null, null, null, getSortOrder());
foreach ($bookmarks['bookmarks'] as $bookmark) {
if (!checkUrl($bookmark['bAddress'])) {
$tplVars['error'].= T_('Problem with ').$bookmark['bAddress'].' ('. $bookmark['username'] .')<br/>';
}
}
break;
default:
// DO NOTHING
}
}
$templatename = 'admin.tpl';
$users =& $userservice->getObjectUsers();
if ( !is_array($users) ) {
$users = array();
if (!is_array($users)) {
$users = array();
}
$tplVars['users'] =& $users;

View File

@ -24,33 +24,36 @@ $httpContentType = 'application/json';
require_once '../www-header.php';
/* Service creation: only useful services are created */
$b2tservice =SemanticScuttle_Service_Factory::get('Bookmark2Tag');
$bookmarkservice =SemanticScuttle_Service_Factory::get('Tag');
$tagstatservice =SemanticScuttle_Service_Factory::get('TagStat');
$b2tservice = SemanticScuttle_Service_Factory::get('Bookmark2Tag');
$bookmarkservice = SemanticScuttle_Service_Factory::get('Tag');
$tagstatservice = SemanticScuttle_Service_Factory::get('TagStat');
/* Managing all possible inputs */
isset($_GET['tag']) ? define('GET_TAG', $_GET['tag']): define('GET_TAG', '');
isset($_GET['uId']) ? define('GET_UID', $_GET['uId']): define('GET_UID', '');
function displayTag($tag, $uId) {
$uId = ($uId==0)?NULL:$uId; // if user is nobody, NULL allows to look for every public tags
$tag2tagservice =SemanticScuttle_Service_Factory::get('Tag2Tag');
$output = '{ id:'.rand().', name:\''.$tag.'\'';
function displayTag($tag, $uId)
{
// if user is nobody, NULL allows to look for every public tags
$uId = ($uId==0) ? null : $uId;
$linkedTags = $tag2tagservice->getAdminLinkedTags($tag, '>');
if(count($linkedTags) > 0) {
$output.= ', children: [';
foreach($linkedTags as $linkedTag) {
$output.= displayTag($linkedTag, $uId);
}
$output = substr($output, 0, -1); // remove final comma avoiding IE6 Dojo bug
$output.= "]";
}
$tag2tagservice = SemanticScuttle_Service_Factory::get('Tag2Tag');
$output = '{ id:'.rand().', name:\''.$tag.'\'';
$output.= '},';
return $output;
$linkedTags = $tag2tagservice->getAdminLinkedTags($tag, '>');
if (count($linkedTags) > 0) {
$output.= ', children: [';
foreach ($linkedTags as $linkedTag) {
$output.= displayTag($linkedTag, $uId);
}
/* remove final comma avoiding IE6 Dojo bug */
$output = substr($output, 0, -1);
$output.= "]";
}
$output.= '},';
return $output;
}
?>
@ -58,7 +61,8 @@ function displayTag($tag, $uId) {
{ label: 'name', identifier: 'id', items: [
<?php
$json = displayTag(GET_TAG, intval(GET_UID));
$json = substr($json, 0, -1); // remove final comma avoiding IE6 Dojo bug
// remove final comma avoiding IE6 Dojo bug
$json = substr($json, 0, -1);
echo $json;
?>
] }

View File

@ -19,26 +19,22 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
***************************************************************************/
/* Return a json file with list of tags according to current user and sort by popularity*/
/* Return a json file with list of tags according */
/* to current user and sort by popularity */
$httpContentType = 'application/json';
require_once '../www-header.php';
/* Service creation: only useful services are created */
$b2tservice =SemanticScuttle_Service_Factory::get('Bookmark2Tag');
$bookmarkservice =SemanticScuttle_Service_Factory::get('Tag');
$b2tservice = SemanticScuttle_Service_Factory::get('Bookmark2Tag');
$bookmarkservice = SemanticScuttle_Service_Factory::get('Tag');
?>
{identifier:"tag",
items: [
{identifier:"tag", items: [
<?php
$listTags = $b2tservice->getAdminTags(1000, $userservice->getCurrentUserId());
foreach($listTags as $t) {
echo "{tag: \"".$t['tag']."\"},";
}
$listTags = $b2tservice->getAdminTags(1000, $userservice->getCurrentUserId());
foreach ($listTags as $t) {
echo "{tag: \"".$t['tag']."\"},";
}
?>
]}

View File

@ -19,26 +19,24 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
***************************************************************************/
/* Return a json file with list of tags according to current user and sort by popularity*/
/* Return a json file with list of tags according */
/* to current user and sort by popularity */
$httpContentType = 'application/json';
require_once '../www-header.php';
/* Service creation: only useful services are created */
$b2tservice =SemanticScuttle_Service_Factory::get('Bookmark2Tag');
$bookmarkservice =SemanticScuttle_Service_Factory::get('Tag');
$b2tservice = SemanticScuttle_Service_Factory::get('Bookmark2Tag');
$bookmarkservice = SemanticScuttle_Service_Factory::get('Tag');
?>
{identifier:"tag",
items: [
{identifier:"tag", items: [
<?php
$listTags = $b2tservice->getContactTags($userservice->getCurrentUserId(), 1000, $userservice->getCurrentUserId());
foreach($listTags as $t) {
echo "{tag: \"".$t['tag']."\"},";
}
$listTags = $b2tservice->getContactTags(
$userservice->getCurrentUserId(), 1000, $userservice->getCurrentUserId()
);
foreach ($listTags as $t) {
echo "{tag: \"".$t['tag']."\"},";
}
?>
]}

View File

@ -24,33 +24,36 @@ $httpContentType = 'application/json';
require_once '../www-header.php';
/* Service creation: only useful services are created */
$b2tservice =SemanticScuttle_Service_Factory::get('Bookmark2Tag');
$bookmarkservice =SemanticScuttle_Service_Factory::get('Tag');
$tagstatservice =SemanticScuttle_Service_Factory::get('TagStat');
$b2tservice = SemanticScuttle_Service_Factory::get('Bookmark2Tag');
$bookmarkservice = SemanticScuttle_Service_Factory::get('Tag');
$tagstatservice = SemanticScuttle_Service_Factory::get('TagStat');
/* Managing all possible inputs */
isset($_GET['tag']) ? define('GET_TAG', $_GET['tag']): define('GET_TAG', '');
isset($_GET['uId']) ? define('GET_UID', $_GET['uId']): define('GET_UID', '');
function displayTag($tag, $uId) {
$uId = ($uId==0)?NULL:$uId; // if user is nobody, NULL allows to look for every public tags
$tag2tagservice =SemanticScuttle_Service_Factory::get('Tag2Tag');
$output = '{ id:'.rand().', name:\''.$tag.'\'';
function displayTag($tag, $uId)
{
// if user is nobody, NULL allows to look for every public tags
$uId = ($uId==0) ? null : $uId;
$linkedTags = $tag2tagservice->getLinkedTags($tag, '>', $uId);
if(count($linkedTags) > 0) {
$output.= ', children: [';
foreach($linkedTags as $linkedTag) {
$output.= displayTag($linkedTag, $uId);
}
$output = substr($output, 0, -1); // remove final comma avoiding IE6 Dojo bug
$output.= "]";
}
$tag2tagservice =SemanticScuttle_Service_Factory::get('Tag2Tag');
$output = '{ id:'.rand().', name:\''.$tag.'\'';
$output.= '},';
return $output;
$linkedTags = $tag2tagservice->getLinkedTags($tag, '>', $uId);
if (count($linkedTags) > 0) {
$output.= ', children: [';
foreach ($linkedTags as $linkedTag) {
$output.= displayTag($linkedTag, $uId);
}
// remove final comma avoiding IE6 Dojo bug
$output = substr($output, 0, -1);
$output.= "]";
}
$output.= '},';
return $output;
}
?>
@ -58,7 +61,8 @@ function displayTag($tag, $uId) {
{ label: 'name', identifier: 'id', items: [
<?php
$json = displayTag(GET_TAG, intval(GET_UID));
$json = substr($json, 0, -1); // remove final comma avoiding IE6 Dojo bug
// remove final comma avoiding IE6 Dojo bug
$json = substr($json, 0, -1);
echo $json;
?>
] }

View File

@ -19,26 +19,25 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
***************************************************************************/
/* Return a json file with list of tags according to current user and sort by popularity*/
/* Return a json file with list of tags according */
/* to current user and sort by popularity */
$httpContentType = 'application/json';
require_once '../www-header.php';
/* Service creation: only useful services are created */
$b2tservice =SemanticScuttle_Service_Factory::get('Bookmark2Tag');
$bookmarkservice =SemanticScuttle_Service_Factory::get('Tag');
$b2tservice = SemanticScuttle_Service_Factory::get('Bookmark2Tag');
$bookmarkservice = SemanticScuttle_Service_Factory::get('Tag');
?>
{identifier:"tag",
items: [
<?php
$listTags = $b2tservice->getPopularTags($userservice->getCurrentUserId(), 1000, $userservice->getCurrentUserId());
foreach($listTags as $t) {
echo "{tag: \"".$t['tag']."\"},";
}
$listTags = $b2tservice->getPopularTags(
$userservice->getCurrentUserId(), 1000, $userservice->getCurrentUserId()
);
foreach ($listTags as $t) {
echo "{tag: \"".$t['tag']."\"},";
}
?>
]}

View File

@ -28,38 +28,39 @@ require_once 'www-header.php';
/* Managing all possible inputs */
isset($_GET['url']) ? define('GET_URL', $_GET['url']): define('GET_URL', '');
function getTitle($url) {
$fd = @fopen($url, 'r');
if ($fd) {
$html = fread($fd, 1750);
fclose($fd);
function getTitle($url)
{
$fd = @fopen($url, 'r');
if ($fd) {
$html = fread($fd, 1750);
fclose($fd);
// Get title from title tag
preg_match_all('/<title>(.*)<\/title>/si', $html, $matches);
$title = $matches[1][0];
// Get title from title tag
preg_match_all('/<title>(.*)<\/title>/si', $html, $matches);
$title = $matches[1][0];
// Get encoding from charset attribute
preg_match_all('/<meta.*charset=([^;"]*)">/i', $html, $matches);
$encoding = strtoupper($matches[1][0]);
// Get encoding from charset attribute
preg_match_all('/<meta.*charset=([^;"]*)">/i', $html, $matches);
$encoding = strtoupper($matches[1][0]);
// Convert to UTF-8 from the original encoding
if (function_exists("mb_convert_encoding")) {
$title = @mb_convert_encoding($title, 'UTF-8', $encoding);
}
// Convert to UTF-8 from the original encoding
if (function_exists("mb_convert_encoding")) {
$title = @mb_convert_encoding($title, 'UTF-8', $encoding);
}
if (utf8_strlen($title) > 0) {
return $title;
} else {
// No title, so return filename
$uriparts = explode('/', $url);
$filename = end($uriparts);
unset($uriparts);
if (utf8_strlen($title) > 0) {
return $title;
} else {
// No title, so return filename
$uriparts = explode('/', $url);
$filename = end($uriparts);
unset($uriparts);
return $filename;
}
} else {
return false;
}
return $filename;
}
} else {
return false;
}
}
echo '<?xml version="1.0" encoding="utf-8"?>';
?>

View File

@ -30,37 +30,35 @@ list($url, $user) = explode(
isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : '/'
);
if (!$user) {
header('Location: '. createURL('populartags'));
exit;
header('Location: '. createURL('populartags'));
exit;
}
if ($usecache) {
// Generate hash for caching on
$hashtext = $_SERVER['REQUEST_URI'];
if ($userservice->isLoggedOn()) {
$hashtext .= $userservice->getCurrentUserID();
}
$hash = md5($hashtext);
// Generate hash for caching on
$hashtext = $_SERVER['REQUEST_URI'];
if ($userservice->isLoggedOn()) {
$hashtext .= $userservice->getCurrentUserID();
}
$hash = md5($hashtext);
// Cache for an hour
$cacheservice->Start($hash, 3600);
// Cache for an hour
$cacheservice->Start($hash, 3600);
}
// Header variables
$pagetitle = T_('All Tags');
if (isset($user) && $user != '') {
$userid = $userservice->getIdFromUser($user);
if($userid == NULL) {
$tplVars['error'] = sprintf(T_('User with username %s was not found'), $user);
$templateservice->loadTemplate('error.404.tpl', $tplVars);
exit();
}
$pagetitle .= ': '. ucfirst($user);
$userid = $userservice->getIdFromUser($user);
if ($userid == null) {
$tplVars['error'] = sprintf(T_('User with username %s was not found'), $user);
$templateservice->loadTemplate('error.404.tpl', $tplVars);
exit();
}
$pagetitle .= ': '. ucfirst($user);
} else {
$userid = NULL;
$userid = null;
}
$tags =& $b2tservice->getTags($userid);
@ -68,9 +66,9 @@ $tplVars['tags'] =& $b2tservice->tagCloud($tags, 5, 90, 225, getSortOrder());
$tplVars['user'] = $user;
if (isset($userid)) {
$tplVars['cat_url'] = createURL('bookmarks', '%s/%s');
$tplVars['cat_url'] = createURL('bookmarks', '%s/%s');
} else {
$tplVars['cat_url'] = createURL('tags', '%2$s');
$tplVars['cat_url'] = createURL('tags', '%2$s');
}
$tplVars['sidebar_blocks'] = array('linked');
@ -82,7 +80,7 @@ $tplVars['subtitle'] = $pagetitle;
$templateservice->loadTemplate('tags.tpl', $tplVars);
if ($usecache) {
// Cache output if existing copy has expired
$cacheservice->End($hash);
// Cache output if existing copy has expired
$cacheservice->End($hash);
}
?>

View File

@ -20,7 +20,7 @@ require_once 'httpauth.inc.php';
header("Content-disposition: filename=exportBookmarks.csv");
/* Service creation: only useful services are created */
$bookmarkservice =SemanticScuttle_Service_Factory::get('Bookmark');
$bookmarkservice = SemanticScuttle_Service_Factory::get('Bookmark');
// Check to see if a tag was specified.
if (isset($_REQUEST['tag']) && (trim($_REQUEST['tag']) != '')) {
@ -40,22 +40,27 @@ $bookmarks = $bookmarkservice->getBookmarks(
echo 'url;title;tags;description';
echo "\n";
foreach($bookmarks['bookmarks'] as $row) {
if (is_null($row['bDescription']) || (trim($row['bDescription']) == ''))
foreach ($bookmarks['bookmarks'] as $row) {
if (is_null($row['bDescription']) || (trim($row['bDescription']) == '')) {
$description = '';
else
$description = filter(str_replace(array("\r\n", "\n", "\r"),"", $row['bDescription']), 'xml');
} else {
$description = filter(
str_replace(array("\r\n", "\n", "\r"), "", $row['bDescription']), 'xml'
);
}
$taglist = '';
if (count($row['tags']) > 0) {
foreach($row['tags'] as $tag)
foreach ($row['tags'] as $tag) {
$taglist .= convertTag($tag) .',';
}
$taglist = substr($taglist, 0, -1);
} else {
$taglist = 'system:unfiled';
}
echo '"'.filter($row['bAddress'], 'xml') .'";"'. filter($row['bTitle'], 'xml') .'";"'. filter($taglist, 'xml') .'";"'. $description .'"';
echo '"'.filter($row['bAddress'], 'xml') .'";"'. filter($row['bTitle'], 'xml') .
'";"'. filter($taglist, 'xml') .'";"'. $description .'"';
echo "\n";
}

View File

@ -1,21 +1,33 @@
<?php
/*
Export for Google Custom Search
/**
* Export for Google Custom Search
*
* 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
*/
// Force HTTP authentication first!
//require_once('httpauth.inc.php');
$httpContentType = false;
require_once '../www-header.php';
if($GLOBALS['enableGoogleCustomSearch'] == false) {
echo "Google Custom Search disabled. You can enable it into the config.php file.";
if ($GLOBALS['enableGoogleCustomSearch'] == false) {
echo "Google Custom Search disabled. " .
"You can enable it into the config.php file.";
die;
}
/* Service creation: only useful services are created */
$bookmarkservice =SemanticScuttle_Service_Factory::get('Bookmark');
$bookmarkservice = SemanticScuttle_Service_Factory::get('Bookmark');
/*
// Restrict to admins?
@ -24,44 +36,48 @@ $bookmarkservice =SemanticScuttle_Service_Factory::get('Bookmark');
}*/
// Check if queried format is xml
if (isset($_REQUEST['xml']) && (trim($_REQUEST['xml']) == 1))
$xml = true;
else
$xml = false;
if (isset($_REQUEST['xml']) && (trim($_REQUEST['xml']) == 1)) {
$xml = true;
} else {
$xml = false;
}
// Check to see if a tag was specified.
if (isset($_REQUEST['tag']) && (trim($_REQUEST['tag']) != ''))
$tag = trim($_REQUEST['tag']);
else
$tag = NULL;
if (isset($_REQUEST['tag']) && (trim($_REQUEST['tag']) != '')) {
$tag = trim($_REQUEST['tag']);
} else {
$tag = null;
}
// Get the posts relevant to the passed-in variables.
$bookmarks =& $bookmarkservice->getBookmarks(0, NULL, NULL, $tag, NULL, getSortOrder());
$bookmarks =& $bookmarkservice->getBookmarks(
0, null, null, $tag, null, getSortOrder()
);
// Set up the plain file and output all the posts.
header('Content-Type: text/plain; charset=utf-8');
if(!$xml) {
header('Content-Type: text/plain');
foreach($bookmarks['bookmarks'] as $row) {
if(checkUrl($row['bAddress'], false)) {
echo $row['bAddress']."\n";
}
}
if (!$xml) {
header('Content-Type: text/plain');
foreach ($bookmarks['bookmarks'] as $row) {
if (checkUrl($row['bAddress'], false)) {
echo $row['bAddress']."\n";
}
}
} else {
header('Content-Type: text/xml');
echo '<GoogleCustomizations>'."\n";
echo ' <Annotations>'."\n";
foreach($bookmarks['bookmarks'] as $row) {
//if(substr($row['bAddress'], 0, 7) == "http://") {
if(checkUrl($row['bAddress'], false)) {
echo ' <Annotation about="'.filter($row['bAddress']).'">'."\n";
echo ' <Label name="include"/>'."\n";
echo ' </Annotation>'."\n";
}
}
echo ' </Annotations>'."\n";
echo '</GoogleCustomizations>'."\n";
header('Content-Type: text/xml');
echo '<GoogleCustomizations>'."\n";
echo ' <Annotations>'."\n";
foreach ($bookmarks['bookmarks'] as $row) {
//if(substr($row['bAddress'], 0, 7) == "http://") {
if (checkUrl($row['bAddress'], false)) {
echo ' <Annotation about="'.filter($row['bAddress']).'">'."\n";
echo ' <Label name="include"/>'."\n";
echo ' </Annotation>'."\n";
}
}
echo ' </Annotations>'."\n";
echo '</GoogleCustomizations>'."\n";
}
?>

View File

@ -48,11 +48,13 @@ echo '<!DOCTYPE NETSCAPE-Bookmark-file-1>'."\r\n";
echo '<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8" />';
echo '<!-- This is an automatically generated file. -->'."\r\n";
echo '<TITLE>Bookmarks</TITLE>'."\r\n";
echo '<H1 LAST_MODIFIED="'. date('U') .'">Bookmarks for '. htmlspecialchars($currentUser->getUsername()) .''. (is_null($tag) ? '' : ' tag="'. htmlspecialchars($tag) .'"') ." from " . $sitename ."</H1>\r\n";
echo '<H1 LAST_MODIFIED="'. date('U');
echo '">Bookmarks for '. htmlspecialchars($currentUser->getUsername());
echo (is_null($tag) ? '' : ' tag="'. htmlspecialchars($tag) .'"');
echo ' from ' . $sitename .'</H1>\r\n';
echo '<DL>'."\r\n";
foreach ($bookmarks['bookmarks'] as $row) {
if (is_null($row['bDescription']) || (trim($row['bDescription']) == '')) {
$description = '';
@ -71,7 +73,11 @@ foreach ($bookmarks['bookmarks'] as $row) {
$taglist = 'system:unfiled';
}
echo "\t<DT><A HREF=\"". filter($row['bAddress'], 'xml') .'" '. $description .' hash="'. md5($row['bAddress']) .'" tags="'. filter($taglist, 'xml') .'" ADD_DATE="'. date('U', strtotime($row['bDatetime'])) ."\" >" . filter($row['bTitle'], 'xml') ."</a>\r\n";
echo "\t<DT><A HREF=\"". filter($row['bAddress'], 'xml') .'" ';
echo $description .' hash="'. md5($row['bAddress']) .'" tags="';
echo filter($taglist, 'xml') .'" ADD_DATE="';
echo date('U', strtotime($row['bDatetime']));
echo "\" >" . filter($row['bTitle'], 'xml') ."</a>\r\n";
}

View File

@ -1,12 +1,29 @@
<?php
/* Export data with semantic format (SIOC: http://sioc-project.org/, FOAF, SKOS, Annotea Ontology) */
/**
* Export data with semantic format
*
* (SIOC: http://sioc-project.org/, FOAF, SKOS, Annotea Ontology)
*
* 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
*/
$httpContentType = 'text/xml';
require_once '../www-header.php';
/* Service creation: only useful services are created */
$userservice =SemanticScuttle_Service_Factory::get('User');
$bookmarkservice =SemanticScuttle_Service_Factory::get('Bookmark');
$userservice = SemanticScuttle_Service_Factory::get('User');
$bookmarkservice = SemanticScuttle_Service_Factory::get('Bookmark');
?>
<?php echo "<?xml version=\"1.0\" encoding=\"utf-8\"\n?>"; ?>
@ -37,19 +54,17 @@ $bookmarkservice =SemanticScuttle_Service_Factory::get('Bookmark');
$users = $userservice->getObjectUsers();
$usersArray = array(); // useful for bookmarks display
foreach($users as $user) {
$usersArray[$user->getId()] = $user->getUserName();
foreach ($users as $user) {
$usersArray[$user->getId()] = $user->getUserName();
}
?>
<?php foreach($users as $user) :?>
<sioc:User rdf:about="<?php echo createUrl('profile', $user->getUserName())?>">
<sioc:name><?php echo $user->getUserName() ?></sioc:name>
<sioc:member_of rdf:resource="<?php echo ROOT?>" />
</sioc:User>
<?php endforeach; ?>
<?php
foreach ($users as $user) { ?>
<sioc:User rdf:about="<?php echo createUrl('profile', $user->getUserName())?>">
<sioc:name><?php echo $user->getUserName() ?></sioc:name>
<sioc:member_of rdf:resource="<?php echo ROOT?>" />
</sioc:User>
<?php
}
/*
No page for usergroup (users/admin) for the moment
<sioc:Usergroup rdf:ID="authors">
@ -57,31 +72,33 @@ No page for usergroup (users/admin) for the moment
<sioc:has_member rdf:nodeID="sioc-id2245901" />
</sioc:Usergroup>
*/
?>
<?php
//bookmarks are described using Annotea ontology
$bookmarks =& $bookmarkservice->getBookmarks(0, NULL, NULL, NULL);
?>
$bookmarks =& $bookmarkservice->getBookmarks(0, null, null, null);
<?php foreach($bookmarks['bookmarks'] as $bookmark): ?>
<bm:Bookmark rdf:about="<?php echo createUrl('history', $bookmark['bHash']) ?>">
<dc:title><?php echo filter($bookmark['bTitle']) ?></dc:title>
<dc:created><?php echo filter($bookmark['bCreated']) ?></dc:created>
<dc:description><?php echo filter(strip_tags($bookmark['bDescription'])) ?></dc:description>
<dc:date><?php echo $bookmark['bDateTime'] ?></dc:date>
<bm:recalls rdf:resource="<?php echo filter($bookmark['bAddress']) ?>"/>
<sioc:owner_of rdf:resource="<?php echo createUrl('profile', $usersArray[$bookmark['uId']]) ?>"/>
<?php foreach($bookmark['tags'] as $tag): ?>
<sioc:topic>
<skos:concept rdf:about="<?php echo createUrl('bookmarks', $usersArray[$bookmark['uId']].'/'.$tag) ?>" />
</sioc:topic>
<?php endforeach; ?>
</bm:Bookmark>
<?php endforeach; ?>
foreach ($bookmarks['bookmarks'] as $bookmark) { ?>
<bm:Bookmark rdf:about="<?php echo createUrl('history', $bookmark['bHash']) ?>">
<dc:title><?php echo filter($bookmark['bTitle']) ?></dc:title>
<dc:created><?php echo filter($bookmark['bCreated']) ?></dc:created>
<dc:description><?php echo filter(strip_tags($bookmark['bDescription'])) ?>
</dc:description>
<dc:date><?php echo $bookmark['bDateTime'] ?></dc:date>
<bm:recalls rdf:resource="<?php echo filter($bookmark['bAddress']) ?>"/>
<sioc:owner_of rdf:resource="<?php
echo createUrl('profile', $usersArray[$bookmark['uId']])
?>"/>
<?php foreach ($bookmark['tags'] as $tag) { ?>
<sioc:topic>
<skos:concept rdf:about="<?php
echo createUrl('bookmarks', $usersArray[$bookmark['uId']].'/'.$tag)
?>" />
</sioc:topic>
<?php } ?>
</bm:Bookmark>
<?php
}
<?php
// tags and concepts are described using SKOS ontology
//concept for user/admins, preflabel, definition, top concept
?>

View File

@ -1,4 +1,5 @@
<?php
/**
* Checks if the user is logged on and sends a HTTP basic auth
* request to the browser if not. In that case the script ends.
@ -17,51 +18,59 @@
* @license GPL http://www.gnu.org/licenses/gpl.html
* @link http://sourceforge.net/projects/semanticscuttle
*/
require_once '../www-header.php';
/**
* Sends HTTP auth headers to the browser
*
* @return nothing
*/
function authenticate()
{
header('WWW-Authenticate: Basic realm="SemanticScuttle API"');
header('HTTP/1.0 401 Unauthorized');
header('WWW-Authenticate: Basic realm="SemanticScuttle API"');
header('HTTP/1.0 401 Unauthorized');
die(T_("Use of the API calls requires authentication."));
die(T_("Use of the API calls requires authentication."));
}
if (!$userservice->isLoggedOn()) {
/* First check to see if a private key was sent */
if (isset($_POST['privatekey']) {
$login = $userservice->loginPK($_POST['privatekey']);
if ($login) {
$currentUser = $userservice->getCurrentObjectUser();
return;
} else {
/* is someone hacking? */
/* TODO: Track attempts */
}
}
/* First check to see if a private key was sent */
if (isset($_POST['privatekey'])) {
$login = $userservice->loginPK($_POST['privatekey']);
if ($login) {
$currentUser = $userservice->getCurrentObjectUser();
return;
} else {
/* is someone hacking? */
/* TODO: Track attempts */
}
}
/* Maybe we have caught authentication data in $_SERVER['REMOTE_USER']
( Inspired by http://www.yetanothercommunitysystem.com/article-321-regle-comment-utiliser-l-authentification-http-en-php-chez-ovh ) */
if ((!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW']))
&& isset($_SERVER['REMOTE_USER'])
&& preg_match('/Basic\s+(.*)$/i', $_SERVER['REMOTE_USER'], $matches)) {
list($name, $password) = explode(':', base64_decode($matches[1]));
$_SERVER['PHP_AUTH_USER'] = strip_tags($name);
$_SERVER['PHP_AUTH_PW'] = strip_tags($password);
}
/* Maybe we have caught authentication data in $_SERVER['REMOTE_USER']
( Inspired by http://www.yetanothercommunitysystem.com/article-321-regle-comment-utiliser-l-authentification-http-en-php-chez-ovh ) */
if ((!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW']))
&& isset($_SERVER['REMOTE_USER'])
&& preg_match('/Basic\s+(.*)$/i', $_SERVER['REMOTE_USER'], $matches)
) {
list($name, $password) = explode(':', base64_decode($matches[1]));
$_SERVER['PHP_AUTH_USER'] = strip_tags($name);
$_SERVER['PHP_AUTH_PW'] = strip_tags($password);
}
if (!isset($_SERVER['PHP_AUTH_USER'])) {
authenticate();
} else {
$login = $userservice->login($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
if ($login) {
$currentUser = $userservice->getCurrentObjectUser();
} else {
authenticate();
}
}
if (!isset($_SERVER['PHP_AUTH_USER'])) {
authenticate();
} else {
$login = $userservice->login(
$_SERVER['PHP_AUTH_USER'],
$_SERVER['PHP_AUTH_PW']
);
if ($login) {
$currentUser = $userservice->getCurrentObjectUser();
} else {
authenticate();
}
}
}
?>

View File

@ -1,7 +1,22 @@
<?php
/**
* Perform OpenSearch
*
* 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
*/
$httpContentType = 'text/xml';
require_once '../www-header.php';
?>
<?xml version="1.0" encoding="utf-8" ?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<ShortName><?php echo $GLOBALS['sitename']?></ShortName>

View File

@ -2,7 +2,10 @@
/**
* API for adding a new bookmark.
*
* PHP version 5.
*
* The following POST and GET parameters are accepted:
*
* @param string $url URL of the bookmark (required)
* @param string $description Bookmark title (required)
* @param string $extended Extended bookmark description (optional)
@ -28,8 +31,6 @@
*
* SemanticScuttle - your social bookmark manager.
*
* PHP version 5.
*
* @category Bookmarking
* @package SemanticScuttle
* @author Benjamin Huynh-Kim-Bang <mensonge@users.sourceforge.net>
@ -38,7 +39,7 @@
* @license GPL http://www.gnu.org/licenses/gpl.html
* @link http://sourceforge.net/projects/semanticscuttle
* @link http://www.delicious.com/help/api
*/
*/
// Force HTTP authentication
$httpContentType = 'text/xml';
@ -143,4 +144,4 @@ if (is_null($url)) {
// Set up the XML file and output the result.
echo '<?xml version="1.0" standalone="yes" ?' . ">\r\n";
echo '<result code="' . $msg .'" />';
?>
?>

View File

@ -1,47 +1,70 @@
<?php
// Implements the del.icio.us API request for all a user's posts, optionally filtered by tag.
/**
* Implements the del.icio.us API request for all a user's posts
* optionally filtered by tag.
*
* del.icio.us behavior:
* - doesn't include the filtered tag as an attribute on the root element (we do)
*
* 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
*/
// del.icio.us behavior:
// - doesn't include the filtered tag as an attribute on the root element (we do)
// Force HTTP authentication first!
//Force HTTP authentication first!
$httpContentType = 'text/xml';
require_once 'httpauth.inc.php';
/* Service creation: only useful services are created */
$bookmarkservice =SemanticScuttle_Service_Factory::get('Bookmark');
$bookmarkservice = SemanticScuttle_Service_Factory::get('Bookmark');
// Check to see if a tag was specified.
if (isset($_REQUEST['tag']) && (trim($_REQUEST['tag']) != ''))
if (isset($_REQUEST['tag']) && (trim($_REQUEST['tag']) != '')) {
$tag = trim($_REQUEST['tag']);
else
$tag = NULL;
} else {
$tag = null;
}
// Get the posts relevant to the passed-in variables.
$bookmarks =& $bookmarkservice->getBookmarks(0, NULL, $userservice->getCurrentUserId(), $tag);
$bookmarks =& $bookmarkservice->getBookmarks(
0, null, $userservice->getCurrentUserId(), $tag
);
// Set up the XML file and output all the posts.
echo '<?xml version="1.0" standalone="yes" ?'.">\r\n";
echo '<posts update="'. gmdate('Y-m-d\TH:i:s\Z') .'" user="'. htmlspecialchars($currentUser->getUsername()) .'"'. (is_null($tag) ? '' : ' tag="'. htmlspecialchars($tag) .'"') .">\r\n";
echo '<posts update="'. gmdate('Y-m-d\TH:i:s\Z');
echo '" user="'. htmlspecialchars($currentUser->getUsername());
echo '"'. (is_null($tag) ? '' : ' tag="'. htmlspecialchars($tag) .'"') .">\r\n";
foreach($bookmarks['bookmarks'] as $row) {
if (is_null($row['bDescription']) || (trim($row['bDescription']) == ''))
foreach ($bookmarks['bookmarks'] as $row) {
if (is_null($row['bDescription']) || (trim($row['bDescription']) == '')) {
$description = '';
else
} else {
$description = 'extended="'. filter($row['bDescription'], 'xml') .'" ';
}
$taglist = '';
if (count($row['tags']) > 0) {
foreach($row['tags'] as $tag)
foreach ($row['tags'] as $tag) {
$taglist .= convertTag($tag) .' ';
}
$taglist = substr($taglist, 0, -1);
} else {
$taglist = 'system:unfiled';
}
echo "\t<post href=\"". filter($row['bAddress'], 'xml') .'" description="'. filter($row['bTitle'], 'xml') .'" '. $description .'hash="'. md5($row['bAddress']) .'" tag="'. filter($taglist, 'xml') .'" time="'. gmdate('Y-m-d\TH:i:s\Z', strtotime($row['bDatetime'])) ."\" />\r\n";
echo "\t<post href=\"". filter($row['bAddress'], 'xml');
echo '" description="'. filter($row['bTitle'], 'xml');
echo '" '. $description .'hash="'. md5($row['bAddress']);
echo '" tag="'. filter($taglist, 'xml') .'" time="';
echo gmdate('Y-m-d\TH:i:s\Z', strtotime($row['bDatetime'])) ."\" />\r\n";
}
echo '</posts>';
?>
?>

View File

@ -38,7 +38,8 @@ $bookmarks = $bookmarkservice->getBookmarks(
// Set up the XML file and output all the tags.
echo '<?xml version="1.0" standalone="yes" ?'.">\r\n";
echo '<dates tag="'. (is_null($tag) ? '' : filter($tag, 'xml')) .'" user="'. filter($currentUser->getUsername(), 'xml') ."\">\r\n";
echo '<dates tag="'. (is_null($tag) ? '' : filter($tag, 'xml'));
echo '" user="'. filter($currentUser->getUsername(), 'xml') ."\">\r\n";
$lastdate = null;
$count = 0;
@ -57,4 +58,4 @@ if ($lastdate !== null) {
}
echo "</dates>";
?>
?>

View File

@ -6,7 +6,8 @@
* uses GMT dates -- so we do too.
*
* del.icio.us behavior:
* - includes an empty tag attribute on the root element when it hasn't been specified
* - includes an empty tag attribute on the root element
* when it hasn't been specified
*
* Scuttle behavior:
* - Uses today, instead of the last bookmarked date, if no date is specified
@ -56,7 +57,9 @@ $bookmarks = $bookmarkservice->getBookmarks(
// Set up the XML file and output all the tags.
echo '<?xml version="1.0" standalone="yes" ?'.">\r\n";
echo '<posts'. (is_null($dtstart) ? '' : ' dt="'. $dtstart .'"') .' tag="'. (is_null($tag) ? '' : filter($tag, 'xml')) .'" user="'. filter($currentUser->getUsername(), 'xml') ."\">\r\n";
echo '<posts'. (is_null($dtstart) ? '' : ' dt="'. $dtstart .'"') .' tag="';
echo (is_null($tag) ? '' : filter($tag, 'xml')) .'" user="';
echo filter($currentUser->getUsername(), 'xml') ."\">\r\n";
foreach ($bookmarks['bookmarks'] as $row) {
if (is_null($row['bDescription']) || (trim($row['bDescription']) == '')) {
@ -75,8 +78,14 @@ foreach ($bookmarks['bookmarks'] as $row) {
$taglist = 'system:unfiled';
}
echo "\t<post href=\"". filter($row['bAddress'], 'xml') .'" description="'. filter($row['bTitle'], 'xml') .'" '. $description .'hash="'. $row['bHash'] .'" others="'. $bookmarkservice->countOthers($row['bAddress']) .'" tag="'. filter($taglist, 'xml') .'" time="'. gmdate('Y-m-d\TH:i:s\Z', strtotime($row['bDatetime'])) ."\" />\r\n";
echo "\t<post href=\"". filter($row['bAddress'], 'xml');
echo '" description="'. filter($row['bTitle'], 'xml');
echo '" '. $description .'hash="'. $row['bHash'];
echo '" others="'. $bookmarkservice->countOthers($row['bAddress']);
echo '" tag="'. filter($taglist, 'xml');
echo '" time="'. gmdate('Y-m-d\TH:i:s\Z', strtotime($row['bDatetime'])) ."\" />";
echo "\r\n";
}
echo '</posts>';
?>
?>

View File

@ -1,8 +1,21 @@
<?php
// Implements the del.icio.us API request for all a user's posts, optionally filtered by tag.
// del.icio.us behavior:
// - doesn't include the filtered tag as an attribute on the root element (we do)
/**
* Implements the del.icio.us API request for all a user's posts
* optionally filtered by tag.
*
* del.icio.us behavior:
* - doesn't include the filtered tag as an attribute on the root element (we do)
*
* 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
*/
// Force HTTP authentication first!
//require_once('httpauth.inc.php');
@ -10,38 +23,46 @@ $httpContentType = 'text/xml';
require_once '../www-header.php';
/* Service creation: only useful services are created */
$bookmarkservice =SemanticScuttle_Service_Factory::get('Bookmark');
$bookmarkservice = SemanticScuttle_Service_Factory::get('Bookmark');
// Check to see if a tag was specified.
if (isset($_REQUEST['tag']) && (trim($_REQUEST['tag']) != ''))
if (isset($_REQUEST['tag']) && (trim($_REQUEST['tag']) != '')) {
$tag = trim($_REQUEST['tag']);
else
$tag = NULL;
} else {
$tag = null;
}
// Get the posts relevant to the passed-in variables.
$bookmarks =& $bookmarkservice->getBookmarks(0, NULL, NULL, $tag);
$bookmarks =& $bookmarkservice->getBookmarks(0, null, null, $tag);
// Set up the XML file and output all the posts.
echo '<?xml version="1.0" standalone="yes" ?'.">\r\n";
echo '<posts update="'. gmdate('Y-m-d\TH:i:s\Z') .'" '. (is_null($tag) ? '' : ' tag="'. htmlspecialchars($tag) .'"') .">\r\n";
echo '<posts update="'. gmdate('Y-m-d\TH:i:s\Z') .'" ';
echo (is_null($tag) ? '' : ' tag="'. htmlspecialchars($tag) .'"') .">\r\n";
foreach($bookmarks['bookmarks'] as $row) {
if (is_null($row['bDescription']) || (trim($row['bDescription']) == ''))
foreach ($bookmarks['bookmarks'] as $row) {
if (is_null($row['bDescription']) || (trim($row['bDescription']) == '')) {
$description = '';
else
} else {
$description = 'extended="'. filter($row['bDescription'], 'xml') .'" ';
}
$taglist = '';
if (count($row['tags']) > 0) {
foreach($row['tags'] as $tag)
foreach ($row['tags'] as $tag) {
$taglist .= convertTag($tag) .' ';
}
$taglist = substr($taglist, 0, -1);
} else {
$taglist = 'system:unfiled';
}
echo "\t<post href=\"". filter($row['bAddress'], 'xml') .'" description="'. filter($row['bTitle'], 'xml') .'" '. $description .'hash="'. md5($row['bAddress']) .'" tag="'. filter($taglist, 'xml') .'" time="'. gmdate('Y-m-d\TH:i:s\Z', strtotime($row['bDatetime'])) ."\" />\r\n";
echo "\t<post href=\"". filter($row['bAddress'], 'xml');
echo '" description="'. filter($row['bTitle'], 'xml');
echo '" '. $description .'hash="'. md5($row['bAddress']);
echo '" tag="'. filter($taglist, 'xml');
echo '" time="'. gmdate('Y-m-d\TH:i:s\Z', strtotime($row['bDatetime'])) ."\" />";
echo "\r\n";
}
echo '</posts>';

View File

@ -56,7 +56,8 @@ $bookmarks = $bookmarkservice->getBookmarks(
// Set up the XML file and output all the tags.
echo '<?xml version="1.0" standalone="yes" ?'.">\r\n";
echo '<posts tag="'. (is_null($tag) ? '' : filter($tag, 'xml')) .'" user="'. filter($currentUser->getUsername(), 'xml') ."\">\r\n";
echo '<posts tag="'. (is_null($tag) ? '' : filter($tag, 'xml'));
echo '" user="'. filter($currentUser->getUsername(), 'xml') ."\">\r\n";
foreach ($bookmarks['bookmarks'] as $row) {
if (is_null($row['bDescription']) || (trim($row['bDescription']) == '')) {
@ -75,8 +76,13 @@ foreach ($bookmarks['bookmarks'] as $row) {
$taglist = 'system:unfiled';
}
echo "\t<post href=\"". filter($row['bAddress'], 'xml') .'" description="'. filter($row['bTitle'], 'xml') .'" '. $description .'hash="'. $row['bHash'] .'" tag="'. filter($taglist, 'xml') .'" time="'. gmdate('Y-m-d\TH:i:s\Z', strtotime($row['bDatetime'])) ."\" />\r\n";
echo "\t<post href=\"". filter($row['bAddress'], 'xml');
echo '" description="'. filter($row['bTitle'], 'xml');
echo '" '. $description .'hash="'. $row['bHash'];
echo '" tag="'. filter($taglist, 'xml');
echo '" time="'. gmdate('Y-m-d\TH:i:s\Z', strtotime($row['bDatetime'])) ."\" />";
echo "\r\n";
}
echo '</posts>';
?>
?>

View File

@ -1,15 +1,29 @@
<?php
// Implements the del.icio.us API request for all a user's tags.
// del.icio.us behavior:
// - tags can't have spaces
/**
* Implements the del.icio.us API request for all a user's tags.
*
* del.icio.us behavior:
* - tags can't have spaces
*
* 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
*/
// Force HTTP authentication first!
$httpContentType = 'text/xml';
require_once 'httpauth.inc.php';
/* Service creation: only useful services are created */
$b2tservice =SemanticScuttle_Service_Factory::get('Bookmark2Tag');
$b2tservice = SemanticScuttle_Service_Factory::get('Bookmark2Tag');
// Get the tags relevant to the passed-in variables.
@ -18,8 +32,9 @@ $tags =& $b2tservice->getTags($userservice->getCurrentUserId());
// Set up the XML file and output all the tags.
echo '<?xml version="1.0" standalone="yes" ?'.">\r\n";
echo "<tags>\r\n";
foreach($tags as $row) {
echo "\t<tag count=\"". $row['bCount'] .'" tag="'. filter(convertTag($row['tag'], 'out'), 'xml') ."\" />\r\n";
foreach ($tags as $row) {
echo "\t<tag count=\"". $row['bCount'] .'" tag="';
echo filter(convertTag($row['tag'], 'out'), 'xml') ."\" />\r\n";
}
echo "</tags>";
?>

View File

@ -1,32 +1,49 @@
<?php
// Implements the del.icio.us API request to rename a user's tag.
// del.icio.us behavior:
// - oddly, returns an entirely different result (<result></result>) than the other API calls.
/**
* Implements the del.icio.us API request to rename a user's tag.
*
* del.icio.us behavior:
* - oddly, returns an entirely different result (<result></result>) than
* the other API calls.
*
* 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
*/
// Force HTTP authentication first!
$httpContentType = 'text/xml';
require_once 'httpauth.inc.php';
/* Service creation: only useful services are created */
$b2tservice =SemanticScuttle_Service_Factory::get('Bookmark2Tag');
$b2tservice = SemanticScuttle_Service_Factory::get('Bookmark2Tag');
// Get the tag info.
if (isset($_REQUEST['old']) && (trim($_REQUEST['old']) != ''))
if (isset($_REQUEST['old']) && (trim($_REQUEST['old']) != '')) {
$old = trim($_REQUEST['old']);
else
$old = NULL;
} else {
$old = null;
}
if (isset($_REQUEST['new']) && (trim($_REQUEST['new']) != ''))
if (isset($_REQUEST['new']) && (trim($_REQUEST['new']) != '')) {
$new = trim($_REQUEST['new']);
else
$new = NULL;
} else {
$new = null;
}
if (is_null($old) || is_null($new)) {
$renamed = false;
} else {
// Rename the tag.
$result = $b2tservice->renameTag($userservice->getCurrentUserId(), $old, $new, true);
$result = $b2tservice->renameTag(
$userservice->getCurrentUserId(), $old, $new, true
);
$renamed = $result;
}

View File

@ -33,46 +33,42 @@ isset($_POST['title']) ? define('POST_TITLE', $_POST['title']): define('POST_TIT
isset($_POST['description']) ? define('POST_DESCRIPTION', $_POST['description']): define('POST_DESCRIPTION', '');
// prevent cycle between personal and common edit page
if(!isset($_POST['referrer'])) {
define('POST_REFERRER', '');
} elseif(strpos($_POST['referrer'], ROOT.'edit.php') == 0) {
define('POST_REFERRER', createUrl('history', POST_HASH));
if (!isset($_POST['referrer'])) {
define('POST_REFERRER', '');
} elseif (strpos($_POST['referrer'], ROOT.'edit.php') == 0) {
define('POST_REFERRER', createUrl('history', POST_HASH));
} else {
define('POST_REFERRER', $_POST['referrer']);
define('POST_REFERRER', $_POST['referrer']);
}
list ($url, $hash) = explode('/', $_SERVER['PATH_INFO']);
$template = 'bookmarkcommondescriptionedit.tpl';
//permissions
if(is_null($currentUser)) {
$tplVars['error'] = T_('Permission denied.');
$templateservice->loadTemplate('error.500.tpl', $tplVars);
exit();
if (is_null($currentUser)) {
$tplVars['error'] = T_('Permission denied.');
$templateservice->loadTemplate('error.500.tpl', $tplVars);
exit();
}
if (POST_CONFIRM) {
if (strlen($hash)>0 &&
$cdservice->addBookmarkDescription(POST_HASH, stripslashes(POST_TITLE), stripslashes(POST_DESCRIPTION), $currentUser->getId(), time())
) {
$tplVars['msg'] = T_('Bookmark common description updated');
header('Location: '. POST_REFERRER);
} else {
$tplVars['error'] = T_('Failed to update the bookmark common description');
$template = 'error.500.tpl';
}
if (strlen($hash)>0 && $cdservice->addBookmarkDescription(POST_HASH, stripslashes(POST_TITLE), stripslashes(POST_DESCRIPTION), $currentUser->getId(), time())) {
$tplVars['msg'] = T_('Bookmark common description updated');
header('Location: '. POST_REFERRER);
} else {
$tplVars['error'] = T_('Failed to update the bookmark common description');
$template = 'error.500.tpl';
}
} elseif (POST_CANCEL) {
header('Location: '. POST_REFERRER);
header('Location: '. POST_REFERRER);
} else {
$bkm = $bookmarkservice->getBookmarkByHash($hash);
$bkm = $bookmarkservice->getBookmarkByHash($hash);
$tplVars['subtitle'] = T_('Edit Bookmark Common Description') .': '. $bkm['bAddress'];
$tplVars['formaction'] = $_SERVER['SCRIPT_NAME'] .'/'. $hash;
$tplVars['referrer'] = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
$tplVars['hash'] = $hash;
$tplVars['description'] = $cdservice->getLastBookmarkDescription($hash);
$tplVars['subtitle'] = T_('Edit Bookmark Common Description') .': '. $bkm['bAddress'];
$tplVars['formaction'] = $_SERVER['SCRIPT_NAME'] .'/'. $hash;
$tplVars['referrer'] = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
$tplVars['hash'] = $hash;
$tplVars['description'] = $cdservice->getLastBookmarkDescription($hash);
}
$templateservice->loadTemplate($template, $tplVars);
?>

View File

@ -22,8 +22,8 @@
require_once 'www-header.php';
/* Service creation: only useful services are created */
$bookmarkservice =SemanticScuttle_Service_Factory::get('Bookmark');
$cacheservice =SemanticScuttle_Service_Factory::get('Cache');
$bookmarkservice = SemanticScuttle_Service_Factory::get('Bookmark');
$cacheservice = SemanticScuttle_Service_Factory::get('Cache');
/* Managing all possible inputs */
isset($_GET['action']) ? define('GET_ACTION', $_GET['action']): define('GET_ACTION', '');
@ -53,70 +53,66 @@ isset($_GET['sort']) ? define('GET_SORT', $_GET['sort']): define('GET_SORT', '')
if ((GET_ACTION == "add") && !$userservice->isLoggedOn()) {
$loginqry = str_replace("'", '%27', stripslashes($_SERVER['QUERY_STRING']));
header('Location: '. createURL('login', '?'. $loginqry));
exit();
$loginqry = str_replace("'", '%27', stripslashes($_SERVER['QUERY_STRING']));
header('Location: '. createURL('login', '?'. $loginqry));
exit();
}
if ($userservice->isLoggedOn()) {
$currentUser = $userservice->getCurrentObjectUser();
$currentUserID = $currentUser->getId();
$currentUsername = $currentUser->getUsername();
$currentUser = $userservice->getCurrentObjectUser();
$currentUserID = $currentUser->getId();
$currentUsername = $currentUser->getUsername();
}
@list($url, $user, $cat) = isset($_SERVER['PATH_INFO']) ? explode('/', $_SERVER['PATH_INFO']) : NULL;
@list($url, $user, $cat) = isset($_SERVER['PATH_INFO']) ? explode('/', $_SERVER['PATH_INFO']) : null;
$endcache = false;
if ($usecache) {
// Generate hash for caching on
$hash = md5($_SERVER['REQUEST_URI'] . $user);
// Generate hash for caching on
$hash = md5($_SERVER['REQUEST_URI'] . $user);
// Don't cache if its users' own bookmarks
if ($userservice->isLoggedOn()) {
if ($currentUsername != $user) {
// Cache for 5 minutes
$cacheservice->Start($hash);
$endcache = true;
}
} else {
// Cache for 30 minutes
$cacheservice->Start($hash, 1800);
$endcache = true;
}
// Don't cache if its users' own bookmarks
if ($userservice->isLoggedOn()) {
if ($currentUsername != $user) {
// Cache for 5 minutes
$cacheservice->Start($hash);
$endcache = true;
}
} else {
// Cache for 30 minutes
$cacheservice->Start($hash, 1800);
$endcache = true;
}
}
$pagetitle = $rssCat = $catTitle = '';
if ($user) {
if (is_int($user)) {
$userid = intval($user);
} else {
if (!($userinfo = $userservice->getUserByUsername($user))) {
$tplVars['error'] = sprintf(T_('User with username %s was not found'), $user);
$templateservice->loadTemplate('error.404.tpl', $tplVars);
exit();
} else {
$userid =& $userinfo['uId'];
}
}
$pagetitle .= ': '. $user;
if (is_int($user)) {
$userid = intval($user);
} else {
if (!($userinfo = $userservice->getUserByUsername($user))) {
$tplVars['error'] = sprintf(T_('User with username %s was not found'), $user);
$templateservice->loadTemplate('error.404.tpl', $tplVars);
exit();
} else {
$userid =& $userinfo['uId'];
}
}
$pagetitle .= ': '. $user;
}
if ($cat) {
$catTitle = ': '. str_replace('+', ' + ', $cat);
$catTitle = ': '. str_replace('+', ' + ', $cat);
$catTitleWithUrls = ': ';
$titleTags = explode('+', filter($cat));
for($i = 0; $i<count($titleTags);$i++) {
$catTitleWithUrls.= $titleTags[$i].'<a href="'.createUrl('bookmarks', $user.'/'.aggregateTags($titleTags, '+', $titleTags[$i])).'" title="'.T_('Remove the tag from the selection').'">*</a> + ';
}
$catTitleWithUrls = substr($catTitleWithUrls, 0, strlen($catTitleWithUrls) - strlen(' + '));
$catTitleWithUrls = ': ';
$titleTags = explode('+', filter($cat));
for ($i = 0; $i<count($titleTags);$i++) {
$catTitleWithUrls.= $titleTags[$i].'<a href="'.createUrl('bookmarks', $user.'/'.aggregateTags($titleTags, '+', $titleTags[$i])).'" title="'.T_('Remove the tag from the selection').'">*</a> + ';
}
$catTitleWithUrls = substr($catTitleWithUrls, 0, strlen($catTitleWithUrls) - strlen(' + '));
$pagetitle .= $catTitleWithUrls;
}
else
{
$catTitleWithUrls = '';
$pagetitle .= $catTitleWithUrls;
} else {
$catTitleWithUrls = '';
}
$pagetitle = substr($pagetitle, 2);
@ -127,166 +123,167 @@ $tplVars['loadjs'] = true;
$saved = false;
$templatename = 'bookmarks.tpl';
if ($userservice->isLoggedOn() && POST_SUBMITTED != '') {
if (!POST_TITLE || !POST_ADDRESS) {
$tplVars['error'] = T_('Your bookmark must have a title and an address');
$templatename = 'editbookmark.tpl';
} else {
$address = trim(POST_ADDRESS);
// If the bookmark exists already, edit the original
if ($bookmarkservice->bookmarkExists($address, $currentUserID)) {
$bookmark = $bookmarkservice->getBookmarkByAddress($address);
header('Location: '. createURL('edit', $bookmark['bId']));
exit();
// If it's new, save it
} else {
$title = trim(POST_TITLE);
$description = trim(POST_DESCRIPTION);
$privateNote = trim(POST_PRIVATENOTE);
$status = intval(POST_STATUS);
$categories = trim(POST_TAGS);
$saved = true;
if ($bookmarkservice->addBookmark($address, $title, $description, $privateNote, $status, $categories)) {
if (POST_POPUP != '') {
$tplVars['msg'] = '<script type="text/javascript">window.close();</script>';
} else {
$tplVars['msg'] = T_('Bookmark saved') . ' <a href="javascript:history.go(-2)">'.T_('(Come back to previous page.)').'</a>';
// Redirection option
if ($GLOBALS['useredir']) {
$address = $GLOBALS['url_redir'] . $address;
}
}
} else {
$tplVars['error'] = T_('There was an error saving your bookmark. Please try again or contact the administrator.');
$templatename = 'editbookmark.tpl';
$saved = false;
}
}
}
if (!POST_TITLE || !POST_ADDRESS) {
$tplVars['error'] = T_('Your bookmark must have a title and an address');
$templatename = 'editbookmark.tpl';
} else {
$address = trim(POST_ADDRESS);
// If the bookmark exists already, edit the original
if ($bookmarkservice->bookmarkExists($address, $currentUserID)) {
$bookmark = $bookmarkservice->getBookmarkByAddress($address);
header('Location: '. createURL('edit', $bookmark['bId']));
exit();
} else {
// If it's new, save it
$title = trim(POST_TITLE);
$description = trim(POST_DESCRIPTION);
$privateNote = trim(POST_PRIVATENOTE);
$status = intval(POST_STATUS);
$categories = trim(POST_TAGS);
$saved = true;
if ($bookmarkservice->addBookmark($address, $title, $description, $privateNote, $status, $categories)) {
if (POST_POPUP != '') {
$tplVars['msg'] = '<script type="text/javascript">window.close();</script>';
} else {
$tplVars['msg'] = T_('Bookmark saved') . ' <a href="javascript:history.go(-2)">'.T_('(Come back to previous page.)').'</a>';
// Redirection option
if ($GLOBALS['useredir']) {
$address = $GLOBALS['url_redir'] . $address;
}
}
} else {
$tplVars['error'] = T_('There was an error saving your bookmark. Please try again or contact the administrator.');
$templatename = 'editbookmark.tpl';
$saved = false;
}
}
}
}
if (GET_ACTION == "add") {
// If the bookmark exists already, edit the original
if ($bookmarkservice->bookmarkExists(stripslashes(GET_ADDRESS), $currentUserID)) {
$bookmark =& $bookmarkservice->getBookmarks(0, NULL, $currentUserID, NULL, NULL, NULL, NULL, NULL, NULL, $bookmarkservice->getHash(stripslashes(GET_ADDRESS)));
$popup = (GET_POPUP!='') ? '?popup=1' : '';
header('Location: '. createURL('edit', $bookmark['bookmarks'][0]['bId'] . $popup));
exit();
}
$templatename = 'editbookmark.tpl';
// If the bookmark exists already, edit the original
if ($bookmarkservice->bookmarkExists(stripslashes(GET_ADDRESS), $currentUserID)) {
$bookmark =& $bookmarkservice->getBookmarks(0, null, $currentUserID, null, null, null, null, null, null, $bookmarkservice->getHash(stripslashes(GET_ADDRESS)));
$popup = (GET_POPUP!='') ? '?popup=1' : '';
header('Location: '. createURL('edit', $bookmark['bookmarks'][0]['bId'] . $popup));
exit();
}
$templatename = 'editbookmark.tpl';
}
if ($templatename == 'editbookmark.tpl') {
if ($userservice->isLoggedOn()) {
$tplVars['formaction'] = createURL('bookmarks', $currentUsername);
if (POST_SUBMITTED != '') {
$tplVars['row'] = array(
if ($userservice->isLoggedOn()) {
$tplVars['formaction'] = createURL('bookmarks', $currentUsername);
if (POST_SUBMITTED != '') {
$tplVars['row'] = array(
'bTitle' => stripslashes(POST_TITLE),
'bAddress' => stripslashes(POST_ADDRESS),
'bDescription' => stripslashes(POST_DESCRIPTION),
'bPrivateNote' => stripslashes(POST_PRIVATENOTE),
'bPrivateNote' => stripslashes(POST_PRIVATENOTE),
'tags' => (POST_TAGS ? explode(',', stripslashes(POST_TAGS)) : array()),
'bStatus' => 0,
);
$tplVars['tags'] = POST_TAGS;
} else {
if(GET_COPYOF != '') { //copy from bookmarks page
$tplVars['row'] = $bookmarkservice->getBookmark(intval(GET_COPYOF), true);
if(!$currentUser->isAdmin()) {
$tplVars['row']['bPrivateNote'] = ''; //only admin can copy private note
}
}else { //copy from pop-up bookmarklet
$tplVars['row'] = array(
'bTitle' => stripslashes(GET_TITLE),
'bAddress' => stripslashes(GET_ADDRESS),
'bDescription' => stripslashes(GET_DESCRIPTION),
'bPrivateNote' => stripslashes(GET_PRIVATENOTE),
'tags' => (GET_TAGS ? explode(',', stripslashes(GET_TAGS)) : array()),
'bStatus' => 0
);
}
}
$title = T_('Add a Bookmark');
$tplVars['referrer'] = '';;
if (isset($_SERVER['HTTP_REFERER'])) {
$tplVars['referrer'] = $_SERVER['HTTP_REFERER'];
}
$tplVars['pagetitle'] = $title;
$tplVars['subtitle'] = $title;
$tplVars['btnsubmit'] = T_('Add Bookmark');
$tplVars['popup'] = (GET_POPUP!='') ? GET_POPUP : null;
} else {
$tplVars['error'] = T_('You must be logged in before you can add bookmarks.');
}
} else if ($user && GET_POPUP == '') {
'bStatus' => 0,
);
$tplVars['tags'] = POST_TAGS;
} else {
if (GET_COPYOF != '') { //copy from bookmarks page
$tplVars['row'] = $bookmarkservice->getBookmark(intval(GET_COPYOF), true);
if (!$currentUser->isAdmin()) {
$tplVars['row']['bPrivateNote'] = ''; //only admin can copy private note
}
} else { //copy from pop-up bookmarklet
$tplVars['row'] = array(
'bTitle' => stripslashes(GET_TITLE),
'bAddress' => stripslashes(GET_ADDRESS),
'bDescription' => stripslashes(GET_DESCRIPTION),
'bPrivateNote' => stripslashes(GET_PRIVATENOTE),
'tags' => (GET_TAGS ? explode(',', stripslashes(GET_TAGS)) : array()),
'bStatus' => 0
);
}
}
$title = T_('Add a Bookmark');
$tplVars['referrer'] = '';;
if (isset($_SERVER['HTTP_REFERER'])) {
$tplVars['referrer'] = $_SERVER['HTTP_REFERER'];
}
$tplVars['pagetitle'] = $title;
$tplVars['subtitle'] = $title;
$tplVars['btnsubmit'] = T_('Add Bookmark');
$tplVars['popup'] = (GET_POPUP!='') ? GET_POPUP : null;
} else {
$tplVars['error'] = T_('You must be logged in before you can add bookmarks.');
}
} elseif ($user && GET_POPUP == '') {
$tplVars['sidebar_blocks'] = array('watchstatus');
$tplVars['sidebar_blocks'] = array('watchstatus');
if (!$cat) { //user page without tags
$cat = NULL;
$tplVars['currenttag'] = NULL;
//$tplVars['sidebar_blocks'][] = 'menu2';
$tplVars['sidebar_blocks'][] = 'linked';
$tplVars['sidebar_blocks'][] = 'popular';
} else { //pages with tags
$rssCat = '/'. filter($cat, 'url');
$tplVars['currenttag'] = $cat;
$tplVars['sidebar_blocks'][] = 'tagactions';
//$tplVars['sidebar_blocks'][] = 'menu2';
$tplVars['sidebar_blocks'][] = 'linked';
$tplVars['sidebar_blocks'][] = 'related';
/*$tplVars['sidebar_blocks'][] = 'menu';*/
}
$tplVars['sidebar_blocks'][] = 'menu2';
$tplVars['popCount'] = 30;
//$tplVars['sidebar_blocks'][] = 'popular';
if (!$cat) { //user page without tags
$cat = null;
$tplVars['currenttag'] = null;
//$tplVars['sidebar_blocks'][] = 'menu2';
$tplVars['sidebar_blocks'][] = 'linked';
$tplVars['sidebar_blocks'][] = 'popular';
} else { //pages with tags
$rssCat = '/'. filter($cat, 'url');
$tplVars['currenttag'] = $cat;
$tplVars['sidebar_blocks'][] = 'tagactions';
//$tplVars['sidebar_blocks'][] = 'menu2';
$tplVars['sidebar_blocks'][] = 'linked';
$tplVars['sidebar_blocks'][] = 'related';
/*$tplVars['sidebar_blocks'][] = 'menu';*/
}
$tplVars['sidebar_blocks'][] = 'menu2';
$tplVars['popCount'] = 30;
//$tplVars['sidebar_blocks'][] = 'popular';
$tplVars['userid'] = $userid;
$tplVars['userinfo'] =& $userinfo;
$tplVars['user'] = $user;
$tplVars['range'] = 'user';
$tplVars['userid'] = $userid;
$tplVars['userinfo'] =& $userinfo;
$tplVars['user'] = $user;
$tplVars['range'] = 'user';
// Pagination
$perpage = getPerPageCount($currentUser);
if (intval(GET_PAGE) > 1) {
$page = intval(GET_PAGE);
$start = ($page - 1) * $perpage;
} else {
$page = 0;
$start = 0;
}
// Pagination
$perpage = getPerPageCount($currentUser);
if (intval(GET_PAGE) > 1) {
$page = intval(GET_PAGE);
$start = ($page - 1) * $perpage;
} else {
$page = 0;
$start = 0;
}
// Set template vars
$tplVars['rsschannels'] = array(
array(filter($sitename .': '. $pagetitle), createURL('rss', filter($user, 'url') . $rssCat.'?sort='.getSortOrder()))
);
// Set template vars
$tplVars['rsschannels'] = array(
array(
filter($sitename .': '. $pagetitle),
createURL('rss', filter($user, 'url') . $rssCat.'?sort='.getSortOrder())
)
);
$tplVars['page'] = $page;
$tplVars['start'] = $start;
$tplVars['bookmarkCount'] = $start + 1;
$tplVars['page'] = $page;
$tplVars['start'] = $start;
$tplVars['bookmarkCount'] = $start + 1;
$bookmarks =& $bookmarkservice->getBookmarks($start, $perpage, $userid, $cat, null, getSortOrder());
$tplVars['total'] = $bookmarks['total'];
$tplVars['bookmarks'] =& $bookmarks['bookmarks'];
$tplVars['cat_url'] = createURL('bookmarks', '%s/%s');
$tplVars['nav_url'] = createURL('bookmarks', '%s/%s%s');
if ($userservice->isLoggedOn() && $user == $currentUsername) {
$tplVars['pagetitle'] = T_('My Bookmarks') . $catTitle;
$tplVars['subtitle'] = T_('My Bookmarks') . $catTitleWithUrls;
} else {
$tplVars['pagetitle'] = $user.': '.$cat;
$tplVars['subtitle'] = $pagetitle;
}
$bookmarks =& $bookmarkservice->getBookmarks($start, $perpage, $userid, $cat, null, getSortOrder());
$tplVars['total'] = $bookmarks['total'];
$tplVars['bookmarks'] =& $bookmarks['bookmarks'];
$tplVars['cat_url'] = createURL('bookmarks', '%s/%s');
$tplVars['nav_url'] = createURL('bookmarks', '%s/%s%s');
if ($userservice->isLoggedOn() && $user == $currentUsername) {
$tplVars['pagetitle'] = T_('My Bookmarks') . $catTitle;
$tplVars['subtitle'] = T_('My Bookmarks') . $catTitleWithUrls;
} else {
$tplVars['pagetitle'] = $user.': '.$cat;
$tplVars['subtitle'] = $pagetitle;
}
}
$tplVars['summarizeLinkedTags'] = true;
$tplVars['pageName'] = PAGE_BOOKMARKS;
$templateservice->loadTemplate($templatename, $tplVars);
if ($usecache && $endcache) {
// Cache output if existing copy has expired
$cacheservice->End($hash);
// Cache output if existing copy has expired
$cacheservice->End($hash);
}
?>

View File

@ -45,22 +45,19 @@ $tplVars['pagetitle'] = T_('Edit Bookmark');
$tplVars['subtitle'] = T_('Edit Bookmark');
$tplVars['loadjs'] = true;
list ($url, $bookmark) = explode('/', $_SERVER['PATH_INFO']);
list ($url, $bookmark) = explode('/', $_SERVER['PATH_INFO']);
if (!($row = $bookmarkservice->getBookmark(intval($bookmark), true))) {
$tplVars['error'] = sprintf(T_('Bookmark with id %s not was not found'), $bookmark);
$templateservice->loadTemplate('error.404.tpl', $tplVars);
exit();
} else {
if (!$bookmarkservice->editAllowed($row)) {
$tplVars['error'] = T_('You are not allowed to edit this bookmark');
$templateservice->loadTemplate('error.500.tpl', $tplVars);
exit();
} else if (POST_SUBMITTED != '') {
if (!POST_TITLE || !POST_ADDRESS) {
$tplVars['error'] = T_('Your bookmark must have a title and an address');
} else {
@ -80,10 +77,10 @@ if (!($row = $bookmarkservice->getBookmark(intval($bookmark), true))) {
//$tplVars['msg'] = (POST_POPUP != '') ? '<script type="text/javascript">window.close();</script>' : T_('Bookmark saved');
$tplVars['msg'] = '<script type="text/javascript">window.close();</script>';
} elseif (POST_REFERRER != '') {
$tplVars['msg'] = T_('Bookmark saved');
$tplVars['msg'] = T_('Bookmark saved');
header('Location: '. POST_REFERRER);
} else {
$tplVars['msg'] = T_('Bookmark saved');
$tplVars['msg'] = T_('Bookmark saved');
header('Location: '. createURL('bookmarks', $currentUser->getUsername()));
}
}
@ -92,9 +89,9 @@ if (!($row = $bookmarkservice->getBookmark(intval($bookmark), true))) {
if (POST_DELETE != '') {
// Delete bookmark
if ($bookmarkservice->deleteBookmark($bookmark)) {
if (POST_POPUP != '') {
$tplVars['msg'] = '<script type="text/javascript">window.close();</script>';
} elseif (POST_REFERRER != '') {
if (POST_POPUP != '') {
$tplVars['msg'] = '<script type="text/javascript">window.close();</script>';
} elseif (POST_REFERRER != '') {
header('Location: '. POST_REFERRER);
} else {
header('Location: '. createURL('bookmarks', $currentUser->getUsername()));

View File

@ -1,7 +1,21 @@
<?php
/**
* Google custom search
*
* 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
*/
require_once '../www-header.php';
if($GLOBALS['enableGoogleCustomSearch'] == false) {
if ($GLOBALS['enableGoogleCustomSearch'] == false) {
echo "Google Custom Search disabled. You can enable it into the config.php file.";
die;
}

View File

@ -1,6 +1,21 @@
<?php require_once '../www-header.php';
<?php
/**
* Google custom search
*
* 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
*/
if($GLOBALS['enableGoogleCustomSearch']==false) {
require_once '../www-header.php';
if ($GLOBALS['enableGoogleCustomSearch']==false) {
echo "Google Custom Search disabled. You can enable it into the config.php file.";
die;
}
@ -20,26 +35,24 @@ if($GLOBALS['enableGoogleCustomSearch']==false) {
<input type="submit" name="sa" value="Search" />
</form>
<script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cref"></script>
<!-- Google CSE Search Box Ends -->
<small>Based on <a href="http://www.google.com/coop/cse/">Google Custom Search</a> over this <a href="<?php echo ROOT ?>api/export_gcs.php">list of websites</a> from <?php echo $GLOBALS['sitename'] ?>.</small>
<br />
<br />
<small><a href="<?php echo ROOT?>"><?php echo T_('Come back to ').$GLOBALS['sitename'] ?>...</a></small>
<?php if($userservice->isLoggedOn() && $currentUser->isAdmin()){
echo '<p><small>';
echo T_('Admin tips: ');
echo T_('To refresh manually Google Custom Search Engine, goes to: ');
echo '<a href="http://www.google.com/coop/cse/cref?cref='.ROOT.'search/context.php">http://www.google.com/coop/cse/cref</a><br/>';
echo T_('If no result appears, check that all the urls are valid in the admin section.');
echo '</small></p>';
}
<?php
if ($userservice->isLoggedOn() && $currentUser->isAdmin()) {
echo '<p><small>';
echo T_('Admin tips: ');
echo T_('To refresh manually Google Custom Search Engine, goes to: ');
echo '<a href="http://www.google.com/coop/cse/cref?cref='.ROOT.'search/context.php">http://www.google.com/coop/cse/cref</a><br/>';
echo T_('If no result appears, check that all the urls are valid in the admin section.');
echo '</small></p>';
}
?>
</center>
</body>
</html>

View File

@ -29,9 +29,7 @@ $cacheservice =SemanticScuttle_Service_Factory::get('Cache');
isset($_GET['page']) ? define('GET_PAGE', $_GET['page']): define('GET_PAGE', 0);
isset($_GET['sort']) ? define('GET_SORT', $_GET['sort']): define('GET_SORT', '');
@list($url, $hash) = isset($_SERVER['PATH_INFO']) ? explode('/', $_SERVER['PATH_INFO']) : NULL;
@list($url, $hash) = isset($_SERVER['PATH_INFO']) ? explode('/', $_SERVER['PATH_INFO']) : null;
if ($usecache) {
// Generate hash for caching on
@ -57,7 +55,7 @@ if (intval(GET_PAGE) > 1) {
if ($bookmark =& $bookmarkservice->getBookmarkByHash($hash)) {
// Template variables
$bookmarks =& $bookmarkservice->getBookmarks($start, $perpage, NULL, NULL, NULL, getSortOrder(), NULL, NULL, NULL, $hash);
$bookmarks =& $bookmarkservice->getBookmarks($start, $perpage, null, null, null, getSortOrder(), null, null, null, $hash);
$tplVars['pagetitle'] = T_('History') .': '. $bookmark['bAddress'];
$tplVars['subtitle'] = sprintf(T_('History for %s'), $bookmark['bAddress']);
$tplVars['loadjs'] = true;
@ -73,10 +71,10 @@ if ($bookmark =& $bookmarkservice->getBookmarkByHash($hash)) {
$tplVars['cat_url'] = createURL('bookmarks', '%1$s/%2$s');
$tplVars['nav_url'] = createURL('history', $hash .'/%3$s');
$tplVars['rsschannels'] = array();
if($userservice->isLoggedOn()) {
$tplVars['user'] = $currentUser->getUsername();
if ($userservice->isLoggedOn()) {
$tplVars['user'] = $currentUser->getUsername();
} else {
$tplVars['user'] = '';
$tplVars['user'] = '';
}
$templateservice->loadTemplate('bookmarks.tpl', $tplVars);
} else {

View File

@ -31,86 +31,90 @@ isset($_POST['status']) ? define('POST_STATUS', $_POST['status']): define('POST_
if ($userservice->isLoggedOn() && sizeof($_FILES) > 0 && $_FILES['userfile']['size'] > 0) {
$userinfo = $userservice->getCurrentObjectUser();
$userinfo = $userservice->getCurrentObjectUser();
if (is_numeric(POST_STATUS)) {
$status = intval(POST_STATUS);
} else {
$status = 2;
}
if (is_numeric(POST_STATUS)) {
$status = intval(POST_STATUS);
} else {
$status = 2;
}
$depth = array();
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
$depth = array();
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
if (!($fp = fopen($_FILES['userfile']['tmp_name'], "r")))
die(T_("Could not open XML input"));
if (!($fp = fopen($_FILES['userfile']['tmp_name'], "r"))) {
die(T_("Could not open XML input"));
}
while ($data = fread($fp, 4096)) {
if (!xml_parse($xml_parser, $data, feof($fp))) {
die(sprintf(T_("XML error: %s at line %d"),
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
}
}
xml_parser_free($xml_parser);
header('Location: '. createURL('bookmarks', $userinfo->getUsername()));
while ($data = fread($fp, 4096)) {
if (!xml_parse($xml_parser, $data, feof($fp))) {
die(sprintf(
T_("XML error: %s at line %d"),
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)
));
}
}
xml_parser_free($xml_parser);
header('Location: '. createURL('bookmarks', $userinfo->getUsername()));
} else {
$templatename = 'importDelicious.tpl';
$tplVars['subtitle'] = T_('Import Bookmarks from del.icio.us');
$tplVars['formaction'] = createURL('import');
$templateservice->loadTemplate($templatename, $tplVars);
$templatename = 'importDelicious.tpl';
$tplVars['subtitle'] = T_('Import Bookmarks from del.icio.us');
$tplVars['formaction'] = createURL('import');
$templateservice->loadTemplate($templatename, $tplVars);
}
function startElement($parser, $name, $attrs)
{
global $depth, $status, $tplVars, $userservice;
$bookmarkservice = SemanticScuttle_Service_Factory::get('Bookmark');
function startElement($parser, $name, $attrs) {
global $depth, $status, $tplVars, $userservice;
if ($name == 'POST') {
while (list($attrTitle, $attrVal) = each($attrs)) {
switch ($attrTitle) {
case 'HREF':
$bAddress = $attrVal;
break;
case 'DESCRIPTION':
$bTitle = $attrVal;
break;
case 'EXTENDED':
$bDescription = $attrVal;
break;
case 'TIME':
$bDatetime = $attrVal;
break;
case 'TAG':
$tags = strtolower($attrVal);
break;
}
}
if ($bookmarkservice->bookmarkExists($bAddress, $userservice->getCurrentUserId())) {
$tplVars['error'] = T_('You have already submitted this bookmark.');
} else {
// Strangely, PHP can't work out full ISO 8601 dates, so we have to chop off the Z.
$bDatetime = substr($bDatetime, 0, -1);
$bookmarkservice =SemanticScuttle_Service_Factory::get('Bookmark');
// If bookmark claims to be from the future, set it to be now instead
if (strtotime($bDatetime) > time()) {
$bDatetime = gmdate('Y-m-d H:i:s');
}
if ($name == 'POST') {
while(list($attrTitle, $attrVal) = each($attrs)) {
switch ($attrTitle) {
case 'HREF':
$bAddress = $attrVal;
break;
case 'DESCRIPTION':
$bTitle = $attrVal;
break;
case 'EXTENDED':
$bDescription = $attrVal;
break;
case 'TIME':
$bDatetime = $attrVal;
break;
case 'TAG':
$tags = strtolower($attrVal);
break;
}
}
if ($bookmarkservice->bookmarkExists($bAddress, $userservice->getCurrentUserId())) {
$tplVars['error'] = T_('You have already submitted this bookmark.');
} else {
// Strangely, PHP can't work out full ISO 8601 dates, so we have to chop off the Z.
$bDatetime = substr($bDatetime, 0, -1);
// If bookmark claims to be from the future, set it to be now instead
if (strtotime($bDatetime) > time()) {
$bDatetime = gmdate('Y-m-d H:i:s');
}
if ($bookmarkservice->addBookmark($bAddress, $bTitle, $bDescription, '', $status, $tags, null, $bDatetime, true, true))
$tplVars['msg'] = T_('Bookmark imported.');
else
$tplVars['error'] = T_('There was an error saving your bookmark. Please try again or contact the administrator.');
}
}
$depth[$parser]++;
if ($bookmarkservice->addBookmark($bAddress, $bTitle, $bDescription, '', $status, $tags, null, $bDatetime, true, true)) {
$tplVars['msg'] = T_('Bookmark imported.');
} else {
$tplVars['error'] = T_('There was an error saving your bookmark. Please try again or contact the administrator.');
}
}
}
$depth[$parser]++;
}
function endElement($parser, $name) {
global $depth;
$depth[$parser]--;
function endElement($parser, $name)
{
global $depth;
$depth[$parser]--;
}
?>

View File

@ -34,93 +34,93 @@ $countImportedBookmarks = 0;
$tplVars['msg'] = '';
if ($userservice->isLoggedOn() && sizeof($_FILES) > 0 && $_FILES['userfile']['size'] > 0) {
$userinfo = $userservice->getCurrentObjectUser();
$userinfo = $userservice->getCurrentObjectUser();
if (is_numeric(POST_STATUS)) {
$status = intval(POST_STATUS);
} else {
$status = 2;
}
if (is_numeric(POST_STATUS)) {
$status = intval(POST_STATUS);
} else {
$status = 2;
}
// File handle
$html = file_get_contents($_FILES['userfile']['tmp_name']);
// File handle
$html = file_get_contents($_FILES['userfile']['tmp_name']);
// Create link array
//preg_match_all('/<a\s+(.*?)\s*\/*>([^<]*)/si', $html, $matches);
preg_match_all('/<a\s+(.*?)>([^<]*?)<\/a>.*?(<dd>([^<]*)|<dt>)/si', $html, $matches);
// Create link array
//preg_match_all('/<a\s+(.*?)\s*\/*>([^<]*)/si', $html, $matches);
preg_match_all('/<a\s+(.*?)>([^<]*?)<\/a>.*?(<dd>([^<]*)|<dt>)/si', $html, $matches);
//var_dump($matches);die();
//var_dump($matches);die();
$links = $matches[1];
$titles = $matches[2];
$descriptions = $matches[4];
$links = $matches[1];
$titles = $matches[2];
$descriptions = $matches[4];
$size = count($links);
for ($i = 0; $i < $size; $i++) {
$size = count($links);
for ($i = 0; $i < $size; $i++) {
// echo "<hr/>";
// echo $links[$i]."<br/>";
preg_match_all('/(\w*\s*=\s*"[^"]*")/', $links[$i], $attributes);
//$attributes = $attributes[0]; // we keep just one row
// echo "<hr/>";
// echo $links[$i]."<br/>";
preg_match_all('/(\w*\s*=\s*"[^"]*")/', $links[$i], $attributes);
//$attributes = $attributes[0]; // we keep just one row
$bDatetime = ""; //bDateTime optional
$bCategories = ""; //bCategories optional
$bDatetime = ""; //bDateTime optional
$bCategories = ""; //bCategories optional
foreach ($attributes[0] as $attribute) {
$att = preg_split('/\s*=\s*/s', $attribute, 2);
$attrTitle = $att[0];
foreach ($attributes[0] as $attribute) {
$att = preg_split('/\s*=\s*/s', $attribute, 2);
$attrTitle = $att[0];
$attrVal = eregi_replace('"', '&quot;', preg_replace('/([\'"]?)(.*)\1/', '$2', $att[1]));
$attrVal = eregi_replace('"', '&quot;', preg_replace('/([\'"]?)(.*)\1/', '$2', $att[1]));
switch ($attrTitle) {
case "HREF":
$bAddress = $attrVal;
break;
case "ADD_DATE":
$bDatetime = gmdate('Y-m-d H:i:s', $attrVal);
break;
case "TAGS":
$bCategories = $attrVal;
break;
case "NOTE":
$bPrivateNote = $attrVal;
}
}
$bTitle = trim($titles[$i]);
$bDescription = trim($descriptions[$i]);
switch ($attrTitle) {
case "HREF":
$bAddress = $attrVal;
break;
case "ADD_DATE":
$bDatetime = gmdate('Y-m-d H:i:s', $attrVal);
break;
case "TAGS":
$bCategories = $attrVal;
break;
case "NOTE":
$bPrivateNote = $attrVal;
}
}
$bTitle = trim($titles[$i]);
$bDescription = trim($descriptions[$i]);
if ($bookmarkservice->bookmarkExists($bAddress, $userservice->getCurrentUserId())) {
$tplVars['error'] = T_('You have already submitted some of these bookmarks.');
} else {
// If bookmark is local (like javascript: or place: in Firefox3), do nothing
if(substr($bAddress, 0, 7) == "http://" || substr($bAddress, 0, 8) == "https://") {
if ($bookmarkservice->bookmarkExists($bAddress, $userservice->getCurrentUserId())) {
$tplVars['error'] = T_('You have already submitted some of these bookmarks.');
} else {
// If bookmark is local (like javascript: or place: in Firefox3), do nothing
if (substr($bAddress, 0, 7) == "http://" || substr($bAddress, 0, 8) == "https://") {
// If bookmark claims to be from the future, set it to be now instead
if (strtotime($bDatetime) > time()) {
$bDatetime = gmdate('Y-m-d H:i:s');
}
// If bookmark claims to be from the future, set it to be now instead
if (strtotime($bDatetime) > time()) {
$bDatetime = gmdate('Y-m-d H:i:s');
}
if ($bookmarkservice->addBookmark($bAddress, $bTitle, $bDescription, $bPrivateNote, $status, $bCategories, null, $bDatetime, false, true)) {
$countImportedBookmarks++;
} else {
$tplVars['error'] = T_('There was an error saving your bookmark. Please try again or contact the administrator.');
}
}
}
}
//header('Location: '. createURL('bookmarks', $userinfo->getUsername()));
$templatename = 'importNetscape.tpl';
$tplVars['msg'].= T_('Bookmarks found: ').$size.' ';
$tplVars['msg'].= T_('Bookmarks imported: ').' '.$countImportedBookmarks;
$tplVars['subtitle'] = T_('Import Bookmarks from Browser File');
$tplVars['formaction'] = createURL('importNetscape');
$templateservice->loadTemplate($templatename, $tplVars);
if ($bookmarkservice->addBookmark($bAddress, $bTitle, $bDescription, $bPrivateNote, $status, $bCategories, null, $bDatetime, false, true)) {
$countImportedBookmarks++;
} else {
$tplVars['error'] = T_('There was an error saving your bookmark. Please try again or contact the administrator.');
}
}
}
}
//header('Location: '. createURL('bookmarks', $userinfo->getUsername()));
$templatename = 'importNetscape.tpl';
$tplVars['msg'].= T_('Bookmarks found: ').$size.' ';
$tplVars['msg'].= T_('Bookmarks imported: ').' '.$countImportedBookmarks;
$tplVars['subtitle'] = T_('Import Bookmarks from Browser File');
$tplVars['formaction'] = createURL('importNetscape');
$templateservice->loadTemplate($templatename, $tplVars);
} else {
$templatename = 'importNetscape.tpl';
$tplVars['subtitle'] = T_('Import Bookmarks from Browser File');
$tplVars['formaction'] = createURL('importNetscape');
$templateservice->loadTemplate($templatename, $tplVars);
$templatename = 'importNetscape.tpl';
$tplVars['subtitle'] = T_('Import Bookmarks from Browser File');
$tplVars['formaction'] = createURL('importNetscape');
$templateservice->loadTemplate($templatename, $tplVars);
}
?>

View File

@ -22,7 +22,7 @@
require_once 'www-header.php';
/* Service creation: only useful services are created */
$tag2tagservice =SemanticScuttle_Service_Factory::get('Tag2Tag');
$tag2tagservice = SemanticScuttle_Service_Factory::get('Tag2Tag');
/* Managing current logged user */
$currentUser = $userservice->getCurrentObjectUser();
@ -34,37 +34,37 @@ $currentUser = $userservice->getCurrentObjectUser();
$tplVars['msg'] = '';
if ($userservice->isLoggedOn() && sizeof($_FILES) > 0 && $_FILES['userfile']['size'] > 0) {
$userinfo = $userservice->getCurrentObjectUser();
$userinfo = $userservice->getCurrentObjectUser();
// File handle
$html = file_get_contents($_FILES['userfile']['tmp_name']);
// File handle
$html = file_get_contents($_FILES['userfile']['tmp_name']);
// Create link array
preg_match_all('/(.*?)\n/', $html, $matches);
// Create link array
preg_match_all('/(.*?)\n/', $html, $matches);
//print_r($matches); die();
//print_r($matches); die();
$fatherTag = '';
$countNewLinks = 0;
foreach($matches[1] as $match) {
if($match == '') {
// do nothing because void line
}elseif(substr($match, 0, 2) == '//') {
// do nothing because commentary
} elseif(substr($match, 0, 2) == ' ') {
// add as child of previous tag
if($fatherTag != '') {
$tag2tagservice->addLinkedTags($fatherTag, $match, '>', $currentUser->getId());
$countNewLinks++;
} else {
$tplVars['error'] = T_('Bad indentation'). ' '.$match;
}
} else{
$fatherTag = $match;
}
}
$tplVars['msg'] = T_('New links between tags: ').$countNewLinks;
$fatherTag = '';
$countNewLinks = 0;
foreach ($matches[1] as $match) {
if ($match == '') {
// do nothing because void line
} elseif (substr($match, 0, 2) == '//') {
// do nothing because commentary
} elseif (substr($match, 0, 2) == ' ') {
// add as child of previous tag
if ($fatherTag != '') {
$tag2tagservice->addLinkedTags($fatherTag, $match, '>', $currentUser->getId());
$countNewLinks++;
} else {
$tplVars['error'] = T_('Bad indentation'). ' '.$match;
}
} else {
$fatherTag = $match;
}
}
$tplVars['msg'] = T_('New links between tags: ').$countNewLinks;
}

View File

@ -22,23 +22,21 @@
require_once 'www-header.php';
/* Service creation: only useful services are created */
$bookmarkservice =SemanticScuttle_Service_Factory::get('Bookmark');
$cacheservice =SemanticScuttle_Service_Factory::get('Cache');
$bookmarkservice = SemanticScuttle_Service_Factory::get('Bookmark');
$cacheservice = SemanticScuttle_Service_Factory::get('Cache');
/* Managing all possible inputs */
isset($_GET['action']) ? define('GET_ACTION', $_GET['action']): define('GET_ACTION', '');
isset($_GET['page']) ? define('GET_PAGE', $_GET['page']): define('GET_PAGE', 0);
isset($_GET['sort']) ? define('GET_SORT', $_GET['sort']): define('GET_SORT', '');
// Logout action
if (GET_ACTION == "logout") {
$userservice->logout();
$tplVars['currentUser'] = null;
$tplvars['msg'] = T_('You have now logged out');
$userservice->logout();
$tplVars['currentUser'] = null;
$tplvars['msg'] = T_('You have now logged out');
}
// Header variables
$tplVars['loadjs'] = true;
$tplVars['rsschannels'] = array(
@ -46,25 +44,25 @@ array(sprintf(T_('%s: Recent bookmarks'), $sitename), createURL('rss').'?sort='.
);
if ($usecache) {
// Generate hash for caching on
$hashtext = $_SERVER['REQUEST_URI'];
if ($userservice->isLoggedOn()) {
$hashtext .= $userservice->getCurrentUserID();
}
$hash = md5($hashtext);
// Generate hash for caching on
$hashtext = $_SERVER['REQUEST_URI'];
if ($userservice->isLoggedOn()) {
$hashtext .= $userservice->getCurrentUserID();
}
$hash = md5($hashtext);
// Cache for 15 minutes
$cacheservice->Start($hash, 900);
// Cache for 15 minutes
$cacheservice->Start($hash, 900);
}
// Pagination
$perpage = getPerPageCount($currentUser);
if (intval(GET_PAGE) > 1) {
$page = intval(GET_PAGE);
$start = ($page - 1) * $perpage;
$page = intval(GET_PAGE);
$start = ($page - 1) * $perpage;
} else {
$page = 0;
$start = 0;
$page = 0;
$start = 0;
}
$tplVars['page'] = $page;
@ -76,7 +74,7 @@ $tplVars['pagetitle'] = T_('Store, share and tag your favourite links');
$tplVars['subtitle'] = T_('All Bookmarks');
$tplVars['bookmarkCount'] = $start + 1;
$bookmarks = $bookmarkservice->getBookmarks($start, $perpage, NULL, NULL, NULL, getSortOrder(), NULL, 0, NULL);
$bookmarks = $bookmarkservice->getBookmarks($start, $perpage, null, null, null, getSortOrder(), null, 0, null);
$tplVars['total'] = $bookmarks['total'];
$tplVars['bookmarks'] =& $bookmarks['bookmarks'];
@ -90,7 +88,7 @@ $tplVars['currenttag'] = '';
$templateservice->loadTemplate('bookmarks.tpl', $tplVars);
if ($usecache) {
// Cache output if existing copy has expired
$cacheservice->End($hash);
// Cache output if existing copy has expired
$cacheservice->End($hash);
}
?>

View File

@ -33,17 +33,18 @@ isset($_POST['username']) ? define('POST_USERNAME', $_POST['username']): define(
isset($_POST['password']) ? define('POST_PASSWORD', $_POST['password']): define('POST_PASSWORD', '');
isset($_POST['query']) ? define('POST_QUERY', $_POST['query']): define('POST_QUERY', '');
$keeppass = (POST_KEEPPASS=='yes')?true:false;
$keeppass = (POST_KEEPPASS=='yes') ? true : false;
$login = false;
if (POST_SUBMITTED!='' && POST_USERNAME!='' && POST_PASSWORD!='') {
$posteduser = trim(utf8_strtolower(POST_USERNAME));
$login = $userservice->login($posteduser, POST_PASSWORD, $keeppass);
if ($login) {
if (POST_QUERY)
if (POST_QUERY) {
header('Location: '. createURL('bookmarks', $posteduser .'?'. POST_QUERY));
else
} else {
header('Location: '. createURL('bookmarks', $posteduser));
}
} else {
$tplVars['error'] = T_('The details you have entered are incorrect. Please try again.');
}

View File

@ -31,44 +31,44 @@ isset($_POST['email']) ? define('POST_EMAIL', $_POST['email']): define('POST_EMA
// IF SUBMITTED
if (POST_SUBMITTED != '') {
// NO USERNAME
if (!POST_USERNAME) {
$tplVars['error'] = T_('You must enter your username.');
// NO USERNAME
if (!POST_USERNAME) {
$tplVars['error'] = T_('You must enter your username.');
// NO E-MAIL
} elseif (!POST_EMAIL) {
$tplVars['error'] = T_('You must enter your <abbr title="electronic mail">e-mail</abbr> address.');
// NO E-MAIL
} elseif (!POST_EMAIL) {
$tplVars['error'] = T_('You must enter your <abbr title="electronic mail">e-mail</abbr> address.');
// USERNAME AND E-MAIL
} else {
// USERNAME AND E-MAIL
} else {
// NO MATCH
$userinfo = $userservice->getObjectUserByUsername(POST_USERNAME);
if ($userinfo == NULL) {
$tplVars['error'] = T_('No matches found for that username.');
// NO MATCH
$userinfo = $userservice->getObjectUserByUsername(POST_USERNAME);
if ($userinfo == null) {
$tplVars['error'] = T_('No matches found for that username.');
} elseif (POST_EMAIL != $userinfo->getEmail()) {
$tplVars['error'] = T_('No matches found for that combination of username and <abbr title="electronic mail">e-mail</abbr> address.');
} elseif (POST_EMAIL != $userinfo->getEmail()) {
$tplVars['error'] = T_('No matches found for that combination of username and <abbr title="electronic mail">e-mail</abbr> address.');
// MATCH
} else {
// MATCH
} else {
// GENERATE AND STORE PASSWORD
$password = $userservice->generatePassword($userinfo->getId());
if (!($password = $userservice->generatePassword($userinfo->getId()))) {
$tplVars['error'] = T_('There was an error while generating your new password. Please try again.');
// GENERATE AND STORE PASSWORD
$password = $userservice->generatePassword($userinfo->getId());
if (!($password = $userservice->generatePassword($userinfo->getId()))) {
$tplVars['error'] = T_('There was an error while generating your new password. Please try again.');
} else {
// SEND E-MAIL
$message = T_('Your new password is:') ."\n". $password ."\n\n". T_('To keep your bookmarks secure, you should change this password in your profile the next time you log in.');
$message = wordwrap($message, 70);
$headers = 'From: '. $adminemail;
$mail = mail(POST_EMAIL, sprintf(T_('%s Account Information'), $sitename), $message);
} else {
// SEND E-MAIL
$message = T_('Your new password is:') ."\n". $password ."\n\n". T_('To keep your bookmarks secure, you should change this password in your profile the next time you log in.');
$message = wordwrap($message, 70);
$headers = 'From: '. $adminemail;
$mail = mail(POST_EMAIL, sprintf(T_('%s Account Information'), $sitename), $message);
$tplVars['msg'] = sprintf(T_('New password generated and sent to %s'), POST_EMAIL);
}
}
}
$tplVars['msg'] = sprintf(T_('New password generated and sent to %s'), POST_EMAIL);
}
}
}
}
$templatename = 'password.tpl';

View File

@ -22,24 +22,24 @@
require_once 'www-header.php';
/* Service creation: only useful services are created */
$b2tservice =SemanticScuttle_Service_Factory::get('Bookmark2Tag');
$cacheservice =SemanticScuttle_Service_Factory::get('Cache');
$b2tservice = SemanticScuttle_Service_Factory::get('Bookmark2Tag');
$cacheservice = SemanticScuttle_Service_Factory::get('Cache');
@list($url, $user) = isset($_SERVER['PATH_INFO']) ? explode('/', $_SERVER['PATH_INFO']) : NULL;
@list($url, $user) = isset($_SERVER['PATH_INFO']) ? explode('/', $_SERVER['PATH_INFO']) : null;
if ($usecache) {
// Generate hash for caching on
$hashtext = $_SERVER['REQUEST_URI'];
if ($userservice->isLoggedOn()) {
$hashtext .= $currentUser->getId();
if ($currentUser->getUsername() == $user) {
$hashtext .= $user;
}
}
$hash = md5($hashtext);
// Generate hash for caching on
$hashtext = $_SERVER['REQUEST_URI'];
if ($userservice->isLoggedOn()) {
$hashtext .= $currentUser->getId();
if ($currentUser->getUsername() == $user) {
$hashtext .= $user;
}
}
$hash = md5($hashtext);
// Cache for an hour
$cacheservice->Start($hash, 3600);
// Cache for an hour
$cacheservice->Start($hash, 3600);
}
// Header variables
@ -47,17 +47,17 @@ $pagetitle = T_('Popular Tags');
if (isset($user) && $user != '') {
$userid = $userservice->getIdFromUser($user);
if($userid == NULL) {
$tplVars['error'] = sprintf(T_('User with username %s was not found'), $user);
$templateservice->loadTemplate('error.404.tpl', $tplVars);
//throw a 404 error
exit();
}
$userid = $userservice->getIdFromUser($user);
if ($userid == null) {
$tplVars['error'] = sprintf(T_('User with username %s was not found'), $user);
$templateservice->loadTemplate('error.404.tpl', $tplVars);
//throw a 404 error
exit();
}
$pagetitle .= ': '. ucfirst($user);
$pagetitle .= ': '. ucfirst($user);
} else {
$userid = NULL;
$userid = null;
}
$tags = $b2tservice->getPopularTags($userid, 150);
@ -65,9 +65,9 @@ $tplVars['tags'] =& $b2tservice->tagCloud($tags, 5, 90, 225, getSortOrder('alpha
$tplVars['user'] = $user;
if (isset($userid)) {
$tplVars['cat_url'] = createURL('bookmarks', '%s/%s');
$tplVars['cat_url'] = createURL('bookmarks', '%s/%s');
} else {
$tplVars['cat_url'] = createURL('tags', '%2$s');
$tplVars['cat_url'] = createURL('tags', '%2$s');
}
$tplVars['sidebar_blocks'] = array('linked');
@ -78,7 +78,7 @@ $tplVars['loadjs'] = true;
$templateservice->loadTemplate('tags.tpl', $tplVars);
if ($usecache) {
// Cache output if existing copy has expired
$cacheservice->End($hash);
// Cache output if existing copy has expired
$cacheservice->End($hash);
}
?>

View File

@ -38,33 +38,32 @@ isset($_SESSION['token']) ? define('SESSION_TOKEN', $_SESSION['token']): define(
isset($_SESSION['token_stamp']) ? define('SESSION_TOKENSTAMP', $_SESSION['token_stamp']): define('SESSION_TOKENSTAMP', '');
@list($url, $user) = isset($_SERVER['PATH_INFO']) ? explode('/', $_SERVER['PATH_INFO']) : NULL;
@list($url, $user) = isset($_SERVER['PATH_INFO']) ? explode('/', $_SERVER['PATH_INFO']) : null;
if ($user) {
if (is_int($user)) {
$userid = intval($user);
} else {
$user = urldecode($user);
$userinfo = $userservice->getObjectUserByUsername($user);
if ($userinfo == NULL) {
$tplVars['error'] = sprintf(T_('User with username %s was not found'), $user);
$templateservice->loadTemplate('error.404.tpl', $tplVars);
exit();
} else {
$userid =& $userinfo->getId();
}
}
if (is_int($user)) {
$userid = intval($user);
} else {
$user = urldecode($user);
$userinfo = $userservice->getObjectUserByUsername($user);
if ($userinfo == null) {
$tplVars['error'] = sprintf(T_('User with username %s was not found'), $user);
$templateservice->loadTemplate('error.404.tpl', $tplVars);
exit();
} else {
$userid =& $userinfo->getId();
}
}
} else {
$tplVars['error'] = T_('Username was not specified');
$templateservice->loadTemplate('error.404.tpl', $tplVars);
exit();
$tplVars['error'] = T_('Username was not specified');
$templateservice->loadTemplate('error.404.tpl', $tplVars);
exit();
}
if ($userservice->isLoggedOn() && $user == $currentUser->getUsername()) {
$title = T_('My Profile');
$title = T_('My Profile');
} else {
$title = T_('Profile') .': '. $user;
$title = T_('Profile') .': '. $user;
}
$tplVars['pagetitle'] = $title;
$tplVars['subtitle'] = $title;
@ -73,55 +72,53 @@ $tplVars['user'] = $user;
$tplVars['userid'] = $userid;
if (POST_SUBMITTED!='' && $currentUser->getId() == $userid) {
$error = false;
$detPass = trim(POST_PASS);
$detPassConf = trim(POST_PASSCONF);
$detName = trim(POST_NAME);
$detMail = trim(POST_MAIL);
$detPage = trim(POST_PAGE);
$detDesc = filter(POST_DESC);
$error = false;
$detPass = trim(POST_PASS);
$detPassConf = trim(POST_PASSCONF);
$detName = trim(POST_NAME);
$detMail = trim(POST_MAIL);
$detPage = trim(POST_PAGE);
$detDesc = filter(POST_DESC);
// manage token preventing from CSRF vulnaribilities
if ( SESSION_TOKEN == ''
|| time() - SESSION_TOKENSTAMP > 600 //limit token lifetime, optionnal
|| SESSION_TOKEN != POST_TOKEN) {
$error = true;
$tplVars['error'] = T_('Invalid Token');
}
// manage token preventing from CSRF vulnaribilities
//limit token lifetime, optionnal
if ( SESSION_TOKEN == '' || time() - SESSION_TOKENSTAMP > 600 || SESSION_TOKEN != POST_TOKEN) {
$error = true;
$tplVars['error'] = T_('Invalid Token');
}
if ($detPass != $detPassConf) {
$error = true;
$tplVars['error'] = T_('Password and confirmation do not match.');
}
if ($detPass != "" && strlen($detPass) < 6) {
$error = true;
$tplVars['error'] = T_('Password must be at least 6 characters long.');
}
if (!$userservice->isValidEmail($detMail)) {
$error = true;
$tplVars['error'] = T_('E-mail address is not valid.');
}
if (!$error) {
if (!$userservice->updateUser($userid, $detPass, $detName, $detMail, $detPage, $detDesc)) {
$tplvars['error'] = T_('An error occurred while saving your changes.');
} else {
$tplVars['msg'] = T_('Changes saved.');
}
}
$userinfo = $userservice->getObjectUserByUsername($user);
if ($detPass != $detPassConf) {
$error = true;
$tplVars['error'] = T_('Password and confirmation do not match.');
}
if ($detPass != "" && strlen($detPass) < 6) {
$error = true;
$tplVars['error'] = T_('Password must be at least 6 characters long.');
}
if (!$userservice->isValidEmail($detMail)) {
$error = true;
$tplVars['error'] = T_('E-mail address is not valid.');
}
if (!$error) {
if (!$userservice->updateUser($userid, $detPass, $detName, $detMail, $detPage, $detDesc)) {
$tplvars['error'] = T_('An error occurred while saving your changes.');
} else {
$tplVars['msg'] = T_('Changes saved.');
}
}
$userinfo = $userservice->getObjectUserByUsername($user);
}
if (!$userservice->isLoggedOn() || $currentUser->getId() != $userid) {
$templatename = 'profile.tpl.php';
$templatename = 'profile.tpl.php';
} else {
//Token Init
$_SESSION['token'] = md5(uniqid(rand(), true));
$_SESSION['token_stamp'] = time();
$templatename = 'editprofile.tpl.php';
$tplVars['formaction'] = createURL('profile', $user);
$tplVars['token'] = $_SESSION['token'];
//Token Init
$_SESSION['token'] = md5(uniqid(rand(), true));
$_SESSION['token_stamp'] = time();
$templatename = 'editprofile.tpl.php';
$tplVars['formaction'] = createURL('profile', $user);
$tplVars['token'] = $_SESSION['token'];
}
$tplVars['objectUser'] = $userinfo;

View File

@ -42,7 +42,7 @@ if (POST_SUBMITTED != '') {
$posteduser = trim(utf8_strtolower(POST_USERNAME));
// Check if form is incomplete
if (!($posteduser) || POST_PASS == '' || POST_MAIL == '') {
if (!($posteduser) || POST_PASS == '' || POST_MAIL == '') {
$tplVars['error'] = T_('You <em>must</em> enter a username, password and e-mail address.');
// Check if username is reserved

View File

@ -30,8 +30,8 @@ isset($_GET['sort']) ? define('GET_SORT', $_GET['sort']): define('GET_SORT', '')
// POST
if (POST_TERMS != '') {
// Redirect to GET
header(
// Redirect to GET
header(
'Location: '
. createURL('search', POST_RANGE .'/'. filter(POST_TERMS, 'url'))
);
@ -40,23 +40,21 @@ if (POST_TERMS != '') {
}
/* Service creation: only useful services are created */
$bookmarkservice =SemanticScuttle_Service_Factory::get('Bookmark');
$searchhistoryservice =SemanticScuttle_Service_Factory::get('SearchHistory');
$bookmarkservice = SemanticScuttle_Service_Factory::get('Bookmark');
$searchhistoryservice = SemanticScuttle_Service_Factory::get('SearchHistory');
/* Managing current logged user */
$currentUserId = $userservice->getCurrentUserId();
$exploded = isset($_SERVER['PATH_INFO'])
? explode('/', $_SERVER['PATH_INFO']) : null;
if(count($exploded) == 4) {
$exploded = isset($_SERVER['PATH_INFO']) ? explode('/', $_SERVER['PATH_INFO']) : null;
if (count($exploded) == 4) {
list($url, $range, $terms, $page) = $exploded;
} else if (count($exploded) == 2) {
} elseif (count($exploded) == 2) {
list($url, $range) = $exploded;
$terms = $page= NULL;
$terms = $page= null;
} else {
list($url, $range, $terms) = $exploded;
$page= NULL;
$page= null;
}
$tplVars['loadjs'] = true;
@ -71,10 +69,10 @@ if (intval(GET_PAGE) > 1) {
$start = 0;
}
$s_user = NULL;
$s_start = NULL;
$s_end = NULL;
$s_watchlist = NULL;
$s_user = null;
$s_start = null;
$s_end = null;
$s_watchlist = null;
// No search terms
if (is_null($terms)) {
@ -90,7 +88,7 @@ if (is_null($terms)) {
switch ($range) {
case 'all':
$tplVars['select_all'] = $selected;
$s_user = NULL;
$s_user = null;
break;
case 'watchlist':
$tplVars['select_watchlist'] = $selected;
@ -105,7 +103,7 @@ if (is_null($terms)) {
if (isset($s_user)) {
$tplVars['user'] = $range;
$s_user = $userservice->getIdFromUser($s_user);
if($s_user == NULL) {
if ($s_user == null) {
$tplVars['error'] = sprintf(T_('User with username %s was not found'), $s_user);
$templateservice->loadTemplate('error.404.tpl', $tplVars);
exit();
@ -114,7 +112,7 @@ if (is_null($terms)) {
}
}
$bookmarks =& $bookmarkservice->getBookmarks(
$start, $perpage, $s_user, NULL, $terms, getSortOrder(),
$start, $perpage, $s_user, null, $terms, getSortOrder(),
$s_watchlist, $s_start, $s_end
);
@ -123,9 +121,7 @@ $searchhistoryservice->addSearch(
$terms, $range, $bookmarks['total'], $currentUserId
);
if (isset($_GET['lucky']) && $_GET['lucky']
&& isset($bookmarks['bookmarks'][0])
) {
if (isset($_GET['lucky']) && $_GET['lucky'] && isset($bookmarks['bookmarks'][0])) {
$url = $bookmarks['bookmarks'][0]['bAddress'];
header('Location: ' . $url);
exit();

View File

@ -33,7 +33,7 @@ isset($_POST['tag2']) ? define('POST_TAG2', $_POST['tag2']): define('POST_TAG2',
//permissions
if(!$userservice->isLoggedOn()) {
if (!$userservice->isLoggedOn()) {
$tplVars['error'] = T_('Permission denied.');
$templateservice->loadTemplate('error.500.tpl', $tplVars);
exit();
@ -58,10 +58,9 @@ if (POST_CONFIRM != '') {
header('Location: '. createURL('bookmarks', $currentUser->getUsername() .'/'. $tags));
}
$tplVars['links'] = $tag2tagservice->getLinks($currentUser->getId());
$tplVars['tag1'] = $tag1;
$tplVars['tag2'] = '';
$tplVars['links'] = $tag2tagservice->getLinks($currentUser->getId());
$tplVars['tag1'] = $tag1;
$tplVars['tag2'] = '';
$tplVars['subtitle'] = T_('Add Tag Link') .': '. $tag1;
$tplVars['formaction'] = $_SERVER['SCRIPT_NAME'] .'/'. $tag1;
$tplVars['referrer'] = $_SERVER['HTTP_REFERER'];

View File

@ -37,47 +37,44 @@ isset($_SERVER['HTTP_REFERER']) ? define('HTTP_REFERER', $_SERVER['HTTP_REFERER'
$currentUser = $userservice->getCurrentObjectUser();
//permissions
if(!$userservice->isloggedOn()) {
$tplVars['error'] = T_('Permission denied.');
$templateservice->loadTemplate('error.500.tpl', $tplVars);
exit();
if (!$userservice->isloggedOn()) {
$tplVars['error'] = T_('Permission denied.');
$templateservice->loadTemplate('error.500.tpl', $tplVars);
exit();
}
/* Managing path info */
if(isset($_SERVER['PATH_INFO'])) {
$exploded = explode('/', $_SERVER['PATH_INFO']);
if(count($exploded) == 3) {
list ($url, $tag1, $tag2) = explode('/', $_SERVER['PATH_INFO']);
} else {
list ($url, $tag1) = explode('/', $_SERVER['PATH_INFO']);
$tag2 = '';
}
if (isset($_SERVER['PATH_INFO'])) {
$exploded = explode('/', $_SERVER['PATH_INFO']);
if (count($exploded) == 3) {
list ($url, $tag1, $tag2) = explode('/', $_SERVER['PATH_INFO']);
} else {
list ($url, $tag1) = explode('/', $_SERVER['PATH_INFO']);
$tag2 = '';
}
} else {
$url = $tag1 = $tag2 = '';
$url = $tag1 = $tag2 = '';
}
if (POST_CONFIRM) {
$tag = POST_TAG1;
$linkType = POST_LINKTYPE;
$newTag = POST_TAG2;
if ($tag2tagservice->removeLinkedTags(POST_TAG1, POST_TAG2, POST_LINKTYPE, $currentUser->getId())) {
$tplVars['msg'] = T_('Tag link deleted');
header('Location: '. createURL('bookmarks', $currentUser->getUsername().'/'.$tag));
} else {
$tplVars['error'] = T_('Failed to delete the link');
$templateservice->loadTemplate('error.500.tpl', $tplVars);
exit();
}
$tag = POST_TAG1;
$linkType = POST_LINKTYPE;
$newTag = POST_TAG2;
if ($tag2tagservice->removeLinkedTags(POST_TAG1, POST_TAG2, POST_LINKTYPE, $currentUser->getId())) {
$tplVars['msg'] = T_('Tag link deleted');
header('Location: '. createURL('bookmarks', $currentUser->getUsername().'/'.$tag));
} else {
$tplVars['error'] = T_('Failed to delete the link');
$templateservice->loadTemplate('error.500.tpl', $tplVars);
exit();
}
} elseif (POST_CANCEL) {
header('Location: '. createURL('bookmarks', $currentUser->getUsername() .'/'. $tags));
header('Location: '. createURL('bookmarks', $currentUser->getUsername() .'/'. $tags));
}
$tplVars['links'] = $tag2tagservice->getLinks($currentUser->getId());
$tplVars['tag1'] = $tag1;
$tplVars['tag2'] = $tag2;
$tplVars['links'] = $tag2tagservice->getLinks($currentUser->getId());
$tplVars['tag1'] = $tag1;
$tplVars['tag2'] = $tag2;
$tplVars['subtitle'] = T_('Delete Link Between Tags') .': '. $tag1.' > '.$tag2;
$tplVars['formaction'] = $_SERVER['SCRIPT_NAME'];
$tplVars['referrer'] = HTTP_REFERER;

View File

@ -29,32 +29,31 @@ $tag2tagservice = SemanticScuttle_Service_Factory :: get('Tag2Tag');
isset($_SERVER['HTTP_REFERER']) ? define('HTTP_REFERER', $_SERVER['HTTP_REFERER']): define('HTTP_REFERER', '');
//permissions
if(!$userservice->loggedOn()) {
if (!$userservice->loggedOn()) {
$tplVars['error'] = T_('Permission denied.');
$templateservice->loadTemplate('error.500.tpl', $tplVars);
exit();
}
/* Managing path info */
if(isset($_SERVER['PATH_INFO'])) {
$exploded = explode('/', $_SERVER['PATH_INFO']);
if(count($exploded) == 3) {
list ($url, $tag1, $tag2) = explode('/', $_SERVER['PATH_INFO']);
} else {
list ($url, $tag1) = explode('/', $_SERVER['PATH_INFO']);
$tag2 = '';
}
if (isset($_SERVER['PATH_INFO'])) {
$exploded = explode('/', $_SERVER['PATH_INFO']);
if (count($exploded) == 3) {
list ($url, $tag1, $tag2) = explode('/', $_SERVER['PATH_INFO']);
} else {
list ($url, $tag1) = explode('/', $_SERVER['PATH_INFO']);
$tag2 = '';
}
} else {
$url = $tag1 = $tag2 = '';
$url = $tag1 = $tag2 = '';
}
$tplVars['links'] = $tag2tagservice->getLinks($userservice->getCurrentUserId());
$tplVars['tag1'] = $tag1;
$tplVars['tag2'] = $tag2;
$tplVars['subtitle'] = T_('Edit Link Between Tags') .': '. $tag1.' > '.$tag2;
$tplVars['formaddaction'] = createUrl('tag2tagadd');
$tplVars['links'] = $tag2tagservice->getLinks($userservice->getCurrentUserId());
$tplVars['tag1'] = $tag1;
$tplVars['tag2'] = $tag2;
$tplVars['subtitle'] = T_('Edit Link Between Tags') .': '. $tag1.' > '.$tag2;
$tplVars['formaddaction'] = createUrl('tag2tagadd');
$tplVars['formdeleteaction'] = createUrl('tag2tagdelete');
$tplVars['referrer'] = HTTP_REFERER;
$tplVars['referrer'] = HTTP_REFERER;
$templateservice->loadTemplate('tag2tagedit.tpl', $tplVars);
?>

View File

@ -43,11 +43,7 @@ $currentUser = $userservice->getCurrentObjectUser();
list ($url, $tag) = explode('/', $_SERVER['PATH_INFO']);
//permissions
if (!$userservice->isLoggedOn()
|| (!$GLOBALS['enableCommonTagDescriptionEditedByAll']
&& !$currentUser->isAdmin()
)
) {
if (!$userservice->isLoggedOn() || (!$GLOBALS['enableCommonTagDescriptionEditedByAll'] && !$currentUser->isAdmin())) {
$tplVars['error'] = T_('Permission denied.');
$templateservice->loadTemplate('error.500.tpl', $tplVars);
exit();

View File

@ -22,7 +22,7 @@
require_once 'www-header.php';
/* Service creation: only useful services are created */
$tagservice = SemanticScuttle_Service_Factory :: get('Tag');
$tagservice = SemanticScuttle_Service_Factory :: get('Tag');
/* Managing all possible inputs */
isset($_POST['confirm']) ? define('POST_CONFIRM', $_POST['confirm']): define('POST_CONFIRM', '');
@ -36,33 +36,31 @@ $currentUser = $userservice->getCurrentObjectUser();
/* Managing path info */
list ($url, $tag) = explode('/', $_SERVER['PATH_INFO']);
$template = 'tagedit.tpl';
$template = 'tagedit.tpl';
//permissions
if(!$userservice->isLoggedOn()) {
$tplVars['error'] = T_('Permission denied.');
$templateservice->loadTemplate('error.500.tpl', $tplVars);
exit();
if (!$userservice->isLoggedOn()) {
$tplVars['error'] = T_('Permission denied.');
$templateservice->loadTemplate('error.500.tpl', $tplVars);
exit();
}
if (POST_CONFIRM) {
if ( strlen($tag)>0 &&
$tagservice->updateDescription($tag, $currentUser->getId(), stripslashes(POST_DESCRIPTION))
) {
$tplVars['msg'] = T_('Tag description updated');
header('Location: '. POST_REFERRER);
} else {
$tplVars['error'] = T_('Failed to update the tag description');
$template = 'error.500.tpl';
}
if (strlen($tag)>0 && $tagservice->updateDescription($tag, $currentUser->getId(), stripslashes(POST_DESCRIPTION))) {
$tplVars['msg'] = T_('Tag description updated');
header('Location: '. POST_REFERRER);
} else {
$tplVars['error'] = T_('Failed to update the tag description');
$template = 'error.500.tpl';
}
} elseif (POST_CANCEL) {
header('Location: '. POST_REFERRER);
header('Location: '. POST_REFERRER);
} else {
$tplVars['subtitle'] = T_('Edit Tag Description') .': '. $tag;
$tplVars['formaction'] = $_SERVER['SCRIPT_NAME'] .'/'. $tag;
$tplVars['referrer'] = $_SERVER['HTTP_REFERER'];
$tplVars['tag'] = $tag;
$tplVars['description'] = $tagservice->getDescription($tag, $currentUser->getId());
$tplVars['subtitle'] = T_('Edit Tag Description') .': '. $tag;
$tplVars['formaction'] = $_SERVER['SCRIPT_NAME'] .'/'. $tag;
$tplVars['referrer'] = $_SERVER['HTTP_REFERER'];
$tplVars['tag'] = $tag;
$tplVars['description'] = $tagservice->getDescription($tag, $currentUser->getId());
}
$templateservice->loadTemplate($template, $tplVars);
?>

View File

@ -23,7 +23,7 @@ require_once 'www-header.php';
/* Service creation: only useful services are created */
$b2tservice = SemanticScuttle_Service_Factory :: get('Bookmark2Tag');
$tagservice = SemanticScuttle_Service_Factory :: get('Tag');
$tagservice = SemanticScuttle_Service_Factory :: get('Tag');
$tag2tagservice = SemanticScuttle_Service_Factory :: get('Tag2Tag');
/* Managing all possible inputs */
@ -37,42 +37,41 @@ $currentUser = $userservice->getCurrentObjectUser();
/* Managing path info */
list ($url, $tag) = explode('/', $_SERVER['PATH_INFO']);
//$tag = isset($_GET['query']) ? $_GET['query'] : NULL;
$template = 'tagrename.tpl';
//$tag = isset($_GET['query']) ? $_GET['query'] : null;
$template = 'tagrename.tpl';
if (POST_CONFIRM) {
if (trim(POST_OLD) != '') {
$old = trim(POST_OLD);
} else {
$old = NULL;
}
if (trim(POST_OLD) != '') {
$old = trim(POST_OLD);
} else {
$old = null;
}
if (trim(POST_NEW) != '') {
$new = trim(POST_NEW);
} else {
$new = NULL;
}
if (trim(POST_NEW) != '') {
$new = trim(POST_NEW);
} else {
$new = null;
}
if (
!is_null($old) &&
!is_null($new) &&
$tagservice->renameTag($currentUser->getId(), $old, $new) &&
$b2tservice->renameTag($currentUser->getId(), $old, $new) &&
$tag2tagservice->renameTag($currentUser->getId(), $old, $new)
) {
$tplVars['msg'] = T_('Tag renamed');
header('Location: '. createURL('bookmarks', $currentUser->getUsername()));
} else {
$tplVars['error'] = T_('Failed to rename the tag');
$template = 'error.500.tpl';
}
if (!is_null($old)
&& !is_null($new)
&& $tagservice->renameTag($currentUser->getId(), $old, $new)
&& $b2tservice->renameTag($currentUser->getId(), $old, $new)
&& $tag2tagservice->renameTag($currentUser->getId(), $old, $new)
) {
$tplVars['msg'] = T_('Tag renamed');
header('Location: '. createURL('bookmarks', $currentUser->getUsername()));
} else {
$tplVars['error'] = T_('Failed to rename the tag');
$template = 'error.500.tpl';
}
} elseif (POST_CANCEL) {
header('Location: '. createURL('bookmarks', $currentUser->getUsername() .'/'. $tags));
header('Location: '. createURL('bookmarks', $currentUser->getUsername() .'/'. $tags));
} else {
$tplVars['subtitle'] = T_('Rename Tag') .': '. $tag;
$tplVars['formaction'] = $_SERVER['SCRIPT_NAME'] .'/'. $tag;
$tplVars['referrer'] = $_SERVER['HTTP_REFERER'];
$tplVars['old'] = $tag;
$tplVars['subtitle'] = T_('Rename Tag') .': '. $tag;
$tplVars['formaction'] = $_SERVER['SCRIPT_NAME'] .'/'. $tag;
$tplVars['referrer'] = $_SERVER['HTTP_REFERER'];
$tplVars['old'] = $tag;
}
$templateservice->loadTemplate($template, $tplVars);
?>

View File

@ -22,8 +22,8 @@
require_once 'www-header.php';
/* Service creation: only useful services are created */
$bookmarkservice =SemanticScuttle_Service_Factory::get('Bookmark');
$cacheservice =SemanticScuttle_Service_Factory::get('Cache');
$bookmarkservice = SemanticScuttle_Service_Factory::get('Bookmark');
$cacheservice = SemanticScuttle_Service_Factory::get('Cache');
/* Managing all possible inputs */
isset($_GET['page']) ? define('GET_PAGE', $_GET['page']): define('GET_PAGE', 0);
@ -35,49 +35,50 @@ $currentUser = $userservice->getCurrentObjectUser();
/* Managing path info */
list($url, $cat) = explode('/', $_SERVER['PATH_INFO']);
if (!$cat) {
header('Location: '. createURL('populartags'));
exit;
header('Location: '. createURL('populartags'));
exit;
}
$titleTags = explode('+', filter($cat));
$pagetitle = T_('Tags') .': ';
for($i = 0; $i<count($titleTags);$i++) {
$pagetitle.= $titleTags[$i].'<a href="'.createUrl('tags', aggregateTags($titleTags, '+', $titleTags[$i])).'" title="'.T_('Remove the tag from the selection').'">*</a> + ';
for ($i = 0; $i<count($titleTags);$i++) {
$pagetitle.= $titleTags[$i].'<a href="'.createUrl('tags', aggregateTags($titleTags, '+', $titleTags[$i])).'" title="'.T_('Remove the tag from the selection').'">*</a> + ';
}
$pagetitle = substr($pagetitle, 0, strlen($pagetitle) - strlen(' + '));
//$cattitle = str_replace('+', ' + ', $cat);
if ($usecache) {
// Generate hash for caching on
if ($userservice->isLoggedOn()) {
$hash = md5($_SERVER['REQUEST_URI'] . $currentUser->getId());
} else {
$hash = md5($_SERVER['REQUEST_URI']);
}
// Generate hash for caching on
if ($userservice->isLoggedOn()) {
$hash = md5($_SERVER['REQUEST_URI'] . $currentUser->getId());
} else {
$hash = md5($_SERVER['REQUEST_URI']);
}
// Cache for 30 minutes
$cacheservice->Start($hash, 1800);
// Cache for 30 minutes
$cacheservice->Start($hash, 1800);
}
// Header variables
$tplVars['pagetitle'] = T_('Tags') .': '. $cat;
$tplVars['loadjs'] = true;
$tplVars['rsschannels'] = array(
array(filter($sitename .': '. $pagetitle), createURL('rss', 'all/'. filter($cat, 'url')).'?sort='.getSortOrder())
array(
filter($sitename .': '. $pagetitle),
createURL('rss', 'all/'. filter($cat, 'url')).'?sort='.getSortOrder()
)
);
// Pagination
$perpage = getPerPageCount($currentUser);
if (intval(GET_PAGE) > 1) {
$page = intval(GET_PAGE);
$start = ($page - 1) * $perpage;
$page = intval(GET_PAGE);
$start = ($page - 1) * $perpage;
} else {
$page = 0;
$start = 0;
$page = 0;
$start = 0;
}
$tplVars['page'] = $page;
@ -87,7 +88,7 @@ $tplVars['currenttag'] = $cat;
$tplVars['sidebar_blocks'] = array('linked', 'related', 'menu2');//array('linked', 'related', 'popular');
$tplVars['subtitle'] = $pagetitle;
$tplVars['bookmarkCount'] = $start + 1;
$bookmarks =& $bookmarkservice->getBookmarks($start, $perpage, NULL, $cat, NULL, getSortOrder());
$bookmarks =& $bookmarkservice->getBookmarks($start, $perpage, null, $cat, null, getSortOrder());
$tplVars['total'] = $bookmarks['total'];
$tplVars['bookmarks'] =& $bookmarks['bookmarks'];
$tplVars['cat_url'] = createURL('bookmarks', '%1$s/%2$s');
@ -96,8 +97,8 @@ $tplVars['nav_url'] = createURL('tags', '%2$s%3$s');
$templateservice->loadTemplate('bookmarks.tpl', $tplVars);
if ($usecache) {
// Cache output if existing copy has expired
$cacheservice->End($hash);
// Cache output if existing copy has expired
$cacheservice->End($hash);
}
?>

View File

@ -35,7 +35,7 @@ exit();
// This part below will be executed once you comment the two lines above
/////////////////
require_once 'www-header.php';
$tagstatservice = SemanticScuttle_Service_Factory :: get('TagStat');
$tagstatservice = SemanticScuttle_Service_Factory :: get('TagStat');
?>
<h1>Upgrade</h1>
@ -51,11 +51,11 @@ $tagstatservice = SemanticScuttle_Service_Factory :: get('TagStat');
<li>3/ Complete the upgrade by clicking on the following link : <a href="upgrade.php?action=upgrade">upgrade</a></li>
</ul>
<?php
if($_GET['action']=="upgrade") {
// Update the stats
$tagstatservice->updateAllStat();
echo "Upgrade script executed: OK!<br/><br/>";
echo "For security reason, don't forget to uncomment back the first lines into \"upgrade.php\"<br/><br/>";
echo 'In case of problem during upgrade, please use our <a href="http://sourceforge.net/tracker/?group_id=211356&atid=1017431">sourceforge page</a> to inform us. Thank you.';
if ($_GET['action']=="upgrade") {
// Update the stats
$tagstatservice->updateAllStat();
echo "Upgrade script executed: OK!<br/><br/>";
echo "For security reason, don't forget to uncomment back the first lines into \"upgrade.php\"<br/><br/>";
echo 'In case of problem during upgrade, please use our <a href="http://sourceforge.net/tracker/?group_id=211356&atid=1017431">sourceforge page</a> to inform us. Thank you.';
}
?>

View File

@ -22,8 +22,8 @@
require_once 'www-header.php';
/* Service creation: only useful services are created */
$bookmarkservice =SemanticScuttle_Service_Factory::get('Bookmark');
$cacheservice =SemanticScuttle_Service_Factory::get('Cache');
$bookmarkservice = SemanticScuttle_Service_Factory::get('Bookmark');
$cacheservice = SemanticScuttle_Service_Factory::get('Cache');
/* Managing current logged user */
$currentUser = $userservice->getCurrentObjectUser();
@ -31,15 +31,15 @@ $currentUser = $userservice->getCurrentObjectUser();
$pagetitle = T_('Users');
if ($usecache) {
// Generate hash for caching on
if ($userservice->isLoggedOn()) {
$hash = md5($_SERVER['REQUEST_URI'] . $currentUser->getId());
} else {
$hash = md5($_SERVER['REQUEST_URI']);
}
// Generate hash for caching on
if ($userservice->isLoggedOn()) {
$hash = md5($_SERVER['REQUEST_URI'] . $currentUser->getId());
} else {
$hash = md5($_SERVER['REQUEST_URI']);
}
// Cache for 30 minutes
$cacheservice->Start($hash, 1800);
// Cache for 30 minutes
$cacheservice->Start($hash, 1800);
}
// Header variables
@ -56,7 +56,7 @@ $tplVars['users'] =& $userservice->getUsers();
$templateservice->loadTemplate('users.tpl', $tplVars);
if ($usecache) {
// Cache output if existing copy has expired
$cacheservice->End($hash);
// Cache output if existing copy has expired
$cacheservice->End($hash);
}
?>

View File

@ -28,34 +28,34 @@ isset($_POST['contact']) ? define('POST_CONTACT', $_POST['contact']): define('PO
isset($_GET['contact']) ? define('GET_CONTACT', $_GET['contact']): define('GET_CONTACT', '');
/* Managing path info */
@list($url, $user) = isset($_SERVER['PATH_INFO']) ? explode('/', $_SERVER['PATH_INFO']) : NULL;
@list($url, $user) = isset($_SERVER['PATH_INFO']) ? explode('/', $_SERVER['PATH_INFO']) : null;
if($user=='' && POST_CONTACT != '') {
$user = POST_CONTACT;
} elseif($user=='' && GET_CONTACT != '') {
$user = GET_CONTACT;
if ($user=='' && POST_CONTACT != '') {
$user = POST_CONTACT;
} elseif ($user=='' && GET_CONTACT != '') {
$user = GET_CONTACT;
}
if ($userservice->isLoggedOn() && $user) {
$pagetitle = '';
$pagetitle = '';
$userid = $userservice->getIdFromUser($user);
if($userid == NULL) {
$tplVars['error'] = sprintf(T_('User with username %s was not found'), $user);
$templateservice->loadTemplate('error.404.tpl', $tplVars);
exit();
}
$userid = $userservice->getIdFromUser($user);
$watched = $userservice->getWatchStatus($userid, $currentUser->getId());
$changed = $userservice->setWatchStatus($userid);
if ($userid == null) {
$tplVars['error'] = sprintf(T_('User with username %s was not found'), $user);
$templateservice->loadTemplate('error.404.tpl', $tplVars);
exit();
}
if ($watched) {
$tplVars['msg'] = T_('User removed from your watchlist');
} else {
$tplVars['msg'] = T_('User added to your watchlist');
}
$watched = $userservice->getWatchStatus($userid, $currentUser->getId());
$changed = $userservice->setWatchStatus($userid);
header('Location: '. createURL('watchlist', $currentUser->getUsername()));
if ($watched) {
$tplVars['msg'] = T_('User removed from your watchlist');
} else {
$tplVars['msg'] = T_('User added to your watchlist');
}
header('Location: '. createURL('watchlist', $currentUser->getUsername()));
}
?>

View File

@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
require_once 'www-header.php';
/* Service creation: only useful services are created */
$bookmarkservice =SemanticScuttle_Service_Factory::get('Bookmark');
$cacheservice =SemanticScuttle_Service_Factory::get('Cache');
$bookmarkservice = SemanticScuttle_Service_Factory::get('Bookmark');
$cacheservice = SemanticScuttle_Service_Factory::get('Cache');
/* Managing all possible inputs */
isset($_GET['page']) ? define('GET_PAGE', $_GET['page']): define('GET_PAGE', 0);
@ -32,7 +32,7 @@ isset($_GET['sort']) ? define('GET_SORT', $_GET['sort']): define('GET_SORT', '')
$currentUser = $userservice->getCurrentObjectUser();
/* Managing path info */
@list($url, $user, $page) = isset($_SERVER['PATH_INFO']) ? explode('/', $_SERVER['PATH_INFO']) : NULL;
@list($url, $user, $page) = isset($_SERVER['PATH_INFO']) ? explode('/', $_SERVER['PATH_INFO']) : null;
if ($usecache) {
@ -55,8 +55,8 @@ if ($user) {
if (is_int($user)) {
$userid = intval($user);
} else {
$userinfo = $userservice->getObjectUserByUsername($user);
if ($userinfo == NULL ) {
$userinfo = $userservice->getObjectUserByUsername($user);
if ($userinfo == null ) {
// Throw a 404 error
$tplVars['error'] = sprintf(T_('User with username %s was not found'), $user);
$templateservice->loadTemplate('error.404.tpl', $tplVars);
@ -91,7 +91,7 @@ if ($user) {
$tplVars['start'] = $start;
$tplVars['bookmarkCount'] = $start + 1;
$bookmarks =& $bookmarkservice->getBookmarks($start, $perpage, $userid, NULL, NULL, getSortOrder(), true);
$bookmarks =& $bookmarkservice->getBookmarks($start, $perpage, $userid, null, null, getSortOrder(), true);
$tplVars['sidebar_blocks'] = array('watchlist');
$tplVars['watched'] = true;