Annotation of loncom/interface/lonerrorhandler.pm, revision 1.20
1.1 www 1: # The LearningOnline Network
2: # Internal Server Error Handler
3: #
1.20 ! jms 4: # $Id: lonerrorhandler.pm,v 1.19 2008/11/18 19:14:22 jms Exp $
1.3 albertel 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
1.4 www 28:
1.19 jms 29:
30:
1.1 www 31: package Apache::lonerrorhandler;
32:
33: use strict;
34: use Apache::Constants qw(:common);
1.11 albertel 35: use Apache::loncommon();
1.7 albertel 36: use Apache::lonnet;
1.11 albertel 37: use Apache::lonmsg();
38: use Apache::lonacc();
1.13 raeburn 39: use Apache::lonlocal;
1.1 www 40:
41: sub handler {
42: my $r = shift;
1.6 albertel 43: &Apache::loncommon::content_type($r,'text/html');
1.1 www 44: $r->send_http_header;
45: return OK if $r->header_only;
46:
1.11 albertel 47: &Apache::lonacc::get_posted_cgi($r);
1.17 raeburn 48: if (!$Apache::lonlocal::lh) {
1.16 raeburn 49: &Apache::lonlocal::get_language_handle($r);
50: }
1.9 albertel 51: my $title = $env{'form.sendinfo'} ? 'Sending Error Report'
52: : 'Could Not Process Request';
53: $r->print(&Apache::loncommon::start_page($title));
1.8 www 54:
55: if ($env{'form.sendinfo'}) {
56: my $repro='no';
57: # ------------------------------------------------------------------ Mail stuff
58: if ($env{'form.reproducible'}) {
59: $repro='yes';
60: }
1.13 raeburn 61: my %lt = &Apache::lonlocal::texthash (
62: msg => 'LON-CAPA Error Message',
63: rep => 'Reproducible',
64: ver => 'Version',
65: syl => 'Syllabus',
66: pri => 'Prior Action',
67: gue => 'Guesses',
68: env => 'Environment',
69: );
1.8 www 70: my $message=(<<ENDMESSAGE);
1.13 raeburn 71: $lt{'msg'}
72: $lt{'rep'}: $repro
73: $lt{'ver'}: $env{'form.version'}
74: $lt{'syl'}:
1.8 www 75: $env{'form.syllabus'}
76:
1.13 raeburn 77: $lt{'pri'}:
1.8 www 78: $env{'form.prioraction'}
79:
1.13 raeburn 80: $lt{'gue'}:
1.8 www 81: $env{'form.guesses'}
82:
1.13 raeburn 83: $lt{'env'}:
1.8 www 84: $env{'form.environment'}
85: ENDMESSAGE
1.13 raeburn 86: my $sysmail = $r->dir_config('lonSysEMail');
87: my $defdom = $r->dir_config('lonDefDomain');
1.14 raeburn 88: my $origmail = $r->dir_config('lonAdmEMail');
89: my $recipients = &Apache::loncommon::build_recipient_list($sysmail,
90: 'errormail',$defdom,$origmail);
1.13 raeburn 91: if ($recipients ne '') {
92: &Apache::lonmsg::sendemail($recipients,'ERROR REPORT',$message);
93: $r->print('<h2>'.&mt('Report submitted').'</h2>'.&mt('Thank you!'));
94: } else {
95: $r->print('<h2>'.&mt('Warning: Report not submitted').'</h2>'.
1.15 bisitz 96: '<span class="LC_error">'
97: .&mt('The administrators of the domain [_1] have not set'
98: .' any e-mail addresses for receipt of your error report.'
99: ,'<tt>'.$defdom.'</tt>')
100: .'</span>');
1.13 raeburn 101: }
1.8 www 102: } else {
103: # ------------------------------------------------------------- Get environment
104: my $envkey;
105: my $env='';
106: my $syllabus='';
107:
108: foreach $envkey (sort(keys(%env))) {
109: $env.="$envkey: $env{$envkey}\n";
110: }
111: foreach $envkey (sort(keys(%ENV))) {
112: $env.="$envkey: $ENV{$envkey}\n";
113: if ($envkey=~/REDIRECT\_(REQUEST_URI|SCRIPT|ERROR)/) {
114: $syllabus.="\n$1:\n$ENV{$envkey}";
115: }
116: }
117:
118: $env=~s/\"/\'\'/g;
119:
120: my $version=$r->dir_config('lonVersion');
121:
122: # ----------------------------------------------------------- Print error form
1.15 bisitz 123: $r->print('<h2 class="LC_error">'
124: .&mt('Somewhere something went wrong')
125: .'</h2>'
126: .'<p>'.&mt('Please help us to find out what.').'</p>'
127: .'<p>'.&mt('Please take a moment to fill out the form below.').' '
128: .&mt('Your information, together with internal debugging information, '
129: .'will be emailed to the system and server administrators.')
130: .'</p>
1.8 www 131: <form action="/adm/errorhandler" method="post">
1.13 raeburn 132: <h3>'.&mt('Please describe what you did just before this screen came up').'</h3>
1.8 www 133: <textarea name="prioraction" cols="50" rows="5">
1.2 www 134: </textarea>
1.13 raeburn 135: <h3>'.&mt('Is this problem reproducible?').'</h3>
1.8 www 136: <label>
1.13 raeburn 137: <input type="checkbox" name="reproducible" value="yes" /> '.&mt('Yes!').'
1.8 www 138: </label>
1.13 raeburn 139: <h3>'.&mt('Do you have any guesses why this might have happened?').'</h3>
1.8 www 140: <textarea name="guesses" cols="50" rows="5">
1.2 www 141: </textarea>
1.13 raeburn 142: <input type="hidden" name="version" value="'.$version.'" />
143: <input type="hidden" name="environment" value="'.$env.'" />
144: <input type="hidden" name="syllabus" value="'.$syllabus.'" />
1.8 www 145: <input type="hidden" name="sendinfo" value="1" />
146: <p>
1.18 schafran 147: <input type="submit" title="Send Information" value="'.&mt('Send').'" />
1.8 www 148: </p>
1.2 www 149: </form>
1.13 raeburn 150: <h1>'.&mt('Thank you for your help!').'</h1>
1.15 bisitz 151: <div><font size="-1">
1.13 raeburn 152: '.&mt('Internal info:').
1.15 bisitz 153: '<pre>'.
1.13 raeburn 154: $syllabus.'
1.8 www 155: </pre>
1.15 bisitz 156: </font></div>
1.13 raeburn 157: ');
1.2 www 158: # -------------------------- Better terminate this in case something was sticky
1.9 albertel 159:
1.8 www 160: $r->child_terminate();
161: }
1.10 albertel 162: $r->print(&Apache::loncommon::end_page());
1.1 www 163: return OK;
1.13 raeburn 164: }
1.1 www 165:
166: 1;
167: __END__
1.20 ! jms 168:
! 169:
! 170: =pod
! 171:
! 172: =head1 NAME
! 173:
! 174: Apache::lonerrorhandler.pm
! 175:
! 176: =head1 SYNOPSIS
! 177:
! 178: Handles errors.
! 179:
! 180: This is part of the LearningOnline Network with CAPA project
! 181: described at http://www.lon-capa.org.
! 182:
! 183: =head1 OVERVIEW
! 184:
! 185: None
! 186:
! 187: =cut
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>