- check for existing awstats-configuration-directory and model-file, fixes #45
This commit is contained in:
@@ -55,14 +55,33 @@ while($row = $db->fetch_array($result_tasks))
|
||||
{
|
||||
$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']);
|
||||
|
||||
/**
|
||||
* dont do anyting if the directory not exists
|
||||
* (e.g. awstats not installed yet or whatever)
|
||||
* fixes #45
|
||||
*/
|
||||
if (is_dir($awstatsclean['dir']))
|
||||
{
|
||||
$awstatsclean['dir'] = dir($awstatsclean['path']);
|
||||
while($awstatsclean['entry'] = $awstatsclean['dir']->read()) {
|
||||
$awstatsclean['fullentry'] = $awstatsclean['path'].'/'.$awstatsclean['entry'];
|
||||
/**
|
||||
* dont do anything if the file does not exist
|
||||
*/
|
||||
if (file_exists($awstatsclean['fullentry']))
|
||||
{
|
||||
$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']);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$cronlog->logAction(CRON_ACTION, LOG_WARNING, "File '".$awstatsclean['fullentry']."' could not be found, please check if you followed all the instructions on the configuration page");
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($awstatsclean);
|
||||
|
||||
Reference in New Issue
Block a user