summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandi <andi@splitbrain.org>2005-01-23 19:30:35 +0100
committerandi <andi@splitbrain.org>2005-01-23 19:30:35 +0100
commitb77734d63a7cb01074d51c394b9ae2ab9e1344b8 (patch)
tree67cbed36b02597d201d61452b2ecd05c48ce9a82
parent0396becba66d77cb925a7a46a01af74bf519e7e1 (diff)
downloadrpg-b77734d63a7cb01074d51c394b9ae2ab9e1344b8.tar.gz
rpg-b77734d63a7cb01074d51c394b9ae2ab9e1344b8.tar.bz2
utf8 fixes for media files
darcs-hash:20050123183035-9977f-01ee16209de1f01738b975dd3be5f41ed4ffce76.gz
-rw-r--r--inc/format.php48
-rw-r--r--media.php10
2 files changed, 32 insertions, 26 deletions
diff --git a/inc/format.php b/inc/format.php
index 501d0e795..7b8d140ca 100644
--- a/inc/format.php
+++ b/inc/format.php
@@ -407,7 +407,7 @@ function format_rss($url){
*/
function img_cache(&$csrc,&$src,&$w,&$h,$nocache){
global $conf;
-
+
//container for various paths
$f['full']['web'] = $src;
$f['resz']['web'] = $src;
@@ -428,6 +428,7 @@ function img_cache(&$csrc,&$src,&$w,&$h,$nocache){
$isurl = true;
}else{
$src = str_replace(':','/',$src);
+ $src = utf8_encodeFN($src);
$f['full']['web'] = $conf['mediaweb'].'/'.$src;
$f['resz']['web'] = $conf['mediaweb'].'/'.$src;
$f['full']['fs'] = $conf['mediadir'].'/'.$src;
@@ -447,27 +448,32 @@ function img_cache(&$csrc,&$src,&$w,&$h,$nocache){
}
//for local images (cached or media) do resizing
- if($isimg && (!$isurl) && $w){
- $info = getImageSize($f['full']['fs']);
- //if $h not given calcualte it with correct aspect ratio
- if(!$h){
- $h = round(($w * $info[1]) / $info[0]);
- }
- $cache = $conf['mediadir'].'/.cache/'.$md5.'.'.$w.'x'.$h.'.'.$ext;
- //delete outdated cachefile
- if(@file_exists($cache) && (filemtime($cache)<filemtime($f['full']['fs']))){
- unlink($cache);
- }
- //check if a resized cachecopy exists else create one
- if(@file_exists($cache) || img_resize($ext,$f['full']['fs'],$info[0],$info[1],$cache,$w,$h)){
- $f['resz']['web'] = $conf['mediaweb'].'/.cache/'.$md5.'.'.$w.'x'.$h.'.'.$ext;
- $f['resz']['fs'] = $conf['mediadir'].'/.cache/'.$md5.'.'.$w.'x'.$h.'.'.$ext;
+ if($isimg && (!$isurl)){
+ if($w){
+ $info = getImageSize($f['full']['fs']);
+ //if $h not given calcualte it with correct aspect ratio
+ if(!$h){
+ $h = round(($w * $info[1]) / $info[0]);
+ }
+ $cache = $conf['mediadir'].'/.cache/'.$md5.'.'.$w.'x'.$h.'.'.$ext;
+ //delete outdated cachefile
+ if(@file_exists($cache) && (filemtime($cache)<filemtime($f['full']['fs']))){
+ unlink($cache);
+ }
+ //check if a resized cachecopy exists else create one
+ if(@file_exists($cache) || img_resize($ext,$f['full']['fs'],$info[0],$info[1],$cache,$w,$h)){
+ $f['resz']['web'] = $conf['mediaweb'].'/.cache/'.$md5.'.'.$w.'x'.$h.'.'.$ext;
+ $f['resz']['fs'] = $conf['mediadir'].'/.cache/'.$md5.'.'.$w.'x'.$h.'.'.$ext;
+ }
+ }else{
+ //if no new size was given just return the img size
+ $info = getImageSize($f['full']['fs']);
+ $w = $info[0];
+ $h = $info[1];
}
- }elseif($isimg && (!$isurl)){
- //if no new size was given just return the img size
- $info = getImageSize($f['full']['fs']);
- $w = $info[0];
- $h = $info[1];
+ //urlencode (yes! secondtime! with force!)
+ $f['full']['web'] = utf8_encodeFN($f['full']['web'],false);
+ $f['resz']['web'] = utf8_encodeFN($f['resz']['web'],false);
}
//set srcs
diff --git a/media.php b/media.php
index 522557de0..354910f0e 100644
--- a/media.php
+++ b/media.php
@@ -18,7 +18,7 @@ $NS = cleanID($NS);
if(auth_quickaclcheck("$NS:*") >= AUTH_UPLOAD){
$uploadok = true;
//create the given namespace (just for beautification)
- $mdir = $conf['mediadir'].'/'.str_replace(':','/',$NS);
+ $mdir = $conf['mediadir'].'/'.utf8_encodeFN(str_replace(':','/',$NS));
umask($conf['dmask']);
io_mkdir_p($mdir);
umask($conf['umask']);
@@ -67,7 +67,7 @@ function media_upload($NS){
if(empty($id)) $id = $file['name'];
$id = cleanID($NS.':'.$id);
// get filename
- $fn = str_replace(':','/',$id);
+ $fn = utf8_encodeFN(str_replace(':','/',$id));
$fn = $conf['mediadir'].'/'.$fn;
// prepare directory
io_makeFileDir($fn);
@@ -105,7 +105,7 @@ function media_html_uploadform($ns){
function media_html_media($ns){
global $conf;
global $lang;
- $dir = str_replace(':','/',$ns);
+ $dir = utf8_encodeFN(str_replace(':','/',$ns));
print '<b>'.$lang['mediafiles'].'</b>';
print ' <code>'.$ns.':</code>';
@@ -124,7 +124,7 @@ function media_html_media($ns){
foreach($data as $item){
print '<li>';
print '<a href="javascript:mediaSelect(\''.$item['id'].'\')">';
- print $item['file'];
+ print utf8_decodeFN($item['file']);
print '</a>';
if($item['isimg']){
print ' ('.$item['info'][0].'&#215;'.$item['info'][1];
@@ -158,7 +158,7 @@ function media_html_namespaces(){
function media_html_list_namespaces($item){
$ret = '';
- $ret .= '<a href="'.getBaseURL().'media.php?ns='.$item['id'].'" class="idx_dir">';
+ $ret .= '<a href="'.getBaseURL().'media.php?ns='.idfilter($item['id']).'" class="idx_dir">';
$ret .= $item['id'];
$ret .= '</a>';
return $ret;