From: Benjamin Mako Hill Date: Fri, 21 Jun 2024 06:51:39 +0000 (+1000) Subject: initial patch to cause scuttle to work with PHP 8.2 X-Git-Url: https://projects.mako.cc/source/scuttle/commitdiff_plain/91d3a96bb7741ba92d2d3d7a7dc7d18e0d79688f initial patch to cause scuttle to work with PHP 8.2 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. --- diff --git a/about.php b/about.php index d5b3572..c32df61 100644 --- a/about.php +++ b/about.php @@ -19,7 +19,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ***************************************************************************/ require_once 'header.inc.php'; -$templateservice =& ServiceFactory::getServiceInstance('TemplateService'); +$sf = new ServiceFactory(); +$templateservice =& $sf->getServiceInstance('TemplateService'); $tplVars = array(); $tplVars['subtitle'] = T_('About'); diff --git a/ajaxDelete.php b/ajaxDelete.php index fb99301..0760a8e 100644 --- a/ajaxDelete.php +++ b/ajaxDelete.php @@ -23,7 +23,8 @@ header('Last-Modified: '. gmdate("D, d M Y H:i:s") .' GMT'); 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'); diff --git a/ajaxIsAvailable.php b/ajaxIsAvailable.php index d1a64a3..1971dbd 100644 --- a/ajaxIsAvailable.php +++ b/ajaxIsAvailable.php @@ -23,5 +23,6 @@ header('Last-Modified: '. gmdate("D, d M Y H:i:s") .' GMT'); 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'])); diff --git a/alltags.php b/alltags.php index 331ac59..8423872 100644 --- a/alltags.php +++ b/alltags.php @@ -20,10 +20,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 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) { diff --git a/bookmarks.php b/bookmarks.php index d264531..cbedbfd 100644 --- a/bookmarks.php +++ b/bookmarks.php @@ -20,10 +20,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 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(); @@ -33,6 +34,7 @@ if (isset($_GET['action']) && ($_GET['action'] == "add") && !$userservice->isLog exit(); } +# 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; @@ -147,11 +149,16 @@ if ($templatename == 'editbookmark.tpl') { ); $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']), - 'tags' => ($_GET['tags'] ? explode(',', stripslashes($_GET['tags'])) : array()) + 'tags' => ($raw_tags ? explode(',', stripslashes($raw_tags)) : array()) ); } $title = T_('Add a Bookmark'); @@ -202,7 +209,7 @@ if ($templatename == 'editbookmark.tpl') { $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'); diff --git a/edit.php b/edit.php index fbbc083..0358a4d 100644 --- a/edit.php +++ b/edit.php @@ -20,9 +20,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 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'); diff --git a/history.php b/history.php index 8a31972..d85cd7f 100644 --- a/history.php +++ b/history.php @@ -20,10 +20,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 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(); @@ -86,4 +87,4 @@ if ($usecache) { // Cache output if existing copy has expired $cacheservice->End($cachehash); } -?> \ No newline at end of file +?> diff --git a/import.php b/import.php index 5f0c5ee..9e1cdd4 100644 --- a/import.php +++ b/import.php @@ -20,8 +20,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 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(); @@ -62,8 +63,9 @@ else { 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)) { diff --git a/importNetscape.php b/importNetscape.php index f953ffc..e78acab 100644 --- a/importNetscape.php +++ b/importNetscape.php @@ -20,9 +20,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 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'); $tplVars = array(); diff --git a/index.php b/index.php index 2a9d8ab..6afd72e 100644 --- a/index.php +++ b/index.php @@ -19,10 +19,12 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ***************************************************************************/ 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']) { diff --git a/login.php b/login.php index 38ca360..8e59253 100644 --- a/login.php +++ b/login.php @@ -19,8 +19,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ***************************************************************************/ 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(); diff --git a/password.php b/password.php index fba6f97..b559255 100644 --- a/password.php +++ b/password.php @@ -19,8 +19,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ***************************************************************************/ 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 diff --git a/populartags.php b/populartags.php index 5bda611..37fe285 100644 --- a/populartags.php +++ b/populartags.php @@ -19,10 +19,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ***************************************************************************/ 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']); diff --git a/profile.php b/profile.php index 81be208..a5a137c 100644 --- a/profile.php +++ b/profile.php @@ -19,8 +19,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ***************************************************************************/ require_once 'header.inc.php'; -$templateservice =& ServiceFactory::getServiceInstance('TemplateService'); -$userservice =& ServiceFactory::getServiceInstance('UserService'); +$sf = new ServiceFactory(); +$templateservice =& $sf->getServiceInstance('TemplateService'); +$userservice =& $sf->getServiceInstance('UserService'); $tplVars = array(); diff --git a/register.php b/register.php index e93c2ab..624d4ae 100644 --- a/register.php +++ b/register.php @@ -19,8 +19,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ***************************************************************************/ 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; diff --git a/rss.php b/rss.php index 533bf4c..3f8be6f 100644 --- a/rss.php +++ b/rss.php @@ -20,10 +20,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 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'); diff --git a/search.inc.php b/search.inc.php index 9feaf5c..1121db1 100644 --- a/search.inc.php +++ b/search.inc.php @@ -8,34 +8,34 @@ $currentUsername = $currentUser[$userservice->getFieldName('username')]; $logged_on = TRUE; } - if ($logged_on || isset($user)) { + if (!$logged_on && !isset($user)) { + ?> + + - - - + diff --git a/search.php b/search.php index 1932c28..7420dd2 100644 --- a/search.php +++ b/search.php @@ -27,12 +27,19 @@ if (isset($_POST['terms'])) { // GET } else { - $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(); - 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; diff --git a/services/bookmarkservice.php b/services/bookmarkservice.php index 3d532f6..ab94aa2 100644 --- a/services/bookmarkservice.php +++ b/services/bookmarkservice.php @@ -10,13 +10,13 @@ class BookmarkService { return $instance; } - function BookmarkService(&$db) { + function __construct(&$db) { $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; } @@ -46,7 +46,7 @@ class BookmarkService { 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; @@ -72,7 +72,7 @@ class BookmarkService { 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; @@ -105,7 +105,7 @@ class BookmarkService { // 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 @@ -151,7 +151,7 @@ class BookmarkService { $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); @@ -197,7 +197,7 @@ class BookmarkService { $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); @@ -218,8 +218,8 @@ class BookmarkService { // 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()) { @@ -238,11 +238,12 @@ class BookmarkService { // 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. @@ -312,7 +313,7 @@ class BookmarkService { $aTerms = array_map('trim', $aTerms); // Search terms in tags as well when none given - if (!count($tags)) { + if (isset($tags) && !count($tags)) { $query_2 .= ' LEFT JOIN '. $GLOBALS['tableprefix'] .'tags AS T ON B.bId = T.bId'; $dotags = true; } else { @@ -396,7 +397,7 @@ class BookmarkService { return false; } - $userservice = & ServiceFactory :: getServiceInstance('UserService'); + $userservice = & (new ServiceFactory())->getServiceInstance('UserService'); $sId = $userservice->getCurrentUserId(); if ($userservice->isLoggedOn()) { diff --git a/services/servicefactory.php b/services/servicefactory.php index 987d908..7186b05 100644 --- a/services/servicefactory.php +++ b/services/servicefactory.php @@ -1,11 +1,10 @@ getInstance($db); } return $instances[$name]; } diff --git a/services/tagservice.php b/services/tagservice.php index 9c6c75f..f749f95 100644 --- a/services/tagservice.php +++ b/services/tagservice.php @@ -11,7 +11,7 @@ class TagService { return $instance; } - function TagService(&$db) { + function __construct(&$db) { $this->db =& $db; $this->tablename = $GLOBALS['tableprefix'] .'tags'; } @@ -107,7 +107,7 @@ class TagService { } 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) .'"'; @@ -158,7 +158,7 @@ class TagService { } 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'; @@ -228,7 +228,7 @@ class TagService { // 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()) { @@ -299,7 +299,7 @@ class TagService { } 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; @@ -348,9 +348,8 @@ class TagService { } 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"])); }); } - return $output; } diff --git a/services/templateservice.php b/services/templateservice.php index 1a1719c..6675462 100644 --- a/services/templateservice.php +++ b/services/templateservice.php @@ -10,7 +10,7 @@ class TemplateService { return $instance; } - function TemplateService() { + function __construct() { $this->basedir = $GLOBALS['TEMPLATES_DIR']; } @@ -29,7 +29,7 @@ class Template { 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; diff --git a/services/userservice.php b/services/userservice.php index b55a7df..a4fdbb7 100644 --- a/services/userservice.php +++ b/services/userservice.php @@ -21,7 +21,7 @@ class UserService { 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'; diff --git a/tagdelete.php b/tagdelete.php index 2d76a3c..ec7ecad 100644 --- a/tagdelete.php +++ b/tagdelete.php @@ -19,9 +19,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ***************************************************************************/ 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']); @@ -44,4 +45,4 @@ $tplVars['subtitle'] = T_('Delete Tag') .': '. $tag; $tplVars['formaction'] = $_SERVER['SCRIPT_NAME'] .'/'. $tag; $tplVars['referrer'] = $_SERVER['HTTP_REFERER']; $templateservice->loadTemplate('tagdelete.tpl', $tplVars); -?> \ No newline at end of file +?> diff --git a/tagrename.php b/tagrename.php index 87163b0..dc3abb9 100644 --- a/tagrename.php +++ b/tagrename.php @@ -19,9 +19,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ***************************************************************************/ 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']); diff --git a/tags.php b/tags.php index be35861..47899b3 100644 --- a/tags.php +++ b/tags.php @@ -20,10 +20,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 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(); diff --git a/templates/bookmarks.tpl.php b/templates/bookmarks.tpl.php index fa40561..743a7c2 100644 --- a/templates/bookmarks.tpl.php +++ b/templates/bookmarks.tpl.php @@ -1,10 +1,22 @@ getServiceInstance('UserService'); +$bookmarkservice =& $sf->getServiceInstance('BookmarkService'); $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) { ?> diff --git a/templates/dynamictags.inc.php b/templates/dynamictags.inc.php index d7f094a..a4fd3f4 100644 --- a/templates/dynamictags.inc.php +++ b/templates/dynamictags.inc.php @@ -18,8 +18,9 @@ along with this program; if not, write to the Free Software 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(); diff --git a/templates/editbookmark.tpl.php b/templates/editbookmark.tpl.php index 2304134..358b239 100644 --- a/templates/editbookmark.tpl.php +++ b/templates/editbookmark.tpl.php @@ -4,16 +4,19 @@ $this->includeTemplate($GLOBALS['top_include']); $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; + } } ?> @@ -36,7 +39,7 @@ switch ($row['bStatus']) { - + @@ -54,12 +57,12 @@ switch ($row['bStatus']) { - + - + @@ -78,7 +81,7 @@ $(function() { $this->includeTemplate('dynamictags.inc'); // Bookmarklets and import links -if (empty($_REQUEST['popup']) && !$showdelete) { +if (empty($_REQUEST['popup']) && (!isset($showdelete) || !$showdelete)) { ?>

