* @version 1.0.1 (July 10, 2004) * @package AutoIndex */ class FileItem extends Item { /** * @param string $fn The filename * @return string Everything after the list dot in the filename, not including the dot */ public static function ext($fn) { $fn = Item::get_basename($fn); return (strpos($fn, '.') ? strtolower(substr(strrchr($fn, '.'), 1)) : ''); } /** * @return string Returns the extension of the filename * @see FileItem::ext() */ public function file_ext() { return self::ext($this -> filename); } /** * @param string $parent_dir * @param string $filename */ public function __construct($parent_dir, $filename) { parent::__construct($parent_dir, $filename); if (!is_file($this -> parent_dir . $filename)) { throw new ExceptionDisplay('File ' . Url::html_output($this -> parent_dir . $filename) . ' does not exist.'); } global $config, $words, $downloads; $this -> filename = $filename; $this -> size = new Size(filesize($this -> parent_dir . $filename)); if (ICON_PATH) { $file_icon = new Icon($filename); $this -> icon = $file_icon -> __toString(); } $this -> downloads = (DOWNLOAD_COUNT && $downloads -> is_set($parent_dir . $filename) ? (int)($downloads -> __get($parent_dir . $filename)) : 0); $this -> link = Url::html_output($_SERVER['PHP_SELF']) . '?dir=' . Url::translate_uri(substr($this -> parent_dir, strlen($config -> __get('base_dir')))) . '&file=' . Url::translate_uri($filename); if (THUMBNAIL_HEIGHT && in_array(self::ext($filename), array('png', 'jpg', 'jpeg', 'jfif', 'gif', 'bmp'))) { $this -> thumb_link = ' ' . $words -> __get('thumbnail of') . ' ' . $filename . ''; $this -> thumb_link .= ' ' . $words -> __get('view') . ' ' . $words -> __get('file') . ''; } if (THUMBNAIL_HEIGHT && in_array(self::ext($filename), array('avi', 'thm', 'mkv', 'asf', 'mov', 'wmv', '3gp'))) { $mime = new MimeType($filename); $finfo = finfo_open(FILEINFO_MIME_TYPE); //Display correct headers for media file $mimetype = finfo_file($finfo, $this -> parent_dir . $filename); $file_size = function_exists('getvideosize') ? getvideosize($this -> parent_dir . $filename) : array(); $file_mime = function_exists('getvideosize') ? $file_size['mime'] : $mime -> __toString(); $this -> thumb_link = ' '; if (function_exists('imagecreatefromavi') && in_array(self::ext($filename), array('avi', 'wmv', '3gp'))) { $this -> thumb_link .= '
' . $words -> __get('thumbnail of') . ' ' . $filename . ''; } else { $this -> thumb_link = ' '; } } if (THUMBNAIL_HEIGHT && in_array(self::ext($filename), array('svg', 'xml'))) { $icon_svg = ICON_PATH ? Url::translate_uri($config -> __get('icon_path') . 'svg.png') : Url::translate_uri($this -> parent_dir . $filename); $heightwidth = in_array(self::ext($filename), array('svg', 'xml')) ? ' height="' . '150' . '" width="' . '150' . '" ' : ' '; $this -> thumb_link = ' ' . $words -> __get('thumbnail of') . ' ' . $filename . ''; //. ' ' . $words -> __get('thumbnail of') . ' ' . $filename . ''; } $size = $this -> size -> __get('bytes'); if (MD5_SHOW && $size > 0 && $size / 1048576 <= $config -> __get('md5_show')) { $this -> md5_link = '[' . $words -> __get('calculate md5sum') . ']'; } } /** * @param string $var The key to look for * @return mixed The data stored at the key */ public function __get($var = '') { if (isset($this -> $var)) { return $this -> $var; } throw new ExceptionDisplay('Variable ' . Url::html_output($var) . ' not set in FileItem class.'); } } ?>