improved version of in_docroot, allows for pathnames starting like the docroot

This commit is contained in:
Ralf Becker 2003-07-03 17:11:23 +00:00
parent 62a6e8fd34
commit 7381cb74d0

View File

@ -102,7 +102,7 @@
// test if the files-dir is inside the document-root, and refuse working if so
//
if (strstr($this->basedir,PHPGW_SERVER_ROOT) || strstr($this->basedir,$GLOBALS['HTTP_SERVER_VARS']['DOCUMENT_ROOT']))
if ($this->in_docroot($this->basedir))
{
$GLOBALS['phpgw']->common->phpgw_header();
if ($GLOBALS['phpgw_info']['flags']['noheader'])
@ -157,6 +157,31 @@
}
}
/*!
@function in_docroot
@abstract test if $path lies within the webservers document-root
*/
function in_docroot($path)
{
$docroots = array(PHPGW_SERVER_ROOT,$GLOBALS['HTTP_SERVER_VARS']['DOCUMENT_ROOT']);
foreach ($docroots as $docroot)
{
$len = strlen($docroot);
if ($docroot == substr($path,0,$len))
{
$rest = substr($path,$len);
if (!strlen($rest) || $rest[0] == DIRECTORY_SEPARATOR)
{
return True;
}
}
}
return False;
}
/*!
@function set_relative
@abstract Set path relativity