File:  [LON-CAPA] / loncom / interface / lonerrorhandler.pm
Revision 1.10: download - view: text, annotated - select for diffs
Tue Mar 21 18:33:39 2006 UTC (18 years, 2 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
- some end_page improvements

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

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