"; echo ""; echo "
 
"; echo "
\n"; echo "
" . basename($file) . "
\n"; echo "
Size: " . format_size($file) . "
Last modified: " . date("D. F jS, Y - h:ia", filemtime($file)) . "
\n"; echo "
\n"; echo "
\n"; echo "
"; } // RECURSIVE FUNCTION TO BUILD THE BLOCKS function build_blocks( $items, $folder ) { global $ignore_file_list, $ignore_ext_list, $sort_by, $toggle_sub_folders; $objects = array(); $objects['directories'] = array(); $objects['files'] = array(); foreach($items as $c => $item) { if( $item == ".." OR $item == ".") continue; // IGNORE FILE if(in_array($item, $ignore_file_list)) { continue; } if( $folder && $item ) { $item = "$folder/$item"; } $file_ext = getFileExt($item); // IGNORE EXT if(in_array($file_ext, $ignore_ext_list)) { continue; } // DIRECTORIES if( is_dir($item) ) { $objects['directories'][] = $item; continue; } // FILE DATE $file_time = date("U", filemtime($item)); // FILES if( $item ) { $objects['files'][$file_time . "-" . $item] = $item; } } foreach($objects['directories'] as $c => $file) { display_block( $file ); if($toggle_sub_folders) { $sub_items = (array) scandir( $file ); if( $sub_items ) { echo "
"; build_blocks( $sub_items, $file ); echo "
"; } } } // SORT BEFORE LOOP if( $sort_by == "date_asc" ) { ksort($objects['files']); } elseif( $sort_by == "date_desc" ) { krsort($objects['files']); } elseif( $sort_by == "name_asc" ) { natsort($objects['files']); } elseif( $sort_by == "name_desc" ) { arsort($objects['files']); } foreach($objects['files'] as $t => $file) { $fileExt = getFileExt($file); if(in_array($file, $ignore_file_list)) { continue; } if(in_array($fileExt, $ignore_ext_list)) { continue; } display_block( $file ); } } // GET THE BLOCKS STARTED, FALSE TO INDICATE MAIN FOLDER $items = scandir( dirname(__FILE__) ); build_blocks( $items, false ); ?>
Free PHP File Directory Script (GitHub)