add_comment.cgi: perltidy

This commit is contained in:
Milan
2020-04-09 22:58:17 +02:00
parent b72f71e0ac
commit d3762084d6

View File

@@ -1,7 +1,9 @@
#!/usr/bin/perl #!/usr/bin/perl
use warnings;
use strict; use strict;
use warnings;
no warnings 'redefine';
use Data::Dumper; use Data::Dumper;
use params(); use params();
@@ -56,7 +58,6 @@ if (comments::check($dbh, $config, $comment)){
$comment->{comment_id} = comments::insert( $dbh, $config, $comment ); $comment->{comment_id} = comments::insert( $dbh, $config, $comment );
if ( $comment->{comment_id} > 0 ) { if ( $comment->{comment_id} > 0 ) {
comments::update_comment_count( $dbh, $config, $comment ); comments::update_comment_count( $dbh, $config, $comment );
delete_cache($config);
send_mail( $comment, $nslookup, 'new' ); send_mail( $comment, $nslookup, 'new' );
} }
} }
@@ -68,8 +69,12 @@ sub is_blocked{
my $block = 0; my $block = 0;
$block = 1 $block = 1
if ( ( $user_agent eq 'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:35.0) Gecko/20100101 Firefox/35.0' ) if ( $user_agent eq 'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:35.0) Gecko/20100101 Firefox/35.0' )
&& ( $nslookup =~ /alicedsl/ ) ); && ( $nslookup =~ /alicedsl/ );
$block = 1
if $user_agent eq
'Mozilla/5.0 (Linux; Android 8.0.0; ANE-LX1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.99 Mobile Safari/537.36';
return $block; return $block;
} }
@@ -82,8 +87,8 @@ sub send_mail{
my $user_agent = $ENV{HTTP_USER_AGENT} || ''; my $user_agent = $ENV{HTTP_USER_AGENT} || '';
my $cookie = $ENV{HTTP_COOKIE} || ''; my $cookie = $ENV{HTTP_COOKIE} || '';
my $from = 'no-reply@'; my $from = 'no-reply@localhost';
my $to = 'info@'; my $to = 'info@localhost';
my $subject = "$status comment from '$comment->{author}': $comment->{content}"; my $subject = "$status comment from '$comment->{author}': $comment->{content}";
my $content = "$status comment my $content = "$status comment
@@ -93,16 +98,16 @@ EMAIL: $comment->{email}
CONTENT: '$comment->{content}' CONTENT: '$comment->{content}'
view event view event
https://piradio.de/programm/sendung/$comment->{event_id}.html#comments https://localhost/programm/sendung/$comment->{event_id}.html#comments
"; ";
if ( $status eq 'new' ) { if ( $status eq 'new' ) {
$content .= " $content .= "
manage comments: manage comments:
https://piradio.de/agenda/planung/comment.cgi?project_id=1&studio_id=1 https://localhost/agenda/planung/comment.cgi?project_id=1&studio_id=1
lock this comment lock this comment
https://piradio.de/agenda/planung/comment.cgi?event_id=$comment->{event_id}&comment_id=$comment->{comment_id}&set_lock_status=blocked https://localhost/agenda/planung/comment.cgi?event_id=$comment->{event_id}&comment_id=$comment->{comment_id}&set_lock_status=blocked
"; ";
} }
@@ -122,7 +127,6 @@ $nslookup
To => $to, To => $to,
Subject => $subject, Subject => $subject,
Data => $content Data => $content
#.Dumper($comment)
); );
$msg->send; $msg->send;
@@ -138,31 +142,6 @@ sub nslookup{
return ''; return '';
} }
sub delete_cache{
my $config=shift;
unless($config->{locations}->{base_dir}=~/a-zA-Z/){
print STDERR "add_comment.cgi: base_dir is not configured\n";
return;
}
unless($config->{cache}->{cache_dir}=~/a-zA-Z/){
print STDERR "add_comment.cgi: cache_dir is not configured\n";
return;
}
unless($config->{controllers}->{comments}=~/a-zA-Z/){
print STDERR "add_comment.cgi: contoller 'comments' is not configured\n";
return;
}
my $cache_dir=$config->{locations}->{base_dir}.'/'.$config->{cache}->{cache_dir}.'/';
my $widget_cache=$cache_dir.'/'.$config->{controllers}->{comments};
`rm -f $widget_cache/*` if (-d $widget_cache);
my $aggregator_dir=$cache_dir.'/programm/'.$config->{controllers}->{comments};
`rm -f $aggregator_dir/*` if (-d $aggregator_dir);
}
sub check_params { sub check_params {
my $config = shift; my $config = shift;
my $params = shift; my $params = shift;
@@ -244,4 +223,3 @@ sub escape_text{
return $s; return $s;
} }