Feature #545: Include the awstatsGenerateIndex in cronjob.

Seperate the awstats updates output directory from the awstats static
output directory.
Switch to zero padded months.
Symlink current month to 'current' directory (force needed to update
the link if it already exists)
This commit is contained in:
Marcus van Dam
2015-06-01 14:55:43 +02:00
parent f6cdc0575b
commit 9bbdb1b3b9

View File

@@ -26,10 +26,11 @@ function awstatsDoSingleDomain($domain, $outputdir) {
if (file_exists($domainconfig)) { if (file_exists($domainconfig)) {
$outputdir = makeCorrectDir($outputdir . '/' . $domain); $outputdir = makeCorrectDir($outputdir . '/' . $domain);
$staticOutputdir = makeCorrectDir($outputdir . '/' . date('Y') . '-' . date('m'));
if (!is_dir($outputdir)) { if (!is_dir($staticOutputdir)) {
safe_exec('mkdir -p ' . escapeshellarg($outputdir)); safe_exec('mkdir -p ' . escapeshellarg($staticOutputdir));
} }
//check for correct path of awstats_buildstaticpages.pl //check for correct path of awstats_buildstaticpages.pl
@@ -42,19 +43,19 @@ function awstatsDoSingleDomain($domain, $outputdir) {
exit; exit;
} }
$cronlog->logAction(CRON_ACTION, LOG_INFO, "Running awstats_buildstaticpages.pl for domain '".$domain."' (Output: '".$outputdir."')"); $cronlog->logAction(CRON_ACTION, LOG_INFO, "Running awstats_buildstaticpages.pl for domain '".$domain."' (Output: '".$staticOutputdir."')");
safe_exec($awbsp.' -awstatsprog='.escapeshellarg($awprog).' -update -month=' . date('n') . ' -year=' . date('Y') . ' -config=' . $domain . ' -dir='.escapeshellarg($outputdir)); safe_exec($awbsp.' -awstatsprog='.escapeshellarg($awprog).' -update -month=' . date('m') . ' -year=' . date('Y') . ' -config=' . $domain . ' -dir='.escapeshellarg($staticOutputdir));
// index file is saved like 'awstats.[domain].html', // update our awstats index files
// so link a index.html to it awstatsGenerateIndex($domain, $outputdir);
$original_index = makeCorrectFile($outputdir.'/awstats.'.$domain.'.html');
$new_index = makeCorrectFile($outputdir.'/index.html'); // the default selection is 'current',
if (!file_exists($new_index)) { // so link the latest dir to it
safe_exec('ln -s '.escapeshellarg($original_index).' '.escapeshellarg($new_index)); $new_current = makeCorrectFile($outputdir . '/current');
} safe_exec('ln -fs ' . escapeshellarg($staticOutputdir) . ' ' . escapeshellarg($new_current));
//statistics file looks like: 'awstats[month][year].[domain].txt' //statistics file looks like: 'awstats[month][year].[domain].txt'
$file = makeCorrectFile($outputdir.'/awstats'.date('mY', time()).'.'.$domain.'.txt'); $file = makeCorrectFile($staticOutputdir.'/awstats'.date('mY', time()).'.'.$domain.'.txt');
$cronlog->logAction(CRON_ACTION, LOG_INFO, "Gathering traffic information from '".$file."'"); $cronlog->logAction(CRON_ACTION, LOG_INFO, "Gathering traffic information from '".$file."'");
if (file_exists($file)) { if (file_exists($file)) {