- check for existing awstats-configuration-directory and model-file, fixes #45

This commit is contained in:
Michael Kaufmann (d00p)
2010-03-02 22:03:55 +00:00
parent 0cd452de28
commit a0c557c405

View File

@@ -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);