#!c:/perl/bin/perl -w $|++; use strict; use CGI::Simple; use HTML::Template; my $q = CGI::Simple->new; my $t = HTML::Template->new( filehandle => *DATA ); my @ext = qw( pl css htm html shtm shtml ); my $file = $q->param('file'); my $fh; if ( ($file =~ /[^a-zA-Z0-9_\-\.]/) or ($file =~ /\.\./) or ($file eq '.') or !(grep { $file =~ /\.$_\z/i } @ext) !(-e $file) or !(open $fh, '<', $file) or ) { $t->param( title => 'My File Viewer', file => 'Script Error', code => 'An error occured while preparing the file for display.' ); } else { $t->param( title => 'My File Viewer', file => $file, code => do { local $/; <$fh> } ); } print $q->header, $t->output; exit; __DATA__ Pekkhum's Script Veiwer


© Copyright 2003 Nathan Bessette