- 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['header'] = "## GENERATED BY FROXLOR\n";
|
||||||
$awstatsclean['path'] = '/etc/awstats';
|
$awstatsclean['path'] = '/etc/awstats';
|
||||||
$awstatsclean['dir'] = dir($awstatsclean['path']);
|
|
||||||
while($awstatsclean['entry'] = $awstatsclean['dir']->read()) {
|
/**
|
||||||
$awstatsclean['fullentry'] = $awstatsclean['path'].'/'.$awstatsclean['entry'];
|
* dont do anyting if the directory not exists
|
||||||
$awstatsclean['fh'] = fopen($awstatsclean['fullentry'], 'r');
|
* (e.g. awstats not installed yet or whatever)
|
||||||
$awstatsclean['headerRead'] = fgets($awstatsclean['fh'], strlen($awstatsclean['header'])+1);
|
* fixes #45
|
||||||
fclose($awstatsclean['fh']);
|
*/
|
||||||
if($awstatsclean['headerRead'] == $awstatsclean['header']) {
|
if (is_dir($awstatsclean['dir']))
|
||||||
@unlink($awstatsclean['fullentry']);
|
{
|
||||||
|
$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);
|
unset($awstatsclean);
|
||||||
|
|||||||
Reference in New Issue
Block a user