File:  [LON-CAPA] / loncom / interface / lonerrorhandler.pm
Revision 1.12: download - view: text, annotated - select for diffs
Sat Sep 2 20:49:20 2006 UTC (17 years, 8 months ago) by albertel
Branches: MAIN
CVS tags: version_2_5_X, version_2_5_99_0, version_2_5_2, version_2_5_1, version_2_5_0, version_2_4_X, version_2_4_99_0, version_2_4_2, version_2_4_1, version_2_4_0, version_2_3_X, version_2_3_99_0, version_2_3_2, version_2_3_1, version_2_3_0, version_2_2_99_1, version_2_2_99_0, HEAD
- xhtml

    1: # The LearningOnline Network
    2: # Internal Server Error Handler
    3: #
    4: # $Id: lonerrorhandler.pm,v 1.12 2006/09/02 20:49:20 albertel 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: 
   38: sub handler {
   39:     my $r = shift;
   40:     &Apache::loncommon::content_type($r,'text/html');
   41:     $r->send_http_header;
   42:     return OK if $r->header_only;
   43: 
   44:     &Apache::lonacc::get_posted_cgi($r);
   45: 
   46:     my $title = $env{'form.sendinfo'} ? 'Sending Error Report'
   47:                                       : 'Could Not Process Request';
   48:     $r->print(&Apache::loncommon::start_page($title));
   49: 
   50:     if ($env{'form.sendinfo'}) {
   51: 	my $repro='no';
   52: # ------------------------------------------------------------------ Mail stuff
   53: 	if ($env{'form.reproducible'}) {
   54: 	    $repro='yes';
   55: 	}
   56: 	my $message=(<<ENDMESSAGE);
   57: LON-CAPA Error Message
   58: Reproducible: $repro
   59: Version: $env{'form.version'}
   60: Syllabus:
   61: $env{'form.syllabus'}
   62: 
   63: Prior Action:
   64: $env{'form.prioraction'}
   65: 
   66: Guesses:
   67: $env{'form.guesses'}
   68: 
   69: Environment:
   70: $env{'form.environment'}
   71: ENDMESSAGE
   72: 	my $recipients=$r->dir_config('lonAdmEMail').','.
   73: 	    $r->dir_config('lonSysEMail'); 
   74: 
   75:         &Apache::lonmsg::sendemail($recipients,'ERROR REPORT',$message);
   76: 	$r->print('<h2>Report submitted</h2>Thank you!');
   77:     } else {
   78: # ------------------------------------------------------------- Get environment
   79: 	my $envkey;
   80: 	my $env='';
   81: 	my $syllabus='';
   82: 
   83: 	foreach $envkey (sort(keys(%env))) {
   84: 	    $env.="$envkey: $env{$envkey}\n";
   85: 	}
   86: 	foreach $envkey (sort(keys(%ENV))) {
   87: 	    $env.="$envkey: $ENV{$envkey}\n";
   88: 	    if ($envkey=~/REDIRECT\_(REQUEST_URI|SCRIPT|ERROR)/) {
   89: 		$syllabus.="\n$1:\n$ENV{$envkey}";
   90: 	    }
   91: 	}
   92: 
   93: 	$env=~s/\"/\'\'/g;
   94: 
   95: 	my $version=$r->dir_config('lonVersion');
   96: 
   97: # ----------------------------------------------------------- Print error form
   98: 	$r->print(<<ENDDOCUMENT);
   99: <h2>Somewhere something went wrong - please help us to find out what.</h2>
  100: Please take a moment to fill out the form below. Your information, together
  101: with internal debugging information, will be emailed to the system and server
  102: administrators.
  103: <form action="/adm/errorhandler" method="post">
  104: <input type="submit" value="Send Information" />
  105: <h3>Please describe what you did just before this screen came up</h3>
  106: <textarea name="prioraction" cols="50" rows="5">
  107: </textarea>
  108: <h3>Is this problem reproducible?</h3>
  109: <label>
  110: <input type="checkbox" name="reproducible" value="yes" /> Yes!
  111: </label>
  112: <h3>Do you have any guesses why this might have happened?</h3>
  113: <textarea name="guesses" cols="50" rows="5">
  114: </textarea>
  115: <input type="hidden" name="version" value="$version" />
  116: <input type="hidden" name="environment" value="$env" />
  117: <input type="hidden" name="syllabus" value="$syllabus" />
  118: <input type="hidden" name="sendinfo" value="1" />
  119: <p>
  120: <input type="submit" value="Send Information" />
  121: </p>
  122: </form>
  123: <h1>Thank you for your help!</h1>
  124: <font size="-1">
  125: <pre>
  126: Internal info:
  127: $syllabus
  128: </pre>
  129: </font>
  130: ENDDOCUMENT
  131: # -------------------------- Better terminate this in case something was sticky
  132: 
  133:         $r->child_terminate();
  134:     }
  135:     $r->print(&Apache::loncommon::end_page());
  136:     return OK;
  137: } 
  138: 
  139: 1;
  140: __END__

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