1: # The LearningOnline Network with CAPA
2: # A debugging harness.
3: #
4: # $Id: lontest.pm,v 1.4 2002/06/13 17:54:04 bowersj2 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:
35: # section takes one env var name as input, and returns
36: # what section the given env var is in, which is the part
37: # of the env var before the first period.
38: # Returns the section, or blank string for 'no section',
39: # which is normal for the standard ENV vars like REQUEST_URI.
40: sub section
41: {
42: my ($name) = @_;
43: return $1 if $name =~ m/\A([^.]*)\./;
44: return '';
45: }
46:
47: sub handler {
48: my $r = shift;
49: $r->content_type('text/html');
50: $r->send_http_header;
51: return OK if $r->header_only;
52:
53: $r->print('<html><body>');
54:
55: my $envkey;
56:
57: $->print("<hr><h1>Debugging</h1><hr>\n");
58: $->print("<font face='Courier'>");
59:
60: my $i=0;
61: my $interval = 20; # change this to change how many keys/table
62: my $prevSection = ''; # keeps track of the section we're in.
63: foreach $envkey (sort keys %ENV) {
64: if (not ($i % $interval))
65: {
66: $r->print('</table>') unless $i eq 0;
67: $r->print('<table border="0">')
68: }
69: my $sec = section($envkey);
70:
71: if ($prevSection ne $sec) # new section, print header
72: {
73: $r->print('<tr><td colspan="2">');
74: $r->print("<br><br><h2 style='color: #008800'><u>$sec</u></h2>");
75: $r->print('</td></tr>');
76: $prevSection = $sec;
77: }
78:
79: my $envVal = $ENV{$envkey};
80: $envVal =~ s/(.{50})/\1\<wbr\>/g;
81: $envkey =~ s/(.{30})/\1\<wbr\>/g;
82:
83: $r->print("<tr><td valign='top'><b>$envkey</b></td>");
84: $r->print("<td valign='top'>$envVal</td></tr>\n");
85: $i++;
86: }
87:
88: $r->print('</table></font><h1>Total Number of Elements: '.$i.'</h1>');
89:
90: # ------------------------------------------------------------------- End Debug
91: $r->print('</body></html>');
92: }
93:
94:
95: 1;
96: __END__
97:
98:
99:
100:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>