diff options
author | Christian Weiske <cweiske@cweiske.de> | 2012-01-20 14:52:36 +0100 |
---|---|---|
committer | Christian Weiske <cweiske@cweiske.de> | 2012-01-20 14:52:36 +0100 |
commit | 728d642563be526d84921c73825f4087dcb1b044 (patch) | |
tree | 3b7a8d7db0c141bb7627b7948984d1a0d5bf36fc | |
parent | 79d1e2de1097bb73b2cc1e7d0190a6c2bc05268d (diff) | |
download | semanticscuttle-728d642563be526d84921c73825f4087dcb1b044.tar.gz semanticscuttle-728d642563be526d84921c73825f4087dcb1b044.tar.bz2 |
Part of bug #3463481: Add HTTP protocol to self URL in feed
-rw-r--r-- | src/SemanticScuttle/functions.php | 25 | ||||
-rw-r--r-- | www/rss.php | 2 |
2 files changed, 26 insertions, 1 deletions
diff --git a/src/SemanticScuttle/functions.php b/src/SemanticScuttle/functions.php index 84e9c5f..09f7cf3 100644 --- a/src/SemanticScuttle/functions.php +++ b/src/SemanticScuttle/functions.php @@ -118,6 +118,31 @@ function createURL($page = '', $ending = '') { return ROOT . $page; } } + +/** + * Adds the protocol to the URL if it's missing. + * If the current URL is served via HTTPS, https will be used as protocol. + * + * Useful to fix ROOT urls of SemanticScuttle when it's needed, e.g. + * in the bookmarklet or the feed. + * + * @param string $url Url with or without the protocol ("//example.org/foo") + * + * @return string URL with a HTTP protocol + */ +function addProtocolToUrl($url) +{ + if (substr($url, 0, 2) != '//') { + return $url; + } + + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']) { + $protocol = 'https:'; + } else { + $protocol = 'http:'; + } + return $protocol . $url; +} /** * Creates a "vote for/against this bookmark" URL. * Also runs htmlspecialchars() on them to prevent XSS. diff --git a/www/rss.php b/www/rss.php index d888726..46c0ffd 100644 --- a/www/rss.php +++ b/www/rss.php @@ -124,7 +124,7 @@ if ($cat) { } $tplVars['feedtitle'] = filter($GLOBALS['sitename'] . (isset($pagetitle) ? $pagetitle : '')); -$tplVars['feedlink'] = ROOT; +$tplVars['feedlink'] = addProtocolToUrl(ROOT); $tplVars['feeddescription'] = sprintf(T_('Recent bookmarks posted to %s'), $GLOBALS['sitename']); $bookmarks = $bookmarkservice->getBookmarks( |