- don't spam "PHP Warning: readdir() expects parameter 1 to be resource, boolean given" when webserver-configuration-directories do not exist in wipeOutOldConfigs

This commit is contained in:
Michael Kaufmann (d00p)
2010-04-28 07:04:01 +00:00
parent 5f5650f53a
commit a7041e0399
3 changed files with 21 additions and 14 deletions

View File

@@ -27,7 +27,7 @@
* @author Florian Lippert <flo@syscp.org> * @author Florian Lippert <flo@syscp.org>
*/ */
function isConfigDir($dir) function isConfigDir($dir, $ifexists = false)
{ {
if(file_exists($dir)) if(file_exists($dir))
{ {
@@ -42,9 +42,16 @@ function isConfigDir($dir)
} }
else else
{ {
if(substr($dir, -1) == '/') if(!$ifexists)
{ {
$returnval = true; if(substr($dir, -1) == '/')
{
$returnval = true;
}
else
{
$returnval = false;
}
} }
else else
{ {

View File

@@ -914,14 +914,8 @@ class apache
mkdir($this->settings['system']['apacheconf_htpasswddir'], 0751); mkdir($this->settings['system']['apacheconf_htpasswddir'], 0751);
umask($umask); umask($umask);
} }
elseif(!is_dir($this->settings['system']['apacheconf_htpasswddir']))
{
fwrite($this->debugHandler, ' cron_tasks: WARNING!!! ' . $this->settings['system']['apacheconf_htpasswddir'] . ' is not a directory. htpasswd directory protection is disabled!!!' . "\n");
echo 'WARNING!!! ' . $this->settings['system']['apacheconf_htpasswddir'] . ' is not a directory. htpasswd directory protection is disabled!!!';
$this->logger->logAction(CRON_ACTION, LOG_WARNING, 'WARNING!!! ' . $this->settings['system']['apacheconf_htpasswddir'] . ' is not a directory. htpasswd directory protection is disabled!!!');
}
if(is_dir($this->settings['system']['apacheconf_htpasswddir'])) if(isConfigDir($this->settings['system']['apacheconf_htpasswddir'], true))
{ {
foreach($this->htpasswds_data as $htpasswd_filename => $htpasswd_file) foreach($this->htpasswds_data as $htpasswd_filename => $htpasswd_file)
{ {
@@ -933,6 +927,12 @@ class apache
$this->wipeOutOldHtpasswdConfigs(); $this->wipeOutOldHtpasswdConfigs();
} }
else
{
fwrite($this->debugHandler, ' cron_tasks: WARNING!!! ' . $this->settings['system']['apacheconf_htpasswddir'] . ' is not a directory. htpasswd directory protection is disabled!!!' . "\n");
echo 'WARNING!!! ' . $this->settings['system']['apacheconf_htpasswddir'] . ' is not a directory. htpasswd directory protection is disabled!!!';
$this->logger->logAction(CRON_ACTION, LOG_WARNING, 'WARNING!!! ' . $this->settings['system']['apacheconf_htpasswddir'] . ' is not a directory. htpasswd directory protection is disabled!!!');
}
} }
// Write virtualhosts // Write virtualhosts
@@ -1006,7 +1006,7 @@ class apache
fwrite($this->debugHandler, ' apache::wipeOutOldVhostConfigs: cleaning ' . $this->settings['system']['apacheconf_vhost'] . "\n"); fwrite($this->debugHandler, ' apache::wipeOutOldVhostConfigs: cleaning ' . $this->settings['system']['apacheconf_vhost'] . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, "cleaning " . $this->settings['system']['apacheconf_vhost']); $this->logger->logAction(CRON_ACTION, LOG_INFO, "cleaning " . $this->settings['system']['apacheconf_vhost']);
if(isConfigDir($this->settings['system']['apacheconf_vhost'])) if(isConfigDir($this->settings['system']['apacheconf_vhost'], true))
{ {
$vhost_file_dirhandle = opendir($this->settings['system']['apacheconf_vhost']); $vhost_file_dirhandle = opendir($this->settings['system']['apacheconf_vhost']);
@@ -1035,7 +1035,7 @@ class apache
fwrite($this->debugHandler, ' apache::wipeOutOldDiroptionConfigs: cleaning ' . $this->settings['system']['apacheconf_diroptions'] . "\n"); fwrite($this->debugHandler, ' apache::wipeOutOldDiroptionConfigs: cleaning ' . $this->settings['system']['apacheconf_diroptions'] . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, "cleaning " . $this->settings['system']['apacheconf_diroptions']); $this->logger->logAction(CRON_ACTION, LOG_INFO, "cleaning " . $this->settings['system']['apacheconf_diroptions']);
if(isConfigDir($this->settings['system']['apacheconf_diroptions'])) if(isConfigDir($this->settings['system']['apacheconf_diroptions'], true))
{ {
$diroptions_file_dirhandle = opendir($this->settings['system']['apacheconf_diroptions']); $diroptions_file_dirhandle = opendir($this->settings['system']['apacheconf_diroptions']);
@@ -1064,7 +1064,7 @@ class apache
fwrite($this->debugHandler, ' apache::wipeOutOldHtpasswdConfigs: cleaning ' . $this->settings['system']['apacheconf_htpasswddir'] . "\n"); fwrite($this->debugHandler, ' apache::wipeOutOldHtpasswdConfigs: cleaning ' . $this->settings['system']['apacheconf_htpasswddir'] . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, "cleaning " . $this->settings['system']['apacheconf_htpasswddir']); $this->logger->logAction(CRON_ACTION, LOG_INFO, "cleaning " . $this->settings['system']['apacheconf_htpasswddir']);
if(isConfigDir($this->settings['system']['apacheconf_htpasswddir'])) if(isConfigDir($this->settings['system']['apacheconf_htpasswddir'], true))
{ {
$htpasswds_file_dirhandle = opendir($this->settings['system']['apacheconf_htpasswddir']); $htpasswds_file_dirhandle = opendir($this->settings['system']['apacheconf_htpasswddir']);

View File

@@ -831,7 +831,7 @@ class lighttpd
fwrite($this->debugHandler, ' lighttpd::wipeOutOldConfigs: cleaning ' . $this->settings['system']['apacheconf_vhost'] . "\n"); fwrite($this->debugHandler, ' lighttpd::wipeOutOldConfigs: cleaning ' . $this->settings['system']['apacheconf_vhost'] . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, "cleaning " . $this->settings['system']['apacheconf_vhost']); $this->logger->logAction(CRON_ACTION, LOG_INFO, "cleaning " . $this->settings['system']['apacheconf_vhost']);
if(isConfigDir($this->settings['system']['apacheconf_vhost'])) if(isConfigDir($this->settings['system']['apacheconf_vhost'], true))
{ {
$vhost_file_dirhandle = opendir($this->settings['system']['apacheconf_vhost']); $vhost_file_dirhandle = opendir($this->settings['system']['apacheconf_vhost']);