configure email for sending comment notifications
This commit is contained in:
@@ -21,8 +21,6 @@ my $r = shift;
|
||||
( my $cgi, my $params, my $error ) = params::get($r);
|
||||
|
||||
my $config = config::getFromScriptLocation();
|
||||
my $debug = $config->{system}->{debug};
|
||||
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING},
|
||||
params => {
|
||||
@@ -51,14 +49,15 @@ $comment->{content} =~ s/(^|\s)((www\.)(.*?))(\s|$|\<)/$1\<a href\=\"http\:\/\/$
|
||||
if ( comments::check( $dbh, $config, $comment ) ) {
|
||||
my $nslookup = nslookup();
|
||||
|
||||
#if (is_blocked($nslookup)==1){
|
||||
# send_mail($comment, $nslookup, 'blocked');
|
||||
# return;
|
||||
#};
|
||||
if (is_blocked($nslookup)==1){
|
||||
send_mail($comment, $nslookup, 'blocked');
|
||||
return;
|
||||
};
|
||||
|
||||
$comment->{comment_id} = comments::insert( $dbh, $config, $comment );
|
||||
if ( $comment->{comment_id} > 0 ) {
|
||||
comments::update_comment_count( $dbh, $config, $comment );
|
||||
send_mail( $comment, $nslookup, 'new' );
|
||||
send_mail( $config, $comment, $nslookup, 'new' );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,18 +66,16 @@ sub is_blocked {
|
||||
|
||||
my $user_agent = $ENV{HTTP_USER_AGENT};
|
||||
|
||||
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/ );
|
||||
# add lock settings here
|
||||
# return 1 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;
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub send_mail {
|
||||
my $config = shift;
|
||||
my $comment = shift;
|
||||
my $nslookup = shift;
|
||||
my $status = shift || 'new';
|
||||
@@ -87,10 +84,12 @@ sub send_mail {
|
||||
my $user_agent = $ENV{HTTP_USER_AGENT} || '';
|
||||
my $cookie = $ENV{HTTP_COOKIE} || '';
|
||||
|
||||
my $from = 'no-reply@localhost';
|
||||
my $to = 'info@localhost';
|
||||
my $subject = "$status comment from '$comment->{author}': $comment->{content}";
|
||||
my $content = "$status comment
|
||||
my $locations = $config->{locations};
|
||||
my $base_domain = $locations->{base_domain};
|
||||
my $from = $locations->{email};
|
||||
my $to = $locations->{email};
|
||||
my $subject = "$status comment from '$comment->{author}': $comment->{content}";
|
||||
my $content = qq!$status comment
|
||||
|
||||
FROM: '$comment->{author}'
|
||||
EMAIL: $comment->{email}
|
||||
@@ -98,17 +97,17 @@ EMAIL: $comment->{email}
|
||||
CONTENT: '$comment->{content}'
|
||||
|
||||
view event
|
||||
https://localhost/programm/sendung/$comment->{event_id}.html#comments
|
||||
";
|
||||
$base_domain/programm/sendung/$comment->{event_id}.html#comments
|
||||
!;
|
||||
|
||||
if ( $status eq 'new' ) {
|
||||
$content .= "
|
||||
$content .= qq!
|
||||
manage comments:
|
||||
https://localhost/agenda/planung/comment.cgi?project_id=1&studio_id=1
|
||||
$base_domain/agenda/planung/comment.cgi?project_id=1&studio_id=1
|
||||
|
||||
lock this comment
|
||||
https://localhost/agenda/planung/comment.cgi?event_id=$comment->{event_id}&comment_id=$comment->{comment_id}&set_lock_status=blocked
|
||||
";
|
||||
$base_domain/agenda/planung/comment.cgi?event_id=$comment->{event_id}&comment_id=$comment->{comment_id}&set_lock_status=blocked
|
||||
!;
|
||||
}
|
||||
|
||||
$content .= qq{
|
||||
@@ -174,12 +173,12 @@ sub check_params {
|
||||
$comment->{content} = $params->{'content'} || '';
|
||||
$comment->{content} = escape_text( $comment->{content} );
|
||||
$comment->{content} = substr( $comment->{content}, 0, 1000 );
|
||||
log::error( $config, 'add_comment.cgi: missing body' ) if ( $comment->{content} eq '' );
|
||||
log::error( $config, 'add_comment.cgi: missing body' ) if $comment->{content} eq '';
|
||||
|
||||
$comment->{author} = $params->{'author'} || '';
|
||||
$comment->{author} = escape_text( $comment->{author} );
|
||||
$comment->{author} = substr( $comment->{author}, 0, 40 );
|
||||
log::error( $config, 'add_comment.cgi: missing name' ) if ( $comment->{author} eq '' );
|
||||
log::error( $config, 'add_comment.cgi: missing name' ) if $comment->{author} eq '';
|
||||
|
||||
$comment->{email} = $params->{'email'} || '';
|
||||
$comment->{email} = escape_text( $comment->{email} );
|
||||
@@ -190,16 +189,18 @@ sub check_params {
|
||||
$comment->{title} = substr( $comment->{title}, 0, 80 );
|
||||
|
||||
$comment->{ip} = $ENV{REMOTE_ADDR} || '';
|
||||
log::error( $config, 'missing ip' ) if ( $comment->{ip} eq '' );
|
||||
log::error( $config, 'missing ip' ) if $comment->{ip} eq '';
|
||||
$comment->{ip} = Digest::MD5::md5_base64( $comment->{ip} );
|
||||
|
||||
my $today = time::datetime_to_array( time::time_to_datetime() );
|
||||
my $date = time::datetime_to_array( $comment->{event_start} );
|
||||
my $delta_days = time::days_between( $today, $date );
|
||||
|
||||
log::error( $config, 'add_comment.cgi: no comments allowed, yet' )
|
||||
if ( $delta_days > $config->{permissions}->{no_new_comments_before} );
|
||||
if $delta_days > $config->{permissions}->{no_new_comments_before};
|
||||
|
||||
log::error( $config, 'add_comment.cgi: no comments allowed anymore' )
|
||||
if ( $delta_days < -1 * $config->{permissions}->{no_new_comments_after} );
|
||||
if $delta_days < -1 * $config->{permissions}->{no_new_comments_after};
|
||||
|
||||
return {
|
||||
template => $template,
|
||||
|
||||
Reference in New Issue
Block a user