fixing syscp-feature-request #1236 (cron doesnt delete user directories)
This commit is contained in:
@@ -54,18 +54,18 @@ while($row = $db->fetch_array($result_tasks))
|
||||
if($row['type'] == '1')
|
||||
{
|
||||
//dhr: cleanout froxlor-generated awstats configs prior to re-creation
|
||||
if ($settings[system][awstats_enabled] == '1')
|
||||
if ($settings['system']['awstats_enabled'] == '1')
|
||||
{
|
||||
$awstatsclean[header] = "## GENERATED BY FROXLOR\n";
|
||||
$awstatsclean[path] = '/etc/awstats';
|
||||
$awstatsclean[dir] = dir($awstatsclean[path]);
|
||||
while($awstatsclean[entry] = $awstatsclean[dir]->read()) {
|
||||
$awstatsclean[fullentry] = $awstatsclean[path].'/'.$awstatsclean[entry];
|
||||
$awstatsclean[fh] = fopen($awstatsclean[fullentry], 'r');
|
||||
$awstatsclean[headerRead] = fgets($awstatsclean[fh], strlen($awstatsclean[header])+1);
|
||||
fclose($awstatsclean[fh]);
|
||||
if($awstatsclean[headerRead] == $awstatsclean[header]) {
|
||||
@unlink($awstatsclean[fullentry]);
|
||||
$awstatsclean['header'] = "## GENERATED BY FROXLOR\n";
|
||||
$awstatsclean['path'] = '/etc/awstats';
|
||||
$awstatsclean['dir'] = dir($awstatsclean['path']);
|
||||
while($awstatsclean['entry'] = $awstatsclean['dir']->read()) {
|
||||
$awstatsclean['fullentry'] = $awstatsclean['path'].'/'.$awstatsclean['entry'];
|
||||
$awstatsclean['fh'] = fopen($awstatsclean['fullentry'], 'r');
|
||||
$awstatsclean['headerRead'] = fgets($awstatsclean['fh'], strlen($awstatsclean['header'])+1);
|
||||
fclose($awstatsclean['fh']);
|
||||
if($awstatsclean['headerRead'] == $awstatsclean['header']) {
|
||||
@unlink($awstatsclean['fullentry']);
|
||||
}
|
||||
}
|
||||
unset($awstatsclean);
|
||||
@@ -199,6 +199,32 @@ while($row = $db->fetch_array($result_tasks))
|
||||
mkDirWithCorrectOwnership($directory['customerroot'], $directory['homedir'], $directory['uid'], $directory['gid']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TYPE=6 MEANS THAT A CUSTOMER HAS BEEN DELETED AND THAT WE HAVE TO REMOVE ITS FILES
|
||||
*/
|
||||
elseif ($row['type'] == '6')
|
||||
{
|
||||
fwrite($debugHandler, ' cron_tasks: Task6 started - deleting customer data' . "\n");
|
||||
$cronlog->logAction(CRON_ACTION, LOG_INFO, 'Task6 started - deleting customer data');
|
||||
|
||||
if(is_array($row['data']))
|
||||
{
|
||||
if(isset($row['data']['loginname']))
|
||||
{
|
||||
/*
|
||||
* remove homedir
|
||||
*/
|
||||
$cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Running: rm -rf ' . escapeshellarg($settings['system']['documentroot_prefix'] . $row['data']['loginname']));
|
||||
safe_exec('rm -rf '.escapeshellarg($settings['system']['documentroot_prefix'] . $row['data']['loginname']));
|
||||
/*
|
||||
* remove maildir
|
||||
*/
|
||||
$cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Running: rm -rf ' . escapeshellarg($settings['system']['vmail_homedir'] . $row['data']['loginname']));
|
||||
safe_exec('rm -rf '.escapeshellarg($settings['system']['vmail_homedir'] . $row['data']['loginname']));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($db->num_rows($result_tasks) != 0)
|
||||
|
||||
Reference in New Issue
Block a user