From cd4f9e41dfdca96403af92075337ab4f42c00200 Mon Sep 17 00:00:00 2001 From: alexhigh Date: Thu, 24 Apr 2014 10:45:33 +0000 Subject: [PATCH] 2014-04-24 Alejandro Gallardo * install.php: Now the user path backslashes are replaced with slashes. * extensions/files_repo.php, extensions/files_repo/files_repo_form.php, extensions/files_repo/files_repo_get_file.php, extensions/files_repo/files_repo_list.php, extensions/files_repo/functions_files_repo.php: Replaced the 'DIRECTORY_SEPARATOR' var with slashes. Removed the realpath functions. * include/config.inc.php: Replaced the "owndir" final slash with a 'DIRECTORY_SEPARATOR'. * include/functions_html.php: Replaced the "$working_dir" backslashes with slashes. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@9809 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 19 ++++++++++++++++ pandora_console/extensions/files_repo.php | 22 +++++++++---------- .../extensions/files_repo/files_repo_form.php | 4 ++-- .../files_repo/files_repo_get_file.php | 8 +++---- .../extensions/files_repo/files_repo_list.php | 4 ++-- .../files_repo/functions_files_repo.php | 20 ++++++++--------- pandora_console/include/config.inc.php | 2 +- pandora_console/include/functions_html.php | 1 + pandora_console/install.php | 4 +++- 9 files changed, 52 insertions(+), 32 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 762d6df173..0275082311 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,22 @@ +2014-04-24 Alejandro Gallardo + + * install.php: Now the user path backslashes will be + replaced with slashes. + + * extensions/files_repo.php, + extensions/files_repo/files_repo_form.php, + extensions/files_repo/files_repo_get_file.php, + extensions/files_repo/files_repo_list.php, + extensions/files_repo/functions_files_repo.php: Replaced + the 'DIRECTORY_SEPARATOR' var with slashes. Removed the + realpath functions. + + * include/config.inc.php: Replaced the "owndir" final slash + with a 'DIRECTORY_SEPARATOR'. + + * include/functions_html.php: Replaced the "$working_dir" + possible backslashes with slashes. + 2014-04-24 Juan Manuel Ramon * operation/events/events.build_table.php: Fixed diff --git a/pandora_console/extensions/files_repo.php b/pandora_console/extensions/files_repo.php index 9f1d9837f0..14985a44e5 100644 --- a/pandora_console/extensions/files_repo.php +++ b/pandora_console/extensions/files_repo.php @@ -24,8 +24,8 @@ function pandora_files_repo_install () { } } - $full_extensions_dir = $config['homedir'].DIRECTORY_SEPARATOR.EXTENSIONS_DIR.DIRECTORY_SEPARATOR; - $full_sql_dir = $full_extensions_dir."files_repo".DIRECTORY_SEPARATOR."sql".DIRECTORY_SEPARATOR; + $full_extensions_dir = $config['homedir']."/".EXTENSIONS_DIR."/"; + $full_sql_dir = $full_extensions_dir."files_repo/sql/"; /* SQL installation */ switch ($config['dbtype']) { @@ -81,7 +81,7 @@ function pandora_files_repo_uninstall () { } if (!empty($config['attachment_store'])) - delete_dir($config['attachment_store'].DIRECTORY_SEPARATOR."files_repo"); + delete_dir($config['attachment_store']."/files_repo"); } function pandora_files_repo_godmode () { @@ -115,8 +115,8 @@ function pandora_files_repo_godmode () { // Header ui_print_page_header (__("Files repository manager"), "images/extensions.png", false, "", true, $onheader); - $full_extensions_dir = $config['homedir'].DIRECTORY_SEPARATOR.EXTENSIONS_DIR.DIRECTORY_SEPARATOR; - require_once ($full_extensions_dir."files_repo".DIRECTORY_SEPARATOR."functions_files_repo.php"); + $full_extensions_dir = $config['homedir']."/".EXTENSIONS_DIR."/"; + require_once ($full_extensions_dir."files_repo/functions_files_repo.php"); // Directory files_repo check if (!files_repo_check_directory(true)) { @@ -159,11 +159,11 @@ function pandora_files_repo_godmode () { } // FORM - require ($full_extensions_dir."files_repo".DIRECTORY_SEPARATOR."files_repo_form.php"); + require ($full_extensions_dir."files_repo/files_repo_form.php"); if (!$file_id) { // LIST $manage = true; - require ($full_extensions_dir."files_repo".DIRECTORY_SEPARATOR."files_repo_list.php"); + require ($full_extensions_dir."files_repo/files_repo_list.php"); } } @@ -189,8 +189,8 @@ function pandora_files_repo_operation () { // Header ui_print_page_header (__("Files repository"), "images/extensions.png", false, "", false, $onheader); - $full_extensions_dir = $config['homedir'].DIRECTORY_SEPARATOR.EXTENSIONS_DIR.DIRECTORY_SEPARATOR; - require_once ($full_extensions_dir."files_repo".DIRECTORY_SEPARATOR."functions_files_repo.php"); + $full_extensions_dir = $config['homedir']."/".EXTENSIONS_DIR."/"; + require_once ($full_extensions_dir."files_repo/functions_files_repo.php"); // Directory files_repo check if (!files_repo_check_directory(true)) { @@ -198,8 +198,8 @@ function pandora_files_repo_operation () { } // LIST - $full_extensions_dir = $config['homedir'].DIRECTORY_SEPARATOR.EXTENSIONS_DIR.DIRECTORY_SEPARATOR; - require ($full_extensions_dir."files_repo".DIRECTORY_SEPARATOR."files_repo_list.php"); + $full_extensions_dir = $config['homedir']."/".EXTENSIONS_DIR."/"; + require ($full_extensions_dir."files_repo/files_repo_list.php"); } extensions_add_operation_menu_option(__('Files repository'), null, null, "v1r1"); diff --git a/pandora_console/extensions/files_repo/files_repo_form.php b/pandora_console/extensions/files_repo/files_repo_form.php index ed5ec2ce5c..2032522295 100644 --- a/pandora_console/extensions/files_repo/files_repo_form.php +++ b/pandora_console/extensions/files_repo/files_repo_form.php @@ -17,8 +17,8 @@ global $config; -$full_extensions_dir = $config['homedir'].DIRECTORY_SEPARATOR.EXTENSIONS_DIR.DIRECTORY_SEPARATOR; -require_once ($full_extensions_dir."files_repo".DIRECTORY_SEPARATOR."functions_files_repo.php"); +$full_extensions_dir = $config['homedir']."/".EXTENSIONS_DIR."/"; +require_once ($full_extensions_dir."files_repo/functions_files_repo.php"); $file = array(); $file['name'] = ''; 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 c80b585cb1..e3d896b96b 100644 --- a/pandora_console/extensions/files_repo/files_repo_get_file.php +++ b/pandora_console/extensions/files_repo/files_repo_get_file.php @@ -15,8 +15,7 @@ // GNU General Public License for more details. -$ds = DIRECTORY_SEPARATOR; -require_once ("..".$ds."..".$ds."include".$ds."config.php"); +require_once ("../../include/config.php"); $file_hash = (string) get_parameter('file'); @@ -45,15 +44,14 @@ if (!$check_hash) { } // Get the location -$files_repo_path = $config['attachment_store'].$ds."files_repo"; -$location = $files_repo_path.$ds.$file['id']."_".$file['name']; +$files_repo_path = $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 } // All checks are fine. Download the file! header('Content-type: aplication/octet-stream;'); -header('Content-type: ' . mime_content_type($location) . ';'); header("Content-Length: " . filesize($location)); header('Content-Disposition: attachment; filename="' . $file['name'] . '"'); readfile($location); diff --git a/pandora_console/extensions/files_repo/files_repo_list.php b/pandora_console/extensions/files_repo/files_repo_list.php index e3bff54a6d..c9a1601be8 100644 --- a/pandora_console/extensions/files_repo/files_repo_list.php +++ b/pandora_console/extensions/files_repo/files_repo_list.php @@ -17,8 +17,8 @@ global $config; -$full_extensions_dir = $config['homedir'].DIRECTORY_SEPARATOR.EXTENSIONS_DIR.DIRECTORY_SEPARATOR; -require_once ($full_extensions_dir."files_repo".DIRECTORY_SEPARATOR."functions_files_repo.php"); +$full_extensions_dir = $config['homedir']."/".EXTENSIONS_DIR."/"; +require_once ($full_extensions_dir."files_repo/functions_files_repo.php"); $offset = (int) get_parameter('offset'); $filter = array(); diff --git a/pandora_console/extensions/files_repo/functions_files_repo.php b/pandora_console/extensions/files_repo/functions_files_repo.php index e02d8f7595..6ed43b0de8 100644 --- a/pandora_console/extensions/files_repo/functions_files_repo.php +++ b/pandora_console/extensions/files_repo/functions_files_repo.php @@ -18,8 +18,8 @@ function files_repo_check_directory ($print_messages = false) { global $config; - $attachment_path = realpath($config['attachment_store']); - $files_repo_path = $attachment_path.DIRECTORY_SEPARATOR."files_repo"; + $attachment_path = $config['attachment_store']; + $files_repo_path = $attachment_path."/files_repo"; $result = false; $messages = ""; @@ -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'].DIRECTORY_SEPARATOR."files_repo"; + $files_repo_path = $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); @@ -149,7 +149,7 @@ function files_repo_get_files ($filter = false, $count = false) { $data = array(); $data['name'] = $file['name']; $data['description'] = $file['description']; - $data['location'] = $files_repo_path.DIRECTORY_SEPARATOR.$file['id']."_".$data['name']; + $data['location'] = $files_repo_path."/".$file['id']."_".$data['name']; // Size in bytes $data['size'] = filesize($data['location']); // Last modification time in unix timestamp @@ -169,8 +169,8 @@ 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 = realpath($config['attachment_store']); - $files_repo_path = $attachment_path.DIRECTORY_SEPARATOR."files_repo"; + $attachment_path = $config['attachment_store']; + $files_repo_path = $attachment_path."/"."files_repo"; $result = array(); $result["status"] = false; @@ -205,7 +205,7 @@ function files_repo_add_file ($file_input_name = "upfile", $description = "", $g if ($file_id) { $file_tmp = $_FILES[$file_input_name]['tmp_name']; - $destination = $files_repo_path.DIRECTORY_SEPARATOR.$file_id."_".$filename; + $destination = $files_repo_path."/".$file_id."_".$filename; if (move_uploaded_file($file_tmp, $destination)) { @@ -283,9 +283,9 @@ function files_repo_delete_file ($file_id) { $filename = db_get_value("name", "tfiles_repo", "id", $file_id); if ($filename) { - $attachment_path = realpath($config['attachment_store']); - $files_repo_path = $attachment_path.DIRECTORY_SEPARATOR."files_repo"; - $location = $files_repo_path.DIRECTORY_SEPARATOR.$file_id."_".$filename; + $attachment_path = $config['attachment_store']; + $files_repo_path = $attachment_path."/files_repo"; + $location = $files_repo_path."/".$file_id."_".$filename; if (file_exists($location)) { $result = false; diff --git a/pandora_console/include/config.inc.php b/pandora_console/include/config.inc.php index d8e3ac8114..3499a67852 100644 --- a/pandora_console/include/config.inc.php +++ b/pandora_console/include/config.inc.php @@ -38,6 +38,6 @@ error_reporting(E_ALL); // Display ALL errors // error_reporting(E_ERROR); -$ownDir = dirname(__FILE__) . '/'; +$ownDir = dirname(__FILE__) . DIRECTORY_SEPARATOR; include ($ownDir . "config_process.php"); ?> diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 6a84e58429..4f7e755246 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -21,6 +21,7 @@ if (!isset($config)) { $working_dir = getcwd(); + $working_dir = str_replace("\\", "/", $working_dir); // Windows compatibility $levels = substr_count($working_dir, '/'); for ($i = 0; $i < $levels; $i++) { diff --git a/pandora_console/install.php b/pandora_console/install.php index 96fc080a52..cad414cfa3 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -698,8 +698,10 @@ function install_step4() { $url = $_POST["url"]; else $url = "http://localhost"; - if (isset($_POST["path"])) + if (isset($_POST["path"])) { $path = $_POST["path"]; + $path = str_replace("\\", "/", $path); // Windows compatibility + } else $path = "/var/www"; }