diff options
Diffstat (limited to 'lib/helper.php')
-rw-r--r-- | lib/helper.php | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/lib/helper.php b/lib/helper.php index 290d281c04c..060d887fd67 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -203,7 +203,7 @@ class OC_Helper { return OC::$WEBROOT."/core/img/filetypes/$mimetype.png"; } //try only the first part of the filetype - $mimetype=substr($mimetype,0,strpos($mimetype,'-')); + $mimetype=substr($mimetype,0, strpos($mimetype,'-')); if( file_exists( OC::$SERVERROOT."/core/img/filetypes/$mimetype.png" )) { return OC::$WEBROOT."/core/img/filetypes/$mimetype.png"; } @@ -288,18 +288,18 @@ class OC_Helper { if($file != '.' && $file != '..') { $fullpath = $path.'/'.$file; if(is_link($fullpath)) - return FALSE; + return false; elseif(!is_dir($fullpath) && !@chmod($fullpath, $filemode)) - return FALSE; + return false; elseif(!self::chmodr($fullpath, $filemode)) - return FALSE; + return false; } } closedir($dh); if(@chmod($path, $filemode)) - return TRUE; + return true; else - return FALSE; + return false; } /** @@ -364,8 +364,8 @@ class OC_Helper { if(strpos($path,'.')) { //try to guess the type by the file extension - if(!self::$mimetypes || self::$mimetypes != include('mimetypes.list.php')) { - self::$mimetypes=include('mimetypes.list.php'); + if(!self::$mimetypes || self::$mimetypes != include 'mimetypes.list.php') { + self::$mimetypes=include 'mimetypes.list.php'; } $extension=strtolower(strrchr(basename($path), ".")); $extension=substr($extension,1);//remove leading . @@ -377,7 +377,7 @@ class OC_Helper { if($mimeType=='application/octet-stream' and function_exists('finfo_open') and function_exists('finfo_file') and $finfo=finfo_open(FILEINFO_MIME)) { $info = @strtolower(finfo_file($finfo,$path)); if($info) { - $mimeType=substr($info,0,strpos($info,';')); + $mimeType=substr($info,0, strpos($info,';')); } finfo_close($finfo); } @@ -387,20 +387,15 @@ class OC_Helper { } if (!$isWrapped and $mimeType=='application/octet-stream' && OC_Helper::canExecute("file")) { // it looks like we have a 'file' command, - // lets see it it does have mime support + // lets see if it does have mime support $path=escapeshellarg($path); $fp = popen("file -i -b $path 2>/dev/null", "r"); $reply = fgets($fp); pclose($fp); - //trim the character set from the end of the response - $mimeType=substr($reply,0,strrpos($reply,' ')); - $mimeType=substr($mimeType,0,strrpos($mimeType,"\n")); - - //trim ; - if (strpos($mimeType, ';') !== false) { - $mimeType = strstr($mimeType, ';', true); - } + // we have smth like 'text/x-c++; charset=us-ascii\n' + // and need to eliminate everything starting with semicolon including trailing LF + $mimeType = preg_replace('/;.*/ms', '', trim($reply)); } return $mimeType; @@ -509,7 +504,7 @@ class OC_Helper { } $count=0; while(!feof($source)) { - $count+=fwrite($target,fread($source,8192)); + $count+=fwrite($target, fread($source,8192)); } return $count; } |