From 8436d04115c7e7ea7230e97bdf7e1c7dadcec63d Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Sat, 14 Nov 2009 18:24:05 +0100 Subject: [PATCH] create index pages, create symlinked current directory --- functions.php | 109 +++++++++++++++++++++++++++++++++++++++++++++++ update-sites.php | 41 ++---------------- 2 files changed, 112 insertions(+), 38 deletions(-) create mode 100644 functions.php diff --git a/functions.php b/functions.php new file mode 100644 index 0000000..7649f61 --- /dev/null +++ b/functions.php @@ -0,0 +1,109 @@ +' + . $name . ''; + } + $html = << + + + {$site} + + + + + +XML; + file_put_contents( + $GLOBALS['htmldir'] . '/' . $site . '/index.htm', + $html + ); +} + +function aws_createGlobalIndex() +{ + $dirs = glob($GLOBALS['htmldir'] . '/*', GLOB_ONLYDIR); + sort($dirs); + $links = ''; + foreach ($dirs as $dir) { + $name = basename($dir); + $links .= '
  • ' + . $name . '
  • '; + } + $html = << + + + awstats + + +
      +{$links} +
    + + +XML; + file_put_contents( + $GLOBALS['htmldir'] . '/index.htm', + $html + ); +} +?> \ No newline at end of file diff --git a/update-sites.php b/update-sites.php index 5159548..601ecd2 100644 --- a/update-sites.php +++ b/update-sites.php @@ -2,46 +2,11 @@ /** * 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); } +aws_createGlobalIndex(); ?> \ No newline at end of file -- 2.30.2