From 1015a57dff9a6f85b8e0534d280aa1e09945a598 Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Sat, 16 Feb 2013 21:08:09 +0000 Subject: FS#2415 add to mediamanager (refactor pageinfo() and shift MEDIAMANAGER_STARTED after mediainfo() sets up ) --- inc/common.php | 68 ++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 47 insertions(+), 21 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 28b527633..d4265f78c 100644 --- a/inc/common.php +++ b/inc/common.php @@ -86,32 +86,20 @@ function formSecurityToken($print = true) { } /** - * Return info about the current document as associative - * array. + * Determine basic information for a request of $id * - * @author Andreas Gohr + * @param unknown_type $id + * @param unknown_type $httpClient */ -function pageinfo() { - global $ID; - global $REV; - global $RANGE; +function basicinfo($id, $htmlClient=true){ global $USERINFO; - global $lang; - - // include ID & REV not redundant, as some parts of DokuWiki may temporarily change $ID, e.g. p_wiki_xhtml - // FIXME ... perhaps it would be better to ensure the temporary changes weren't necessary - $info['id'] = $ID; - $info['rev'] = $REV; // set info about manager/admin status. $info['isadmin'] = false; $info['ismanager'] = false; if(isset($_SERVER['REMOTE_USER'])) { - $sub = new Subscription(); - $info['userinfo'] = $USERINFO; - $info['perm'] = auth_quickaclcheck($ID); - $info['subscribed'] = $sub->user_subscription(); + $info['perm'] = auth_quickaclcheck($id); $info['client'] = $_SERVER['REMOTE_USER']; if($info['perm'] == AUTH_ADMIN) { @@ -127,12 +115,40 @@ function pageinfo() { } } else { - $info['perm'] = auth_aclcheck($ID, '', null); + $info['perm'] = auth_aclcheck($id, '', null); $info['subscribed'] = false; $info['client'] = clientIP(true); } - $info['namespace'] = getNS($ID); + $info['namespace'] = getNS($id); + + // mobile detection + if ($htmlClient) { + $info['ismobile'] = clientismobile(); + } + + return $info; + } + +/** + * Return info about the current document as associative + * array. + * + * @author Andreas Gohr + */ +function pageinfo() { + global $ID; + global $REV; + global $RANGE; + global $lang; + + $info = basicinfo($ID); + + // include ID & REV not redundant, as some parts of DokuWiki may temporarily change $ID, e.g. p_wiki_xhtml + // FIXME ... perhaps it would be better to ensure the temporary changes weren't necessary + $info['id'] = $ID; + $info['rev'] = $REV; + $info['locked'] = checklock($ID); $info['filepath'] = fullpath(wikiFN($ID)); $info['exists'] = @file_exists($info['filepath']); @@ -210,8 +226,18 @@ function pageinfo() { } } - // mobile detection - $info['ismobile'] = clientismobile(); + return $info; +} + +/** + * Return information about the current media item as an associative array. + */ +function mediainfo(){ + global $NS; + global $IMG; + + $info = basicinfo("$NS:*"); + $info['image'] = $IMG; return $info; } -- cgit v1.2.3 From 7e87a794494ea987ebc31decd939a25d44a5c00d Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Sun, 17 Feb 2013 20:03:38 +0000 Subject: fix missing 'subscribed' key --- inc/common.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index d4265f78c..5c28cf9c3 100644 --- a/inc/common.php +++ b/inc/common.php @@ -88,8 +88,8 @@ function formSecurityToken($print = true) { /** * Determine basic information for a request of $id * - * @param unknown_type $id - * @param unknown_type $httpClient + * @author Andreas Gohr + * @author Chris Smith */ function basicinfo($id, $htmlClient=true){ global $USERINFO; @@ -116,7 +116,6 @@ function basicinfo($id, $htmlClient=true){ } else { $info['perm'] = auth_aclcheck($id, '', null); - $info['subscribed'] = false; $info['client'] = clientIP(true); } @@ -149,6 +148,13 @@ function pageinfo() { $info['id'] = $ID; $info['rev'] = $REV; + if(isset($_SERVER['REMOTE_USER'])) { + $sub = new Subscription(); + $info['subscribed'] = $sub->user_subscription(); + } else { + $info['subscribed'] = false; + } + $info['locked'] = checklock($ID); $info['filepath'] = fullpath(wikiFN($ID)); $info['exists'] = @file_exists($info['filepath']); -- cgit v1.2.3 From 826d276602b191ee09d3450f7a8f9476c0e787b1 Mon Sep 17 00:00:00 2001 From: Klap-in Date: Tue, 21 May 2013 12:06:16 +0200 Subject: Clean internal ids in ml(), that it matches with fetch.php The resize token was broken because fetch.php cleans the id before the token calculation, while ml() uses the raw id --- inc/common.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 4d939ac77..03236f7d4 100644 --- a/inc/common.php +++ b/inc/common.php @@ -435,6 +435,11 @@ function exportlink($id = '', $format = 'raw', $more = '', $abs = false, $sep = */ function ml($id = '', $more = '', $direct = true, $sep = '&', $abs = false) { global $conf; + $isexternalimage = preg_match('#^(https?|ftp)://#i', $id); + if(!$isexternalimage) { + $id = cleanID($id); + } + if(is_array($more)) { // add token for resized images if($more['w'] || $more['h']){ @@ -467,7 +472,7 @@ function ml($id = '', $more = '', $direct = true, $sep = '&', $abs = false) } // external URLs are always direct without rewriting - if(preg_match('#^(https?|ftp)://#i', $id)) { + if($isexternalimage) { $xlink .= 'lib/exe/fetch.php'; // add hash: $xlink .= '?hash='.substr(md5(auth_cookiesalt().$id), 0, 6); -- cgit v1.2.3 From b9ee6a44e7499b5c2e9f117096cedc769ef2e25d Mon Sep 17 00:00:00 2001 From: Klap-in Date: Sun, 9 Jun 2013 23:04:52 +0200 Subject: apply media_isexternal in ml() --- inc/common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 59ceb0c0d..5f045e72d 100644 --- a/inc/common.php +++ b/inc/common.php @@ -435,7 +435,7 @@ function exportlink($id = '', $format = 'raw', $more = '', $abs = false, $sep = */ function ml($id = '', $more = '', $direct = true, $sep = '&', $abs = false) { global $conf; - $isexternalimage = preg_match('#^(https?|ftp)://#i', $id); + $isexternalimage = media_isexternal($id); if(!$isexternalimage) { $id = cleanID($id); } -- cgit v1.2.3 From e0086ca277bafe4f068079a4655a5601914a6f03 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 12 Jun 2013 21:45:37 +0200 Subject: check for spam in summary as well, added common spam summary --- inc/common.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 59ceb0c0d..760a9f6dc 100644 --- a/inc/common.php +++ b/inc/common.php @@ -557,12 +557,13 @@ function checkwordblock($text = '') { global $TEXT; global $PRE; global $SUF; + global $SUM; global $conf; global $INFO; if(!$conf['usewordblock']) return false; - if(!$text) $text = "$PRE $TEXT $SUF"; + if(!$text) $text = "$PRE $TEXT $SUF $SUM"; // we prepare the text a tiny bit to prevent spammers circumventing URL checks $text = preg_replace('!(\b)(www\.[\w.:?\-;,]+?\.[\w.:?\-;,]+?[\w/\#~:.?+=&%@\!\-.:?\-;,]+?)([.:?\-;,]*[^\w/\#~:.?+=&%@\!\-.:?\-;,])!i', '\1http://\2 \2\3', $text); -- cgit v1.2.3