1) { $size=$size/1024; $i++; } return substr($size,0,strpos($size,'.')+2).$iec[$i]; } // check the file function ok_file( $file ) { $hide_list = array("php", "log", "swp"); if ( !is_file( $file ) ) return false; // determine file extension $dotpos = strlen( $file ) - 1; for ( $dotpos=$dotpos; $dotpos >= 0; $dotpos-- ) if ( substr( $file, $dotpos, 1) == "." ) break; // now dotpos shows where the dot is $extension = substr( $file, $dotpos+1 ); if ( in_array( strtolower($extension), $hide_list ) ) return false; return true; } if ( !isset($_REQUEST['d']) ) $dir = $base_dir; else $dir = $base_dir . $_REQUEST['d'] . "/"; if ( !is_dir($dir) ) die("bad directory $dir"); $dirlist = array(); $filelist = array(); // get all files in initial directory $dh = opendir( $dir ); while ( ( $file = readdir( $dh ) ) !== false ) { if ( is_dir( $dir . $file ) && substr( $file, 0, 1) != "." ) $dirlist[] = $dir . $file; if ( ok_file($dir.$file) ) $filelist[] = $file; } closedir($dh); $rootfiles = "\t\n"; foreach ( $dirlist as $d ) { $fmtime = date("Y-m-d H:i", filemtime("$d")); $rootfiles .= "\t\t\n"; } foreach ( $filelist as $f ) { $ftype = exec("file -i -b \"$dir$f\""); $fmtime = date("Y-m-d H:i", filemtime("$dir$f")); $fsize = filesize("$dir$f"); $humansize = size_hum_read($fsize); $rootfiles .= "\t\t\n"; } $rootfiles .= "\t\n"; // now get subdirs /* $bigout = ""; foreach ( $dirlist as $dd ) { $bigout .= "Index of $dd
\n
"; } */ ?> \n"; ?> \n"; ?>