#!/usr/bin/perl # Declarations #===================================================================== #use warnings; #use strict; use CGI; my %F; my $c = new CGI; foreach($c->param()) { $F{$_} = $c->param($_); } use Syntax::Highlight::Perl; my $color_table = { 'Variable_Scalar' => 'color:#BBBB00;', 'Variable_Array' => 'color:#f70;', 'Variable_Hash' => 'color:#80f;', 'Variable_Typeglob' => 'color:#f03;', 'Subroutine' => 'color:#980;', 'Quote' => 'color:#BB0000;', 'String' => 'color:#BB0000;', #'Comment_Normal' => 'color:#069;font-style:italic;', 'Comment_Normal' => 'color:#00BB00;font-style:bold', 'Comment_POD' => 'color:#014;font-family:' . 'garamond,serif;font-size:11pt;', 'Bareword' => 'color:#3A3;', 'Package' => 'color:#900;', 'Number' => 'color:#f0f;', 'Operator' => 'color:#ffffff;', 'Symbol' => 'color:#ffffff;', 'Keyword' => 'color:#0000BB;', 'Builtin_Operator' => 'color:#BB00BB;', 'Builtin_Function' => 'color:#001;', 'Character' => 'color:#BB0000;', 'Directive' => 'color:#399;font-style:regular;', 'Label' => 'color:#939;font-style:regular;', 'Line' => 'color:#ffffff;', }; # Program proper #===================================================================== my $formatter = Syntax::Highlight::Perl->new(); $formatter->define_substitution('<' => '<', '>' => '>', '&' => '&'); # HTML escapes. # install the formats set up above while ( my ( $type, $style ) = each %{$color_table} ) { $formatter->set_format($type, [ qq||, '' ] ); } #my $file = shift || die "Give me a perl file to colorize!\n"; # print "Content-Type: text/html\n\n"; my $file = $F{file}; if($file =~ /\.\.|\/|\;/) { print "FUCK YOU!\n"; exit; } if(!$file || ! -e $file) { print "There's no such file: $file\n"; exit; } open F, '<', $file or die $!; print '
'; #print ''; while ("; close F; exit 0;) { print $formatter->format_string; } #print "