File:  [LON-CAPA] / loncom / interface / lontest.pm
Revision 1.19: download - view: text, annotated - select for diffs
Sun Mar 19 21:54:41 2006 UTC (18 years, 2 months ago) by albertel
Branches: MAIN
CVS tags: version_2_8_X, version_2_8_2, version_2_8_1, version_2_8_0, version_2_7_X, version_2_7_99_1, version_2_7_99_0, version_2_7_1, version_2_7_0, 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_X, version_2_5_99_1, 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_X, version_2_2_99_1, version_2_2_99_0, version_2_2_2, version_2_2_1, version_2_2_0, version_2_1_99_3, version_2_1_99_2, version_2_1_99_1, version_2_1_99_0, HEAD, GCI_1
-elimintaing some use of &bodytag in favor of &start_page instead

    1: # The LearningOnline Network with CAPA
    2: # A debugging harness.
    3: #
    4: # $Id: lontest.pm,v 1.19 2006/03/19 21:54:41 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: 
   30: package Apache::lontest;
   31: 
   32: use strict;
   33: use Apache::Constants qw(:common :http);
   34: use GDBM_File;
   35: use Apache::loncommon;
   36: use Apache::lonnet;
   37: 
   38: # section takes one env var name as input, and returns
   39: # what section the given env var is in, which is the part
   40: # of the env var before the first period.
   41: # Returns the section, or blank string for 'no section',
   42: # which is normal for the standard env vars like REQUEST_URI.
   43: sub section
   44: {
   45:     my ($name) = @_;
   46:     return $1 if $name =~ m/\A([^.]*)\./;
   47:     return '';
   48: }
   49: 
   50: sub print_hash {
   51:     my ($r,$hash)=@_;
   52:     my $i=0;
   53:     my $interval = 20; # change this to change how many keys/table
   54:     my $prevSection = ''; # keeps track of the section we're in.
   55: 
   56:     foreach my $envkey (sort(keys(%{$hash}))) {
   57: 	if (not ($i % $interval)) {
   58: 	    $r->print('</table>') unless $i eq 0;
   59: 	    $r->print('<table border="0">');
   60: 	}
   61: 	my $sec = section($envkey);
   62: 	
   63: 	if ($prevSection ne $sec) { # new section, print header 
   64: 	    $r->print('<tr><td colspan="2">');
   65: 	    $r->print("<br /><br /><h2 style='color: #008800'><u>$sec</u></h2>");
   66: 	    $r->print('</td></tr>');
   67: 	    $prevSection = $sec;
   68: 	}
   69: 
   70: 	my $envVal = $hash->{$envkey};
   71: 	$envVal =~ s/(.{50})/$1\<wbr\>/g;
   72: 	$envkey =~ s/(.{30})/$1\<wbr\>/g;
   73: 	 
   74: 	$r->print("<tr><td valign='top'><b>$envkey</b></td>");
   75: 	$r->print("<td valign='top'>$envVal</td></tr>\n");
   76: 	$i++;
   77:     }
   78: 
   79:     $r->print('</table></font><h1>Total Number of Elements: '.$i.'</h1>');
   80: }
   81: sub handler {
   82:     my $r = shift;
   83:     &Apache::loncommon::content_type($r,'text/html');
   84:     $r->send_http_header;
   85:     return OK if $r->header_only;
   86: 
   87:     $r->print(&Apache::loncommon::start_page("List Environment",undef,
   88: 					     {'function' => 'admin'}));
   89: 
   90:     $r->print("<hr /><h1>Debugging</h1><hr />\n");
   91:     $r->print("<font face='Courier'>");
   92:     $r->print("<hr /><h2>ENV</h2><hr />\n");
   93:     &print_hash($r,\%ENV);
   94:     $r->print("<hr /><h2>env</h2><hr />\n");
   95:     &print_hash($r,\%env);
   96: # ------------------------------------------------ If in a course, print hashes
   97:     if ($env{'request.course.id'}) {
   98: 
   99: 	my %parmhash;
  100: 	my %symbhash;
  101: 	my %hash;
  102: 
  103: 	my $fn=$env{'request.course.fn'};
  104: 
  105: 	if (tie(%hash,'GDBM_File',"$fn.db",&GDBM_READER(),0640)) {
  106: 	    $r->print('<h2>Big Hash</h2>');
  107: 	    foreach (sort keys %hash) {
  108: 		$r->print("\n<br />".$_.': '.$hash{$_});
  109: 	    }
  110: 	    untie %hash;
  111: 	} else {
  112: 	    $r->print('<h2>Count not tie big hash</h2>');
  113: 	}
  114: 	if (tie(%parmhash,'GDBM_File',
  115: 		$env{'request.course.fn'}.'_parms.db',
  116: 		&GDBM_READER(),0640)) {
  117: 	    $r->print('<h2>Parm Hash</h2>');
  118: 	    foreach (sort keys %parmhash) {
  119: 	        $r->print("\n<br />".$_.': '.$parmhash{$_});
  120: 	    }
  121: 	    untie %parmhash;
  122: 	} else {
  123:             $r->print('<h2>Could not tie parmhash</h2>');
  124: 	}
  125: 	if (tie(%symbhash,'GDBM_File',"$fn\_symb.db",&GDBM_READER(),0640)) {
  126:             $r->print('<h2>Symb Hash</h2>');
  127:             foreach (sort keys %symbhash) {
  128: 		$r->print("\n<br />".$_.': '.$symbhash{$_});
  129:             }
  130:             untie %symbhash;
  131: 	} else {
  132:             $r->print('<h2>Could not tie symbhash</h2>');
  133: 	}
  134: 	if (-e $fn.'.state') {
  135: 	    $r->print('<h2>State</h2>');
  136: 	    my @conditions=();
  137: 	    {
  138: 		my $fh=Apache::File->new($fn.'.state');
  139: 		@conditions=<$fh>;
  140: 	    }
  141: 	    foreach (@conditions) {
  142: 		$r->print('<tt>'.$_.'</tt><br />');
  143: 	    }
  144: 	}
  145:     }
  146:  
  147: # ------------------------------------------------------------------- End Debug
  148:      $r->print(&Apache::loncommon::end_page());    
  149:      return OK;
  150:  }
  151: 
  152: 
  153: 1;
  154: __END__
  155: 
  156: 
  157: 
  158: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>
500 Internal Server Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.