#WHMADDON:aolforwardfinder:AOL Forwarder Finder
##----------------------------------------------------
## Version 1.0
##
## Usage:
##
## 1) Copy to "/usr/local/cpanel/whostmgr/docroot/cgi/" directory.
## 2) Rename to "addon_aolforwarderfinder.cgi".
## 3) Chown to root:root.
## 4) Chmod to 755.
## 5) Log into WHM as user with root privs and click the link
## called "AOL Forwarder Finder" under the Add-ons section.
##----------------------------------------------------
BEGIN {
push(@INC,'/usr/local/cpanel','/usr/local/cpanel/Cpanel');
push(@INC,"/usr/local/cpanel/whostmgr/docroot/cgi");
}
use whmlib;
#--------------------------------
my $delimiter = "::";
#--------------------------------
print "Content-type: text/html\r\n\r\n";
defheader("AOL Forwarder Finder");
#-------------------------------------
if (!$ACL{all}) {
print "
Sorry, but this function may only be run by the server
administrator.
exit();
}
#-------------------------------------
# Start main work.
&printscriptinfo;
my @aolforwarders;
my @print;
chdir("/etc/valiases");
@aolforwarders = `grep -i \@aol. *`;
if (! @aolforwarders) {
print "
There were no \@aol forwarders found. Lucky!
";exit();
}
foreach my $line (@aolforwarders) {
my $owner;
my $realdomain;
my $reseller;
my @aols;
my @aoladdresses;
my ($domain, $forwarder, $addresses) = split(/:/, $line);
$owner = `/scripts/whoowns $domain`;
$realdomain = &domainname($owner);
$reseller = &findreseller($owner);
@aoladdresses = split(/,/, $addresses);
my @aols;
foreach (@aoladdresses) {
$_ = &trim($_);
if ($_ =~ /aol.com/i) {
push(@aols, $_);
}
}
if ($forwarder eq "*") {
$forwarder = "default address";
}
foreach(@aols) {
push(@print, $reseller . $delimiter .
$realdomain . $delimiter . $domain . $delimiter . $forwarder . $delimiter .
$_ . "\n
");
}
}
# Print results.
@print = sort { $a cmp $b } @print;
foreach(@print) {
print($_);
}
## Subroutines
sub trim {
my $string = shift(@_);
$string =~ s/\s//g;
return $string;
}
sub domainname {
my $user;
my $domain;
$user = $_[0];
open(CPU,"/var/cpanel/users/" . $user);
while(
if (/^DNS=(\S+)/) {
$domain = $1;
}
}
close(CPU);
return $domain;
}
sub findreseller {
my $user;
my $reseller;
$user = $_[0];
open(CPU,"/var/cpanel/users/" . $user);
while(
if (/^OWNER=(\S+)/) {
$reseller = $1;
}
}
close(CPU);
#if ($reseller ne "root") {
return &domainname($reseller);
#}
#else {
# return "NOT RESOLD";
#}
}
sub printscriptinfo {
print "
This script shows a list of all email forwarders
on the server that are set up to forward email to AOL.
[reseller's
domain] = The reseller who owns the [cpanel domain].
[cpanel
domain] = The main cpanel domain where the forwarder is located.
/>[forwarder domain] = The actual domain for the forwarder. (ie: It
might be an add-on or parked domain.)
[forwarder address] = The
actual email address that is doing the forwarding.
[aol address]
= The destination/target email address.
print "
[reseller's domain] " . $delimiter . " [cpanel
domain] " . $delimiter . " [forwarder domain] " . $delimiter . " [forwarder
address] " . $delimiter . " [aol address]
}
No comments:
Post a Comment