File:  [LON-CAPA] / loncom / interface / lonerrorhandler.pm
Revision 1.19: download - view: text, annotated - select for diffs
Tue Nov 18 19:14:22 2008 UTC (15 years, 7 months ago) by jms
Branches: MAIN
CVS tags: HEAD
Added/updated/converted POD. Many files had their POD redone to new standards.

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

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