Compare commits

..

25 Commits
master ... phar

Author SHA1 Message Date
Christian Weiske
f36c79cb7b phar + clean urls work fully now 2014-03-26 21:54:55 +01:00
Christian Weiske
995dbef2a1 map clean urls to .php files in phar 2014-03-26 21:54:51 +01:00
Christian Weiske
fb4d822f31 make "php dist/SemanticScuttle-0.98.X.phar r scripts/avahi-export.php" work 2014-03-26 21:54:46 +01:00
Christian Weiske
9a57269b23 introduce global $cfg variable that one day will get rid of all the $GLOBALS pollution 2014-03-26 21:54:41 +01:00
Christian Weiske
524b1056a6 troubleshooting 2014-03-26 21:54:36 +01:00
Christian Weiske
6f5cd7c6e4 phar installation instructions 2014-03-26 21:54:22 +01:00
Christian Weiske
7947dad6a5 implement extracting files and running scripts 2014-03-26 21:53:00 +01:00
Christian Weiske
897bc4f7dc use console_commandline to handle cli arguments 2014-03-26 21:52:56 +01:00
Christian Weiske
d49a9e684b map calls to phar without anything 2014-03-26 21:52:51 +01:00
Christian Weiske
75156bfd20 first version of phar cli interface; currently lists files only 2014-03-26 21:52:47 +01:00
Christian Weiske
afe1fbd4b4 phar setup 2014-03-26 21:52:42 +01:00
Christian Weiske
557467b2b4 properly detect path info when running in the phar without /www/ 2014-03-26 21:51:35 +01:00
Christian Weiske
2333ebf0e7 fix config tests 2014-03-26 21:50:20 +01:00
Christian Weiske
e991f209bc get rid of www/ in phar 2014-03-26 21:50:13 +01:00
Christian Weiske
3070f234b6 fix file inclusion with phar 2014-03-26 21:49:38 +01:00
Christian Weiske
e6d66690d2 fix PATH_INFO in phar mode
Conflicts:
	src/SemanticScuttle/Environment.php
	src/SemanticScuttle/constants.php
	tests/SemanticScuttle/EnvironmentTest.php
2014-03-26 21:47:33 +01:00
Christian Weiske
aed211c5b2 provide mapping for /www/ 2014-03-26 21:43:42 +01:00
Christian Weiske
64923095e6 detect correct root path when run from the phar 2014-03-26 21:43:37 +01:00
Christian Weiske
f93c3bbe76 test configurable root 2014-03-26 21:43:32 +01:00
Christian Weiske
b0e4b4390b move root directory detection into SemanticScuttle_Environment to make it testable
Conflicts:
	tests/SemanticScuttle/EnvironmentTest.php
2014-03-26 17:19:05 +01:00
Christian Weiske
bbe708ce17 delete phar file before generating it 2014-03-26 17:16:18 +01:00
Christian Weiske
160ef2d631 own stub for the phar to disallow access to anything but www/ 2014-03-26 17:16:11 +01:00
Christian Weiske
b73d18af88 load configuration for phar files
Conflicts:
	src/SemanticScuttle/Config.php
2014-03-26 17:15:54 +01:00
Christian Weiske
ddcf7cd2a3 we have no hostname on cli (phar) 2014-03-26 17:11:53 +01:00
Christian Weiske
72db833930 phar generation task
Conflicts:
	build.xml
2014-03-26 17:11:37 +01:00
66 changed files with 1054 additions and 1356 deletions

View File

@ -1,12 +0,0 @@
Patched SemanticScuttle (social bookmarking tool).
================================================
### New :
* Better import for XML bookmark file.
* Support for adding multiple bookmarks at once with my modified Firefox's Scuttle plugin.
* Block everything if global private mode enabled and user not logged on.
* Shoulder surfing protection.
* Batch tagging.
* Search will now look in bookmarks addresses too.

View File

@ -22,8 +22,10 @@
" />
<property name="zipfile" value="${phing.project.name}-${version}.zip" />
<property name="pkgfile" value="${phing.project.name}-${version}.tgz" />
<property name="pharfile" value="${phing.project.name}-${version}.phar" />
<property name="distfile" value="dist/${zipfile}" />
<property name="distpkgfile" value="dist/pear/${pkgfile}" />
<property name="pharfilepath" value="dist/${pharfile}" />
<property name="sfproject" value="SemanticScuttle" />
<property name="sffilepath" value="s/se/semanticscuttle/" />
<property name="svnpath" value="https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/" />
@ -305,6 +307,30 @@
</target>
<target name="phar" depends="check"
description="Create .phar file for release"
>
<echo msg="Creating .phar for SemanticScuttle ${version}"/>
<delete file="${pharfilepath}" quiet="yes"/>
<pharpackage basedir="." destfile="${pharfilepath}"
alias="SemanticScuttle.phar"
stub="res/phar-stub.php"
>
<metadata>
<element name="version" value="${version}" />
<element name="authors">
<element name="Christian Weiske">
<element name="e-mail" value="cweiske@cweiske.de" />
</element>
</element>
</metadata>
<fileset refid="fs.zip"/>
</pharpackage>
</target>
<target name="build-docs" description="render documentation">
<rST format="html" uptodate="true"
toolparam="--stylesheet=res/docs/style.css"

View File

@ -208,6 +208,8 @@ $tableprefix = 'sc_';
*/
$dbneedssetnames = true;
$dbpersist = false;
/***************************************************
* Users
@ -253,13 +255,10 @@ $adminsAreAdvisedTagsFromOtherAdmins = false;
*
* @var array
*/
$reservedusers = array('all', 'watchlist');
$reservedusers = array('all', 'watchlist');
/**
* If global private mode is enabled (everything will be blocked for unlogged users).
* @var boolean
*/
$privatemode = false;
/***************************************************
* Anti SPAM measures
@ -545,27 +544,35 @@ $defaults['privacy'] = 0;
*/
/**
* Which thumbnail service type to use.
* Enable bookmark website thumbnails.
*
* Currently supported:
* - null (no screenshots)
* - 'phancap', see http://cweiske.de/phancap.htm
* According to artviper.net license, buy a license if you
* gain profit with your pages.
*
* @var boolean
* @link http://www.websitethumbnail.de/
*/
$enableWebsiteThumbnails = false;
/**
* User ID from websitethumbnail.de
*
* You need to register on
* http://www.artviper.net/registerapi.php
* in order to use thumbnails on your domain
*
* @var string
* @link http://www.artviper.net/registerapi.php
*/
$thumbnailsUserId = null;
/**
* API key.
* Sent to you by artviper.net after registration.
*
* @var string
*/
$thumbnailsType = null;
/**
* Configuration for thumbnail service.
*
* Phancap requires an array with the following keys:
* - url: URL to phancap's get.php file
* - token: user name (if access protected)
* - secret: password for the user (if access protected)
*
* @var array
*/
$thumbnailsConfig = array();
$thumbnailsKey = null;
@ -615,13 +622,6 @@ $menu2Tags = array(
'menu2', 'tags', 'configurable', 'in', 'data/config.php'
);
/**
* Tag protected from shoulder surfing.
* This tag, his children and the associated bookmarks won't appear anywhere unless enabled in the UI.
*
* @var string
*/
$shoulderSurfingProtectedTag = 's_hidden';
/****************************

View File

@ -115,38 +115,3 @@ echo jsEscTitle(htmlspecialchars($link));
}
//]]>
</script>
<script type="text/javascript">
function activateSocialApi(node) {
var baseurl = <?php echo json_encode(addProtocolToUrl(createURL())); ?>;
var socialApiData = {
// currently required
"name": <?php echo json_encode($GLOBALS['sitename']); ?>,
"iconURL": baseurl + "themes/default/images/logo.png",
"icon32URL": baseurl + "themes/default/images/logo.png",
"icon64URL": baseurl + "themes/default/images/logo.png",
"markURL": "<?php echo addProtocolToUrl(createURL('bookmarks', $GLOBALS['user'])); ?>?action=add&amp;popup=1&amp;width=800&amp;height=470&amp;address=%{url}&amp;title=%{title}&amp;description=%{description}%{text}",
"markedIcon": baseurl + "themes/default/images/logo.png",
"unmarkedIcon": baseurl + "themes/default/images/logo-empty.png",
// should be available for display purposes
"description": "Self-hosted bookmark manager",
"author": "Christian Weiske",
"homepageURL": "http://semanticscuttle.sf.net/",
// optional
"version": "0.0.3"
};
var event = new CustomEvent("ActivateSocialFeature");
node.setAttribute("data-service", JSON.stringify(socialApiData));
node.dispatchEvent(event);
}
</script>
<p>
<button onclick="activateSocialApi(this)" title="activate semanticscuttle in firefox">
Add SemanticScuttle to Firefox
</button>
</p>

View File

@ -5,14 +5,14 @@
*
* Expects a $row variable with bookmark data.
*/
$thumbnailer = SemanticScuttle_Service_Factory::get('Thumbnails')->getThumbnailer();
$imgUrl = $thumbnailer->getThumbnailUrl($address, 120, 90);
if ($imgUrl !== false) {
echo '<a href="' . htmlspecialchars($address) . '">'
. '<img class="thumbnail" width="120" height="90" src="'
. htmlspecialchars($imgUrl).
'" />'
. '</a>';
if (!$GLOBALS['enableWebsiteThumbnails']) {
return;
}
$thumbnailHash = md5(
$address . $GLOBALS['thumbnailsUserId'] . $GLOBALS['thumbnailsKey']
);
//echo '<a href="'. $address .'"'. $rel .' ><img class="thumbnail" src="http://www.artviper.net/screenshots/screener.php?url='.$address.'&w=120&sdx=1280&userID='.$GLOBALS['thumbnailsUserId'].'&hash='.$thumbnailHash.'" />';
echo '<img class="thumbnail" onclick="window.location.href=\''.htmlspecialchars($address).'\'" src="http://www.artviper.net/screenshots/screener.php?url='.htmlspecialchars($address).'&amp;w=120&amp;sdx=1280&amp;userID='.$GLOBALS['thumbnailsUserId'].'&amp;hash='.$thumbnailHash.'" />';
?>

View File

@ -162,14 +162,6 @@ default:
<a href="?sort=<?php echo $votingSort ?>"><?php echo T_("Voting").$votingArrow; ?></a>
<span>/</span>
<?php } ?>
<?php
if ($userservice->isLoggedOn() && $_SERVER['PHP_SELF'] !== "/index.php") {
echo '<form method="get" action="'. $_SERVER['REQUEST_URI'] .'">';
echo '<input type="hidden" name="batch" value="1"/>';
echo '<input type="submit" value="Batch tagging"/>';
echo "</form>";
}
?>
<?php
if ($currenttag!= '') {
@ -186,6 +178,7 @@ if ($currenttag!= '') {
}
}
?></p>
<?php
// PAGINATION

View File

@ -6,6 +6,11 @@ echo '<a href="'.createURL('about').'">'.T_('About').'</a>';
echo ' - ';
echo T_("Propulsed by ");
echo " <a href=\"https://sourceforge.net/projects/semanticscuttle/\">SemanticScuttle</a>";
if($GLOBALS['enableWebsiteThumbnails']) {
// Licence to the thumbnails provider (OBLIGATORY IF YOU USE ARTVIPER SERVICE)
echo ' (Thumbnails by <a href="http://www.artviper.net">webdesign</a>)';
}
?>
</div>

View File

