From e4f389ef1728a0f86164a0e4b88626be9860dabb Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Thu, 26 May 2011 14:23:33 +0300 Subject: media version saving --- inc/pageutils.php | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'inc/pageutils.php') diff --git a/inc/pageutils.php b/inc/pageutils.php index c9bf60135..51567191e 100644 --- a/inc/pageutils.php +++ b/inc/pageutils.php @@ -307,6 +307,19 @@ function metaFN($id,$ext){ return $fn; } +/** + * returns the full path to the media's meta file specified by ID and extension + * + * The filename is URL encoded to protect Unicode chars + */ +function mediaMetaFN($id,$ext){ + global $conf; + $id = cleanID($id); + $id = str_replace(':','/',$id); + $fn = $conf['mediametadir'].'/'.utf8_encodeFN($id).$ext; + return $fn; +} + /** * returns an array of full paths to all metafiles of a given ID * @@ -327,11 +340,16 @@ function metaFiles($id){ * * @author Andreas Gohr */ -function mediaFN($id){ +function mediaFN($id, $rev=''){ global $conf; $id = cleanID($id); $id = str_replace(':','/',$id); - $fn = $conf['mediadir'].'/'.utf8_encodeFN($id); + if(empty($rev)){ + $fn = $conf['mediadir'].'/'.utf8_encodeFN($id); + }else{ + list($name, $ext) = explode(".", $id); + $fn = $conf['mediaolddir'].'/'.utf8_encodeFN($name).'.'.$rev.'.'.utf8_encodeFN($ext); + } return $fn; } -- cgit v1.2.3 From cbe26ad6152c998c9a3290b0d321030c61dc7f1b Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Sat, 4 Jun 2011 19:12:06 +0300 Subject: media version saving fix --- inc/pageutils.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'inc/pageutils.php') diff --git a/inc/pageutils.php b/inc/pageutils.php index 51567191e..37b15a498 100644 --- a/inc/pageutils.php +++ b/inc/pageutils.php @@ -295,8 +295,6 @@ function wikiLockFN($id) { /** * returns the full path to the meta file specified by ID and extension * - * The filename is URL encoded to protect Unicode chars - * * @author Steven Danz */ function metaFN($id,$ext){ @@ -310,7 +308,7 @@ function metaFN($id,$ext){ /** * returns the full path to the media's meta file specified by ID and extension * - * The filename is URL encoded to protect Unicode chars + * @author Kate Arzamastseva */ function mediaMetaFN($id,$ext){ global $conf; @@ -339,6 +337,7 @@ function metaFiles($id){ * The filename is URL encoded to protect Unicode chars * * @author Andreas Gohr + * @author Kate Arzamastseva */ function mediaFN($id, $rev=''){ global $conf; @@ -347,8 +346,9 @@ function mediaFN($id, $rev=''){ if(empty($rev)){ $fn = $conf['mediadir'].'/'.utf8_encodeFN($id); }else{ - list($name, $ext) = explode(".", $id); - $fn = $conf['mediaolddir'].'/'.utf8_encodeFN($name).'.'.$rev.'.'.utf8_encodeFN($ext); + $ext = mimetype($id); + $name = substr($id, 0, strrpos($id, '.')); + $fn = $conf['mediaolddir'].'/'.utf8_encodeFN($name).'.'.(int)$rev.'.'.utf8_encodeFN($ext[0]); } return $fn; } -- cgit v1.2.3 From 61f1aad8f877bdf33a160812d88b60c56aed1040 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Sun, 5 Jun 2011 21:00:51 +0300 Subject: media version saving fixes --- inc/pageutils.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'inc/pageutils.php') diff --git a/inc/pageutils.php b/inc/pageutils.php index 37b15a498..09a23cbdd 100644 --- a/inc/pageutils.php +++ b/inc/pageutils.php @@ -347,8 +347,8 @@ function mediaFN($id, $rev=''){ $fn = $conf['mediadir'].'/'.utf8_encodeFN($id); }else{ $ext = mimetype($id); - $name = substr($id, 0, strrpos($id, '.')); - $fn = $conf['mediaolddir'].'/'.utf8_encodeFN($name).'.'.(int)$rev.'.'.utf8_encodeFN($ext[0]); + $name = substr($id,0, -1*strlen($ext[0])); + $fn = $conf['mediaolddir'].'/'.utf8_encodeFN($name .'.'.( (int) $rev ).'.'.$ext[0]); } return $fn; } -- cgit v1.2.3 From 8e69fd30702f1101a9c70dbe6eac6f45f9af3970 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Mon, 13 Jun 2011 20:23:18 +0300 Subject: media manager --- inc/pageutils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/pageutils.php') diff --git a/inc/pageutils.php b/inc/pageutils.php index 09a23cbdd..81dcb66e7 100644 --- a/inc/pageutils.php +++ b/inc/pageutils.php @@ -347,7 +347,7 @@ function mediaFN($id, $rev=''){ $fn = $conf['mediadir'].'/'.utf8_encodeFN($id); }else{ $ext = mimetype($id); - $name = substr($id,0, -1*strlen($ext[0])); + $name = substr($id,0, -1*strlen($ext[0])-1); $fn = $conf['mediaolddir'].'/'.utf8_encodeFN($name .'.'.( (int) $rev ).'.'.$ext[0]); } return $fn; -- cgit v1.2.3 From b680ea06a64290b3e28a7b7d2d8d33373a3e6709 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 25 Sep 2011 09:54:17 +0200 Subject: fix namespace cleaning FS#2295 This patch applies the correct pagename cleaning to namespaces as well. Namespaces should follow the same rules as pagenames but due to a bug it was possible to have namespaces ending in a underscore. If you used such a namespace it will be inaccessible after applying this patch. You should rename the namespace directory on the filesystem (removing the trailing underscore). You old links will then work automatically again. Rebuilding the search index is recommended. --- inc/pageutils.php | 1 + 1 file changed, 1 insertion(+) (limited to 'inc/pageutils.php') diff --git a/inc/pageutils.php b/inc/pageutils.php index 81dcb66e7..31b5f9ff9 100644 --- a/inc/pageutils.php +++ b/inc/pageutils.php @@ -134,6 +134,7 @@ function cleanID($raw_id,$ascii=false,$media=false){ $id = preg_replace('#:+#',':',$id); $id = ($media ? trim($id,':.-') : trim($id,':._-')); $id = preg_replace('#:[:\._\-]+#',':',$id); + $id = preg_replace('#[:\._\-]+:#',':',$id); $cache[(string)$raw_id] = $id; return($id); -- cgit v1.2.3