Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: Google Sitemap timestamp calculation #168

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -154,29 +155,40 @@ function gtag() {
!$markupDisabledConfig && !$markupDisabledPost) {
$element = $element['element'];
$eventData[$element] = preg_replace_callback(
"#<a (.*)href=(\"|')(http://|https://|)([^\"']+)(\"|')([^>]*)>#isUm",
"#<a\\s+(.*)href\\s*=\\s*[\"|'](http://|https://|)([^\"']*)[\"|']([^>]*)>#isUm",
array($this, 'analytics_tracker_callback'),
$eventData[$element]
);
}
}
return true;

default :
default:
return false;
} // end switch ($event) {
}

/**
* matches:
* 0 = entire regexp match
* 1 = anything between "<a" and "href"
* 2 = scheme
* 3 = address
* 4 = anything after "href" and ">"
*/
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 '<a onclick="_gaq.push([\'_trackPageview\', \'/extlink/' .
(function_exists('serendipity_specialchars') ? serendipity_specialchars($matches[4]) : htmlspecialchars($matches[4], ENT_COMPAT, LANG_CHARSET)) .
(function_exists('serendipity_specialchars') ? serendipity_specialchars($matches[3]) : htmlspecialchars($matches[3], ENT_COMPAT, LANG_CHARSET)) .
'\']);" ' . substr($matches[0], 2);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down
29 changes: 21 additions & 8 deletions serendipity_event_userprofiles/serendipity_event_userprofiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,15 @@ function introspect_config_item($name, &$propbag)
}

function &getLocalProperties() {
return array(
$props = array(
'realname' => array('desc' => USERCONF_REALNAME,
'type' => 'string'),
'username' => array('desc' => USERCONF_USERNAME,
'type' => 'string'),
'email' => array('desc' => USERCONF_EMAIL,
'type' => 'string')
);
return $props;
}

function getShow($type, $user) {
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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();
Expand All @@ -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;
}
Expand Down Expand Up @@ -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'];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php #

# (c) by Falk D�ring
# (c) by Falk D�ring


if (IN_serendipity !== true) {
Expand All @@ -10,11 +10,12 @@
@serendipity_plugin_api::load_language(dirname(__FILE__));

class serendipity_plugin_userprofiles extends serendipity_plugin {
protected $dependencies = array();

function introspect(&$propbag) {
$propbag->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'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down