ok, first attempt at solving some compatibility issues.

- dropping in replacement for realpath


git-svn-id: file:///svn/phpbb/trunk@6122 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2006-06-24 13:27:04 +00:00
parent 1042800c28
commit 3439d0f96e
5 changed files with 79 additions and 10 deletions

View file

@ -14,12 +14,12 @@ phpBB Project Manager : theFinn (James Atkinson)
phpBB Lead Developers : Acyd Burn (Meik Sievertsen) phpBB Lead Developers : Acyd Burn (Meik Sievertsen)
psoTFX (Paul S. Owen) [2001 - 09/2005] psoTFX (Paul S. Owen) [2001 - 09/2005]
phpBB Developers : DavidMJ (David M.) phpBB Developers : Ashe (Ludovic Arnaud) - [10/2002 - 11/2003, 06/2006 - ]
DavidMJ (David M.)
GrahamJE (Graham Eames) GrahamJE (Graham Eames)
naderman (Nils Aderman) naderman (Nils Aderman)
subBlue (Tom Beddard) subBlue (Tom Beddard)
Ashe (Ludovic Arnaud) - [10/2002 - 11/2003]
BartVB (Bart van Bragt) - [11/2000 - 03/2006] BartVB (Bart van Bragt) - [11/2000 - 03/2006]

View file

@ -376,6 +376,71 @@ if (!function_exists('stripos'))
} }
} }
if (!function_exists('realpath'))
{
/**
* Replacement for realpath if it is disabled
* This function is from the php manual by nospam at savvior dot com
*/
function phpbb_realpath($path)
{
$translated_path = getenv('PATH_TRANSLATED');
$translated_path = str_replace('\\', '/', $translated_path);
$translated_path = str_replace(basename(getenv('PATH_INFO')), '', $translated_path);
$translated_path .= '/';
if ($path == '.' || $path == './')
{
return $translated_path;
}
// now check for back directory
$translated_path .= $path;
$dirs = explode('/', $translated_path);
foreach ($dirs as $key => $value)
{
if ($value == '..')
{
$dirs[$key] = '';
$dirs[$key - 2] = '';
}
}
$translated_path = '';
foreach($dirs as $key => $value)
{
if (strlen($value) > 0)
{
$translated_path .= $value . '/';
}
}
$translated_path = substr($translated_path, 0, strlen($translated_path) - 1);
if (is_dir($translated_path) || is_file($translated_path))
{
return $translated_path;
}
return false;
}
}
else
{
/**
* A wrapper for realpath
*/
function phpbb_realpath($path)
{
return realpath($path);
}
}
// functions used for building option fields // functions used for building option fields
/** /**
@ -1189,8 +1254,8 @@ function redirect($url)
else else
{ {
// Get the realpath of dirname // Get the realpath of dirname
$root_dirs = explode('/', str_replace('\\', '/', realpath('./'))); $root_dirs = explode('/', str_replace('\\', '/', phpbb_realpath('./')));
$page_dirs = explode('/', str_replace('\\', '/', realpath($pathinfo['dirname']))); $page_dirs = explode('/', str_replace('\\', '/', phpbb_realpath($pathinfo['dirname'])));
$intersection = array_intersect_assoc($root_dirs, $page_dirs); $intersection = array_intersect_assoc($root_dirs, $page_dirs);
$root_dirs = array_diff_assoc($root_dirs, $intersection); $root_dirs = array_diff_assoc($root_dirs, $intersection);
@ -2144,7 +2209,7 @@ function get_backtrace()
$output = '<div style="font-family: monospace;">'; $output = '<div style="font-family: monospace;">';
$backtrace = debug_backtrace(); $backtrace = debug_backtrace();
$path = realpath($phpbb_root_path); $path = phpbb_realpath($phpbb_root_path);
foreach ($backtrace as $number => $trace) foreach ($backtrace as $number => $trace)
{ {
@ -2226,8 +2291,8 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
if (strpos($errfile, 'cache') === false && strpos($errfile, 'template.') === false) if (strpos($errfile, 'cache') === false && strpos($errfile, 'template.') === false)
{ {
// remove complete path to installation, with the risk of changing backslashes meant to be there // remove complete path to installation, with the risk of changing backslashes meant to be there
$errfile = str_replace(array(realpath($phpbb_root_path), '\\'), array('', '/'), $errfile); $errfile = str_replace(array(phpbb_realpath($phpbb_root_path), '\\'), array('', '/'), $errfile);
$msg_text = str_replace(array(realpath($phpbb_root_path), '\\'), array('', '/'), $msg_text); $msg_text = str_replace(array(phpbb_realpath($phpbb_root_path), '\\'), array('', '/'), $msg_text);
echo '<b>[phpBB Debug] PHP Notice</b>: in file <b>' . $errfile . '</b> on line <b>' . $errline . '</b>: <b>' . $msg_text . '</b><br />' . "\n"; echo '<b>[phpBB Debug] PHP Notice</b>: in file <b>' . $errfile . '</b> on line <b>' . $errline . '</b>: <b>' . $msg_text . '</b><br />' . "\n";
} }

View file

@ -141,6 +141,10 @@ function user_add($user_row, $cp_data = false)
'user_type' => $user_row['user_type'], 'user_type' => $user_row['user_type'],
); );
/**
* @todo user_allow_email is not used anywhere. Think about removing it.
*/
// These are the additional vars able to be specified // These are the additional vars able to be specified
$additional_vars = array( $additional_vars = array(
'user_permissions' => '', 'user_permissions' => '',

View file

@ -67,8 +67,8 @@ class session
$page_name = htmlspecialchars(basename($script_name)); $page_name = htmlspecialchars(basename($script_name));
// current directory within the phpBB root (for example: adm) // current directory within the phpBB root (for example: adm)
$root_dirs = explode('/', str_replace('\\', '/', realpath($root_path))); $root_dirs = explode('/', str_replace('\\', '/', phpbb_realpath($root_path)));
$page_dirs = explode('/', str_replace('\\', '/', realpath('./'))); $page_dirs = explode('/', str_replace('\\', '/', phpbb_realpath('./')));
$intersection = array_intersect_assoc($root_dirs, $page_dirs); $intersection = array_intersect_assoc($root_dirs, $page_dirs);
$root_dirs = array_diff_assoc($root_dirs, $intersection); $root_dirs = array_diff_assoc($root_dirs, $intersection);

View file

@ -100,7 +100,7 @@ $lang = array_merge($lang, array(
'COLOUR_SWATCH' => 'Colour swatch', 'COLOUR_SWATCH' => 'Colour swatch',
'CONFIRM' => 'Confirm', 'CONFIRM' => 'Confirm',
'CONFIRM_CODE' => 'Confirmation code', 'CONFIRM_CODE' => 'Confirmation code',
'CONFIRM_CODE_EXPLAIN' => 'Enter the code exactly as you see it in the image, it is case insensitive.', 'CONFIRM_CODE_EXPLAIN' => 'Enter the code exactly as you see it in the image, it is case insensitive. Please note that a zero does not exist.',
'CONFIRM_CODE_WRONG' => 'The confirmation code you entered was incorrect.', 'CONFIRM_CODE_WRONG' => 'The confirmation code you entered was incorrect.',
'CONGRATULATIONS' => 'Congratulations to', 'CONGRATULATIONS' => 'Congratulations to',
'CONNECTION_FAILED' => 'Connection failed', 'CONNECTION_FAILED' => 'Connection failed',