From cafbdda3443db4c9ae0f6ce6a513160d20a7f46c Mon Sep 17 00:00:00 2001 From: alexhigh Date: Thu, 5 Jun 2014 12:06:03 +0000 Subject: [PATCH] 2014-06-05 Alejandro Gallardo * extensions/files_repo/files_repo_get_file.php, extensions/files_repo/files_repo_list.php, extensions/files_repo/functions_files_repo.php, godmode/setup/setup_general.php: Improved the Windows compatibility and fixed some errors. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@10120 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 8 ++++++++ .../extensions/files_repo/files_repo_get_file.php | 2 +- .../extensions/files_repo/files_repo_list.php | 7 +++++-- .../extensions/files_repo/functions_files_repo.php | 12 ++++++------ pandora_console/godmode/setup/setup_general.php | 2 +- 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 441fe854d7..13235fa0fb 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,11 @@ +2014-06-05 Alejandro Gallardo + + * extensions/files_repo/files_repo_get_file.php, + extensions/files_repo/files_repo_list.php, + extensions/files_repo/functions_files_repo.php, + godmode/setup/setup_general.php: Improved the Windows + compatibility and fixed some errors. + 2014-06-05 Vanessa Gil * godmode/agentes/configurar_agentes.php: Changed diff --git a/pandora_console/extensions/files_repo/files_repo_get_file.php b/pandora_console/extensions/files_repo/files_repo_get_file.php index e3d896b96b..aee720d050 100644 --- a/pandora_console/extensions/files_repo/files_repo_get_file.php +++ b/pandora_console/extensions/files_repo/files_repo_get_file.php @@ -44,7 +44,7 @@ if (!$check_hash) { } // Get the location -$files_repo_path = $config['attachment_store']."/files_repo"; +$files_repo_path = io_safe_output($config['attachment_store'])."/files_repo"; $location = $files_repo_path."/".$file['id']."_".$file['name']; if (!file_exists($location) || !is_readable($location) || !is_file($location)) { throw_error(5); // ERROR diff --git a/pandora_console/extensions/files_repo/files_repo_list.php b/pandora_console/extensions/files_repo/files_repo_list.php index f8889861b7..9acd6d01f0 100644 --- a/pandora_console/extensions/files_repo/files_repo_list.php +++ b/pandora_console/extensions/files_repo/files_repo_list.php @@ -64,15 +64,18 @@ if (!empty($files)) { $data = array(); // Prepare the filename for the get_file.php script - $relative_path = str_replace($_SERVER['DOCUMENT_ROOT'], '', $file['location']); + $document_root = str_replace("\\", "/", io_safe_output($_SERVER['DOCUMENT_ROOT'])); + $file['location'] = str_replace("\\", "/", io_safe_output($file['location'])); + $relative_path = str_replace($document_root, '', $file['location']); $file_path = base64_encode($relative_path); $hash = md5($relative_path . $config['dbpass']); $url = ui_get_full_url("include/get_file.php?file=$file_path&hash=$hash"); + $date_format = ($config['date_format']) ? io_safe_output($config['date_format']) : 'F j, Y - H:m'; $data[0] = "" . $file['name'] . ""; // Name $data[1] = ui_print_truncate_text($file['description'], 'description', true, true); // Description $data[2] = ui_format_filesize($file['size']); // Size - $data[3] = date('F j, Y - H:m', $file['mtime']); // Last modification + $data[3] = date($date_format, $file['mtime']); // Last modification // Public URL $data[4] = ""; diff --git a/pandora_console/extensions/files_repo/functions_files_repo.php b/pandora_console/extensions/files_repo/functions_files_repo.php index 6ed43b0de8..54a9d9efd3 100644 --- a/pandora_console/extensions/files_repo/functions_files_repo.php +++ b/pandora_console/extensions/files_repo/functions_files_repo.php @@ -18,7 +18,7 @@ function files_repo_check_directory ($print_messages = false) { global $config; - $attachment_path = $config['attachment_store']; + $attachment_path = io_safe_output($config['attachment_store']); $files_repo_path = $attachment_path."/files_repo"; $result = false; @@ -27,7 +27,7 @@ function files_repo_check_directory ($print_messages = false) { // attachment/ check if (!is_writable($attachment_path)) { $messages .= ui_print_error_message(array('message' => __('Attachment directory is not writable by HTTP Server') - .''.'

'.__('Please check that the web server has write rights on the {HOMEDIR}/attachment directory'), + .''.'

'.sprinf(__('Please check that the web server has write rights on the %s directory'), $attachment_path), 'no_close' => true, 'force_style' => 'color: #000000 !important'), '', true); } else { // attachment/agent_packages/ check @@ -38,7 +38,7 @@ function files_repo_check_directory ($print_messages = false) { } if (!is_writable($files_repo_path)) { $messages .= ui_print_error_message(array('message' => __('Attachment directory is not writable by HTTP Server') - .''.'

'.__('Please check that the web server has write rights on the {HOMEDIR}/attachment directory'), + .''.'

'.sprinf(__('Please check that the web server has write rights on the %s directory'), $attachment_path), 'no_close' => true, 'force_style' => 'color: #000000 !important'), '', true); } else { $result = true; @@ -127,7 +127,7 @@ function files_repo_get_files ($filter = false, $count = false) { global $config; // Don't use the realpath for the download links! - $files_repo_path = $config['attachment_store']."/files_repo"; + $files_repo_path = io_safe_output($config['attachment_store'])."/files_repo"; $sql = "SELECT * FROM tfiles_repo " . db_format_array_where_clause_sql($filter, "AND", "WHERE"); $files = db_get_all_rows_sql($sql); @@ -169,7 +169,7 @@ function files_repo_get_files ($filter = false, $count = false) { function files_repo_add_file ($file_input_name = "upfile", $description = "", $groups = array(), $public = false) { global $config; - $attachment_path = $config['attachment_store']; + $attachment_path = io_safe_output($config['attachment_store']); $files_repo_path = $attachment_path."/"."files_repo"; $result = array(); @@ -283,7 +283,7 @@ function files_repo_delete_file ($file_id) { $filename = db_get_value("name", "tfiles_repo", "id", $file_id); if ($filename) { - $attachment_path = $config['attachment_store']; + $attachment_path = io_safe_output($config['attachment_store']); $files_repo_path = $attachment_path."/files_repo"; $location = $files_repo_path."/".$file_id."_".$filename; diff --git a/pandora_console/godmode/setup/setup_general.php b/pandora_console/godmode/setup/setup_general.php index e7cef9be80..0883f2d448 100644 --- a/pandora_console/godmode/setup/setup_general.php +++ b/pandora_console/godmode/setup/setup_general.php @@ -162,7 +162,7 @@ if ($config["integria_enabled"]) { $table->data[19][0] = __('Enable Netflow'); $rbt_disabled = false; -if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) { +if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { $rbt_disabled = true; $table->data[19][0] .= ui_print_help_tip (__('Not supported in Windows systems.'), true); }