public static function info($name) { if (!file_exists($name)) { return null; } $info = DataObject::instance(); $name = str_replace("\\", '/', $name); $info->add("fileName", $name); $info->add("mode", MFile::mode($name)); $info->add("permmask", MFile::permissionMask($name)); $info->add("size", (int) filesize($name)); $info->add("sizeKB", round($info->size / 1024, 2)); $info->add("sizeMB", round($info->size / 1048576, 2)); if ($info->sizeMB >= 1) { $smart = $info->sizeMB . " MB"; } elseif ($info->sizeKB >= 1) { $smart = $info->sizeKB . " KB"; } else { $smart = $info->size . " Bytes"; } $info->add("smartSize", $smart); $info->add("type", filetype($name)); $info->add("isDir", is_dir($name)); $info->add("isFile", is_file($name)); $info->add("lastModifiedTimestamp", filemtime($name)); $info->add("lastModifiedDate", date("d.m.Y", $info->lastModifiedTimestamp)); $info->add("lastModifiedTime", date("H:i", $info->lastModifiedTimestamp)); $info->add("lastModified", date("d.m.Y H:i", $info->lastModifiedTimestamp)); $pi = pathinfo($name); $info->add("dirName", $pi['dirname']); $info->add("baseName", utf8_encode($pi['basename'])); $info->add("extension", strtolower(isset($pi['extension']) ? $pi['extension'] : null)); $info->add("folderUp", $pi['basename'] == '..'); $owner = fileowner($name) == 0 ? "n/a" : fileowner($name); $info->add("owner", $owner); $info->add("isReadable", is_readable($name)); $info->add("isWritable", is_writable($name)); $imgArray = array("gif", "jpg", "jpeg", "png", "ico", "icon"); $info->add("isImage", in_array(strtolower($info->extension), $imgArray)); $docArray = array("doc", " docx", "pdf", "rtf", "ps", "lwp", "txt", "text", "wps", "htm", "html", "odt", "ods", "odp", "pps", "ppt", "xml"); $info->add("isDocument", in_array(strtolower($info->extension), $docArray)); $audioArray = array("mp3", "ra", "ram", "wav", "wave", "wma", "au", "mpa", "m3u", "aif", "iff", "mid", "midi"); $info->add("isAudio", in_array(strtolower($info->extension), $audioArray)); $videoArray = array("avi", "mov", "movi", "moov", "qt", "mp4", "mpg", "mpeg", "rm", "swf", "wm", "wmv", "dvx", "divx", "flv", "xvid"); $info->add("isVideo", in_array(strtolower($info->extension), $videoArray)); $compressedArray = array("zip", "rar", "gz", "gzip"); $info->add("isCompressed", in_array(strtolower($info->extension), $compressedArray)); $info->add("sub", null); return $info; }