add_comment.cgi: perltidy
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
use warnings;
|
||||
no warnings 'redefine';
|
||||
|
||||
use Data::Dumper;
|
||||
|
||||
use params();
|
||||
@@ -56,7 +58,6 @@ if (comments::check($dbh, $config, $comment)){
|
||||
$comment->{comment_id} = comments::insert( $dbh, $config, $comment );
|
||||
if ( $comment->{comment_id} > 0 ) {
|
||||
comments::update_comment_count( $dbh, $config, $comment );
|
||||
delete_cache($config);
|
||||
send_mail( $comment, $nslookup, 'new' );
|
||||
}
|
||||
}
|
||||
@@ -68,8 +69,12 @@ sub is_blocked{
|
||||
|
||||
my $block = 0;
|
||||
$block = 1
|
||||
if ( ( $user_agent eq 'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:35.0) Gecko/20100101 Firefox/35.0' )
|
||||
&& ( $nslookup =~ /alicedsl/ ) );
|
||||
if ( $user_agent eq 'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:35.0) Gecko/20100101 Firefox/35.0' )
|
||||
&& ( $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;
|
||||
}
|
||||
|
||||
@@ -82,8 +87,8 @@ sub send_mail{
|
||||
my $user_agent = $ENV{HTTP_USER_AGENT} || '';
|
||||
my $cookie = $ENV{HTTP_COOKIE} || '';
|
||||
|
||||
my $from = 'no-reply@';
|
||||
my $to = 'info@';
|
||||
my $from = 'no-reply@localhost';
|
||||
my $to = 'info@localhost';
|
||||
my $subject = "$status comment from '$comment->{author}': $comment->{content}";
|
||||
my $content = "$status comment
|
||||
|
||||
@@ -93,16 +98,16 @@ EMAIL: $comment->{email}
|
||||
CONTENT: '$comment->{content}'
|
||||
|
||||
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' ) {
|
||||
$content .= "
|
||||
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
|
||||
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,
|
||||
Subject => $subject,
|
||||
Data => $content
|
||||
#.Dumper($comment)
|
||||
);
|
||||
|
||||
$msg->send;
|
||||
@@ -138,31 +142,6 @@ sub nslookup{
|
||||
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 {
|
||||
my $config = shift;
|
||||
my $params = shift;
|
||||
@@ -244,4 +223,3 @@ sub escape_text{
|
||||
return $s;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user