mirror of
https://github.com/jcampbell1/simple-file-manager.git
synced 2025-02-20 22:00:04 +01:00
Flag for hiding subdirs
This commit is contained in:
27
index.php
27
index.php
@@ -14,9 +14,9 @@ $allow_delete = true; // Set to false to disable delete button and delete POST r
|
|||||||
$allow_upload = true; // Set to true to allow upload files
|
$allow_upload = true; // Set to true to allow upload files
|
||||||
$allow_create_folder = true; // Set to false to disable folder creation
|
$allow_create_folder = true; // Set to false to disable folder creation
|
||||||
$allow_direct_link = true; // Set to false to only allow downloads and not direct link
|
$allow_direct_link = true; // Set to false to only allow downloads and not direct link
|
||||||
|
$allow_show_folders = true; // Set to false to hide all subdirectories
|
||||||
|
|
||||||
$disallowed_extensions = ['php']; // must be an array. Extensions disallowed to be uploaded
|
$disallowed_extensions = ['php']; // must be an array. Extensions disallowed to be uploaded
|
||||||
|
|
||||||
$hidden_extensions = ['php']; // must be an array of lowercase file extensions. Extensions hidden in directory index
|
$hidden_extensions = ['php']; // must be an array of lowercase file extensions. Extensions hidden in directory index
|
||||||
|
|
||||||
$PASSWORD = ''; // Set the password, to access the file manager... (optional)
|
$PASSWORD = ''; // Set the password, to access the file manager... (optional)
|
||||||
@@ -64,9 +64,9 @@ if($_GET['do'] == 'list') {
|
|||||||
$directory = $file;
|
$directory = $file;
|
||||||
$result = [];
|
$result = [];
|
||||||
$files = array_diff(scandir($directory), ['.','..']);
|
$files = array_diff(scandir($directory), ['.','..']);
|
||||||
foreach($files as $entry) if($entry !== basename(__FILE__) && !in_array(strtolower(pathinfo($entry, PATHINFO_EXTENSION)), $hidden_extensions)) {
|
foreach ($files as $entry) if (!is_entry_ignored($entry)) {
|
||||||
$i = $directory . '/' . $entry;
|
$i = $directory . '/' . $entry;
|
||||||
$stat = stat($i);
|
$stat = stat($i);
|
||||||
$result[] = [
|
$result[] = [
|
||||||
'mtime' => $stat['mtime'],
|
'mtime' => $stat['mtime'],
|
||||||
'size' => $stat['size'],
|
'size' => $stat['size'],
|
||||||
@@ -119,6 +119,25 @@ if($_GET['do'] == 'list') {
|
|||||||
readfile($file);
|
readfile($file);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function is_entry_ignored($entry) {
|
||||||
|
if ($entry === basename(__FILE__)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
global $allow_show_folders;
|
||||||
|
if (is_dir($entry) && !$allow_show_folders) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$ext = strtolower(pathinfo($entry, PATHINFO_EXTENSION));
|
||||||
|
if (in_array($ext, $hidden_extensions)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
function rmrf($dir) {
|
function rmrf($dir) {
|
||||||
if(is_dir($dir)) {
|
if(is_dir($dir)) {
|
||||||
$files = array_diff(scandir($dir), ['.','..']);
|
$files = array_diff(scandir($dir), ['.','..']);
|
||||||
|
|||||||
Reference in New Issue
Block a user