aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions.php
diff options
context:
space:
mode:
authorMeik Sievertsen <acydburn@phpbb.com>2006-06-24 13:27:04 +0000
committerMeik Sievertsen <acydburn@phpbb.com>2006-06-24 13:27:04 +0000
commit3439d0f96e4deeecc2e681e08bf66b7c70f01930 (patch)
tree6c8cc87fc51e079a6598cf63fadc8e8b7952e6bd /phpBB/includes/functions.php
parent1042800c286e6d0997b3446961eb4cd3dcf9cf30 (diff)
downloadforums-3439d0f96e4deeecc2e681e08bf66b7c70f01930.tar
forums-3439d0f96e4deeecc2e681e08bf66b7c70f01930.tar.gz
forums-3439d0f96e4deeecc2e681e08bf66b7c70f01930.tar.bz2
forums-3439d0f96e4deeecc2e681e08bf66b7c70f01930.tar.xz
forums-3439d0f96e4deeecc2e681e08bf66b7c70f01930.zip
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
Diffstat (limited to 'phpBB/includes/functions.php')
-rw-r--r--phpBB/includes/functions.php75
1 files changed, 70 insertions, 5 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 92410f2c1c..0a2778defe 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -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
/**
@@ -1189,8 +1254,8 @@ function redirect($url)
else
{
// Get the realpath of dirname
- $root_dirs = explode('/', str_replace('\\', '/', realpath('./')));
- $page_dirs = explode('/', str_replace('\\', '/', realpath($pathinfo['dirname'])));
+ $root_dirs = explode('/', str_replace('\\', '/', phpbb_realpath('./')));
+ $page_dirs = explode('/', str_replace('\\', '/', phpbb_realpath($pathinfo['dirname'])));
$intersection = array_intersect_assoc($root_dirs, $page_dirs);
$root_dirs = array_diff_assoc($root_dirs, $intersection);
@@ -2144,7 +2209,7 @@ function get_backtrace()
$output = '<div style="font-family: monospace;">';
$backtrace = debug_backtrace();
- $path = realpath($phpbb_root_path);
+ $path = phpbb_realpath($phpbb_root_path);
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)
{
// 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);
- $msg_text = str_replace(array(realpath($phpbb_root_path), '\\'), array('', '/'), $msg_text);
+ $errfile = str_replace(array(phpbb_realpath($phpbb_root_path), '\\'), array('', '/'), $errfile);
+ $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";
}