diff options
| author | Nils Adermann <naderman@naderman.de> | 2010-03-02 01:05:39 +0100 |
|---|---|---|
| committer | Nils Adermann <naderman@naderman.de> | 2010-03-02 01:05:39 +0100 |
| commit | a0b58772175ce7490872356c5050d08bd15b488b (patch) | |
| tree | f99eb0f4b0984cca5020daf403286370f739f414 /phpBB/includes/functions.php | |
| parent | 6482e72e7c7b7d6b73cef970197789a2c139f44e (diff) | |
| parent | a94c760650a9454d1ac33b30243898eae57f8f4f (diff) | |
| download | forums-a0b58772175ce7490872356c5050d08bd15b488b.tar forums-a0b58772175ce7490872356c5050d08bd15b488b.tar.gz forums-a0b58772175ce7490872356c5050d08bd15b488b.tar.bz2 forums-a0b58772175ce7490872356c5050d08bd15b488b.tar.xz forums-a0b58772175ce7490872356c5050d08bd15b488b.zip | |
Merge commit 'release-3.0.4-RC1'
Diffstat (limited to 'phpBB/includes/functions.php')
| -rw-r--r-- | phpBB/includes/functions.php | 63 |
1 files changed, 47 insertions, 16 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index b96024e4e3..55c4cc5b51 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -462,7 +462,7 @@ function _hash_crypt_private($password, $setting, &$itoa64) /** * Global function for chmodding directories and files for internal use * This function determines owner and group whom the file belongs to and user and group of PHP and then set safest possible file permissions. -* The function determines owner and group from common.php file and sets the same to the provided file. +* The function determines owner and group from common.php file and sets the same to the provided file. Permissions are mapped to the group, user always has rw(x) permission. * The function uses bit fields to build the permissions. * The function sets the appropiate execute bit on directories. * @@ -511,6 +511,7 @@ function phpbb_chmod($filename, $perms = CHMOD_READ) // Will most likely not work if (@chown($filename, $common_php_owner)); { + clearstatcache(); $file_uid = fileowner($filename); } } @@ -520,6 +521,7 @@ function phpbb_chmod($filename, $perms = CHMOD_READ) { if (@chgrp($filename, $common_php_group)); { + clearstatcache(); $file_gid = filegroup($filename); } } @@ -532,7 +534,7 @@ function phpbb_chmod($filename, $perms = CHMOD_READ) // Who is PHP? if ($file_uid === false || $file_gid === false || $php_uid === false || $php_gids === false) { - $php = null; + $php = NULL; } else if ($file_uid == $php_uid /* && $common_php_owner !== false && $common_php_owner === $file_uid*/) { @@ -564,16 +566,23 @@ function phpbb_chmod($filename, $perms = CHMOD_READ) { case null: case 'owner': + /* ATTENTION: if php is owner or NULL we set it to group here. This is the most failsafe combination for the vast majority of server setups. + $result = @chmod($filename, ($owner << 6) + (0 << 3) + (0 << 0)); + clearstatcache(); + if (!is_null($php) || (is_readable($filename) && is_writable($filename))) { break; } + */ case 'group': $result = @chmod($filename, ($owner << 6) + ($perms << 3) + (0 << 0)); + clearstatcache(); + if (!is_null($php) || ((!($perms & CHMOD_READ) || is_readable($filename)) && (!($perms & CHMOD_WRITE) || is_writable($filename)))) { break; @@ -582,6 +591,8 @@ function phpbb_chmod($filename, $perms = CHMOD_READ) case 'other': $result = @chmod($filename, ($owner << 6) + ($perms << 3) + ($perms << 0)); + clearstatcache(); + if (!is_null($php) || ((!($perms & CHMOD_READ) || is_readable($filename)) && (!($perms & CHMOD_WRITE) || is_writable($filename)))) { break; @@ -1820,30 +1831,45 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false) } } - // Assign sid if session id is not specified - if ($session_id === false) - { - $session_id = $_SID; - } - - $amp_delim = ($is_amp) ? '&' : '&'; - $url_delim = (strpos($url, '?') === false) ? '?' : $amp_delim; - - // Appending custom url parameter? - $append_url = (!empty($_EXTRA_URL)) ? implode($amp_delim, $_EXTRA_URL) : ''; + $params_is_array = is_array($params); + // Get anchor $anchor = ''; if (strpos($url, '#') !== false) { list($url, $anchor) = explode('#', $url, 2); $anchor = '#' . $anchor; } - else if (!is_array($params) && strpos($params, '#') !== false) + else if (!$params_is_array && strpos($params, '#') !== false) { list($params, $anchor) = explode('#', $params, 2); $anchor = '#' . $anchor; } + // Handle really simple cases quickly + if ($_SID == '' && $session_id === false && empty($_EXTRA_URL) && !$params_is_array && !$anchor) + { + if ($params === false) + { + return $url; + } + + $url_delim = (strpos($url, '?') === false) ? '?' : (($is_amp) ? '&' : '&'); + return $url . ($params !== false ? $url_delim. $params : ''); + } + + // Assign sid if session id is not specified + if ($session_id === false) + { + $session_id = $_SID; + } + + $amp_delim = ($is_amp) ? '&' : '&'; + $url_delim = (strpos($url, '?') === false) ? '?' : $amp_delim; + + // Appending custom url parameter? + $append_url = (!empty($_EXTRA_URL)) ? implode($amp_delim, $_EXTRA_URL) : ''; + // Use the short variant if possible ;) if ($params === false) { @@ -2190,12 +2216,17 @@ function build_url($strip_vars = false) /** * Meta refresh assignment +* Adds META template variable with meta http tag. +* +* @param int $time Time in seconds for meta refresh tag +* @param string $url URL to redirect to. The url will go through redirect() first before the template variable is assigned +* @param bool $disable_cd_check If true, meta_refresh() will redirect to an external domain. If false, the redirect point to the boards url if it does not match the current domain. Default is false. */ -function meta_refresh($time, $url) +function meta_refresh($time, $url, $disable_cd_check = false) { global $template; - $url = redirect($url, true); + $url = redirect($url, true, $disable_cd_check); $url = str_replace('&', '&', $url); // For XHTML compatibility we change back & to & |
