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.
This commit is contained in:
20xd6 2022-07-26 13:33:49 -04:00
parent 4958a76f9a
commit 015c5ef6db

View File

@ -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 "<pre>"; print_r( $files_arr ); echo "</pre>";
// 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 "<pre>"; print_r( $files_arr ); echo "</pre>";
// 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("<ul><li><a href='$file'> $link_title </a></li></ul>\n");//Output the result.
}
}
}
else {
echo "Directory does not exists";