From 2f4a618900e2c3b6ea14c68cbeb5897cd2ac1a04 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 29 May 2008 12:25:56 +0000 Subject: ok... i hope i haven't messed too much with the code and everything is still working. Changes: - Ascraeus now uses constants for the phpbb root path and the php extension. This ensures more security for external applications and modifications (no more overwriting of root path and extension possible through insecure mods and register globals enabled) as well as no more globalizing needed. - A second change implemented here is an additional short-hand-notation for append_sid(). It is allowed to omit the root path and extension now (for example calling append_sid('memberlist')) - in this case the root path and extension get added automatically. The hook is called after these are added. git-svn-id: file:///svn/phpbb/trunk@8572 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_transfer.php | 36 ++++++++++------------------------- 1 file changed, 10 insertions(+), 26 deletions(-) (limited to 'phpBB/includes/functions_transfer.php') diff --git a/phpBB/includes/functions_transfer.php b/phpBB/includes/functions_transfer.php index 9eb32a7b45..63f8d72e9f 100644 --- a/phpBB/includes/functions_transfer.php +++ b/phpBB/includes/functions_transfer.php @@ -38,13 +38,11 @@ class transfer */ function __construct() { - global $phpbb_root_path; - $this->file_perms = 0644; $this->dir_perms = 0777; // We use the store directory as temporary path to circumvent open basedir restrictions - $this->tmp_path = $phpbb_root_path . 'store/'; + $this->tmp_path = PHPBB_ROOT_PATH . 'store/'; } /** @@ -52,9 +50,7 @@ class transfer */ public function write_file($destination_file = '', $contents = '') { - global $phpbb_root_path; - - $destination_file = $this->root_path . str_replace($phpbb_root_path, '', $destination_file); + $destination_file = $this->root_path . str_replace(PHPBB_ROOT_PATH, '', $destination_file); // need to create a temp file and then move that temp file. // ftp functions can only move files around and can't create. @@ -104,9 +100,7 @@ class transfer */ public function make_dir($dir) { - global $phpbb_root_path; - - $dir = str_replace($phpbb_root_path, '', $dir); + $dir = str_replace(PHPBB_ROOT_PATH, '', $dir); $dir = explode('/', $dir); $dirs = ''; @@ -120,7 +114,7 @@ class transfer } $cur_dir = $dir[$i] . '/'; - if (!file_exists($phpbb_root_path . $dirs . $cur_dir)) + if (!file_exists(PHPBB_ROOT_PATH . $dirs . $cur_dir)) { // create the directory $result = $this->_mkdir($dir[$i]); @@ -144,10 +138,8 @@ class transfer */ public function copy_file($from_loc, $to_loc) { - global $phpbb_root_path; - - $from_loc = ((strpos($from_loc, $phpbb_root_path) !== 0) ? $phpbb_root_path : '') . $from_loc; - $to_loc = $this->root_path . str_replace($phpbb_root_path, '', $to_loc); + $from_loc = ((strpos($from_loc, PHPBB_ROOT_PATH) !== 0) ? PHPBB_ROOT_PATH : '') . $from_loc; + $to_loc = $this->root_path . str_replace(PHPBB_ROOT_PATH, '', $to_loc); if (!file_exists($from_loc)) { @@ -164,9 +156,7 @@ class transfer */ public function delete_file($file) { - global $phpbb_root_path; - - $file = $this->root_path . str_replace($phpbb_root_path, '', $file); + $file = $this->root_path . str_replace(PHPBB_ROOT_PATH, '', $file); return $this->_delete($file); } @@ -177,9 +167,7 @@ class transfer */ public function remove_dir($dir) { - global $phpbb_root_path; - - $dir = $this->root_path . str_replace($phpbb_root_path, '', $dir); + $dir = $this->root_path . str_replace(PHPBB_ROOT_PATH, '', $dir); return $this->_rmdir($dir); } @@ -189,9 +177,7 @@ class transfer */ public function rename($old_handle, $new_handle) { - global $phpbb_root_path; - - $old_handle = $this->root_path . str_replace($phpbb_root_path, '', $old_handle); + $old_handle = $this->root_path . str_replace(PHPBB_ROOT_PATH, '', $old_handle); return $this->_rename($old_handle, $new_handle); } @@ -201,9 +187,7 @@ class transfer */ public function file_exists($directory, $filename) { - global $phpbb_root_path; - - $directory = $this->root_path . str_replace($phpbb_root_path, '', $directory); + $directory = $this->root_path . str_replace(PHPBB_ROOT_PATH, '', $directory); $this->_chdir($directory); $result = $this->_ls(''); -- cgit v1.2.1