diff --git a/templates/profile.tpl.php b/templates/profile.tpl.php index e9ff91b..0d93c99 100644 --- a/templates/profile.tpl.php +++ b/templates/profile.tpl.php @@ -1,5 +1,6 @@ getServiceInstance('UserService'); $this->includeTemplate($GLOBALS['top_include']); ?> diff --git a/templates/sidebar.block.common.php b/templates/sidebar.block.common.php index 205ca1e..f3a30e1 100644 --- a/templates/sidebar.block.common.php +++ b/templates/sidebar.block.common.php @@ -1,5 +1,6 @@ getServiceInstance('TagService'); $commonTags =& $tagservice->getRelatedTagsByHash($hash); $commonTags =& $tagservice->tagCloud($commonTags, 5, 90, 225, 'alphabet_asc'); diff --git a/templates/sidebar.block.popular.php b/templates/sidebar.block.popular.php index fc9703d..05b73ad 100644 --- a/templates/sidebar.block.popular.php +++ b/templates/sidebar.block.popular.php @@ -1,11 +1,18 @@ getServiceInstance('TagService'); +$userservice =& $sf->getServiceInstance('UserService'); $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'); diff --git a/templates/sidebar.block.profile.php b/templates/sidebar.block.profile.php index 1b8e915..f4b8a2f 100644 --- a/templates/sidebar.block.profile.php +++ b/templates/sidebar.block.profile.php @@ -1,5 +1,6 @@ getServiceInstance('UserService'); if (utf8_strlen($userinfo['name']) > 0) { $name = $userinfo['name']; } else { diff --git a/templates/sidebar.block.recent.php b/templates/sidebar.block.recent.php index f489e49..1afcb0d 100644 --- a/templates/sidebar.block.recent.php +++ b/templates/sidebar.block.recent.php @@ -1,11 +1,17 @@ getServiceInstance('TagService'); +$userservice =& $sf->getServiceInstance('UserService'); $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'); diff --git a/templates/sidebar.block.related.php b/templates/sidebar.block.related.php index 3a37718..15af8bf 100644 --- a/templates/sidebar.block.related.php +++ b/templates/sidebar.block.related.php @@ -1,11 +1,18 @@ getServiceInstance('TagService'); +$userservice =& $sf->getServiceInstance('UserService'); $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) { @@ -18,6 +25,7 @@ if ($currenttag) { + + @@ -26,4 +34,4 @@ if ($currenttag) { \ No newline at end of file +?> diff --git a/templates/sidebar.block.tagactions.php b/templates/sidebar.block.tagactions.php index 836c40c..07bb201 100644 --- a/templates/sidebar.block.tagactions.php +++ b/templates/sidebar.block.tagactions.php @@ -1,5 +1,6 @@ getServiceInstance('UserService'); if ($userservice->isLoggedOn()) { $currentUser = $userservice->getCurrentUser(); $currentUsername = $currentUser[$userservice->getFieldName('username')]; diff --git a/templates/sidebar.block.watchlist.php b/templates/sidebar.block.watchlist.php index e35fa76..38bb389 100644 --- a/templates/sidebar.block.watchlist.php +++ b/templates/sidebar.block.watchlist.php @@ -1,5 +1,6 @@ getServiceInstance('UserService'); $watching = $userservice->getWatchNames($userid); if ($watching) { diff --git a/templates/sidebar.block.watchstatus.php b/templates/sidebar.block.watchstatus.php index d912846..6349fc6 100644 --- a/templates/sidebar.block.watchstatus.php +++ b/templates/sidebar.block.watchstatus.php @@ -1,5 +1,6 @@ getServiceInstance('UserService'); if ($userservice->isLoggedOn()) { $currentUser = $userservice->getCurrentUser(); $currentUsername = $currentUser[$userservice->getFieldName('username')]; diff --git a/templates/sidebar.tpl.php b/templates/sidebar.tpl.php index 5f399b5..1aed4b3 100644 --- a/templates/sidebar.tpl.php +++ b/templates/sidebar.tpl.php @@ -5,7 +5,11 @@ $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 '

'. $rsschannels[$i][0] .'

'; } diff --git a/templates/toolbar.inc.php b/templates/toolbar.inc.php index 023ed3b..37193fd 100644 --- a/templates/toolbar.inc.php +++ b/templates/toolbar.inc.php @@ -1,5 +1,6 @@ getServiceInstance('UserService'); if ($userservice->isLoggedOn()) { $cUser = $userservice->getCurrentUser(); $cUsername = $cUser[$userservice->getFieldName('username')]; diff --git a/templates/top.inc.php b/templates/top.inc.php index 6a1bdb8..a881f56 100644 --- a/templates/top.inc.php +++ b/templates/top.inc.php @@ -8,12 +8,16 @@ '; } ?> - + diff --git a/watch.php b/watch.php index cfd7cee..47de138 100644 --- a/watch.php +++ b/watch.php @@ -19,7 +19,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ***************************************************************************/ 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) { diff --git a/watchlist.php b/watchlist.php index 3ecc79c..d16f989 100644 --- a/watchlist.php +++ b/watchlist.php @@ -19,10 +19,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ***************************************************************************/ 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();