From 015c5ef6db857c836679a16bb850dc0e5fd6d1dd Mon Sep 17 00:00:00 2001 From: 20xd6 <20xd6@airmail.cc> Date: Tue, 26 Jul 2022 13:33:49 -0400 Subject: [PATCH] Fix for issue #18 The page generation now checks for the size of $file_arr and only generates a menu if the size os greater than 0. --- common/php/page_menu.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/common/php/page_menu.php b/common/php/page_menu.php index 3960ead..dc116d2 100644 --- a/common/php/page_menu.php +++ b/common/php/page_menu.php @@ -18,11 +18,12 @@ function remove_sorting_number($link_title){ $dir = '.'; // Check if the directory exists if (file_exists($dir) && is_dir($dir) ) { - // Get the files of the directory as an array - $scan_arr = scandir($dir); - $files_arr = array_diff($scan_arr, array('.','..','index.php','common','.htaccess') ); - // echo "
"; print_r( $files_arr ); echo ""; - // Get each files of our directory with line break + // Get the files of the directory as an array + $scan_arr = scandir($dir); + $files_arr = array_diff($scan_arr, array('.','..','index.php','common','.htaccess') ); + // echo "
"; print_r( $files_arr ); echo ""; + // Get each files of our directory with line break + if (sizeof($files_arr) != 0 ) { foreach ($files_arr as $file) { //Get the file path $file_path = "./".$file; @@ -41,6 +42,7 @@ if (file_exists($dir) && is_dir($dir) ) { $link_title = remove_sorting_number($link_title);//Removes the number used to keep articles in post order from the displayed title. echo("\n");//Output the result. } + } } else { echo "Directory does not exists";