diff --git a/pandora_console/include/functions_filemanager.php b/pandora_console/include/functions_filemanager.php
index 50a95a1c42..15a34aa4fc 100644
--- a/pandora_console/include/functions_filemanager.php
+++ b/pandora_console/include/functions_filemanager.php
@@ -595,178 +595,187 @@ function filemanager_file_explorer(
$files = filemanager_list_dir($real_directory);
- $table = new stdClass();
- $table->width = '100%';
- $table->id = 'table_filemanager';
- if (!defined('METACONSOLE')) {
- $table->class = 'info_table';
- $table->title = ''.__('Index of %s', $relative_directory).'';
- }
-
- if (defined('METACONSOLE')) {
- $table->class = 'databox_tactical';
- $table->title = ''.__('Index of %s', $relative_directory).'';
- }
-
- $table->colspan = [];
- $table->data = [];
- $table->head = [];
- $table->size = [];
-
- $table->align[1] = 'left';
- $table->align[2] = 'left';
- $table->align[3] = 'left';
- $table->align[4] = 'left';
-
- $table->size[0] = '24px';
-
- $table->head[0] = '';
- $table->head[1] = __('Name');
- $table->head[2] = __('Last modification');
- $table->head[3] = __('Size');
- $table->head[4] = __('Actions');
-
- $prev_dir = explode('/', $relative_directory);
- $prev_dir_str = '';
- for ($i = 0; $i < (count($prev_dir) - 1); $i++) {
- $prev_dir_str .= $prev_dir[$i];
- if ($i < (count($prev_dir) - 2)) {
- $prev_dir_str .= '/';
+ if (!empty($files)) {
+ $table = new stdClass();
+ $table->width = '100%';
+ $table->id = 'table_filemanager';
+ if (!defined('METACONSOLE')) {
+ $table->class = 'info_table';
+ $table->title = ''.__('Index of %s', $relative_directory).'';
}
- }
- if (($prev_dir_str != '') && ($father != $relative_directory)) {
- $table->data[0][0] = html_print_image('images/go_previous.png', true);
- $table->data[0][1] = '';
- $table->data[0][1] .= __('Parent directory');
- $table->data[0][1] .= '';
+ if (defined('METACONSOLE')) {
+ $table->class = 'databox_tactical';
+ $table->title = ''.__('Index of %s', $relative_directory).'';
+ }
- $table->colspan[0][1] = 5;
- }
+ $table->colspan = [];
+ $table->data = [];
+ $table->head = [];
+ $table->size = [];
- foreach ($files as $fileinfo) {
- $fileinfo['realpath'] = str_replace('\\', '/', $fileinfo['realpath']);
- $relative_path = str_replace($_SERVER['DOCUMENT_ROOT'], '', $fileinfo['realpath']);
+ $table->align[1] = 'left';
+ $table->align[2] = 'left';
+ $table->align[3] = 'left';
+ $table->align[4] = 'left';
- $data = [];
+ $table->size[0] = '24px';
- switch ($fileinfo['mime']) {
- case MIME_DIR:
- $data[0] = html_print_image('images/mimetypes/directory.png', true, ['title' => __('Directory')]);
- break;
+ $table->head[0] = '';
+ $table->head[1] = __('Name');
+ $table->head[2] = __('Last modification');
+ $table->head[3] = __('Size');
+ $table->head[4] = __('Actions');
- case MIME_IMAGE:
- $data[0] = html_print_image('images/mimetypes/image.png', true, ['title' => __('Image')]);
- break;
+ $prev_dir = explode('/', $relative_directory);
+ $prev_dir_str = '';
+ for ($i = 0; $i < (count($prev_dir) - 1); $i++) {
+ $prev_dir_str .= $prev_dir[$i];
+ if ($i < (count($prev_dir) - 2)) {
+ $prev_dir_str .= '/';
+ }
+ }
- case MIME_ZIP:
- $data[0] = html_print_image('images/mimetypes/zip.png', true, ['title' => __('Compressed file')]);
- break;
+ if (($prev_dir_str != '') && ($father != $relative_directory)) {
+ $table->data[0][0] = html_print_image('images/go_previous.png', true);
+ $table->data[0][1] = '';
+ $table->data[0][1] .= __('Parent directory');
+ $table->data[0][1] .= '';
- case MIME_TEXT:
- $data[0] = html_print_image('images/mimetypes/text.png', true, ['title' => __('Text file')]);
- break;
+ $table->colspan[0][1] = 5;
+ }
- case MIME_UNKNOWN:
- if ($fileinfo['size'] == 0) {
- if ((strstr($fileinfo['name'], '.txt') !== false) || (strstr($fileinfo['name'], '.conf') !== false) || (strstr($fileinfo['name'], '.sql') !== false) || (strstr($fileinfo['name'], '.pl') !== false)) {
- $fileinfo['mime'] = MIME_TEXT;
- $data[0] = html_print_image('images/mimetypes/text.png', true, ['title' => __('Text file')]);
+ foreach ($files as $fileinfo) {
+ $fileinfo['realpath'] = str_replace('\\', '/', $fileinfo['realpath']);
+ $relative_path = str_replace($_SERVER['DOCUMENT_ROOT'], '', $fileinfo['realpath']);
+
+ $data = [];
+
+ switch ($fileinfo['mime']) {
+ case MIME_DIR:
+ $data[0] = html_print_image('images/mimetypes/directory.png', true, ['title' => __('Directory')]);
+ break;
+
+ case MIME_IMAGE:
+ $data[0] = html_print_image('images/mimetypes/image.png', true, ['title' => __('Image')]);
+ break;
+
+ case MIME_ZIP:
+ $data[0] = html_print_image('images/mimetypes/zip.png', true, ['title' => __('Compressed file')]);
+ break;
+
+ case MIME_TEXT:
+ $data[0] = html_print_image('images/mimetypes/text.png', true, ['title' => __('Text file')]);
+ break;
+
+ case MIME_UNKNOWN:
+ if ($fileinfo['size'] == 0) {
+ if ((strstr($fileinfo['name'], '.txt') !== false) || (strstr($fileinfo['name'], '.conf') !== false) || (strstr($fileinfo['name'], '.sql') !== false) || (strstr($fileinfo['name'], '.pl') !== false)) {
+ $fileinfo['mime'] = MIME_TEXT;
+ $data[0] = html_print_image('images/mimetypes/text.png', true, ['title' => __('Text file')]);
+ } else {
+ // unknow
+ $data[0] = '';
+ }
} else {
- // unknow
+ // pdf
$data[0] = '';
}
- } else {
- // pdf
- $data[0] = '';
+ break;
+
+ default:
+ $data[0] = html_print_image('images/mimetypes/unknown.png', true, ['title' => __('Unknown')]);
+ break;
+ }
+
+ if ($fileinfo['is_dir']) {
+ $data[1] = ''.$fileinfo['name'].'';
+ } else if (!empty($url_file)) {
+ // Set the custom url file
+ $url_file_clean = str_replace('[FILE_FULLPATH]', $fileinfo['realpath'], $url_file);
+
+ $data[1] = ''.$fileinfo['name'].'';
+ } else {
+ $filename = base64_encode($relative_directory.'/'.$fileinfo['name']);
+ $hash = md5($filename.$config['dbpass']);
+ $data[1] = ''.$fileinfo['name'].'';
+ }
+
+ // Notice that uploaded php files could be dangerous
+ if (pathinfo($fileinfo['realpath'], PATHINFO_EXTENSION) == 'php'
+ && (is_readable($fileinfo['realpath']) || is_executable($fileinfo['realpath']))
+ ) {
+ $error_message = __('This file could be executed by any user');
+ $error_message .= '. '.__('Make sure it can\'t perform dangerous tasks');
+ $data[1] = ''.$data[1].'';
+ }
+
+ $data[2] = ui_print_timestamp(
+ $fileinfo['last_modified'],
+ true,
+ ['prominent' => true]
+ );
+ if ($fileinfo['is_dir']) {
+ $data[3] = '';
+ } else {
+ $data[3] = ui_format_filesize($fileinfo['size']);
+ }
+
+ // Actions buttons
+ // Delete button
+ $data[4] = '';
+ $data[4] .= '';
+ $typefile = array_pop(explode('.', $fileinfo['name']));
+ if (is_writable($fileinfo['realpath'])
+ && (! is_dir($fileinfo['realpath']) || count(scandir($fileinfo['realpath'])) < 3) && (!$readOnly)
+ ) {
+ $data[4] .= '';
+
+ if (($editor) && (!$readOnly)) {
+ if (($typefile != 'bin') && ($typefile != 'pdf') && ($typefile != 'png') && ($typefile != 'jpg')
+ && ($typefile != 'iso') && ($typefile != 'docx') && ($typefile != 'doc') && ($fileinfo['mime'] != MIME_DIR)
+ ) {
+ $hash = md5($fileinfo['realpath'].$config['dbpass']);
+ $data[4] .= "".html_print_image('images/edit.png', true, ['style' => 'margin-top: 2px;', 'title' => __('Edit file')]).'';
+ }
+ }
+ }
+
+ if ((!$fileinfo['is_dir']) && ($download_button)) {
+ $filename = base64_encode($fileinfo['name']);
+ $hash = md5($filename.$config['dbpass']);
+ $data[4] .= '';
+ $data[4] .= html_print_image('images/file.png', true);
+ $data[4] .= '';
+ }
+
+ $data[4] .= '';
+
+ array_push($table->data, $data);
}
-
- if ($fileinfo['is_dir']) {
- $data[1] = ''.$fileinfo['name'].'';
- } else if (!empty($url_file)) {
- // Set the custom url file
- $url_file_clean = str_replace('[FILE_FULLPATH]', $fileinfo['realpath'], $url_file);
-
- $data[1] = ''.$fileinfo['name'].'';
- } else {
- $filename = base64_encode($relative_directory.'/'.$fileinfo['name']);
- $hash = md5($filename.$config['dbpass']);
- $data[1] = ''.$fileinfo['name'].'';
- }
-
- // Notice that uploaded php files could be dangerous
- if (pathinfo($fileinfo['realpath'], PATHINFO_EXTENSION) == 'php'
- && (is_readable($fileinfo['realpath']) || is_executable($fileinfo['realpath']))
- ) {
- $error_message = __('This file could be executed by any user');
- $error_message .= '. '.__('Make sure it can\'t perform dangerous tasks');
- $data[1] = ''.$data[1].'';
- }
-
- $data[2] = ui_print_timestamp(
- $fileinfo['last_modified'],
- true,
- ['prominent' => true]
+ } else {
+ ui_print_info_message(
+ [
+ 'no_close' => true,
+ 'message' => __('No files or directories to show.'),
+ ]
);
- if ($fileinfo['is_dir']) {
- $data[3] = '';
- } else {
- $data[3] = ui_format_filesize($fileinfo['size']);
- }
-
- // Actions buttons
- // Delete button
- $data[4] = '';
- $data[4] .= '';
- $typefile = array_pop(explode('.', $fileinfo['name']));
- if (is_writable($fileinfo['realpath'])
- && (! is_dir($fileinfo['realpath']) || count(scandir($fileinfo['realpath'])) < 3) && (!$readOnly)
- ) {
- $data[4] .= '';
-
- if (($editor) && (!$readOnly)) {
- if (($typefile != 'bin') && ($typefile != 'pdf') && ($typefile != 'png') && ($typefile != 'jpg')
- && ($typefile != 'iso') && ($typefile != 'docx') && ($typefile != 'doc') && ($fileinfo['mime'] != MIME_DIR)
- ) {
- $hash = md5($fileinfo['realpath'].$config['dbpass']);
- $data[4] .= "".html_print_image('images/edit.png', true, ['style' => 'margin-top: 2px;', 'title' => __('Edit file')]).'';
- }
- }
- }
-
- if ((!$fileinfo['is_dir']) && ($download_button)) {
- $filename = base64_encode($fileinfo['name']);
- $hash = md5($filename.$config['dbpass']);
- $data[4] .= '';
- $data[4] .= html_print_image('images/file.png', true);
- $data[4] .= '';
- }
-
- $data[4] .= '';
-
- array_push($table->data, $data);
}
if (!$readOnly) {