File:  [LON-CAPA] / loncom / interface / lonerrorhandler.pm
Revision 1.14: download - view: text, annotated - select for diffs
Tue Dec 4 04:43:21 2007 UTC (16 years, 5 months ago) by raeburn
Branches: MAIN
CVS tags: version_2_6_X, version_2_6_99_1, version_2_6_99_0, version_2_6_3, version_2_6_2, version_2_6_1, version_2_6_0, version_2_5_99_1, HEAD
- Make loncommon::build_recipient_list() more generally applicable.
- Eliminate duplicate addresses in recipient list
- Use loncommon::build_recipient_list() to provide recipient email list for
  help support form and package update alerts.

    1: # The LearningOnline Network
    2: # Internal Server Error Handler
    3: #
    4: # $Id: lonerrorhandler.pm,v 1.14 2007/12/04 04:43:21 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: 
   47:     my $title = $env{'form.sendinfo'} ? 'Sending Error Report'
   48:                                       : 'Could Not Process Request';
   49:     $r->print(&Apache::loncommon::start_page($title));
   50: 
   51:     if ($env{'form.sendinfo'}) {
   52: 	my $repro='no';
   53: # ------------------------------------------------------------------ Mail stuff
   54: 	if ($env{'form.reproducible'}) {
   55: 	    $repro='yes';
   56: 	}
   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:                  );
   66: 	my $message=(<<ENDMESSAGE);
   67: $lt{'msg'}
   68: $lt{'rep'}: $repro
   69: $lt{'ver'}: $env{'form.version'}
   70: $lt{'syl'}:
   71: $env{'form.syllabus'}
   72: 
   73: $lt{'pri'}:
   74: $env{'form.prioraction'}
   75: 
   76: $lt{'gue'}:
   77: $env{'form.guesses'}
   78: 
   79: $lt{'env'}:
   80: $env{'form.environment'}
   81: ENDMESSAGE
   82:         my $sysmail = $r->dir_config('lonSysEMail');
   83:         my $defdom = $r->dir_config('lonDefDomain');
   84:         my $origmail = $r->dir_config('lonAdmEMail');
   85:         my $recipients = &Apache::loncommon::build_recipient_list($sysmail,
   86:                                              'errormail',$defdom,$origmail);
   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>'.
   92:                       '<span class="LC_error">'.&mt("The administrators of
   93:                       the domain ($defdom) have not set any e-mail addresses
   94:                       for receipt of your error report.").'</span>');
   95:         }
   96:     } else {
   97: # ------------------------------------------------------------- Get environment
   98: 	my $envkey;
   99: 	my $env='';
  100: 	my $syllabus='';
  101: 
  102: 	foreach $envkey (sort(keys(%env))) {
  103: 	    $env.="$envkey: $env{$envkey}\n";
  104: 	}
  105: 	foreach $envkey (sort(keys(%ENV))) {
  106: 	    $env.="$envkey: $ENV{$envkey}\n";
  107: 	    if ($envkey=~/REDIRECT\_(REQUEST_URI|SCRIPT|ERROR)/) {
  108: 		$syllabus.="\n$1:\n$ENV{$envkey}";
  109: 	    }
  110: 	}
  111: 
  112: 	$env=~s/\"/\'\'/g;
  113: 
  114: 	my $version=$r->dir_config('lonVersion');
  115: 
  116: # ----------------------------------------------------------- Print error form
  117: 	$r->print('<h2>'.
  118: &mt('Somewhere something went wrong - please help us to find out what.').'</h2>'.
  119: &mt('Please take a moment to fill out the form below.').' '.&mt('Your information,
  120:  together with internal debugging information, will be emailed to the system and 
  121: server administrators.').'
  122: <form action="/adm/errorhandler" method="post">
  123: <input type="submit" value="'.&mt('Send Information').'" />
  124: <h3>'.&mt('Please describe what you did just before this screen came up').'</h3>
  125: <textarea name="prioraction" cols="50" rows="5">
  126: </textarea>
  127: <h3>'.&mt('Is this problem reproducible?').'</h3>
  128: <label>
  129: <input type="checkbox" name="reproducible" value="yes" /> '.&mt('Yes!').'
  130: </label>
  131: <h3>'.&mt('Do you have any guesses why this might have happened?').'</h3>
  132: <textarea name="guesses" cols="50" rows="5">
  133: </textarea>
  134: <input type="hidden" name="version" value="'.$version.'" />
  135: <input type="hidden" name="environment" value="'.$env.'" />
  136: <input type="hidden" name="syllabus" value="'.$syllabus.'" />
  137: <input type="hidden" name="sendinfo" value="1" />
  138: <p>
  139: <input type="submit" value="'.&mt('Send Information').'" />
  140: </p>
  141: </form>
  142: <h1>'.&mt('Thank you for your help!').'</h1>
  143: <font size="-1">
  144: <pre>
  145: '.&mt('Internal info:').
  146: $syllabus.'
  147: </pre>
  148: </font>
  149: ');
  150: # -------------------------- Better terminate this in case something was sticky
  151: 
  152:         $r->child_terminate();
  153:     }
  154:     $r->print(&Apache::loncommon::end_page());
  155:     return OK;
  156: }
  157: 
  158: 1;
  159: __END__

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