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

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

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