2013-06-27 Miguel de Dios <miguel.dedios@artica.es>
* godmode/servers/plugin.php, godmode/setup/file_manager.php, include/functions_filemanager.php: added the filemanager to server plugin, and of course change the code for to make this feature. MERGED FROM THE BRANCH PANDORA_4_0 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8429 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
ca47644a7f
commit
5bf1f2216f
|
@ -1,3 +1,11 @@
|
|||
2013-06-27 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* godmode/servers/plugin.php, godmode/setup/file_manager.php,
|
||||
include/functions_filemanager.php: added the filemanager to server
|
||||
plugin, and of course change the code for to make this feature.
|
||||
|
||||
MERGED FROM THE BRANCH PANDORA_4_0
|
||||
|
||||
2013-06-26 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql,
|
||||
|
|
|
@ -29,6 +29,8 @@ if (is_ajax ()) {
|
|||
// Load global vars
|
||||
global $config;
|
||||
|
||||
require_once ("include/functions_filemanager.php");
|
||||
|
||||
check_login ();
|
||||
|
||||
if (! check_acl ($config['id_user'], 0, "LM")) {
|
||||
|
@ -42,6 +44,8 @@ enterprise_include_once ('meta/include/functions_components_meta.php');
|
|||
|
||||
$view = get_parameter ("view", "");
|
||||
$create = get_parameter ("create", "");
|
||||
$filemanager = (bool)get_parameter("filemanager", false);
|
||||
$plugin_command = get_parameter('plugin_command', '');
|
||||
|
||||
if ($view != "") {
|
||||
$form_id = $view;
|
||||
|
@ -50,26 +54,89 @@ if ($view != "") {
|
|||
$form_description = $plugin["description"];
|
||||
$form_max_timeout = $plugin ["max_timeout"];
|
||||
$form_max_retries = $plugin ["max_retries"];
|
||||
if (empty($plugin_command))
|
||||
$form_execute = $plugin ["execute"];
|
||||
else
|
||||
$form_execute = $plugin_command;
|
||||
$form_plugin_type = $plugin ["plugin_type"];
|
||||
$macros = $plugin ["macros"];
|
||||
$parameters = $plugin ["parameters"];
|
||||
}
|
||||
|
||||
if ($create != "") {
|
||||
$form_id = 0;
|
||||
$form_name = "";
|
||||
$form_description = "";
|
||||
$form_max_timeout = 15;
|
||||
$form_max_retries = 1;
|
||||
$form_execute = "";
|
||||
$form_execute = $plugin_command;
|
||||
$form_plugin_type = 0;
|
||||
$form_parameters = "";
|
||||
$macros = "";
|
||||
$parameters = "";
|
||||
}
|
||||
//END LOAD VALUES
|
||||
|
||||
// =====================================================================
|
||||
// INIT FILEMANAGER
|
||||
// =====================================================================
|
||||
if ($filemanager) {
|
||||
|
||||
$id_plugin = (int)get_parameter('id_plugin', 0);
|
||||
|
||||
|
||||
/* Add custom directories here */
|
||||
$fallback_directory = "attachment/plugin";
|
||||
|
||||
$directory = (string) get_parameter ('directory', $fallback_directory);
|
||||
|
||||
// A miminal security check to avoid directory traversal
|
||||
if (preg_match ("/\.\./", $directory))
|
||||
$directory = $fallback_directory;
|
||||
if (preg_match ("/^\//", $directory))
|
||||
$directory = $fallback_directory;
|
||||
if (preg_match ("/^manager/", $directory))
|
||||
$directory = $fallback_directory;
|
||||
|
||||
$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;
|
||||
|
||||
$real_directory = realpath ($config['homedir'] . '/' . $directory);
|
||||
|
||||
echo '<h4>' . __('Index of %s', $directory) . '</h4>';
|
||||
|
||||
$chunck_url = '&view=' . $id_plugin;
|
||||
if ($id_plugin == 0) {
|
||||
$chunck_url = '&create=1';
|
||||
}
|
||||
|
||||
filemanager_file_explorer($real_directory,
|
||||
$directory,
|
||||
'index.php?sec=gservers&sec2=godmode/servers/plugin&filemanager=1&id_plugin=' . $id_plugin,
|
||||
$fallback_directory,
|
||||
false,
|
||||
false,
|
||||
'index.php?sec=gservers&sec2=godmode/servers/plugin' . $chunck_url . '&plugin_command=[FILE_FULLPATH]&id_plugin=' . $id_plugin,
|
||||
true,
|
||||
0775);
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// =====================================================================
|
||||
// END FILEMANAGER
|
||||
// =====================================================================
|
||||
|
||||
// SHOW THE FORM
|
||||
// =================================================================
|
||||
// =====================================================================
|
||||
|
||||
$sec = 'gservers';
|
||||
|
||||
|
@ -168,6 +235,9 @@ if (($create != "") OR ($view != "")) {
|
|||
if ($locked) {
|
||||
$data[1] .= html_print_image('images/lock.png', true, array('class' => 'command_advanced_conf'));
|
||||
}
|
||||
$data[1] .= ' <a href="index.php?sec=gservers&sec2=godmode/servers/plugin&filemanager=1&id_plugin=' . $form_id . '" style="vertical-align: bottom;">';
|
||||
$data[1] .= html_print_image('images/file.png', true);
|
||||
$data[1] .= '</a>';
|
||||
$table->data['plugin_command'] = $data;
|
||||
|
||||
$data = array();
|
||||
|
|
|
@ -57,12 +57,11 @@ $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);
|
||||
|
||||
echo '<h4>' . __('Index of %s', $directory) . '</h4>';
|
||||
|
||||
filemanager_file_explorer($real_directory, $directory, 'index.php?sec=gsetup&sec2=godmode/setup/file_manager');
|
||||
filemanager_file_explorer($real_directory,
|
||||
$directory,
|
||||
'index.php?sec=gsetup&sec2=godmode/setup/file_manager');
|
||||
?>
|
||||
|
|
|
@ -151,6 +151,7 @@ if ($upload_file) {
|
|||
$filesize = $_FILES['file']['size'];
|
||||
$real_directory = (string) get_parameter('real_directory');
|
||||
$directory = (string) get_parameter ('directory');
|
||||
$umask = (string)get_parameter('umask', '');
|
||||
|
||||
$hash = get_parameter('hash', '');
|
||||
$testHash = md5($real_directory . $directory . $config['dbpass']);
|
||||
|
@ -172,6 +173,10 @@ if ($upload_file) {
|
|||
$config['filemanager']['message'] = ui_print_error_message(__('Upload error'), '', true);
|
||||
}
|
||||
else {
|
||||
if ($umask !== '') {
|
||||
chmod($nombre_archivo, $umask);
|
||||
}
|
||||
|
||||
$config['filemanager']['correct_upload_file'] = 1;
|
||||
$config['filemanager']['message'] = ui_print_success_message(__('Upload correct'), '', true);
|
||||
|
||||
|
@ -208,6 +213,7 @@ if ($create_text_file) {
|
|||
$real_directory = io_safe_output($real_directory);
|
||||
$directory = (string) get_parameter ('directory');
|
||||
$directory = io_safe_output($directory);
|
||||
$umask = (string)get_parameter('umask', '');
|
||||
|
||||
$hash = get_parameter('hash', '');
|
||||
$testHash = md5($real_directory . $directory . $config['dbpass']);
|
||||
|
@ -228,6 +234,10 @@ if ($create_text_file) {
|
|||
$config['filemanager']['message'] = ui_print_error_message(__('Error creating file'), '', true);
|
||||
}
|
||||
else {
|
||||
if ($umask !== '') {
|
||||
chmod($nombre_archivo, $umask);
|
||||
}
|
||||
|
||||
$config['filemanager']['message'] = ui_print_success_message(__('Upload correct'), '', true);
|
||||
$config['filemanager']['correct_upload_file'] = 1;
|
||||
}
|
||||
|
@ -403,12 +413,10 @@ function filemanager_read_recursive_dir($dir, $relative_path = '') {
|
|||
{
|
||||
while (false !== ($entry = readdir($handle))) {
|
||||
if (($entry != ".") && ($entry != "..")) {
|
||||
if (is_dir($dir . $entry))
|
||||
{
|
||||
if (is_dir($dir . $entry)) {
|
||||
$return = array_merge($return, filemanager_read_recursive_dir($dir . $entry . '/', $relative_path . $entry . '/' ));
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
$return[] = array('relative' => $relative_path . $entry, 'absolute' => $dir . $entry);
|
||||
}
|
||||
}
|
||||
|
@ -427,8 +435,11 @@ function filemanager_read_recursive_dir($dir, $relative_path = '') {
|
|||
* @param string $url The url to set in the forms and some links in the explorer.
|
||||
* @param string $father The directory father don't navigate bottom this.
|
||||
* @param boolean $editor The flag to set the edition of text files.
|
||||
* @param string $url_file The url to put in the files instead the default. By default empty string and use the url of filemanager.
|
||||
* @param boolean $download_button The flag to show download button, by default false.
|
||||
* @param string $umask The umask as hex values to set the new files or updload.
|
||||
*/
|
||||
function filemanager_file_explorer($real_directory, $relative_directory, $url, $father = '', $editor = false, $readOnly = false) {
|
||||
function filemanager_file_explorer($real_directory, $relative_directory, $url, $father = '', $editor = false, $readOnly = false, $url_file = '', $download_button = false, $umask = '') {
|
||||
global $config;
|
||||
|
||||
$hack_metaconsole = '';
|
||||
|
@ -459,7 +470,6 @@ function filemanager_file_explorer($real_directory, $relative_directory, $url, $
|
|||
}
|
||||
|
||||
function show_main_buttons_folder() {
|
||||
//$("#main_buttons").css("display", "");
|
||||
$("#table2-1").css('display', 'none');
|
||||
$("#create_folder").css("display", "none");
|
||||
$("#upload_file").css("display", "none");
|
||||
|
@ -537,6 +547,7 @@ function filemanager_file_explorer($real_directory, $relative_directory, $url, $
|
|||
$table->data[1][1] .= '<form method="post" action="' . $url . '" enctype="multipart/form-data">';
|
||||
$table->data[1][1] .= ui_print_help_tip (__("The zip upload in this dir, easy to upload multiple files."), true);
|
||||
$table->data[1][1] .= html_print_input_file ('file', true, false);
|
||||
$table->data[1][1] .= html_print_input_hidden('umask', $umask, true);
|
||||
$table->data[1][1] .= html_print_checkbox('decompress', 1, false, true);
|
||||
$table->data[1][1] .= __('Decompress');
|
||||
$table->data[1][1] .= ' ';
|
||||
|
@ -557,6 +568,7 @@ function filemanager_file_explorer($real_directory, $relative_directory, $url, $
|
|||
$table->data[1][1] .= html_print_input_hidden ('real_directory', $real_directory, true);
|
||||
$table->data[1][1] .= html_print_input_hidden ('directory', $relative_directory, true);
|
||||
$table->data[1][1] .= html_print_input_hidden('hash', md5($real_directory . $relative_directory . $config['dbpass']), true);
|
||||
$table->data[1][1] .= html_print_input_hidden('umask', $umask, true);
|
||||
$table->data[1][1] .= html_print_input_hidden ('create_text_file', 1, true);
|
||||
$table->data[1][1] .= '</form>';
|
||||
$table->data[1][1] .= '</div>';
|
||||
|
@ -590,6 +602,12 @@ function filemanager_file_explorer($real_directory, $relative_directory, $url, $
|
|||
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 {
|
||||
$hash = md5($relative_path . $config['dbpass']);
|
||||
$data[1] = '<a href="' . $hack_metaconsole . 'include/get_file.php?file='.base64_encode($relative_path).'&hash=' . $hash . '">'.$fileinfo['name'].'</a>';
|
||||
|
@ -631,6 +649,12 @@ function filemanager_file_explorer($real_directory, $relative_directory, $url, $
|
|||
}
|
||||
}
|
||||
}
|
||||
if ((!$fileinfo['is_dir']) && ($download_button)) {
|
||||
$hash = md5($fileinfo['url'] . $config['dbpass']);
|
||||
$data[4] .= '<a href="include/get_file.php?file='.base64_encode($fileinfo['url']).'&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);
|
||||
|
|
Loading…
Reference in New Issue