+#!/usr/bin/env php
<?php
/**
* Updates awstats for multiple sites
*/
-require 'config.php';
-
-function aws_sites()
-{
- $sites = array();
- foreach (glob($GLOBALS['confdir'] . '/awstats.*.conf') as $file) {
- $sites[] = preg_replace('/^.*awstats.(.+).conf$/', '\\1', $file);
- }
- return $sites;
-}
-
-function aws_createHtml($site, $last = false)
-{
- if (!is_dir($GLOBALS['htmldir'])) {
- die("HTML directory " . $GLOBALS['htmldir'] . " does not exist\n");
- }
-
- if ($last) {
- $month = date('m', strtotime('last month'));
- $year = date('Y', strtotime('last month'));
- } else {
- $month = date('m');
- $year = date('Y');
- }
-
- $dir = $GLOBALS['htmldir'] . '/' . $site . '/' . $year . '-' . $month . '/';
- if (!is_dir($dir)) {
- mkdir($dir, 0777, true);
- }
- $cmd = $GLOBALS['awsbstp']
- . ' -config=' . escapeshellarg($site)
- . ' -awstatsprog=' . escapeshellarg($GLOBALS['awstats'])
- . ' -update'
- . ' -month=' . $month
- . ' -year=' . $year
- . ' -dir=' . escapeshellarg($dir);
- passthru($cmd);var_dump($cmd);
-}
+require_once 'functions.php';
foreach (aws_sites() as $site) {
aws_createHtml($site);
+ aws_createIndex($site);
+ // allow apache to work for 15 seconds (so that one can use svn commit again)
+ sleep(15);
}
-?>
\ No newline at end of file
+aws_createGlobalIndex();
+?>