From 996909f7b914113d00098b4ccf7ab5fba072dd3f Mon Sep 17 00:00:00 2001 From: querwurzelt <> Date: Sun, 20 Jan 2019 22:19:33 +0100 Subject: [PATCH] PHP 7.3 compat, bug fixes --- cache/.gitignore | 1 + cache/.htaccess | 3 +-- data/config.default.php | 6 +++--- data/schema/2.sql | 2 +- data/tables.sql | 4 ++-- data/templates/default/dynamictags.inc.php | 2 +- data/templates/default/sidebar.block.popular.php | 2 +- data/templates/default/sidebar.block.recent.php | 2 +- data/templates/default/tags.tpl.php | 2 +- src/SemanticScuttle/Service/Bookmark.php | 6 +++--- src/SemanticScuttle/Service/Bookmark2Tag.php | 10 +++++++--- www/.htaccess | 2 +- 12 files changed, 23 insertions(+), 19 deletions(-) create mode 100644 cache/.gitignore diff --git a/cache/.gitignore b/cache/.gitignore new file mode 100644 index 00000000..f05fcdc1 --- /dev/null +++ b/cache/.gitignore @@ -0,0 +1 @@ +*.cache \ No newline at end of file diff --git a/cache/.htaccess b/cache/.htaccess index baa56e5a..b66e8088 100644 --- a/cache/.htaccess +++ b/cache/.htaccess @@ -1,2 +1 @@ -order allow,deny -deny from all \ No newline at end of file +Require all denied diff --git a/data/config.default.php b/data/config.default.php index 8af04ba9..bb9eddb7 100644 --- a/data/config.default.php +++ b/data/config.default.php @@ -115,7 +115,7 @@ * * @var string */ -$dir_cache = dirname(__FILE__) . '/cache/'; +$dir_cache = dirname(__DIR__, 1) . '/cache'; /** * Use clean urls without .php filenames. @@ -149,14 +149,14 @@ * * @var string */ -$dbtype = 'mysql4'; +$dbtype = 'mysqli'; /** * Database hostname/IP * * @var string */ -$dbhost = '127.0.0.1'; +$dbhost = 'localhost'; /** * Database port. diff --git a/data/schema/2.sql b/data/schema/2.sql index 6c3bfaf7..171e0115 100644 --- a/data/schema/2.sql +++ b/data/schema/2.sql @@ -1,4 +1,4 @@ -ALTER TABLE `sc_bookmarks` CHANGE `bDescription` `bDescription` VARCHAR( 1500 ) +ALTER TABLE `sc_bookmarks` CHANGE `bDescription` `bDescription` VARCHAR( 1500 ); CREATE TABLE `sc_tagscache` ( `tcId` int(11) NOT NULL auto_increment, `tag1` varchar(100) NOT NULL default '', diff --git a/data/tables.sql b/data/tables.sql index 68d5ba97..523e5ffa 100644 --- a/data/tables.sql +++ b/data/tables.sql @@ -17,8 +17,8 @@ CREATE TABLE `sc_bookmarks` ( `bDescription` text default NULL, `bPrivateNote` text default NULL, `bHash` varchar(32) NOT NULL default '', - `bVotes` int(11) NOT NULL, - `bVoting` int(11) NOT NULL, + `bVotes` int(11) NOT NULL default '0', + `bVoting` int(11) NOT NULL default '0', `bShort` varchar(16) default NULL, PRIMARY KEY (`bId`), KEY `sc_bookmarks_usd` (`uId`,`bStatus`,`bDatetime`), diff --git a/data/templates/default/dynamictags.inc.php b/data/templates/default/dynamictags.inc.php index c2ab6d4e..f7310486 100644 --- a/data/templates/default/dynamictags.inc.php +++ b/data/templates/default/dynamictags.inc.php @@ -53,7 +53,7 @@ function writeTagsProposition($tagsCloud, $title) $taglist = ''; foreach (array_keys($tagsCloud) as $key) { $row = $tagsCloud[$key]; - $entries = T_ngettext('bookmark', 'bookmarks', $row['bCount']); + $entries = T_ngettext('bookmark', 'bookmarks', (int)$row['bCount']); $taglist .= ''. filter($row['tag']) .' '; } echo $contents ."\n"; diff --git a/data/templates/default/sidebar.block.recent.php b/data/templates/default/sidebar.block.recent.php index 80ae71c9..1deae27e 100644 --- a/data/templates/default/sidebar.block.recent.php +++ b/data/templates/default/sidebar.block.recent.php @@ -26,7 +26,7 @@ } foreach ($recentTags as $row) { - $entries = T_ngettext('bookmark', 'bookmarks', $row['bCount']); + $entries = T_ngettext('bookmark', 'bookmarks', (int)$row['bCount']); $contents .= ''. filter($row['tag']) .' '; } echo $contents ."
\n"; diff --git a/data/templates/default/tags.tpl.php b/data/templates/default/tags.tpl.php index d6259cc8..dce5e1c3 100644 --- a/data/templates/default/tags.tpl.php +++ b/data/templates/default/tags.tpl.php @@ -16,7 +16,7 @@ '. filter($row['tag']) .' '; } echo $contents ."\n"; diff --git a/src/SemanticScuttle/Service/Bookmark.php b/src/SemanticScuttle/Service/Bookmark.php index 13153503..39ec4f08 100644 --- a/src/SemanticScuttle/Service/Bookmark.php +++ b/src/SemanticScuttle/Service/Bookmark.php @@ -734,7 +734,7 @@ public function getBookmarks( $tags = explode('+', trim($tags)); } - $tagcount = count($tags); + $tagcount = empty($tags) ? 0 : count($tags); for ($i = 0; $i < $tagcount; $i ++) { $tags[$i] = trim($tags[$i]); } @@ -853,7 +853,7 @@ public function getBookmarks( $aTerms = array_map('trim', $aTerms); // Search terms in tags as well when none given - if (!count($tags)) { + if (!empty($tags)) { $query_2 .= ' LEFT JOIN '. $b2tservice->getTableName() .' AS T' . ' ON B.bId = T.bId'; $dotags = true; @@ -1136,7 +1136,7 @@ public function normalize($address) // Delete final / if (substr($address, -1) == '/') { - $address = substr($address, 0, count($address)-2); + $address = substr($address, 0, strlen($address)-2); } return $address; diff --git a/src/SemanticScuttle/Service/Bookmark2Tag.php b/src/SemanticScuttle/Service/Bookmark2Tag.php index a01b5d70..25790228 100644 --- a/src/SemanticScuttle/Service/Bookmark2Tag.php +++ b/src/SemanticScuttle/Service/Bookmark2Tag.php @@ -691,14 +691,12 @@ function &tagCloud($tags = NULL, $steps = 5, $sizemin = 90, $sizemax = 225, $sor } if ($sortOrder == 'alphabet_asc') { - usort($output, create_function('$a,$b','return strcasecmp(utf8_deaccent($a["tag"]), utf8_deaccent($b["tag"]));')); + usort($output, "cmp"); } return $output; } - - /** * Deletes all tags in bookmarks2tags * @@ -711,4 +709,10 @@ public function deleteAll() } } + +function cmp($a,$b) +{ + return strcasecmp(utf8_deaccent($a["tag"]), utf8_deaccent($b["tag"])); +} + ?> diff --git a/www/.htaccess b/www/.htaccess index 563fe53f..65447f58 100644 --- a/www/.htaccess +++ b/www/.htaccess @@ -6,7 +6,7 @@ # Rewrite clean URLs onto real files