= 1073741824) { $size = round($size / 1073741824 * 100) / 100 . " GB"; } elseif($size >= 1048576) { $size = round($size / 1048576 * 100) / 100 . " MB"; } elseif($size >= 1024) { $size = round($size / 1024 * 100) / 100 . " KB"; } else $size = $size . " Bytes"; if($size==0) $size="-"; return $size; } //------------------------------------------------------------------------------ function get_file_date($dir, $item) { // file date return @filemtime(get_abs_item($dir, $item)); } //------------------------------------------------------------------------------ function parse_file_date($date) { // parsed file date return @date($GLOBALS["date_fmt"],$date); } //------------------------------------------------------------------------------ function get_is_image($dir, $item) { // is this file an image? if(!get_is_file($dir, $item)) return false; return @eregi($GLOBALS["images_ext"], $item); } //----------------------------------------------------------------------------- function get_is_editable($dir, $item) { // is this file editable? if(!get_is_file($dir, $item)) return false; foreach($GLOBALS["editable_ext"] as $pat) if(@eregi($pat,$item)) return true; return false; } //----------------------------------------------------------------------------- function get_mime_type($dir, $item, $query) { // get file's mimetype if(get_is_dir($dir, $item)) { // directory $mime_type = $GLOBALS["super_mimes"]["dir"][0]; $image = $GLOBALS["super_mimes"]["dir"][1]; if($query=="img") return $image; else return $mime_type; } // mime_type foreach($GLOBALS["used_mime_types"] as $mime) { list($desc,$img,$ext) = $mime; if(@eregi($ext,$item)) { $mime_type = $desc; $image = $img; if($query=="img") return $image; else return $mime_type; } } if((function_exists("is_executable") && @is_executable(get_abs_item($dir,$item))) || @eregi($GLOBALS["super_mimes"]["exe"][2],$item)) { // executable $mime_type = $GLOBALS["super_mimes"]["exe"][0]; $image = $GLOBALS["super_mimes"]["exe"][1]; } else { // unknown file $mime_type = $GLOBALS["super_mimes"]["file"][0]; $image = $GLOBALS["super_mimes"]["file"][1]; } if($query=="img") return $image; else return $mime_type; } //------------------------------------------------------------------------------ function get_show_item($dir, $item) { // show this file? if($item == "." || $item == ".." || (substr($item,0,1)=="." && $GLOBALS["show_hidden"]==false)) return false; if($GLOBALS["no_access"]!="" && @eregi($GLOBALS["no_access"],$item)) return false; if($GLOBALS["show_hidden"]==false) { $dirs=explode("/",$dir); foreach($dirs as $i) if(substr($i,0,1)==".") return false; } return true; } //------------------------------------------------------------------------------ function copy_dir($source,$dest) { // copy dir $ok = true; if(!@mkdir($dest,0777)) return false; if(($handle=@opendir($source))===false) show_error(basename($source).": ".$GLOBALS["error_msg"]["opendir"]); while(($file=readdir($handle))!==false) { if(($file==".." || $file==".")) continue; $new_source = $source."/".$file; $new_dest = $dest."/".$file; if(@is_dir($new_source)) { $ok=copy_dir($new_source,$new_dest); } else { $ok=@copy($new_source,$new_dest); } } closedir($handle); return $ok; } //------------------------------------------------------------------------------ function remove($item) { // remove file / dir $ok = true; if(@is_link($item) || @is_file($item)) $ok=@unlink($item); elseif(@is_dir($item)) { if(($handle=@opendir($item))===false) show_error(basename($item).": ".$GLOBALS["error_msg"]["opendir"]); while(($file=readdir($handle))!==false) { if(($file==".." || $file==".")) continue; $new_item = $item."/".$file; if(!@file_exists($new_item)) show_error(basename($item).": ".$GLOBALS["error_msg"]["readdir"]); //if(!get_show_item($item, $new_item)) continue; if(@is_dir($new_item)) { $ok=remove($new_item); } else { $ok=@unlink($new_item); } } closedir($handle); $ok=@rmdir($item); } return $ok; } //------------------------------------------------------------------------------ function get_max_file_size() { // get php max_upload_file_size $max = get_cfg_var("upload_max_filesize"); if(@eregi("G$",$max)) { $max = substr($max,0,-1); $max = round($max*1073741824); } elseif(@eregi("M$",$max)) { $max = substr($max,0,-1); $max = round($max*1048576); } elseif(@eregi("K$",$max)) { $max = substr($max,0,-1); $max = round($max*1024); } return $max; } //------------------------------------------------------------------------------ function down_home($abs_dir) { // dir deeper than home? $real_home = @realpath($GLOBALS["home_dir"]); $real_dir = @realpath($abs_dir); if($real_home===false || $real_dir===false) { if(@eregi("\\.\\.",$abs_dir)) return false; } else if(strcmp($real_home,@substr($real_dir,0,strlen($real_home)))) { return false; } return true; } //------------------------------------------------------------------------------ function id_browser() { $browser=$GLOBALS['__SERVER']['HTTP_USER_AGENT']; if(ereg('Opera(/| )([0-9].[0-9]{1,2})', $browser)) { return 'OPERA'; } else if(ereg('MSIE ([0-9].[0-9]{1,2})', $browser)) { return 'IE'; } else if(ereg('OmniWeb/([0-9].[0-9]{1,2})', $browser)) { return 'OMNIWEB'; } else if(ereg('(Konqueror/)(.*)', $browser)) { return 'KONQUEROR'; } else if(ereg('Mozilla/([0-9].[0-9]{1,2})', $browser)) { return 'MOZILLA'; } else { return 'OTHER'; } } //------------------------------------------------------------------------------ ?>