"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "DADA/App/POP3Tools.pm" between
dada-11_14_1.tar.gz and dada-11_14_2.tar.gz

About: Dada is a web-based electronic (mass) mailing list management system.

POP3Tools.pm  (dada-11_14_1):POP3Tools.pm  (dada-11_14_2)
package DADA::App::POP3Tools; package DADA::App::POP3Tools;
use lib qw(../../ ../../DADA/perllib);
use lib "../../";
use lib "../../DADA/perllib";
use lib './';
use lib './DADA/perllib';
use DADA::Config qw(!:DEFAULT); use DADA::Config qw(!:DEFAULT);
use Carp qw(carp croak); use Carp qw(carp croak);
use Fcntl qw( use Fcntl qw(
:DEFAULT :DEFAULT
:flock :flock
LOCK_SH LOCK_SH
O_RDONLY O_RDONLY
O_CREAT O_CREAT
O_WRONLY O_WRONLY
O_TRUNC O_TRUNC
); );
use Try::Tiny;
require Exporter; require Exporter;
@ISA = qw(Exporter); @ISA = qw(Exporter);
use strict; use strict;
use vars qw(@EXPORT); use vars qw(@EXPORT);
@EXPORT = qw(); @EXPORT = qw();
sub net_pop3_login { sub net_pop3_login {
skipping to change at line 92 skipping to change at line 98
$args->{port} = '995'; $args->{port} = '995';
} }
else { else {
$args->{port} = '110'; $args->{port} = '110';
} }
} }
if(!exists($args->{debug})){ if(!exists($args->{debug})){
$args->{debug} = 0; $args->{debug} = 0;
} }
if(!exists($args->{ping_test})){
$args->{ping_test} = 0;
}
# Override everything! # Override everything!
if($DADA::Config::CPAN_DEBUG_SETTINGS{NET_POP3} == 1){ if($DADA::Config::CPAN_DEBUG_SETTINGS{NET_POP3} == 1){
$args->{debug} = 1; $args->{debug} = 1;
} }
$r .= "* Connecting with Net::POP3 v" . $Net::POP3::VERSION . "\n"; $r .= "* Connecting with Net::POP3 v" . $Net::POP3::VERSION . "\n";
if(length($args->{server}) <= 0 ) { if(length($args->{server}) <= 0 ) {
$r .= 'Server is blank?' . "\n"; $r .= 'Server is blank?' . "\n";
return (undef, 0, $r); return (undef, 0, $r);
} }
else { else {
if($args->{ping_test} == 1){
my ( $n_p_t_status, $n_p_t_msg );
try {
( $n_p_t_status, $n_p_t_msg ) = net_ping_test(
$args->{server},
$args->{port},
);
} catch {
warn $_;
};
$r .= $n_p_t_msg;
if($n_p_t_status == 0){
return ( undef, 0, $r );
}
}
$r .= "* Connecting to POP3 host:'" . $args->{server} . "' on port:'" . $args->{port} . "'\n"; $r .= "* Connecting to POP3 host:'" . $args->{server} . "' on port:'" . $args->{port} . "'\n";
my $n_p3_args = { my $n_p3_args = {
SSL => $SSL, SSL => $SSL,
Port => $args->{port}, Port => $args->{port},
Timeout => 60, Timeout => 60,
SSL_verify_mode => $args->{SSL_verify_mode}, SSL_verify_mode => $args->{SSL_verify_mode},
Debug => $args->{debug}, Debug => $args->{debug},
}; };
if($args->{SSL_verify_mode} == 1){ if($args->{SSL_verify_mode} == 1){
$r .= "* Verifying SSL Certificate during connection\n"; $r .= "* Verifying SSL Certificate during connection\n";
} }
#use Data::Dumper; #use Data::Dumper;
#$r .= "args: " . Dumper($args); #$r .= "args: " . Dumper($args);
#return (undef, 0, Dumper($args)); #return (undef, 0, Dumper($args));
my $pop = Net::POP3->new( my $pop = undef;
$args->{server},
%$n_p3_args, if($args->{ping_test} == 1){
); my $pop_worked = 1;
try {
$pop = Net::POP3->new(
$args->{server},
%$n_p3_args,
);
} catch {
$pop_worked = 0;
$r .= '* Problems connection to POP3 host: ' . $_
. "\n";
};
if($pop_worked == 0){
return ( undef, 0, $r );
}
}
else {
$pop = Net::POP3->new(
$args->{server},
%$n_p3_args,
);
}
# require Data::Dumper; # require Data::Dumper;
#$r .= 'Arguments Sent:' . #$r .= 'Arguments Sent:' .
#'Server: ' . $args->{server} . "\n" . #'Server: ' . $args->{server} . "\n" .
#Data::Dumper::Dumper($n_p3_args); #Data::Dumper::Dumper($n_p3_args);
if(!defined($pop)){ if(!defined($pop)){
$r .= "* Connection to '" . $args->{server} . "' wasn't successful\n"; $r .= "* Connection to '" . $args->{server} . "' wasn't successful\n";
return ( undef, 0, $r ); return ( undef, 0, $r );
} }
skipping to change at line 223 skipping to change at line 272
$r .= "\n"; $r .= "\n";
$r .= "* POP3 Login succeeded!\n"; $r .= "* POP3 Login succeeded!\n";
$r .= "* Message count: " . $count . "\n"; $r .= "* Message count: " . $count . "\n";
} }
return ( $pop, 1, $r ); return ( $pop, 1, $r );
} }
} }
sub net_ping_test {
# my $self = shift;
my $host = shift;
my $port = shift;
my $status = 1;
my $can_use_net_ping = 1;
try {
require Net::Ping;
}
catch {
$status = 0;
$can_use_net_ping = 0;
};
if($can_use_net_ping == 0){
return ( 1, "* Net::Ping not available.\n" );
}
my $timeout = 60;
my $p = Net::Ping->new("tcp");
$p->port_number($port);
# perform the ping
if ( $p->ping( $host, $timeout ) ) {
$p->close();
return ( 1, "* Host $host successfully pinged at port $port.\n" );
}
else {
$p->close();
return ( 0,
"* Host $host could not be pinged at port $port. Outbound port may be blocked,
or host is down at specified port\n"
);
}
}
sub _lock_pop3_check { sub _lock_pop3_check {
my ($args) = @_; my ($args) = @_;
if(! exists($args->{name})){ if(! exists($args->{name})){
croak "You need to supply a name! for _lock_pop3_check"; croak "You need to supply a name! for _lock_pop3_check";
} }
if(-f _lockfile_name($args)){ if(-f _lockfile_name($args)){
# oh, boy - the lockfile exists. # oh, boy - the lockfile exists.
 End of changes. 6 change blocks. 
5 lines changed or deleted 93 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)