close $message;
# Now call MAPSDeliver
-- my $status = system "$FindBin::Bin/MAPSDeliver $userid /tmp/MAPSMessage.$$";
-
- if ($status == 0) {
- Logmsg("whitelist", $sender, "Delivered message");
-
- unlink "/tmp/MAPSMessage.$$";
- } else {
- Error("Unable to deliver message - is MAPSDeliver setgid? - $!");
- } # if
-
- RecordHit("white", $sequence, ++$hit_count) if $sequence;
-
- return $status;
- } # Whitelist
-
- sub count($$) {
- my ($table, $condition) = @_;
-
- my $statement;
++ my ($status, @output) = Execute "$FindBin::Bin/MAPSDeliver $userid /tmp/MAPSMessage.$$";
++ #my $status = system "$FindBin::Bin/MAPSDeliver $userid /tmp/MAPSMessage.$$";
++
++ if ($status != 0) {
++ my $msg = "Unable to deliver message (message left at /tmp/MAPSMessage.%%\n\n";
++ $msg .= join "\n", @output;
++
++ Logmsg(
++ userid => $userid,
++ type => 'whitelist',
++ sender => $sender,
++ message => $msg,
++ );
+
- if ($condition) {
- $statement = "select count(*) from $table where $condition";
- } else {
- $statement = "select count(*) from $table";
++ Error ($msg, 1);
+ } # if
- my $sth = $DB->prepare($statement)
- or DBError('count: Unable to prepare statement', $statement);
-
- $sth->execute
- or DBError('count: Unable to execute statement', $statement);
-
- # Get return value, which should be how many message there are
- my @row = $sth->fetchrow_array;
-
- # Done with $sth
- $sth->finish;
-
- my $count;
-
- # Retrieve returned value
- unless ($row[0]) {
- $count = 0
- } else {
- $count = $row[0];
- } # unless
-
- return $count
- } # count
-
- sub count_distinct($$$) {
- my ($table, $column, $condition) = @_;
-
- my $statement;
+ unlink "/tmp/MAPSMessage.$$";
- if ($condition) {
- $statement = "select count(distinct $column) from $table where $condition";
+ if ($status == 0) {
+ Logmsg(
+ userid => $userid,
+ type => 'whitelist',
+ sender => $sender,
+ message => 'Delivered message',
+ );
} else {
- $statement = "select count(distinct $column) from $table";
+ error("Unable to deliver message - is MAPSDeliver setgid? - $!", $status);
} # if
- my $sth = $DB->prepare($statement)
- or DBError('count: Unable to prepare statement', $statement);
-
- $sth->execute
- or DBError('count: Unable to execute statement', $statement);
-
- # Get return value, which should be how many message there are
- my @row = $sth->fetchrow_array;
+ $hit_count++ if $sequence;
- # Done with $sth
- $sth->finish;
-
- # Retrieve returned value
- unless ($row[0]) {
- return 0;
- } else {
- return $row[0];
- } # unless
- } # count_distinct
-
- sub countlog(;$) {
- my ($additional_condition) = @_;
-
- my $condition = "userid=\'$userid\' ";
-
- $condition .= "and $additional_condition" if $additional_condition;
+ RecordHit(
+ userid => $userid,
+ type => 'white',
+ sequence => $sequence,
+ hit_count => $hit_count,
+ );
- return count_distinct('log', 'sender', $condition);
- } # countlog
+ return $status;
+ } # Whitelist
1;