PHP broke a number of syntactical things that were key parts of
scuttle.
- changed the way that objects are initialized to use the "new
Class()" syntax and replace the ClassName functions with __construct.
- add conditional isset() checks to set variables to null before they
are used (esp. in templates)
- rework the ServiceFactory so they are called different and have
access to the database material
- replace deprecated builtins like call_user_func_array() and
create_function()
- handle the explosion of urls a little more gracefully so we don't
have reply on access missing items of arrays.
- search.inc.php relies on a bunch of variables that aren't set
anywhere in the code. I've removed a bunch of stuff from to quite
things but there might be something I'm missing here.
43 files changed:
***************************************************************************/
require_once 'header.inc.php';
***************************************************************************/
require_once 'header.inc.php';
-$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
+$sf = new ServiceFactory();
+$templateservice =& $sf->getServiceInstance('TemplateService');
$tplVars = array();
$tplVars['subtitle'] = T_('About');
$tplVars = array();
$tplVars['subtitle'] = T_('About');
header('Cache-Control: no-cache, must-revalidate');
require_once 'header.inc.php';
header('Cache-Control: no-cache, must-revalidate');
require_once 'header.inc.php';
-$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
+$sf = new ServiceFactory();
+$bookmarkservice =& $sf->getServiceInstance('BookmarkService');
$bookmark = intval($_GET['id']);
if (!$bookmarkservice->editAllowed($bookmark)) {
echo T_('You are not allowed to delete this bookmark');
$bookmark = intval($_GET['id']);
if (!$bookmarkservice->editAllowed($bookmark)) {
echo T_('You are not allowed to delete this bookmark');
header('Cache-Control: no-cache, must-revalidate');
require_once 'header.inc.php';
header('Cache-Control: no-cache, must-revalidate');
require_once 'header.inc.php';
-$userservice =& ServiceFactory::getServiceInstance('UserService');
+$sf = new ServiceFactory();
+$userservice =& $sf->getServiceInstance('UserService');
echo !($userservice->isReserved($_GET['username']) || $userservice->getUserByUsername($_GET['username']));
echo !($userservice->isReserved($_GET['username']) || $userservice->getUserByUsername($_GET['username']));
require_once 'header.inc.php';
require_once 'header.inc.php';
-$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
-$tagservice =& ServiceFactory::getServiceInstance('TagService');
-$userservice =& ServiceFactory::getServiceInstance('UserService');
-$cacheservice =& ServiceFactory::getServiceInstance('CacheService');
+$sf = new ServiceFactory();
+$bookmarkservice =& $sf->getServiceInstance('BookmarkService');
+$templateservice =& $sf->getServiceInstance('TemplateService');
+$userservice =& $sf->getServiceInstance('UserService');
+$cacheservice =& $sf->getServiceInstance('CacheService');
@list($url, $user) = explode('/', $_SERVER['PATH_INFO']);
if (!$user) {
@list($url, $user) = explode('/', $_SERVER['PATH_INFO']);
if (!$user) {
require_once 'header.inc.php';
require_once 'header.inc.php';
-$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
-$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
-$userservice =& ServiceFactory::getServiceInstance('UserService');
-$cacheservice =& ServiceFactory::getServiceInstance('CacheService');
+$sf = new ServiceFactory();
+$bookmarkservice =& $sf->getServiceInstance('BookmarkService');
+$templateservice =& $sf->getServiceInstance('TemplateService');
+$userservice =& $sf->getServiceInstance('UserService');
+$cacheservice =& $sf->getServiceInstance('CacheService');
+# it would probably be better to not supress the errors here
@list($url, $user, $cat) = isset($_SERVER['PATH_INFO']) ? explode('/', $_SERVER['PATH_INFO']) : NULL;
$loggedon = false;
@list($url, $user, $cat) = isset($_SERVER['PATH_INFO']) ? explode('/', $_SERVER['PATH_INFO']) : NULL;
$loggedon = false;
);
$tplVars['tags'] = $_POST['tags'];
} else {
);
$tplVars['tags'] = $_POST['tags'];
} else {
+ if (isset($_GET['tags'])) {
+ $raw_tags = $_GET['tags'];
+ } else {
+ $raw_tags = NULL;
+ }
$tplVars['row'] = array(
'bTitle' => stripslashes($_GET['title']),
'bAddress' => stripslashes($_GET['address']),
'bDescription' => stripslashes($_GET['description']),
$tplVars['row'] = array(
'bTitle' => stripslashes($_GET['title']),
'bAddress' => stripslashes($_GET['address']),
'bDescription' => stripslashes($_GET['description']),
- 'tags' => ($_GET['tags'] ? explode(',', stripslashes($_GET['tags'])) : array())
+ 'tags' => ($raw_tags ? explode(',', stripslashes($raw_tags)) : array())
);
}
$title = T_('Add a Bookmark');
);
}
$title = T_('Add a Bookmark');
$tplVars['start'] = $start;
$tplVars['bookmarkCount'] = $start + 1;
$tplVars['start'] = $start;
$tplVars['bookmarkCount'] = $start + 1;
- $bookmarks =& $bookmarkservice->getBookmarks($start, $perpage, $userid, $cat, $terms, getSortOrder());
+ $bookmarks =& $bookmarkservice->getBookmarks($start, $perpage, $userid, $cat, '', getSortOrder());
$tplVars['total'] = $bookmarks['total'];
$tplVars['bookmarks'] =& $bookmarks['bookmarks'];
$tplVars['cat_url'] = createURL('bookmarks', '%s/%s');
$tplVars['total'] = $bookmarks['total'];
$tplVars['bookmarks'] =& $bookmarks['bookmarks'];
$tplVars['cat_url'] = createURL('bookmarks', '%s/%s');
require_once 'header.inc.php';
require_once 'header.inc.php';
-$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
-$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
-$userservice =& ServiceFactory::getServiceInstance('UserService');
+$sf = new ServiceFactory();
+$bookmarkservice =& $sf->getServiceInstance('BookmarkService');
+$templateservice =& $sf->getServiceInstance('TemplateService');
+$userservice =& $sf->getServiceInstance('UserService');
// Header variables
$tplVars['subtitle'] = T_('Edit Bookmark');
// Header variables
$tplVars['subtitle'] = T_('Edit Bookmark');
require_once 'header.inc.php';
require_once 'header.inc.php';
-$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
-$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
-$userservice =& ServiceFactory::getServiceInstance('UserService');
-$cacheservice =& ServiceFactory::getServiceInstance('CacheService');
+$sf = new ServiceFactory();
+$bookmarkservice =& $sf->getServiceInstance('BookmarkService');
+$templateservice =& $sf->getServiceInstance('TemplateService');
+$userservice =& $sf->getServiceInstance('UserService');
+$cacheservice =& $sf->getServiceInstance('CacheService');
// Cache output if existing copy has expired
$cacheservice->End($cachehash);
}
// Cache output if existing copy has expired
$cacheservice->End($cachehash);
}
-?>
\ No newline at end of file
require_once 'header.inc.php';
require_once 'header.inc.php';
-$userservice =& ServiceFactory::getServiceInstance('UserService');
-$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
+$sf = new ServiceFactory();
+$userservice =& $sf->getServiceInstance('UserService');
+$templateservice =& $sf->getServiceInstance('TemplateService');
function startElement($parser, $name, $attrs) {
global $depth, $status, $tplVars, $userservice;
function startElement($parser, $name, $attrs) {
global $depth, $status, $tplVars, $userservice;
- $bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
- $userservice =& ServiceFactory::getServiceInstance('UserService');
+ $sf = new ServiceFactory();
+ $bookmarkservice =& $sf->getServiceInstance('BookmarkService');
+ $cacheservice =& $sf->getServiceInstance('CacheService');
if ($name == 'POST') {
while(list($attrTitle, $attrVal) = each($attrs)) {
if ($name == 'POST') {
while(list($attrTitle, $attrVal) = each($attrs)) {
require_once 'header.inc.php';
require_once 'header.inc.php';
-$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
-$userservice =& ServiceFactory::getServiceInstance('UserService');
-$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
+$sf = new ServiceFactory();
+$bookmarkservice =& $sf->getServiceInstance('BookmarkService');
+$userservice =& $sf->getServiceInstance('UserService');
+$templateservice =& $sf->getServiceInstance('TemplateService');
***************************************************************************/
require_once 'header.inc.php';
***************************************************************************/
require_once 'header.inc.php';
-$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
-$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
-$userservice =& ServiceFactory::getServiceInstance('UserService');
-$cacheservice =& ServiceFactory::getServiceInstance('CacheService');
+
+$sf = new ServiceFactory();
+$bookmarkservice =& $sf->getServiceInstance('BookmarkService');
+$templateservice =& $sf->getServiceInstance('TemplateService');
+$userservice =& $sf->getServiceInstance('UserService');
+$cacheservice =& $sf->getServiceInstance('CacheService');
$tplvars = array();
if (isset($_GET['action']) && 'logout' == $_GET['action']) {
$tplvars = array();
if (isset($_GET['action']) && 'logout' == $_GET['action']) {
***************************************************************************/
require_once 'header.inc.php';
***************************************************************************/
require_once 'header.inc.php';
-$userservice =& ServiceFactory::getServiceInstance('UserService');
-$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
+$sf = new ServiceFactory();
+$userservice =& $sf->getServiceInstance('UserService');
+$templateservice =& $sf->getServiceInstance('TemplateService');
***************************************************************************/
require_once 'header.inc.php';
***************************************************************************/
require_once 'header.inc.php';
-$userservice =& ServiceFactory::getServiceInstance('UserService');
-$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
+$sf = new ServiceFactory();
+$userservice =& $sf->getServiceInstance('UserService');
+$templateservice =& $sf->getServiceInstance('TemplateService');
$tplVars = array();
// IF SUBMITTED
$tplVars = array();
// IF SUBMITTED
***************************************************************************/
require_once 'header.inc.php';
***************************************************************************/
require_once 'header.inc.php';
-$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
-$tagservice =& ServiceFactory::getServiceInstance('TagService');
-$userservice =& ServiceFactory::getServiceInstance('UserService');
-$cacheservice =& ServiceFactory::getServiceInstance('CacheService');
+$sf = new ServiceFactory();
+$bookmarkservice =& $sf->getServiceInstance('BookmarkService');
+$templateservice =& $sf->getServiceInstance('TemplateService');
+$userservice =& $sf->getServiceInstance('UserService');
+$cacheservice =& $sf->getServiceInstance('CacheService');
list($url, $user) = explode('/', $_SERVER['PATH_INFO']);
list($url, $user) = explode('/', $_SERVER['PATH_INFO']);
***************************************************************************/
require_once 'header.inc.php';
***************************************************************************/
require_once 'header.inc.php';
-$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
-$userservice =& ServiceFactory::getServiceInstance('UserService');
+$sf = new ServiceFactory();
+$templateservice =& $sf->getServiceInstance('TemplateService');
+$userservice =& $sf->getServiceInstance('UserService');
***************************************************************************/
require_once 'header.inc.php';
***************************************************************************/
require_once 'header.inc.php';
-$userservice =& ServiceFactory::getServiceInstance('UserService');
-$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
+$sf = new ServiceFactory();
+$userservice =& $sf->getServiceInstance('UserService');
+$templateservice =& $sf->getServiceInstance('TemplateService');
$tplVars = array();
$completed = FALSE;
$tplVars = array();
$completed = FALSE;
require_once 'header.inc.php';
require_once 'header.inc.php';
-$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
-$cacheservice =& ServiceFactory::getServiceInstance('CacheService');
-$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
-$userservice =& ServiceFactory::getServiceInstance('UserService');
+$sf = new ServiceFactory();
+$bookmarkservice =& $sf->getServiceInstance('BookmarkService');
+$templateservice =& $sf->getServiceInstance('TemplateService');
+$userservice =& $sf->getServiceInstance('UserService');
+$cacheservice =& $sf->getServiceInstance('CacheService');
$tplVars = array();
header('Content-Type: application/xml');
$tplVars = array();
header('Content-Type: application/xml');
$currentUsername = $currentUser[$userservice->getFieldName('username')];
$logged_on = TRUE;
}
$currentUsername = $currentUser[$userservice->getFieldName('username')];
$logged_on = TRUE;
}
- if ($logged_on || isset($user)) {
+ if (!$logged_on && !isset($user)) {
+ ?>
+ <td><input type="hidden" name="range" value="all" /></td>
+ <?php
+ } else {
?>
<td><?php echo T_('Search' /* Search ... for */); ?></td>
<td>
<select name="range">
?>
<td><?php echo T_('Search' /* Search ... for */); ?></td>
<td>
<select name="range">
- <?php if (!in_array($range, array($currentUsername, 'all', 'watchlist')) && $user != $currentUsername): ?>
- <option value="<?php echo $user ?>"<?php echo $selectUser; ?>><?php echo T_("this user's bookmarks"); ?></option>
+ <?php if (isset($currentUsername) && $user != $currentUsername): ?>
+ <option value="<?php echo $user ?>"><?php echo T_("this user's bookmarks"); ?></option>
<?php
endif;
if ($logged_on) {
?>
<?php
endif;
if ($logged_on) {
?>
- <option value="<?php echo $currentUsername; ?>"<?php echo $selectMy; ?>><?php echo T_('my bookmarks'); ?></option>
- <option value="watchlist"<?php echo $select_watchlist; ?>><?php echo T_('my watchlist'); ?></option>
+ <option value="<?php echo $currentUsername; ?>"><?php echo T_('my bookmarks'); ?></option>
+ <option value="watchlist"<?php if (isset($select_watchlist)) { echo $select_watchlist; } ?>><?php echo T_('my watchlist'); ?></option>
- <option value="all"<?php echo $select_all; ?>><?php echo T_('all bookmarks'); ?></option>
+ <option value="all"<?php if (isset($select_all)) { echo $select_all; } ?>><?php echo T_('all bookmarks'); ?></option>
</select>
</td>
<td><?php echo T_('for' /* Search ... for */); ?></td>
<?php
</select>
</td>
<td><?php echo T_('for' /* Search ... for */); ?></td>
<?php
- } else {
- ?>
- <td><input type="hidden" name="range" value="all" /></td>
- <?php
- <td><input type="text" name="terms" size="50" value="<?php echo filter($terms); ?>" /></td>
+ <td><input type="text" name="terms" size="50" value="<?php if (isset($terms)) { echo filter($terms); } ?>" /></td>
<td><input type="submit" value="<?php echo T_('Search' /* Submit button */); ?>" /></td>
</tr>
</table>
<td><input type="submit" value="<?php echo T_('Search' /* Submit button */); ?>" /></td>
</tr>
</table>
- $bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
- $templateservice =& ServiceFactory::getServiceInstance('TemplateService');
- $userservice =& ServiceFactory::getServiceInstance('UserService');
+ $sf = new ServiceFactory();
+ $bookmarkservice =& $sf->getServiceInstance('BookmarkService');
+ $templateservice =& $sf->getServiceInstance('TemplateService');
+ $userservice =& $sf->getServiceInstance('UserService');
$logged_on_userid = $userservice->getCurrentUserId();
$logged_on_userid = $userservice->getCurrentUserId();
- list($url, $range, $terms, $page) = explode('/', $_SERVER['PATH_INFO']);
+
+ # explode the path
+ $path_exploded = explode('/', $_SERVER['PATH_INFO']);
+ $url = (count($path_exploded) > 0 ? $path_exploded[0] : NULL);
+ $range = (count($path_exploded) > 1 ? $path_exploded[1] : NULL);
+ $terms = (count($path_exploded) > 2 ? $path_exploded[2] : NULL);
+ $page = (count($path_exploded) > 3 ? $path_exploded[3] : NULL);
$tplvars = array();
$tplVars['loadjs'] = true;
$tplvars = array();
$tplVars['loadjs'] = true;
- function BookmarkService(&$db) {
+ function __construct(&$db) {
$this->db =& $db;
}
function _getbookmark($fieldname, $value, $all = false) {
if (!$all) {
$this->db =& $db;
}
function _getbookmark($fieldname, $value, $all = false) {
if (!$all) {
- $userservice = & ServiceFactory :: getServiceInstance('UserService');
+ $userservice = & (new ServiceFactory())->getServiceInstance('UserService');
$sId = $userservice->getCurrentUserId();
$range = ' AND uId = '. $sId;
}
$sId = $userservice->getCurrentUserId();
$range = ' AND uId = '. $sId;
}
if ($row = & $this->db->sql_fetchrow($dbresult)) {
if ($include_tags) {
if ($row = & $this->db->sql_fetchrow($dbresult)) {
if ($include_tags) {
- $tagservice = & ServiceFactory :: getServiceInstance('TagService');
+ $tagservice = & (new ServiceFactory())->getServiceInstance('TagService');
$row['tags'] = $tagservice->getTagsForBookmark($bid);
}
return $row;
$row['tags'] = $tagservice->getTagsForBookmark($bid);
}
return $row;
if (!($bookmark = $this->getBookmark($bookmark)))
return false;
if (!($bookmark = $this->getBookmark($bookmark)))
return false;
- $userservice = & ServiceFactory :: getServiceInstance('UserService');
+ $userservice = & (new ServiceFactory())->getServiceInstance('UserService');
$userid = $userservice->getCurrentUserId();
if ($userservice->isAdmin($userid))
return true;
$userid = $userservice->getCurrentUserId();
if ($userservice->isAdmin($userid))
return true;
// Adds a bookmark to the database.
// Note that date is expected to be a string that's interpretable by strtotime().
function addBookmark($address, $title, $description, $status, $categories, $date = NULL, $fromApi = false, $fromImport = false) {
// Adds a bookmark to the database.
// Note that date is expected to be a string that's interpretable by strtotime().
function addBookmark($address, $title, $description, $status, $categories, $date = NULL, $fromApi = false, $fromImport = false) {
- $userservice = & ServiceFactory :: getServiceInstance('UserService');
+ $userservice = & (new ServiceFactory())->getServiceInstance('UserService');
$sId = $userservice->getCurrentUserId();
// If bookmark address doesn't contain ":", add "http://" to the start as a default protocol
$sId = $userservice->getCurrentUserId();
// If bookmark address doesn't contain ":", add "http://" to the start as a default protocol
$extension = end($uriparts);
unset($uriparts);
$extension = end($uriparts);
unset($uriparts);
- $tagservice = & ServiceFactory :: getServiceInstance('TagService');
+ $tagservice = & (new ServiceFactory())->getServiceInstance('TagService');
if (!$tagservice->attachTags($bId, $categories, $fromApi, $extension, false, $fromImport)) {
$this->db->sql_transaction('rollback');
message_die(GENERAL_ERROR, 'Could not insert bookmark', '', __LINE__, __FILE__, $sql, $this->db);
if (!$tagservice->attachTags($bId, $categories, $fromApi, $extension, false, $fromImport)) {
$this->db->sql_transaction('rollback');
message_die(GENERAL_ERROR, 'Could not insert bookmark', '', __LINE__, __FILE__, $sql, $this->db);
$extension = end($uriparts);
unset($uriparts);
$extension = end($uriparts);
unset($uriparts);
- $tagservice = & ServiceFactory :: getServiceInstance('TagService');
+ $tagservice = & (new ServiceFactory())->getServiceInstance('TagService');
if (!$tagservice->attachTags($bId, $categories, $fromApi, $extension)) {
$this->db->sql_transaction('rollback');
message_die(GENERAL_ERROR, 'Could not update bookmark', '', __LINE__, __FILE__, $sql, $this->db);
if (!$tagservice->attachTags($bId, $categories, $fromApi, $extension)) {
$this->db->sql_transaction('rollback');
message_die(GENERAL_ERROR, 'Could not update bookmark', '', __LINE__, __FILE__, $sql, $this->db);
// if that user is on the logged-in user's watchlist, get the public AND contacts-only
// bookmarks; otherwise, just get the public bookmarks.
// - if the $user is set and IS the logged-in user, then get all bookmarks.
// if that user is on the logged-in user's watchlist, get the public AND contacts-only
// bookmarks; otherwise, just get the public bookmarks.
// - if the $user is set and IS the logged-in user, then get all bookmarks.
- $userservice =& ServiceFactory::getServiceInstance('UserService');
- $tagservice =& ServiceFactory::getServiceInstance('TagService');
+ $userservice =& (new ServiceFactory())->getServiceInstance('UserService');
+ $tagservice =& (new ServiceFactory())->getServiceInstance('TagService');
$sId = $userservice->getCurrentUserId();
if ($userservice->isLoggedOn()) {
$sId = $userservice->getCurrentUserId();
if ($userservice->isLoggedOn()) {
// Set up the tags, if need be.
if (!is_array($tags) && !is_null($tags)) {
$tags = explode('+', trim($tags));
// Set up the tags, if need be.
if (!is_array($tags) && !is_null($tags)) {
$tags = explode('+', trim($tags));
- }
-
- $tagcount = count($tags);
- for ($i = 0; $i < $tagcount; $i ++) {
- $tags[$i] = trim($tags[$i]);
+ $tagcount = count($tags);
+ for ($i = 0; $i < $tagcount; $i ++) {
+ $tags[$i] = trim($tags[$i]);
+ }
+ } else {
+ $tagcount = 0;
}
// Set up the SQL query.
}
// Set up the SQL query.
$aTerms = array_map('trim', $aTerms);
// Search terms in tags as well when none given
$aTerms = array_map('trim', $aTerms);
// Search terms in tags as well when none given
+ if (isset($tags) && !count($tags)) {
$query_2 .= ' LEFT JOIN '. $GLOBALS['tableprefix'] .'tags AS T ON B.bId = T.bId';
$dotags = true;
} else {
$query_2 .= ' LEFT JOIN '. $GLOBALS['tableprefix'] .'tags AS T ON B.bId = T.bId';
$dotags = true;
} else {
- $userservice = & ServiceFactory :: getServiceInstance('UserService');
+ $userservice = & (new ServiceFactory())->getServiceInstance('UserService');
$sId = $userservice->getCurrentUserId();
if ($userservice->isLoggedOn()) {
$sId = $userservice->getCurrentUserId();
if ($userservice->isLoggedOn()) {
<?php
class ServiceFactory {
<?php
class ServiceFactory {
- function ServiceFactory(&$db, $serviceoverrules = array()) {
+ function ServiceFactory() {
}
function &getServiceInstance($name, $servicedir = NULL) {
global $dbhost, $dbuser, $dbpass, $dbname, $dbport, $dbpersist, $dbtype;
}
function &getServiceInstance($name, $servicedir = NULL) {
global $dbhost, $dbuser, $dbpass, $dbname, $dbport, $dbpersist, $dbtype;
- static $instances = array();
static $db;
if (!isset($db)) {
require_once dirname(__FILE__) .'/../includes/db/'. $dbtype .'.php';
static $db;
if (!isset($db)) {
require_once dirname(__FILE__) .'/../includes/db/'. $dbtype .'.php';
message_die(CRITICAL_ERROR, "Could not connect to the database", $db);
}
}
message_die(CRITICAL_ERROR, "Could not connect to the database", $db);
}
}
+
+ static $instances = array();
if (!isset($instances[$name])) {
if (isset($serviceoverrules[$name])) {
$name = $serviceoverrules[$name];
if (!isset($instances[$name])) {
if (isset($serviceoverrules[$name])) {
$name = $serviceoverrules[$name];
}
require_once $servicedir . strtolower($name) .'.php';
}
}
require_once $servicedir . strtolower($name) .'.php';
}
- $instances[$name] = call_user_func_array(array($name, 'getInstance'), array(&$db));
+ $instances[$name] = (new $name($db))->getInstance($db);
}
return $instances[$name];
}
}
return $instances[$name];
}
- function TagService(&$db) {
+ function __construct(&$db) {
$this->db =& $db;
$this->tablename = $GLOBALS['tableprefix'] .'tags';
}
$this->db =& $db;
$this->tablename = $GLOBALS['tableprefix'] .'tags';
}
}
function deleteTag($tag) {
}
function deleteTag($tag) {
- $userservice =& ServiceFactory::getServiceInstance('UserService');
+ $userservice =& (new ServiceFactory())->getServiceInstance('UserService');
$logged_on_user = $userservice->getCurrentUserId();
$query = 'DELETE FROM '. $this->getTableName() .' USING '. $GLOBALS['tableprefix'] .'tags, '. $GLOBALS['tableprefix'] .'bookmarks WHERE '. $GLOBALS['tableprefix'] .'tags.bId = '. $GLOBALS['tableprefix'] .'bookmarks.bId AND '. $GLOBALS['tableprefix'] .'bookmarks.uId = '. $logged_on_user .' AND '. $GLOBALS['tableprefix'] .'tags.tag = "'. $this->db->sql_escape($tag) .'"';
$logged_on_user = $userservice->getCurrentUserId();
$query = 'DELETE FROM '. $this->getTableName() .' USING '. $GLOBALS['tableprefix'] .'tags, '. $GLOBALS['tableprefix'] .'bookmarks WHERE '. $GLOBALS['tableprefix'] .'tags.bId = '. $GLOBALS['tableprefix'] .'bookmarks.bId AND '. $GLOBALS['tableprefix'] .'bookmarks.uId = '. $logged_on_user .' AND '. $GLOBALS['tableprefix'] .'tags.tag = "'. $this->db->sql_escape($tag) .'"';
}
function &getTags($userid = NULL) {
}
function &getTags($userid = NULL) {
- $userservice =& ServiceFactory::getServiceInstance('UserService');
+ $userservice =& (new ServiceFactory())->getServiceInstance('UserService');
$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'] .'tags AS T ON B.bId = T.bId';
$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'] .'tags AS T ON B.bId = T.bId';
// Returns the most popular tags used for a particular bookmark hash
function &getRelatedTagsByHash($hash, $limit = 20) {
// Returns the most popular tags used for a particular bookmark hash
function &getRelatedTagsByHash($hash, $limit = 20) {
- $userservice = & ServiceFactory :: getServiceInstance('UserService');
+ $userservice = & (new ServiceFactory())->getServiceInstance('UserService');
$sId = $userservice->getCurrentUserId();
// Logged in
if ($userservice->isLoggedOn()) {
$sId = $userservice->getCurrentUserId();
// Logged in
if ($userservice->isLoggedOn()) {
}
function renameTag($userid, $old, $new, $fromApi = false) {
}
function renameTag($userid, $old, $new, $fromApi = false) {
- $bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
+ $bookmarkservice =& (new ServiceFactory())->getServiceInstance('BookmarkService');
if (is_null($userid) || is_null($old) || is_null($new))
return false;
if (is_null($userid) || is_null($old) || is_null($new))
return false;
}
if ($sortOrder == 'alphabet_asc') {
}
if ($sortOrder == 'alphabet_asc') {
- usort($output, create_function('$a,$b','return strcmp(utf8_strtolower($a["tag"]), utf8_strtolower($b["tag"]));'));
+ usort($output, function($a, $b) { return strcmp(utf8_strtolower($a["tag"]), utf8_strtolower($b["tag"])); });
- function TemplateService() {
+ function __construct() {
$this->basedir = $GLOBALS['TEMPLATES_DIR'];
}
$this->basedir = $GLOBALS['TEMPLATES_DIR'];
}
var $file = '';
var $templateservice;
var $file = '';
var $templateservice;
- function Template($file, $vars = NULL, &$templateservice) {
+ function __construct($file, $vars = NULL, &$templateservice) {
$this->vars = $vars;
$this->file = $file;
$this->templateservice = $templateservice;
$this->vars = $vars;
$this->file = $file;
$this->templateservice = $templateservice;
var $cookiekey;
var $cookietime = 63072000; // 2 years
var $cookiekey;
var $cookietime = 63072000; // 2 years
- function UserService(&$db) {
+ function __construct(&$db) {
$this->db =& $db;
$this->tablename = $GLOBALS['tableprefix'] .'users';
$this->sessionkey = $GLOBALS['cookieprefix'] .'-currentuserid';
$this->db =& $db;
$this->tablename = $GLOBALS['tableprefix'] .'users';
$this->sessionkey = $GLOBALS['cookieprefix'] .'-currentuserid';
***************************************************************************/
require_once 'header.inc.php';
***************************************************************************/
require_once 'header.inc.php';
-$tagservice = & ServiceFactory :: getServiceInstance('TagService');
-$templateservice = & ServiceFactory :: getServiceInstance('TemplateService');
-$userservice = & ServiceFactory :: getServiceInstance('UserService');
+$sf = new ServiceFactory();
+$tagservice =& $sf->getServiceInstance('TagService');
+$templateservice =& $sf->getServiceInstance('TemplateService');
+$userservice =& $sf->getServiceInstance('UserService');
list ($url, $tag) = explode('/', $_SERVER['PATH_INFO']);
list ($url, $tag) = explode('/', $_SERVER['PATH_INFO']);
$tplVars['formaction'] = $_SERVER['SCRIPT_NAME'] .'/'. $tag;
$tplVars['referrer'] = $_SERVER['HTTP_REFERER'];
$templateservice->loadTemplate('tagdelete.tpl', $tplVars);
$tplVars['formaction'] = $_SERVER['SCRIPT_NAME'] .'/'. $tag;
$tplVars['referrer'] = $_SERVER['HTTP_REFERER'];
$templateservice->loadTemplate('tagdelete.tpl', $tplVars);
-?>
\ No newline at end of file
***************************************************************************/
require_once 'header.inc.php';
***************************************************************************/
require_once 'header.inc.php';
-$tagservice = & ServiceFactory :: getServiceInstance('TagService');
-$templateservice = & ServiceFactory :: getServiceInstance('TemplateService');
-$userservice = & ServiceFactory :: getServiceInstance('UserService');
+$sf = new ServiceFactory();
+$tagservice =& $sf->getServiceInstance('TagService');
+$templateservice =& $sf->getServiceInstance('TemplateService');
+$userservice =& $sf->getServiceInstance('UserService');
list ($url, $tag) = explode('/', $_SERVER['PATH_INFO']);
list ($url, $tag) = explode('/', $_SERVER['PATH_INFO']);
require_once 'header.inc.php';
require_once 'header.inc.php';
-$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
-$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
-$userservice =& ServiceFactory::getServiceInstance('UserService');
-$cacheservice =& ServiceFactory::getServiceInstance('CacheService');
+$sf = new ServiceFactory();
+$bookmarkservice =& $sf->getServiceInstance('BookmarkService');
+$templateservice =& $sf->getServiceInstance('TemplateService');
+$userservice =& $sf->getServiceInstance('UserService');
+$cacheservice =& $sf->getServiceInstance('CacheService');
-$userservice =& ServiceFactory::getServiceInstance('UserService');
-$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
+$sf = new ServiceFactory();
+$userservice =& $sf->getServiceInstance('UserService');
+$bookmarkservice =& $sf->getServiceInstance('BookmarkService');
$logged_on_userid = $userservice->getCurrentUserId();
$this->includeTemplate($GLOBALS['top_include']);
$logged_on_userid = $userservice->getCurrentUserId();
$this->includeTemplate($GLOBALS['top_include']);
+# define variables
+if (!isset($currenttag)) {
+ $currenttag = NULL;
+}
+if (!isset($user)) {
+ $user = NULL;
+}
+if (!isset($userid)) {
+ $userid = NULL;
+}
+
include 'search.inc.php';
if (count($bookmarks) > 0) {
?>
include 'search.inc.php';
if (count($bookmarks) > 0) {
?>
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
***************************************************************************/
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
***************************************************************************/
-$tagservice =& ServiceFactory::getServiceInstance('TagService');
-$userservice =& ServiceFactory::getServiceInstance('UserService');
+$sf = new ServiceFactory();
+$tagservice =& $sf->getServiceInstance('TagService');
+$userservice =& $sf->getServiceInstance('UserService');
$logged_on_userid = $userservice->getCurrentUserId();
$logged_on_userid = $userservice->getCurrentUserId();
$accessPublic = '';
$accessShared = '';
$accessPrivate = '';
$accessPublic = '';
$accessShared = '';
$accessPrivate = '';
-switch ($row['bStatus']) {
- case 0 :
- $accessPublic = ' selected="selected"';
- break;
- case 1 :
- $accessShared = ' selected="selected"';
- break;
- case 2 :
- $accessPrivate = ' selected="selected"';
- break;
+
+if (isset($row['bStatus'])) {
+ switch ($row['bStatus']) {
+ case 0 :
+ $accessPublic = ' selected="selected"';
+ break;
+ case 1 :
+ $accessShared = ' selected="selected"';
+ break;
+ case 2 :
+ $accessPrivate = ' selected="selected"';
+ break;
+ }
</tr>
<tr>
<th align="left"><?php echo T_('Tags'); ?></th>
</tr>
<tr>
<th align="left"><?php echo T_('Tags'); ?></th>
- <td><input type="text" id="tags" name="tags" size="75" value="<?php echo filter(implode(', ', $row['tags']), 'xml'); ?>" /></td>
+ <td><input type="text" id="tags" name="tags" size="75" value="<?php if (isset($row['tags'])) { echo filter(implode(', ', $row['tags']), 'xml'); }?>" /></td>
<td>← <?php echo T_('Comma-separated'); ?></td>
</tr>
<tr>
<td>← <?php echo T_('Comma-separated'); ?></td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" name="submitted" value="<?php echo $btnsubmit; ?>" />
<td></td>
<td>
<input type="submit" name="submitted" value="<?php echo $btnsubmit; ?>" />
- <?php if ($showdelete): ?>
+ <?php if (isset($showdelete) && $showdelete): ?>
<input type="submit" name="delete" value="<?php echo T_('Delete Bookmark'); ?>" />
<?php endif; ?>
<?php if ($popup): ?>
<input type="hidden" name="popup" value="1" />
<input type="submit" name="delete" value="<?php echo T_('Delete Bookmark'); ?>" />
<?php endif; ?>
<?php if ($popup): ?>
<input type="hidden" name="popup" value="1" />
- <?php elseif ($referrer): ?>
+ <?php elseif (isset($referrer) && $referrer): ?>
<input type="hidden" name="referrer" value="<?php echo $referrer; ?>" />
<?php endif; ?>
</td>
<input type="hidden" name="referrer" value="<?php echo $referrer; ?>" />
<?php endif; ?>
</td>
$this->includeTemplate('dynamictags.inc');
// Bookmarklets and import links
$this->includeTemplate('dynamictags.inc');
// Bookmarklets and import links
-if (empty($_REQUEST['popup']) && !$showdelete) {
+if (empty($_REQUEST['popup']) && (!isset($showdelete) || !$showdelete)) {
?>
<h3><?php echo T_('Bookmarklet'); ?></h3>
?>
<h3><?php echo T_('Bookmarklet'); ?></h3>
-$userservice =& ServiceFactory::getServiceInstance('UserService');
+$sf = new ServiceFactory();
+$userservice =& $sf->getServiceInstance('UserService');
$this->includeTemplate($GLOBALS['top_include']);
?>
$this->includeTemplate($GLOBALS['top_include']);
?>
-$tagservice =& ServiceFactory::getServiceInstance('TagService');
+$sf = new ServiceFactory();
+$tagservice =& $sf->getServiceInstance('TagService');
$commonTags =& $tagservice->getRelatedTagsByHash($hash);
$commonTags =& $tagservice->tagCloud($commonTags, 5, 90, 225, 'alphabet_asc');
$commonTags =& $tagservice->getRelatedTagsByHash($hash);
$commonTags =& $tagservice->tagCloud($commonTags, 5, 90, 225, 'alphabet_asc');
-$tagservice =& ServiceFactory::getServiceInstance('TagService');
-$userservice =& ServiceFactory::getServiceInstance('UserService');
+$sf = new ServiceFactory();
+$tagservice =& $sf->getServiceInstance('TagService');
+$userservice =& $sf->getServiceInstance('UserService');
$logged_on_userid = $userservice->getCurrentUserId();
if ($logged_on_userid === false) {
$logged_on_userid = NULL;
}
$logged_on_userid = $userservice->getCurrentUserId();
if ($logged_on_userid === false) {
$logged_on_userid = NULL;
}
+if (!isset($userid)) {
+ $userid = NULL;
+}
+if (!isset($user)) {
+ $user = NULL;
+}
$popularTags =& $tagservice->getPopularTags($userid, $popCount, $logged_on_userid);
$popularTags =& $tagservice->tagCloud($popularTags, 5, 90, 225, 'alphabet_asc');
$popularTags =& $tagservice->getPopularTags($userid, $popCount, $logged_on_userid);
$popularTags =& $tagservice->tagCloud($popularTags, 5, 90, 225, 'alphabet_asc');
-$userservice =& ServiceFactory::getServiceInstance('UserService');
+$sf = new ServiceFactory();
+$userservice =& $sf->getServiceInstance('UserService');
if (utf8_strlen($userinfo['name']) > 0) {
$name = $userinfo['name'];
} else {
if (utf8_strlen($userinfo['name']) > 0) {
$name = $userinfo['name'];
} else {
-$tagservice =& ServiceFactory::getServiceInstance('TagService');
-$userservice =& ServiceFactory::getServiceInstance('UserService');
+$sf = new ServiceFactory();
+$tagservice =& $sf->getServiceInstance('TagService');
+$userservice =& $sf->getServiceInstance('UserService');
$logged_on_userid = $userservice->getCurrentUserId();
if ($logged_on_userid === false) {
$logged_on_userid = NULL;
}
$logged_on_userid = $userservice->getCurrentUserId();
if ($logged_on_userid === false) {
$logged_on_userid = NULL;
}
+
+if (!isset($userid)) {
+ $userid = NULL;
+}
+
$recentTags = $tagservice->getPopularTags($userid, $popCount, $logged_on_userid, $GLOBALS['defaultRecentDays']);
$recentTags =& $tagservice->tagCloud($recentTags, 5, 90, 225, 'alphabet_asc');
$recentTags = $tagservice->getPopularTags($userid, $popCount, $logged_on_userid, $GLOBALS['defaultRecentDays']);
$recentTags =& $tagservice->tagCloud($recentTags, 5, 90, 225, 'alphabet_asc');
-$tagservice =& ServiceFactory::getServiceInstance('TagService');
-$userservice =& ServiceFactory::getServiceInstance('UserService');
+$sf = new ServiceFactory();
+$tagservice =& $sf->getServiceInstance('TagService');
+$userservice =& $sf->getServiceInstance('UserService');
$logged_on_userid = $userservice->getCurrentUserId();
if ($logged_on_userid === false) {
$logged_on_userid = NULL;
}
$logged_on_userid = $userservice->getCurrentUserId();
if ($logged_on_userid === false) {
$logged_on_userid = NULL;
}
+if (!isset($userid)) {
+ $userid = NULL;
+}
+if (!isset($user)) {
+ $user = NULL;
+}
if ($currenttag) {
$relatedTags = $tagservice->getRelatedTags($currenttag, $userid, $logged_on_userid);
if (sizeof($relatedTags) > 0) {
if ($currenttag) {
$relatedTags = $tagservice->getRelatedTags($currenttag, $userid, $logged_on_userid);
if (sizeof($relatedTags) > 0) {
<tr>
<td><a href="<?php echo sprintf($cat_url, filter($user, 'url'), filter($currenttag, 'url') .'+'. filter($row['tag'], 'url')); ?>">+</a></td>
<td><a href="<?php echo sprintf($cat_url, filter($user, 'url'), filter($row['tag'], 'url')); ?>" rel="tag"><?php echo filter($row['tag']); ?></a></td>
<tr>
<td><a href="<?php echo sprintf($cat_url, filter($user, 'url'), filter($currenttag, 'url') .'+'. filter($row['tag'], 'url')); ?>">+</a></td>
<td><a href="<?php echo sprintf($cat_url, filter($user, 'url'), filter($row['tag'], 'url')); ?>" rel="tag"><?php echo filter($row['tag']); ?></a></td>
</tr>
<?php endforeach; ?>
</table>
</tr>
<?php endforeach; ?>
</table>
-?>
\ No newline at end of file
-$userservice =& ServiceFactory::getServiceInstance('UserService');
+$sf = new ServiceFactory();
+$userservice =& $sf->getServiceInstance('UserService');
if ($userservice->isLoggedOn()) {
$currentUser = $userservice->getCurrentUser();
$currentUsername = $currentUser[$userservice->getFieldName('username')];
if ($userservice->isLoggedOn()) {
$currentUser = $userservice->getCurrentUser();
$currentUsername = $currentUser[$userservice->getFieldName('username')];
-$userservice =& ServiceFactory::getServiceInstance('UserService');
+$sf = new ServiceFactory();
+$userservice =& $sf->getServiceInstance('UserService');
$watching = $userservice->getWatchNames($userid);
if ($watching) {
$watching = $userservice->getWatchNames($userid);
if ($watching) {
-$userservice =& ServiceFactory::getServiceInstance('UserService');
+$sf = new ServiceFactory();
+$userservice =& $sf->getServiceInstance('UserService');
if ($userservice->isLoggedOn()) {
$currentUser = $userservice->getCurrentUser();
$currentUsername = $currentUser[$userservice->getFieldName('username')];
if ($userservice->isLoggedOn()) {
$currentUser = $userservice->getCurrentUser();
$currentUsername = $currentUser[$userservice->getFieldName('username')];
$this->includeTemplate('sidebar.block.'. $sidebar_blocks[$i]);
}
$this->includeTemplate('sidebar.block.'. $sidebar_blocks[$i]);
}
- $size = count($rsschannels);
+ if (isset($rsschannels)) {
+ $size = count($rsschannels);
+ } else {
+ $size = 0;
+ }
for ($i = 0; $i < $size; $i++) {
echo '<p><a href="'. $rsschannels[$i][1] .'" title="'. $rsschannels[$i][0] .'"><img src="'. $GLOBALS['root'] .'rss.gif" width="16" height="16" alt="'. $rsschannels[$i][0] .'" /></a></p>';
}
for ($i = 0; $i < $size; $i++) {
echo '<p><a href="'. $rsschannels[$i][1] .'" title="'. $rsschannels[$i][0] .'"><img src="'. $GLOBALS['root'] .'rss.gif" width="16" height="16" alt="'. $rsschannels[$i][0] .'" /></a></p>';
}
-$userservice =& ServiceFactory::getServiceInstance('UserService');
+$sf = new ServiceFactory();
+$userservice =& $sf->getServiceInstance('UserService');
if ($userservice->isLoggedOn()) {
$cUser = $userservice->getCurrentUser();
$cUsername = $cUser[$userservice->getFieldName('username')];
if ($userservice->isLoggedOn()) {
$cUser = $userservice->getCurrentUser();
$cUsername = $cUser[$userservice->getFieldName('username')];
<link rel="stylesheet" type="text/css" href="<?php echo $GLOBALS['root']; ?>scuttle.css" />
<link rel="stylesheet" type="text/css" href="<?php echo $GLOBALS['root']; ?>jquery-ui-1.8.9.autocomplete.css" />
<?php
<link rel="stylesheet" type="text/css" href="<?php echo $GLOBALS['root']; ?>scuttle.css" />
<link rel="stylesheet" type="text/css" href="<?php echo $GLOBALS['root']; ?>jquery-ui-1.8.9.autocomplete.css" />
<?php
- $size = count($rsschannels);
+ if (isset($rsschannels)) {
+ $size = count($rsschannels);
+ } else {
+ $size = 0;
+ }
for ($i = 0; $i < $size; $i++) {
echo '<link rel="alternate" type="application/rss+xml" title="'. $rsschannels[$i][0] .'" href="'. $rsschannels[$i][1] .'" />';
}
?>
for ($i = 0; $i < $size; $i++) {
echo '<link rel="alternate" type="application/rss+xml" title="'. $rsschannels[$i][0] .'" href="'. $rsschannels[$i][1] .'" />';
}
?>
+ <?php if (isset($loadjs) && $loadjs): ?>
<script type="text/javascript" src="<?php echo $GLOBALS['root']; ?>includes/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="<?php echo $GLOBALS['root']; ?>includes/jquery-ui-1.8.9.autocomplete.min.js"></script>
<script type="text/javascript" src="<?php echo $GLOBALS['root']; ?>jsScuttle.php"></script>
<script type="text/javascript" src="<?php echo $GLOBALS['root']; ?>includes/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="<?php echo $GLOBALS['root']; ?>includes/jquery-ui-1.8.9.autocomplete.min.js"></script>
<script type="text/javascript" src="<?php echo $GLOBALS['root']; ?>jsScuttle.php"></script>
***************************************************************************/
require_once 'header.inc.php';
***************************************************************************/
require_once 'header.inc.php';
-$userservice =& ServiceFactory::getServiceInstance('UserService');
+$sf = new ServiceFactory();
+$userservice =& $sf->getServiceInstance('UserService');
@list($url, $user) = isset($_SERVER['PATH_INFO']) ? explode('/', $_SERVER['PATH_INFO']) : NULL;
if ($userservice->isLoggedOn() && $user) {
@list($url, $user) = isset($_SERVER['PATH_INFO']) ? explode('/', $_SERVER['PATH_INFO']) : NULL;
if ($userservice->isLoggedOn() && $user) {
***************************************************************************/
require_once 'header.inc.php';
***************************************************************************/
require_once 'header.inc.php';
-$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
-$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
-$userservice =& ServiceFactory::getServiceInstance('UserService');
-$cacheservice =& ServiceFactory::getServiceInstance('CacheService');
+$sf = new ServiceFactory();
+$bookmarkservice =& $sf->getServiceInstance('BookmarkService');
+$templateservice =& $sf->getServiceInstance('TemplateService');
+$userservice =& $sf->getServiceInstance('UserService');
+$cacheservice =& $sf->getServiceInstance('CacheService');