Merge branch 'ent-6522-fallo-visual-vista-ficheros-colecciones' into 'develop'
Added infobox for empty folder on collections See merge request artica/pandorafms!3717
This commit is contained in:
commit
8c730f7a0c
|
@ -595,178 +595,187 @@ function filemanager_file_explorer(
|
||||||
|
|
||||||
$files = filemanager_list_dir($real_directory);
|
$files = filemanager_list_dir($real_directory);
|
||||||
|
|
||||||
$table = new stdClass();
|
if (!empty($files)) {
|
||||||
$table->width = '100%';
|
$table = new stdClass();
|
||||||
$table->id = 'table_filemanager';
|
$table->width = '100%';
|
||||||
if (!defined('METACONSOLE')) {
|
$table->id = 'table_filemanager';
|
||||||
$table->class = 'info_table';
|
if (!defined('METACONSOLE')) {
|
||||||
$table->title = '<span>'.__('Index of %s', $relative_directory).'</span>';
|
$table->class = 'info_table';
|
||||||
}
|
$table->title = '<span>'.__('Index of %s', $relative_directory).'</span>';
|
||||||
|
|
||||||
if (defined('METACONSOLE')) {
|
|
||||||
$table->class = 'databox_tactical';
|
|
||||||
$table->title = '<span>'.__('Index of %s', $relative_directory).'</span>';
|
|
||||||
}
|
|
||||||
|
|
||||||
$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 (($prev_dir_str != '') && ($father != $relative_directory)) {
|
if (defined('METACONSOLE')) {
|
||||||
$table->data[0][0] = html_print_image('images/go_previous.png', true);
|
$table->class = 'databox_tactical';
|
||||||
$table->data[0][1] = '<a href="'.$url.'&directory='.$prev_dir_str.'&hash2='.md5($prev_dir_str.$config['dbpass']).'">';
|
$table->title = '<span>'.__('Index of %s', $relative_directory).'</span>';
|
||||||
$table->data[0][1] .= __('Parent directory');
|
}
|
||||||
$table->data[0][1] .= '</a>';
|
|
||||||
|
|
||||||
$table->colspan[0][1] = 5;
|
$table->colspan = [];
|
||||||
}
|
$table->data = [];
|
||||||
|
$table->head = [];
|
||||||
|
$table->size = [];
|
||||||
|
|
||||||
foreach ($files as $fileinfo) {
|
$table->align[1] = 'left';
|
||||||
$fileinfo['realpath'] = str_replace('\\', '/', $fileinfo['realpath']);
|
$table->align[2] = 'left';
|
||||||
$relative_path = str_replace($_SERVER['DOCUMENT_ROOT'], '', $fileinfo['realpath']);
|
$table->align[3] = 'left';
|
||||||
|
$table->align[4] = 'left';
|
||||||
|
|
||||||
$data = [];
|
$table->size[0] = '24px';
|
||||||
|
|
||||||
switch ($fileinfo['mime']) {
|
$table->head[0] = '';
|
||||||
case MIME_DIR:
|
$table->head[1] = __('Name');
|
||||||
$data[0] = html_print_image('images/mimetypes/directory.png', true, ['title' => __('Directory')]);
|
$table->head[2] = __('Last modification');
|
||||||
break;
|
$table->head[3] = __('Size');
|
||||||
|
$table->head[4] = __('Actions');
|
||||||
|
|
||||||
case MIME_IMAGE:
|
$prev_dir = explode('/', $relative_directory);
|
||||||
$data[0] = html_print_image('images/mimetypes/image.png', true, ['title' => __('Image')]);
|
$prev_dir_str = '';
|
||||||
break;
|
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:
|
if (($prev_dir_str != '') && ($father != $relative_directory)) {
|
||||||
$data[0] = html_print_image('images/mimetypes/zip.png', true, ['title' => __('Compressed file')]);
|
$table->data[0][0] = html_print_image('images/go_previous.png', true);
|
||||||
break;
|
$table->data[0][1] = '<a href="'.$url.'&directory='.$prev_dir_str.'&hash2='.md5($prev_dir_str.$config['dbpass']).'">';
|
||||||
|
$table->data[0][1] .= __('Parent directory');
|
||||||
|
$table->data[0][1] .= '</a>';
|
||||||
|
|
||||||
case MIME_TEXT:
|
$table->colspan[0][1] = 5;
|
||||||
$data[0] = html_print_image('images/mimetypes/text.png', true, ['title' => __('Text file')]);
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
case MIME_UNKNOWN:
|
foreach ($files as $fileinfo) {
|
||||||
if ($fileinfo['size'] == 0) {
|
$fileinfo['realpath'] = str_replace('\\', '/', $fileinfo['realpath']);
|
||||||
if ((strstr($fileinfo['name'], '.txt') !== false) || (strstr($fileinfo['name'], '.conf') !== false) || (strstr($fileinfo['name'], '.sql') !== false) || (strstr($fileinfo['name'], '.pl') !== false)) {
|
$relative_path = str_replace($_SERVER['DOCUMENT_ROOT'], '', $fileinfo['realpath']);
|
||||||
$fileinfo['mime'] = MIME_TEXT;
|
|
||||||
$data[0] = html_print_image('images/mimetypes/text.png', true, ['title' => __('Text file')]);
|
$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 {
|
} else {
|
||||||
// unknow
|
// pdf
|
||||||
$data[0] = '';
|
$data[0] = '';
|
||||||
}
|
}
|
||||||
} else {
|
break;
|
||||||
// pdf
|
|
||||||
$data[0] = '';
|
default:
|
||||||
|
$data[0] = html_print_image('images/mimetypes/unknown.png', true, ['title' => __('Unknown')]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($fileinfo['is_dir']) {
|
||||||
|
$data[1] = '<a href="'.$url.'&directory='.$relative_directory.'/'.$fileinfo['name'].'&hash2='.md5($relative_directory.'/'.$fileinfo['name'].$config['dbpass']).'">'.$fileinfo['name'].'</a>';
|
||||||
|
} else if (!empty($url_file)) {
|
||||||
|
// Set the custom url file
|
||||||
|
$url_file_clean = str_replace('[FILE_FULLPATH]', $fileinfo['realpath'], $url_file);
|
||||||
|
|
||||||
|
$data[1] = '<a href="'.$url_file_clean.'">'.$fileinfo['name'].'</a>';
|
||||||
|
} else {
|
||||||
|
$filename = base64_encode($relative_directory.'/'.$fileinfo['name']);
|
||||||
|
$hash = md5($filename.$config['dbpass']);
|
||||||
|
$data[1] = '<a href="'.$hack_metaconsole.'include/get_file.php?file='.urlencode($filename).'&hash='.$hash.'">'.$fileinfo['name'].'</a>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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] = '<span class="error forced_title" data-title="'.$error_message.'" data-use_title_for_force_title="1">'.$data[1].'</span>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$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] .= '<span style="display: flex">';
|
||||||
|
$typefile = array_pop(explode('.', $fileinfo['name']));
|
||||||
|
if (is_writable($fileinfo['realpath'])
|
||||||
|
&& (! is_dir($fileinfo['realpath']) || count(scandir($fileinfo['realpath'])) < 3) && (!$readOnly)
|
||||||
|
) {
|
||||||
|
$data[4] .= '<form method="post" action="'.$url.'" style="">';
|
||||||
|
$data[4] .= '<input type="image" src="images/cross.png" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
|
||||||
|
$data[4] .= html_print_input_hidden('filename', $fileinfo['realpath'], true);
|
||||||
|
$data[4] .= html_print_input_hidden('hash', md5($fileinfo['realpath'].$config['dbpass']), true);
|
||||||
|
$data[4] .= html_print_input_hidden('delete_file', 1, true);
|
||||||
|
|
||||||
|
$relative_dir = str_replace($homedir_filemanager, '', str_replace('\\', '/', dirname($fileinfo['realpath'])));
|
||||||
|
|
||||||
|
if ($relative_dir[0] == '/') {
|
||||||
|
$relative_dir = substr($relative_dir, 1);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
$hash2 = md5($relative_dir.$config['dbpass']);
|
||||||
$data[0] = html_print_image('images/mimetypes/unknown.png', true, ['title' => __('Unknown')]);
|
|
||||||
break;
|
$data[4] .= html_print_input_hidden('directory', $relative_dir, true);
|
||||||
|
$data[4] .= html_print_input_hidden('hash2', $hash2, true);
|
||||||
|
$data[4] .= '</form>';
|
||||||
|
|
||||||
|
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] .= "<a style='vertical-align: top;' href='$url&edit_file=1&hash=".$hash.'&location_file='.$fileinfo['realpath']."' style='float: left;'>".html_print_image('images/edit.png', true, ['style' => 'margin-top: 2px;', 'title' => __('Edit file')]).'</a>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((!$fileinfo['is_dir']) && ($download_button)) {
|
||||||
|
$filename = base64_encode($fileinfo['name']);
|
||||||
|
$hash = md5($filename.$config['dbpass']);
|
||||||
|
$data[4] .= '<a href="include/get_file.php?file='.urlencode($filename).'&hash='.$hash.'" style="vertical-align: 25%;">';
|
||||||
|
$data[4] .= html_print_image('images/file.png', true);
|
||||||
|
$data[4] .= '</a>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$data[4] .= '</span>';
|
||||||
|
|
||||||
|
array_push($table->data, $data);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
if ($fileinfo['is_dir']) {
|
ui_print_info_message(
|
||||||
$data[1] = '<a href="'.$url.'&directory='.$relative_directory.'/'.$fileinfo['name'].'&hash2='.md5($relative_directory.'/'.$fileinfo['name'].$config['dbpass']).'">'.$fileinfo['name'].'</a>';
|
[
|
||||||
} else if (!empty($url_file)) {
|
'no_close' => true,
|
||||||
// Set the custom url file
|
'message' => __('No files or directories to show.'),
|
||||||
$url_file_clean = str_replace('[FILE_FULLPATH]', $fileinfo['realpath'], $url_file);
|
]
|
||||||
|
|
||||||
$data[1] = '<a href="'.$url_file_clean.'">'.$fileinfo['name'].'</a>';
|
|
||||||
} else {
|
|
||||||
$filename = base64_encode($relative_directory.'/'.$fileinfo['name']);
|
|
||||||
$hash = md5($filename.$config['dbpass']);
|
|
||||||
$data[1] = '<a href="'.$hack_metaconsole.'include/get_file.php?file='.urlencode($filename).'&hash='.$hash.'">'.$fileinfo['name'].'</a>';
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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] = '<span class="error forced_title" data-title="'.$error_message.'" data-use_title_for_force_title="1">'.$data[1].'</span>';
|
|
||||||
}
|
|
||||||
|
|
||||||
$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] .= '<span style="display: flex">';
|
|
||||||
$typefile = array_pop(explode('.', $fileinfo['name']));
|
|
||||||
if (is_writable($fileinfo['realpath'])
|
|
||||||
&& (! is_dir($fileinfo['realpath']) || count(scandir($fileinfo['realpath'])) < 3) && (!$readOnly)
|
|
||||||
) {
|
|
||||||
$data[4] .= '<form method="post" action="'.$url.'" style="">';
|
|
||||||
$data[4] .= '<input type="image" src="images/cross.png" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
|
|
||||||
$data[4] .= html_print_input_hidden('filename', $fileinfo['realpath'], true);
|
|
||||||
$data[4] .= html_print_input_hidden('hash', md5($fileinfo['realpath'].$config['dbpass']), true);
|
|
||||||
$data[4] .= html_print_input_hidden('delete_file', 1, true);
|
|
||||||
|
|
||||||
$relative_dir = str_replace($homedir_filemanager, '', str_replace('\\', '/', dirname($fileinfo['realpath'])));
|
|
||||||
|
|
||||||
if ($relative_dir[0] == '/') {
|
|
||||||
$relative_dir = substr($relative_dir, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
$hash2 = md5($relative_dir.$config['dbpass']);
|
|
||||||
|
|
||||||
$data[4] .= html_print_input_hidden('directory', $relative_dir, true);
|
|
||||||
$data[4] .= html_print_input_hidden('hash2', $hash2, true);
|
|
||||||
$data[4] .= '</form>';
|
|
||||||
|
|
||||||
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] .= "<a style='vertical-align: top;' href='$url&edit_file=1&hash=".$hash.'&location_file='.$fileinfo['realpath']."' style='float: left;'>".html_print_image('images/edit.png', true, ['style' => 'margin-top: 2px;', 'title' => __('Edit file')]).'</a>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((!$fileinfo['is_dir']) && ($download_button)) {
|
|
||||||
$filename = base64_encode($fileinfo['name']);
|
|
||||||
$hash = md5($filename.$config['dbpass']);
|
|
||||||
$data[4] .= '<a href="include/get_file.php?file='.urlencode($filename).'&hash='.$hash.'" style="vertical-align: 25%;">';
|
|
||||||
$data[4] .= html_print_image('images/file.png', true);
|
|
||||||
$data[4] .= '</a>';
|
|
||||||
}
|
|
||||||
|
|
||||||
$data[4] .= '</span>';
|
|
||||||
|
|
||||||
array_push($table->data, $data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$readOnly) {
|
if (!$readOnly) {
|
||||||
|
|
Loading…
Reference in New Issue