--- loncom/interface/lonsupportreq.pm 2019/08/12 18:11:42 1.79.2.6
+++ loncom/interface/lonsupportreq.pm 2022/01/01 19:55:31 1.79.2.9
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Helpdesk request form
#
-# $Id: lonsupportreq.pm,v 1.79.2.6 2019/08/12 18:11:42 raeburn Exp $
+# $Id: lonsupportreq.pm,v 1.79.2.9 2022/01/01 19:55:31 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -70,7 +70,7 @@ sub handler {
}
my $origurl = $env{'form.origurl'};
if ($origurl =~ m{^https?://[^/]+(.*)$}) {
- $origurl =~ $1;
+ $origurl = $1;
}
$origurl =~ s/(`)//g;
$origurl =~ s/\$/\(\$\)/g;
@@ -663,7 +663,8 @@ sub print_request_receipt {
return;
}
}
- my @ENVvars = ('HTTP_HOST','HTTP_USER_AGENT','REMOTE_ADDR','SERVER_ADDR','SERVER_NAME');
+ my $ip = &Apache::lonnet::get_requestor_ip();
+ my @ENVvars = ('HTTP_HOST','HTTP_USER_AGENT','SERVER_ADDR','SERVER_NAME');
my @envvars = ('browser.os','browser.type','browser.version','user.home','request.role');
my @loncvars = ('user.name','user.domain','request.course.sec','request.course.id');
my @cookievars;
@@ -676,9 +677,6 @@ sub print_request_receipt {
my $admin = $Apache::lonnet::perlvar{'lonAdminMail'};
my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
my $defdom = &get_domain();
- my ($to,$bcc,$addtext) =
- &Apache::loncommon::build_recipient_list(undef,'helpdeskmail',
- $defdom,$origmail);
my $from = $admin;
my %helpform;
my %domconfig =
@@ -896,6 +894,33 @@ $lt{'date'}: $reporttime
}
}
}
+
+ my ($requname,$requdom,$reqemail);
+ foreach my $field ('uname','udom','email') {
+ $env{'form.'.$field} =~ s/^\s+//;
+ $env{'form.'.$field} =~ s/\s+$//;
+ }
+ if ($env{'form.uname'} =~ /^$match_username$/) {
+ $requname = $env{'form.uname'};
+ }
+ if ($env{'form.udom'} =~ /^$match_domain$/) {
+ $requdom = $env{'form.udom'};
+ }
+ if ($env{'form.email'} =~ m/^[^\@]+\@[^\@]+$/) {
+ $reqemail = $env{'form.email'};
+ }
+
+ my $dom_in_effect;
+ unless ($env{'user.domain'} eq 'public') {
+ $dom_in_effect = $env{'user.domain'};
+ }
+ if ($dom_in_effect eq '') {
+ $dom_in_effect = $requdom;
+ }
+ if ($dom_in_effect eq '') {
+ $dom_in_effect = $defdom;
+ }
+
$displaymsg .= ''.
$lt{'date'}.': '.$reporttime.'
'."\n";
@@ -918,6 +943,11 @@ END
&print_header($r,$url,'process');
}
my $bad_email = 0;
+ my ($to,$bcc,$addtext) =
+ &Apache::loncommon::build_recipient_list(undef,'helpdeskmail',
+ $dom_in_effect,$origmail,
+ $requname,$requdom,
+ $reqemail);
if ($to =~ /,/) {
my @ok_email;
foreach my $email (split(/,/,$to)) {
@@ -955,12 +985,8 @@ END
}
$r->print(&Apache::loncommon::confirmwrapper($message));
- if (defined($env{'form.email'})) {
- $env{'form.email'} =~ s/^\s+//;
- $env{'form.email'} =~ s/\s+$//;
- if ($env{'form.email'} =~ m/^[^\@]+\@[^\@]+$/) {
- $from = $env{'form.email'};
- }
+ if ($reqemail ne '') {
+ $from = $reqemail;
}
if (defined($env{'form.cc'})) {
@@ -1026,6 +1052,7 @@ END
foreach my $var(@ENVvars) {
$supportmsg .= "$var: $ENV{$var}\n";
}
+ $supportmsg .= "REMOTE_ADDR: $ip\n";
foreach my $var (@envvars) {
$supportmsg .= "$var: $env{$var}\n";
}
@@ -1046,6 +1073,7 @@ END
foreach my $var (@ENVvars) {
$attachment_text .= "$var: $ENV{$var}\n";
}
+ $attachment_text .= "REMOTE_ADDR: $ip\n";
foreach my $var (@envvars) {
$attachment_text .= "$var: $env{$var}\n";
}
@@ -1120,6 +1148,10 @@ END
$var.': '.$ENV{$var}.', ';
}
}
+ if ($ip ne '') {
+ $envmsg .= ''.
+ 'REMOTE_ADDR: '.$ip.', ';
+ }
foreach my $var (@envvars) {
if ($env{$var} ne '') {
$envmsg .= ''.