John Crisp
2018-07-12 17:34:48 UTC
So I stupidly decided to have a hack at awstats which was not generating so settings correctly.
All the code is the old API but seems to work ok barring the actual conf generator template.
I've converted that to use the 'new' style and all works apart from one section that checks to see if a subnet mask is correct - I'm not sure if this now necessary, and if there may be a better way.
It has this format but it keeps telling me the subroutine is already declared.
Any suggestions?
{
# think originally this was near the top
# sub mip ($$)
Some code
if ( defined $ipskipExtIP && $ipskipExtIP eq "mask"
) {
$OUT .= mip( $externalip, $externalnetmask ) .
";
Some code
sub mip ($$) {
my ( $ip, $msk ) = @_;
( my @mask ) = split( "[\.]", $msk );
my $i;
# AWStats cannot handle non-standard netmasks!
for ( $i = 0; $i < 4; $i++ ) {
if ( $mask[$i] ne "255" ) {
if ( $i == 1 ) {
$ip =~ s/[0-9]*\.[0-9]*\.[0-9]*$//;
}
elsif ( $i == 2 ) {
$ip =~ s/[0-9]*\.[0-9]*$//;
}
elsif ( $i == 3 ) {
$ip =~ s/[0-9]*$//;
}
last;
}
}
return $ip;
}
}
WARNING in /etc/e
smith/templates-custom//etc/e-smith/web/panels/manager/cgi-
in/.awstats/awstats.conf/12hosts: Subroutine mip redefined
t /etc/e-smith/templates-custom//etc/e-smith/web/panels/man
ger/cgi-bin/.awstats/awstats.conf/12hosts line 119.
All the code is the old API but seems to work ok barring the actual conf generator template.
I've converted that to use the 'new' style and all works apart from one section that checks to see if a subnet mask is correct - I'm not sure if this now necessary, and if there may be a better way.
It has this format but it keeps telling me the subroutine is already declared.
Any suggestions?
{
# think originally this was near the top
# sub mip ($$)
Some code
if ( defined $ipskipExtIP && $ipskipExtIP eq "mask"
) {
$OUT .= mip( $externalip, $externalnetmask ) .
";
Some code
sub mip ($$) {
my ( $ip, $msk ) = @_;
( my @mask ) = split( "[\.]", $msk );
my $i;
# AWStats cannot handle non-standard netmasks!
for ( $i = 0; $i < 4; $i++ ) {
if ( $mask[$i] ne "255" ) {
if ( $i == 1 ) {
$ip =~ s/[0-9]*\.[0-9]*\.[0-9]*$//;
}
elsif ( $i == 2 ) {
$ip =~ s/[0-9]*\.[0-9]*$//;
}
elsif ( $i == 3 ) {
$ip =~ s/[0-9]*$//;
}
last;
}
}
return $ip;
}
}
WARNING in /etc/e
smith/templates-custom//etc/e-smith/web/panels/manager/cgi-
in/.awstats/awstats.conf/12hosts: Subroutine mip redefined
t /etc/e-smith/templates-custom//etc/e-smith/web/panels/man
ger/cgi-bin/.awstats/awstats.conf/12hosts line 119.
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.
Sent from my Android phone with K-9 Mail. Please excuse my brevity.