".__('attach_error')."";
} else {
// Delete temporal file
unlink ($_FILES['file']['tmp_name']);
}
}
}
if ($delete_file) {
echo "
".__('Deleting file')."
";
$file = (string) get_parameter ('filename');
$directory = (string) get_parameter ('directory');
$full_filename = $directory.'/'.$file;
if (!is_dir ($full_filename)){
echo "".__('Deleting')." ".$full_filename."
";
unlink ($full_filename);
}
}
echo "".__('Pandora Setup')." » ".__('File manager')."
";
$directory = (string) get_parameter ('directory', "/");
// CREATE DIR
if ($create_dir) {
$dirname = (string) get_parameter ('dirname');
if ($dirname) {
@mkdir ($directory.'/'.$dirname);
echo ''.__('Created directory %s', $dirname).'
';
}
}
// A miminal security check to avoid directory traversal
if (preg_match ("/\.\./", $directory))
$directory = "images";
if (preg_match ("/^\//", $directory))
$directory = "images";
if (preg_match ("/^manager/", $directory))
$directory = "images";
/* Add custom directories here */
$fallback_directory = "images";
$banned_directories['include'] = true;
$banned_directories['godmode'] = true;
$banned_directories['operation'] = true;
$banned_directories['reporting'] = true;
$banned_directories['general'] = true;
$banned_directories[ENTERPRISE_DIR] = true;
if (isset ($banned_directories[$directory]))
$directory = $fallback_directory;
// Current directory
$available_directories[$directory] = $directory;
$real_directory = realpath ($config['homedir'].'/'.$directory);
$table->width = '50%';
$table->data = array ();
if (! is_file_manager_writable_dir ($real_directory)) {
echo "".__('Current directory is not writable by HTTP Server')."
";
echo '';
echo __('Please check that current directory has write rights for HTTP server');
echo '
';
} else {
$table->data[1][0] = __('Upload file');
$table->data[1][1] = print_input_file ('file', true, false);
$table->data[1][2] = print_submit_button (__('Go'), 'go', false,
'class="sub next"', true);
$table->data[1][2] .= print_input_hidden ('directory', $directory, true);
$table->data[1][2] .= print_input_hidden ('upload_file', 1, true);
}
echo '';
echo ''.__('Index of %s', $directory).'
';
// List files
if (! is_dir ($real_directory)) {
echo __('Directory %s doesn\'t exist!', $directory);
return;
}
$files = list_file_manager_dir ($real_directory);
$table->width = '90%';
$table->class = 'listing';
$table->colspan = array ();
$table->data = array ();
$table->head = array ();
$table->size = array ();
$table->size[0] = '24px';
$table->head[0] = '';
$table->head[1] = __('Name');
$table->head[2] = __('Last modification');
$table->head[3] = __('Size');
$table->head[4] = '';
$prev_dir = split ("/", $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 != '') {
$table->data[0][0] = print_image ('images/go_previous.png', true);
$table->data[0][1] = '';
$table->data[0][1] .= __('Parent directory');
$table->data[0][1] .='';
$table->colspan[0][1] = 5;
}
if (is_writable ($real_directory)) {
$table->data[1][0] = print_image ('images/mimetypes/directory.png', true,
array ('title' => __('Create directory')));
$table->data[1][1] = '';
$table->colspan[0][1] = 5;
}
foreach ($files as $fileinfo) {
$data = array ();
switch ($fileinfo['mime']) {
case MIME_DIR:
$data[0] = print_image ('images/mimetypes/directory.png', true);
break;
case MIME_IMAGE:
$data[0] = print_image ('images/mimetypes/image.png', true);
break;
case MIME_ZIP:
$data[0] = print_image ('images/mimetypes/zip.png', true);
break;
default:
$data[0] = print_image ('images/mimetypes/unknown.png', true);
}
if ($fileinfo['is_dir']) {
$data[1] = ''.$fileinfo['name'].'';
} else {
$data[1] = ''.$fileinfo['name'].'';
}
$data[2] = print_timestamp ($fileinfo['last_modified'], true,
array ('prominent' => true));
if ($fileinfo['is_dir']) {
$data[3] = '';
} else {
$data[3] = format_filesize ($fileinfo['size']);
}
array_push ($table->data, $data);
}
print_table ($table);
?>