Changeset 23605
- Timestamp:
- 11/14/08 07:49:30 (5 years ago)
- Files:
-
- 1 modified
-
lang/perl/MENTA/trunk/lib/MENTA.pm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/MENTA/trunk/lib/MENTA.pm
r23604 r23605 40 40 while ( my ($package, $filename, $line,) = caller($i) ) { 41 41 last if $filename eq 'bin/cgi-server.pl'; 42 push @trace, {level => $i, package => $package, filename => $filename, line => $line}; 42 my $context = sub { 43 my ( $file, $linenum ) = @_; 44 my $code; 45 if ( -f $file ) { 46 my $start = $linenum - 3; 47 my $end = $linenum + 3; 48 $start = $start < 1 ? 1 : $start; 49 open my $fh, '<:utf8', $file or die "エラー画面表示用に ${file} を開こうとしたのに開けません: $!"; 50 my $cur_line = 0; 51 while ( my $line = <$fh> ) { 52 ++$cur_line; 53 last if $cur_line > $end; 54 next if $cur_line < $start; 55 my @tag = 56 $cur_line == $linenum 57 ? (q{<b style="color: #000;background-color: #f99;">}, '</b>') 58 : ( '', '' ); 59 $code .= sprintf( '%s%5d: %s%s', 60 $tag[0], $cur_line, 61 escape_html($line), 62 $tag[1], ); 63 } 64 close $file; 65 } 66 return $code; 67 }->($filename, $line); 68 push @trace, {level => $i, package => $package, filename => $filename, line => $line, context => $context }; 43 69 $i++; 44 70 } … … 107 133 my $out = qq{<!doctype html><title>INTERNAL SERVER ERROR!!! HACKED BY MENTA</title><body style="background: red; color: white; font-weight: bold"><marquee behavior="alternate" scrolldelay="66" style="text-transform: uppercase"><span style="font-size: xx-large; color: black">☠</span> <span style="color: green">500</span> Internal Server Error <span style="font-size: xx-large; color: black">☠</span></marquee><p><span style="color: blue">$msg</span></p><ol>}; 108 134 for my $stack (@{$err->{trace}}) { 109 $out .= '<li>' . escape_html(join(', ', $stack->{package}, $stack->{filename}, $stack->{line})) . '</li>'; 135 $out .= '<li>' . escape_html(join(', ', $stack->{package}, $stack->{filename}, $stack->{line})) 136 . qq(<pre style="background-color: #fee;color: #333;">$stack->{context}</pre></li>); 110 137 } 111 138 $out .= qq{</ol><p style="text-align: right; color: black"><strong>Regards,<br>MENTA</strong></p>\n};
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)