summaryrefslogtreecommitdiff
path: root/inc/common.php
diff options
context:
space:
mode:
authorGerrit Uitslag <klapinklapin@gmail.com>2013-11-19 21:26:50 +0100
committerGerrit Uitslag <klapinklapin@gmail.com>2013-11-19 21:26:50 +0100
commit703aeaef1a43b07dc5497dba72c98151466396cc (patch)
tree1e18a6b3fc3c28156c2e56f8a3d515b8dd6a9cf9 /inc/common.php
parent33c3b3817b00aa9384760813643fac0e33daaaff (diff)
parent14b3007921f7b66fc9e3621b861a3c83e7e9093c (diff)
downloadrpg-703aeaef1a43b07dc5497dba72c98151466396cc.tar.gz
rpg-703aeaef1a43b07dc5497dba72c98151466396cc.tar.bz2
Merge remote-tracking branch 'origin/master' into diff_navigation
Diffstat (limited to 'inc/common.php')
-rw-r--r--inc/common.php30
1 files changed, 13 insertions, 17 deletions
diff --git a/inc/common.php b/inc/common.php
index 1b4d9e8e4..32771285b 100644
--- a/inc/common.php
+++ b/inc/common.php
@@ -64,7 +64,7 @@ function getSecurityToken() {
*/
function checkSecurityToken($token = null) {
global $INPUT;
- if(!$_SERVER['REMOTE_USER']) return true; // no logged in user, no need for a check
+ if(empty($_SERVER['REMOTE_USER'])) return true; // no logged in user, no need for a check
if(is_null($token)) $token = $INPUT->str('sectok');
if(getSecurityToken() != $token) {
@@ -148,7 +148,7 @@ function pageinfo() {
$info['id'] = $ID;
$info['rev'] = $REV;
- if(isset($_SERVER['REMOTE_USER'])) {
+ if(isset($_SERVER['REMOTE_USER'])) {
$sub = new Subscription();
$info['subscribed'] = $sub->user_subscription();
} else {
@@ -474,23 +474,24 @@ function ml($id = '', $more = '', $direct = true, $sep = '&amp;', $abs = false)
if(is_array($more)) {
// add token for resized images
- if($more['w'] || $more['h']){
+ if(!empty($more['w']) || !empty($more['h']) || $isexternalimage){
$more['tok'] = media_get_token($id,$more['w'],$more['h']);
}
// strip defaults for shorter URLs
if(isset($more['cache']) && $more['cache'] == 'cache') unset($more['cache']);
- if(!$more['w']) unset($more['w']);
- if(!$more['h']) unset($more['h']);
+ if(empty($more['w'])) unset($more['w']);
+ if(empty($more['h'])) unset($more['h']);
if(isset($more['id']) && $direct) unset($more['id']);
$more = buildURLparams($more, $sep);
} else {
$matches = array();
- if (preg_match_all('/\b(w|h)=(\d*)\b/',$more,$matches,PREG_SET_ORDER)){
+ if (preg_match_all('/\b(w|h)=(\d*)\b/',$more,$matches,PREG_SET_ORDER) || $isexternalimage){
$resize = array('w'=>0, 'h'=>0);
foreach ($matches as $match){
$resize[$match[1]] = $match[2];
}
- $more .= $sep.'tok='.media_get_token($id,$resize['w'],$resize['h']);
+ $more .= $more === '' ? '' : $sep;
+ $more .= 'tok='.media_get_token($id,$resize['w'],$resize['h']);
}
$more = str_replace('cache=cache', '', $more); //skip default
$more = str_replace(',,', ',', $more);
@@ -506,14 +507,8 @@ function ml($id = '', $more = '', $direct = true, $sep = '&amp;', $abs = false)
// external URLs are always direct without rewriting
if($isexternalimage) {
$xlink .= 'lib/exe/fetch.php';
- // add hash:
- $xlink .= '?hash='.substr(PassHash::hmac('md5', $id, auth_cookiesalt()), 0, 6);
- if($more) {
- $xlink .= $sep.$more;
- $xlink .= $sep.'media='.rawurlencode($id);
- } else {
- $xlink .= $sep.'media='.rawurlencode($id);
- }
+ $xlink .= '?'.$more;
+ $xlink .= $sep.'media='.rawurlencode($id);
return $xlink;
}
@@ -1130,7 +1125,7 @@ function saveWikiText($id, $text, $summary, $minor = false) {
// if useheading is enabled, purge the cache of all linking pages
if(useHeading('content')) {
- $pages = ft_backlinks($id);
+ $pages = ft_backlinks($id, true);
foreach($pages as $page) {
$cache = new cache_renderer($page, wikiFN($page), 'xhtml');
$cache->removeCache();
@@ -1630,7 +1625,8 @@ function set_doku_pref($pref, $val) {
}
if (!empty($cookieVal)) {
- setcookie('DOKU_PREFS', $cookieVal, time()+365*24*3600, DOKU_BASE, '', ($conf['securecookie'] && is_ssl()));
+ $cookieDir = empty($conf['cookiedir']) ? DOKU_REL : $conf['cookiedir'];
+ setcookie('DOKU_PREFS', $cookieVal, time()+365*24*3600, $cookieDir, '', ($conf['securecookie'] && is_ssl()));
}
}