MHonArc

 view release on metacpan or  search on metacpan

admin/mhaadmin.cgi  view on Meta::CPAN

##  File:
##	$Id: mhaadmin.cgi,v 1.3 2001/12/24 13:31:57 ehood Exp $
##  Author:
##      Earl Hood       mhonarc@pobox.com
##  Description:
##	CGI program for MHonArc archive administration.
##---------------------------------------------------------------------------##
##    Copyright (C) 1998,1999	Earl Hood, mhonarc@pobox.com
##
##    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
##---------------------------------------------------------------------------##

package MHAHttpAdmin;

use lib qw ( . ./lib );
use CGI;
use CGI::Carp;

##---------------------------------------------------------------------------##
##				Main routine				     ##
##---------------------------------------------------------------------------##

use vars qw( $JSMenuBar $JSIndexPage $JSMesgPage );
BEGIN: {
    jscript_define();
    $ENV{'M2H_USELOCALTIME'} = 1;
}

my $Debug = 0;  # set to 1 for debug mode, messages sent to server log

my $Rc;
my $menulogo;
my $noteicon;
my $query;
my $action;
my $archive;
my $pagesize;

my @body_attr = (
    '-bgcolor'	=> "#dddddd",
    '-text'	=> "#000000",
    '-link'	=> "#0000ee",
    '-vlink'	=> "#551a8b",
    '-alink'	=> "#ff0000",
);

MAIN: {
    $Rc = require 'mhaadmin.rc' or
	croak qq/Error: Unable to require resource file\n/;

    if ($Debug) { warn '@INC=', join(':', @INC), "\n"; }

    $menulogo	= "$Rc->{'iconurl'}/mhaicon.png";
    $noteicon	= "$Rc->{'iconurl'}/mhanote_s.png";

    $ENV{'M2H_LOCKMETHOD'} = $Rc->{'lockmethod'}
	if defined($Rc->{'lockmethod'});

    ## Load main MHonArc library
    require 'mhamain.pl';
    if ($Debug) { warn qq/MHonArc version = $mhonarc::VERSION\n/; }
    if ($Debug) { warn qq/lockmethod = $ENV{'M2H_LOCKMETHOD'}\n/; }

    ## Initialize CGI environment
    $query 	= new CGI;

    ## Initialize MHonArc
    mhonarc::initialize();

    ## Get archive
    $archive	= $query->param('archive');
    if ($archive !~ /\S/) {
	$archive = $query->param('archive') ||
		   (sort { $Rc->{archive}{$a}[0] cmp $Rc->{archive}{$b}[0] }
			 keys %{$Rc->{archive}})[0];
    }

    ## Get action
    $action	= $query->param('action');

    if ($Debug) { warn qq/(archive=$archive, action=$action)/; }

    ## Check if deleting messages
    if ($action eq 'delete') {
	my %dup = ();
	my @msgnum = grep { /\S/ && ($dup{$_}++ < 1 ) }
			  $query->param('msgnum');
	if (@msgnum) {
	    mhonarc::process_input(
			    '-outdir', $archive,
			    '-quiet',
			    '-rmm',
			    @msgnum);
	}
	$action = 'index';
    }

    ## Print menubar
    if ($action eq 'menubar') {
	do_menu_bar();
	last MAIN;
    }

    ## Viewing a message
    if ($action eq 'show') {
	do_mesg_view();
	last MAIN;
    }



( run in 0.684 second using v1.01-cache-2.11-cpan-39bf76dae61 )