From 295523457fdc982b9ef2dc96aa454d27e9e8174d Mon Sep 17 00:00:00 2001 From: Jari Turkia Date: Mon, 3 Jun 2024 21:52:50 +0300 Subject: [PATCH 1/4] bugfix: When not adding tracking counters, return a proper link --- .../serendipity_event_google_analytics.php | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/serendipity_event_google_analytics/serendipity_event_google_analytics.php b/serendipity_event_google_analytics/serendipity_event_google_analytics.php index c27596733..8e6666eb8 100644 --- a/serendipity_event_google_analytics/serendipity_event_google_analytics.php +++ b/serendipity_event_google_analytics/serendipity_event_google_analytics.php @@ -154,7 +154,7 @@ function gtag() { !$markupDisabledConfig && !$markupDisabledPost) { $element = $element['element']; $eventData[$element] = preg_replace_callback( - "#]*)>#isUm", + "#]*)>#isUm", array($this, 'analytics_tracker_callback'), $eventData[$element] ); @@ -162,21 +162,32 @@ function gtag() { } return true; - default : + default: return false; } // end switch ($event) { } + /** + * matches: + * 0 = entire regexp match + * 1 = anything between "" + */ function analytics_tracker_callback($matches) { - $parsed_url = parse_url($matches[3].$matches[4]); + $parsed_url = parse_url($matches[2].$matches[3]); + + // Skip tracking for local URLs without scheme, or unknown scheme. if (!isset($parsed_url["scheme"])) - return; + return $matches[0]; if (!in_array($parsed_url["scheme"], array("http", "https"))) - return; + return $matches[0]; + // Note: Assume, there is no second onclick-event in substr($matches[0], 2) return ' Date: Sun, 13 Oct 2024 21:20:46 +0300 Subject: [PATCH 2/4] bugfix: Make plugins work on PHP 8.2 with no dynamic properties --- .../serendipity_event_google_analytics.php | 1 + .../serendipity_plugin_userprofiles.php | 5 +++-- .../serendipity_plugin_userprofiles_birthdays.php | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/serendipity_event_google_analytics/serendipity_event_google_analytics.php b/serendipity_event_google_analytics/serendipity_event_google_analytics.php index 8e6666eb8..d30a18098 100644 --- a/serendipity_event_google_analytics/serendipity_event_google_analytics.php +++ b/serendipity_event_google_analytics/serendipity_event_google_analytics.php @@ -8,6 +8,7 @@ class serendipity_event_google_analytics extends serendipity_event { var $title = PLUGIN_EVENT_GOOGLE_ANALYTICS_NAME; + protected $markup_elements = array(); // Docs: // - Install Google Tag Manager for web pages: https://developers.google.com/tag-platform/tag-manager/web diff --git a/serendipity_event_userprofiles/serendipity_plugin_userprofiles.php b/serendipity_event_userprofiles/serendipity_plugin_userprofiles.php index b983f8a0e..649f3fb57 100644 --- a/serendipity_event_userprofiles/serendipity_plugin_userprofiles.php +++ b/serendipity_event_userprofiles/serendipity_plugin_userprofiles.php @@ -1,6 +1,6 @@ add('name', PLUGIN_USERPROFILES_NAME); $propbag->add('description', PLUGIN_USERPROFILES_NAME_DESC); - $propbag->add('author', "Falk Döring"); + $propbag->add('author', "Falk D�ring"); $propbag->add('stackable', false); $propbag->add('version', '1.2.2'); $propbag->add('configuration', array('title', 'show_groups', 'show_users')); diff --git a/serendipity_event_userprofiles/serendipity_plugin_userprofiles_birthdays.php b/serendipity_event_userprofiles/serendipity_plugin_userprofiles_birthdays.php index 4ef348843..f894547ff 100644 --- a/serendipity_event_userprofiles/serendipity_plugin_userprofiles_birthdays.php +++ b/serendipity_event_userprofiles/serendipity_plugin_userprofiles_birthdays.php @@ -8,6 +8,7 @@ @serendipity_plugin_api::load_language(dirname(__FILE__)); class serendipity_plugin_userprofiles_birthdays extends serendipity_plugin { + protected $dependencies = array(); function introspect(&$propbag) { $propbag->add('name', PLUGIN_USERPROFILES_BIRTHDAYSNAME); From b13fdcc22dcf40e6fa41e335009b7c3a155438f9 Mon Sep 17 00:00:00 2001 From: Jari Turkia Date: Sun, 13 Oct 2024 21:22:59 +0300 Subject: [PATCH 3/4] bugfix: Calculating most recent timestamp properly for Google Sitemap XML-output --- .../serendipity_event_google_sitemap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/serendipity_event_google_sitemap/serendipity_event_google_sitemap.php b/serendipity_event_google_sitemap/serendipity_event_google_sitemap.php index 49433a01f..461a8046a 100644 --- a/serendipity_event_google_sitemap/serendipity_event_google_sitemap.php +++ b/serendipity_event_google_sitemap/serendipity_event_google_sitemap.php @@ -308,7 +308,7 @@ function add_entries(&$sitemap_xml, $limit = 0) { // add entries foreach($entries as $entry) { - $max = max($entry['timestamp_1']+0, $entry['timestamp_2']+0); + $max = max(intval($entry['timestamp_1']), intval($entry['timestamp_2'])); $url = serendipity_archiveURL($entry['id'], $entry['title']); $props = serendipity_fetchEntryProperties($entry['id']); $props['title'] = $entry['title']; From 79499928caaf5241de30d851fe454a7a73b09193 Mon Sep 17 00:00:00 2001 From: Jari Turkia Date: Mon, 14 Oct 2024 21:53:35 +0300 Subject: [PATCH 4/4] feat: Made user profiles -plugin work with PHP 8.2 --- .../serendipity_event_userprofiles.php | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/serendipity_event_userprofiles/serendipity_event_userprofiles.php b/serendipity_event_userprofiles/serendipity_event_userprofiles.php index d8beef57b..edfa1a974 100755 --- a/serendipity_event_userprofiles/serendipity_event_userprofiles.php +++ b/serendipity_event_userprofiles/serendipity_event_userprofiles.php @@ -169,7 +169,7 @@ function introspect_config_item($name, &$propbag) } function &getLocalProperties() { - return array( + $props = array( 'realname' => array('desc' => USERCONF_REALNAME, 'type' => 'string'), 'username' => array('desc' => USERCONF_USERNAME, @@ -177,6 +177,7 @@ function &getLocalProperties() { 'email' => array('desc' => USERCONF_EMAIL, 'type' => 'string') ); + return $props; } function getShow($type, $user) { @@ -315,7 +316,7 @@ function show() { function selected() { global $serendipity; - if ($serendipity['GET']['subpage'] == 'userprofiles') { + if (isset($serendipity['GET']['subpage']) && $serendipity['GET']['subpage'] == 'userprofiles') { return true; } @@ -417,7 +418,7 @@ function editUser(&$user) { $this->updateConfigVar($property, $profile, $user[$property], $user['authorid']); $profile[$property] = $user[$property]; } else { - $user[$property] = $profile[$property]; + $user[$property] = $profile[$property] ?? null; } $this->showCol($property, $info, $user); @@ -442,7 +443,7 @@ function editOptions(&$user) { $this->updateConfigVar($property, $profile, $user[$property], $user['authorid']); $profile[$property] = $user[$property]; } else { - $user[$property] = $profile[$property]; + $user[$property] = $profile[$property] ?? null; } $this->showCol($property, $info, $user); @@ -538,12 +539,19 @@ function event_hook($event, &$bag, &$eventData, $addData = null) { if (!$tfile) { $tfile = dirname(__FILE__) . '/plugin_userprofile.tpl'; } - $inclusion = $serendipity['smarty']->security_settings['INCLUDE_ANY']; - $serendipity['smarty']->security_settings['INCLUDE_ANY'] = true; + if ($serendipity['smarty']->security_settings) { + $inclusion = $serendipity['smarty']->security_settings['INCLUDE_ANY']; + $serendipity['smarty']->security_settings['INCLUDE_ANY'] = true; + } $profile = $this->getConfigVars($serendipity['GET']['viewAuthor']); $local_properties =& $this->getLocalProperties(); foreach($local_properties as $property => $info) { - $profile[$property] = $GLOBALS['uInfo'][0][$property]; + if (isset($GLOBALS['uInfo'])) { + $profile[$property] = $GLOBALS['uInfo'][0][$property]; + } + else { + $profile[$property] = null; + } } $properties = array(); @@ -559,7 +567,9 @@ function event_hook($event, &$bag, &$eventData, $addData = null) { $serendipity['smarty']->assign('userProfileTitle', PLUGIN_EVENT_USERPROFILES_SHOW); $content = $serendipity['smarty']->fetch('file:'. $tfile); - $serendipity['smarty']->security_settings['INCLUDE_ANY'] = $inclusion; + if ($serendipity['smarty']->security_settings) { + $serendipity['smarty']->security_settings['INCLUDE_ANY'] = $inclusion; + } echo $content; } @@ -619,6 +629,9 @@ function event_hook($event, &$bag, &$eventData, $addData = null) { return true; } + if (!isset($eventData['authorid'])) { + return true; + } if (empty($eventData['author'])) { $tmp = serendipity_fetchAuthor($eventData['authorid']); $author = $tmp[0]['realname'];