--- loncom/interface/lonsupportreq.pm 2013/01/04 19:07:17 1.67.2.1 +++ loncom/interface/lonsupportreq.pm 2012/08/27 06:28:06 1.69 @@ -1,5 +1,5 @@ # -# $Id: lonsupportreq.pm,v 1.67.2.1 2013/01/04 19:07:17 raeburn Exp $ +# $Id: lonsupportreq.pm,v 1.69 2012/08/27 06:28:06 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -36,9 +36,10 @@ use Apache::lonhtmlcommon; use Apache::lonnet; use Apache::lonlocal; use Apache::lonacc(); +use Apache::lonauth(); use Apache::courseclassifier; use LONCAPA qw(:DEFAULT :match); -use HTML::Entities; + sub handler { my ($r) = @_; @@ -56,19 +57,8 @@ sub handler { if ($r->uri eq '/adm/helpdesk') { &Apache::lonacc::get_posted_cgi($r); } - my $function; - if ($env{'form.function'}) { - if (($env{'form.function'} eq 'norole') || - ($env{'form.function'} eq 'student') || - ($env{'form.function'} eq 'admin') || - ($env{'form.function'} eq 'author')) { - $function = $env{'form.function'}; - } - } + my $function = $env{'form.function'}; my $origurl = $env{'form.origurl'}; - $origurl =~ s{^https?://}{}; - $origurl =~ s/(`)//g; - $origurl =~ s/\$/\(\$\)/g; my $command = $env{'form.command'}; if ($command eq 'process') { @@ -112,9 +102,13 @@ sub print_request_form { } $formname = 'logproblem'; my $machine = &Apache::lonnet::absolute_url(); - my $sourceurl = $machine.$origurl; - $server = $machine.&cleanup_html($origurl); - $server =~ s/\?.*$//; + if ($origurl =~ m-^https?://-) { + $server = $origurl; + } else { + $server = $machine.$origurl; + } + my $showserver = $server; + $showserver =~ s/\?.*$//; my %lt = &Apache::lonlocal::texthash ( email => 'The e-mail address you entered', notv => 'is not a valid e-mail address', @@ -364,8 +358,8 @@ ENDJS $num ++; $i = $num%2; $output .= &Apache::lonhtmlcommon::row_title("$lt{'urlp'}",undef,$css[$i]). - $server."\n".'&').'" />'."\n". + $showserver."\n".'&').'" />'."\n". &Apache::lonhtmlcommon::row_closure(). &Apache::lonhtmlcommon::row_title("$lt{'phon'}",undef,'LC_evenrow_value'). '
'."\n". @@ -494,6 +488,18 @@ ENDJS $num ++; $i = $num%2; } + } else { + my $lonhost = $r->dir_config('lonHostID'); + my ($captchaform,$error) = + &Apache::loncommon::captcha_display('login',$lonhost); + if ($captchaform) { + $output .= &Apache::lonhtmlcommon::row_title(&mt('Validation'),undef, + $css[$i])."\n". + $captchaform."\n". + &Apache::lonhtmlcommon::row_closure(); + $num ++; + $i = $num%2; + } } $output .= &Apache::lonhtmlcommon::row_title($lt{'fini'},undef,$css[$i]); $output .= <dir_config('lonHostID'); + my ($captcha_chk,$captcha_error) = + &Apache::loncommon::captcha_response('login',$lonhost); + if ($captcha_chk != 1) { + $r->print(&Apache::loncommon::start_page('Support request failed',undef, + {'function' => $function, + 'add_entries' => { + topmargin => "0", + marginheight => "0", + }, + 'only_body' => 1,})); + if ($r->uri eq '/adm/helpdesk') { + &print_header($r,$url,'process'); + } + $r->print('

'.&mt('Support request failed').'

'. + ''. + &mt('Validation of the code you entered failed.'). + &Apache::loncommon::end_page()); + return; + } + } my @ENVvars = ('HTTP_HOST','HTTP_USER_AGENT','REMOTE_ADDR','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'); @@ -638,11 +670,10 @@ sub print_request_receipt { $okcclist = join(', ',@ok_ccs); } if (@bad_ccs == 1) { - if ($bad_ccs[0] ne '') { - $badccmsg .= '
'.&mt('The following Cc e-mail address is invalid: ').&cleanup_html($bad_ccs[0]); - } + $badccmsg .= '
'.&mt('The following Cc e-mail address is invalid: ').$bad_ccs[0]; } elsif (@bad_ccs > 1) { - $badccmsg .= '
'.&mt('The following Cc e-mail addresses are invalid: '). &cleanup_html(join(', ',@bad_ccs)); + my $bad_cc_string = join(', ',@bad_ccs); + $badccmsg .= '
'.&mt('The following Cc e-mail addresses are invalid: ').$bad_cc_string; } } $env{'form.user'} = "'".$env{'form.uname'}.':'.$env{'form.udom'}."'"; @@ -678,12 +709,9 @@ END ''. "$lt{$item}: $showurl
\n"; } elsif ($item eq 'cc') { - if ($okcclist) { - my $showcclist = &cleanup_html($okcclist); - $displaymsg .= - ''. - "$lt{$item}: $showcclist
\n"; - } + $displaymsg .= + ''. + "$lt{$item}: $okcclist
\n"; } else { my $showitem = $env{'form.'.$item}; $showitem = &cleanup_html($showitem); @@ -923,11 +951,12 @@ sub print_header { } else { $reviewtext = &mt('Please review the information in "Log-in help" if you are unable to log-in.'); } - my $linkback; if ($origurl eq '') { - $linkback = 'javascript:history.go(-1)'; - } else { - $linkback = &HTML::Entities::encode($origurl,'"<>&'); + $origurl = 'javascript:history.go(-1)'; + } + my $loginhelp = &Apache::lonauth::loginhelpdisplay(); + if ($loginhelp eq '') { + $loginhelp = '/adm/loginproblems.html'; } $r->print(<<"END"); @@ -941,9 +970,9 @@ sub print_header {
- + $getstartlink - + @@ -976,11 +1005,8 @@ END sub get_domain { my $codedom; if (exists($env{'form.codedom'})) { - if (&Apache::lonnet::domain($env{'form.codedom'}) ne '') { - return $env{'form.codedom'}; - } - } - if ($env{'request.course.id'}) { + $codedom = $env{'form.codedom'}; + } elsif ($env{'request.course.id'}) { $codedom = $env{'course.'.$env{'request.course.id'}.'.domain'}; } elsif ($env{'request.role.domain'}) { $codedom = $env{'request.role.domain'}; @@ -995,7 +1021,6 @@ sub cleanup_html { my $outgoing; if ($incoming ne '') { $outgoing = $incoming; - $outgoing =~ s/;/;/g; $outgoing =~ s/\#/#/g; $outgoing =~ s/\&/&/g; $outgoing =~ s/