utf8 fixes for media files
darcs-hash:20050123183035-9977f-01ee16209de1f01738b975dd3be5f41ed4ffce76.gz
This commit is contained in:
parent
0396becba6
commit
b77734d63a
|
@ -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]);
|
||||
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];
|
||||
}
|
||||
$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;
|
||||
}
|
||||
}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
|
||||
|
|
10
media.php
10
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].'×'.$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;
|
||||
|
|
Loading…
Reference in New Issue