--- /dev/null
+<?php
+$confdir = '/etc/awstats/';
+$htmldir = '/var/www/system/awstats/';
+$awstats = '/usr/lib/cgi-bin/awstats.pl';
+$awsbstp = '/usr/share/doc/awstats/examples/awstats_buildstaticpages.pl';
+
+?>
\ No newline at end of file
--- /dev/null
+<?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);
+}
+
+foreach (aws_sites() as $site) {
+ aws_createHtml($site);
+}
+?>
\ No newline at end of file