@ -1,5 +1,6 @@
<?php
$this->includeTemplate($GLOBALS['top_include']);
$accessPublic = '';
$accessShared = '';
$accessPrivate = '';
@ -32,14 +33,6 @@ if (is_array($row['tags'])) {
$row['tags'] = implode(', ', $row['tags']);
}
if (! is_array($row['bAddress'])) {
$row['bAddress'] = array($row['bAddress']);
}
if (! is_array($row['bTitle'])) {
$row['bTitle'] = array($row['bTitle']);
}
$ajaxUrl = ROOT . 'ajax/'
. (
($GLOBALS['adminsAreAdvisedTagsFromOtherAdmins'] && $currentUser->isAdmin())
@ -47,8 +40,18 @@ $ajaxUrl = ROOT . 'ajax/'
: 'getcontacttags'
) . '.php';
?>
<form onsubmit="var ind = 0; var cb = document.getElementById('checkbox'+ind); while (cb !== null) {var title = document.getElementById('titleField'+ind); var address = document.getElementById('address'+ind); if(cb.checked) {cb.parentNode.removeChild(cb);} else {cb.parentNode.removeChild(cb); title.parentNode.removeChild(title); address.parentNode.removeChild(address);} ind++; cb = document.getElementById('checkbox'+ind);}" action="<?php echo $formaction; ?>" method="post">
<form action="<?php echo $formaction; ?>" method="post">
<table>
<tr>
<th align="left"><?php echo T_('Address'); ?></th>
<td><input type="text" id="address" name="address" size="75" maxlength="65535" value="<?php echo filter($row['bAddress'], 'xml'); ?>" onblur="useAddress(this)" /></td>
<td> <?php echo T_('Required'); ?></td>
</tr>
<tr>
<th align="left"><?php echo T_('Title'); ?></th>
<td><input type="text" id="titleField" name="title" size="75" maxlength="255" value="<?php echo filter($row['bTitle'], 'xml'); ?>" onkeypress="this.style.backgroundImage = 'none';" /></td>
<td> <?php echo T_('Required'); ?></td>
</tr>
<tr>
<th align="left">
<?php echo T_('Description'); ?>
@ -75,44 +78,13 @@ $ajaxUrl = ROOT . 'ajax/'
<td> <?php echo T_('Just visible by you and your contacts.'); ?>
</td>
</tr>
<?php if(! isset($batch)): ?>
<tr>
<th align="left"><?php echo T_('Tags'); ?></th>
<td class="scuttletheme">
<input type="text" id="tags" class="tags" name="tags" size="75" value="<?php echo filter($row['tags'], 'xml'); ?>"/>
<input type="text" id="tags" name="tags" size="75" value="<?php echo filter($row['tags'], 'xml'); ?>"/>
</td>
<td> <?php echo T_('Comma-separated'); ?></td>
</tr>
<?php else: ?>
<tr>
<th align="left"><?php echo 'Common tags'; ?></th>
<td class="scuttletheme">
<span><?php echo filter($commontags, 'xml'); ?></span>
</td>
<td> <?php echo 'Tags common to all those bookmarks'; ?></td>
</tr>
<tr>
<th align="left"><?php echo 'Associated tags'; ?></th>
<td class="scuttletheme">
<span><?php echo filter($alltags, 'xml'); ?></span>
</td>
<td> <?php echo 'All tags associated to those bookmarks'; ?></td>
</tr>
<tr>
<th align="left"><?php echo 'Add those tags'; ?></th>
<td class="scuttletheme">
<input type="text" id="tags" class="tags" name="tags" size="75" value="<?php echo filter($row['tags'], 'xml'); ?>"/>
</td>
<td> <?php echo T_('Comma-separated'); ?></td>
</tr>
<tr>
<th align="left"><?php echo 'Remove those tags'; ?></th>
<td class="scuttletheme">
<input type="text" id="removetags" class="tags" name="removetags" size="75" value="<?php echo filter($row['tags'], 'xml'); ?>"/>
</td>
<td> <?php echo T_('Comma-separated'); ?></td>
</tr>
<?php endif; ?>
<tr>
<th></th>
<td align="right"><small><?php echo htmlspecialchars(T_('Note: use ">" to include one tag in another. e.g.: europe>france>paris'))?></small></td>
@ -143,9 +115,6 @@ $ajaxUrl = ROOT . 'ajax/'
<input type="submit" name="delete" value="<?php echo T_('Delete Bookmark'); ?>" />
<?php
}
?>
<button type="button" id="button" title="Invert selection" onclick="var ind = 0; var cb = document.getElementById('checkbox'+ind); while (cb !== null) {var title = document.getElementById('titleField'+ind); var address = document.getElementById('address'+ind); if(cb.checked) {cb.checked=false;} else {cb.checked=true;} ind++; cb = document.getElementById('checkbox'+ind);}">Invert selection</button>
<?php
if (isset($showdelete) && $showdelete) {
echo ' (<a href="'.createURL('bookmarkcommondescriptionedit', $row['bHash']).'">';
echo T_('edit common description').'</a>)';
@ -157,42 +126,14 @@ $ajaxUrl = ROOT . 'ajax/'
<?php
} elseif (isset($referrer)) {
?>
<input type="hidden" name="referrer" value="<?php echo filter($referrer, 'xml'); ?>" />
<input type="hidden" name="referrer" value="<?php echo $referrer; ?>" />
<?php
}
?>
</td>
<td></td>
</tr>
<?php
$ind = 0;
foreach($row['bAddress'] as $index => $address) {
?>
<tr>
<td height="20px"></td>
<td><input type="checkbox" id="checkbox<?php echo $ind; ?>" checked="checked" /></td>
<td></td>
</tr>
<tr>
<th align="left"><?php echo T_('Address'); ?></th>
<td><input type="text" id="address<?php echo $ind; ?>" name="address[<?php echo $index; ?>]" size="75" maxlength="65535" value="<?php echo filter($address, 'xml'); ?>" onblur="useAddress(this)" /></td>
<td> <?php echo T_('Required'); ?></td>
</tr>
<tr>
<th align="left"><?php echo T_('Title'); ?></th>
<td><input type="text" id="titleField<?php echo $ind; ?>" name="title[<?php echo $index; ?>]" size="75" maxlength="255" value="<?php echo filter($row['bTitle'][$index], 'xml'); ?>" onkeypress="this.style.backgroundImage = 'none';" /></td>
<td> <?php echo T_('Required'); ?></td>
</tr>
<tr>
<td height="20px"></td>
<td></td>
<td></td>
</tr>
<?php
$ind++;
}
?>
</table>
</table>
</form>
<link href="<?php echo ROOT ?>js/jquery-ui-1.8.11/themes/base/jquery.ui.all.css" rel="stylesheet" type="text/css"/>
@ -215,8 +156,7 @@ jQuery(document).ready(function() {
}
//var availableTags = ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby"];
//jQuery("input#tags").autocomplete({
jQuery("input.tags").autocomplete({
jQuery("input#tags").autocomplete({
autoFocus: true,
minLength: 1,

View File

@ -11,62 +11,14 @@ if ($userservice->isLoggedOn() && is_object($currentUser)) {
<li><a href="<?php echo createURL('watchlist', $cUsername); ?>"><?php echo T_('Watchlist'); ?></a></li>
<li><a href="<?php echo $userservice->getProfileUrl($cUserId, $cUsername); ?>"><?php echo T_('Profile'); ?></a></li>
<li><a href="<?php echo createURL('bookmarks', $cUsername . '?action=add'); ?>"><?php echo T_('Add a Bookmark'); ?></a></li>
<?php if (isset($loadjs)) :?>
<li class="access"><button type="button" id="button" title="shoulder surfing protection" onclick="if(! $.cookie('noshoulderSurfingProtection')) {toggle();} else {$.removeCookie('noshoulderSurfingProtection', { path: '/' }); location.reload();}"><?php if(! isset($_COOKIE["noshoulderSurfingProtection"])) {echo "Protected";} else {echo "Unprotected";} ?></button></li>
<?php endif ?>
<li class="access"><?php echo $cUsername?><a href="<?php echo ROOT ?>?action=logout">(<?php echo T_('Log Out'); ?>)</a></li>
<li><a href="<?php echo createURL('about'); ?>"><?php echo T_('About'); ?></a></li>
<?php if($currentUser->isAdmin()): ?>
<li><a href="<?php echo createURL('admin', ''); ?>"><?php echo '['.T_('Admin').']'; ?></a></li>
<?php endif; ?>
</ul>
<?php if (isset($loadjs)) :?>
<div id="password-form" style="background:white; z-index: 2; position:absolute; top:55px; right:10px; visibility:hidden;">
<form id="noshoulderSurfingProtectionPassword">
<input type="password" name="password" id="password" size="40" placeholder="Type your password then press Enter to unprotect."/>
<!-- Allow form submission with keyboard without duplicating the dialog button -->
<input type="submit" tabindex="-1" style="position:absolute; top:-1000px"/>
</form>
</div>
<script>
// Prevents browser autocompletion. autocomplete="off" as input type="password" attribute only works with HTML5.
setTimeout(
clear(),
1000 //1,000 milliseconds = 1 second
);
function clear() {
$('#password').val('');
}
function toggle() {
if ($("#password-form").css("visibility") == "visible") {
$("#password-form").css("visibility", "hidden");
}
else {
clear();
$("#password-form").css("visibility", "visible");
}
}
$( "#noshoulderSurfingProtectionPassword" ).submit(function( event ) {
$.post(
'<?php echo ROOT ?>ajax/checkpassword.php',
{
password : $("#password").val(),
},
function(data) {
if(data == 'true') {
$.cookie('noshoulderSurfingProtection', 'null', { path: '/' });
location.reload();
}
},
'text'
);
event.preventDefault();
});
</script>
<?php endif ?>
<?php
} else {
?>

View File

@ -22,35 +22,19 @@ if (isset($rsschannels)) {
<?php if (DEBUG_MODE) : ?>
<script type="text/javascript" src="<?php echo ROOT_JS ?>jquery-1.4.2.js"></script>
<script type="text/javascript" src="<?php echo ROOT_JS ?>jquery.jstree.js"></script>
<script type="text/javascript" src="<?php echo ROOT_JS ?>jquery.cookie-1.4.1.js"></script>
<?php else: ?>
<script type="text/javascript" src="<?php echo ROOT_JS ?>jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="<?php echo ROOT_JS ?>jquery.jstree.min.js"></script>
<script type="text/javascript" src="<?php echo ROOT_JS ?>jquery.cookie-1.4.1.js"></script>
<?php endif ?>
<script type="text/javascript" src="<?php echo ROOT ?>jsScuttle.php"></script>
<?php endif ?>
</head>
<?php
$bodystyle = '';
if (isset($_GET['popup'])) {
if (isset($_GET['height'])) {
$bodystyle .= 'height:' . intval($_GET['height']) . 'px;';
}
if (isset($_GET['width'])) {
$bodystyle .= 'width:' . intval($_GET['width']) . 'px;';
}
if ($bodystyle != '') {
$bodystyle = ' style="' . $bodystyle . '"';
}
}
?>
<body<?php echo $bodystyle; ?>>
<body>
<?php
$headerstyle = '';
if (isset($_GET['popup'])) {
if(isset($_GET['popup'])) {
$headerstyle = ' class="popup"';
}
?>

View File

@ -14,6 +14,11 @@ To run SemanticScuttle, you need:
Standard installation instructions
==================================
If you downloaded the ``.phar`` file, follow the `Phar setup instructions`__.
Otherwise continue here:
__ install-phar.html
If you've downloaded a ``SemanticScuttle-x.y.z.zip`` file from SourceForge,
then this instructions are for you.

View File

@ -59,9 +59,6 @@ __ https://sourceforge.net/mailarchive/forum.php?forum_name=semanticscuttle-deve
Known issues
============
See `troubleshooting.rst`_ for a list of known problems and their solution.
Number of bookmarks always 0: "0 bookmark(s)"
---------------------------------------------
This issue occurs when debug mode is enabled.
Technically, this is because the database layers ``DEBUG_EXTRA`` gets
enabled through debug mode.
.. _troubleshooting.rst: troubleshooting.html

View File

@ -211,6 +211,3 @@ Here we authenticate against an active directory server.
);
$authEmailSuffix = '@example.org';
More LDAP options can be found in the `PEAR manual`__.
__ http://pear.php.net/manual/en/package.authentication.auth.storage.ldap.php

84
doc/install-phar.rst Normal file
View File

@ -0,0 +1,84 @@
==================================
SemanticScuttle .phar installation
==================================
How to install the `.phar` version of SemanticScuttle.
Note: The ``.phar`` file can be used from the browser and
via command line. Use ``--help`` to find out what you can do.
.. contents::
Server setup
============
Apache or any other web server is by default not configured to let PHP handle
``.phar`` files, so we need to add it.
The default apache configuration on Debian contains the following lines::
<FilesMatch "\.ph(p3?|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
which matches ``.php``, ``.php3`` and ``.phtml`` files.
Adding ``.phar`` is trivial::
<FilesMatch "\.ph(ar|p3?|tml)$">
Restart your server after this configuration change.
Database setup
==============
Extract the database schema from the ``.phar`` file::
$ php SemanticScuttle-0.98.3.phar x data/tables.sql tables.sql
Import the schema into you MySQL server::
$ mysql -umyusername mydatabase < tables.sql
Database upgrades
-----------------
If you are upgrading from an earlier version of SemanticScuttle, you might need
to upgrade your database schema.
See the `upgrade instructions`_ for more information.
Get a list of all schema files with ::
$ php SemanticScuttle-0.98.3.phar list | grep schema
and then extract the relevant ones with ::
$ php SemanticScuttle-0.98.3.phar x data/schema/6.sql
.. _upgrade instructions: UPGRADE.html
Configuration
=============
Extract the configuration file from the ``.phar`` file::
$ php SemanticScuttle-0.98.3.phar x data/config.php.dist SemanticScuttle-0.98.3.phar.config.php
Note that the file name must be exactly the name of the ``.phar``
plus ``.config.php`` - otherwise the configuration file is not detected.
After extracting it, modify it according to your needs.
Caching
-------
If you want to enable caching, make sure you use a ``$dir_cache`` that is
_outside_ the phar file.
Visit SemanticScuttle
=====================
Open your browser and navigate to the ``.phar`` file.
Happy bookmarking!

View File

@ -51,8 +51,7 @@ Existing themes
===============
* `Flat`__ by Roman Lehnhof. See the `introduction blog post`__
* `sscuttlizr`__
__ https://github.com/rlehnhof/flat
__ http://lehnhof.net/2013/08/semantic-scuttle-new-flat-interface-theme-template/
__ https://github.com/jonrandoem/sscuttlizr

View File

@ -2,35 +2,7 @@
Tools to use with SemanticScuttle
=================================
Scuttleoid
==========
Scuttloid is an android client for managing your bookmarks that are
stored on a Semantic Scuttle server.
It allows to list/search your personal bookmarks, add and edit existing
bookmarks, and share them to other applications.
Installable via `f-droid`__.
Also see the `source code`__.
__ https://f-droid.org/repository/browse/?fdid=gr.ndre.scuttloid
__ https://github.com/ilesinge/scuttloid
Scuttle for Android
===================
Scuttle for Android is a client for the Scuttle bookmarking software.
Enter your Scuttle login information and you will presented with a list of your
bookmarks.
Touching a bookmark will load that web page in the browser.
Use the browser's "Share" menu option to add bookmarks to your Scuttle.
See the homepage__ and `source code`__.
__ http://slideme.org/application/scuttle-android
__ https://github.com/shadybrooksoftware/Scuttle-For-Android
ttrss2scuttle
TTRSS2SCUTTLE
=============
Announced in a `blog post`__, the plugin for the feed reader `Tiny Tiny RSS`__
allows you to bookmark any of the articles in your own SemanticScuttle

33
doc/troubleshooting.rst Normal file
View File

@ -0,0 +1,33 @@
===============================
SemanticScuttle Troubleshooting
===============================
Godaddy error: "No input file specified."
=========================================
Opening personalized URLs like ``bookmarks.php/username`` on a godaddy
hosted server leads to the error ::
No input file specified.
We do not have a real solution yet, but changing the PHP handler from
`CGI` to `mod_php` in the control center makes it work:
- Hosting Control Center
- Settings
- File extensions
- Change ``.php`` from `FastCGI` to `PHP 5.x`
Thanks to CESgeekbook__ for the hint.
__ http://www.cesgeekbook.com/2010/07/php-no-input-file-specified-godaddy.html
Number of bookmarks always 0: "0 bookmark(s)"
=============================================
This issue occurs when debug mode is enabled.
Technically, this is because the database layers ``DEBUG_EXTRA`` gets
enabled through debug mode.

54
res/phar-stub.php Normal file
View File

@ -0,0 +1,54 @@
<?php
if (!in_array('phar', stream_get_wrappers())
|| !class_exists('Phar', 0)
) {
echo 'PHP Phar extension required';
exit;
}
Phar::interceptFileFuncs();
if (php_sapi_name() == 'cli') {
require_once dirname(__FILE__) . '/../src/SemanticScuttle/Phar/Cli.php';
$cli = new SemanticScuttle_Phar_Cli();
$cli->run();
exit;
}
function mapUrls($path)
{
$arMap = array(
'' => '/www/index.php',
'/' => '/www/index.php',
'/gsearch/' => '/www/gsearch/index.php',
);
if (isset($arMap[$path])) {
return $arMap[$path];
}
$parts = explode('/', $path);
$partPos = 1;
if (in_array($parts[$partPos], array('js', 'player', 'themes'))) {
return '/www' . $path;
}
if (in_array($parts[$partPos], array('ajax', 'api', 'gsearch'))) {
$partPos = 2;
}
$pos = strrpos($parts[$partPos], '.');
if ($pos === false) {
$parts[$partPos] .= '.php';
$_SERVER['PATH_INFO'] = '/' . implode(
'/', array_slice($parts, $partPos + 1)
);
}
return '/www' . implode('/', $parts);
}
Phar::webPhar(
null,
'www/index.php',
null,
array(),
'mapUrls'
);
__HALT_COMPILER(); ?>

View File

@ -20,7 +20,7 @@
* @license AGPL http://www.gnu.org/licenses/agpl.html
* @link http://sourceforge.net/projects/semanticscuttle
*/
class SemanticScuttle_Config
class SemanticScuttle_Config implements ArrayAccess
{
/**
* Prefix for configuration files.
@ -30,6 +30,121 @@ class SemanticScuttle_Config
*/
public $filePrefix = '';
/**
* Array with all configuration data
*/
protected $configData = array();
/**
* Loads the variables from the given configuration file
* into $GLOBALS
*
* @param string $file Configuration file path to load
*
* @return void
*/
public function load($file)
{
// ack \\$ data/config.default.php |sed 's/ .*$//'|grep -v ^$|sort
//this here is required because setting $GLOBALS doesnt'
// automatically set "global" :/
global
$adminemail,
$adminsAreAdvisedTagsFromOtherAdmins,
$adminsCanModifyBookmarksFromOtherUsers,
$admin_users,
$allowedProtocols,
$allowUnittestMode,
$antispamAnswer,
$antispamQuestion,
$authDebug,
$authEmailSuffix,
$authOptions,
$authType,
$avahiServiceFilePath,
$avahiServiceFilePrefix,
$avahiTagName,
$blankDescription,
$bottom_include,
$cleanurls,
$dateOrderField,
$dbhost,
$dbname,
$dbneedssetnames,
$dbpass,
$dbpersist,
$dbport,
$dbtype,
$dbuser,
$debugMode,
$defaultOrderBy,
$defaultPerPage,
$defaultPerPageForAdmins,
$defaultRecentDays,
$defaultRssEntries,
$defaults,
$descriptionAnchors,
$dir_cache,
$enableAdminColors,
$enableCommonBookmarkDescription,
$enableCommonTagDescription,
$enableCommonTagDescriptionEditedByAll,
$enableGoogleCustomSearch,
$enableRegistration,
$enableVoting,
$enableWebsiteThumbnails,
$filetypes,
$footerMessage,
$googleAnalyticsCode,
$hideBelowVoting,
$index_sidebar_blocks,
$locale,
$longdate,
$maxRssEntries,
$maxSizeMenuBlock,
$menu2Tags,
$menuTag,
$nofollow,
$reservedusers,
$root,
$serviceoverrides,
$shortdate,
$shorturl,
$sidebarBottomMessage,
$sidebarTopMessage,
$sitename,
$sizeSearchHistory,
$tableprefix,
$TEMPLATES_DIR,
$theme,
$thumbnailsKey,
$thumbnailsUserId,
$top_include,
$unittestUrl,
$url_redir,
$usecache,
$useredir,
$votingMode,
$welcomeMessage;
require_once $file;
//make them global
//does not really work because many parts still access the variables
// without $cfg/$GLOBALS
//unset($file);
//$GLOBALS = get_defined_vars() + $GLOBALS;
}
/**
* Assigns GLOBALS to configData
*/
public function __construct()
{
$this->configData =& $GLOBALS;
}
/**
@ -50,30 +165,29 @@ class SemanticScuttle_Config
return $datadir;
}
/**
* Tries to find a configuration file by looking in different
* places:
* - pear data_dir/SemanticScuttle/config-$hostname.php
* - pear data_dir/SemanticScuttle/config.php
* - /etc/semanticscuttle/config-$hostname.php
* - /etc/semanticscuttle/config.php
*
* Paths with host name have priority.
* Creates an array with file paths where the configuration
* file may be located.
*
* When open_basedir restrictions are in effect and /etc is not part of
* the setting, /etc/semanticscuttle/ is not checked for config files.
*
* @return array Array with config file path as first value
* and default config file path as second value.
* Any may be NULL if not found
* @return array Array of possible configuration file paths.
*/
public function findFiles()
public function getPossibleConfigFiles()
{
//use basename to prevent path injection
$host = basename($_SERVER['HTTP_HOST']);
if (isset($_SERVER['HTTP_HOST'])) {
//use basename to prevent path injection
$host = basename($_SERVER['HTTP_HOST']);
} else {
$host = 'cli';
}
$datadir = $this->getDataDir();
$arFiles = array();
if (class_exists('Phar') && Phar::running(false) != '') {
$arFiles[] = Phar::running(false) . '.config.php';
}
$openbase = ini_get('open_basedir');
if ($openbase && strpos($openbase, '/etc') === false) {
@ -93,6 +207,30 @@ class SemanticScuttle_Config
);
}
return $arFiles;
}
/**
* Tries to find a configuration file by looking in different
* places:
* - pear data_dir/SemanticScuttle/config-$hostname.php
* - pear data_dir/SemanticScuttle/config.php
* - /etc/semanticscuttle/config-$hostname.php
* - /etc/semanticscuttle/config.php
*
* Paths with host name have priority.
*
* @return array Array with config file path as first value
* and default config file path as second value.
* Any may be NULL if not found
*/
public function findFiles()
{
$datadir = $this->getDataDir();
$arFiles = $this->getPossibleConfigFiles();
$configfile = null;
foreach ($arFiles as $file) {
if (file_exists($this->filePrefix . $file)) {
@ -118,6 +256,32 @@ class SemanticScuttle_Config
}
return array($configfile, $defaultfile);
}
public function offsetExists($offset)
{
return isset($this->configData[$offset]);
}
public function offsetGet($offset)
{
return $this->configData[$offset];
}
public function offsetSet($offset, $value)
{
if (is_null($offset)) {
$this->configData[] = $value;
} else {
$this->configData[$offset] = $value;
}
}
public function offsetUnset($offset)
{
unset($this->configData[$offset]);
}
}
?>

View File

@ -29,6 +29,17 @@ class SemanticScuttle_Environment
*/
public static function getServerPathInfo()
{
if (isset($_SERVER['PHAR_PATH_TRANSLATED'])) {
$fscript = '/' . $_SERVER['SCRIPT_NAME'];
if ($fscript == $_SERVER['PATH_INFO']
|| $fscript == $_SERVER['PATH_INFO'] . '.php'
) {
return null;
} else if (substr($_SERVER['PATH_INFO'], 0, strlen($fscript)) == $fscript) {
return substr($_SERVER['PATH_INFO'], strlen($fscript));
}
}
if (isset($_SERVER['PATH_INFO'])) {
return $_SERVER['PATH_INFO'];
}
@ -44,5 +55,51 @@ class SemanticScuttle_Environment
//fallback when no special path after the php file is given
return '';
}
/**
* Determines the root directory from the server environment.
* The root directory is the path that needs to be prepended
* to relative links.
*
* Returns $GLOBALS['root'] if set.
*
* @return string Base URL with trailing slash
*/
public static function getRoot()
{
if (isset($GLOBALS['root'])) {
return $GLOBALS['root'];
}
$rootTmp = '/';
if (isset($_SERVER['PHAR_PATH_TRANSLATED'])) {
$rootTmp = $_SERVER['SCRIPT_NAME'] . '/';
$_SERVER['SCRIPT_NAME'] = substr(
$_SERVER['PATH_TRANSLATED'],
strpos($_SERVER['PATH_TRANSLATED'], $rootTmp)
+ strlen($rootTmp)
+ 4 /* strip "www/" */
);
}
$pieces = explode('/', $_SERVER['SCRIPT_NAME']);
foreach ($pieces as $piece) {
//we eliminate possible sscuttle subfolders (like gsearch for example)
if ($piece != '' && !strstr($piece, '.php')
&& $piece != 'gsearch' && $piece != 'ajax'
) {
$rootTmp .= $piece .'/';
}
}
if (($rootTmp != '/') && (substr($rootTmp, -1, 1) != '/')) {
$rootTmp .= '/';
}
//we do not prepend http since we also want to support https connections
// "http" is not required; it's automatically determined by the browser
// depending on the current connection.
return '//' . $_SERVER['HTTP_HOST'] . $rootTmp;
}
}
?>

View File

@ -0,0 +1,150 @@
<?php
/**
* SemanticScuttle - your social bookmark manager.
*
* PHP version 5.
*
* @category Bookmarking
* @package SemanticScuttle
* @author Christian Weiske <cweiske@cweiske.de>
* @license AGPL http://www.gnu.org/licenses/agpl.html
* @link http://sourceforge.net/projects/semanticscuttle
*/
require_once 'Console/CommandLine.php';
/**
* Command line interface for the SemanticScuttle.phar file.
* Can be used to extract parts of the phar file and to run
* scripts in it.
*
* @category Bookmarking
* @package SemanticScuttle
* @author Christian Weiske <cweiske@cweiske.de>
* @license AGPL http://www.gnu.org/licenses/agpl.html
* @link http://sourceforge.net/projects/semanticscuttle
*/
class SemanticScuttle_Phar_Cli
{
public function run()
{
$ccl = new Console_CommandLine();
$ccl->name = 'SemanticScuttle';
$ccl->description = 'Command line interface to SemanticScuttle .phar files';
$ccl->version = '0.98.3';
$ccl->add_help_option = true;
$ccl->add_version_option = true;
$ccl->force_posix = true;
$ccl->addCommand('list', array('aliases' => array('l')));
$extract = $ccl->addCommand('extract', array('aliases' => array('x')));
$extract->addArgument(
'file', array('description' => 'Path of file to extract')
);
$extract->addArgument(
'target', array(
'description' => 'Path to store file contents. Defaults to stdout',
'optional' => true,
)
);
$run = $ccl->addCommand('run', array('aliases' => array('r')));
$run->addArgument(
'file', array('description' => 'Path of file to extract')
);
try {
$result = $ccl->parse();
if ($result->command_name == '') {
$ccl->displayUsage();
}
$method = $result->command_name . 'Action';
$this->$method($result->command->args, $result->command->options);
} catch (Exception $ex) {
$ccl->displayError($ex->getMessage());
}
}
/**
* Lists the contents of this phar archive and echos the output
*
* @return void
*/
public function listAction()
{
$excludes = array(
'data/locales',
'data/templates',
'src',
'www',
);
$it = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator(
'phar://SemanticScuttle.phar/'
)
);
while($it->valid()) {
if (!$it->isDot()) {
$name = $it->getSubPathName();
$excluded = false;
foreach ($excludes as $exclude) {
if (substr($name, 0, strlen($exclude)) == $exclude) {
$excluded = true;
break;
}
}
if (!$excluded) {
echo $name . "\n";
}
}
$it->next();
}
}
/**
* Extract the file given in $args['file'] to stdout
*
* @param array $args Array of commandline arguments
* @param array $options Array of commandline options
*
* @return void
* @throws Exception When the file does not exist in the .phar
*/
public function extractAction($args, $options)
{
$file = 'phar://SemanticScuttle.phar/' . $args['file'];
if (!file_exists($file)) {
echo 'File "' . $args['file'] . '" does not exist in phar.' . "\n";
exit(1);
}
if (isset($args['target'])) {
copy($file, $args['target']);
} else {
readfile($file);
}
}
/**
* Runs a script inside the .phar
*
* @param array $args Array of commandline arguments
* @param array $options Array of commandline options
*
* @return void
* @throws Exception When the file does not exist in the .phar
*/
public function runAction($args, $options)
{
$file = 'phar://SemanticScuttle.phar/' . $args['file'];
if (!file_exists($file)) {
echo 'File "' . $args['file'] . '" does not exist in phar.' . "\n";
exit(1);
}
//FIXME: shift off options
include $file;
}
}
?>

View File

@ -51,7 +51,7 @@ class SemanticScuttle_Service
{
static $instance;
if (!isset($instance)) {
$instance = new static($db);
$instance = new self($db);
}
return $instance;
}

View File

@ -687,7 +687,6 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
* @param string $terms Search terms separated by spaces
* @param string $sortOrder One of the following values:
* "date_asc", "date_desc",
* "modified_asc", "modified_desc"
* "title_desc", "title_asc",
* "url_desc", "url_asc",
* "voting_asc", "voting_desc"
@ -733,26 +732,11 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
if (!is_array($tags) && !is_null($tags)) {
$tags = explode('+', trim($tags));
}
if (!is_null($tags)) {
$tags = array_map('trim', $tags);
}
// Remove shoulder surfing protected tags.
if (! empty($GLOBALS['shoulderSurfingProtectedTag']) && $userservice->isLoggedOn() && ! isset($_COOKIE["noshoulderSurfingProtection"])) {
$shoulderSurfingProtectedTags = $tag2tagservice->getAllLinkedTags($GLOBALS['shoulderSurfingProtectedTag'], '>', $sId, array());
$shoulderSurfingProtectedTags[] = $GLOBALS['shoulderSurfingProtectedTag'];
$tags2 = [];
foreach ($tags as $tag) {
if (! in_array($tag, $shoulderSurfingProtectedTags, true)) {
$tags2[] = $tag;
}
}
// If we filtered everything, we stop here and return nothing.
if(! empty($tags) && empty($tags2)) {
return array();
}
$tags = $tags2;
}
$tagcount = count($tags);
for ($i = 0; $i < $tagcount; $i ++) {
$tags[$i] = trim($tags[$i]);
}
// Set up the SQL query.
$query_1 = 'SELECT DISTINCT ';
@ -830,12 +814,6 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
case 'url_asc':
$query_5 .= ' ORDER BY B.bAddress ASC ';
break;
case 'modified_desc':
$query_5 .= ' ORDER BY B.bModified DESC ';
break;
case 'modified_asc':
$query_5 .= ' ORDER BY B.bModified ASC ';
break;
default:
$query_5 .= ' ORDER BY B.' . $GLOBALS['dateOrderField'] . ' DESC ';
}
@ -888,13 +866,10 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
// but private notes won't appear if not allowed.
$query_4 .= ' OR B.bPrivateNote LIKE "'
. $this->db->sql_escape($aTerms[$i])
. '%"';
.'%"';
$query_4 .= ' OR U.username = "'
. $this->db->sql_escape($aTerms[$i])
. '"'; //exact match for username
$query_4 .= ' OR B.bAddress LIKE "%'
. $this->db->sql_escape($aTerms[$i])
. '%"';
if ($dotags) {
$query_4 .= ' OR T.tag LIKE "'
. $this->db->sql_escape($aTerms[$i])
@ -917,20 +892,6 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
$query_4 .= ' AND B.bHash = "'. $hash .'"';
}
// Exclude bookmarks with shoulder surfing protected tags.
if (! empty($GLOBALS['shoulderSurfingProtectedTag']) && $userservice->isLoggedOn() && ! isset($_COOKIE["noshoulderSurfingProtection"])) {
$query_4 .= ' AND B.bId NOT IN (SELECT DISTINCT B0.bId FROM '.
$this->getTableName() .' AS B0, ' . $userservice->getTableName()
.' AS U, ' . $b2tservice->getTableName() .' AS T WHERE B0.uId = U.'
. $userservice->getFieldName('primary') . $privacy .' AND B0.uId = '
. $sId . ' AND (';
$count_s = count($shoulderSurfingProtectedTags);
for ($i = 0; $i < $count_s - 1; $i++) {
$query_4 .= 'T.tag = "'. $shoulderSurfingProtectedTags[$i] .'" OR ';
}
$query_4 .= 'T.tag = "'. $shoulderSurfingProtectedTags[$count_s - 1] .'")'
.' AND T.bId = B0.bId)';
}
$query = $query_1 . $query_2 . $query_3 . $query_4 . $query_5;
@ -943,10 +904,10 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
'', __LINE__, __FILE__, $query, $this->db
);
}
// Disabled because breaks when in debug mode…
//if (SQL_LAYER == 'mysql4') {
// $totalquery = 'SELECT FOUND_ROWS() AS total';
//} else {
if (SQL_LAYER == 'mysql4') {
$totalquery = 'SELECT FOUND_ROWS() AS total';
} else {
if ($hash) {
$totalquery = 'SELECT COUNT(*) AS total'. $query_2
. $query_3 . $query_4;
@ -954,7 +915,7 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
$totalquery = 'SELECT COUNT(DISTINCT bAddress) AS total'
. $query_2 . $query_3 . $query_4;
}
//}
}
if (!($totalresult = $this->db->sql_query($totalquery))
|| (!($row = $this->db->sql_fetchrow($totalresult)))

View File

@ -149,7 +149,7 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService
foreach ($tags as $key => $tag) {
if (strpos($tag, '=')) {
// case "="
$pieces = $tagservice->normalize(explode('=', $tag));
$pieces = explode('=', $tag);
$nbPieces = count($pieces);
if ($nbPieces <= 1) {
continue;
@ -163,7 +163,7 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService
$tags[$key] = $pieces[0];
} else {
// case ">"
$pieces = $tagservice->normalize(explode('>', $tag));
$pieces = explode('>', $tag);
$nbPieces = count($pieces);
if ($nbPieces <= 1) {
continue;
@ -329,7 +329,7 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService
$query = 'SELECT tag, bId FROM ' . $this->getTableName()
. ' WHERE bId IN (' . implode(',', $bookmarkids) . ')'
. ' AND LEFT(tag, 7) <> "system:"'
. ' AND LEFT(tag, 7) <> "system:"'
. ' ORDER BY id, bId ASC';
if (!($dbresult = $this->db->sql_query($query))) {
@ -353,7 +353,7 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService
function &getTags($userid = NULL) {
$userservice = SemanticScuttle_Service_Factory::get('User');
$userservice =SemanticScuttle_Service_Factory::get('User');
$logged_on_user = $userservice->getCurrentUserId();
$query = 'SELECT T.tag, COUNT(B.bId) AS bCount FROM '. $GLOBALS['tableprefix'] .'bookmarks AS B INNER JOIN '. $userservice->getTableName() .' AS U ON B.uId = U.'. $userservice->getFieldName('primary') .' INNER JOIN '. $GLOBALS['tableprefix'] .'bookmarks2tags AS T ON B.bId = T.bId';
@ -366,6 +366,7 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService
} else {
$conditions['B.bStatus'] = 0;
}
$query .= ' WHERE '. $this->db->sql_build_array('SELECT', $conditions) .' AND LEFT(T.tag, 7) <> "system:" GROUP BY T.tag ORDER BY bCount DESC, tag';
if (!($dbresult = $this->db->sql_query($query))) {
@ -374,34 +375,11 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService
}
$output = $this->db->sql_fetchrowset($dbresult);
$this->db->sql_freeresult($dbresult);
return $this->filterShoulderSurfingProtectedTags($output);
}
function &filterShoulderSurfingProtectedTags($dboutput) {
$userservice = SemanticScuttle_Service_Factory::get('User');
if (! empty($GLOBALS['shoulderSurfingProtectedTag']) && $userservice->isLoggedOn() && ! isset($_COOKIE["noshoulderSurfingProtection"])) {
$logged_on_user = $userservice->getCurrentUserId();
$ttt = SemanticScuttle_Service_Factory::get('Tag2Tag');
$shoulderSurfingProtectedTags = $ttt->getAllLinkedTags($GLOBALS['shoulderSurfingProtectedTag'], '>', $logged_on_user, array());
$shoulderSurfingProtectedTags[] = $GLOBALS['shoulderSurfingProtectedTag'];
$output = array();
foreach ($dboutput as $array) {
$flag = 1;
foreach ($shoulderSurfingProtectedTags as $tag) {
if ($array['tag'] === $tag) {
$flag = 0;
break;
}
}
if ($flag) {$output[] = $array;}
}
return $output;
}
else {return $dboutput;}
}
// Returns the tags related to the specified tags; i.e. attached to the same bookmarks
function &getRelatedTags($tags, $for_user = NULL, $logged_on_user = NULL, $limit = 10) {
$conditions = array();
@ -445,7 +423,7 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService
}
$output = $this->db->sql_fetchrowset($dbresult);
$this->db->sql_freeresult($dbresult);
return $this->filterShoulderSurfingProtectedTags($output);
return $output;
}
// Returns the most popular tags used for a particular bookmark hash
@ -475,7 +453,7 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService
}
$output = $this->db->sql_fetchrowset($dbresult);
$this->db->sql_freeresult($dbresult);
return $this->filterShoulderSurfingProtectedTags($output);
return $output;
}
@ -635,7 +613,7 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService
$output = $this->db->sql_fetchrowset($dbresult);
$this->db->sql_freeresult($dbresult);
return $this->filterShoulderSurfingProtectedTags($output);
return $output;
}

View File

@ -113,16 +113,14 @@ class SemanticScuttle_Service_Factory
*/
protected static function loadDb()
{
global $dbhost, $dbuser, $dbpass, $dbname,
$dbport, $dbpersist, $dbtype, $dbneedssetnames;
if (self::$db !== null) {
return;
}
include_once 'SemanticScuttle/db/'. $dbtype .'.php';
include_once 'SemanticScuttle/db/'. $GLOBALS['dbtype'] .'.php';
$db = new sql_db();
$db->sql_connect(
$dbhost, $dbuser, $dbpass, $dbname, $dbport, $dbpersist
$GLOBALS['dbhost'], $GLOBALS['dbuser'], $GLOBALS['dbpass'],
$GLOBALS['dbname'], $GLOBALS['dbport'], $GLOBALS['dbpersist']
);
if (!$db->db_connect_id) {
message_die(
@ -132,7 +130,7 @@ class SemanticScuttle_Service_Factory
);
}
$dbneedssetnames && $db->sql_query('SET NAMES UTF8');
$GLOBALS['dbneedssetnames'] && $db->sql_query('SET NAMES UTF8');
self::$db = $db;
}

View File

@ -151,10 +151,6 @@ class SemanticScuttle_Service_SearchHistory extends SemanticScuttle_DbService
$range = null, $uId = null, $nb = null,
$start = null, $distinct = false, $withResults = false
) {
$userservice = SemanticScuttle_Service_Factory::get('User');
if ($userservice->isLoggedOn() && ! isset($_COOKIE["noshoulderSurfingProtection"])) {
return array();
}
$sql = 'SELECT DISTINCT(shTerms),'
. ' shId, shRange, shNbResults, shDatetime, uId';
$sql.= ' FROM '. $this->getTableName();

View File

@ -318,8 +318,7 @@ class SemanticScuttle_Service_Tag2Tag extends SemanticScuttle_DbService
}
$output = $this->db->sql_fetchrowset($dbresult);
$this->db->sql_freeresult($dbresult);
$btt = SemanticScuttle_Service_Factory::get('Bookmark2Tag');
return $btt->filterShoulderSurfingProtectedTags($output);
return $output;
}
function getMenuTags($uId) {
@ -378,25 +377,6 @@ class SemanticScuttle_Service_Tag2Tag extends SemanticScuttle_DbService
$dbres = $this->db->sql_query($query);
$rowset = $this->db->sql_fetchrowset($dbres);
$this->db->sql_freeresult($dbres);
$userservice = SemanticScuttle_Service_Factory::get('User');
if (count($rowset)>0 && ! empty($GLOBALS['shoulderSurfingProtectedTag']) && $userservice->isLoggedOn() && ! isset($_COOKIE["noshoulderSurfingProtection"])) {
$logged_on_user = $userservice->getCurrentUserId();
$shoulderSurfingProtectedTags = $this->getAllLinkedTags($GLOBALS['shoulderSurfingProtectedTag'], '>', $logged_on_user, array());
$shoulderSurfingProtectedTags[] = $GLOBALS['shoulderSurfingProtectedTag'];
$output = array();
foreach($rowset as $link) {
$flag = 1;
foreach ($shoulderSurfingProtectedTags as $tag) {
if ($link['tag1'] === $tag || $link['tag2'] === $tag) {
$flag = 0;
break;
}
}
if ($flag) {$output[] = $link;}
}
$rowset = $output;
}
return $rowset;
}

View File

@ -1,59 +0,0 @@
<?php
/**
* SemanticScuttle - your social bookmark manager.
*
* PHP version 5.
*
* @category Bookmarking
* @package SemanticScuttle
* @author Christian Weiske <cweiske@cweiske.de>
* @license GPL http://www.gnu.org/licenses/gpl.html
* @link http://sourceforge.net/projects/semanticscuttle
*/
/**
* Instantiates the configured website thumbnailer object.
*
* @category Bookmarking
* @package SemanticScuttle
* @author Christian Weiske <cweiske@cweiske.de>
* @license GPL http://www.gnu.org/licenses/gpl.html
* @link http://sourceforge.net/projects/semanticscuttle
*/
class SemanticScuttle_Service_Thumbnails extends SemanticScuttle_Service
{
/**
* Instantiates the configured website thumbnailer object.
*
* @return object Website thumbnailer
*/
public function getThumbnailer()
{
if (!isset($GLOBALS['thumbnailsType'])
|| $GLOBALS['thumbnailsType'] == ''
) {
$class = 'SemanticScuttle_Thumbnailer_Null';
} else {
$class = 'SemanticScuttle_Thumbnailer_'
. ucfirst($GLOBALS['thumbnailsType']);
}
if (!class_exists($class)) {
//PEAR classname to filename rule
$file = str_replace('_', '/', $class) . '.php';
include_once $file;
}
$thumbnailer = new $class();
if (!isset($GLOBALS['thumbnailsConfig'])
|| $GLOBALS['thumbnailsConfig'] == ''
) {
$thumbnailer->setConfig(null);
} else {
$thumbnailer->setConfig($GLOBALS['thumbnailsConfig']);
}
return $thumbnailer;
}
}
?>

View File

@ -1,52 +0,0 @@
<?php
/**
* SemanticScuttle - your social bookmark manager.
*
* PHP version 5.
*
* @category Bookmarking
* @package SemanticScuttle
* @author Christian Weiske <cweiske@cweiske.de>
* @license GPL http://www.gnu.org/licenses/gpl.html
* @link http://sourceforge.net/projects/semanticscuttle
*/
/**
* Dummy thumbnailer that never returns a thumbnail URL
*
* @category Bookmarking
* @package SemanticScuttle
* @author Christian Weiske <cweiske@cweiske.de>
* @license GPL http://www.gnu.org/licenses/gpl.html
* @link http://sourceforge.net/projects/semanticscuttle
*/
class SemanticScuttle_Thumbnailer_Null
{
/**
* Set dummy configuration
*
* @param array $config Dummy configuration
*
* @return void
*/
public function setConfig($config)
{
}
/**
* Get the URL for a website thumbnail.
* Always returns false.
*
* @param string $bookmarkUrl URL of website to create thumbnail for
* @param integer $width Screenshot width
* @param integer $height Screenshot height
*
* @return mixed FALSE when no screenshot could be obtained,
* string with the URL otherwise
*/
public function getThumbnailUrl($bookmarkUrl, $width, $height)
{
return false;
}
}
?>

View File

@ -1,92 +0,0 @@
<?php
/**
* SemanticScuttle - your social bookmark manager.
*
* PHP version 5.
*
* @category Bookmarking
* @package SemanticScuttle
* @author Christian Weiske <cweiske@cweiske.de>
* @license GPL http://www.gnu.org/licenses/gpl.html
* @link http://sourceforge.net/projects/semanticscuttle
*/
/**
* Show website thumbnails/screenshots using phancap
*
* @category Bookmarking
* @package SemanticScuttle
* @author Christian Weiske <cweiske@cweiske.de>
* @license GPL http://www.gnu.org/licenses/gpl.html
* @link http://sourceforge.net/projects/semanticscuttle
* @see http://cweiske.de/phancap.htm
*/
class SemanticScuttle_Thumbnailer_Phancap
{
/**
* Configuration array.
* Required keys:
* - url
* - token
* - secret
*/
protected $config = array();
/**
* Set phancap configuration
*
* @param array $config Phancap configuration
*
* @return void
*/
public function setConfig($config)
{
$this->config = $config;
}
/**
* Get the URL for a website thumbnail
*
* @param string $bookmarkUrl URL of website to create thumbnail for
* @param integer $width Screenshot width
* @param integer $height Screenshot height
*
* @return mixed FALSE when no screenshot could be obtained,
* string with the URL otherwise
*/
public function getThumbnailUrl($bookmarkUrl, $width, $height)
{
//default parameters for the phancap service
$parameters = array(
'url' => $bookmarkUrl,
'swidth' => $width,
'sheight' => $height,
'sformat' => 'jpg',
);
if (isset($this->config['token']) && $this->config['token'] != '') {
$parameters['atoken'] = $this->config['token'];
$parameters['atimestamp'] = time();
//create signature
ksort($parameters);
foreach ($parameters as $key => $value) {
$encparams[] = $key . '=' . rawurlencode($value);
}
$encstring = implode('&', $encparams);
$signature = hash_hmac('sha1', $encstring, $this->config['secret']);
//append signature to parameters
$parameters['asignature'] = $signature;
}
//url-encode the parameters
$urlParams = array();
foreach ($parameters as $key => $value) {
$urlParams[] = $key . '=' . urlencode($value);
}
//final URL
return $this->config['url'] . '?' . implode('&', $urlParams);
}
}
?>

View File

@ -25,29 +25,7 @@ if (isset($GLOBALS['debugMode'])) {
}
// Determine the base URL as ROOT
if (!isset($GLOBALS['root'])) {
$pieces = explode('/', $_SERVER['SCRIPT_NAME']);
$rootTmp = '/';
foreach ($pieces as $piece) {
//we eliminate possible sscuttle subfolders (like gsearch for example)
if ($piece != '' && !strstr($piece, '.php')
&& $piece != 'gsearch' && $piece != 'ajax'
) {
$rootTmp .= $piece .'/';
}
}
if (($rootTmp != '/') && (substr($rootTmp, -1, 1) != '/')) {
$rootTmp .= '/';
}
//we do not prepend http since we also want to support https connections
// "http" is not required; it's automatically determined by the browser
// depending on the current connection.
define('ROOT', '//'. $_SERVER['HTTP_HOST'] . $rootTmp);
} else {
define('ROOT', $GLOBALS['root']);
}
define('ROOT', SemanticScuttle_Environment::getRoot());
define('ROOT_JS', ROOT . 'js/jstree-1.0-rc2/');
// Error codes

View File

@ -281,14 +281,13 @@ class sql_db
if ($query_id)
{
$id = (int) $query_id;
unset($this->rowset[$id]);
unset($this->row[$id]);
unset($this->rowset[$query_id]);
unset($this->row[$query_id]);
$result = array();
while ($this->rowset[$id] = $this->sql_fetchrow($query_id))
while ($this->rowset[$query_id] = $this->sql_fetchrow($query_id))
{
$result[] = $this->rowset[$id];
$result[] = $this->rowset[$query_id];
}
return $result;
}
@ -550,4 +549,4 @@ class sql_db
} // if ... define
?>
?>

