#!/usr/bin/perl
############################################
## ##
## WebLibs ##
## by Darryl Burgdorf ##
## (e-mail burgdorf@awsd.com) ##
## ##
## last modified: 6/7/97 ##
## copyright (c) 1997 ##
## ##
## latest version is available from ##
## http://awsd.com/scripts/ ##
## ##
############################################
# COPYRIGHT NOTICE:
#
# Copyright 1997 Darryl C. Burgdorf. All Rights Reserved.
#
# This program may be used and modified free of charge by anyone, so
# long as this copyright notice and the header above remain intact. By
# using this program you agree to indemnify Darryl C. Burgdorf from any
# liability.
#
# Selling the code for this program without prior written consent is
# expressly forbidden. Obtain permission before redistributing this
# program over the Internet or in any other medium. In all cases
# copyright and header must remain intact.
# VERSION HISTORY:
#
# 1.00 06/07/97 Initial "public" release
$InputFile = "input.txt";
$TextFile = "goodfile.txt";
$CGIURL = "weblibs.pl";
print "Content-type: text/html\n\n";
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs){
($name, $value) = split(/=/, $pair);
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
if ($FORM{$name}) {
$FORM{$name} = "$FORM{$name}, $value";
}
else {
$FORM{$name} = $value;
push (@variables,$name);
}
}
if ($FORM{'TextFile'}) { &SendFile; }
if (-d $TextFile) {
opendir(FILES,$TextFile);
@tempfiles = readdir(FILES);
closedir(FILES);
foreach $file (@tempfiles) {
if (-T "$TextFile/$file") {
push (@files, $file);
}
}
srand();
$files = @files;
$file = @files[int(rand($files))];
$TextFile = $TextFile."/".$file;
}
open (FILE,"$TextFile");
@LINES =
\n"; print "
\n"; } else { print $line; } } exit; sub SendFile { open (FILE,"$FORM{'TextFile'}"); @LINES =