File:
[LON-CAPA] /
loncom /
interface /
lonerrorhandler.pm
Revision
1.24:
download - view:
text,
annotated -
select for diffs
Mon Aug 12 16:51:58 2013 UTC (11 years ago) by
raeburn
Branches:
MAIN
CVS tags:
version_2_12_X,
version_2_11_X,
version_2_11_5_msu,
version_2_11_5,
version_2_11_4_uiuc,
version_2_11_4_msu,
version_2_11_4,
version_2_11_3_uiuc,
version_2_11_3_msu,
version_2_11_3,
version_2_11_2_uiuc,
version_2_11_2_msu,
version_2_11_2_educog,
version_2_11_2,
version_2_11_1,
version_2_11_0_RC3,
version_2_11_0_RC2,
version_2_11_0_RC1,
version_2_11_0,
HEAD
- Domain Configuration (Contacts)
- Enable/Disable e-mail sent to LON-CAPA when:
(a) error form is submitted
(b) domain defaults (authentication type or language) are changed.
- E-mail recipient can be specified when bi-nightly searchcat.pl detects
situation where a student/employeeID is used for more than one user in
server's domain.
1: # The LearningOnline Network
2: # Internal Server Error Handler
3: #
4: # $Id: lonerrorhandler.pm,v 1.24 2013/08/12 16:51:58 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:
30:
31: package Apache::lonerrorhandler;
32:
33: use strict;
34: use Apache::Constants qw(:common);
35: use Apache::loncommon();
36: use Apache::lonnet;
37: use Apache::lonmsg();
38: use Apache::lonacc();
39: use Apache::lonlocal;
40:
41: sub handler {
42: my $r = shift;
43: &Apache::loncommon::content_type($r,'text/html');
44: $r->send_http_header;
45: return OK if $r->header_only;
46:
47: &Apache::lonacc::get_posted_cgi($r);
48: if (!$Apache::lonlocal::lh) {
49: &Apache::lonlocal::get_language_handle($r);
50: }
51: my $title = $env{'form.sendinfo'} ? 'Sending Error Report'
52: : 'Could Not Process Request';
53: $r->print(&Apache::loncommon::start_page($title));
54:
55: if ($env{'form.sendinfo'}) {
56: my $repro='no';
57: # ------------------------------------------------------------------ Mail stuff
58: if ($env{'form.reproducible'}) {
59: $repro='yes';
60: }
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: );
70: my $message=(<<ENDMESSAGE);
71: $lt{'msg'}
72: $lt{'rep'}: $repro
73: $lt{'ver'}: $env{'form.version'}
74: $lt{'syl'}:
75: $env{'form.syllabus'}
76:
77: $lt{'pri'}:
78: $env{'form.prioraction'}
79:
80: $lt{'gue'}:
81: $env{'form.guesses'}
82:
83: $lt{'env'}:
84: $env{'form.environment'}
85: ENDMESSAGE
86: my $defdom = $r->dir_config('lonDefDomain');
87: my $sysmail;
88: my $notify = 1;
89: my %domconfig = &Apache::lonnet::get_dom('configuration',['contacts']);
90: if (ref($domconfig{'contacts'}) eq 'HASH') {
91: if ($domconfig{'contacts'}{'reporterrors'} == 0) {
92: $notify = 0;
93: }
94: }
95: if ($notify) {
96: $sysmail = 'errorrecord@loncapa.org';
97: }
98: my $origmail = $r->dir_config('lonAdmEMail');
99: my $recipients = &Apache::loncommon::build_recipient_list($sysmail,
100: 'errormail',$defdom,$origmail);
101: if ($recipients ne '') {
102: &Apache::lonmsg::sendemail($recipients,'ERROR REPORT',$message);
103: $r->print('<h2>'.&mt('Report submitted').'</h2>'.&mt('Thank you!'));
104: } else {
105: $r->print('<h2>'.&mt('Warning: Report not submitted').'</h2>'.
106: '<span class="LC_error">'
107: .&mt('The administrators of the domain [_1] have not set'
108: .' any e-mail addresses for receipt of your error report.'
109: ,'<tt>'.$defdom.'</tt>')
110: .'</span>');
111: }
112: } else {
113: # ------------------------------------------------------------- Get environment
114: my $envkey;
115: my $env='';
116: my $syllabus='';
117:
118: foreach $envkey (keys(%env)) {
119: if ($envkey =~ /^form\.(.+)\.filename$/) {
120: my $item = $1;
121: if (exists($env{'form.'.$item.'.mimetype'})) {
122: if (exists($env{'form.'.$item})) {
123: my $size = (length($env{'form.'.$item}))/(1024.0 * 1024.0);
124: $env{'form.'.$item} = &mt('File (contents not shown) - size was [_1] MB.',sprintf("%.4f",$size));
125: }
126: }
127: }
128: }
129:
130: foreach $envkey (sort(keys(%env))) {
131: $env.="$envkey: $env{$envkey}\n";
132: }
133: foreach $envkey (sort(keys(%ENV))) {
134: $env.="$envkey: $ENV{$envkey}\n";
135: if ($envkey=~/REDIRECT\_(REQUEST_URI|SCRIPT|ERROR)/) {
136: $syllabus.="\n$1:\n$ENV{$envkey}";
137: }
138: }
139:
140: $env=~s/\"/\'\'/g;
141:
142: my $version=$r->dir_config('lonVersion');
143:
144: # ----------------------------------------------------------- Print error form
145: $r->print('<h2 class="LC_error">'
146: .&mt('Somewhere something went wrong')
147: .'</h2>'
148: .'<p>'.&mt('Please help us to find out what.').'</p>'
149: .'<p>'.&mt('Please take a moment to fill out the form below.').' '
150: .&mt('Your information, together with internal debugging information, '
151: .'will be e-mailed to the system and server administrators.')
152: .'</p>
153: <form action="/adm/errorhandler" method="post">
154: <h3>'.&mt('Please describe what you did just before this screen came up').'</h3>
155: <textarea name="prioraction" cols="50" rows="5">
156: </textarea>
157: <h3>'.&mt('Is this problem reproducible?').'</h3>
158: <label>
159: <input type="checkbox" name="reproducible" value="yes" /> '.&mt('Yes!').'
160: </label>
161: <h3>'.&mt('Do you have any guesses why this might have happened?').'</h3>
162: <textarea name="guesses" cols="50" rows="5">
163: </textarea>
164: <input type="hidden" name="version" value="'.$version.'" />
165: <input type="hidden" name="environment" value="'.$env.'" />
166: <input type="hidden" name="syllabus" value="'.$syllabus.'" />
167: <input type="hidden" name="sendinfo" value="1" />
168: <p>
169: <input type="submit" title="'.&mt('Send Information').'" value="'.&mt('Send').'" />
170: </p>
171: </form>
172: <h1>'.&mt('Thank you for your help!').'</h1>
173: <div><font size="-1">
174: '.&mt('Internal info:').
175: '<pre>'.
176: $syllabus.'
177: </pre>
178: </font></div>
179: ');
180: # -------------------------- Better terminate this in case something was sticky
181:
182: $r->child_terminate();
183: }
184: $r->print(&Apache::loncommon::end_page());
185: return OK;
186: }
187:
188: 1;
189: __END__
190:
191:
192: =pod
193:
194: =head1 NAME
195:
196: Apache::lonerrorhandler.pm
197:
198: =head1 SYNOPSIS
199:
200: Handles errors.
201:
202: This is part of the LearningOnline Network with CAPA project
203: described at http://www.lon-capa.org.
204:
205: =head1 OVERVIEW
206:
207: None
208:
209: =cut
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>