mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-08 00:54:15 +01:00
improved version of in_docroot, allows for pathnames starting like the docroot
This commit is contained in:
parent
62a6e8fd34
commit
7381cb74d0
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user