File:
[LON-CAPA] /
loncom /
interface /
lonerrorhandler.pm
Revision
1.16:
download - view:
text,
annotated -
select for diffs
Sat Oct 4 00:09:18 2008 UTC (15 years, 8 months ago) by
raeburn
Branches:
MAIN
CVS tags:
HEAD
Bug 5604.
- resetpw.pm : move call to loncommon::start_page() so it occurs after call
to lonlocal::get_language_handle().
- lonerrorhandler.pm : Need to call lonlocal::get_language_handle() for cases where
errors occur on pages which don't use PerlAuthzHandler lonacc.
1: # The LearningOnline Network
2: # Internal Server Error Handler
3: #
4: # $Id: lonerrorhandler.pm,v 1.16 2008/10/04 00:09:18 raeburn Exp $
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: #
28:
29: package Apache::lonerrorhandler;
30:
31: use strict;
32: use Apache::Constants qw(:common);
33: use Apache::loncommon();
34: use Apache::lonnet;
35: use Apache::lonmsg();
36: use Apache::lonacc();
37: use Apache::lonlocal;
38:
39: sub handler {
40: my $r = shift;
41: &Apache::loncommon::content_type($r,'text/html');
42: $r->send_http_header;
43: return OK if $r->header_only;
44:
45: &Apache::lonacc::get_posted_cgi($r);
46: if (!$lh) {
47: &Apache::lonlocal::get_language_handle($r);
48: }
49: my $title = $env{'form.sendinfo'} ? 'Sending Error Report'
50: : 'Could Not Process Request';
51: $r->print(&Apache::loncommon::start_page($title));
52:
53: if ($env{'form.sendinfo'}) {
54: my $repro='no';
55: # ------------------------------------------------------------------ Mail stuff
56: if ($env{'form.reproducible'}) {
57: $repro='yes';
58: }
59: my %lt = &Apache::lonlocal::texthash (
60: msg => 'LON-CAPA Error Message',
61: rep => 'Reproducible',
62: ver => 'Version',
63: syl => 'Syllabus',
64: pri => 'Prior Action',
65: gue => 'Guesses',
66: env => 'Environment',
67: );
68: my $message=(<<ENDMESSAGE);
69: $lt{'msg'}
70: $lt{'rep'}: $repro
71: $lt{'ver'}: $env{'form.version'}
72: $lt{'syl'}:
73: $env{'form.syllabus'}
74:
75: $lt{'pri'}:
76: $env{'form.prioraction'}
77:
78: $lt{'gue'}:
79: $env{'form.guesses'}
80:
81: $lt{'env'}:
82: $env{'form.environment'}
83: ENDMESSAGE
84: my $sysmail = $r->dir_config('lonSysEMail');
85: my $defdom = $r->dir_config('lonDefDomain');
86: my $origmail = $r->dir_config('lonAdmEMail');
87: my $recipients = &Apache::loncommon::build_recipient_list($sysmail,
88: 'errormail',$defdom,$origmail);
89: if ($recipients ne '') {
90: &Apache::lonmsg::sendemail($recipients,'ERROR REPORT',$message);
91: $r->print('<h2>'.&mt('Report submitted').'</h2>'.&mt('Thank you!'));
92: } else {
93: $r->print('<h2>'.&mt('Warning: Report not submitted').'</h2>'.
94: '<span class="LC_error">'
95: .&mt('The administrators of the domain [_1] have not set'
96: .' any e-mail addresses for receipt of your error report.'
97: ,'<tt>'.$defdom.'</tt>')
98: .'</span>');
99: }
100: } else {
101: # ------------------------------------------------------------- Get environment
102: my $envkey;
103: my $env='';
104: my $syllabus='';
105:
106: foreach $envkey (sort(keys(%env))) {
107: $env.="$envkey: $env{$envkey}\n";
108: }
109: foreach $envkey (sort(keys(%ENV))) {
110: $env.="$envkey: $ENV{$envkey}\n";
111: if ($envkey=~/REDIRECT\_(REQUEST_URI|SCRIPT|ERROR)/) {
112: $syllabus.="\n$1:\n$ENV{$envkey}";
113: }
114: }
115:
116: $env=~s/\"/\'\'/g;
117:
118: my $version=$r->dir_config('lonVersion');
119:
120: # ----------------------------------------------------------- Print error form
121: $r->print('<h2 class="LC_error">'
122: .&mt('Somewhere something went wrong')
123: .'</h2>'
124: .'<p>'.&mt('Please help us to find out what.').'</p>'
125: .'<p>'.&mt('Please take a moment to fill out the form below.').' '
126: .&mt('Your information, together with internal debugging information, '
127: .'will be emailed to the system and server administrators.')
128: .'</p>
129: <form action="/adm/errorhandler" method="post">
130: <h3>'.&mt('Please describe what you did just before this screen came up').'</h3>
131: <textarea name="prioraction" cols="50" rows="5">
132: </textarea>
133: <h3>'.&mt('Is this problem reproducible?').'</h3>
134: <label>
135: <input type="checkbox" name="reproducible" value="yes" /> '.&mt('Yes!').'
136: </label>
137: <h3>'.&mt('Do you have any guesses why this might have happened?').'</h3>
138: <textarea name="guesses" cols="50" rows="5">
139: </textarea>
140: <input type="hidden" name="version" value="'.$version.'" />
141: <input type="hidden" name="environment" value="'.$env.'" />
142: <input type="hidden" name="syllabus" value="'.$syllabus.'" />
143: <input type="hidden" name="sendinfo" value="1" />
144: <p>
145: <input type="submit" value="'.&mt('Send Information').'" />
146: </p>
147: </form>
148: <h1>'.&mt('Thank you for your help!').'</h1>
149: <div><font size="-1">
150: '.&mt('Internal info:').
151: '<pre>'.
152: $syllabus.'
153: </pre>
154: </font></div>
155: ');
156: # -------------------------- Better terminate this in case something was sticky
157:
158: $r->child_terminate();
159: }
160: $r->print(&Apache::loncommon::end_page());
161: return OK;
162: }
163:
164: 1;
165: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>