+#!/usr/bin/perl -w
+#
+# Copyright (c) 2002 Ivan Kohler
+# All rights reserved.
+# This program is free software; you can redistribute it and/or modify it under
+# the same terms as Perl itself.
+#
+# ivan-icelog@420.am
+
+use strict;
+use Net::Icecast;
+use Apache::ASP;
+
+require "/etc/icesnap.conf";
+
+unless ( -e $outdir) {
+ mkdir($outdir, 0755) or die "can't mkdir $outdir: $!";
+}
+
+my $c = Net::Icecast->new($host, $port, $admin_password)
+ or die "can't connect";
+
+my %hash = $c->listeners;
+
+#my %mount;
+use vars qw( %mount );
+
+#produce blank pages
+foreach my $mount (qw( / /24 ) ) {
+ $mount{$mount} = {};
+}
+
+foreach my $listener ( keys %hash ) {
+# print "$listener => \n";
+ my %lhash = %{$hash{$listener}};
+ foreach my $key ( keys %lhash ) {
+# print " $key => $lhash{$key}\n";
+ }
+
+ $mount{$lhash{mountpoint}}{$lhash{user_agent}}++;
+}
+
+#print "\n\n";
+
+use vars qw($mount);
+foreach $mount ( keys %mount ) {
+ my $total = 0;
+ &writepage();
+# print "$mount => \n";
+# foreach my $user_agent ( keys %{$mount{$mount}} ) {
+# $total += $mount{$mount}{$user_agent};
+# print " $user_agent => $mount{$mount}{$user_agent}\n";
+# }
+# print " TOTAL $total\n\n";
+}
+
+sub writepage {
+ #my $mount = shift;
+# my %mount = %{shift()};
+ #my $mref = shift;
+
+ open(STDOUT,">$outdir/$mount.html") or die "can't open $outdir/$mount.html: $!";
+
+ #nicked from cgi/asp in the Apache::ASP disribution
+
+ my $r = &Apache::ASP::CGI::init($template);
+
+ $r->dir_config('NoHeaders', 1);
+
+ &Apache::ASP::handler($r);
+
+ close STDOUT;
+
+}
+