mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 16:48:49 +01:00
moved check_dir to setup_detection, to have it available inside and outside of setup
This commit is contained in:
parent
bfff821e18
commit
ab3c470388
@ -10,8 +10,8 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
class setup_detection
|
||||
{
|
||||
class setup_detection
|
||||
{
|
||||
function get_versions()
|
||||
{
|
||||
$d = dir(EGW_SERVER_ROOT);
|
||||
@ -337,14 +337,14 @@
|
||||
}
|
||||
$config_errors =& $GLOBALS['egw_info']['setup']['config_errors'];
|
||||
$config_errors = array();
|
||||
if (!check_dir($config['temp_dir'],$error_msg))
|
||||
if (!$this->check_dir($config['temp_dir'],$error_msg))
|
||||
{
|
||||
$config_errors[] = lang("Your temporary directory '%1' %2",$config['temp_dir'],$error_msg);
|
||||
}
|
||||
|
||||
if ((!isset($config['file_repository']) || $config['file_repository'] == 'sql') &&
|
||||
(!isset($config['file_store_contents']) || $config['file_store_contents'] == 'filesystem') &&
|
||||
!check_dir($config['files_dir'],$error_msg,true))
|
||||
!$this->check_dir($config['files_dir'],$error_msg,true))
|
||||
{
|
||||
$config_errors[] = lang("Your files directory '%1' %2",$config['files_dir'],$error_msg);
|
||||
}
|
||||
@ -362,7 +362,7 @@
|
||||
),__LINE__,__FILE__);
|
||||
}
|
||||
}
|
||||
if (!check_dir($config['backup_dir'],$error_msg,true))
|
||||
if (!$this->check_dir($config['backup_dir'],$error_msg,true))
|
||||
{
|
||||
$config_errors[] = lang("Your backup directory '%1' %2",$config['backup_dir'],$error_msg);
|
||||
}
|
||||
@ -487,5 +487,48 @@
|
||||
return True;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a directory exists, is writable by the webserver and optionaly is in the docroot
|
||||
*
|
||||
* @param string $dir path
|
||||
* @param string &$msg error-msg: 'does not exist', 'is not writeable by the webserver' or 'is in the webservers docroot' (run through lang)
|
||||
* @param boolean $check_in_docroot=false run an optional in docroot check
|
||||
* @return boolean
|
||||
*/
|
||||
static function check_dir($dir,&$msg,$check_in_docroot=false)
|
||||
{
|
||||
if (!@is_dir($dir) && !@mkdir($dir,0700,true))
|
||||
{
|
||||
$msg = lang('does not exist');
|
||||
return false;
|
||||
}
|
||||
?>
|
||||
if (!@is_writeable($dir) && $_SERVER['HTTP_HOST']) // only do the check if we run by the webserver
|
||||
{
|
||||
$msg = lang('is not writeable by the webserver');
|
||||
return false;
|
||||
}
|
||||
if ($check_in_docroot)
|
||||
{
|
||||
$docroots = array(realpath(EGW_SERVER_ROOT),realpath($_SERVER['DOCUMENT_ROOT']));
|
||||
$dir = realpath($dir);
|
||||
|
||||
foreach ($docroots as $docroot)
|
||||
{
|
||||
$len = strlen($docroot);
|
||||
|
||||
if ($docroot == substr($dir,0,$len) && $len>0)
|
||||
{
|
||||
$rest = substr($dir,$len);
|
||||
|
||||
if (!strlen($rest) || $rest[0] == DIRECTORY_SEPARATOR)
|
||||
{
|
||||
$msg = lang('is in the webservers docroot');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -54,50 +54,6 @@
|
||||
|
||||
define('SEP',filesystem_separator());
|
||||
|
||||
/**
|
||||
* Checks if a directory exists, is writable by the webserver and optionaly is in the docroot
|
||||
*
|
||||
* @param string $dir path
|
||||
* @param string &$msg error-msg: 'does not exist', 'is not writeable by the webserver' or 'is in the webservers docroot' (run through lang)
|
||||
* @param boolean $check_in_docroot=false run an optional in docroot check
|
||||
* @return boolean
|
||||
*/
|
||||
function check_dir($dir,&$msg,$check_in_docroot=false)
|
||||
{
|
||||
if (!@is_dir($dir) && !@mkdir($dir,0700,true))
|
||||
{
|
||||
$msg = lang('does not exist');
|
||||
return false;
|
||||
}
|
||||
if (!@is_writeable($dir) && $_SERVER['HTTP_HOST']) // only do the check if we run by the webserver
|
||||
{
|
||||
$msg = lang('is not writeable by the webserver');
|
||||
return false;
|
||||
}
|
||||
if ($check_in_docroot)
|
||||
{
|
||||
$docroots = array(realpath(EGW_SERVER_ROOT),realpath($_SERVER['DOCUMENT_ROOT']));
|
||||
$dir = realpath($dir);
|
||||
|
||||
foreach ($docroots as $docroot)
|
||||
{
|
||||
$len = strlen($docroot);
|
||||
|
||||
if ($docroot == substr($dir,0,$len) && $len>0)
|
||||
{
|
||||
$rest = substr($dir,$len);
|
||||
|
||||
if (!strlen($rest) || $rest[0] == DIRECTORY_SEPARATOR)
|
||||
{
|
||||
$msg = lang('is in the webservers docroot');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* function to handle multilanguage support
|
||||
*
|
||||
|
@ -36,7 +36,7 @@
|
||||
|
||||
function temp_dir($settings)
|
||||
{
|
||||
if (!check_dir($settings['temp_dir'],$error_msg))
|
||||
if (!setup_detection::check_dir($settings['temp_dir'],$error_msg))
|
||||
{
|
||||
$GLOBALS['config_error'] = lang("Your temporary directory '%1' %2",$settings['temp_dir'],$error_msg);
|
||||
}
|
||||
@ -44,7 +44,8 @@
|
||||
|
||||
function files_dir($settings)
|
||||
{
|
||||
if ($settings['file_repository'] == 'sql' && $settings['file_store_contents'] == 'filesystem' && !check_dir($settings['files_dir'],$error_msg,true))
|
||||
if ($settings['file_repository'] == 'sql' && $settings['file_store_contents'] == 'filesystem' &&
|
||||
!setup_detection::check_dir($settings['files_dir'],$error_msg,true))
|
||||
{
|
||||
$GLOBALS['config_error'] = lang("Your files directory '%1' %2",$settings['files_dir'],$error_msg);
|
||||
}
|
||||
@ -56,7 +57,7 @@
|
||||
{
|
||||
$settings['backup_dir'] = $settings['files_dir'].'/db_backup';
|
||||
}
|
||||
if (!check_dir($settings['backup_dir'],$error_msg,true))
|
||||
if (!setup_detection::check_dir($settings['backup_dir'],$error_msg,true))
|
||||
{
|
||||
$GLOBALS['config_error'] = lang("Your backup directory '%1' %2",$settings['backup_dir'],$error_msg);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user