#!/usr/local/bin/perl # Group Listing Script, version 1.2-1 # Copyright 2001, Joshua Cantara # Portions copyright 2000 Allan Newsome # This program is licensed under the GPL. use CLI; use CGI qw(:standard); ########################################################## # Change the variables below to your settings # ########################################################## local $CGServerAddress = "192.168.0.1"; #ip/dns address of mail server local $DomainName = "dom.com"; #actual domain name used in emails, ie: postmaster@DomainName.com local $PostmasterLogin = "postmaster"; #postmaster, or any user with appropriate server access. local $PostmasterPassword = "1234"; #above user's password # Edit the css below to customize the look for your site local $css = qq| |; ########################################################## # You should not have to change anything below this point# ########################################################## BEGIN { #This allows the web server to find the CLI.pm file in the current directory use FindBin qw($Bin); use lib "$Bin"; } ################################################ # LIST GROUPS # Useage: &list; ################################################ sub list { my $cli = new CGP::CLI( { PeerAddr => $CGServerAddress, PeerPort => 106, login => $PostmasterLogin, password => $PostmasterPassword } ); unless($cli) { print "Can't login to CGPro: " . $CGP::ERR_STRING; exit; } my $GroupList = $cli->ListGroups || die "Can't get the groups list: ".$cli->getErrMssage.", quitting"; my $logintext; if ($login == 1) { $logintext = '&login=1'; } else { $logintext = ''; } print qq| Listing of Email Groups $css

Listing of Email Groups

Click the group name to see its members.

|; if ($login == 1) { print qq|Clicking [add] will add the address to the "To:" field of your current email. You may mix as many groups/invididual address as you like.|; } print qq| |; $cli->Logout; } ################################################ # LIST A GROUP # Useage: &group; ################################################ sub group { my $query = new CGI; my $GroupNam = $query->param('groupname'); my @list = 0; my $i = 0; my @listmems; my @realnames; my $member; my $data; my @sort_list; my $listmember; my $cli = new CGP::CLI( { PeerAddr => $CGServerAddress, PeerPort => 106, login => $PostmasterLogin, password => $PostmasterPassword } ); unless($cli) { errormsg("Can't login to CGPro: ".$CGP::ERR_STRING); } my $Settings = $cli->GetGroup($GroupNam); my $realgroupName = @$Settings{'RealName'}; foreach (keys %$Settings) { $data = @$Settings{$_}; if (ref ($data) eq 'ARRAY') { foreach $member (@$data) { if ($member !~ /@/) { my $accountData = $cli->GetAccount("$member\@$DomainName"); my $realName = @$accountData{'RealName'}; my $GroupSettings = $cli->GetGroup($member); my $realgroupName = @$GroupSettings{'RealName'}; if (length($realName) > 0) { push(@realnames, '
('.$realName.')'); } if ((length($realgroupName) > 0) && (length($realName) < 1)) { push(@realnames, '
('.$realgroupName.')'); } if ((length($realgroupName) < 1) && (length($realName) < 1)) { push(@realnames, ' '); } push(@listmems, $member.'@'.$DomainName); } else { push(@realnames, ' '); push(@listmems, $member); } } } } if (length($realgroupName) > 0) { $GroupNam = $realgroupName; } my $numberofmembers = $#listmems + 1; print qq| Group Listing $css

$numberofmembers Members in Email Group
"$GroupNam"

|; print qq| |; $cli->Logout; } ################################################ # MAIN LOOP! ################################################ print "Content-type: text/html\n\n"; print qq||; my $q = new CGI; local $login = $q->param('login'); if ($q->param('action') eq '') { &printframes; } elsif ($q->param('action') eq 'group') { &group; } elsif ($q->param('action') eq 'list') { &list; } elsif ($q->param('action') eq 'blank') { &printblank; } exit; ################################################ # PRINT BLANK PAGE # Useage: &printblank; ################################################ sub printblank { print qq| Main Page $css      |; } ################################################ # PRINT FRAMES SRC # Useage: &printframes; ################################################ sub printframes { my $logintext; if ($login == 1) { $logintext = '&login=1'; } else { $logintext = ''; } print qq| Email Groups Listings $css <BODY BGCOLOR="#ffffff"> This page requires frames. Please view using a modern web browser. </body> |; }