version 1.79.2.12, 2024/07/15 17:13:06
|
version 1.94, 2019/06/16 05:33:45
|
Line 29
|
Line 29
|
package Apache::lonsupportreq; |
package Apache::lonsupportreq; |
|
|
use strict; |
use strict; |
use MIME::Types; |
|
use MIME::Lite; |
|
use CGI::Cookie(); |
use CGI::Cookie(); |
use Apache::Constants qw(:common); |
use Apache::Constants qw(:common); |
use Apache::loncommon(); |
use Apache::loncommon(); |
Line 70 sub handler {
|
Line 68 sub handler {
|
} |
} |
my $origurl = $env{'form.origurl'}; |
my $origurl = $env{'form.origurl'}; |
if ($origurl =~ m{^https?://[^/]+(.*)$}) { |
if ($origurl =~ m{^https?://[^/]+(.*)$}) { |
$origurl = $1; |
$origurl =~ $1; |
} |
} |
$origurl =~ s/(`)//g; |
$origurl =~ s/(`)//g; |
$origurl =~ s/\$/\(\$\)/g; |
$origurl =~ s/\$/\(\$\)/g; |
Line 153 sub print_request_form {
|
Line 151 sub print_request_form {
|
} |
} |
} |
} |
|
|
|
my %coursecodes; |
my %codes; |
my %codes; |
my @codetitles; |
my @codetitles; |
my %cat_titles; |
my %cat_titles; |
Line 160 sub print_request_form {
|
Line 159 sub print_request_form {
|
my %idlist; |
my %idlist; |
my %idnums; |
my %idnums; |
my %idlist_titles; |
my %idlist_titles; |
|
my $caller = 'global'; |
my $totcodes = 0; |
my $totcodes = 0; |
|
my $format_reply; |
my $jscript = ''; |
my $jscript = ''; |
my $loaditems = qq| |
my $loaditems = qq| |
function initialize_codes() { |
function initialize_codes() { |
Line 168 function initialize_codes() {
|
Line 169 function initialize_codes() {
|
} |
} |
|; |
|; |
unless ($helpform{'course'} eq 'no') { |
unless ($helpform{'course'} eq 'no') { |
my $instcats = &Apache::lonnet::get_dom_instcats($codedom); |
$totcodes = &Apache::courseclassifier::retrieve_instcodes(\%coursecodes,$codedom); |
if (ref($instcats) eq 'HASH') { |
if ($totcodes > 0) { |
if ((ref($instcats->{'codetitles'}) eq 'ARRAY') && (ref($instcats->{'codes'}) eq 'HASH') && |
$format_reply = &Apache::lonnet::auto_instcode_format($caller,$codedom,\%coursecodes,\%codes,\@codetitles,\%cat_titles,\%cat_order); |
(ref($instcats->{'cat_titles'}) eq 'HASH') && (ref($instcats->{'cat_order'}) eq 'HASH')) { |
if ($format_reply eq 'ok') { |
%codes = %{$instcats->{'codes'}}; |
|
@codetitles = @{$instcats->{'codetitles'}}; |
|
%cat_titles = %{$instcats->{'cat_titles'}}; |
|
%cat_order = %{$instcats->{'cat_order'}}; |
|
$totcodes = scalar(keys(%codes)); |
|
} |
|
if ($totcodes > 0) { |
|
my $numtypes = @codetitles; |
my $numtypes = @codetitles; |
&Apache::courseclassifier::build_code_selections(\%codes,\@codetitles,\%cat_titles,\%cat_order,\%idlist,\%idnums,\%idlist_titles); |
&Apache::courseclassifier::build_code_selections(\%codes,\@codetitles,\%cat_titles,\%cat_order,\%idlist,\%idnums,\%idlist_titles); |
my ($scripttext,$longtitles) = &Apache::courseclassifier::javascript_definitions(\@codetitles,\%idlist,\%idlist_titles,\%idnums,\%cat_titles); |
my ($scripttext,$longtitles) = &Apache::courseclassifier::javascript_definitions(\@codetitles,\%idlist,\%idlist_titles,\%idnums,\%cat_titles); |
Line 321 $jscript
|
Line 315 $jscript
|
$loaditems |
$loaditems |
// ]]> |
// ]]> |
</script> |
</script> |
|
<script type="text/javascript" src="/res/adm/includes/file_upload.js"></script> |
ENDJS |
ENDJS |
if ($knownuser) { |
if ($recaptcha_version >=2) { |
$js .="\n".'<script type="text/javascript" src="/res/adm/includes/file_upload.js"></script>'; |
|
} elsif ($recaptcha_version >=2) { |
|
$js.= "\n".'<script src="https://www.google.com/recaptcha/api.js"></script>'."\n"; |
$js.= "\n".'<script src="https://www.google.com/recaptcha/api.js"></script>'."\n"; |
} |
} |
my %add_entries = ( |
my %add_entries = ( |
Line 393 ENDJS
|
Line 386 ENDJS
|
$i = $num%2; |
$i = $num%2; |
if ($knownuser) { |
if ($knownuser) { |
if ($homeserver) { |
if ($homeserver) { |
my $ip = &Apache::lonnet::get_requestor_ip($r); |
unless ($helpform{'cc'} eq 'no') { |
my %setters; |
|
my ($startblock,$endblock,$triggerblock,$by_ip,$blockdom) = |
|
&Apache::loncommon::blockcheck(\%setters,'com',$ip); |
|
unless (($helpform{'cc'} eq 'no') || ($by_ip)) { |
|
$output .= &Apache::lonhtmlcommon::row_title($html_lt{'emac'},undef,$css[$i]). |
$output .= &Apache::lonhtmlcommon::row_title($html_lt{'emac'},undef,$css[$i]). |
'<input type="text" size="50" name="cc" value="" /><br />'."\n". |
'<input type="text" size="50" name="cc" value="" /><br />'."\n". |
&Apache::lonhtmlcommon::row_closure(); |
&Apache::lonhtmlcommon::row_closure(); |
Line 466 ENDJS
|
Line 455 ENDJS
|
my $numtitles = @codetitles; |
my $numtitles = @codetitles; |
if ($numtitles == 0) { |
if ($numtitles == 0) { |
$output .= $html_lt{'enin'}.': |
$output .= $html_lt{'enin'}.': |
<input type="text" name="coursecode" size="15" value="'.&HTML::Entities::encode($ccode,'\'"&<>').'" />'."\n"; |
<input type="text" name="coursecode" size="15" value="" />'."\n"; |
} else { |
} else { |
my @standardnames = &Apache::loncommon::get_standard_codeitems(); |
my @standardnames = &Apache::loncommon::get_standard_codeitems(); |
my $lasttitle = $numtitles; |
my $lasttitle = $numtitles; |
Line 587 ENDJS
|
Line 576 ENDJS
|
} |
} |
$showmax = ' ('.sprintf("%.2f",$showmax).' '.&mt('MB max.').')'; |
$showmax = ' ('.sprintf("%.2f",$showmax).' '.&mt('MB max.').')'; |
$output .= &Apache::lonhtmlcommon::row_title($html_lt{'opfi'},undef,$css[$i]) |
$output .= &Apache::lonhtmlcommon::row_title($html_lt{'opfi'},undef,$css[$i]) |
.' <input type="file" name="screenshot" class="LC_flUpload" size="20" />' |
.' <input type="file" name="screenshot" class="flUpload" size="20" />' |
.'<input type="hidden" id="LC_free_space" value="'.$max.'" />' |
.'<input type="hidden" id="free_space" value="'.$max.'" />' |
.'<br />'."\n".$html_lt{'uplf'}.$showmax."\n" |
.'<br />'."\n".$html_lt{'uplf'}.$showmax."\n" |
.&Apache::lonhtmlcommon::row_closure(); |
.&Apache::lonhtmlcommon::row_closure(); |
$num ++; |
$num ++; |
Line 667 sub print_request_receipt {
|
Line 656 sub print_request_receipt {
|
return; |
return; |
} |
} |
} |
} |
my $ip = &Apache::lonnet::get_requestor_ip($r); |
my @ENVvars = ('HTTP_HOST','HTTP_USER_AGENT','REMOTE_ADDR','SERVER_ADDR','SERVER_NAME'); |
my %setters; |
|
my ($startblock,$endblock,$triggerblock,$by_ip,$blockdom) = |
|
&Apache::loncommon::blockcheck(\%setters,'com',$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 @envvars = ('browser.os','browser.type','browser.version','user.home','request.role'); |
my @loncvars = ('user.name','user.domain','request.course.sec','request.course.id'); |
my @loncvars = ('user.name','user.domain','request.course.sec','request.course.id'); |
my @cookievars; |
my @cookievars; |
Line 716 sub print_request_receipt {
|
Line 701 sub print_request_receipt {
|
unless ($helpform{'course'} eq 'no') { |
unless ($helpform{'course'} eq 'no') { |
$formvars{'course'} = 1; |
$formvars{'course'} = 1; |
} |
} |
unless (($helpform{'cc'} eq 'no') || ($by_ip)) { |
unless ($helpform{'cc'} eq 'no') { |
$formvars{'cc'} = 1; |
$formvars{'cc'} = 1; |
} |
} |
unless ($helpform{'screenshot'} eq 'no') { |
unless ($helpform{'screenshot'} eq 'no') { |
Line 727 sub print_request_receipt {
|
Line 712 sub print_request_receipt {
|
$coursecode = $env{'form.coursecode'}; |
$coursecode = $env{'form.coursecode'}; |
if ($coursecode eq '') { |
if ($coursecode eq '') { |
my $totcodes = 0; |
my $totcodes = 0; |
my $instcats = &Apache::lonnet::get_dom_instcats($defdom); |
my %coursecodes; |
if (ref($instcats) eq 'HASH') { |
$totcodes = &Apache::courseclassifier::retrieve_instcodes(\%coursecodes,$defdom); |
if (ref($instcats->{'codes'}) eq 'HASH') { |
|
$totcodes = scalar(keys(%{$instcats->{'codes'}})); |
|
} |
|
} |
|
my @standardnames = &Apache::loncommon::get_standard_codeitems(); |
my @standardnames = &Apache::loncommon::get_standard_codeitems(); |
if ($totcodes > 0) { |
if ($totcodes > 0) { |
my $noregexps = 1; |
my $noregexps = 1; |
Line 762 sub print_request_receipt {
|
Line 743 sub print_request_receipt {
|
secn => 'Section', |
secn => 'Section', |
warn => 'Warning: Problem with support e-mail address', |
warn => 'Warning: Problem with support e-mail address', |
your => 'Your support request contained the following information', |
your => 'Your support request contained the following information', |
belo => 'Below is your support request which could not be sent', |
|
ifyk => 'If you know an IT support address for your institution, you could copy this information and send it to that email address.', |
|
sect => 'section', |
sect => 'section', |
info => 'Information supplied', |
info => 'Information supplied', |
adin => 'Additional information recorded', |
adin => 'Additional information recorded', |
Line 983 END
|
Line 962 END
|
|
|
my $message; |
my $message; |
if (!$bad_email) { |
if (!$bad_email) { |
$message = &mt('A support request has been sent to [_1]','<tt>'.$to.'</tt>'); |
$message = &Apache::lonhtmlcommon::confirm_success( |
|
&mt('A support request has been sent to [_1]','<tt>'.$to.'</tt>')); |
} else { |
} else { |
$message = $lt{'warn'}.'<br />'; |
$message = &Apache::lonhtmlcommon::confirm_success( |
if ($to eq '') { |
$lt{'warn'}.'<br />' |
$message .= &mt('For this LON-CAPA server no e-mail address has been configured to receive support requests, so your support request has [_1]not[_2] been sent to the LON-CAPA support staff or administrator at your institution.','<b>','</b>'); |
.&mt('As the e-mail address provided for this LON-CAPA server ([_1]) does not appear to be a valid e-mail address, your support request has [_2]not[_3] been sent to the LON-CAPA support staff or administrator at your institution.','<tt>'.$to.'</tt>','<b>','</b>') |
} else { |
.' '.&mt('Instead a copy has been sent to the LON-CAPA support team at Michigan State University.'),1); |
$message .= &mt('As the e-mail address provided for this LON-CAPA server ([_1]) does not appear to be a valid e-mail address, your support request has [_2]not[_3] been sent to the LON-CAPA support staff or administrator at your institution.','<tt>'.$to.'</tt>','<b>','</b>'); |
$to = 'helpdesk@lon-capa.org'; |
} |
|
} |
} |
$r->print(&Apache::loncommon::confirmwrapper(&Apache::lonhtmlcommon::confirm_success($message,$bad_email))); |
$r->print(&Apache::loncommon::confirmwrapper($message)); |
|
|
if ($reqemail ne '') { |
if ($reqemail ne '') { |
$from = $reqemail; |
$from = $reqemail; |
Line 1061 END
|
Line 1040 END
|
foreach my $var(@ENVvars) { |
foreach my $var(@ENVvars) { |
$supportmsg .= "$var: $ENV{$var}\n"; |
$supportmsg .= "$var: $ENV{$var}\n"; |
} |
} |
$supportmsg .= "REMOTE_ADDR: $ip\n"; |
|
foreach my $var (@envvars) { |
foreach my $var (@envvars) { |
$supportmsg .= "$var: $env{$var}\n"; |
$supportmsg .= "$var: $env{$var}\n"; |
} |
} |
Line 1082 END
|
Line 1060 END
|
foreach my $var (@ENVvars) { |
foreach my $var (@ENVvars) { |
$attachment_text .= "$var: $ENV{$var}\n"; |
$attachment_text .= "$var: $ENV{$var}\n"; |
} |
} |
$attachment_text .= "REMOTE_ADDR: $ip\n"; |
|
foreach my $var (@envvars) { |
foreach my $var (@envvars) { |
$attachment_text .= "$var: $env{$var}\n"; |
$attachment_text .= "$var: $env{$var}\n"; |
} |
} |
Line 1101 END
|
Line 1078 END
|
} |
} |
} |
} |
|
|
unless ($bad_email) { |
# Compose and send a MIME email |
my $msg = MIME::Lite->new( |
&Apache::loncommon::mime_email($from, $to, $subject, $supportmsg, $cc_string, $bcc, |
From => $from, |
$attachmentpath, $fname, $attachment_text); |
To => $to, |
|
Subject => $subject, |
|
Type =>'TEXT', |
|
Data => $supportmsg, |
|
); |
|
if ($homeserver) { |
|
if (@ok_ccs > 0) { |
|
my $cc_string = join(', ',@ok_ccs); |
|
$msg->add("Cc" => $cc_string); |
|
} |
|
} |
|
if ($bcc ne '') { |
|
$msg->add("Bcc" => $bcc); |
|
} |
|
$msg->attr("content-type" => "text/plain"); |
|
$msg->attr("content-type.charset" => "UTF-8"); |
|
|
|
if ($homeserver && $attachmentpath) { |
|
my ($type, $encoding) = MIME::Types::by_suffix($attachmentpath); |
|
$msg->attach(Type => $type, |
|
Path => $attachmentpath, |
|
Filename => $fname |
|
); |
|
|
|
} elsif ($attachment_text ne '') { |
|
$msg->attach(Type => 'TEXT', |
|
Data => $attachment_text); |
|
} |
|
|
|
### Send it: |
|
$msg->send('sendmail'); |
|
} |
|
|
|
if ($attachmentpath =~ m|$Apache::lonnet::perlvar{'lonDaemons'}/tmp/helprequests/(\d+)/[^/]+|) { |
if ($attachmentpath =~ m|$Apache::lonnet::perlvar{'lonDaemons'}/tmp/helprequests/(\d+)/[^/]+|) { |
unlink($attachmentpath); |
unlink($attachmentpath); |
} |
} |
if ($bad_email) { |
$r->print('<b>'.$lt{'your'}.'</b>:<br /><br />'."\n"); |
$r->print('<b>'.$lt{'belo'}.'</b><br />'. |
|
$lt{'ifyk'}.'<br /><br />'."\n"); |
|
} else { |
|
$r->print('<b>'.$lt{'your'}.'</b>:<br /><br />'."\n"); |
|
} |
|
$r->print('<div style="width:620px;">'. |
$r->print('<div style="width:620px;">'. |
&Apache::lonhtmlcommon::start_pick_box(). |
&Apache::lonhtmlcommon::start_pick_box(). |
&Apache::lonhtmlcommon::row_title($lt{'info'},undef,'LC_oddrow_value')."\n".$displaymsg."\n". |
&Apache::lonhtmlcommon::row_title($lt{'info'},undef,'LC_oddrow_value')."\n".$displaymsg."\n". |
Line 1164 END
|
Line 1104 END
|
$var.'</span>: '.$ENV{$var}.', '; |
$var.'</span>: '.$ENV{$var}.', '; |
} |
} |
} |
} |
if ($ip ne '') { |
|
$envmsg .= '<span class="LC_helpform_receipt_cat">'. |
|
'REMOTE_ADDR</span>: '.$ip.', '; |
|
} |
|
foreach my $var (@envvars) { |
foreach my $var (@envvars) { |
if ($env{$var} ne '') { |
if ($env{$var} ne '') { |
$envmsg .= '<span class="LC_helpform_receipt_cat">'. |
$envmsg .= '<span class="LC_helpform_receipt_cat">'. |