home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.pdx.edu
/
2014.03.ftp.cs.pdx.edu.tar
/
ftp.cs.pdx.edu
/
stash
/
CGI_WEB
/
my_list.cgi
< prev
next >
Wrap
Text File
|
1999-04-06
|
973b
|
43 lines
#! /usr/bin/perl
#
# CGI Script for displaying the contents of a file.
#
# Version 1.0, 03/99
# Author Matthias Lampe, lampe@cs.pdx.edu
#
# The scripts takes the name of the file as a parameter and simply
# displays the content of the file.
#
# PARAMETERS:
# file
#
use CGI #qw(:standard); # include CGI library
$f = CGI->new; # create new CGI instance
print $f->header("text/plain"); # print HTTP header
$file = $f->param("file"); # read parameter
$file="list.cgi";
#--- just allow to read files in directory of script or
# subdirectories, i.e. '.' or '/' are not allowed as
# first characters in filename
if ($file =~ /^[.\/]/)
{
print("Illegal filename $file.");
die("Illegal filename $file.\n");
}
#--- open file or die if file not found
open(FILE_HANDLE, $file) || (print("Error opening file $file: $!")
&& die("Error opening file $file: $!\n"));
#--- read content of file
while ($line = <FILE_HANDLE>)
{
print $line;
}
close(FILE_HANDLE);