View File

@ -14,6 +14,7 @@
* @license GPL http://www.gnu.org/licenses/gpl.html
* @link http://sourceforge.net/projects/semanticscuttle
*/
global $wwwdir, $datadir;
if ('@data_dir@' == '@' . 'data_dir@') {
//non pear-install
@ -29,6 +30,8 @@ require_once dirname(__FILE__) . '/Environment.php';
require_once dirname(__FILE__) . '/Config.php';
$cfg = new SemanticScuttle_Config();
$GLOBALS['cfg'] = $cfg;
list($configfile, $defaultfile) = $cfg->findFiles();
if ($defaultfile === null) {
header('HTTP/1.0 500 Internal Server Error');
@ -48,8 +51,8 @@ set_include_path(
);
// 1 // First requirements part (before debug management)
require_once $defaultfile;
require_once $configfile;
$cfg->load($defaultfile);
$cfg->load($configfile);
if (isset($_GET['unittestMode']) && $_GET['unittestMode'] == 1
) {
@ -87,7 +90,7 @@ require_once 'SemanticScuttle/constants.php';
// Debug Management using constants
if (DEBUG_MODE) {
ini_set('display_errors', '0');
ini_set('display_errors', '1');
ini_set('mysql.trace_mode', '1');
error_reporting(E_ALL);
} else {
@ -106,11 +109,11 @@ require_once 'SemanticScuttle/Model/Bookmark.php';
require_once 'SemanticScuttle/Model/UserArray.php';
require_once 'SemanticScuttle/Model/User/SslClientCert.php';
if (count($GLOBALS['serviceoverrides']) > 0
if (count($cfg['serviceoverrides']) > 0
&& !defined('UNIT_TEST_MODE')
) {
SemanticScuttle_Service_Factory::$serviceoverrides
= $GLOBALS['serviceoverrides'];
= $cfg['serviceoverrides'];
}
// 3 // Third requirements part which import functions from includes/ directory
@ -121,7 +124,7 @@ require_once 'SemanticScuttle/utf8.php';
// Translation
require_once 'php-gettext/gettext.inc';
$domain = 'messages';
T_setlocale(LC_MESSAGES, $locale);
T_setlocale(LC_MESSAGES, $cfg['locale']);
T_bindtextdomain($domain, realpath($datadir . 'locales/'));
T_bind_textdomain_codeset($domain, 'UTF-8');
T_textdomain($domain);
@ -129,15 +132,15 @@ T_textdomain($domain);
// 4 // Session
if (isset($_SERVER['REMOTE_ADDR'])) {
session_start();
if ($GLOBALS['enableVoting']) {
if ($cfg['enableVoting']) {
if (isset($_SESSION['lastUrl'])) {
$GLOBALS['lastUrl'] = $_SESSION['lastUrl'];
$cfg['lastUrl'] = $_SESSION['lastUrl'];
}
//this here is hacky, but currently the only way to
// differentiate between css/js php files and normal
// http files
if (!isset($GLOBALS['saveInLastUrl'])
|| $GLOBALS['saveInLastUrl']
if (!isset($cfg['saveInLastUrl'])
|| $cfg['saveInLastUrl']
) {
$_SESSION['lastUrl'] = $_SERVER['REQUEST_URI'];
}
@ -171,29 +174,4 @@ if (!defined('UNIT_TEST_MODE') || defined('HTTP_UNIT_TEST_MODE')) {
header('Content-Type: ' . $httpContentType . '; charset=utf-8');
}
}
// 7 // Block everything if global private mode enabled and user not logged on
// This is required to prevent breaking the API. Some API PHP source files include httpauth.inc.php
// which already check if the user is logged on and include www-header.php.
// We also allow password.php so users can reset their password and login.php so they can log in.
if (isset($GLOBALS['privatemode'])) {
if ($GLOBALS['privatemode'] && ! $userservice->isLoggedOn()) {
$flag = 1;
$included_files = get_included_files();
foreach ($included_files as $filename) {
if (strpos($filename,'httpauth.inc.php') !== false || strpos($filename,'password.php') !== false || strpos($filename,'login.php') !== false) {
$flag = 0;
break;
}
}
if ($flag) {
$tplVars['error'] = T_('You must log in.');
$tplVars['subtitle'] = T_('Log In');
$tplVars['formaction'] = createURL('login');
$tplVars['querystring'] = filter($_SERVER['QUERY_STRING']);
$templateservice->loadTemplate('login.tpl', $tplVars);
die();
}
}
}
?>

View File

@ -1,149 +0,0 @@
<?php
/***************************************************************************
The MIT License (MIT)
Copyright (c) 2015 kafene
https://github.com/kafene/netscape-bookmark-parser
http://kafene.org
Slightly modified by yohan.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
***************************************************************************/
/**
* Basically netscape bookmark files often come so badly formed, there's
* no reliable way I could find to parse them with DOM or SimpleXML,
* even after running HTML Tidy on them. So, this function does a bunch of
* transformations on the general format of a netscape bookmark file, to get
* Each bookmark and its description onto one line, and goes through line by
* line, matching tags and attributes. It's messy, but it works better than
* anything I could find in hours of googling, and anything that I could
* write after hours with DOM and SimpleXML. I didn't want to pull in a big
* DOM parsing library just to do this one thing, so this is it.
*/
/*
print '<PRE>';
var_dump(parse_netscape_bookmarks(file_get_contents('bookmarks_export.htm')));
*/
function parse_netscape_bookmarks($bkmk_str, $default_tag = null) {
$i = 0;
$next = false;
$items = [];
$current_tag = $default_tag = $default_tag ?: 'autoimported-'.date("Ymd");
$bkmk_str = str_replace(["\r","\n","\t"], ['','',' '], $bkmk_str);
$bkmk_str = preg_replace_callback('@<dd>(.*?)(<A|<\/|<DL|<DT|<P)@mis', function($m) {
return '<dd>'.str_replace(["\r", "\n"], ['', '<br>'], trim($m[1])).'</';
}, $bkmk_str);
$bkmk_str = preg_replace('/>(\s*?)</mis', ">\n<", $bkmk_str);
$bkmk_str = preg_replace('/(<!DOCTYPE|<META|<!--|<TITLE|<H1|<P)(.*?)\n/i', '', $bkmk_str);
$bkmk_str = trim($bkmk_str);
$bkmk_str = preg_replace('/\n<dd/i', '<dd', $bkmk_str);
//best way to do it :
$bkmk_str = preg_replace('/(?<=.)<\/DL>/', "\n</DL>", $bkmk_str);
$lines = explode("\n", $bkmk_str);
$str_bool = function($str, $default = false) {
if (!$str) {
return false;
} elseif (!is_string($str) && $str) {
return true;
}
$true = 'y|yes|on|checked|ok|1|true|array|\+|okay|yes+|t|one';
$false = 'n|no|off|empty|null|false|0|-|exit|die|neg|f|zero|void';
if (preg_match("/^($true)$/i", $str)) {
return true;
} elseif (preg_match("/^($false)$/i", $str)) {
return false;
}
return $default;
};
$tags = array($default_tag);
foreach ($lines as $line_no => $line) {
/* If we match a tag, set current tag to that, if <DL>, stop tag. */
if (preg_match('/^<h\d(.*?)>(.*?)<\/h\d>/i', $line, $m1)) {
$current_tag = trim(preg_replace("/\s+/", "_", strtr($m1[2], ', /+', '____')));
$tags[] = $current_tag;
continue;
} elseif (preg_match('/^<\/DL>/i', $line)) {
$current_tag = $default_tag;
array_pop($tags);
}
if (preg_match('/<a/i', $line, $m2)) {
$items[$i]['tags'] = $tags;
if (preg_match('/href="(.*?)"/i', $line, $m3)) {
$items[$i]['uri'] = $m3[1];
// $items[$i]['meta'] = meta($m3[1]);
} else {
$items[$i]['uri'] = '';
// $items[$i]['meta'] = '';
}
if (preg_match('/<a(.*?)>(.*?)<\/a>/i', $line, $m4)) {
$items[$i]['title'] = $m4[2];
// $items[$i]['slug'] = slugify($m4[2]);
} else {
$items[$i]['title'] = 'untitled';
// $items[$i]['slug'] = '';
}
if (preg_match('/note="(.*?)"<\/a>/i', $line, $m5)) {
$items[$i]['note'] = $m5[1];
} elseif (preg_match('/<dd>(.*?)<\//i', $line, $m6)) {
$items[$i]['note'] = str_replace('<br>', "\n", $m6[1]);
} else {
$items[$i]['note'] = '';
}
if (preg_match('/(tags?|labels?|folders?)="(.*?)"/i', $line, $m7)) {
array_unique(array_merge($items[$i]['tags'], explode(' ', trim(preg_replace("/\s+/", " ", strtr($m7[2], ',', ' '))))));
}
if (preg_match('/add_date="(.*?)"/i', $line, $m8)) {
$items[$i]['time'] = $m8[1];
} else {
$items[$i]['time'] = time();
}
if (preg_match('/(public|published|pub)="(.*?)"/i', $line, $m9)) {
$items[$i]['pub'] = $str_bool($m9[2], false) ? 1 : 0;
} elseif (preg_match('/(private|shared)="(.*?)"/i', $line, $m10)) {
$items[$i]['pub'] = $str_bool($m10[2], true) ? 0 : 1;
}
$i++;
}
}
ksort($items);
return $items;
}
?>

View File

@ -42,7 +42,7 @@ class SemanticScuttle_ConfigTest extends PHPUnit_Framework_TestCase
'SemanticScuttle_Config',
array('getDataDir')
);
$this->cfg->expects($this->once())
$this->cfg->expects($this->any())
->method('getDataDir')
->will($this->returnValue('/data-dir/'));

View File

@ -229,6 +229,175 @@ class SemanticScuttle_EnvironmentTest extends PHPUnit_Framework_TestCase
'/dummy/foo', SemanticScuttle_Environment::getServerPathInfo()
);
}
public function testGetServerPathInfoPharPurePhpFile()
{
$_SERVER = array(
'SERVER_NAME' => 'dist.bm.bogo',
'SERVER_ADDR' => '127.0.0.1',
'SERVER_PORT' => '80',
'DOCUMENT_ROOT' => '/etc/apache2/htdocs',
'SCRIPT_FILENAME' => '/home/cweiske/Dev/html/hosts/dist.bm.bogo/SemanticScuttle-0.98.X.phar',
'QUERY_STRING' => '',
'REQUEST_URI' => '/SemanticScuttle-0.98.X.phar/www/populartags.php',
'SCRIPT_NAME' => 'www/populartags.php',
'PATH_INFO' => '/www/populartags.php',
'PATH_TRANSLATED' => 'phar:///home/cweiske/Dev/semanticscuttle/cwdev/dist/SemanticScuttle-0.98.X.phar/www/populartags.php',
'PHP_SELF' => '/SemanticScuttle-0.98.X.phar/www/populartags.php',
'PHAR_PATH_TRANSLATED' => '/home/cweiske/Dev/html/hosts/dist.bm.bogo/www/populartags.php',
);
$this->assertNull(
SemanticScuttle_Environment::getServerPathInfo()
);
}
public function testGetServerPathInfoPharCleanUrl()
{
$_SERVER = array(
'HTTP_HOST' => 'dist.bm.bogo',
'SERVER_NAME' => 'dist.bm.bogo',
'SERVER_ADDR' => '127.0.0.1',
'SERVER_PORT' => '80',
'DOCUMENT_ROOT' => '/etc/apache2/htdocs' ,
'SCRIPT_FILENAME' => '/home/cweiske/Dev/html/hosts/dist.bm.bogo/SemanticScuttle-0.98.X.phar' ,
'QUERY_STRING' => '',
'REQUEST_URI' => '/SemanticScuttle-0.98.X.phar/populartags',
'SCRIPT_NAME' => 'populartags.php',
'PATH_INFO' => '/populartags',
'PATH_TRANSLATED' => 'phar:///home/cweiske/Dev/semanticscuttle/cwdev/dist/SemanticScuttle-0.98.X.phar/www/populartags.php',
'PHP_SELF' => '/SemanticScuttle-0.98.X.phar/populartags',
'PHAR_PATH_TRANSLATED' => '/home/cweiske/Dev/html/hosts/dist.bm.bogo/populartags',
);
$this->assertNull(
SemanticScuttle_Environment::getServerPathInfo()
);
}
public function testGetServerPathInfoPharWithInfo()
{
$_SERVER = array(
'PATH' => '/usr/local/bin:/usr/bin:/bin',
'SERVER_NAME' => 'dist.bm.bogo',
'DOCUMENT_ROOT' => '/etc/apache2/htdocs',
'SCRIPT_FILENAME' => '/home/cweiske/Dev/html/hosts/dist.bm.bogo/SemanticScuttle-0.98.X.phar',
'QUERY_STRING' => '',
'REQUEST_URI' => '/SemanticScuttle-0.98.X.phar/www/populartags.php/foo/bar',
'SCRIPT_NAME' => 'www/populartags.php',
'PATH_INFO' => '/foo/bar',
'PATH_TRANSLATED' => 'phar:///home/cweiske/Dev/semanticscuttle/cwdev/dist/SemanticScuttle-0.98.X.phar/www/populartags.php',
'PHP_SELF' => '/SemanticScuttle-0.98.X.phar/www/populartags.php/foo/bar',
'PHAR_PATH_INFO' => '/www/populartags.php/foo/bar',
'PHAR_PATH_TRANSLATED' => '/home/cweiske/Dev/html/hosts/dist.bm.bogo/www/populartags.php/foo/bar',
);
$this->assertEquals(
'/foo/bar', SemanticScuttle_Environment::getServerPathInfo()
);
}
public function testGetServerPathInfoPharWithInfoWithoutWww()
{
$_SERVER = array(
'PATH' => '/usr/local/bin:/usr/bin:/bin',
'SERVER_NAME' => 'dist.bm.bogo',
'DOCUMENT_ROOT' => '/etc/apache2/htdocs',
'SCRIPT_FILENAME' => '/home/cweiske/Dev/html/hosts/dist.bm.bogo/SemanticScuttle-0.98.X.phar',
'QUERY_STRING' => '',
'REQUEST_URI' => '/SemanticScuttle-0.98.X.phar/tags.php/test',
'SCRIPT_NAME' => 'tags.php',
'PATH_INFO' => '/tags.php/test',
'PATH_TRANSLATED' => 'phar:///home/cweiske/Dev/semanticscuttle/cwdev/dist/SemanticScuttle-0.98.X.phar/www/tags.php',
'PHP_SELF' => '/SemanticScuttle-0.98.X.phar/tags.php/test',
'PHAR_PATH_TRANSLATED' => '/home/cweiske/Dev/html/hosts/dist.bm.bogo/tags.php/test',
);
$this->assertEquals(
'/test', SemanticScuttle_Environment::getServerPathInfo()
);
}
public function testGetRootWithConfigPreset()
{
$GLOBALS['root'] = 'https://happy.penguin.example.org/walks/away/';
$this->assertEquals(
'https://happy.penguin.example.org/walks/away/',
SemanticScuttle_Environment::getRoot()
);
}
public function testGetRootInRootDir()
{
$_SERVER = array(
'HTTP_HOST' => 'bm.bogo',
'DOCUMENT_ROOT' => '/etc/apache2/htdocs',
'SCRIPT_FILENAME' => '/home/cweiske/Dev/html/hosts/bm.bogo/index.php',
'QUERY_STRING' => '',
'REQUEST_URI' => '/',
'SCRIPT_NAME' => '/index.php',
'PHP_SELF' => '/index.php',
);
$this->assertEquals(
'//bm.bogo/',
SemanticScuttle_Environment::getRoot()
);
}
public function testGetRootInSubdir()
{
$_SERVER = array(
'HTTP_HOST' => 'bm-subdir.bogo',
'DOCUMENT_ROOT' => '/etc/apache2/htdocs',
'SCRIPT_FILENAME' => '/home/cweiske/Dev/html/hosts/bm-subdir.bogo/tools/scuttle/index.php',
'QUERY_STRING' => '',
'REQUEST_URI' => '/tools/scuttle/',
'SCRIPT_NAME' => '/tools/scuttle/index.php',
'PHP_SELF' => '/tools/scuttle/index.php',
);
$this->assertEquals(
'//bm-subdir.bogo/tools/scuttle/',
SemanticScuttle_Environment::getRoot()
);
}
public function testGetRootFromPharIndex()
{
$_SERVER = array(
'HTTP_HOST' => 'dist.bm.bogo',
'DOCUMENT_ROOT' => '/etc/apache2/htdocs',
'SCRIPT_FILENAME' => '/home/cweiske/Dev/html/hosts/dist.bm.bogo/SemanticScuttle-0.98.X.phar',
'QUERY_STRING' => '',
'REQUEST_URI' => '/SemanticScuttle-0.98.X.phar/www/index.php',
'SCRIPT_NAME' => '/SemanticScuttle-0.98.X.phar',
'PATH_INFO' => '/www/index.php',
'PATH_TRANSLATED' => 'phar:///home/cweiske/Dev/semanticscuttle/cwdev/dist/SemanticScuttle-0.98.X.phar/www/index.php',
'PHP_SELF' => '/SemanticScuttle-0.98.X.phar/www/index.php',
'PHAR_PATH_TRANSLATED' => '/home/cweiske/Dev/html/hosts/dist.bm.bogo/www/index.php',
);
$this->assertEquals(
'//dist.bm.bogo/SemanticScuttle-0.98.X.phar/',
SemanticScuttle_Environment::getRoot()
);
}
public function testGetRootFromPharWithSubpath()
{
$_SERVER = array(
'HTTP_HOST' => 'dist.bm.bogo',
'DOCUMENT_ROOT' => '/etc/apache2/htdocs',
'SCRIPT_FILENAME' => '/home/cweiske/Dev/html/hosts/dist.bm.bogo/SemanticScuttle-0.98.X.phar',
'QUERY_STRING' => 'no value',
'REQUEST_URI' => '/SemanticScuttle-0.98.X.phar/www/index.php/foo/bar/',
'SCRIPT_NAME' => '/SemanticScuttle-0.98.X.phar',
'PATH_INFO' => '/foo/bar/',
'PATH_TRANSLATED' => 'phar:///home/cweiske/Dev/semanticscuttle/cwdev/dist/SemanticScuttle-0.98.X.phar/www/index.php',
'PHP_SELF' => '/SemanticScuttle-0.98.X.phar/www/index.php/foo/bar/',
'REQUEST_TIME' => '1313425297',
'PHAR_PATH_INFO' => '/www/index.php/foo/bar/',
'PHAR_PATH_TRANSLATED' => '/home/cweiske/Dev/html/hosts/dist.bm.bogo/www/index.php/foo/bar/',
);
$this->assertEquals(
'//dist.bm.bogo/SemanticScuttle-0.98.X.phar/',
SemanticScuttle_Environment::getRoot()
);
}
}
?>

View File

@ -22,7 +22,6 @@ require_once 'www-header.php';
$tplVars['pagetitle'] = T_('About');
$tplVars['subtitle'] = T_('About');
$tplVars['loadjs'] = true;
$templateservice->loadTemplate('about.tpl', $tplVars);
?>
?>

View File

@ -1,33 +0,0 @@
<?php
require_once '../www-header.php';
if(isset($_POST['password']) && $userservice->isLoggedOn()){
$password = $userservice->sanitisePassword($_POST['password']);
$username = $currentUser->getUsername();
$db = SemanticScuttle_Service_Factory::getDb();
$query = 'SELECT '. $userservice->getFieldName('primary') .' FROM '. $userservice->getTableName() .' WHERE '. $userservice->getFieldName('username') .' = "'. $db->sql_escape($username) .'" AND '. $userservice->getFieldName('password') .' = "'. $db->sql_escape($password) .'"';
if (!($dbresult = $db->sql_query($query))) {
message_die(
GENERAL_ERROR,
'Could not get user',
'', __LINE__, __FILE__, $query, $db
);
echo 'false';
}
else {
$row = $db->sql_fetchrow($dbresult);
$db->sql_freeresult($dbresult);
if ($row) {
echo 'true';
}
else {
echo 'false';
}
}
}
else {
echo 'false';
}
?>

View File

@ -20,7 +20,7 @@
*/
$httpContentType = 'application/json';
require_once '../www-header.php';
require_once __DIR__ . '/../www-header.php';
/**
* Creates and returns an array of tags for the jsTree ajax loader.

View File

@ -22,7 +22,7 @@
*/
$httpContentType = 'application/json';
require_once '../www-header.php';
require_once __DIR__ . '/../www-header.php';
$limit = 30;
$beginsWith = null;

View File

@ -22,7 +22,7 @@
*/
$httpContentType = 'application/json';
require_once '../www-header.php';
require_once __DIR__ . '/../www-header.php';
$limit = 30;
$beginsWith = null;

View File

@ -25,7 +25,7 @@
* @link http://sourceforge.net/projects/semanticscuttle
*/
$httpContentType = 'application/json';
require_once '../www-header.php';
require_once __DIR__ . '/../www-header.php';
$tag = isset($_GET['tag']) ? $_GET['tag'] : null;
$uId = isset($_GET['uId']) ? (int)$_GET['uId'] : 0;
@ -138,4 +138,4 @@ $tagData = assembleLinkedTagData(
SemanticScuttle_Service_Factory::get('Tag2Tag')
);
echo json_encode($tagData);
?>
?>

View File

@ -21,7 +21,7 @@ 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*/
$httpContentType = 'application/json';
require_once '../www-header.php';
require_once __DIR__ . '/../www-header.php';
/* Service creation: only useful services are created */
$b2tservice =SemanticScuttle_Service_Factory::get('Bookmark2Tag');

View File

@ -72,6 +72,7 @@ if (isset($userid)) {
} else {
$tplVars['cat_url'] = createURL('tags', '%2$s');
}
$tplVars['sidebar_blocks'] = array('linked');
$tplVars['userid'] = $userid;
$tplVars['loadjs'] = true;

View File

@ -6,7 +6,7 @@
// Force HTTP authentication first!
//require_once('httpauth.inc.php');
$httpContentType = false;
require_once '../www-header.php';
require_once __DIR__ . '/../www-header.php';
if($GLOBALS['enableGoogleCustomSearch'] == false) {
echo "Google Custom Search disabled. You can enable it into the config.php file.";

View File

@ -2,7 +2,7 @@
/* Export data with semantic format (SIOC: http://sioc-project.org/, FOAF, SKOS, Annotea Ontology) */
$httpContentType = 'text/xml';
require_once '../www-header.php';
require_once __DIR__ . '/../www-header.php';
/* Service creation: only useful services are created */
$userservice =SemanticScuttle_Service_Factory::get('User');

View File

@ -17,7 +17,7 @@
* @license GPL http://www.gnu.org/licenses/gpl.html
* @link http://sourceforge.net/projects/semanticscuttle
*/
require_once '../www-header.php';
require_once __DIR__ . '/../www-header.php';
/**
* Sends HTTP auth headers to the browser

View File

@ -1,6 +1,6 @@
<?php
$httpContentType = 'text/xml';
require_once '../www-header.php';
require_once __DIR__ . '/../www-header.php';
echo '<' . '?xml version="1.0" encoding="utf-8" ?' . ">\n";
?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">

View File

@ -4,9 +4,6 @@
// del.icio.us behavior:
// - doesn't include the filtered tag as an attribute on the root element (we do)
// Scuttle behavior:
// - returns privacy status of each bookmark.
// Force HTTP authentication first!
$httpContentType = 'text/xml';
require_once 'httpauth.inc.php';
@ -43,8 +40,8 @@ foreach($bookmarks['bookmarks'] as $row) {
$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'])) . '" status="'. filter($row['bStatus'], 'xml') ."\" />\r\n";
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 '</posts>';
?>
?>

View File

@ -10,7 +10,6 @@
*
* Scuttle behavior:
* - Uses today, instead of the last bookmarked date, if no date is specified
* - returns privacy status of each bookmark.
*
* SemanticScuttle - your social bookmark manager.
*
@ -76,8 +75,8 @@ 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'])) . '" status="'. filter($row['bStatus'], 'xml') ."\" />\r\n";
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 '</posts>';
?>
?>

View File

@ -4,13 +4,10 @@
// del.icio.us behavior:
// - doesn't include the filtered tag as an attribute on the root element (we do)
// Scuttle behavior:
// - returns privacy status of each bookmark.
// Force HTTP authentication first!
//require_once('httpauth.inc.php');
$httpContentType = 'text/xml';
require_once '../www-header.php';
require_once __DIR__ . '/../www-header.php';
/* Service creation: only useful services are created */
$bookmarkservice =SemanticScuttle_Service_Factory::get('Bookmark');
@ -44,7 +41,7 @@ foreach($bookmarks['bookmarks'] as $row) {
$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'])) . '" status="'. filter($row['bStatus'], 'xml') ."\" />\r\n";
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 '</posts>';

View File

@ -4,9 +4,6 @@
* optionally filtered by tag and/or number of posts
* (default 15, max 100, just like del.icio.us).
*
* Scuttle behavior:
* - returns privacy status of each bookmark.
*
* SemanticScuttle - your social bookmark manager.
*
* PHP version 5.
@ -78,8 +75,8 @@ 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'])) . '" status="'. filter($row['bStatus'], 'xml') ."\" />\r\n";
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 '</posts>';
?>
?>

View File

@ -9,11 +9,6 @@
* that too, so we are as close at the API as possible,
* not breaking delicious clients.
*
* SemanticScuttle supports an extra parameter:
* - ?datemode=modified
* - sorts by modified date and returns modification time
* instead of creation time
*
* SemanticScuttle - your social bookmark manager.
*
* PHP version 5.
@ -32,27 +27,18 @@
$httpContentType = 'text/xml';
require_once 'httpauth.inc.php';
// parameter "datemode=modified" will get last modified date
// instead of last created date
$orderby = null;
$timeField = 'bDatetime';
if (isset($_GET['datemode']) && $_GET['datemode'] == 'modified') {
$orderby = 'modified_desc';
$timeField = 'bModified';
}
$bs = SemanticScuttle_Service_Factory::get('Bookmark');
$bookmarks = $bs->getBookmarks(0, 1, $userservice->getCurrentUserId(), null, null, $orderby);
$bookmarks = $bs->getBookmarks(0, 1, $userservice->getCurrentUserId());
// Set up the XML file and output all the tags.
echo '<?xml version="1.0" standalone="yes" ?' . ">\r\n";
//foreach is used in case there are no bookmarks
foreach ($bookmarks['bookmarks'] as $row) {
echo '<update time="'
. gmdate('Y-m-d\TH:i:s\Z', strtotime($row[$timeField]))
. gmdate('Y-m-d\TH:i:s\Z', strtotime($row['bDatetime']))
. '"'
. ' inboxnew="0"'
. ' />';
}
?>
?>

View File

@ -29,21 +29,15 @@ $cacheservice =SemanticScuttle_Service_Factory::get('Cache');
isset($_GET['action']) ? define('GET_ACTION', $_GET['action']): define('GET_ACTION', '');
isset($_POST['submitted']) ? define('POST_SUBMITTED', $_POST['submitted']): define('POST_SUBMITTED', '');
// define does not support arrays before PHP version 7
isset($_GET['title']) ? $TITLE = $_GET['title']: $TITLE = array();
//isset($_GET['title']) ? define('GET_TITLE', $_GET['title']): define('GET_TITLE', '');
isset($_GET['address']) ? $ADDRESS = $_GET['address']: $ADDRESS = array();
//isset($_GET['address']) ? define('GET_ADDRESS', $_GET['address']): define('GET_ADDRESS', '');
isset($_GET['title']) ? define('GET_TITLE', $_GET['title']): define('GET_TITLE', '');
isset($_GET['address']) ? define('GET_ADDRESS', $_GET['address']): define('GET_ADDRESS', '');
isset($_GET['description']) ? define('GET_DESCRIPTION', $_GET['description']): define('GET_DESCRIPTION', '');
isset($_GET['privateNote']) ? define('GET_PRIVATENOTE', $_GET['privateNote']): define('GET_PRIVATENOTE', '');
isset($_GET['tags']) ? define('GET_TAGS', $_GET['tags']): define('GET_TAGS', '');
isset($_GET['copyOf']) ? define('GET_COPYOF', $_GET['copyOf']): define('GET_COPYOF', '');
// define does not support arrays before PHP version 7
isset($_POST['title']) ? $TITLE = $_POST['title']: $TITLE = array();
//isset($_POST['title']) ? define('POST_TITLE', $_POST['title']): define('POST_TITLE', '');
isset($_POST['address']) ? $ADDRESS = $_POST['address']: $ADDRESS = array();
//isset($_POST['address']) ? define('POST_ADDRESS', $_POST['address']): define('POST_ADDRESS', '');
isset($_POST['title']) ? define('POST_TITLE', $_POST['title']): define('POST_TITLE', '');
isset($_POST['address']) ? define('POST_ADDRESS', $_POST['address']): define('POST_ADDRESS', '');
isset($_POST['description']) ? define('POST_DESCRIPTION', $_POST['description']): define('POST_DESCRIPTION', '');
isset($_POST['privateNote']) ? define('POST_PRIVATENOTE', $_POST['privateNote']): define('POST_PRIVATENOTE', '');
isset($_POST['status']) ? define('POST_STATUS', $_POST['status']): define('POST_STATUS', '');
@ -54,22 +48,12 @@ isset($_POST['popup']) ? define('POST_POPUP', $_POST['popup']): define('POST_POP
isset($_GET['page']) ? define('GET_PAGE', $_GET['page']): define('GET_PAGE', 0);
isset($_GET['sort']) ? define('GET_SORT', $_GET['sort']): define('GET_SORT', '');
isset($_GET['batch']) ? define('GET_BATCH', $_GET['batch']): define('GET_BATCH', 0);
if (!isset($_POST['tags'])) {
$_POST['tags'] = array();
}
if (!isset($_POST['removetags'])) {
$_POST['removetags'] = array();
}
//echo '<p>' . var_export($_POST, true) . '</p>';die();
if (! is_array($ADDRESS)) {
$ADDRESS = array($ADDRESS);
}
if (! is_array($TITLE)) {
$TITLE = array($TITLE);
}
if ((GET_ACTION == "add") && !$userservice->isLoggedOn()) {
$loginqry = str_replace("'", '%27', stripslashes($_SERVER['QUERY_STRING']));
@ -146,119 +130,71 @@ $tplVars['loadjs'] = true;
$saved = false;
$templatename = 'bookmarks.tpl';
if ($userservice->isLoggedOn() && POST_SUBMITTED != '') {
if (!$TITLE || !$ADDRESS) {
if (!POST_TITLE || !POST_ADDRESS) {
$tplVars['error'] = T_('Your bookmark must have a title and an address');
$templatename = 'editbookmark.tpl';
}
else {
$address = array_map('trim', $ADDRESS);
$valid = 1;
foreach($address as $value) {
if (!SemanticScuttle_Model_Bookmark::isValidUrl($value)) {
$tplVars['error'] = T_('This bookmark URL may not be added' + $value);
$templatename = 'editbookmark.tpl';
$valid = 0;
break;
}
}
if ($valid) {
$title = array_map('trim', $TITLE);
$description = trim(POST_DESCRIPTION);
$privateNote = trim(POST_PRIVATENOTE);
$status = intval(POST_STATUS);
$categories = array_map('trim', explode(',', trim($_POST['tags'])));
$removecategories = array_map('trim', explode(',', trim($_POST['removetags'])));
$saved = true;
foreach($address as $index => $value) {
if ($bookmarkservice->bookmarkExists($value, $currentUserID)) {
// If the bookmark exists already, edit the original
$bookmark = $bookmarkservice->getBookmarkByAddress($value);
$bId = intval($bookmark['bId']);
$row = $bookmarkservice->getBookmark($bId, true);
$categories = array_unique(array_merge($row['tags'], $categories));
// remove tags
$categories = array_diff($categories, $removecategories);
if (!$bookmarkservice->updateBookmark($bId, $value, $title[$index], $description, $privateNote, $status, $categories)) {
$tplvars['error'] = T_('Error while saving this bookmark : ' + $value);
$templatename = 'editbookmark.tpl';
$saved = false;
break;
}
}
// If it's new, save it
elseif (!$bookmarkservice->addBookmark($value, $title[$index], $description, $privateNote, $status, $categories)) {
$tplVars['error'] = T_('There was an error saving this bookmark : ' + $value + ' Please try again or contact the administrator.');
$templatename = 'editbookmark.tpl';
$saved = false;
break;
}
}
if ($saved) {
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>';
}
}
}
} else {
$address = trim(POST_ADDRESS);
if (!SemanticScuttle_Model_Bookmark::isValidUrl($address)) {
$tplVars['error'] = T_('This bookmark URL may not be added');
$templatename = 'editbookmark.tpl';
} else if ($bookmarkservice->bookmarkExists($address, $currentUserID)) {
// If the bookmark exists already, edit the original
$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 = explode(',', $_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" || GET_BATCH) {
if (GET_ACTION == "add") {
// If the bookmark exists already, edit the original
if (count($ADDRESS) === 1) {
if ($bookmarkservice->bookmarkExists(stripslashes($ADDRESS[0]), $currentUserID)) {
$bookmark =& $bookmarkservice->getBookmarks(0, NULL, $currentUserID, NULL, NULL, NULL, NULL, NULL, NULL, $bookmarkservice->getHash(stripslashes($ADDRESS[0])));
$popup = (GET_POPUP!='') ? '?popup=1' : '';
header('Location: '. createURL('edit', $bookmark['bookmarks'][0]['bId'] . $popup));
exit();
}
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') { // Prepare to display the edit bookmark page.
if ($templatename == 'editbookmark.tpl') {
if ($userservice->isLoggedOn()) {
$tplVars['formaction'] = createURL('bookmarks', $currentUsername);
if (POST_SUBMITTED != '') {
$tplVars['row'] = array(
'bTitle' => array_map('stripslashes', $TITLE),
'bAddress' => array_map('stripslashes', $ADDRESS),
'bDescription' => stripslashes(POST_DESCRIPTION),
'bPrivateNote' => stripslashes(POST_PRIVATENOTE),
'tags' => ($_POST['tags'] ? $_POST['tags'] : array()),
'bTitle' => stripslashes(POST_TITLE),
'bAddress' => stripslashes(POST_ADDRESS),
'bDescription' => stripslashes(POST_DESCRIPTION),
'bPrivateNote' => stripslashes(POST_PRIVATENOTE),
'tags' => ($_POST['tags'] ? $_POST['tags'] : array()),
'bStatus' => $GLOBALS['defaults']['privacy'],
);
$tplVars['tags'] = $_POST['tags'];
}
elseif (GET_BATCH) {
$completebookmarks = $bookmarkservice->getBookmarks(0, null, $userid, $cat, null, getSortOrder());
$addresses2 = array();
$titles2 = array();
$tags2 = array();
foreach ($completebookmarks['bookmarks'] as $key => &$row) {
$addresses2[$row['bId']] = $row['bAddress'];
$titles2[$row['bId']] = $row['bTitle'];
$row = $bookmarkservice->getBookmark($row['bId'], true);
$tags2[] = $row['tags'];
}
$alltags2 = array_unique(call_user_func_array('array_merge', $tags2));
$commontags2 = call_user_func_array('array_intersect', $tags2);
$tplVars['row'] = array(
'bTitle' => $titles2,
'bAddress' => $addresses2,
'bDescription' => '',
'bPrivateNote' => '',
'tags' => array(),
'bStatus' => $GLOBALS['defaults']['privacy']
);
$tplVars['batch'] = '1';
$tplVars['alltags'] = implode(', ', $alltags2);
$tplVars['commontags'] = implode(', ', $commontags2);
}
else {
} else {
if(GET_COPYOF != '') { //copy from bookmarks page
$tplVars['row'] = $bookmarkservice->getBookmark(intval(GET_COPYOF), true);
if(!$currentUser->isAdmin()) {
@ -266,12 +202,12 @@ if ($templatename == 'editbookmark.tpl') { // Prepare to display the edit bookma
}
}else { //copy from pop-up bookmarklet
$tplVars['row'] = array(
'bTitle' => array_map('stripslashes', $TITLE),
'bAddress' => array_map('stripslashes', $ADDRESS),
'bDescription' => stripslashes(GET_DESCRIPTION),
'bPrivateNote' => stripslashes(GET_PRIVATENOTE),
'tags' => (GET_TAGS ? explode(',', stripslashes(GET_TAGS)) : array()),
'bStatus' => $GLOBALS['defaults']['privacy']
'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' => $GLOBALS['defaults']['privacy']
);
}
@ -293,46 +229,20 @@ if ($templatename == 'editbookmark.tpl') { // Prepare to display the edit bookma
$tplVars['sidebar_blocks'] = array('watchstatus');
if (!$cat) { //user page without tags
$rssTitle = "My Bookmarks";
$rssTitle = "My Bookmarks";
$cat = NULL;
$tplVars['currenttag'] = NULL;
//$tplVars['sidebar_blocks'][] = 'menu2';
$tplVars['sidebar_blocks'][] = 'linked';
$tplVars['sidebar_blocks'][] = 'popular';
} else { //pages with tags
$rssTitle = "Tags" . $catTitle;
$rssTitle = "Tags" . $catTitle;
$rssCat = '/'. filter($cat, 'url');
$tplVars['currenttag'] = $cat;
$tplVars['sidebar_blocks'][] = 'tagactions';
//$tplVars['sidebar_blocks'][] = 'menu2';
if (! empty($GLOBALS['shoulderSurfingProtectedTag']) && ! isset($_COOKIE["noshoulderSurfingProtection"])) {
$tag2tagservice = SemanticScuttle_Service_Factory::get('Tag2Tag');
$b2tservice = SemanticScuttle_Service_Factory::get('Bookmark2Tag');
$alltags = $b2tservice->getTags($currentUserID);
$shoulderSurfingProtectedTags = $tag2tagservice->getAllLinkedTags($GLOBALS['shoulderSurfingProtectedTag'], '>', $currentUserID, array());
$shoulderSurfingProtectedTags[] = $GLOBALS['shoulderSurfingProtectedTag'];
$flag = 0;
if (! in_array($cat, $shoulderSurfingProtectedTags, true)) {
foreach ($alltags as $tag) {
if ($tag['tag'] === $cat) {
$flag = 1;
break;
}
}
}
if ($flag) {
$tplVars['sidebar_blocks'][] = 'tagactions';
$tplVars['sidebar_blocks'][] = 'linked';
$tplVars['sidebar_blocks'][] = 'related';
}
}
else {
$tplVars['sidebar_blocks'][] = 'tagactions';
$tplVars['sidebar_blocks'][] = 'linked';
$tplVars['sidebar_blocks'][] = 'related';
}
$tplVars['sidebar_blocks'][] = 'linked';
$tplVars['sidebar_blocks'][] = 'related';
/*$tplVars['sidebar_blocks'][] = 'menu';*/
}
$tplVars['sidebar_blocks'][] = 'menu2';
@ -363,24 +273,24 @@ if ($templatename == 'editbookmark.tpl') { // Prepare to display the edit bookma
)
);
if ($userservice->isLoggedOn()) {
$currentUsername = $currentUser->getUsername();
if ($userservice->isPrivateKeyValid($currentUser->getPrivateKey())) {
array_push(
$tplVars['rsschannels'],
array(
sprintf(
T_('%s: %s (+private %s)'),
$sitename, $rssTitle, $currentUsername
),
createURL('rss', filter($currentUsername, 'url'))
. $rssCat
. '?sort=' . getSortOrder()
. '&privateKey=' . $currentUser->getPrivateKey()
)
);
}
if ($userservice->isLoggedOn()) {
$currentUsername = $currentUser->getUsername();
if ($userservice->isPrivateKeyValid($currentUser->getPrivateKey())) {
array_push(
$tplVars['rsschannels'],
array(
sprintf(
T_('%s: %s (+private %s)'),
$sitename, $rssTitle, $currentUsername
),
createURL('rss', filter($currentUsername, 'url'))
. $rssCat
. '?sort=' . getSortOrder()
. '&privateKey=' . $currentUser->getPrivateKey()
)
);
}
}
$tplVars['page'] = $page;
$tplVars['start'] = $start;

View File

@ -29,12 +29,8 @@ $bookmarkservice = SemanticScuttle_Service_Factory :: get('Bookmark');
isset($_POST['submitted']) ? define('POST_SUBMITTED', $_POST['submitted']): define('POST_SUBMITTED', '');
isset($_POST['delete']) ? define('POST_DELETE', $_POST['delete']): define('POST_DELETE', '');
// define does not support arrays before PHP version 7
isset($_POST['title']) ? $TITLE = $_POST['title']: $TITLE = array();
//isset($_POST['title']) ? define('POST_TITLE', $_POST['title']): define('POST_TITLE', '');
isset($_POST['address']) ? $ADDRESS = $_POST['address']: $ADDRESS = array();
//isset($_POST['address']) ? define('POST_ADDRESS', $_POST['address']): define('POST_ADDRESS', '');
isset($_POST['title']) ? define('POST_TITLE', $_POST['title']): define('POST_TITLE', '');
isset($_POST['address']) ? define('POST_ADDRESS', $_POST['address']): define('POST_ADDRESS', '');
isset($_POST['description']) ? define('POST_DESCRIPTION', $_POST['description']): define('POST_DESCRIPTION', '');
isset($_POST['privateNote']) ? define('POST_PRIVATENOTE', $_POST['privateNote']): define('POST_PRIVATENOTE', '');
isset($_POST['status']) ? define('POST_STATUS', $_POST['status']): define('POST_STATUS', $GLOBALS['defaults']['privacy']);
@ -44,14 +40,6 @@ isset($_GET['popup']) ? define('GET_POPUP', $_GET['popup']): define('GET_POPUP',
isset($_POST['popup']) ? define('POST_POPUP', $_POST['popup']): define('POST_POPUP', '');
isset($_POST['referrer']) ? define('POST_REFERRER', $_POST['referrer']): define('POST_REFERRER', '');
if (! is_array($ADDRESS)) {
$ADDRESS = array($ADDRESS);
}
if (! is_array($TITLE)) {
$TITLE = array($TITLE);
}
// Header variables
$tplVars['pagetitle'] = T_('Edit Bookmark');
$tplVars['subtitle'] = T_('Edit Bookmark');
@ -64,24 +52,28 @@ if (!($row = $bookmarkservice->getBookmark(intval($bookmark), true))) {
$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 (!$TITLE || !$ADDRESS) {
if (!POST_TITLE || !POST_ADDRESS) {
$tplVars['error'] = T_('Your bookmark must have a title and an address');
} else {
// Update bookmark
$bId = intval($bookmark);
$address = array_map('trim', $ADDRESS);
$title = array_map('trim', $TITLE);
$address = trim(POST_ADDRESS);
$title = trim(POST_TITLE);
$description = trim(POST_DESCRIPTION);
$privateNote = trim(POST_PRIVATENOTE);
$status = intval(POST_STATUS);
$tags = trim(POST_TAGS);
if (!$bookmarkservice->updateBookmark($bId, $address[0], $title[0], $description, $privateNote, $status, $tags)) {
if (!$bookmarkservice->updateBookmark($bId, $address, $title, $description, $privateNote, $status, $tags)) {
$tplvars['error'] = T_('Error while saving your bookmark');
} else {
if (POST_POPUP != '') {

View File

@ -16,7 +16,7 @@
* @link http://sourceforge.net/projects/semanticscuttle
* @link http://www.google.com/cse/docs/cref.html
*/
require_once '../www-header.php';
require_once __DIR__ . '/../www-header.php';
if ($GLOBALS['enableGoogleCustomSearch'] == false) {
header('HTTP/1.0 403 Forbidden');

View File

@ -17,7 +17,7 @@
* @link http://sourceforge.net/projects/semanticscuttle
* @link http://www.google.com/cse/docs/cref.html
*/
require_once '../www-header.php';
require_once __DIR__ . '/../www-header.php';
if ($GLOBALS['enableGoogleCustomSearch'] == false) {
header('HTTP/1.0 403 Forbidden');

View File

@ -20,13 +20,6 @@
***************************************************************************/
require_once 'www-header.php';
if ('@data_dir@' == '@' . 'data_dir@') {
//non pear-install
require_once dirname(__FILE__) . '/../src/SemanticScuttle/parse_netscape_bookmarks.php';
} else {
//pear installation; files are in include path
require_once 'SemanticScuttle/parse_netscape_bookmarks.php';
}
/* Service creation: only useful services are created */
$bookmarkservice =SemanticScuttle_Service_Factory::get('Bookmark');
@ -51,45 +44,78 @@ if ($userservice->isLoggedOn() && sizeof($_FILES) > 0 && $_FILES['userfile']['si
// File handle
$html = file_get_contents($_FILES['userfile']['tmp_name']);
// Create array
$matches = parse_netscape_bookmarks($html);
//var_dump($matches);
$size = count($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();
$links = $matches[1];
$titles = $matches[2];
$descriptions = $matches[4];
$size = count($links);
for ($i = 0; $i < $size; $i++) {
$bDatetime = gmdate('Y-m-d H:i:s', $matches[$i]['time']); //bDateTime optional
$bCategories = $matches[$i]['tags']; //bCategories optional
$bAddress = $matches[$i]['uri'];
$bDescription = $matches[$i]['note'];
$bTitle = $matches[$i]['title'];
$bPrivateNote = '';
// 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
$bPrivateNote = ""; //bPrivateNote optional
$bPrivate = $status; //bPrivate set default
foreach ($attributes[0] as $attribute) {
$att = preg_split('/\s*=\s*/s', $attribute, 2);
$attrTitle = $att[0];
$attrVal = str_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;
break;
case "PRIVATE":
if ($attrVal) {
$bPrivate = 2;//private
}
}
}
$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.');
// If the bookmark exists already, edit the original
$bookmark = $bookmarkservice->getBookmarkByAddress($bAddress);
$bId = intval($bookmark['bId']);
$row = $bookmarkservice->getBookmark($bId, true);
$categories = array_unique(array_merge($row['tags'], $bCategories));
//var_dump('update', $bId, $bAddress, $row['bTitle'], $row['bDescription'], $row['bPrivateNote'], $row['bStatus'], $categories);
if ($bookmarkservice->updateBookmark($bId, $bAddress, $row['bTitle'], $row['bDescription'], $row['bPrivateNote'], $row['bStatus'], $categories)) {
$countImportedBookmarks++;
}
else {
$tplvars['error'] = T_('Error while saving this bookmark : ' + $bAddress);
}
$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');
}
//var_dump('add ', $bAddress, $bTitle, $bDescription, $bPrivateNote, $status, $bCategories, $bDatetime);
if ($bookmarkservice->addBookmark($bAddress, $bTitle, $bDescription, $bPrivateNote, $status, $bCategories, null, $bDatetime, false, true)) {
if ($bookmarkservice->addBookmark($bAddress, $bTitle, $bDescription, $bPrivateNote, $bPrivate, $bCategories, null, $bDatetime, false, true)) {
$countImportedBookmarks++;
} else {
$tplVars['error'] = T_('There was an error saving your bookmark : ' . $bAddress . ' Please try again or contact the administrator.');
$tplVars['error'] = T_('There was an error saving your bookmark. Please try again or contact the administrator.');
}
}
}
@ -107,5 +133,4 @@ if ($userservice->isLoggedOn() && sizeof($_FILES) > 0 && $_FILES['userfile']['si
$tplVars['formaction'] = createURL('importNetscape');
$templateservice->loadTemplate($templatename, $tplVars);
}
?>

View File

@ -1,117 +0,0 @@
/*!
* jQuery Cookie Plugin v1.4.1
* https://github.com/carhartl/jquery-cookie
*
* Copyright 2013 Klaus Hartl
* Released under the MIT license
*/
(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD
define(['jquery'], factory);
} else if (typeof exports === 'object') {
// CommonJS
factory(require('jquery'));
} else {
// Browser globals
factory(jQuery);
}
}(function ($) {
var pluses = /\+/g;
function encode(s) {
return config.raw ? s : encodeURIComponent(s);
}
function decode(s) {
return config.raw ? s : decodeURIComponent(s);
}
function stringifyCookieValue(value) {
return encode(config.json ? JSON.stringify(value) : String(value));
}
function parseCookieValue(s) {
if (s.indexOf('"') === 0) {
// This is a quoted cookie as according to RFC2068, unescape...
s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
}
try {
// Replace server-side written pluses with spaces.
// If we can't decode the cookie, ignore it, it's unusable.
// If we can't parse the cookie, ignore it, it's unusable.
s = decodeURIComponent(s.replace(pluses, ' '));
return config.json ? JSON.parse(s) : s;
} catch(e) {}
}
function read(s, converter) {
var value = config.raw ? s : parseCookieValue(s);
return $.isFunction(converter) ? converter(value) : value;
}
var config = $.cookie = function (key, value, options) {
// Write
if (value !== undefined && !$.isFunction(value)) {
options = $.extend({}, config.defaults, options);
if (typeof options.expires === 'number') {
var days = options.expires, t = options.expires = new Date();
t.setTime(+t + days * 864e+5);
}
return (document.cookie = [
encode(key), '=', stringifyCookieValue(value),
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
options.path ? '; path=' + options.path : '',
options.domain ? '; domain=' + options.domain : '',
options.secure ? '; secure' : ''
].join(''));
}
// Read
var result = key ? undefined : {};
// To prevent the for loop in the first place assign an empty array
// in case there are no cookies at all. Also prevents odd result when
// calling $.cookie().
var cookies = document.cookie ? document.cookie.split('; ') : [];
for (var i = 0, l = cookies.length; i < l; i++) {
var parts = cookies[i].split('=');
var name = decode(parts.shift());
var cookie = parts.join('=');
if (key && key === name) {
// If second argument (value) is a function it's a converter...
result = read(cookie, value);
break;
}
// Prevent storing a cookie that we couldn't decode.
if (!key && (cookie = read(cookie)) !== undefined) {
result[name] = cookie;
}
}
return result;
};
config.defaults = {};
$.removeCookie = function (key, options) {
if ($.cookie(key) === undefined) {
return false;
}
// Must not alter options, thus extending a fresh object...
$.cookie(key, '', $.extend({}, options, { expires: -1 }));
return !$.cookie(key);
};
}));

View File

@ -26,7 +26,7 @@ isset($_POST['terms']) ? define('POST_TERMS', $_POST['terms']): define('POST_TER
isset($_POST['range']) ? define('POST_RANGE', $_POST['range']): define('POST_RANGE', '');
isset($_GET['page']) ? define('GET_PAGE', $_GET['page']): define('GET_PAGE', 0);
isset($_GET['sort']) ? define('GET_SORT', $_GET['sort']): define('GET_SORT', '');
isset($_GET['batch']) ? define('GET_BATCH', $_GET['batch']): define('GET_BATCH', 0);
// POST
if (POST_TERMS != '') {
@ -115,41 +115,6 @@ if (is_null($terms)) {
}
}
if ($userservice->isLoggedOn() && GET_BATCH) {
$currentUsername = $currentUser->getUsername();
$completebookmarks = $bookmarkservice->getBookmarks(0, null, $s_user, null, $terms, getSortOrder(),
$s_watchlist, $s_start, $s_end);
$templatename = 'editbookmark.tpl';
$addresses2 = array();
$titles2 = array();
$tags2 = array();
foreach ($completebookmarks['bookmarks'] as $key => &$row) {
$addresses2[$row['bId']] = $row['bAddress'];
$titles2[$row['bId']] = $row['bTitle'];
$row = $bookmarkservice->getBookmark($row['bId'], true);
$tags2[] = $row['tags'];
}
$alltags2 = array_unique(call_user_func_array('array_merge', $tags2));
$commontags2 = call_user_func_array('array_intersect', $tags2);
$tplVars['row'] = array(
'bTitle' => $titles2,
'bAddress' => $addresses2,
'bDescription' => '',
'bPrivateNote' => '',
'tags' => array(),
'bStatus' => $GLOBALS['defaults']['privacy']
);
$tplVars['pagetitle'] = T_('Add a Bookmark');
$tplVars['subtitle'] = T_('Add a Bookmark');
$tplVars['btnsubmit'] = T_('Add Bookmark');
$tplVars['popup'] = null;
$tplVars['batch'] = '1';
$tplVars['alltags'] = implode(', ', $alltags2);
$tplVars['commontags'] = implode(', ', $commontags2);
$tplVars['formaction'] = createURL('bookmarks', $currentUsername);
$templateservice->loadTemplate($templatename, $tplVars);
}
else {
$bookmarks = $bookmarkservice->getBookmarks(
$start, $perpage, $s_user, NULL, $terms, getSortOrder(),
$s_watchlist, $s_start, $s_end
@ -187,5 +152,4 @@ $tplVars['cat_url'] = createURL('tags', '%2$s');
$tplVars['nav_url'] = createURL('search', $range .'/'. $terms .'/%3$s');
$templateservice->loadTemplate('bookmarks.tpl', $tplVars);
}
?>

View File

@ -63,7 +63,7 @@ if (POST_CONFIRM != '') {
}
$tplVars['links'] = $tag2tagservice->getLinks($currentUser->getId());
$tplVars['loadjs'] = true;
$tplVars['tag1'] = $tag1;
$tplVars['tag2'] = '';
$tplVars['subtitle'] = T_('Add Tag Link') .': '. $tag1;

View File

@ -75,7 +75,7 @@ if (POST_CONFIRM) {
}
$tplVars['links'] = $tag2tagservice->getLinks($currentUser->getId());
$tplVars['loadjs'] = true;
$tplVars['tag1'] = $tag1;
$tplVars['tag2'] = $tag2;
$tplVars['subtitle'] = T_('Delete Link Between Tags') .': '. $tag1.' > '.$tag2;

View File

@ -73,7 +73,6 @@ if (POST_CONFIRM) {
$tplVars['formaction'] = $_SERVER['SCRIPT_NAME'] .'/'. $tag;
$tplVars['referrer'] = $_SERVER['HTTP_REFERER'];
$tplVars['old'] = $tag;
$tplVars['loadjs'] = true;
}
$templateservice->loadTemplate($template, $tplVars);
?>

View File

@ -20,6 +20,7 @@
***************************************************************************/
require_once 'www-header.php';
/* Service creation: only useful services are created */
$bookmarkservice =SemanticScuttle_Service_Factory::get('Bookmark');
$cacheservice =SemanticScuttle_Service_Factory::get('Cache');
@ -27,7 +28,6 @@ $cacheservice =SemanticScuttle_Service_Factory::get('Cache');
/* Managing all possible inputs */
isset($_GET['page']) ? define('GET_PAGE', $_GET['page']): define('GET_PAGE', 0);
isset($_GET['sort']) ? define('GET_SORT', $_GET['sort']): define('GET_SORT', '');
isset($_GET['batch']) ? define('GET_BATCH', $_GET['batch']): define('GET_BATCH', 0);
/* Managing current logged user */
$currentUser = $userservice->getCurrentObjectUser();
@ -63,43 +63,6 @@ if ($usecache) {
$cacheservice->Start($hash, 1800);
}
// We need all bookmarks (without paging) for batch tagging.
if ($userservice->isLoggedOn() && GET_BATCH) {
$currentUsername = $currentUser->getUsername();
$completebookmarks = $bookmarkservice->getBookmarks(0, null, null, $cat, null, getSortOrder());
$templatename = 'editbookmark.tpl';
$addresses2 = array();
$titles2 = array();
$tags2 = array();
foreach ($completebookmarks['bookmarks'] as $key => &$row) {
$addresses2[$row['bId']] = $row['bAddress'];
$titles2[$row['bId']] = $row['bTitle'];
$row = $bookmarkservice->getBookmark($row['bId'], true);
$tags2[] = $row['tags'];
}
$alltags2 = array_unique(call_user_func_array('array_merge', $tags2));
$commontags2 = call_user_func_array('array_intersect', $tags2);
$tplVars['row'] = array(
'bTitle' => $titles2,
'bAddress' => $addresses2,
'bDescription' => '',
'bPrivateNote' => '',
'tags' => array(),
'bStatus' => $GLOBALS['defaults']['privacy']
);
$tplVars['pagetitle'] = T_('Add a Bookmark');
$tplVars['subtitle'] = T_('Add a Bookmark');
$tplVars['btnsubmit'] = T_('Add Bookmark');
$tplVars['popup'] = null;
$tplVars['batch'] = '1';
$tplVars['alltags'] = implode(', ', $alltags2);
$tplVars['commontags'] = implode(', ', $commontags2);
$tplVars['formaction'] = createURL('bookmarks', $currentUsername);
$tplVars['loadjs'] = true;
$templateservice->loadTemplate($templatename, $tplVars);
}
else {
// Header variables
$tplVars['pagetitle'] = T_('Tags') .': '. $cat;
$tplVars['loadjs'] = true;
@ -143,38 +106,7 @@ $tplVars['page'] = $page;
$tplVars['start'] = $start;
$tplVars['popCount'] = 25;
$tplVars['currenttag'] = $cat;
if ($userservice->isLoggedOn() && ! empty($GLOBALS['shoulderSurfingProtectedTag']) && ! isset($_COOKIE["noshoulderSurfingProtection"])) {
$tag2tagservice = SemanticScuttle_Service_Factory::get('Tag2Tag');
$b2tservice = SemanticScuttle_Service_Factory::get('Bookmark2Tag');
$currentUserID = $currentUser->getId();
$alltags = $b2tservice->getTags($currentUserID);
$shoulderSurfingProtectedTags = $tag2tagservice->getAllLinkedTags($GLOBALS['shoulderSurfingProtectedTag'], '>', $currentUserID, array());
$shoulderSurfingProtectedTags[] = $GLOBALS['shoulderSurfingProtectedTag'];
$flag = 0;
if (! in_array($cat, $shoulderSurfingProtectedTags, true)) {
foreach ($alltags as $tag) {
if ($tag['tag'] === $cat) {
$flag = 1;
break;
}
}
}
if ($flag) {
$tplVars['sidebar_blocks'][] = 'tagactions';
$tplVars['sidebar_blocks'][] = 'linked';
$tplVars['sidebar_blocks'][] = 'related';
$tplVars['sidebar_blocks'][] = 'menu2';
}
}
else {
$tplVars['sidebar_blocks'][] = 'tagactions';
$tplVars['sidebar_blocks'][] = 'linked';
$tplVars['sidebar_blocks'][] = 'related';
$tplVars['sidebar_blocks'][] = 'menu2';
}
$tplVars['sidebar_blocks'] = array('linked', 'related', 'menu2');//array('linked', 'related', 'popular');
$tplVars['subtitlehtml'] = $pagetitle;
$tplVars['bookmarkCount'] = $start + 1;
$bookmarks = $bookmarkservice->getBookmarks($start, $perpage, NULL, $cat, NULL, getSortOrder());
@ -184,7 +116,7 @@ $tplVars['cat_url'] = createURL('bookmarks', '%1$s/%2$s');
$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);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -110,8 +110,7 @@ html > body h1 {
padding-left: 75px;
}
html > body div#header.popup h1 {
background: url('images/logo.png') no-repeat 10px;
background-size: 24px;
background: url('images/logo_24.gif') no-repeat 10px;
padding: 0.5em 0.5em 0.5em 50px;
}
/*html > body div#header #welcome {
@ -196,6 +195,7 @@ img.thumbnail {
padding: 1px;
margin-right: 6px;
margin-bottom:4px;
cursor:pointer;
border:1px solid #AAA;
}
div.link a {