Annotation of loncom/interface/lonerrorhandler.pm, revision 1.15

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>