diff --git a/index.php b/index.php index d9ffbbe..9d61bc0 100644 --- a/index.php +++ b/index.php @@ -1,7 +1,7 @@ "; - 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 ""; + $download_att = ($force_download AND $file_ext != "dir" ) ? " download='" . basename($file) . "'" : ""; + + $rtn = "
"; + $rtn .= ""; + $rtn .= "
 
"; + $rtn .= "
\n"; + $rtn .= "
" . basename($file) . "
\n"; + $rtn .= "
Size: " . format_size($file) . "
Last modified: " . date("D. F jS, Y - h:ia", filemtime($file)) . "
\n"; + $rtn .= "
\n"; + $rtn .= "
\n"; + $rtn .= "
"; + return $rtn; } // RECURSIVE FUNCTION TO BUILD THE BLOCKS function build_blocks( $items, $folder ) { - global $ignore_file_list, $ignore_ext_list, $sort_by, $toggle_sub_folders; + global $ignore_file_list, $ignore_ext_list, $sort_by, $toggle_sub_folders, $ignore_empty_folders; + $objects = array(); $objects['directories'] = array(); $objects['files'] = array(); @@ -189,11 +200,31 @@ function build_blocks( $items, $folder ) foreach($objects['directories'] as $c => $file) { - display_block( $file ); + $sub_items = (array) scandir( $file ); - if($toggle_sub_folders) + if( $ignore_empty_folders ) + { + $has_sub_items = false; + foreach( $sub_items as $sub_item ) + { + $sub_fileExt = getFileExt( $sub_item ); + if( $sub_item == ".." OR $sub_item == ".") continue; + if(in_array($sub_item, $ignore_file_list)) continue; + if(in_array($sub_fileExt, $ignore_ext_list)) continue; + + $has_sub_items = true; + break; + } + + if( $has_sub_items ) echo display_block( $file ); + } + else + { + echo display_block( $file ); + } + + if( $toggle_sub_folders ) { - $sub_items = (array) scandir( $file ); if( $sub_items ) { echo "
"; @@ -214,7 +245,7 @@ function build_blocks( $items, $folder ) $fileExt = getFileExt($file); if(in_array($file, $ignore_file_list)) { continue; } if(in_array($fileExt, $ignore_ext_list)) { continue; } - display_block( $file ); + echo display_block( $file ); } }