Skip to content
Snippets Groups Projects
Commit 7d408702 authored by Tomáš Plesník's avatar Tomáš Plesník
Browse files

odstranena nadbytecnost v dereferenci pole, presunut do placeholderu,...

odstranena nadbytecnost v dereferenci pole,  presunut do placeholderu, odstranena zavislost na modulu List::Util
parent ac58da12
No related branches found
No related tags found
No related merge requests found
......@@ -19,7 +19,6 @@ use Net::CIDR::Lite;
use DateTime;
use MIME::Base64;
use Crypt::X509;
use List::Util 'first';
our $VERSION = "2.1";
......@@ -222,9 +221,7 @@ sub saveNewEvent
if(defined %client) {
# check validity of event attributes - TYPE
my $valid_types_ref = $VALID_STRINGS{'type'};
my @valid_types = @$valid_types_ref;
my $match = first { /$type/ } @valid_types;
my $match = grep /$type/, @{$VALID_STRINGS{'type'}};
if ($match) {
$sth=$DBH->prepare("INSERT INTO events VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);");
if (!defined $sth) { die("Cannot do insert statement in $function_name: $DBI::errstr\n") }
......@@ -263,27 +260,27 @@ sub getNewEvents
if(defined %client) {
if ($client{'receive_own'} eq 't') { # check if client want your own events or not
if ($requested_type eq '_any_') { # check if client want each or only one type of messages
$sth = $DBH->prepare("SELECT * FROM events WHERE type != 'test' AND id > ? AND valid = 't' ORDER BY id ASC limit $MAX_EVENT_LIMIT;");
$sth = $DBH->prepare("SELECT * FROM events WHERE type != 'test' AND id > ? AND valid = 't' ORDER BY id ASC LIMIT ?;");
if (!defined $sth) {die("Cannot prepare ROE-ANY statement in $function_name: $DBI::errstr\n")}
$sth->execute($last_id);
$sth->execute($last_id, $MAX_EVENT_LIMIT);
} else {
$sth = $DBH->prepare("SELECT * FROM events WHERE type != 'test' AND id > ? AND type = ? AND valid = 't' ORDER BY id ASC limit $MAX_EVENT_LIMIT;");
$sth = $DBH->prepare("SELECT * FROM events WHERE type != 'test' AND id > ? AND type = ? AND valid = 't' ORDER BY id ASC LIMIT ?;");
if (!defined $sth) {die("Cannot prepare ROE statement in $function_name: $DBI::errstr\n")}
$sth->execute($last_id, $requested_type);
$sth->execute($last_id, $requested_type, $MAX_EVENT_LIMIT);
}
} else {
if ($requested_type eq '_any_') {
$sth = $DBH->prepare("SELECT * FROM events WHERE type != 'test' AND id > ? AND valid = 't' AND hostname NOT LIKE ? ORDER BY id ASC limit $MAX_EVENT_LIMIT;");
$sth = $DBH->prepare("SELECT * FROM events WHERE type != 'test' AND id > ? AND valid = 't' AND hostname NOT LIKE ? ORDER BY id ASC LIMIT ?;");
if (!defined $sth) {die("Cannot prepare ANY statement in $function_name: $DBI::errstr\n")}
my ($domain) = $cn =~ /([^\.]+\.[^\.]+)$/;
$domain = '\%' . $domain;
$sth->execute($last_id, $domain);
$sth->execute($last_id, $domain, $MAX_EVENT_LIMIT);
} else {
$sth = $DBH->prepare("SELECT * FROM events WHERE type != 'test' AND id > ? AND type = ? AND valid = 't' AND hostname NOT LIKE ? ORDER BY id ASC limit $MAX_EVENT_LIMIT;");
$sth = $DBH->prepare("SELECT * FROM events WHERE type != 'test' AND id > ? AND type = ? AND valid = 't' AND hostname NOT LIKE ? ORDER BY id ASC LIMIT ?;");
if (!defined $sth) {die("Cannot prepare statement in $function_name: $DBI::errstr\n")}
my ($domain) = $cn =~ /([^\.]+\.[^\.]+)$/;
$domain = '\%' . $domain;
$sth->execute($last_id, $requested_type, $domain);
$sth->execute($last_id, $requested_type, $domain, $MAX_EVENT_LIMIT);
}
}
......
......@@ -288,7 +288,7 @@ create_symlinks()
#-------------------------------------------------------------------------------
# list of used Perl modules
modules=(SOAP::Lite SOAP::Transport::HTTP DBI DBD::mysql Format::Human::Bytes Sys::Syslog File::Basename Net::CIDR::Lite DateTime Getopt::Std Switch IO::Socket::SSL MIME::Base64 Crypt::X509 List::Util)
modules=(SOAP::Lite SOAP::Transport::HTTP DBI DBD::mysql Format::Human::Bytes Sys::Syslog File::Basename Net::CIDR::Lite DateTime Getopt::Std Switch IO::Socket::SSL MIME::Base64 Crypt::X509)
# read input
while getopts "d:k:c:a:Vh" options; do
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment