#!/usr/bin/perl -w # -*- cperl -*- # # # size.pm - Show off the size of your archive! # # GNU MP3D - A portable(ish) MP3 server. # # Homepage: # http://www.gnump3d.org/ # # Author: # Steve Kemp # # Version: # $Id: size.pm,v 1.1 2003/10/12 18:13:12 skx Exp $ # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Steve Kemp # --- # http://www.steve.org.uk/ # # # # Return the author of this plugin. # sub getAuthor() { return( 'Steve Kemp ' ); } # # Return the version of this plugin. # sub getVersion() { my $REVISION = '$Id: size.pm,v 1.1 2003/10/12 18:13:12 skx Exp $'; my $VERSION = ""; $VERSION = join (' ', (split (' ', $REVISION))[1..3]); $VERSION =~ s/,v\b//; $VERSION =~ s/(\S+)$/($1)/; return( $VERSION ); } # # Handle requests to this plugin. # sub handlePath( ) { my ( $uri ) = (@_); my $header = &getHTTPHeader( 200, "text/html" ); &sendData( $data, $header ); my $text = &handleSize( $ARGUMENTS{"theme"}); &sendData( $data, $text ); close( $data ); exit; } # # Display the size of the archive via the 'gnump3d-index --stats' program # # sub handleSize( $ ) { my ($theme) = (@_); my $text = ""; my $config = &configFile(); my @template = &getThemeFile( $theme, "size.html" ); foreach my $line (@template ) { # # Make global substitutions. # $line =~ s/\$HOSTNAME/$host/g; $line =~ s/\$VERSION/$VERSION/g; $line =~ s/\$DIRECTORY/\/stats\//g; $line =~ s/\$HEADING/Statistics/g; $line =~ s/\$TITLE/Statistics/g; # # Now handle the special sections. # if ( $line =~ /(.*)\$BANNER(.*)/ ) { # Insert banner; my $pre = $1; my $post = $2; $text .= $pre; $text .= &getBanner( "/stats/" ); $text .= $post; } elsif ( $line =~ /(.*)\$TEXT(.*)/ ) { my $size = `gnump3d-index --stats`; my $pre = $1; my $post = $2; $text .= $pre; $text .= $size; $text .= $post; } else { $text .= $line; } } return( $text ); }